f2fs: fix to account compressed blocks in f2fs_compressed_blocks()
authorChao Yu <yuchao0@huawei.com>
Thu, 12 Mar 2020 02:45:29 +0000 (10:45 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 23 Mar 2020 04:16:29 +0000 (21:16 -0700)
commit1a67cbe141cf991af252a88143d0fd975be2d9e7
tree5255fa70bd81e14141d034f076c1ef0689483561
parent50b1203d8c9c057558341cf02c0df66ba99a7877
f2fs: fix to account compressed blocks in f2fs_compressed_blocks()

por_fsstress reports inconsistent status in orphan inode, the root cause
of this is in f2fs_write_raw_pages() we decrease i_compr_blocks incorrectly
due to wrong calculation in f2fs_compressed_blocks().

So this patch exposes below two functions based on __f2fs_cluster_blocks:
- f2fs_compressed_blocks: get count of compressed blocks in compressed cluster
- f2fs_cluster_blocks: get count of valid blocks (including reserved blocks)
in compressed cluster.

Then use f2fs_compress_blocks() to get correct compressed blocks count in
f2fs_write_raw_pages().

sanity_check_inode: inode (ino=ad80) hash inconsistent i_compr_blocks:2, i_blocks:1, run fsck to fix

Signed-off-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/compress.c