From patchwork Tue Jan 17 09:54:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?5p2O5oms6Z+s?= X-Patchwork-Id: 44618 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp1670056wrn; Tue, 17 Jan 2023 02:09:57 -0800 (PST) X-Google-Smtp-Source: AMrXdXtg0dfXDF3cs4K2dCjCviQBZQSHb0RT4kH8ZgDwiuxRWynWgLQYBw4Ph4YynlEF69tCC0nJ X-Received: by 2002:a62:ea13:0:b0:58d:9ad4:adaa with SMTP id t19-20020a62ea13000000b0058d9ad4adaamr3008957pfh.17.1673950197537; Tue, 17 Jan 2023 02:09:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1673950197; cv=pass; d=google.com; s=arc-20160816; b=xICXvK2HxCnv98BmREDYAoevwkSz0Hsf3eAkDUgzhG4gx03TV9EiGGOQoJSGAoJTqH hOak9F9G0ncAPh4HPzdQuydC2x4vvPgbRtCKFRcGx8frEVFblTkpYfqhaANi7eTP2P+e 9yUQQg/oHCMlzO2dk0Zz4V1iBE7k7E43QZMqz/CJ5bazuB5ACrO0faHkxQ2Tefyrl2SK QIjJ1+KICW5+b5Z6AXqXvypWgvYBGHbd9EhuPD9vI/VLySri87onPoHc1SVyRDLh4BQA bUZYf8TCJtMn6tRj2nX/XNael5kJcbOwneDPCHdrFIf6hfIB3kBk/GKwAdCUF75iJEOX SxmQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=uTrEb2Cwr9F7vWkD0UMRfe1+egrfVdeiqDQjljagu4g=; b=OzWnoTfL97ARL8yKXQzZkJriEEozf7QDARoB9BAiJp/vTZUKCEOZe8K1zk4QmPNZUC 7qzoIkKDZf+N1VJjLcLsdLHLiu/cIpU9x0lo2knnLhUcPAUppFO66K4TAfTS/JwzFJzM BpScHAiZniw+WC0DEyQRJ1vlU5PpN6Co8SyUSYJeQvLcOpq2o++WMk9AbtQq9Gt22ODX F4EmZ/z287KMZO6Aot2kCACeJNYeQzP5bUD8fc9R0dE/LonjgJ9nHJTSm0h2SGx4m5z6 QfEQmyBjYPQs4n8yjBbYgBuY8s3T+kaZyWGg2RPzvB6jj29XARTuErzX0eMhuj+e8e3I k+zQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=m2kdxy41; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m16-20020a056a00081000b0058dd059fa20si818221pfk.265.2023.01.17.02.09.43; Tue, 17 Jan 2023 02:09:57 -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=m2kdxy41; 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 S235491AbjAQJyZ (ORCPT + 99 others); Tue, 17 Jan 2023 04:54:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47860 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236111AbjAQJyV (ORCPT ); Tue, 17 Jan 2023 04:54:21 -0500 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2114.outbound.protection.outlook.com [40.107.255.114]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 71C242A9A7 for ; Tue, 17 Jan 2023 01:54:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NSDO3woNzIc4ONXQrmHiqGB8Ll8z/Q+d7SMXmK6VCNb569Zy4qA9j2e4gih7nET3xqvOagUfPcGSzFVMFO+7vTqd0RfS3zfISKv+rEP17HORGvmsVuFOjiGBdDid41xe7waowx+lq4iC4kTqHgEA/Xg6pE4QJo1yGbuOpfLrIier7rFQeE+eqzTMluefL1Zufn0gJ25FR4lIlKP+2Ne0/yuOBgKUpdOmUZQQrMMPUAKd7oIMQOmLNheZGnlZRaqi1h0hJeJym0Gu7+C2+Q4oJ2xkDe/TcvRgOI0UFZvywCaSqt6xJr1UPVujtHip6Y4fjUvQWwgvC2uWj22ZqvsLJA== 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=uTrEb2Cwr9F7vWkD0UMRfe1+egrfVdeiqDQjljagu4g=; b=D+jt3oZjG4zBnM4pN3tVBcOePpYDjjieKCys40OWPfUO2KnYW2A1igCAlBdgsb/32eMWoSHhrW/ocqBrFFxA7LtzepoBdpSLRGSlmqBJ/zHyy5B9Xauwli1AjdpijD6M3PrIkJvyvBIV+VtUBRA7DMSwgl8kT58MEY+5ADqznv0UMkc7CCJZa0nz5V5e3+ca8ONiTX3jtedOsSJOFqJwE3drUEw3tV8ShJlu7f0WwdbglcZeJ+P5hK45jGjtp+qATS+6XHC9RS+Qsjj0UOTNHdERrQmo/XaexyYCnbhyV9bQOpoCDgtxBd/rHhKbuNWeyKBuM5NXJ9lO2zP/9jcL3Q== 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=uTrEb2Cwr9F7vWkD0UMRfe1+egrfVdeiqDQjljagu4g=; b=m2kdxy41oHRWZbJlIC+vdGKZU5Urmx2KcAqW9/tznPsZO1BWDBS9xGLtV/MSTIu9A+qwPMgu9x50wxf8SR9xWTB8sLsGIBpic/L1aW984NdropJpHmPx2pVAlCoFLiwvT47cf54aCo+LMyJS2nXaDwgZXKE8ieqKbVVeyi84faQWaGCD5vDdAVlqh5Bi7+hor6+H+ti5Jlw88NoCKta4AbM/a6hCemQCwcmavlb1lPUKXGr5UhmC6h5OpFy7GnheWHbVN/kDsE+2tnZ1tU7ruXK+2odUCSakRaBay7LK72cqseZ5lEteOl0RdQl0yvZuiKKfzDKUw8zqB4yKFTA10A== 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 SG2PR06MB5287.apcprd06.prod.outlook.com (2603:1096:4:1df::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6002.13; Tue, 17 Jan 2023 09:54:16 +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; Tue, 17 Jan 2023 09:54:16 +0000 From: Yangtao Li To: jaegeuk@kernel.org, chao@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Yangtao Li Subject: [PATCH] f2fs: fix to check warm_data_age_threshold Date: Tue, 17 Jan 2023 17:54:07 +0800 Message-Id: <20230117095407.37398-1-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 X-ClientProxiedBy: SG2P153CA0048.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c6::17) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|SG2PR06MB5287:EE_ X-MS-Office365-Filtering-Correlation-Id: 2074cf09-3ebe-4aa0-220a-08daf870cb8b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AUR77EBxYT7lAQEock5u7mXhtV5HU40MwQ4BMJtPB605A/crbLDGV990GdbFhr5eadUpCckOLbCyhzyESGBapPuwewiILOqFNSAANtguX7telX/sfSYlwV5JxlWq5q8pIwNVXiblqEA3PyGBFa4Mw/tJQttBcH2XdV3/3qREHFwgEEaiaegnJutbQRwo1j+qnKkq8/2ltD55cAelyqV3IoTE9ceWexZsPJckDSpbEUUBBX+kZJ/0fAKVjXZ4yLZZG8WhEKiZ78ZV/v+8a4KCf/WxsIh8TB4xaJeXt92/o6PSj4/J4xlNn0LJxmt82291QiBY/UkF27cclnVPB9IfFeXxlGBCDyrl0Mgjg4ll0Y96Ajg+jfr4FHt/150OoTsWxgjZTImT0Ta6gJZnGmsGhKQZ/BeMYvOqEH7ffTIO3SOefDgsKe4iYQkSR18FNYWb/AfTb6ODO8Afphx4hrLOSle9qp4ed0d/S8XEfjJGdk0pXYHtRLvEOqEyWPtSLBZILc9dMUcyjxeJQOWZu814cH+nFPkW17efUr7zeu0cWvSdSfRGLmRqO/QnPtfv+fgVNUGK1wb0AiDXzOmL+lgW/3i5YDp3ldg70+GOEbnuoCGUMMNomUlq/Ky4sBdBjyTfHlWOPUk7DuiqRAq/lCYz4GwjsVPoGsMeaXVf8wvAON4OofLQolJVrGDdEQktQhM8 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)(366004)(39860400002)(396003)(376002)(136003)(346002)(451199015)(6486002)(4744005)(8936002)(478600001)(5660300002)(4326008)(41300700001)(26005)(66476007)(66556008)(8676002)(66946007)(36756003)(2906002)(186003)(316002)(86362001)(52116002)(38100700002)(38350700002)(6506007)(6666004)(107886003)(1076003)(6512007)(2616005)(83380400001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: G9ENNNWLYhn7G4VT9/y1VAfi53ijOLblbs335QSelqPIC1o2JGR3/GO5W69CGtxMgdlsaRqpXGBtY42rK76dyqH/RsRG8868tJfbLkGzOOyIPnUl4fIT1kzklP6KGEST2Im+4pVSrFK1qoR9fFHR3aFG07GP9vrbe2Mq+07101V8NU6Xg+tRhkV6N9tCKMo8UImGyRbKEypqGcFFsTMug8clKYhFfYxAJr74eTpwbzLCWMPjUR3WFslJZv6PSS5m9YgmJRnTUoOOCsTZiNsqnbEy57Io0j+VFEs3etgJOa2ctp9fiUVKANdtO/6ZRc5VIZY++sb+YJix7by6G+tx2/qmX//kQbSeJH/34KCgBnnK/d1cfrcsCd3R7BeRggEFHSudsCXjsNbCtUBBgqDQfwVTpqFeq0612a0vMipl95Hlf6mWOTw877SNESMAdmbbUDiIpU2n1Ycp5d/7TjB91Q+v9y98IDxReHUNBQxqvDjJ4n4nNcBrv0IsfFpXVLePh98whhNRVrROc2QR6TDOLZEOi16dFuOmgiw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 2074cf09-3ebe-4aa0-220a-08daf870cb8b X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Jan 2023 09:54:16.3921 (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: u0CH34Tp0rqvv8FSkTz5OIO6fC1nBTO0SvZAvUsAvuhgL7xdhP4j75IIFk6N+wbpqOnXAXRFgzJ6G+5R+5pgCA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR06MB5287 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1755264002092444767?= X-GMAIL-MSGID: =?utf-8?q?1755264002092444767?= hot_data_age_threshold is a non-zero positive number, and condition 2 includes condition 1, so there is no need to additionally judge whether t is 0. And we need to judge whether hot_data_age_threshold exceeds the number of available blocks. Fixes: 71644dff4811 ("f2fs: add block_age-based extent cache") Signed-off-by: Yangtao Li --- fs/f2fs/sysfs.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index e396851a6dd1..b59595daf3ef 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -689,7 +689,10 @@ static ssize_t __sbi_store(struct f2fs_attr *a, } if (!strcmp(a->attr.name, "warm_data_age_threshold")) { - if (t == 0 || t <= sbi->hot_data_age_threshold) + block_t avail_user_block_count; + + avail_user_block_count = sbi->user_block_count - sbi->current_reserved_blocks; + if (t <= sbi->hot_data_age_threshold || t >= avail_user_block_count) return -EINVAL; if (t == *ui) return count;