Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1423715pxb; Fri, 24 Sep 2021 04:20:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyO4jf6YfyD1lOtsk+P3WX7rO9Nh1x16IL/TvqPupJeZz+VX7RKfZM5QecAt9rk6bvAoaL+ X-Received: by 2002:a6b:2bce:: with SMTP id r197mr8417942ior.212.1632482423617; Fri, 24 Sep 2021 04:20:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632482423; cv=none; d=google.com; s=arc-20160816; b=oAsW1EjSeejdca8QtJLXYw/MlsNDpfPX/dt6y1bID4BYmf/hoDTPi6aJ9j7eyNzDjI WSx88RG/k2GbwIfHSAWXU3w5XlFMeVL5k3gsx8UPbqv83mNViP2AQoOECRokFXhPjVSX gx5CWgBAHl0s28h0RQ9Zgd8+J0HHp0uPluyzXC/o7bRJTtt7O53vSxL7k4kBLY2EfjYL Ls7cw2j0q6oURxQzh+RCUFHWEogkCYYN6TJ4d6HcaEGeBcdhZqJzAlHHpJIggg/GROxZ 7S+Llw877X1UCGR7vErnvwKk/AerunWK0fTPG2Muzp6Tx9Dz9Ys2VR836DpgP9mLbONr 8h3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=zZ2NacrQY3T5Q/4VbAHrJiAeXdZY8CBFics80H9s+IE=; b=tb+D6slQ6xnMD/Q9GkZ5AyGY1z11/DxQlk4u733m6PPqcVRt8f6jurrPYJlSNhop6S 1WLxrBipD0LlKLElFZLUdT6qh2vUD4CC6Q6eV4/TuL7PDLynzyRHXrJ/BOzZYtfTT0Q2 gzBrvxPYqUdpX+n40IW3M90YnvT5EDPxMgNbYcKujYBoU1BMEcZ9eXXZ2NQityD5KB/V 8tSQLPYoxu4edZ/Wvl+S2+/UuHUE/xGyOLwhTCbBTb+Z9ZL5RB0THl3/TC/tSRgc8J9F JHAJZRnA5toPYnbX526VUjCT0+D4u8LURL25EzJhQ24lRPw8b20WmqNqfcVhpzmeD14+ A5Tw== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i22si10898935jaj.107.2021.09.24.04.20.06; Fri, 24 Sep 2021 04:20:23 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245375AbhIXJwT (ORCPT + 99 others); Fri, 24 Sep 2021 05:52:19 -0400 Received: from jabberwock.ucw.cz ([46.255.230.98]:60624 "EHLO jabberwock.ucw.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245429AbhIXJv6 (ORCPT ); Fri, 24 Sep 2021 05:51:58 -0400 Received: by jabberwock.ucw.cz (Postfix, from userid 1017) id 1A2481C0BA3; Fri, 24 Sep 2021 11:50:22 +0200 (CEST) Date: Fri, 24 Sep 2021 11:50:21 +0200 From: Pavel Machek To: Chao Yu Cc: jaegeuk@kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Pavel Machek Subject: Re: [PATCH] f2fs: fix incorrect return value in f2fs_sanity_check_ckpt() Message-ID: <20210924095021.GA16651@duo.ucw.cz> References: <20210922152705.720071-1-chao@kernel.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="Qxx1br4bt0+wmkIi" Content-Disposition: inline In-Reply-To: <20210922152705.720071-1-chao@kernel.org> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --Qxx1br4bt0+wmkIi Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > This code looks quite confused: part of function returns 1 on > corruption, part returns -errno. The problem is not stable-specific. >=20 > [1] https://lkml.org/lkml/2021/9/19/207 >=20 > 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. >=20 > Fixes: 65ddf6564843 ("f2fs: fix to do sanity check for sb/cp fields corre= ctly") > Reported-by: Pavel Machek > Signed-off-by: Chao Yu Reviewed-by: Pavel Machek (This is good minimal fix, but eventually I believe the function should switch to 0/-errno... for consistency with rest of kernel). Thank you, Pavel =09 > +++ 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 >=3D blocks_per_seg)) { > f2fs_warn(sbi, "Insane cp_payload: %u, nat_bits_blocks: %u)", > cp_payload, nat_bits_blocks); > - return -EFSCORRUPTED; > + return 1; > } > =20 > if (unlikely(f2fs_cp_error(sbi))) { --=20 DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany --Qxx1br4bt0+wmkIi Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQRPfPO7r0eAhk010v0w5/Bqldv68gUCYU2fXQAKCRAw5/Bqldv6 8pXIAJ4nca/YOddxdbLx3i18slR3oC/ClQCeJWytQZvNXNh3szUC6zUX3YfJexw= =nsrq -----END PGP SIGNATURE----- --Qxx1br4bt0+wmkIi--