fsck.f2fs: fix incorrect boundary of IS_VALID_NID()
authorChao Yu <yuchao0@huawei.com>
Wed, 9 Jan 2019 02:48:25 +0000 (10:48 +0800)
committerJaegeuk Kim <jaegeuk@kernel.org>
Wed, 27 Mar 2019 14:02:28 +0000 (07:02 -0700)
nid should never equal to max_nid, fix it.

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

index 0d0d5e2..93f01e5 100644 (file)
@@ -369,13 +369,16 @@ static inline block_t sum_blk_addr(struct f2fs_sb_info *sbi, int base, int type)
 
 static inline bool IS_VALID_NID(struct f2fs_sb_info *sbi, u32 nid)
 {
-       return (nid <= (NAT_ENTRY_PER_BLOCK *
+       return (nid < (NAT_ENTRY_PER_BLOCK *
                        le32_to_cpu(F2FS_RAW_SUPER(sbi)->segment_count_nat)
                        << (sbi->log_blocks_per_seg - 1)));
 }
 
 static inline bool IS_VALID_BLK_ADDR(struct f2fs_sb_info *sbi, u32 addr)
 {
+       if (addr == NULL_ADDR || addr == NEW_ADDR)
+               return 1;
+
        if (addr >= le64_to_cpu(F2FS_RAW_SUPER(sbi)->block_count) ||
                                addr < SM_I(sbi)->main_blkaddr) {
                DBG(1, "block addr [0x%x]\n", addr);