Re: [PATCH v1 9/9] exfat: support multi-cluster for exfat_get_cluster
From: Yuezhang.Mo@xxxxxxxx
Date: Sun Jan 04 2026 - 02:57:24 EST
> On 12/30/25 17:06, Yuezhang.Mo@xxxxxxxx wrote:
>>> + /*
>>> + * Return on cache hit to keep the code simple.
>>> + */
>>> + if (fclus == cluster) {
>>> + *count = cid.fcluster + cid.nr_contig - fclus + 1;
>>> return 0;
>>
>> If 'cid.fcluster + cid.nr_contig - fclus + 1 < *count', how about continuing to collect clusters?
>> The following clusters may be continuous.
>
> I'm glad you noticed this detail. It is necessary to explain this and
> update it in the code comments.
>
> The main reason why I didn't continue the collection was that the
> subsequent clusters might also exist in the cache. This requires us to
> search the cache again to confirm this, and this action might introduce
> additional performance overhead.
>
> I think we can continue to collect, but we need to check the cache
> before doing so.
>
So we also need to check the cache in the following, right?
```
/*
* Collect the remaining clusters of this contiguous extent.
*/
if (*dclus != EXFAT_EOF_CLUSTER) {
unsigned int clu = *dclus;
/*
* Now the cid cache contains the first cluster requested,
* Advance the fclus to the last cluster of contiguous
* extent, then update the count and cid cache accordingly.
*/
while (fclus < end) {
if (exfat_ent_get(sb, clu, &content, &bh))
goto err;
if (++clu != content) {
/* TODO: read ahead if content valid */
break;
}
fclus++;
}
cid.nr_contig = fclus - cid.fcluster;
*count = fclus - cluster + 1;
```
>>>
>>> + while (fclus < end) {
>>> + if (exfat_ent_get(sb, clu, &content, &bh))
>>> + goto err;
>>> + if (++clu != content) {
>>> + /* TODO: read ahead if content valid */
>>> + break;
>>
>> The next cluster index has been read and will definitely be used.
>> How about add it to the cache?
>
> Good idea!
> will add it in v2,