Re: [PATCH 2/4] fat: return only first cluster when allocating

From: OGAWA Hirofumi

Date: Mon Oct 12 2026 - 02:03:45 EST


Matheus Alves de Almeida <matheus.aalmeida@xxxxxxxxxxxx> writes:

> Em 2026-10-11 15:57, OGAWA Hirofumi escreveu:
>> Matheus Alves de Almeida <matheus.aalmeida@xxxxxxxxxxxx> writes:
>>
>>> fat_alloc_clusters() returns every allocated cluster number in an array.
>>> For larger allocations, like growing a file, this array would need to be
>>> very large.
>>>
>>> Make fat_alloc_clusters() return only the first allocated cluster in the
>>> chain. Update fat_add_new_entries() to follow the chain when it needs
>>> the second cluster.
>>
>> This would be more common case than fallocate(), so penalize this part
>> would not be good.
>>
>> Thanks.
>
> That makes sense.
>
> I can change the approach so that fat_alloc_clusters() and the directory
> entry path are left unchanged. For fat_add_clusters(), I would add a
> separate fat_alloc_chain() helper which allocates the whole chain but
> only returns the first cluster.
>
> Would that approach be preferable?

Sounds good if both share the almost all codes.

Thanks.
--
OGAWA Hirofumi <hirofumi@xxxxxxxxxxxxxxxxxx>