Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

f2fs: fix a bug caused by NULL extent tree

Thread A: Thread B:

-f2fs_remount
-sbi->mount_opt.opt = 0;
<--- -f2fs_iget
-do_read_inode
-f2fs_init_extent_tree
-F2FS_I(inode)->extent_tree is NULL
-default_options && parse_options
-remount return
<--- -f2fs_map_blocks
-f2fs_lookup_extent_tree
-f2fs_bug_on(sbi, !et);

The same problem with f2fs_new_inode.

Signed-off-by: Yunlei He <heyunlei@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

authored by

Yunlei He and committed by
Jaegeuk Kim
dad48e73 1d7be270

+11 -1
+11 -1
fs/f2fs/extent_cache.c
··· 320 320 } 321 321 322 322 /* return true, if inode page is changed */ 323 - bool f2fs_init_extent_tree(struct inode *inode, struct f2fs_extent *i_ext) 323 + static bool __f2fs_init_extent_tree(struct inode *inode, struct f2fs_extent *i_ext) 324 324 { 325 325 struct f2fs_sb_info *sbi = F2FS_I_SB(inode); 326 326 struct extent_tree *et; ··· 356 356 out: 357 357 write_unlock(&et->lock); 358 358 return false; 359 + } 360 + 361 + bool f2fs_init_extent_tree(struct inode *inode, struct f2fs_extent *i_ext) 362 + { 363 + bool ret = __f2fs_init_extent_tree(inode, i_ext); 364 + 365 + if (!F2FS_I(inode)->extent_tree) 366 + set_inode_flag(inode, FI_NO_EXTENT); 367 + 368 + return ret; 359 369 } 360 370 361 371 static bool f2fs_lookup_extent_tree(struct inode *inode, pgoff_t pgofs,