[f2fs-dev] [PATCH 1/3] f2fs: fix to release node block count in error path of f2fs_new_node_page()

2024-05-06 Thread Chao Yu
It missed to call dec_valid_node_count() to release node block count in error path, fix it. Fixes: 141170b759e0 ("f2fs: fix to avoid use f2fs_bug_on() in f2fs_new_node_page()") Signed-off-by: Chao Yu --- fs/f2fs/node.c | 12 ++-- 1 file changed, 6 insertions(+), 6 deletions(-) diff --g

[f2fs-dev] [PATCH 3/3] f2fs: fix to do sanity check on i_nid for inline_data inode

2024-05-06 Thread Chao Yu
syzbot reports a f2fs bug as below: [ cut here ] kernel BUG at fs/f2fs/inline.c:258! CPU: 1 PID: 34 Comm: kworker/u8:2 Not tainted 6.9.0-rc6-syzkaller-00012-g9e4bc4bcae01 #0 RIP: 0010:f2fs_write_inline_data+0x781/0x790 fs/f2fs/inline.c:258 Call Trace: f2fs_write_single_da

[f2fs-dev] [PATCH 2/3] f2fs: fix to add missing iput() in gc_data_segment()

2024-05-06 Thread Chao Yu
During gc_data_segment(), if inode state is abnormal, it missed to call iput(), fix it. Fixes: 132e3209789c ("f2fs: remove false alarm on iget failure during GC") Fixes: 9056d6489f5a ("f2fs: fix to do sanity check on inode type during garbage collection") Signed-off-by: Chao Yu --- fs/f2fs/gc.c

[f2fs-dev] [PATCH 4/5] f2fs: compress: fix to cover {reserve, release}_compress_blocks() w/ cp_rwsem lock

2024-05-06 Thread Chao Yu
It needs to cover {reserve,release}_compress_blocks() w/ cp_rwsem lock to avoid racing with checkpoint, otherwise, filesystem metadata including blkaddr in dnode, inode fields and .total_valid_block_count may be corrupted after SPO case. Fixes: ef8d563f184e ("f2fs: introduce F2FS_IOC_RELEASE_COMPR

[f2fs-dev] [PATCH 5/5] f2fs: compress: don't allow unaligned truncation on released compress inode

2024-05-06 Thread Chao Yu
f2fs image may be corrupted after below testcase: - mkfs.f2fs -O extra_attr,compression -f /dev/vdb - mount /dev/vdb /mnt/f2fs - touch /mnt/f2fs/file - f2fs_io setflags compression /mnt/f2fs/file - dd if=/dev/zero of=/mnt/f2fs/file bs=4k count=4 - f2fs_io release_cblocks /mnt/f2fs/file - truncate -

[f2fs-dev] [PATCH 3/5] f2fs: compress: fix typo in f2fs_reserve_compress_blocks()

2024-05-06 Thread Chao Yu
s/released/reserved. Signed-off-by: Chao Yu --- fs/f2fs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 6c84485687d3..e77e958a9f92 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -3785,7 +3785,7 @@ static int f2fs_reserve_compr

[f2fs-dev] [PATCH 2/5] f2fs: compress: fix error path of inc_valid_block_count()

2024-05-06 Thread Chao Yu
If inc_valid_block_count() can not allocate all requested blocks, it needs to release block count in .total_valid_block_count and resevation blocks in inode. Fixes: 54607494875e ("f2fs: compress: fix to avoid inconsistence bewteen i_blocks and dnode") Signed-off-by: Chao Yu --- fs/f2fs/f2fs.h |

[f2fs-dev] [PATCH 1/5] f2fs: compress: fix to update i_compr_blocks correctly

2024-05-06 Thread Chao Yu
Previously, we account reserved blocks and compressed blocks into @compr_blocks, then, f2fs_i_compr_blocks_update(,compr_blocks) will update i_compr_blocks incorrectly, fix it. Meanwhile, for the case all blocks in cluster were reserved, fix to update dn->ofs_in_node correctly. Fixes: eb8fbaa5337

[f2fs-dev] [PATCH 1/2] f2fs: remove unused GC_FAILURE_PIN

2024-05-06 Thread Chao Yu
After commit 3db1de0e582c ("f2fs: change the current atomic write way"), we removed all GC_FAILURE_ATOMIC usage, let's change i_gc_failures[] array to i_pin_failure for cleanup. Meanwhile, let's define i_current_depth and i_gc_failures as union variable due to they won't be valid at the same time.

[f2fs-dev] [PATCH 2/2] f2fs: fix to limit gc_pin_file_threshold

2024-05-06 Thread Chao Yu
type of f2fs_inode.i_gc_failures, f2fs_inode_info.i_gc_failures, and f2fs_sb_info.gc_pin_file_threshold is __le16, unsigned int, and u64, so it will cause truncation during comparison and persistence. Unifying variable of these three variables to unsigned short, and add an upper boundary limitatio

[f2fs-dev] [PATCH] f2fs: check validation of fault attrs in f2fs_build_fault_attr()

2024-05-06 Thread Chao Yu
- It missed to check validation of fault attrs in parse_options(), let's fix to add check condition in f2fs_build_fault_attr(). - Use f2fs_build_fault_attr() in __sbi_store() to clean up code. Signed-off-by: Chao Yu --- fs/f2fs/f2fs.h | 12 fs/f2fs/super.c | 27

[f2fs-dev] [PATCH] f2fs: use f2fs_{err, info}_ratelimited() for cleanup

2024-05-06 Thread Chao Yu
Commit b1c9d3f833ba ("f2fs: support printk_ratelimited() in f2fs_printk()") missed some cases, cover all remains for cleanup. Signed-off-by: Chao Yu --- fs/f2fs/compress.c | 54 +- fs/f2fs/segment.c | 5 ++--- 2 files changed, 26 insertions(+), 33 de

[f2fs-dev] [PATCH v2 1/3] f2fs: fix to release node block count in error path of f2fs_new_node_page()

2024-05-06 Thread Chao Yu
It missed to call dec_valid_node_count() to release node block count in error path, fix it. Fixes: 141170b759e0 ("f2fs: fix to avoid use f2fs_bug_on() in f2fs_new_node_page()") Signed-off-by: Chao Yu --- v2: - avoid comppile warning if CONFIG_F2FS_CHECK_FS is off. fs/f2fs/node.c | 2 +- 1 file

[f2fs-dev] [PATCH v2] f2fs: check validation of fault attrs in f2fs_build_fault_attr()

2024-05-06 Thread Chao Yu
- It missed to check validation of fault attrs in parse_options(), let's fix to add check condition in f2fs_build_fault_attr(). - Use f2fs_build_fault_attr() in __sbi_store() to clean up code. Signed-off-by: Chao Yu --- v2: - add static for f2fs_build_fault_attr(). fs/f2fs/f2fs.h | 12 -

[f2fs-dev] [PATCH v2 5/5] f2fs: compress: don't allow unaligned truncation on released compress inode

2024-05-06 Thread Chao Yu
f2fs image may be corrupted after below testcase: - mkfs.f2fs -O extra_attr,compression -f /dev/vdb - mount /dev/vdb /mnt/f2fs - touch /mnt/f2fs/file - f2fs_io setflags compression /mnt/f2fs/file - dd if=/dev/zero of=/mnt/f2fs/file bs=4k count=4 - f2fs_io release_cblocks /mnt/f2fs/file - truncate -