@@ -515,11 +515,19 @@ static int sanity_check_nid(struct f2fs_sb_info *sbi, u32 nid,
}
int fsck_sanity_check_nid(struct f2fs_sb_info *sbi, u32 nid,
- struct f2fs_node *node_blk,
- enum FILE_TYPE ftype, enum NODE_TYPE ntype,
- struct node_info *ni)
+ enum FILE_TYPE ftype, enum NODE_TYPE ntype)
{
- return sanity_check_nid(sbi, nid, node_blk, ftype, ntype, ni);
+ struct f2fs_node *node_blk = NULL;
+ struct node_info ni;
+ int ret;
+
+ node_blk = (struct f2fs_node *)calloc(BLOCK_SZ, 1);
+ ASSERT(node_blk != NULL);
+
+ ret = sanity_check_nid(sbi, nid, node_blk, ftype, ntype, &ni);
+
+ free(node_blk);
+ return ret;
}
static int fsck_chk_xattr_blk(struct f2fs_sb_info *sbi, u32 ino,
@@ -166,8 +166,7 @@ extern int fsck_chk_orphan_node(struct f2fs_sb_info *);
extern int fsck_chk_quota_node(struct f2fs_sb_info *);
extern int fsck_chk_quota_files(struct f2fs_sb_info *);
extern int fsck_sanity_check_nid(struct f2fs_sb_info *, u32,
- struct f2fs_node *, enum FILE_TYPE, enum NODE_TYPE,
- struct node_info *);
+ enum FILE_TYPE, enum NODE_TYPE);
extern int fsck_chk_node_blk(struct f2fs_sb_info *, struct f2fs_inode *, u32,
enum FILE_TYPE, enum NODE_TYPE, u32 *,
struct f2fs_compr_blk_cnt *, struct child_info *);
@@ -25,17 +25,7 @@ void *read_all_xattrs(struct f2fs_sb_info *sbi, struct f2fs_node *inode)
nid_t xnid = le32_to_cpu(inode->i.i_xattr_nid);
if (c.func == FSCK && xnid) {
- struct f2fs_node *node_blk = NULL;
- struct node_info ni;
- int ret;
-
- node_blk = (struct f2fs_node *)calloc(BLOCK_SZ, 1);
- ASSERT(node_blk != NULL);
-
- ret = fsck_sanity_check_nid(sbi, xnid, node_blk,
- F2FS_FT_XATTR, TYPE_XATTR, &ni);
- free(node_blk);
- if (ret)
+ if (fsck_sanity_check_nid(sbi, xnid, F2FS_FT_XATTR, TYPE_XATTR))
return NULL;
}
read_all_xattrs() is the only user of fsck_sanity_check_nid(), wrap openned codes of read_all_xattrs() into fsck_sanity_check_nid(). Then fsck_sanity_check_nid() can be reused later. Signed-off-by: Chao Yu <chao@kernel.org> --- fsck/fsck.c | 16 ++++++++++++---- fsck/fsck.h | 3 +-- fsck/xattr.c | 12 +----------- 3 files changed, 14 insertions(+), 17 deletions(-)