This patch add a simple check orphan inodes in -p 1 mode Signed-off-by: Yunlei He <heyun...@huawei.com> --- fsck/fsck.c | 21 +++++++++++++++++++-- fsck/fsck.h | 2 +- 2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/fsck/fsck.c b/fsck/fsck.c index 0009ea4..fd28d94 100644 --- a/fsck/fsck.c +++ b/fsck/fsck.c @@ -1494,7 +1494,7 @@ int fsck_chk_data_blk(struct f2fs_sb_info *sbi, u32 blk_addr, return 0; } -void fsck_chk_orphan_node(struct f2fs_sb_info *sbi) +int fsck_chk_orphan_node(struct f2fs_sb_info *sbi) { u32 blk_cnt = 0; block_t start_blk, orphan_blkaddr, i, j; @@ -1503,7 +1503,7 @@ void fsck_chk_orphan_node(struct f2fs_sb_info *sbi) u32 entry_count; if (!is_set_ckpt_flags(F2FS_CKPT(sbi), CP_ORPHAN_PRESENT_FLAG)) - return; + return 0; start_blk = __start_cp_addr(sbi) + 1 + get_sb(cp_payload); orphan_blkaddr = __start_sum_addr(sbi) - 1 - get_sb(cp_payload); @@ -1524,7 +1524,18 @@ void fsck_chk_orphan_node(struct f2fs_sb_info *sbi) for (j = 0; j < entry_count; j++) { nid_t ino = le32_to_cpu(orphan_blk->ino[j]); DBG(1, "[%3d] ino [0x%x]\n", i, ino); + struct node_info ni; blk_cnt = 1; + + if (c.preen_mode == PREEN_MODE_1 && !c.fix_on) { + get_node_info(sbi, ino, &ni); + if (!IS_VALID_NID(sbi, ino) || + !IS_VALID_BLK_ADDR(sbi, ni.blk_addr)) + return -EINVAL; + + continue; + } + ret = fsck_chk_node_blk(sbi, NULL, ino, NULL, F2FS_FT_ORPHAN, TYPE_INODE, &blk_cnt, NULL); @@ -1547,6 +1558,8 @@ void fsck_chk_orphan_node(struct f2fs_sb_info *sbi) } free(orphan_blk); free(new_blk); + + return 0; } int fsck_chk_meta(struct f2fs_sb_info *sbi) @@ -1605,6 +1618,10 @@ int fsck_chk_meta(struct f2fs_sb_info *sbi) return -EINVAL; } + /* 4. check orphan inode simply */ + if (fsck_chk_orphan_node(sbi)) + return -EINVAL; + if (fsck->nat_valid_inode_cnt != le32_to_cpu(cp->valid_inode_count)) { ASSERT_MSG("valid inode does not match: nat_valid_inode_cnt %u," " valid_inode_count %u", diff --git a/fsck/fsck.h b/fsck/fsck.h index 412e7b7..8785de8 100644 --- a/fsck/fsck.h +++ b/fsck/fsck.h @@ -109,7 +109,7 @@ enum seg_type { struct selabel_handle; -extern void fsck_chk_orphan_node(struct f2fs_sb_info *); +extern int fsck_chk_orphan_node(struct f2fs_sb_info *); extern int fsck_chk_node_blk(struct f2fs_sb_info *, struct f2fs_inode *, u32, u8 *, enum FILE_TYPE, enum NODE_TYPE, u32 *, struct child_info *); -- 2.10.1 ------------------------------------------------------------------------------ _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel