Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp314999rwb; Wed, 18 Jan 2023 18:15:13 -0800 (PST) X-Google-Smtp-Source: AMrXdXvPdmjAcR/He1FA1AGLsj6PvrYIf296Dk8a2AFGWndai1y0LwWNgqHFvL704S86g3tq8EVd X-Received: by 2002:a17:906:4d0a:b0:84d:3e38:2f0c with SMTP id r10-20020a1709064d0a00b0084d3e382f0cmr23764275eju.67.1674094513150; Wed, 18 Jan 2023 18:15:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674094513; cv=none; d=google.com; s=arc-20160816; b=HfOcLJSPw2zjMqin3jMf3ylKIYDSJJwN57Vx8WVsCieofE3WbLSsk8jN/xq3/l6ld+ ciTHzESMDWtjUySvT1WJwe6aNLDGZOvrSCri7rle5YMItJhBkFVyvQYks1fhFMjw0BUj Q19H+owIA7XGnawH0J0lJyZJlA1VyA/ZIcEnLw1xw+d8HQsxUbC77UhNNH8mU5OXSmoU bC2m7PcPzzjAHAM/nXdeaTwPaEtN7vT4XtRb3i+yjfBWBmTBGyu2+aMJbqxpUutEBFK7 FbceuBOAd43pKV9zsgRHYOVukY6JfVSuLEAZZfFCyjTr6A9imw1hvXmGOTczfWUw3cEN NBdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=g4F3Zs3w22GO5X/MIW7hv2fq/TwBgb+OFG6dSf4fyTc=; b=z59BefwnZJ2tZ/JU3ESMZk7ZVI0GU/SdnvIYu405gKtpWAoNixtBYhn0kYIec67Wz5 l4a0f1Uax8WKricouXHGqG7vq4fP8flxH0JQij5VVd4VR0BQWilBd3QuKJ5vyc8PaUPw 7iKn9v91baGAKrvY6i8tsmZqfczexQ2I0K4WQhZM/e3lqPFAcYJbKopt09LqXXRmFmh9 dBPUXPlPI7DAIfmpSN2g9FA5cmiSW2Okif6ddHXihHlZ7olU8hA31q3IG5z4pZCiSaTK 6FJP/ydha07AfINWJv/2DpUVSspo3QZ0ClFAeY/651Pz1Uju1pU6RG0BJUq4HPpH9MW4 Taiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BjIj96Gx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id xa5-20020a170906fd8500b0084d3fbc7accsi17869411ejb.492.2023.01.18.18.15.02; Wed, 18 Jan 2023 18:15:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BjIj96Gx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S229686AbjASBxp (ORCPT + 44 others); Wed, 18 Jan 2023 20:53:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52164 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229583AbjASBxT (ORCPT ); Wed, 18 Jan 2023 20:53:19 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E70956DB18 for ; Wed, 18 Jan 2023 17:49:27 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8514D60684 for ; Thu, 19 Jan 2023 01:49:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B544DC433EF; Thu, 19 Jan 2023 01:49:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1674092966; bh=fdFF2OaMWXDBkxzhr2snVJKR68kmvzno7bMlUn5Eirc=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=BjIj96GxNIV0MW/vuyH04/n8Eqb8E2EVCjs+0hLQ2jHOTMDjX1NMhwAMeijmBN46A xLLSLvnqVIx2Fl4s8WIRhTwGlrDvbvgnk8Kbd1/52ZEMun58Bm1tgiWQ6hD9UaxWCz 2BjiPPynSKp1uMHWnwSKJXtTKwjcj6k3fPhTou1voD47B0ADwhnHkGVUlhoT7PRsbh eFLfPTz1zfa17SZ5pFCkRn5KePPM0iLfNUTUlo1RyPUAPV4On2Jw4cNhzjOdk2kV+f 6TzUzfGdSAWKHAkwW1Qo+HjyiBeTDQ9h/7x/WT7ZbCBHJAqaMDNF4qYJoNEoC7BoG/ YniDwLC78ya+Q== Date: Wed, 18 Jan 2023 17:49:25 -0800 From: Jaegeuk Kim To: Yangtao Li Cc: chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [f2fs-dev] [PATCH v2 1/2] f2fs: fix to avoid potential memory corruption in __update_iostat_latency() Message-ID: References: <20230116134755.40119-1-frank.li@vivo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230116134755.40119-1-frank.li@vivo.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/16, Yangtao Li wrote: > Hi Chao, > > > Maybe it's betterr to merge these two check condition as below? > > > > if (iotype >= NR_PAGE_TYPE) { > > f2fs_bug_on(sbi, iotype != META_FLUSH); > > iotype = META; > > } > > For normal , only META_FLUSH will be greater than NR_PAGE_TYPE, > there is no problem with this logic. > > > > > For CHECK_FS is off case, I guess it's fine to not return and just print > > warning message for notice. > > But if there is an exception, we don't know the type we originally wanted to count. > If they are all changed to meta, it is possible to get a wrong statistic. I think > there is no need to make statistics on this kind of error scene. Just like in the > next patch, if iostat_lat_type is wrong, we should return directly instead of changing > the value beyond the range to WRITE_ASYNC_IO. > > So it's no need tp merge these two check condition? I also prefer to do like Chao's comment. We don't need to expect such exception at all. And, it seems we just need to do like: enum page_type iotype; if (iotype == META_FLUSH) { iotype = META; } else if (iotype >= NR_PAGE_TYPE) { f2fs_warn(); return; } > > Thx, > Yangtao