On 2022/11/15 16:46, Zhang Qilong wrote:
Mounting f2fs with following issue:
sanity_check_inode: inode (ino=4827) has unsupported log cluster size: 0, run 
fsck to fix

->find_fsync_dnodes
  ->add_fsync_inode
   ->f2fs_iget_retry
    ->f2fs_iget
     ->do_read_inode
      ->sanity_check_inode

It is triggered when entering recovery mode after a system crash.
The root cause is 'i_log_cluster_size' is zero in f2fs inode with
F2FS_COMPR_FL flag. It will resulted in mounting failed, and the
filesystem need to be fscked.

fsync on compressed inode will trigger checkpoint, so f2fs_recover_inode_page()
will never process compressed inode?

Thanks,


We fix it by adding copying compresion information to f2fs inode
page when recover inode page in f2fs_recover_inode_page().

Cc: sta...@vger.kernel.org
Fixes: 4c8ff7095bef ("f2fs: support data compression")
Signed-off-by: Zhang Qilong <zhangqilo...@huawei.com>
---
  fs/f2fs/node.c | 8 ++++++++
  1 file changed, 8 insertions(+)

diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 83cc8a9e4982..2c4031ed71c9 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -2799,6 +2799,14 @@ int f2fs_recover_inode_page(struct f2fs_sb_info *sbi, 
struct page *page)
                        dst->i_crtime = src->i_crtime;
                        dst->i_crtime_nsec = src->i_crtime_nsec;
                }
+               if (f2fs_sb_has_compression(sbi) &&
+                       F2FS_FITS_IN_INODE(src, le16_to_cpu(src->i_extra_isize),
+                                               i_log_cluster_size)) {
+                       dst->i_compr_blocks = src->i_compr_blocks;
+                       dst->i_compress_algorithm = src->i_compress_algorithm;
+                       dst->i_log_cluster_size = src->i_log_cluster_size;
+                       dst->i_compress_flag = src->i_compress_flag;
+               }
        }
new_ni = old_ni;


_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to