Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3297057rwb; Mon, 16 Jan 2023 06:20:32 -0800 (PST) X-Google-Smtp-Source: AMrXdXtdUBgRLgvEjo3kMaipATT0meTa1iIPYNJg1FUlYZgbYsv69c+dlSr/tr7VcSwnEsOqT2Mq X-Received: by 2002:a17:902:bc44:b0:194:614d:44a2 with SMTP id t4-20020a170902bc4400b00194614d44a2mr16330433plz.51.1673878832798; Mon, 16 Jan 2023 06:20:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1673878832; cv=pass; d=google.com; s=arc-20160816; b=nDS/pXJuHMLYXhXC2XcqI/bRjTO/5f1ttQJkgw6uasUZdJYIT2h0+NnXh+gHWgvn5b LM4nS3YFOGbM/Zqzqbqw9h9R10Lq1d+AZ3Df4hE9UcrzdFX2pO5ObNfVszX/MctdL0s/ hQBgjxNTpUwSmzUQ+hw4AkcqekMVSpNbK62nnAgxzq3VkSlMeupQCQcFu4ZPh1bjSji1 SBI8nPGueDaeiThFx3z5OWYJmKd5y6A8/6PeOmWwuckypi5DvNg9pL/+hMtcqUYBFN+Q 4a1QDnqc9NTutYJ65ywJjmfF54bBvgeqjeyOhDHujIEM9yll7OUuhmuA5Tja1pO6NIDE wqYA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=k0YLaj4DfBEA7B2Kj4fr8p7mNowrC37gzYyOiHLLgr0=; b=BsMza8Ft3ROkETVNdIEj1x0A9tkp5Ly/qBBv17ve3JFwlunLkzXTu4xGnzKfqXtUAT K5bgOQBWRcSdTg2JLvrJQNrqMFSOu5637JDdcxYvSBzxB9yELgsneNSZzf7Aty3apPQh UJS6ApAW1dYxfBMMyy8UhaIMez/uon6s2JFS/TmK9aBqofXMKPiySWdWwkYbfxn8DXB9 Hil27Gqe0qlzbVOM8tLYtrb+hQwzTso6eNkjd3UvCUPPi0h8syEOBDdG208UENdRSeCQ d5Y/5Eax3jwG+J8amIgxAjWBme+o0/MQZeArBaOWXLm7+qGFlkIhH1Yd/SrodlX5oCXa lPmw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=RtcKXrui; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t13-20020a170902b20d00b00189d297243fsi28419657plr.254.2023.01.16.06.20.16; Mon, 16 Jan 2023 06:20:32 -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=@vivo.com header.s=selector2 header.b=RtcKXrui; arc=pass (i=1 spf=pass spfdomain=vivo.com dkim=pass dkdomain=vivo.com dmarc=pass fromdomain=vivo.com); 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=vivo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231455AbjAPNsT (ORCPT + 52 others); Mon, 16 Jan 2023 08:48:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229863AbjAPNsL (ORCPT ); Mon, 16 Jan 2023 08:48:11 -0500 Received: from APC01-TYZ-obe.outbound.protection.outlook.com (mail-tyzapc01on2109.outbound.protection.outlook.com [40.107.117.109]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DD1C2196E for ; Mon, 16 Jan 2023 05:48:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bDeRtKOIn53uLkDI9krLPKImPYXZ7BawEY32SsChLgKY4USbMgOLwEILAkD6/0bliaAkCmspWO1ulkxAf3Ol9NIkL/TcdQbU6uf+ORUyB57mQbl86kGSokKErxyLwXfa21eaEdgFQTiMZl/GL0QUKwkk+uX3OMko8kr8ac8ek4WUGb2bi73cxEBSekjTwuJfVoYEGjH5Hw3/34dkJ/KAz0M8236ANWe7M/zJAj3CwZNJWjlsfJAj4EVsBlveOFXPiVJDYgkl8Sjk5GCk8u9y/4ODLr78NAVhjwvu28ztyHjylw9iVvVuEfGO9wzASiKcZhFEKjg+Zsy5ABqCf+EYYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=k0YLaj4DfBEA7B2Kj4fr8p7mNowrC37gzYyOiHLLgr0=; b=gYGndhk++Qr+Blku/MmqOphZlWzZPRDRfsbwP+nEVIudmPx1UDbG5K4XPwaVWpd5B4G8Ie1g5FY2JE08VVizkqxa0hfp+Ui1HKiXijOlQI0Lpdi5J5Rn7TBVgX4hmC0H4bD0YAPdJ9hZTaE8XbqX5kK/2pbY7dVF9GE5vthDtNTKvzp0skGWArKsC5bdhr+xCtguE7QOSmmqAjdGkqWEL6zPjpaD9vftLUkrZOKkgTzSIAjvS1AHZfyumKtlXULlg9RoEL0PD/ox3DbCDopXcXOPJ6AnVSX4t5nPMiUOn7FGtqL9HTourFthwgnVPB91zya2owO7G3cViGYIHSLgDw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=vivo.com; dmarc=pass action=none header.from=vivo.com; dkim=pass header.d=vivo.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vivo.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k0YLaj4DfBEA7B2Kj4fr8p7mNowrC37gzYyOiHLLgr0=; b=RtcKXruituuJXBl0IW+IGijRA0vsnQR4++NyGpV3uIHU6+7xrTazCGDZSL6iUQO6ehpyhQEw4tm5mmhVFYQY7wo2IytbuZw+QtNLu0tUmO2UbzkU3/nfGsT92mzjIqEdrecMOsJ1vxghSIfW8Kqi0xRmXTG2eE6f2vMExewFeBQEAr4guMSCkObGKk80gKlBktjYnbuwe1OY7CtRGvZMduW8ZO24m5Vt9ZzyXGbJQJOUmvlPdUTmmddsWZ8qrYx+oI4PX2wQrydZn/74fq8mGxuYgf1I0pwRySG/zMyCqysrf3Uymo9pQrjyXtQ9NlFEzalVztCtGQyug62ZfFP8Hw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) by TY0PR06MB5008.apcprd06.prod.outlook.com (2603:1096:400:1bf::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.11; Mon, 16 Jan 2023 13:48:04 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::3e52:d08c:ecf4:d572]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::3e52:d08c:ecf4:d572%5]) with mapi id 15.20.6002.012; Mon, 16 Jan 2023 13:48:03 +0000 From: Yangtao Li To: jaegeuk@kernel.org, chao@kernel.org Cc: 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() Date: Mon, 16 Jan 2023 21:47:55 +0800 Message-Id: <20230116134755.40119-1-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: References: Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: SGXP274CA0009.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::21) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|TY0PR06MB5008:EE_ X-MS-Office365-Filtering-Correlation-Id: 6543c8c5-af51-4248-d138-08daf7c84a27 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5cyo31qnmFJDqGm7PSnPQqprz5bcLuzYq5BC81ZaFWCoO0XQXB7Gulta2BUygyTvTR4AM62Tu/8Lm8reMMJnoPBcnAwF6MPMW5KNdGbaN4KWXWBLYDXvyefRpmQZqEtIND9YvMU4mpnKH+lrH7UzqvOp1XAFDBiwjk87tPzuoGFJ61I1oJbBdArCp1MkK7s5PSbGmwD/GT9bFlIDVgJSRB29TUAaRQFERLfrv+YzfxT+G34eB3v5N4NshMLmpVO5QpMM3qxD9Lne59WMctVqIBugflhjQt0W08kgrU0QYRuWXgIut0i2Zj8iCF2Mi7pU9VDB8LRfbj5ioLkipR8uFXaKL2Drjvb/408YViSWQKcrQChBv8tV4iqfjk9p9XNP3LfkVUoeyOe6+5WdfPf/NRa8AE3jMXYGHHyXETrHdYV8ms17yuc3NPxljjRDwyinRy4Ui68FT6b29uAb3asROQQSSOtQwYy97KYHM4spka9BaaTJP704mMF5xzhCmUQPQckLxbcirs0NhKSga4iiWBB9ICaGqlPdzhiw5DRzjX4KSp2pmFLlvzFKPBjz9GqAZ/e2iYe3jnHsG4PIrw5/44958b7H/sVibGSdEa0G8eSc83/dKbWLnw83FsByj9cobFADcXM9TxwBAzoErxllGYTw2wGT8j2Ik2b28wgudNkL9enK5PM72IzdSCQIKzHn X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SEZPR06MB5269.apcprd06.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(396003)(39860400002)(376002)(136003)(366004)(451199015)(41300700001)(8676002)(4326008)(8936002)(4744005)(5660300002)(2906002)(66556008)(66946007)(66476007)(6486002)(478600001)(52116002)(26005)(6666004)(186003)(6506007)(6512007)(2616005)(1076003)(83380400001)(38350700002)(86362001)(36756003)(316002)(38100700002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?cWIE38d7HBoVlwH2/DLGyZ/yslSHWZwhcW1ozANoZpOCJL+5gMqXrK3Pbd/e?= =?us-ascii?Q?tP0ubr2IwKANr2hNz9PS0dKtSkBJv90BAgsIi2d6sE6au6oWXHCcDoPSzZPB?= =?us-ascii?Q?s73RbJnFCJuIgeBHNRFsUTurxb1nX+BADlmXqMKillZKon6fvk1RRBh9V9sq?= =?us-ascii?Q?dzof6ZtiCvaBQc03JfhNRHvlN6BZNovJ6F4PLMPQ6Kgzi290hjkgBmlQmjKB?= =?us-ascii?Q?SUTXxB6iAA7QB39I89E7NTGXrArCf7+cgTNivh/ifYzlCSU1cGoMrJQjOZFI?= =?us-ascii?Q?YCoMZCIZ0cqFDEudc4+G/QmI/qY65G/P1aftmCFGTkvQSx7mS2zFmIhIUwKc?= =?us-ascii?Q?0ZAHSST9C3Y+PU3otGyCwcbzN7BLZXZ8P4VHU2Hm0JCzKouAXJA1y7S7EovG?= =?us-ascii?Q?8gb7BFLxuipnJlDqdzWCa/NMxaYTHgGRTVu7t2VQIMShgaIyGM+VkBvLIY/i?= =?us-ascii?Q?KszIJnhaCX2PnXh3p2jw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?us-ascii?Q?MGKfqXI8wmHk8NyXeWhwXPe1aFdiboYeXZoBxFKUyT9K8Ywc2/Xu/lSkrHMI?= =?us-ascii?Q?Ad1QRZ0vhNEdMfM/ZstsZlLMMN+sVRYeLwan+quODE1MTDfcz4bkfTLabe5D?= =?us-ascii?Q?xnQXgDTpp5xzr+194rmiMc3mNtvPPR2aeRtjWNBDUh1HfOvFHMPcOdrVXnsv?= =?us-ascii?Q?I+d6VxsMMdXfQO/piCq1v8eGEs6LvHsxCRr69zrA?= X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6543c8c5-af51-4248-d138-08daf7c84a27 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Jan 2023 13:48:03.8645 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 923e42dc-48d5-4cbe-b582-1a797a6412ed X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: y2Wa+oBeuJPvy4G1H4eZ5QFME3HnBSsPElZR6uudK+rB4P3l+CD0AMMS8cnNIe0lNL8wBBU/Zes0ACWtVSS2YA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TY0PR06MB5008 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,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 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? Thx, Yangtao