All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junling Zheng <zhengjunling@huawei.com>
To: jaegeuk@kernel.org, yuchao0@huawei.com
Cc: miaoxie@huawei.com, linux-f2fs-devel@lists.sourceforge.net
Subject: [PATCH 5/5] fsck.f2fs: try to recover cp_payload from valid cp pack
Date: Wed, 19 Sep 2018 21:53:51 +0800	[thread overview]
Message-ID: <20180919135352.173525-5-zhengjunling@huawei.com> (raw)
In-Reply-To: <20180919135352.173525-1-zhengjunling@huawei.com>

From: Chao Yu <yuchao0@huawei.com>

If sb checksum is not enabled, and cp pack is valid due to no
crc inconsistence, let's try to recover cp_payload based on
cp_pack_start_sum in cp pack.

Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
 fsck/f2fs.h  |  5 +++++
 fsck/mount.c | 10 +++++++---
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/fsck/f2fs.h b/fsck/f2fs.h
index d216444..0d0d5e2 100644
--- a/fsck/f2fs.h
+++ b/fsck/f2fs.h
@@ -259,6 +259,11 @@ static inline unsigned long __bitmap_size(struct f2fs_sb_info *sbi, int flag)
 	return 0;
 }
 
+static inline block_t __cp_payload(struct f2fs_sb_info *sbi)
+{
+	return le32_to_cpu(F2FS_RAW_SUPER(sbi)->cp_payload);
+}
+
 static inline void *__bitmap_ptr(struct f2fs_sb_info *sbi, int flag)
 {
 	struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
diff --git a/fsck/mount.c b/fsck/mount.c
index 9019921..0e8fa41 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -975,12 +975,16 @@ int sanity_check_ckpt(struct f2fs_sb_info *sbi)
 	}
 
 	cp_pack_start_sum = __start_sum_addr(sbi);
-	cp_payload = get_sb(cp_payload);
+	cp_payload = __cp_payload(sbi);
 	if (cp_pack_start_sum < cp_payload + 1 ||
 		cp_pack_start_sum > blocks_per_seg - 1 -
 			NR_CURSEG_TYPE) {
-		MSG(0, "\tWrong cp_pack_start_sum(%u)\n", cp_pack_start_sum);
-		return 1;
+		MSG(0, "\tWrong cp_pack_start_sum(%u) or cp_payload(%u)\n",
+			cp_pack_start_sum, cp_payload);
+		if ((get_sb(feature) & F2FS_FEATURE_SB_CHKSUM))
+			return 1;
+		set_sb(cp_payload, cp_pack_start_sum - 1);
+		update_superblock(sb, SB_ALL);
 	}
 
 	return 0;
-- 
2.19.0

  parent reply	other threads:[~2018-09-19 13:54 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-19 13:53 [PATCH 1/5] f2fs: support superblock checksum Junling Zheng
2018-09-19 13:53 ` [PATCH 2/5] f2fs-tools: rename CHECKSUM_OFFSET to CP_CHKSUM_OFFSET Junling Zheng
2018-09-19 13:53 ` [PATCH 3/5] fsck.f2fs: unify the updating of superblocks Junling Zheng
2018-09-19 23:33   ` Jaegeuk Kim
2018-09-19 13:53 ` [PATCH 4/5] f2fs-tools: introduce sb checksum Junling Zheng
2018-09-19 23:35   ` Jaegeuk Kim
2018-09-20  2:17     ` Junling Zheng
2018-09-20 21:38       ` Jaegeuk Kim
2018-09-21  3:09         ` Junling Zheng
2018-09-26  1:57           ` Jaegeuk Kim
2018-09-26  3:54             ` Junling Zheng
2018-09-26 20:27               ` Jaegeuk Kim
2018-09-27  2:46                 ` Junling Zheng
2018-09-19 13:53 ` Junling Zheng [this message]
2018-09-19 23:38   ` [PATCH 5/5] fsck.f2fs: try to recover cp_payload from valid cp pack Jaegeuk Kim
2018-09-20  2:38     ` Junling Zheng
2018-09-20  6:45       ` Chao Yu
2018-09-28 12:25 [PATCH 1/5] f2fs: support superblock checksum Junling Zheng
2018-09-28 12:26 ` [PATCH 5/5] fsck.f2fs: try to recover cp_payload from valid cp pack Junling Zheng

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=20180919135352.173525-5-zhengjunling@huawei.com \
    --to=zhengjunling@huawei.com \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=miaoxie@huawei.com \
    --cc=yuchao0@huawei.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.