From mboxrd@z Thu Jan 1 00:00:00 1970 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 C9A4DC4332F for ; Tue, 7 Nov 2023 23:23:14 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1r0VPb-00088h-OX; Tue, 07 Nov 2023 23:23:12 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1r0VPZ-00088a-VJ for linux-f2fs-devel@lists.sourceforge.net; Tue, 07 Nov 2023 23:23:10 +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:References: In-Reply-To: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:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=ZV/tB2zxIEL5+Vxo1eENcom6ehf07BJwLxX0nMRpncQ=; b=BjoVKKr2Q/NosuvVYjrwCVLhIi xRtgKrwifGnt5cla+ERR0CmjfBy4i1NTlXlAQe5IH1+OgaqC/OssIiLYK3qUHJg/I/eH9Sm0fdcB3 hryyrCegf1FyASvyLPcEZgwzeI9WsDks7TzWk0R2lxQA3zxWTo3Fw2CoIeU/Rj6+VnVY=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: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:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=ZV/tB2zxIEL5+Vxo1eENcom6ehf07BJwLxX0nMRpncQ=; b=i3hDDQML023EgLeG/w2lhrAFn9 DW6azy6Vx680WLhnm7jj1untGVEXjVZKn/rkhFDqGRr05PMvdz6O1z0AOMQ+f4rofQmg4NTBmU8A+ WkEthVT+HTaIhs1KM1QsbKaMyOi5uWLU/WU+GWmTAcjzgkN2xyX2/1BcQx+p1JRM/MsI=; 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 1r0VPZ-0005vd-ID for linux-f2fs-devel@lists.sourceforge.net; Tue, 07 Nov 2023 23:23:10 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B74E5CE0219; Tue, 7 Nov 2023 23:23:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2332AC433C8; Tue, 7 Nov 2023 23:23:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699399382; bh=VbLINJBBcOe3ggBEOLfEm+vNop3D93xrWfVtIKzVYpQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ne3E0c3oRYnUGxIg/LgPoscCC45CA8mEs46fGKmEITDA6HPI8iws31AP/w63iFbVc fsipBwxRDl5g6AIspc7O50RxR62pGYzn/5/CME5p5IAfqB4l/N3qBct+PnHpSsUXBo AHfyM8j5Ul2EB0/4xq0ErJ8BUex3SCerAuUVRjFgv5IuYi9s/8vxN2MAOyGzwid1FR fn7WnjGEsDITyndHALAtb3T0BJ0JUbXRCh51HuH3J+j2YBOOu7myNG5hZ5zOkk2whg ZUjmn/sAGi7S5HH6wf1ANn7I8VyUyP8FLI/0SPbWcFwheNajDMANd5Vhnd5uIuSIAB ZrtmQDZlZOK+g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Date: Tue, 7 Nov 2023 18:22:07 -0500 Message-ID: <20231107232231.3775605-13-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231107232231.3775605-1-sashal@kernel.org> References: <20231107232231.3775605-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.6 X-Headers-End: 1r0VPZ-0005vd-ID Subject: [f2fs-dev] [PATCH AUTOSEL 6.6 13/18] f2fs: fix error path of __f2fs_build_free_nids 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: Sasha Levin , Jaegeuk Kim , Zhiguo Niu , linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net From: Zhiguo Niu [ Upstream commit a5e80e18f268ea7c7a36bc4159de0deb3b5a2171 ] If NAT is corrupted, let scan_nat_page() return EFSCORRUPTED, so that, caller can set SBI_NEED_FSCK flag into checkpoint for later repair by fsck. Also, this patch introduces a new fscorrupted error flag, and in above scenario, it will persist the error flag into superblock synchronously to avoid it has no luck to trigger a checkpoint to record SBI_NEED_FSCK Signed-off-by: Zhiguo Niu Signed-off-by: Chao Yu Signed-off-by: Jaegeuk Kim Signed-off-by: Sasha Levin --- fs/f2fs/node.c | 11 +++++++++-- include/linux/f2fs_fs.h | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index ee2e1dd64f256..248764badcde8 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -2389,7 +2389,7 @@ static int scan_nat_page(struct f2fs_sb_info *sbi, blk_addr = le32_to_cpu(nat_blk->entries[i].block_addr); if (blk_addr == NEW_ADDR) - return -EINVAL; + return -EFSCORRUPTED; if (blk_addr == NULL_ADDR) { add_free_nid(sbi, start_nid, true, true); @@ -2504,7 +2504,14 @@ static int __f2fs_build_free_nids(struct f2fs_sb_info *sbi, if (ret) { f2fs_up_read(&nm_i->nat_tree_lock); - f2fs_err(sbi, "NAT is corrupt, run fsck to fix it"); + + if (ret == -EFSCORRUPTED) { + f2fs_err(sbi, "NAT is corrupt, run fsck to fix it"); + set_sbi_flag(sbi, SBI_NEED_FSCK); + f2fs_handle_error(sbi, + ERROR_INCONSISTENT_NAT); + } + return ret; } } diff --git a/include/linux/f2fs_fs.h b/include/linux/f2fs_fs.h index a82a4bb6ce68b..cf1adceb02697 100644 --- a/include/linux/f2fs_fs.h +++ b/include/linux/f2fs_fs.h @@ -104,6 +104,7 @@ enum f2fs_error { ERROR_CORRUPTED_VERITY_XATTR, ERROR_CORRUPTED_XATTR, ERROR_INVALID_NODE_REFERENCE, + ERROR_INCONSISTENT_NAT, ERROR_MAX, }; -- 2.42.0 _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel