From patchwork Sun Jan 14 18:21:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chao Yu X-Patchwork-Id: 13520885 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0430AC47077 for ; Tue, 16 Jan 2024 14:24:36 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rPkMl-00068g-9E; Tue, 16 Jan 2024 14:24:35 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rPkMh-00068W-PJ for linux-f2fs-devel@lists.sourceforge.net; Tue, 16 Jan 2024 14:24:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=1+8e+VhLSXmkdEXvwI7ZG0C5ZaayLAYYGE5p3kIL0y0=; b=bqhZecw0Bqic7PZ7NG14HRnZV+ 3to9Orm5n20GBjYt1rFMUWWQIiCnoAHX5RoETGGa5wl2E/Dwcy+Lrx7/mvMCv6bgHpJbRp+z7zEFU iE7gLrWoIvZrLQOwakngMGW5YVnpm5Q0gykbq8z0VWj8ZAWft7ajSW6/e1bC47hR2hm4=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=1+8e+VhLSXmkdEXvwI7ZG0C5ZaayLAYYGE5p3kIL0y0=; b=n MpkB1ebhxFG7z6ZIP4BELOK4CQZp1NnFqoXyLmgiyW07okK1Uo/vx8jadSBa0P6PfJ/+jL5BpNdxt cJVMI8wjuJ5xR0J09DaaXQspt5TSNVqeQSRT6Mg5Dn4LzrzgJoIv2/xubv4wkBJUec9TAlya6+1qe atfwCNHNrG/+8WQ4=; Received: from sin.source.kernel.org ([145.40.73.55]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1rPkMg-0001ih-RA for linux-f2fs-devel@lists.sourceforge.net; Tue, 16 Jan 2024 14:24:32 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id F3753CE19B2; Tue, 16 Jan 2024 14:24:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9EDB3C433F1; Tue, 16 Jan 2024 14:24:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705415050; bh=VZJTPGfILjf+cNF1UZaQjhGTPWGf48SxG/O+ibMRJvo=; h=From:To:Cc:Subject:Date:From; b=Hxgfm2FavourMrxlmO1xyRBDpXaraB/ZGD9ZmOaWqJ4GGwc9F7cq4YMFgGzAdjH8B oiygj/hJRapv2rvxDbxBSr6hQdGCcQeRPbJzkS4Tnwl4rwV0iR8lLBD5vktI7JGJsK He7O04aTDJWykYDSAdzk58Xh6zMJNRLDyzCVbyAgOS/Yyn3CqrUJymASvRrKnMG51m a+qP+kDFJmXK65/uS11ZQycSjIv+DIwW0h7BF1hOC+gSfCpLZEHKbuFhXa+t5iWXbP 6biSI4aWNg1ps/06XReoDgz+qUs3vCJ82tGVothM4ar/aIecYA/rd4xFdHWYxf3hYf a1uV1oiAHBC2g== From: Chao Yu To: jaegeuk@kernel.org Date: Mon, 15 Jan 2024 02:21:18 +0800 Message-Id: <20240114182118.38596-1-chao@kernel.org> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 X-Headers-End: 1rPkMg-0001ih-RA Subject: [f2fs-dev] [PATCH] fsck.f2fs: fix to avoid assert in do_record_fsync_data() X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kane Ch'in , linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net 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 Signed-off-by: Chao Yu --- 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);