[RFC PATCH 0/7] Enable exfat_get_block to support obtaining multiple clusters

Chi Zhiling posted 7 patches 1 week, 6 days ago
fs/exfat/cache.c    | 11 ++++--
fs/exfat/exfat_fs.h |  6 ++-
fs/exfat/fatent.c   | 90 ++++++++++++++++++++++++++++++++++++---------
fs/exfat/inode.c    | 14 ++++++-
4 files changed, 97 insertions(+), 24 deletions(-)
[RFC PATCH 0/7] Enable exfat_get_block to support obtaining multiple clusters
Posted by Chi Zhiling 1 week, 6 days ago
From: Chi Zhiling <chizhiling@kylinos.cn>

The purpose of this patchset is to prepare for adapting exfat to iomap
in the future. Currently, the main issue preventing exfat from supporting
iomap is its inability to fetch multiple contiguous clusters.

However, this patchset does not directly modify exfat_map_cluster and
exfat_get_cluster to support multi-clusters. Instead, after obtaining
the first cluster, it uses exfat_count_contig_clusters to retrieve the
subsequent contiguous clusters.

This approach is the one with the fewest changes among all the solutions
I have attempted, making the modifications easier to review.

This patchset includes two main changes: one reduces the number of sb_bread
calls when accessing adjacent clusters to save time, and the other enables
fetching multiple contiguous entries in exfat_get_blocks.

Chi Zhiling (7):
  exfat: add cache option for __exfat_ent_get
  exfat: support reuse buffer head for exfat_ent_get
  exfat: reuse cache to improve exfat_get_cluster
  exfat: improve exfat_count_num_clusters
  exfat: improve exfat_find_last_cluster
  exfat: introduce exfat_count_contig_clusters
  exfat: get mutil-clusters in exfat_get_block

 fs/exfat/cache.c    | 11 ++++--
 fs/exfat/exfat_fs.h |  6 ++-
 fs/exfat/fatent.c   | 90 ++++++++++++++++++++++++++++++++++++---------
 fs/exfat/inode.c    | 14 ++++++-
 4 files changed, 97 insertions(+), 24 deletions(-)

-- 
2.43.0
Re: [RFC PATCH 0/7] Enable exfat_get_block to support obtaining multiple clusters
Posted by Namjae Jeon 1 week, 4 days ago
On Tue, Nov 18, 2025 at 5:26 PM Chi Zhiling <chizhiling@163.com> wrote:
>
> From: Chi Zhiling <chizhiling@kylinos.cn>
Hi Chi,
>
> The purpose of this patchset is to prepare for adapting exfat to iomap
> in the future. Currently, the main issue preventing exfat from supporting
> iomap is its inability to fetch multiple contiguous clusters.
Do you have a plan to work iomap support for exfat ?
>
> However, this patchset does not directly modify exfat_map_cluster and
> exfat_get_cluster to support multi-clusters. Instead, after obtaining
> the first cluster, it uses exfat_count_contig_clusters to retrieve the
> subsequent contiguous clusters.
>
> This approach is the one with the fewest changes among all the solutions
> I have attempted, making the modifications easier to review.
>
> This patchset includes two main changes: one reduces the number of sb_bread
> calls when accessing adjacent clusters to save time, and the other enables
> fetching multiple contiguous entries in exfat_get_blocks.
Are there any performance improvement measurements when applying this patch-set?

Thanks.
>
> Chi Zhiling (7):
>   exfat: add cache option for __exfat_ent_get
>   exfat: support reuse buffer head for exfat_ent_get
>   exfat: reuse cache to improve exfat_get_cluster
>   exfat: improve exfat_count_num_clusters
>   exfat: improve exfat_find_last_cluster
>   exfat: introduce exfat_count_contig_clusters
>   exfat: get mutil-clusters in exfat_get_block
>
>  fs/exfat/cache.c    | 11 ++++--
>  fs/exfat/exfat_fs.h |  6 ++-
>  fs/exfat/fatent.c   | 90 ++++++++++++++++++++++++++++++++++++---------
>  fs/exfat/inode.c    | 14 ++++++-
>  4 files changed, 97 insertions(+), 24 deletions(-)
>
> --
> 2.43.0
>
Re: [RFC PATCH 0/7] Enable exfat_get_block to support obtaining multiple clusters
Posted by Chi Zhiling 1 week, 3 days ago
On 11/21/25 09:17, Namjae Jeon wrote:
> On Tue, Nov 18, 2025 at 5:26 PM Chi Zhiling <chizhiling@163.com> wrote:
>>
>> From: Chi Zhiling <chizhiling@kylinos.cn>
> Hi Chi,
>>
>> The purpose of this patchset is to prepare for adapting exfat to iomap
>> in the future. Currently, the main issue preventing exfat from supporting
>> iomap is its inability to fetch multiple contiguous clusters.
> Do you have a plan to work iomap support for exfat ?

Hi, Namjae


Firstly, I'm sorry that there are some errors in this patch. Due to my 
carelessness, the current patch did not work as expected. The parts that 
need to be modified are as follows:

diff --git a/fs/exfat/inode.c b/fs/exfat/inode.c
index 256ba2af34eb..e52af92b1732 100644
--- a/fs/exfat/inode.c
+++ b/fs/exfat/inode.c
@@ -311,7 +311,7 @@ static int exfat_get_block(struct inode *inode, 
sector_t iblock,
                 err = exfat_count_contig_clusters(sb, &chain, &count);
                 if (err)
                         return err;
-               max_blocks = (count << sbi->sect_per_clus_bits) - 
sec_offset;
+               mapped_blocks = (count << sbi->sect_per_clus_bits) - 
sec_offset;
         }
         max_blocks = min(mapped_blocks, max_blocks);


Back to the question, I do have plan to support iomap for exfat, but I'm 
still testing how much benefit switching to iomap will bring :)

>>
>> However, this patchset does not directly modify exfat_map_cluster and
>> exfat_get_cluster to support multi-clusters. Instead, after obtaining
>> the first cluster, it uses exfat_count_contig_clusters to retrieve the
>> subsequent contiguous clusters.
>>
>> This approach is the one with the fewest changes among all the solutions
>> I have attempted, making the modifications easier to review.
>>
>> This patchset includes two main changes: one reduces the number of sb_bread
>> calls when accessing adjacent clusters to save time, and the other enables
>> fetching multiple contiguous entries in exfat_get_blocks.
> Are there any performance improvement measurements when applying this patch-set?

I don't have very detailed performance data yet,

With the fix above, I did a simple read test with big file (30G) on my 
pc (cluster = 512), no significantly improvement in IO read speed. but 
the time proportion of exfat_get_block has decreased.

NO_FAT_CHAIN file:
IO speed:                           2.9G/s -> 3.0G/s
proportion of exfat_get_block       26.7% -> 0.2%

FAT_CHAIN file:
IO speed:                           416M/s -> 444M/s
proportion of exfat_get_block       58% -> 27%

Thanks,

>>
>> Chi Zhiling (7):
>>    exfat: add cache option for __exfat_ent_get
>>    exfat: support reuse buffer head for exfat_ent_get
>>    exfat: reuse cache to improve exfat_get_cluster
>>    exfat: improve exfat_count_num_clusters
>>    exfat: improve exfat_find_last_cluster
>>    exfat: introduce exfat_count_contig_clusters
>>    exfat: get mutil-clusters in exfat_get_block
>>
>>   fs/exfat/cache.c    | 11 ++++--
>>   fs/exfat/exfat_fs.h |  6 ++-
>>   fs/exfat/fatent.c   | 90 ++++++++++++++++++++++++++++++++++++---------
>>   fs/exfat/inode.c    | 14 ++++++-
>>   4 files changed, 97 insertions(+), 24 deletions(-)
>>
>> --
>> 2.43.0
>>