linux/fs/f2fs
Chao Yu 3ab0598e6d f2fs: fix panic during f2fs_resize_fs()
f2fs_resize_fs() hangs in below callstack with testcase:
- mkfs 16GB image & mount image
- dd 8GB fileA
- dd 8GB fileB
- sync
- rm fileA
- sync
- resize filesystem to 8GB

kernel BUG at segment.c:2484!
Call Trace:
 allocate_segment_by_default+0x92/0xf0 [f2fs]
 f2fs_allocate_data_block+0x44b/0x7e0 [f2fs]
 do_write_page+0x5a/0x110 [f2fs]
 f2fs_outplace_write_data+0x55/0x100 [f2fs]
 f2fs_do_write_data_page+0x392/0x850 [f2fs]
 move_data_page+0x233/0x320 [f2fs]
 do_garbage_collect+0x14d9/0x1660 [f2fs]
 free_segment_range+0x1f7/0x310 [f2fs]
 f2fs_resize_fs+0x118/0x330 [f2fs]
 __f2fs_ioctl+0x487/0x3680 [f2fs]
 __x64_sys_ioctl+0x8e/0xd0
 do_syscall_64+0x33/0x80
 entry_SYSCALL_64_after_hwframe+0x44/0xa9

The root cause is we forgot to check that whether we have enough space
in resized filesystem to store all valid blocks in before-resizing
filesystem, then allocator will run out-of-space during block migration
in free_segment_range().

Fixes: b4b10061ef ("f2fs: refactor resize_fs to avoid meta updates in progress")
Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2021-03-12 13:16:41 -08:00
..
acl.c idmapped-mounts-v5.12 2021-02-23 13:39:45 -08:00
acl.h fs: make helpers idmap mount aware 2021-01-24 14:27:20 +01:00
checkpoint.c f2fs: fix a spacing coding style 2021-03-12 13:16:41 -08:00
compress.c f2fs: compress: fix potential deadlock 2021-01-27 15:20:05 -08:00
compress.h f2fs: compress: fix compression chksum 2020-12-10 09:13:53 -08:00
data.c block: Add bio_max_segs 2021-02-26 15:49:51 -07:00
debug.c f2fs: introduce checkpoint_merge mount option 2021-02-03 13:03:06 -08:00
dir.c f2fs-for-5.11-rc1 2020-12-17 11:18:00 -08:00
extent_cache.c f2fs: support 64-bits key in f2fs rb-tree node entry 2020-09-10 14:03:30 -07:00
f2fs.h f2fs: fix to allow migrating fully valid segment 2021-03-12 13:16:41 -08:00
file.c f2fs: fix to allow migrating fully valid segment 2021-03-12 13:16:41 -08:00
gc.c f2fs: fix panic during f2fs_resize_fs() 2021-03-12 13:16:41 -08:00
gc.h f2fs: support age threshold based garbage collection 2020-09-11 11:11:15 -07:00
hash.c f2fs: Handle casefolding with Encryption 2020-12-02 22:00:21 -08:00
inline.c f2fs: fix to avoid inconsistent quota data 2021-02-01 14:32:51 -08:00
inode.c f2fs: compress: support chksum 2020-12-02 22:00:22 -08:00
Kconfig f2fs: deprecate f2fs_trace_io 2021-01-27 15:20:07 -08:00
Makefile f2fs: deprecate f2fs_trace_io 2021-01-27 15:20:07 -08:00
namei.c idmapped-mounts-v5.12 2021-02-23 13:39:45 -08:00
node.c block: Add bio_max_segs 2021-02-26 15:49:51 -07:00
node.h f2fs: avoid race condition for shrinker count 2020-12-03 00:59:26 -08:00
recovery.c f2fs: change to use rwsem for cp_mutex 2020-12-02 22:00:21 -08:00
segment.c f2fs: fix to allow migrating fully valid segment 2021-03-12 13:16:41 -08:00
segment.h f2fs: handle unallocated section and zone on pinned/atgc 2021-01-27 15:19:59 -08:00
shrinker.c f2fs: avoid race condition for shrinker count 2020-12-03 00:59:26 -08:00
super.c f2fs: fix to allow migrating fully valid segment 2021-03-12 13:16:41 -08:00
sysfs.c f2fs: add ckpt_thread_ioprio sysfs node 2021-02-03 13:03:58 -08:00
verity.c mm/readahead: make page_cache_ra_unbounded take a readahead_control 2020-10-16 11:11:16 -07:00
xattr.c idmapped-mounts-v5.12 2021-02-23 13:39:45 -08:00
xattr.h f2fs: code cleanup by removing ifdef macro surrounding 2020-05-26 18:56:10 -07:00