Skip to content

Commit 9fd6886

Browse files
committed
exfat: optimize allocation bitmap loading time
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 <[email protected]> Reviewed-by: Yuezhang Mo <[email protected]> Signed-off-by: Namjae Jeon <[email protected]>
1 parent cb8d6d4 commit 9fd6886

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

fs/exfat/balloc.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <linux/slab.h>
88
#include <linux/bitmap.h>
99
#include <linux/buffer_head.h>
10+
#include <linux/backing-dev.h>
1011

1112
#include "exfat_raw.h"
1213
#include "exfat_fs.h"
@@ -73,9 +74,11 @@ static int exfat_allocate_bitmap(struct super_block *sb,
7374
struct exfat_dentry *ep)
7475
{
7576
struct exfat_sb_info *sbi = EXFAT_SB(sb);
77+
struct blk_plug plug;
7678
long long map_size;
7779
unsigned int i, j, need_map_size;
7880
sector_t sector;
81+
unsigned int max_ra_count;
7982

8083
sbi->map_clu = le32_to_cpu(ep->dentry.bitmap.start_clu);
8184
map_size = le64_to_cpu(ep->dentry.bitmap.size);
@@ -99,7 +102,17 @@ static int exfat_allocate_bitmap(struct super_block *sb,
99102
return -ENOMEM;
100103

101104
sector = exfat_cluster_to_sector(sbi, sbi->map_clu);
105+
max_ra_count = min(sb->s_bdi->ra_pages, sb->s_bdi->io_pages) <<
106+
(PAGE_SHIFT - sb->s_blocksize_bits);
102107
for (i = 0; i < sbi->map_sectors; i++) {
108+
/* Trigger the next readahead in advance. */
109+
if (0 == (i % max_ra_count)) {
110+
blk_start_plug(&plug);
111+
for (j = i; j < min(max_ra_count, sbi->map_sectors - i) + i; j++)
112+
sb_breadahead(sb, sector + j);
113+
blk_finish_plug(&plug);
114+
}
115+
103116
sbi->vol_amap[i] = sb_bread(sb, sector + i);
104117
if (!sbi->vol_amap[i])
105118
goto err_out;

0 commit comments

Comments
 (0)