From: Chi Zhiling <chizhiling@163.com>
To: Namjae Jeon <linkinjeon@kernel.org>
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
Sungjong Seo <sj1557.seo@samsung.com>,
Yuezhang Mo <yuezhang.mo@sony.com>,
Chi Zhiling <chizhiling@kylinos.cn>
Subject: Re: [PATCH v1 1/3] exfat: add block readahead in exfat_chain_cont_cluster
Date: Thu, 5 Feb 2026 10:13:09 +0800 [thread overview]
Message-ID: <41d06f88-d5b6-4a6d-a2fd-813dbdf71517@163.com> (raw)
In-Reply-To: <CAKYAXd-xgjbF1u4x9KZvoaVa0xL7LL6Mie_gL9v+UpfCPpH6BQ@mail.gmail.com>
On 2/5/26 09:39, Namjae Jeon wrote:
> On Wed, Feb 4, 2026 at 4:15 PM Chi Zhiling <chizhiling@163.com> wrote:
>>
>> From: Chi Zhiling <chizhiling@kylinos.cn>
>>
>> The conversion from NO_FAT_CHAIN format to FAT_CHAIN format occurs
>> when the file cannot allocate contiguous space. When the file to be
>> converted is very large, this process can take a long time.
>>
>> This patch introduces simple readahead to read all the blocks in
>> advance, as these blocks are consecutive.
>>
>> Test in an empty exfat filesystem:
>> dd if=/dev/zero of=/mnt/file bs=1M count=30k
>> dd if=/dev/zero of=/mnt/file2 bs=1M count=1
>> time cat /mnt/file2 >> /mnt/file
>>
>> | cluster size | before patch | after patch |
>> | ------------ | ------------ | ----------- |
>> | 512 | 47.667s | 4.316s |
>> | 4k | 6.436s | 0.541s |
>> | 32k | 0.758s | 0.071s |
>> | 256k | 0.117s | 0.011s |
>>
>> Signed-off-by: Chi Zhiling <chizhiling@kylinos.cn>
>> ---
>> fs/exfat/exfat_fs.h | 9 +++++++--
>> fs/exfat/fatent.c | 38 ++++++++++++++++++++++++++++++++++++++
>> 2 files changed, 45 insertions(+), 2 deletions(-)
>>
>> diff --git a/fs/exfat/exfat_fs.h b/fs/exfat/exfat_fs.h
>> index 2dbed5f8ec26..5a3cdf725846 100644
>> --- a/fs/exfat/exfat_fs.h
>> +++ b/fs/exfat/exfat_fs.h
>> @@ -10,6 +10,7 @@
>> #include <linux/ratelimit.h>
>> #include <linux/nls.h>
>> #include <linux/blkdev.h>
>> +#include <linux/backing-dev.h>
>> #include <uapi/linux/exfat.h>
>>
>> #define EXFAT_ROOT_INO 1
>> @@ -79,6 +80,10 @@ enum {
>> #define EXFAT_HINT_NONE -1
>> #define EXFAT_MIN_SUBDIR 2
>>
>> +#define EXFAT_BLK_RA_SIZE(sb) \
>> +(min((sb)->s_bdi->ra_pages, (sb)->s_bdi->io_pages) \
>> + << (PAGE_SHIFT - sb->s_blocksize_bits))
>> +
>> /*
>> * helpers for cluster size to byte conversion.
>> */
>> @@ -117,9 +122,9 @@ enum {
>> #define FAT_ENT_SIZE (4)
>> #define FAT_ENT_SIZE_BITS (2)
>> #define FAT_ENT_OFFSET_SECTOR(sb, loc) (EXFAT_SB(sb)->FAT1_start_sector + \
>> - (((u64)loc << FAT_ENT_SIZE_BITS) >> sb->s_blocksize_bits))
>> + (((u64)(loc) << FAT_ENT_SIZE_BITS) >> sb->s_blocksize_bits))
>> #define FAT_ENT_OFFSET_BYTE_IN_SECTOR(sb, loc) \
>> - ((loc << FAT_ENT_SIZE_BITS) & (sb->s_blocksize - 1))
>> + (((loc) << FAT_ENT_SIZE_BITS) & (sb->s_blocksize - 1))
>>
>> /*
>> * helpers for bitmap.
>> diff --git a/fs/exfat/fatent.c b/fs/exfat/fatent.c
>> index 71ee16479c43..0c17621587d5 100644
>> --- a/fs/exfat/fatent.c
>> +++ b/fs/exfat/fatent.c
>> @@ -142,13 +142,51 @@ int exfat_ent_get(struct super_block *sb, unsigned int loc,
>> return -EIO;
>> }
>>
>> +static int exfat_blk_readahead(struct super_block *sb, sector_t sec,
>> + sector_t *ra, blkcnt_t *ra_cnt, sector_t end)
>> +{
>> + struct blk_plug plug;
>> +
>> + if (sec < *ra)
>> + return 0;
>> +
>> + *ra += *ra_cnt;
>> +
>> + /* No blocks left (or only the last block), skip readahead. */
>> + if (*ra >= end)
>> + return 0;
>> +
>> + *ra_cnt = min(end - *ra + 1, EXFAT_BLK_RA_SIZE(sb));
>> + if (*ra_cnt == 0) {
>> + /* Move 'ra' to the end to disable readahead. */
>> + *ra = end;
>> + return 0;
>> + }
>> +
>> + blk_start_plug(&plug);
>> + for (unsigned int i = 0; i < *ra_cnt; i++)
>> + sb_breadahead(sb, *ra + i);
>> + blk_finish_plug(&plug);
>> + return 0;
>> +}
> Can you combine multiple readahead codes (readahead in
> exfat_allocate_bitmap, exfat_dir_readahead) in exfat?
OK, I will do this in v2.
> Thanks.
next prev parent reply other threads:[~2026-02-05 2:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-04 7:14 Chi Zhiling
2026-02-04 7:14 ` [PATCH v1 1/3] exfat: add block readahead in exfat_chain_cont_cluster Chi Zhiling
2026-02-05 1:39 ` Namjae Jeon
2026-02-05 2:13 ` Chi Zhiling [this message]
2026-02-04 7:14 ` [PATCH v1 2/3] exfat: drop parameter sec for exfat_mirror_bh Chi Zhiling
2026-02-04 7:14 ` [PATCH v1 3/3] exfat: optimize exfat_chain_cont_cluster with cached buffer heads Chi Zhiling
2026-02-04 7:19 ` Chi Zhiling
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=41d06f88-d5b6-4a6d-a2fd-813dbdf71517@163.com \
--to=chizhiling@163.com \
--cc=chizhiling@kylinos.cn \
--cc=linkinjeon@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sj1557.seo@samsung.com \
--cc=yuezhang.mo@sony.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®