Skip to content

Commit 1869899

Browse files
chaseyumosimchah
authored andcommitted
f2fs: fix error handling in fill_super
In fill_super, if we fail to call f2fs_build_stats(), it needs to detach from global f2fs shrink list, otherwise once system starts to shrink slab cache, we will encounter below panic: BUG: unable to handle kernel paging request at 00007d35 Oops: 0002 [#1] PREEMPT SMP EIP: __lock_acquire+0x70/0x12c0 Call Trace: lock_acquire+0xae/0x220 mutex_trylock+0xc5/0xf0 f2fs_shrink_count+0x32/0xb0 [f2fs] shrink_slab+0xf1/0x5b0 drop_slab_node+0x35/0x60 drop_slab+0xf/0x20 drop_caches_sysctl_handler+0x79/0xc0 proc_sys_call_handler+0xa4/0xc0 proc_sys_write+0x1f/0x30 __vfs_write+0x24/0x150 SyS_write+0x44/0x90 do_fast_syscall_32+0xa1/0x1ca entry_SYSENTER_32+0x4c/0x7b In addition, this patch relocates f2fs_join_shrinker in fill_super to avoid unneeded error handling of it. Signed-off-by: Chao Yu <[email protected]> Signed-off-by: Jaegeuk Kim <[email protected]>
1 parent 7c7b469 commit 1869899

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

fs/f2fs/super.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2679,18 +2679,16 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
26792679
goto free_nm;
26802680
}
26812681

2682-
f2fs_join_shrinker(sbi);
2683-
26842682
err = f2fs_build_stats(sbi);
26852683
if (err)
2686-
goto free_nm;
2684+
goto free_node_inode;
26872685

26882686
/* read root inode and dentry */
26892687
root = f2fs_iget(sb, F2FS_ROOT_INO(sbi));
26902688
if (IS_ERR(root)) {
26912689
f2fs_msg(sb, KERN_ERR, "Failed to read root inode");
26922690
err = PTR_ERR(root);
2693-
goto free_node_inode;
2691+
goto free_stats;
26942692
}
26952693
if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
26962694
iput(root);
@@ -2786,6 +2784,8 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
27862784
sbi->valid_super_block ? 1 : 2, err);
27872785
}
27882786

2787+
f2fs_join_shrinker(sbi);
2788+
27892789
f2fs_msg(sbi->sb, KERN_NOTICE, "Mounted with checkpoint version = %llx",
27902790
cur_cp_version(F2FS_CKPT(sbi)));
27912791
f2fs_update_time(sbi, CP_TIME);
@@ -2812,14 +2812,12 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
28122812
free_root_inode:
28132813
dput(sb->s_root);
28142814
sb->s_root = NULL;
2815+
free_stats:
2816+
f2fs_destroy_stats(sbi);
28152817
free_node_inode:
2816-
truncate_inode_pages_final(NODE_MAPPING(sbi));
2817-
mutex_lock(&sbi->umount_mutex);
28182818
release_ino_entry(sbi, true);
2819-
f2fs_leave_shrinker(sbi);
2819+
truncate_inode_pages_final(NODE_MAPPING(sbi));
28202820
iput(sbi->node_inode);
2821-
mutex_unlock(&sbi->umount_mutex);
2822-
f2fs_destroy_stats(sbi);
28232821
free_nm:
28242822
destroy_node_manager(sbi);
28252823
free_sm:

0 commit comments

Comments
 (0)