mirror of
https://gitee.com/openharmony/third_party_f2fs-tools
synced 2024-11-23 10:10:00 +00:00
fsck.f2fs: handle IS_VALID_BLK_ADDR
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
f6d1d582e9
commit
7aafb1b5f4
21
fsck/f2fs.h
21
fsck/f2fs.h
@ -308,16 +308,17 @@ static inline bool IS_VALID_NID(struct f2fs_sb_info *sbi, u32 nid)
|
||||
<< (sbi->log_blocks_per_seg - 1)));
|
||||
}
|
||||
|
||||
#define IS_VALID_BLK_ADDR(sbi, addr) \
|
||||
do { \
|
||||
if (addr >= F2FS_RAW_SUPER(sbi)->block_count || \
|
||||
addr < SM_I(sbi)->main_blkaddr) \
|
||||
{ \
|
||||
DBG(0, "block addr [0x%x]\n", addr); \
|
||||
ASSERT(addr < F2FS_RAW_SUPER(sbi)->block_count); \
|
||||
ASSERT(addr >= SM_I(sbi)->main_blkaddr); \
|
||||
} \
|
||||
} while (0);
|
||||
static inline bool IS_VALID_BLK_ADDR(struct f2fs_sb_info *sbi, u32 addr)
|
||||
{
|
||||
if (addr >= F2FS_RAW_SUPER(sbi)->block_count ||
|
||||
addr < SM_I(sbi)->main_blkaddr) {
|
||||
DBG(0, "block addr [0x%x]\n", addr);
|
||||
ASSERT(addr < F2FS_RAW_SUPER(sbi)->block_count);
|
||||
ASSERT(addr >= SM_I(sbi)->main_blkaddr);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline u64 BLKOFF_FROM_MAIN(struct f2fs_sb_info *sbi, u64 blk_addr)
|
||||
{
|
||||
|
14
fsck/fsck.c
14
fsck/fsck.c
@ -189,8 +189,10 @@ int fsck_chk_node_blk(struct f2fs_sb_info *sbi,
|
||||
struct f2fs_node *node_blk = NULL;
|
||||
int ret = 0;
|
||||
|
||||
if (!IS_VALID_NID(sbi, nid))
|
||||
if (!IS_VALID_NID(sbi, nid)) {
|
||||
ASSERT_MSG("nid is not valid. [0x%x]", nid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ftype != F2FS_FT_ORPHAN ||
|
||||
f2fs_test_bit(nid, fsck->nat_area_bitmap) != 0x0)
|
||||
@ -213,7 +215,10 @@ int fsck_chk_node_blk(struct f2fs_sb_info *sbi,
|
||||
return 0;
|
||||
}
|
||||
|
||||
IS_VALID_BLK_ADDR(sbi, ni.blk_addr);
|
||||
if (!IS_VALID_BLK_ADDR(sbi, ni.blk_addr)) {
|
||||
ASSERT_MSG("blkaddres is not valid. [0x%x]", ni.blk_addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
is_valid_ssa_node_blk(sbi, nid, ni.blk_addr);
|
||||
|
||||
@ -596,7 +601,10 @@ int fsck_chk_data_blk(struct f2fs_sb_info *sbi, u32 blk_addr,
|
||||
return 0;
|
||||
}
|
||||
|
||||
IS_VALID_BLK_ADDR(sbi, blk_addr);
|
||||
if (!IS_VALID_BLK_ADDR(sbi, blk_addr)) {
|
||||
ASSERT_MSG("blkaddres is not valid. [0x%x]", blk_addr);
|
||||
return 0;
|
||||
}
|
||||
|
||||
is_valid_ssa_data_blk(sbi, blk_addr, parent_nid, idx_in_node, ver);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user