linux-f2fs-devel.lists.sourceforge.net archive mirror
 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: [RFC PATCH RESEND 5/5] fsck.f2fs: try to recover cp_payload from valid cp pack
Date: Thu, 30 Aug 2018 11:37:33 +0800	[thread overview]
Message-ID: <20180830033733.236460-5-zhengjunling@huawei.com> (raw)
In-Reply-To: <20180830033733.236460-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 71af6b2..8a7d6e4 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -945,12 +945,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.18.0


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

  parent reply	other threads:[~2018-08-30  3:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-30  3:37 [RFC PATCH RESEND 1/5] f2fs: support superblock checksum Junling Zheng
2018-08-30  3:37 ` [RFC PATCH RESEND 2/5] f2fs-tools: rename CHECKSUM_OFFSET to CP_CHKSUM_OFFSET Junling Zheng
2018-08-30  3:37 ` [RFC PATCH v3 3/5] f2fs-tools: unify the writeback of superblock Junling Zheng
2018-08-30 15:43   ` Chao Yu
2018-09-07 22:23   ` Jaegeuk Kim
2018-09-11  2:43     ` Junling Zheng
2018-09-11  3:28       ` Junling Zheng
2018-09-11 22:14         ` Jaegeuk Kim
2018-08-30  3:37 ` [RFC PATCH RESEND 4/5] f2fs-tools: introduce sb checksum Junling Zheng
2018-08-30  3:37 ` Junling Zheng [this message]
2018-09-06  3:12   ` [RFC PATCH RESEND 5/5] fsck.f2fs: try to recover cp_payload from valid cp pack Chao Yu
2018-09-06  3:05 ` [RFC PATCH RESEND 1/5] f2fs: support superblock checksum Chao Yu

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=20180830033733.236460-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 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).