]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
f2fs: allow to recover node blocks given updated checkpoint
authorJaegeuk Kim <jaegeuk@kernel.org>
Fri, 19 Jan 2018 21:42:33 +0000 (13:42 -0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Mon, 22 Jan 2018 22:56:59 +0000 (14:56 -0800)
If fsck.f2fs changes crc, we have no way to recover some inode blocks by roll-
forward recovery. Let's relax the condition to recover them.

Reviewed-by: Chao Yu <yuchao0@huawei.com>
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
fs/f2fs/checkpoint.c
fs/f2fs/node.h
include/linux/f2fs_fs.h

index 9c7596f7daaeab1afec0db94853334b455b9ed65..512dca8abc7d62f5d1a11ca6785170f7921d85eb 100644 (file)
@@ -1157,6 +1157,7 @@ static void update_ckpt_flags(struct f2fs_sb_info *sbi, struct cp_control *cpc)
 
        /* set this flag to activate crc|cp_ver for recovery */
        __set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG);
+       __clear_ckpt_flags(ckpt, CP_NOCRC_RECOVERY_FLAG);
 
        spin_unlock_irqrestore(&sbi->cp_lock, flags);
 }
index 0ee3e5ff49a30b68d4b3040efa79642d989b19e4..081ef0d672bf5cf457a3bb1f4c20328bf24b1a12 100644 (file)
@@ -305,6 +305,10 @@ static inline bool is_recoverable_dnode(struct page *page)
        struct f2fs_checkpoint *ckpt = F2FS_CKPT(F2FS_P_SB(page));
        __u64 cp_ver = cur_cp_version(ckpt);
 
+       /* Don't care crc part, if fsck.f2fs sets it. */
+       if (__is_set_ckpt_flags(ckpt, CP_NOCRC_RECOVERY_FLAG))
+               return (cp_ver << 32) == (cpver_of_node(page) << 32);
+
        if (__is_set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG))
                cp_ver |= (cur_cp_crc(ckpt) << 32);
 
index cfb522e6affc9a2bb854dde0344b07476bbe0e31..6eed677b6d9aa96837ee1b647ff73e6b4a9ce66e 100644 (file)
@@ -117,6 +117,7 @@ struct f2fs_super_block {
 /*
  * For checkpoint
  */
+#define CP_NOCRC_RECOVERY_FLAG 0x00000200
 #define CP_TRIMMED_FLAG                0x00000100
 #define CP_NAT_BITS_FLAG       0x00000080
 #define CP_CRC_RECOVERY_FLAG   0x00000040