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 5/6] fsck.f2fs: skip block count fix when i_links is fixed
Date: Thu, 26 Mar 2015 17:03:08 -0700	[thread overview]
Message-ID: <1427414589-66956-5-git-send-email-jaegeuk@kernel.org> (raw)
In-Reply-To: <1427414589-66956-1-git-send-email-jaegeuk@kernel.org>

If i_links is wrong, we should not check block count, since it doesn't count
correctly which results in changing the block count to 1.

This patch fixes that.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fsck/fsck.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/fsck/fsck.c b/fsck/fsck.c
index 8cfea56..97bf6ce 100644
--- a/fsck/fsck.c
+++ b/fsck/fsck.c
@@ -440,7 +440,7 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
 						"i_links= 0x%x -> 0x%x",
 						nid, i_links, i_links + 1);
 				}
-				goto check;
+				goto skip_blkcnt_fix;
 			}
 			/* No need to go deep into the node */
 			return;
@@ -550,6 +550,18 @@ void fsck_chk_inode_blk(struct f2fs_sb_info *sbi, u32 nid,
 		}
 	}
 check:
+	if (i_blocks != *blk_cnt) {
+		ASSERT_MSG("ino: 0x%x has i_blocks: %08"PRIx64", "
+				"but has %u blocks",
+				nid, i_blocks, *blk_cnt);
+		if (config.fix_on) {
+			node_blk->i.i_blocks = cpu_to_le64(*blk_cnt);
+			need_fix = 1;
+			FIX_MSG("[0x%x] i_blocks=0x%08"PRIx64" -> 0x%x",
+					nid, i_blocks, *blk_cnt);
+		}
+	}
+skip_blkcnt_fix:
 	if (ftype == F2FS_FT_DIR)
 		DBG(1, "Directory Inode: 0x%x [%s] depth: %d has %d files\n\n",
 				le32_to_cpu(node_blk->footer.ino),
@@ -562,17 +574,6 @@ check:
 				node_blk->i.i_name,
 				(u32)i_blocks);
 
-	if (i_blocks != *blk_cnt) {
-		ASSERT_MSG("ino: 0x%x has i_blocks: %08"PRIx64", "
-				"but has %u blocks",
-				nid, i_blocks, *blk_cnt);
-		if (config.fix_on) {
-			node_blk->i.i_blocks = cpu_to_le64(*blk_cnt);
-			need_fix = 1;
-			FIX_MSG("[0x%x] i_blocks=0x%08"PRIx64" -> 0x%x",
-					nid, i_blocks, *blk_cnt);
-		}
-	}
 	if (ftype == F2FS_FT_DIR && i_links != child_cnt) {
 		ASSERT_MSG("ino: 0x%x has i_links: %u but real links: %u",
 				nid, i_links, child_cnt);
-- 
2.1.1


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/

  parent reply	other threads:[~2015-03-27  0:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-27  0:03 [PATCH 1/6] fsck.f2fs: reduce redundant message Jaegeuk Kim
2015-03-27  0:03 ` [PATCH 2/6] fsck.f2fs: remove inconsistent named directories Jaegeuk Kim
2015-03-27  0:03 ` [PATCH 3/6] fsck.f2fs: check file types Jaegeuk Kim
2015-03-27  0:03 ` [PATCH 4/6] fsck.f2fs: fix inodes having wrong i_links Jaegeuk Kim
2015-03-27  0:03 ` Jaegeuk Kim [this message]
2015-03-27  0:03 ` [PATCH 6/6] fsck.f2fs: preserve orphan blocks 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=1427414589-66956-5-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).