android_kernel_samsung_sm8650/fs/f2fs
Chao Yu 300a842937 f2fs: fix to reserve space for IO align feature
https://bugzilla.kernel.org/show_bug.cgi?id=204137

With below script, we will hit panic during new segment allocation:

DISK=bingo.img
MOUNT_DIR=/mnt/f2fs

dd if=/dev/zero of=$DISK bs=1M count=105
mkfs.f2fe -a 1 -o 19 -t 1 -z 1 -f -q $DISK

mount -t f2fs $DISK $MOUNT_DIR -o "noinline_dentry,flush_merge,noextent_cache,mode=lfs,io_bits=7,fsync_mode=strict"

for (( i = 0; i < 4096; i++ )); do
	name=`head /dev/urandom | tr -dc A-Za-z0-9 | head -c 10`
	mkdir $MOUNT_DIR/$name
done

umount $MOUNT_DIR
rm $DISK

--- Core dump ---
Call Trace:
 allocate_segment_by_default+0x9d/0x100 [f2fs]
 f2fs_allocate_data_block+0x3c0/0x5c0 [f2fs]
 do_write_page+0x62/0x110 [f2fs]
 f2fs_outplace_write_data+0x43/0xc0 [f2fs]
 f2fs_do_write_data_page+0x386/0x560 [f2fs]
 __write_data_page+0x706/0x850 [f2fs]
 f2fs_write_cache_pages+0x267/0x6a0 [f2fs]
 f2fs_write_data_pages+0x19c/0x2e0 [f2fs]
 do_writepages+0x1c/0x70
 __filemap_fdatawrite_range+0xaa/0xe0
 filemap_fdatawrite+0x1f/0x30
 f2fs_sync_dirty_inodes+0x74/0x1f0 [f2fs]
 block_operations+0xdc/0x350 [f2fs]
 f2fs_write_checkpoint+0x104/0x1150 [f2fs]
 f2fs_sync_fs+0xa2/0x120 [f2fs]
 f2fs_balance_fs_bg+0x33c/0x390 [f2fs]
 f2fs_write_node_pages+0x4c/0x1f0 [f2fs]
 do_writepages+0x1c/0x70
 __writeback_single_inode+0x45/0x320
 writeback_sb_inodes+0x273/0x5c0
 wb_writeback+0xff/0x2e0
 wb_workfn+0xa1/0x370
 process_one_work+0x138/0x350
 worker_thread+0x4d/0x3d0
 kthread+0x109/0x140
 ret_from_fork+0x25/0x30

The root cause here is, with IO alignment feature enables, in worst
case, we need F2FS_IO_SIZE() free blocks space for single one 4k write
due to IO alignment feature will fill dummy pages to make IO being
aligned.

So we will easily run out of free segments during non-inline directory's
data writeback, even in process of foreground GC.

In order to fix this issue, I just propose to reserve additional free
space for IO alignment feature to handle worst case of free space usage
ratio during FGGC.

Fixes: 0a595ebaaa ("f2fs: support IO alignment for DATA and NODE writes")
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
2022-01-04 13:20:56 -08:00
..
acl.c vfs: add rcu argument to ->get_acl() callback 2021-08-18 22:08:24 +02:00
acl.h vfs: add rcu argument to ->get_acl() callback 2021-08-18 22:08:24 +02:00
checkpoint.c f2fs: fix to check available space of CP area correctly in update_ckpt_flags() 2022-01-04 13:20:56 -08:00
compress.c f2fs: do not bother checkpoint by f2fs_get_node_info 2022-01-04 13:20:49 -08:00
data.c f2fs: do not bother checkpoint by f2fs_get_node_info 2022-01-04 13:20:49 -08:00
debug.c f2fs: convert S_IRUGO to 0444 2021-08-17 11:59:05 -07:00
dir.c f2fs: support fault injection for f2fs_kmem_cache_alloc() 2021-08-17 11:59:05 -07:00
extent_cache.c f2fs: support fault injection for f2fs_kmem_cache_alloc() 2021-08-17 11:59:05 -07:00
f2fs.h f2fs: fix to reserve space for IO align feature 2022-01-04 13:20:56 -08:00
file.c f2fs: do not bother checkpoint by f2fs_get_node_info 2022-01-04 13:20:49 -08:00
gc.c f2fs: do not bother checkpoint by f2fs_get_node_info 2022-01-04 13:20:49 -08:00
gc.h f2fs: introduce gc_merge mount option 2021-03-30 18:48:56 -07:00
hash.c f2fs: Handle casefolding with Encryption 2020-12-02 22:00:21 -08:00
inline.c f2fs: do not bother checkpoint by f2fs_get_node_info 2022-01-04 13:20:49 -08:00
inode.c f2fs: do not bother checkpoint by f2fs_get_node_info 2022-01-04 13:20:49 -08:00
iostat.c f2fs: use iomap for direct I/O 2021-12-10 15:48:30 -08:00
iostat.h f2fs: introduce periodic iostat io latency traces 2021-08-23 10:25:51 -07:00
Kconfig f2fs: implement iomap operations 2021-12-04 10:53:35 -08:00
Makefile f2fs: separate out iostat feature 2021-08-23 10:25:51 -07:00
namei.c f2fs: support fault injection for dquot_initialize() 2021-10-29 10:38:53 -07:00
node.c f2fs: do not bother checkpoint by f2fs_get_node_info 2022-01-04 13:20:49 -08:00
node.h f2fs: introduce excess_dirty_threshold() 2021-09-20 16:12:51 -07:00
recovery.c f2fs: do not bother checkpoint by f2fs_get_node_info 2022-01-04 13:20:49 -08:00
segment.c f2fs: do not bother checkpoint by f2fs_get_node_info 2022-01-04 13:20:49 -08:00
segment.h f2fs: fix to reserve space for IO align feature 2022-01-04 13:20:56 -08:00
shrinker.c f2fs: avoid race condition for shrinker count 2020-12-03 00:59:26 -08:00
super.c f2fs: fix to reserve space for IO align feature 2022-01-04 13:20:56 -08:00
sysfs.c f2fs: fix to reserve space for IO align feature 2022-01-04 13:20:56 -08:00
verity.c f2fs: support fault injection for dquot_initialize() 2021-10-29 10:38:53 -07:00
xattr.c f2fs: clean up __find_inline_xattr() with __find_xattr() 2022-01-04 13:20:56 -08:00
xattr.h f2fs: code cleanup by removing ifdef macro surrounding 2020-05-26 18:56:10 -07:00