linux-f2fs-devel.lists.sourceforge.net archive mirror
 help / color / mirror / Atom feed
From: Chao Yu <chao@kernel.org>
To: jaegeuk@kernel.org
Cc: Kane Ch'in <qinfd2023@lzu.edu.cn>,
	linux-f2fs-devel@lists.sourceforge.net
Subject: [f2fs-dev] [PATCH] fsck.f2fs: fix to avoid assert in do_record_fsync_data()
Date: Mon, 15 Jan 2024 02:21:18 +0800	[thread overview]
Message-ID: <20240114182118.38596-1-chao@kernel.org> (raw)

As Kane Ch'in reported in bugzilla [1]

I am using some Debian VMs with f2fs root partition for development.
My host machine crashed for some reason and this caused the f2fs
partitions in the VMs to become corrupted. I tried to boot from Debian
Live and repair the partitions but failed.

do_record_fsync_data: [node] ino = 24573, nid = 0, blkaddr = 2063580
recover_data: ino = 24573, nid = 0, recorded = 0, err = 0
do_record_fsync_data: [node] ino = 471286, nid = 0, blkaddr = 2063581
recover_data: ino = 471286, nid = 0, recorded = 0, err = 0
[ASSERT] (do_record_fsync_data:3475) 0

During do_record_fsync_data(), if dnode in warm node chain is valid in
SIT table, it's better to continue checking rather than triggering
assert().

[1] https://bugzilla.kernel.org/show_bug.cgi?id=218349

Reported-by: Kane Ch'in <qinfd2023@lzu.edu.cn>
Signed-off-by: Chao Yu <chao@kernel.org>
---
 fsck/mount.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/fsck/mount.c b/fsck/mount.c
index 30c6228..345556d 100644
--- a/fsck/mount.c
+++ b/fsck/mount.c
@@ -3811,14 +3811,11 @@ static int do_record_fsync_data(struct f2fs_sb_info *sbi,
 	se = get_seg_entry(sbi, segno);
 	offset = OFFSET_IN_SEG(sbi, blkaddr);
 
-	if (f2fs_test_bit(offset, (char *)se->cur_valid_map)) {
-		ASSERT(0);
-		return -1;
-	}
-	if (f2fs_test_bit(offset, (char *)se->ckpt_valid_map)) {
-		ASSERT(0);
-		return -1;
-	}
+	if (f2fs_test_bit(offset, (char *)se->cur_valid_map))
+		return 1;
+
+	if (f2fs_test_bit(offset, (char *)se->ckpt_valid_map))
+		return 1;
 
 	if (!se->ckpt_valid_blocks)
 		se->ckpt_type = CURSEG_WARM_NODE;
@@ -3912,8 +3909,11 @@ static int traverse_dnodes(struct f2fs_sb_info *sbi,
 			goto next;
 
 		err = do_record_fsync_data(sbi, node_blk, blkaddr);
-		if (err)
+		if (err) {
+			if (err > 0)
+				err = 0;
 			break;
+		}
 
 		if (entry->blkaddr == blkaddr)
 			del_fsync_inode(entry);
-- 
2.40.1



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

                 reply	other threads:[~2024-01-16 14:24 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20240114182118.38596-1-chao@kernel.org \
    --to=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=qinfd2023@lzu.edu.cn \
    /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).