linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Jaegeuk Kim <jaegeuk@kernel.org>
To: linux-f2fs-devel@lists.sourceforge.net
Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Subject: [PATCH 13/17] fsck.f2fs: remove corrupted xattr block
Date: Fri, 29 Aug 2014 17:29:00 -0700	[thread overview]
Message-ID: <1409358544-54740-13-git-send-email-jaegeuk@kernel.org> (raw)
In-Reply-To: <1409358544-54740-1-git-send-email-jaegeuk@kernel.org>

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fsck/fsck.c | 65 ++++++++++++++++++++++++++++++++++---------------------------
 fsck/fsck.h |  1 -
 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 *);
-- 
1.8.5.2 (Apple Git-48)


------------------------------------------------------------------------------
Slashdot TV.  
Video for Nerds.  Stuff that matters.
http://tv.slashdot.org/

  parent reply	other threads:[~2014-08-30  0:29 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-30  0:28 [PATCH 01/17] f2fs_dentry_hash: avoid casting unsigned char to singed char Jaegeuk Kim
2014-08-30  0:28 ` [PATCH 02/17] fsck.f2fs: retry to fix corrupted image Jaegeuk Kim
2014-08-30  0:28 ` [PATCH 03/17] fsck.f2fs: clean up codes Jaegeuk Kim
2014-08-30  0:28 ` [PATCH 04/17] fsck.f2fs: handle IS_VALID_BLK_ADDR Jaegeuk Kim
2014-08-30  0:28 ` [PATCH 05/17] fsck.f2fs: remove return value of get_node_info Jaegeuk Kim
2014-08-30  0:28 ` [PATCH 06/17] fsck.f2fs: handle error cases Jaegeuk Kim
2014-08-30  0:28 ` [PATCH 07/17] fsck.f2fs: cleanup mount.c Jaegeuk Kim
2014-08-30  0:28 ` [PATCH 08/17] fsck.f2fs: give a chance to recover sit entries Jaegeuk Kim
2014-08-30  0:28 ` [PATCH 09/17] fsck.f2fs: fix inode block inconsistency Jaegeuk Kim
2014-08-30  0:28 ` [PATCH 10/17] fsck.f2fs: add fixing messeages Jaegeuk Kim
2014-08-30  0:28 ` [PATCH 11/17] fsck.f2fs: remove dentry if its inode block is corrupted Jaegeuk Kim
2014-08-30  0:28 ` [PATCH 12/17] fsck.f2fs: corrupted orphan inode will be removed Jaegeuk Kim
2014-08-30  0:29 ` Jaegeuk Kim [this message]
2014-08-30  0:29 ` [PATCH 14/17] fsck.f2fs: handle correctly segment summary entries Jaegeuk Kim
2014-08-30  0:29 ` [PATCH 15/17] fsck.f2fs: fix checkpoint Jaegeuk Kim
2014-08-30  0:29 ` [PATCH 16/17] fsck.f2fs: check next block is free or not Jaegeuk Kim
2014-08-30  0:29 ` [PATCH 17/17] fsck.f2fs: remove list.h Jaegeuk Kim

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1409358544-54740-13-git-send-email-jaegeuk@kernel.org \
    --to=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).