Message ID | 20240929080011.3802327-1-hanqi@vivo.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 26413ce18e85de3dda2cd3d72c3c3e8ab8f4f996 |
Headers | show |
Series | [f2fs-dev,v2] f2fs: compress: fix inconsistent update of i_blocks in release_compress_blocks and reserve_compress_blocks | expand |
On 2024/9/29 16:00, Qi Han wrote: > After release a file and subsequently reserve it, the FSCK flag is set > when the file is deleted, as shown in the following backtrace: > > F2FS-fs (dm-48): Inconsistent i_blocks, ino:401231, iblocks:1448, sectors:1472 > fs_rec_info_write_type+0x58/0x274 > f2fs_rec_info_write+0x1c/0x2c > set_sbi_flag+0x74/0x98 > dec_valid_block_count+0x150/0x190 > f2fs_truncate_data_blocks_range+0x2d4/0x3cc > f2fs_do_truncate_blocks+0x2fc/0x5f0 > f2fs_truncate_blocks+0x68/0x100 > f2fs_truncate+0x80/0x128 > f2fs_evict_inode+0x1a4/0x794 > evict+0xd4/0x280 > iput+0x238/0x284 > do_unlinkat+0x1ac/0x298 > __arm64_sys_unlinkat+0x48/0x68 > invoke_syscall+0x58/0x11c > > For clusters of the following type, i_blocks are decremented by 1 and > i_compr_blocks are incremented by 7 in release_compress_blocks, while > updates to i_blocks and i_compr_blocks are skipped in reserve_compress_blocks. > > raw node: > D D D D D D D D > after compress: > C D D D D D D D > after reserve: > C D D D D D D D > > Let's update i_blocks and i_compr_blocks properly in reserve_compress_blocks. > > Fixes: eb8fbaa53374 ("f2fs: compress: fix to check unreleased compressed cluster") > Signed-off-by: Qi Han <hanqi@vivo.com> Reviewed-by: Chao Yu <chao@kernel.org> Thanks,
Hello: This patch was applied to jaegeuk/f2fs.git (dev) by Jaegeuk Kim <jaegeuk@kernel.org>: On Sun, 29 Sep 2024 02:00:10 -0600 you wrote: > After release a file and subsequently reserve it, the FSCK flag is set > when the file is deleted, as shown in the following backtrace: > > F2FS-fs (dm-48): Inconsistent i_blocks, ino:401231, iblocks:1448, sectors:1472 > fs_rec_info_write_type+0x58/0x274 > f2fs_rec_info_write+0x1c/0x2c > set_sbi_flag+0x74/0x98 > dec_valid_block_count+0x150/0x190 > f2fs_truncate_data_blocks_range+0x2d4/0x3cc > f2fs_do_truncate_blocks+0x2fc/0x5f0 > f2fs_truncate_blocks+0x68/0x100 > f2fs_truncate+0x80/0x128 > f2fs_evict_inode+0x1a4/0x794 > evict+0xd4/0x280 > iput+0x238/0x284 > do_unlinkat+0x1ac/0x298 > __arm64_sys_unlinkat+0x48/0x68 > invoke_syscall+0x58/0x11c > > [...] Here is the summary with links: - [f2fs-dev,v2] f2fs: compress: fix inconsistent update of i_blocks in release_compress_blocks and reserve_compress_blocks https://git.kernel.org/jaegeuk/f2fs/c/26413ce18e85 You are awesome, thank you!
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 9ae54c4c72fe..71d5ded9eeda 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c @@ -3792,7 +3792,7 @@ static int reserve_compress_blocks(struct dnode_of_data *dn, pgoff_t count, to_reserved = cluster_size - compr_blocks - reserved; /* for the case all blocks in cluster were reserved */ - if (to_reserved == 1) { + if (reserved && to_reserved == 1) { dn->ofs_in_node += cluster_size; goto next; }
After release a file and subsequently reserve it, the FSCK flag is set when the file is deleted, as shown in the following backtrace: F2FS-fs (dm-48): Inconsistent i_blocks, ino:401231, iblocks:1448, sectors:1472 fs_rec_info_write_type+0x58/0x274 f2fs_rec_info_write+0x1c/0x2c set_sbi_flag+0x74/0x98 dec_valid_block_count+0x150/0x190 f2fs_truncate_data_blocks_range+0x2d4/0x3cc f2fs_do_truncate_blocks+0x2fc/0x5f0 f2fs_truncate_blocks+0x68/0x100 f2fs_truncate+0x80/0x128 f2fs_evict_inode+0x1a4/0x794 evict+0xd4/0x280 iput+0x238/0x284 do_unlinkat+0x1ac/0x298 __arm64_sys_unlinkat+0x48/0x68 invoke_syscall+0x58/0x11c For clusters of the following type, i_blocks are decremented by 1 and i_compr_blocks are incremented by 7 in release_compress_blocks, while updates to i_blocks and i_compr_blocks are skipped in reserve_compress_blocks. raw node: D D D D D D D D after compress: C D D D D D D D after reserve: C D D D D D D D Let's update i_blocks and i_compr_blocks properly in reserve_compress_blocks. Fixes: eb8fbaa53374 ("f2fs: compress: fix to check unreleased compressed cluster") Signed-off-by: Qi Han <hanqi@vivo.com> --- fs/f2fs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)