Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp576776pxb; Wed, 22 Sep 2021 08:29:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwNeLOR/xM01pjc+WrO3fb5gS2WmM167zy46MAvu85cGq6IQpevnZVft/HbrwegEUXYXfJZ X-Received: by 2002:a5e:c110:: with SMTP id v16mr173764iol.43.1632324557275; Wed, 22 Sep 2021 08:29:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632324557; cv=none; d=google.com; s=arc-20160816; b=AXDbnHLAQUEUhdDnWNYlJVoUMHsWrLx7a58yn94g/Rv7mWJtmx+4UxkeESmiyZ2HgI z8Scan6/5Soodfc8OqriwIheery3Gdqc6R4Be7ziLwdkIeTqNv1fLKYjPkOQ5702Lb6D 32Dd7r3W82zAAP6FJU/rbLy82KAsaALO6T6yi+dN+H4S2hymh3/RX0JDoAZXBsnmvL/T mjoqG3AqxEyesc3jGstTO79ipqFS9LezX+ZXz993BpM/icPQaIZNSTxj59Shyyu6rYiU VzxE7X7fGxOCLiL+7ykqQAsYXpehWmfCoQA78N/1wFIECAblQ6EtHmwc3TysvixVEqLW RiiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=Ha/QDIzTLuWoK7zr1at00zvswB851ryXVplCGrP5cYg=; b=xaa8cz9lOuMrnrlm7ARHPhOn7r5KB9BK5km2k5zLP8IfZxQYfT6qHiPRKn856+jWkd y8CFdLuQ7mZ4NwKV77LlUXgMViJSaKrX977M1JJ5pLR9IMPQQw0qXamfPgw36rQXdHu9 KsTbPfT6Ar4Y93McKkd3PrqYaru4OWJxBtHfztxu0vZo/qaMf9tvAx4qD1sHhr4VOyCN w3SxbvihwnH+B+tMkTChHuCnoN1HVVnsxgBB2vY1pVtjDr1oOsEct24iSLDxoUrokNp8 kFRUEKHKMwztIlMvEKKMdeyXiBQ7m+rBo4gP7l4nT2gk6AZkzfKXq+VzvP4M6MjnwnI/ FyZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eo05KFjB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k17si3185087iow.29.2021.09.22.08.28.42; Wed, 22 Sep 2021 08:29:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=eo05KFjB; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236417AbhIVP2v (ORCPT + 99 others); Wed, 22 Sep 2021 11:28:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:47530 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232318AbhIVP2u (ORCPT ); Wed, 22 Sep 2021 11:28:50 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8E34861168; Wed, 22 Sep 2021 15:27:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632324440; bh=ovV4urk3GlFS7e1HLPM5jlLAOz+tjnV1IqgTo1O9svM=; h=From:To:Cc:Subject:Date:From; b=eo05KFjBJaxgt7DoeZ/1sjWOZ8jeiyUiibfEP585IltwSmx02D5s0T9vTTRjzA5KF 1NAtUYGs5CDz5qQFFtVoaIi2DX3oKxjRaHWCfvigLHIoJigYPdP57xQIM9FOSL3Oii 66Y6scUdY3RnAoXEtsaS6p7DRmLAKfpQV8JkYrGN9g28EfJVQcO+I2Nhr68luqz3Z6 X3SRx0onTuETYf4+aDEOiB8xD9WHZi3t4GtGkUUkSXCvGj1wzJch3YDe2XBqj1QNGd lK2ePpoEKzkzj1kBE9VLwOBUqPiSfaJKhWVZmsTWvCHQNWngeRyT62tEVaigvqS4+6 8zScPDUctzjZQ== From: Chao Yu To: jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Chao Yu , Pavel Machek Subject: [PATCH] f2fs: fix incorrect return value in f2fs_sanity_check_ckpt() Date: Wed, 22 Sep 2021 23:27:05 +0800 Message-Id: <20210922152705.720071-1-chao@kernel.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org As Pavel Machek reported in [1] This code looks quite confused: part of function returns 1 on corruption, part returns -errno. The problem is not stable-specific. [1] https://lkml.org/lkml/2021/9/19/207 Let's fix to make 'insane cp_payload case' to return 1 rater than EFSCORRUPTED, so that return value can be kept consistent for all error cases, it can avoid confusion of code logic. Fixes: 65ddf6564843 ("f2fs: fix to do sanity check for sb/cp fields correctly") Reported-by: Pavel Machek Signed-off-by: Chao Yu --- fs/f2fs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 8d6d0657a470..e3975cb8e3e8 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -3487,7 +3487,7 @@ int f2fs_sanity_check_ckpt(struct f2fs_sb_info *sbi) NR_CURSEG_PERSIST_TYPE + nat_bits_blocks >= blocks_per_seg)) { f2fs_warn(sbi, "Insane cp_payload: %u, nat_bits_blocks: %u)", cp_payload, nat_bits_blocks); - return -EFSCORRUPTED; + return 1; } if (unlikely(f2fs_cp_error(sbi))) { -- 2.32.0