linux-stable/fs/f2fs
Qi Han ef517d2d21 f2fs: fix f2fs_bug_on when uninstalling filesystem call f2fs_evict_inode.
[ Upstream commit d5c367ef82 ]

creating a large files during checkpoint disable until it runs out of
space and then delete it, then remount to enable checkpoint again, and
then unmount the filesystem triggers the f2fs_bug_on as below:

------------[ cut here ]------------
kernel BUG at fs/f2fs/inode.c:896!
CPU: 2 UID: 0 PID: 1286 Comm: umount Not tainted 6.11.0-rc7-dirty #360
Oops: invalid opcode: 0000 [#1] PREEMPT SMP NOPTI
RIP: 0010:f2fs_evict_inode+0x58c/0x610
Call Trace:
 __die_body+0x15/0x60
 die+0x33/0x50
 do_trap+0x10a/0x120
 f2fs_evict_inode+0x58c/0x610
 do_error_trap+0x60/0x80
 f2fs_evict_inode+0x58c/0x610
 exc_invalid_op+0x53/0x60
 f2fs_evict_inode+0x58c/0x610
 asm_exc_invalid_op+0x16/0x20
 f2fs_evict_inode+0x58c/0x610
 evict+0x101/0x260
 dispose_list+0x30/0x50
 evict_inodes+0x140/0x190
 generic_shutdown_super+0x2f/0x150
 kill_block_super+0x11/0x40
 kill_f2fs_super+0x7d/0x140
 deactivate_locked_super+0x2a/0x70
 cleanup_mnt+0xb3/0x140
 task_work_run+0x61/0x90

The root cause is: creating large files during disable checkpoint
period results in not enough free segments, so when writing back root
inode will failed in f2fs_enable_checkpoint. When umount the file
system after enabling checkpoint, the root inode is dirty in
f2fs_evict_inode function, which triggers BUG_ON. The steps to
reproduce are as follows:

dd if=/dev/zero of=f2fs.img bs=1M count=55
mount f2fs.img f2fs_dir -o checkpoint=disable:10%
dd if=/dev/zero of=big bs=1M count=50
sync
rm big
mount -o remount,checkpoint=enable f2fs_dir
umount f2fs_dir

Let's redirty inode when there is not free segments during checkpoint
is disable.

Signed-off-by: Qi Han <hanqi@vivo.com>
Reviewed-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-12-14 19:54:47 +01:00
..
acl.c f2fs: port to vfs{g,u}id_t and associated helpers 2022-10-04 13:31:43 -07:00
acl.h vfs: add rcu argument to ->get_acl() callback 2021-08-18 22:08:24 +02:00
checkpoint.c f2fs: fix to update user block counts in block_operations() 2024-08-03 08:49:48 +02:00
compress.c f2fs: fix typos in comments 2024-06-12 11:03:37 +02:00
data.c f2fs: fix typos in comments 2024-06-12 11:03:37 +02:00
debug.c f2fs: refactor extent_cache to support for read and more 2023-05-17 11:53:52 +02:00
dir.c f2fs: prevent possible int overflow in dir_block_index() 2024-10-17 15:21:22 +02:00
extent_cache.c f2fs: fix several potential integer overflows in file offsets 2024-10-17 15:21:22 +02:00
f2fs.h fs: Create a generic is_dot_dotdot() utility 2024-10-17 15:21:17 +02:00
file.c f2fs: fix to avoid forcing direct write to use buffered IO on inline_data inode 2024-12-14 19:53:45 +01:00
gc.c f2fs: fix to avoid use GC_AT when setting gc_mode as GC_URGENT_LOW or GC_URGENT_MID 2024-12-14 19:53:45 +01:00
gc.h f2fs: Fix system crash due to lack of free space in LFS 2023-05-24 17:32:38 +01:00
hash.c f2fs: don't use casefolded comparison for "." and ".." 2022-05-17 11:19:23 -07:00
inline.c f2fs: fix return value of f2fs_convert_inline_inode() 2024-08-03 08:49:38 +02:00
inode.c f2fs: fix f2fs_bug_on when uninstalling filesystem call f2fs_evict_inode. 2024-12-14 19:54:47 +01:00
iostat.c f2fs: fix to avoid potential memory corruption in __update_iostat_latency() 2023-03-11 13:55:21 +01:00
iostat.h f2fs: iostat: support accounting compressed IO 2022-08-29 21:15:51 -07:00
Kconfig f2fs: introduce F2FS_UNFAIR_RWSEM to support unfair rwsem 2022-03-04 09:15:53 -08:00
Makefile f2fs: separate out iostat feature 2021-08-23 10:25:51 -07:00
namei.c f2fs: get rid of online repaire on corrupted directory 2024-10-17 15:21:10 +02:00
node.c f2fs: fix to release node block count in error path of f2fs_new_node_page() 2024-06-12 11:03:42 +02:00
node.h f2fs: convert to use bitmap API 2024-01-10 17:10:30 +01:00
recovery.c f2fs: fix to avoid potential panic during recovery 2024-03-26 18:20:55 -04:00
segment.c f2fs: check curseg->inited before write_sum_page in change_curseg 2024-12-14 19:53:45 +01:00
segment.h f2fs: remove struct segment_allocation default_salloc_ops 2024-12-14 19:53:45 +01:00
shrinker.c f2fs: refactor extent_cache to support for read and more 2023-05-17 11:53:52 +02:00
super.c f2fs: avoid potential int overflow in sanity_check_area_boundary() 2024-10-17 15:21:22 +02:00
sysfs.c f2fs: check validation of fault attrs in f2fs_build_fault_attr() 2024-07-11 12:47:09 +02:00
verity.c fs: f2fs: initialize fsdata in pagecache_write() 2023-03-11 13:55:18 +01:00
xattr.c f2fs: reduce expensive checkpoint trigger frequency 2024-10-17 15:21:09 +02:00
xattr.h f2fs: code cleanup by removing ifdef macro surrounding 2020-05-26 18:56:10 -07:00