* [v2 PATCH] exfat: optimize allocation bitmap loading time
@ 2025-08-17 12:22 Namjae Jeon
2025-08-18 9:13 ` Yuezhang.Mo
0 siblings, 1 reply; 2+ messages in thread
From: Namjae Jeon @ 2025-08-17 12:22 UTC (permalink / raw)
To: sj1557.seo, Yuezhang.Mo; +Cc: linux-fsdevel, Namjae Jeon
Loading the allocation bitmap is very slow if user set the small cluster
size on large partition.
For optimizing it, This patch uses sb_breadahead() read the allocation
bitmap. It will improve the mount time.
The following is the result of about 4TB partition(2KB cluster size)
on my target.
without patch:
real 0m41.746s
user 0m0.011s
sys 0m0.000s
with patch:
real 0m2.525s
user 0m0.008s
sys 0m0.008s
Reviewed-by: Sungjong Seo <sj1557.seo@samsung.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
---
v2:
- use optimal readahead size using ->ra_pages or ->io_pages.
fs/exfat/balloc.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/fs/exfat/balloc.c b/fs/exfat/balloc.c
index cc01556c9d9b..260bfaa1e19b 100644
--- a/fs/exfat/balloc.c
+++ b/fs/exfat/balloc.c
@@ -7,6 +7,7 @@
#include <linux/slab.h>
#include <linux/bitmap.h>
#include <linux/buffer_head.h>
+#include <linux/backing-dev.h>
#include "exfat_raw.h"
#include "exfat_fs.h"
@@ -30,9 +31,11 @@ static int exfat_allocate_bitmap(struct super_block *sb,
struct exfat_dentry *ep)
{
struct exfat_sb_info *sbi = EXFAT_SB(sb);
+ struct blk_plug plug;
long long map_size;
- unsigned int i, need_map_size;
+ unsigned int i, j, need_map_size;
sector_t sector;
+ unsigned int max_ra_count;
sbi->map_clu = le32_to_cpu(ep->dentry.bitmap.start_clu);
map_size = le64_to_cpu(ep->dentry.bitmap.size);
@@ -56,7 +59,17 @@ static int exfat_allocate_bitmap(struct super_block *sb,
return -ENOMEM;
sector = exfat_cluster_to_sector(sbi, sbi->map_clu);
+ max_ra_count = min(sb->s_bdi->ra_pages, sb->s_bdi->io_pages) <<
+ (PAGE_SHIFT - sb->s_blocksize_bits);
for (i = 0; i < sbi->map_sectors; i++) {
+ /* Trigger the next readahead in advance. */
+ if (0 == (i % max_ra_count)) {
+ blk_start_plug(&plug);
+ for (j = i; j < min(max_ra_count, sbi->map_sectors - i) + i; j++)
+ sb_breadahead(sb, sector + j);
+ blk_finish_plug(&plug);
+ }
+
sbi->vol_amap[i] = sb_bread(sb, sector + i);
if (!sbi->vol_amap[i]) {
/* release all buffers and free vol_amap */
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [v2 PATCH] exfat: optimize allocation bitmap loading time
2025-08-17 12:22 [v2 PATCH] exfat: optimize allocation bitmap loading time Namjae Jeon
@ 2025-08-18 9:13 ` Yuezhang.Mo
0 siblings, 0 replies; 2+ messages in thread
From: Yuezhang.Mo @ 2025-08-18 9:13 UTC (permalink / raw)
To: Namjae Jeon, sj1557.seo@samsung.com; +Cc: linux-fsdevel@vger.kernel.org
Looks good to me.
Reviewed-by: Yuezhang Mo <Yuezhang.Mo@sony.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-08-18 9:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-17 12:22 [v2 PATCH] exfat: optimize allocation bitmap loading time Namjae Jeon
2025-08-18 9:13 ` Yuezhang.Mo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).