SBI_NEED_FSCK is used for *real* data corruption on-line, then it can
be a condition to end up issuing discard from background/umount/fstrim
to prevent further data losing. This patch split in-memory SBI_NEED_FSCK
to SBI_LOSE_NAT_BIT and SBI_NEED_FSCK, in order to report data corruption
more accurately.

Signed-off-by: Yunlei He <heyun...@huawei.com>
---
 fs/f2fs/checkpoint.c | 3 ++-
 fs/f2fs/f2fs.h       | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c
index 2e23b95..96785ff 100644
--- a/fs/f2fs/checkpoint.c
+++ b/fs/f2fs/checkpoint.c
@@ -1162,7 +1162,8 @@ static void update_ckpt_flags(struct f2fs_sb_info *sbi, 
struct cp_control *cpc)
        else
                __clear_ckpt_flags(ckpt, CP_ORPHAN_PRESENT_FLAG);
 
-       if (is_sbi_flag_set(sbi, SBI_NEED_FSCK))
+       if (is_sbi_flag_set(sbi, SBI_NEED_FSCK) ||
+                       is_sbi_flag_set(sbi, SBI_LOSE_NAT_BITS))
                __set_ckpt_flags(ckpt, CP_FSCK_FLAG);
 
        /* set this flag to activate crc|cp_ver for recovery */
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index c1c3a1d..90940350 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1055,6 +1055,7 @@ enum {
        SBI_POR_DOING,                          /* recovery is doing or not */
        SBI_NEED_SB_WRITE,                      /* need to recover superblock */
        SBI_NEED_CP,                            /* need to checkpoint */
+       SBI_LOSE_NAT_BITS,                      /* nat bits is lost */
 };
 
 enum {
@@ -1517,7 +1518,7 @@ static inline void disable_nat_bits(struct f2fs_sb_info 
*sbi, bool lock)
 {
        unsigned long flags;
 
-       set_sbi_flag(sbi, SBI_NEED_FSCK);
+       set_sbi_flag(sbi, SBI_LOSE_NAT_BITS);
 
        if (lock)
                spin_lock_irqsave(&sbi->cp_lock, flags);
-- 
1.9.1


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to