Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp871845rdg; Fri, 13 Oct 2023 03:59:52 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE7wZvjqOsVeSRntDHw7hdiEAfwmumw4hLaPqR2VWICRaZvljm9QQvn2uYOLJ+zicUIzYlR X-Received: by 2002:a05:6830:1653:b0:6b9:6419:1cde with SMTP id h19-20020a056830165300b006b964191cdemr31224655otr.22.1697194791720; Fri, 13 Oct 2023 03:59:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697194791; cv=none; d=google.com; s=arc-20160816; b=yPMeORvbkSCV3IGMlgRmSLfJEGihWOIqpMCJj5lc4ujPUj46IYKrBMTOqazPq//Dys 8BFtHR3d88yW5pW5Ud1l2lOYmkg+98Prkac+Dcu8ECCckTdnRcXNe5zgdHalnFN5PT47 d/f3oj7aIvUgIHBjKr6qbE6ZawuPhmzAEUwqdwLrh5/3Bb5yYk5nDohn8Di7KecEPQkC +MykHiGLA4LuX68aGHa8ju+sB3qLmucxaFFjK5blFIsjjuZIAQUmAuavX23k7zyv6hkn turB16l6GkgZcFAbnOGjVqcXt5FoHRz5McZkvcEvHnVNltZ5j8esQNCsCcWYmQev+YfE LMJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=Mogbi/2oqpyAyBS1J5rCe6n6lYblpP0L0ZK8pevYaPE=; fh=jjDTLTkAaPK3cTutO2P9ZECZUYkGOS1dcBtirQV26To=; b=UQnLFAWrnZh/L720S9V3n3yC8hqtkP2mMwELrTK+T3umgeTMG5/RspMeyPKAmO6ipb rS60S5HTHCxDCibutIdy/ZAhVh5t5j4PtSAQW+hwAuhBmkh0HyarmPsf+V/rPbTuJJjf fpzG4psDDeMWXDfkObUvSZckFBaeBEIuSEaX38QAHlqFiZf7SeuAs3ZamqrhjxwR75pp xQ9Xrhjjxo8EQ4VpJ3fdI4O0K3sSF86rGmNS4TK3z/Tu8afu8uuupoxsDL8EYVXKzzGn uHS7yIyq9cS6V8s1aN5YPXYWyftE7s7vXDsHzkPx1rQr+1DZyMaJ5ipuiVJOKRe3aEiK 5VlA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id e6-20020a056a001a8600b0068fb8704b9csi17001404pfv.28.2023.10.13.03.59.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Oct 2023 03:59:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 79C1181BE2D6; Fri, 13 Oct 2023 03:59:49 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230103AbjJMK7o (ORCPT + 99 others); Fri, 13 Oct 2023 06:59:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229940AbjJMK7m (ORCPT ); Fri, 13 Oct 2023 06:59:42 -0400 Received: from SHSQR01.spreadtrum.com (unknown [222.66.158.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A39F83 for ; Fri, 13 Oct 2023 03:59:39 -0700 (PDT) Received: from dlp.unisoc.com ([10.29.3.86]) by SHSQR01.spreadtrum.com with ESMTP id 39DAworm019695; Fri, 13 Oct 2023 18:58:50 +0800 (+08) (envelope-from Zhiguo.Niu@unisoc.com) Received: from SHDLP.spreadtrum.com (bjmbx01.spreadtrum.com [10.0.64.7]) by dlp.unisoc.com (SkyGuard) with ESMTPS id 4S6NgW2XMhz2KWZZn; Fri, 13 Oct 2023 18:54:47 +0800 (CST) Received: from bj08434pcu.spreadtrum.com (10.0.73.87) by BJMBX01.spreadtrum.com (10.0.64.7) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Fri, 13 Oct 2023 18:58:49 +0800 From: Zhiguo Niu To: , CC: , , , Subject: [PATCH] f2fs: fix error path of __f2fs_build_free_nids Date: Fri, 13 Oct 2023 18:58:23 +0800 Message-ID: <1697194703-21371-1-git-send-email-zhiguo.niu@unisoc.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.0.73.87] X-ClientProxiedBy: SHCAS01.spreadtrum.com (10.0.1.201) To BJMBX01.spreadtrum.com (10.0.64.7) X-MAIL: SHSQR01.spreadtrum.com 39DAworm019695 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 13 Oct 2023 03:59:49 -0700 (PDT) SBI_NEED_FSCK should be set for fsck has a chance to repair in case of scan_nat_page fail in run time. Signed-off-by: Zhiguo Niu --- fs/f2fs/node.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index ee2e1dd..d9e6087 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c @@ -2499,12 +2499,15 @@ static int __f2fs_build_free_nids(struct f2fs_sb_info *sbi, ret = PTR_ERR(page); } else { ret = scan_nat_page(sbi, page, nid); + if (ret && !mount) { + set_sbi_flag(sbi, SBI_NEED_FSCK); + f2fs_err(sbi, "NAT is corrupt, run fsck to fix it"); + } f2fs_put_page(page, 1); } if (ret) { f2fs_up_read(&nm_i->nat_tree_lock); - f2fs_err(sbi, "NAT is corrupt, run fsck to fix it"); return ret; } } -- 1.9.1