Skip to content

Commit 7f51186

Browse files
committed
ext4: trigger the lazy inode table initialization after resize
After we have finished extending the file system, we need to trigger a the lazy inode table thread to zero out the inode tables. Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
1 parent 15b4913 commit 7f51186

4 files changed

Lines changed: 27 additions & 13 deletions

File tree

‎fs/ext4/ext4.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2227,6 +2227,8 @@ extern int ext4_group_desc_csum_verify(struct super_block *sb, __u32 group,
22272227
struct ext4_group_desc *gdp);
22282228
extern void ext4_group_desc_csum_set(struct super_block *sb, __u32 group,
22292229
struct ext4_group_desc *gdp);
2230+
extern int ext4_register_li_request(struct super_block *sb,
2231+
ext4_group_t first_not_zeroed);
22302232

22312233
static inline int ext4_has_group_desc_csum(struct super_block *sb)
22322234
{

‎fs/ext4/ioctl.c‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,9 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
313313
if (err == 0)
314314
err = err2;
315315
mnt_drop_write_file(filp);
316+
if (!err && ext4_has_group_desc_csum(sb) &&
317+
test_opt(sb, INIT_INODE_TABLE))
318+
err = ext4_register_li_request(sb, input.group);
316319
group_add_out:
317320
ext4_resize_end(sb);
318321
return err;
@@ -358,6 +361,7 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
358361
ext4_fsblk_t n_blocks_count;
359362
struct super_block *sb = inode->i_sb;
360363
int err = 0, err2 = 0;
364+
ext4_group_t o_group = EXT4_SB(sb)->s_groups_count;
361365

362366
if (EXT4_HAS_RO_COMPAT_FEATURE(sb,
363367
EXT4_FEATURE_RO_COMPAT_BIGALLOC)) {
@@ -388,6 +392,11 @@ long ext4_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
388392
if (err == 0)
389393
err = err2;
390394
mnt_drop_write_file(filp);
395+
if (!err && (o_group > EXT4_SB(sb)->s_groups_count) &&
396+
ext4_has_group_desc_csum(sb) &&
397+
test_opt(sb, INIT_INODE_TABLE))
398+
err = ext4_register_li_request(sb, o_group);
399+
391400
resizefs_out:
392401
ext4_resize_end(sb);
393402
return err;

‎fs/ext4/resize.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1506,10 +1506,12 @@ static int ext4_setup_next_flex_gd(struct super_block *sb,
15061506
group_data[i].blocks_count = blocks_per_group;
15071507
overhead = ext4_group_overhead_blocks(sb, group + i);
15081508
group_data[i].free_blocks_count = blocks_per_group - overhead;
1509-
if (ext4_has_group_desc_csum(sb))
1509+
if (ext4_has_group_desc_csum(sb)) {
15101510
flex_gd->bg_flags[i] = EXT4_BG_BLOCK_UNINIT |
15111511
EXT4_BG_INODE_UNINIT;
1512-
else
1512+
if (!test_opt(sb, INIT_INODE_TABLE))
1513+
flex_gd->bg_flags[i] |= EXT4_BG_INODE_ZEROED;
1514+
} else
15131515
flex_gd->bg_flags[i] = EXT4_BG_INODE_ZEROED;
15141516
}
15151517

@@ -1594,7 +1596,7 @@ int ext4_group_add(struct super_block *sb, struct ext4_new_group_data *input)
15941596

15951597
err = ext4_alloc_flex_bg_array(sb, input->group + 1);
15961598
if (err)
1597-
return err;
1599+
goto out;
15981600

15991601
err = ext4_mb_alloc_groupinfo(sb, input->group + 1);
16001602
if (err)

‎fs/ext4/super.c‎

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2776,7 +2776,7 @@ static int ext4_run_li_request(struct ext4_li_request *elr)
27762776
break;
27772777
}
27782778

2779-
if (group == ngroups)
2779+
if (group >= ngroups)
27802780
ret = 1;
27812781

27822782
if (!ret) {
@@ -3016,33 +3016,34 @@ static struct ext4_li_request *ext4_li_request_new(struct super_block *sb,
30163016
return elr;
30173017
}
30183018

3019-
static int ext4_register_li_request(struct super_block *sb,
3020-
ext4_group_t first_not_zeroed)
3019+
int ext4_register_li_request(struct super_block *sb,
3020+
ext4_group_t first_not_zeroed)
30213021
{
30223022
struct ext4_sb_info *sbi = EXT4_SB(sb);
3023-
struct ext4_li_request *elr;
3023+
struct ext4_li_request *elr = NULL;
30243024
ext4_group_t ngroups = EXT4_SB(sb)->s_groups_count;
30253025
int ret = 0;
30263026

3027+
mutex_lock(&ext4_li_mtx);
30273028
if (sbi->s_li_request != NULL) {
30283029
/*
30293030
* Reset timeout so it can be computed again, because
30303031
* s_li_wait_mult might have changed.
30313032
*/
30323033
sbi->s_li_request->lr_timeout = 0;
3033-
return 0;
3034+
goto out;
30343035
}
30353036

30363037
if (first_not_zeroed == ngroups ||
30373038
(sb->s_flags & MS_RDONLY) ||
30383039
!test_opt(sb, INIT_INODE_TABLE))
3039-
return 0;
3040+
goto out;
30403041

30413042
elr = ext4_li_request_new(sb, first_not_zeroed);
3042-
if (!elr)
3043-
return -ENOMEM;
3044-
3045-
mutex_lock(&ext4_li_mtx);
3043+
if (!elr) {
3044+
ret = -ENOMEM;
3045+
goto out;
3046+
}
30463047

30473048
if (NULL == ext4_li_info) {
30483049
ret = ext4_li_info_new();

0 commit comments

Comments
 (0)