aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaegeuk Kim <jaegeuk@kernel.org>2014-08-28 10:56:14 -0700
committerJP Abgrall <jpa@google.com>2014-09-08 14:55:01 -0700
commit1118af29cae53275851c3b1f7ef266e67cc7e2a7 (patch)
tree1fdcde82f544186d61e9cedc1adcbeebad975ce2
parent83e54446710466a0c4493236079184131f0004ce (diff)
downloadandroid_external_f2fs-tools-1118af29cae53275851c3b1f7ef266e67cc7e2a7.tar.gz
android_external_f2fs-tools-1118af29cae53275851c3b1f7ef266e67cc7e2a7.tar.bz2
android_external_f2fs-tools-1118af29cae53275851c3b1f7ef266e67cc7e2a7.zip
fsck.f2fs: remove corrupted xattr block
Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
-rw-r--r--fsck/fsck.c65
-rw-r--r--fsck/fsck.h1
2 files changed, 36 insertions, 30 deletions
diff --git a/fsck/fsck.c b/fsck/fsck.c
index 914dcb9..53a64b7 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -266,6 +266,34 @@ static int sanity_check_nid(struct f2fs_sb_info *sbi, u32 nid,
return 0;
}
+static int fsck_chk_xattr_blk(struct f2fs_sb_info *sbi, u32 ino,
+ u32 x_nid, u32 *blk_cnt)
+{
+ struct f2fs_node *node_blk = NULL;
+ struct node_info ni;
+ int ret = 0;
+
+ if (x_nid == 0x0)
+ return 0;
+
+ node_blk = (struct f2fs_node *)calloc(BLOCK_SZ, 1);
+ ASSERT(node_blk != NULL);
+
+ /* Sanity check */
+ if (sanity_check_nid(sbi, x_nid, node_blk,
+ F2FS_FT_XATTR, TYPE_XATTR, &ni)) {
+ ret = -EINVAL;
+ goto out;
+ }
+
+ *blk_cnt = *blk_cnt + 1;
+ f2fs_set_main_bitmap(sbi, ni.blk_addr);
+ DBG(2, "ino[0x%x] x_nid[0x%x]\n", ino, x_nid);
+out:
+ free(node_blk);
+ return ret;
+}
+
int fsck_chk_node_blk(struct f2fs_sb_info *sbi, struct f2fs_inode *inode,
u32 nid, enum FILE_TYPE ftype, enum NODE_TYPE ntype,
u32 *blk_cnt)
@@ -354,8 +382,14 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
}
}
- fsck_chk_xattr_blk(sbi, nid,
- le32_to_cpu(node_blk->i.i_xattr_nid), blk_cnt);
+ if (fsck_chk_xattr_blk(sbi, nid,
+ le32_to_cpu(node_blk->i.i_xattr_nid), blk_cnt) &&
+ config.fix_cnt) {
+ node_blk->i.i_xattr_nid = 0;
+ need_fix = 1;
+ FIX_MSG("Remove xattr block: 0x%x, x_nid = 0x%x",
+ nid, le32_to_cpu(node_blk->i.i_xattr_nid));
+ }
if (ftype == F2FS_FT_CHRDEV || ftype == F2FS_FT_BLKDEV ||
ftype == F2FS_FT_FIFO || ftype == F2FS_FT_SOCK)
@@ -720,33 +754,6 @@ void fsck_chk_orphan_node(struct f2fs_sb_info *sbi)
free(orphan_blk);
}
-void fsck_chk_xattr_blk(struct f2fs_sb_info *sbi, u32 ino,
- u32 x_nid, u32 *blk_cnt)
-{
- struct f2fs_node *node_blk = NULL;
- struct node_info ni;
-
- if (x_nid == 0x0)
- return;
-
- node_blk = (struct f2fs_node *)calloc(BLOCK_SZ, 1);
- ASSERT(node_blk != NULL);
-
- /* Sanity check */
- if (sanity_check_nid(sbi, x_nid, node_blk,
- F2FS_FT_XATTR, TYPE_XATTR, &ni)) {
- /* TODO: drop xattr node */
- printf("drop xattr node\n");
- goto out;
- }
-
- *blk_cnt = *blk_cnt + 1;
- f2fs_set_main_bitmap(sbi, ni.blk_addr);
- DBG(2, "ino[0x%x] x_nid[0x%x]\n", ino, x_nid);
-out:
- free(node_blk);
-}
-
void fsck_init(struct f2fs_sb_info *sbi)
{
struct f2fs_fsck *fsck = F2FS_FSCK(sbi);
diff --git a/fsck/fsck.h b/fsck/fsck.h
index a3f03fd..85cc931 100644
--- a/fsck/fsck.h
+++ b/fsck/fsck.h
@@ -77,7 +77,6 @@ enum seg_type {
SEG_TYPE_MAX,
};
-extern void fsck_chk_xattr_blk(struct f2fs_sb_info *, u32, u32, u32 *);
extern void fsck_chk_orphan_node(struct f2fs_sb_info *);
extern int fsck_chk_node_blk(struct f2fs_sb_info *, struct f2fs_inode *, u32,
enum FILE_TYPE, enum NODE_TYPE, u32 *);