Skip to content

Commit 0acdb88

Browse files
taoma-tmtytso
authored andcommitted
ext4: don't call update_backups() multiple times for the same bg
When performing an online resize, we add a bunch of groups at one time in ext4_flex_group_add, so in most cases a lot of group descriptors will be in the same group block. But in the end of this function, update_backups will be called for every group descriptor and the same block will be copied and journalled again and again. It is really a waste. Fix things so we only update a particular bg descriptor block once and skip subsequent updates of the same block. Signed-off-by: Tao Ma <boyu.mt@taobao.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
1 parent 7f1468d commit 0acdb88

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

‎fs/ext4/resize.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1460,15 +1460,19 @@ static int ext4_flex_group_add(struct super_block *sb,
14601460
EXT4_DESC_PER_BLOCK(sb));
14611461
int meta_bg = EXT4_HAS_INCOMPAT_FEATURE(sb,
14621462
EXT4_FEATURE_INCOMPAT_META_BG);
1463+
sector_t old_gdb = 0;
14631464

14641465
update_backups(sb, sbi->s_sbh->b_blocknr, (char *)es,
14651466
sizeof(struct ext4_super_block), 0);
14661467
for (; gdb_num <= gdb_num_end; gdb_num++) {
14671468
struct buffer_head *gdb_bh;
14681469

14691470
gdb_bh = sbi->s_group_desc[gdb_num];
1471+
if (old_gdb == gdb_bh->b_blocknr)
1472+
continue;
14701473
update_backups(sb, gdb_bh->b_blocknr, gdb_bh->b_data,
14711474
gdb_bh->b_size, meta_bg);
1475+
old_gdb = gdb_bh->b_blocknr;
14721476
}
14731477
}
14741478
exit:

0 commit comments

Comments
 (0)