From patchwork Wed Nov 23 16:44:01 2022 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: 25081 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2898784wrr; Wed, 23 Nov 2022 08:45:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf6eVfpgO7pS51hzg2bO1jkIFx2YR5Y25NZdvgLctoR+5pT/r4Db/M+ipBRFJjlz+CFRD+Qc X-Received: by 2002:a05:6402:528d:b0:468:dc9:ec08 with SMTP id en13-20020a056402528d00b004680dc9ec08mr11038490edb.17.1669221926492; Wed, 23 Nov 2022 08:45:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1669221926; cv=pass; d=google.com; s=arc-20160816; b=scXEMfe0zzco89WY9JoN5wAQLIKZroqxt5qD/VIrzyUavz/Lz+/sFFi4aYA3fP5MT4 6Er7uI+kSWF+KYII75UNJGFiJSdHyfCjBsPoTU0Gy5nAvPcGzHvJZKkk/s0SejaVRJoG /VLpMiZhC0ngkBXJwK9R5G193LOHjrPKLwujfFVRXbD8lirTMc+scvIz25ORwJIfm7kd kmZWrO8lZIH8To08DKOvFgUfuYSyeKioMf13ggzYGvoXMLn2s19REdv2s9sxRyRNwt+G e3JXTob2U9d0wO2zRDRl/FDWxdxEjjnEJM0xqtFzrywvkHlQ83DOhm+9UTmdQnBJSg01 vcOg== 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=hdD87Cty8XzbQIbcEYc4ded00oVaIUFtan27Ztul8r0=; b=frKc6S1at3BPyL+geeOpvIhqFP2Y79IaBgn7eYy+3pVEL0plnzRGUgHbM+ggKT0n5B NoNaSeKbOVWAicph5KMtH0NzC0KB2d20wYo9J9C3wp/r9CLjFol7H/v09s/vtvewTrry RMGYaOANKyu44p64ztJIt+wh0zN7bE+KjoGi81muzq4RUXaND5Nl26GzQpj7L/rgf9oA o7Gd6UZMEvRuHZCtM/UuTT/t3oXOSYjiOvF3r3Eoo/cA2pZVCupU7bTUofjWYugi5Vhf iTNuKWrTCsLgHuRmm1mq8p6yMWKwFQgpz0y+9oFNda2uC6aju/FfX5P/IhW21YJHa7PJ YM2Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=lKCuJNnr; 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 t13-20020a170906178d00b007a71a3cb3afsi12187580eje.294.2022.11.23.08.44.59; Wed, 23 Nov 2022 08:45:26 -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=lKCuJNnr; 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 S239154AbiKWQoT (ORCPT + 99 others); Wed, 23 Nov 2022 11:44:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239138AbiKWQoR (ORCPT ); Wed, 23 Nov 2022 11:44:17 -0500 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2130.outbound.protection.outlook.com [40.107.255.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EB1965E57 for ; Wed, 23 Nov 2022 08:44:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jz0+Z50VsZX5/enrJ6MPrt16FV5htdf6vlOoq6VHdzyiqo6/VOGOnX1Hl9Jc67UtLfSpx/3hyNpfyWCnWthJxp9dgjXQpXCD75TvfFutQcujui6n+cg7xrSqMKJE5xtKu5qcDlLRuSOxtYx5n8NERgvYsIPjLkISe69I0cBgjXj6TjwjjHKfU4SHXsNvha9l8Xl7KZVTudvBFfJ759/xaO0SIn8jhe3PQbEswBb3NXTlHydyijv4t9NEwlKUIw4pdgFtMewsAq+zHQa4FXQjoWVhIhFREJeEoeCK3BCfeUT1O67DQ7CtKIJ6tV7uJ6A+I9A+w+6c6mojXuCtyQtIPw== 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=hdD87Cty8XzbQIbcEYc4ded00oVaIUFtan27Ztul8r0=; b=fbQaGGWQhSDVVLz7WsLbQmhwtyRs2iwc9BX0Iv4lHgLF/V1E07pKF/p5r7+f7MBlGqArDy+o1PNhqDRaH8Bip6VZD7cX5A8HqSvu1Pr7VaB61Z4IMX5bFvWmQfoYrw62WbAK9aa8LaN1xLq0P10NYt7opbWoE/GmY7LxxwCfllh95ILTLetL1VVoSi5Z6A9UXuwiGYeJpgzrilrj03DRiTTLcmZwKRU2VaFS/Ij5kX5+QSH5G9r+Dv8r9s/BjRqCRO/ckIkd2jdeJnUvv0NYs+XjnqomDZQjfJXf7GksTC4Ag+u/zDRJ8wnN83riRRMuUvpNM7tLj9x0T1hIG5x0sg== 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=hdD87Cty8XzbQIbcEYc4ded00oVaIUFtan27Ztul8r0=; b=lKCuJNnrFFngBxfjoSlm42aCGTiuAfUxvfa7DRjihaXuAUDFB6ZWUpv6zj/nCACbIhB9qrzUjeP8OE4KNS3vhRLE2H1/d80u2otX3Q+iSTJr044xnnr5QmhcTsYxgyxz7tWYTZJnFd4u5mLQu2Ruqd24esw6Mwlye1hnzHryn59kXxXRnJfppqN4wfRYO6lIOGGSppxv76psFhSpuLQ2m7qrhUDXo7Qb1a0VHcGMck4zDqNgHC81MQDu9fwxe4K1zTgB3U1/YmaWE+apBe78vdKyHuOrGO8+77sQU/3ml/4hu//7iUBzYWtFFbqka7OAG3AjmT0NxDtkRaQ3XJzQlw== 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 TYZPR06MB5950.apcprd06.prod.outlook.com (2603:1096:400:333::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.8; Wed, 23 Nov 2022 16:44:13 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::1230:5f04:fe98:d139]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::1230:5f04:fe98:d139%7]) with mapi id 15.20.5834.015; Wed, 23 Nov 2022 16:44:13 +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 v2 1/2] f2fs: define MIN_DISCARD_GRANULARITY macro Date: Thu, 24 Nov 2022 00:44:01 +0800 Message-Id: <20221123164402.13849-1-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 X-ClientProxiedBy: SGXP274CA0011.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::23) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|TYZPR06MB5950:EE_ X-MS-Office365-Filtering-Correlation-Id: f74fda78-ac00-4638-16c5-08dacd71f3b3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QjF4iwYER3Y55w4kHZn41d9H3s3opZy+o3H3pNQrZrxRUop+gXCgWXhHhAzFJmJoKQ5eakp/kB+RxElZosRVX3k5+gKlMR22Wzy9+Fk4wHYkq6IexuJuB2NzLpPqto8D5858QfnKlrhGt9DVIs9OupnFniUA3tj0VhAApqTDJn1ATcZhY+xLWhUCEaRYvZL9rHvWLwV88BW0+haKWQyyo2TDwK5a01SrhtSCHge3SJunsxbhkv5fo2byH+Fe9PbiOHMivKLewpERqZ6RaTcgINdnc1oP2TesQTgHJiXp2jN5WpcUrqIqogulHigffijGrHzo4JaEyWoXjWhwBOPVQPjmPaXrjyhGKeeQf/uBW3haMbqHbSsJq3yMCI/43bVMtmlw8AFiPZLQ2M2L9LBIgP/gajVd+pdQBSoPLDnTBsuwfggf1IISQXM/qyMg5QDA5Q2/ljmXza/J8A8WFkFoBBGFWrWfVqXWoFWIjMyIxvCxcCKiQAvDv8IdwGH2+5/e0KliLHyK1c6cev7P9Vv3ry466Gxtjm3jXH0mIaD8Rf7Z7hs1IsWCWzMwQMIkFwHFFVnNXDJAJWnt2uVL1gW9DlfhtAu5DuWyXL0sxQkUNBFjg8yBHsHBgkxvWhjdsYGwXbZqUgZsT9fjRFJNl5SklWZjEDTUB5XnDgeqJ3yx2PjLIAApEPSG3i58sqZDl1NN 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)(136003)(396003)(376002)(366004)(346002)(39860400002)(451199015)(2906002)(83380400001)(6506007)(66476007)(36756003)(66946007)(41300700001)(66556008)(2616005)(1076003)(86362001)(38100700002)(6512007)(52116002)(38350700002)(5660300002)(4326008)(8676002)(186003)(316002)(8936002)(26005)(478600001)(6486002)(6666004)(107886003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: IrP5FuOsg4qclIGdnEP+zu7aYuac4XMxOI5hGDMYbQiD4p0goqp4oyJ56p3LBAFrvxPCg5PeGwfAmMAStp9tCW9mOBXMSnFNyD5XPQTvXB7JpOYkE/jhXtfXYvap691MKrEoIDtYfZPr/I56ZRNupHrEQUSAyk+82d7C9L/FdAnOOXcz5oRoRYZzD4xjikuIm/rx6r/ARF8b7BQrmVtiAKgmWauFi5ZBPUmCcVaSzg2/uY4oM4XTUEo4BO8b50lcSB4efKWjRDdroBVHiG7zqqAwrvT3qYqI6HJHcvmLzGqVbO4W83Cze9J52TSb3hduWWsYjBb6FOfazS4ScN7R3CYKMaD0JV7NCJgY+h8b6T53yL0xeaFXs157Xm2oRogzyyHF3j/2QHZHMAX9tqKAXW4KVYedGJP0uRr9LQePCOoVb3ZnHIOXfAeo+UUxPkZOrpWjL33LVihROeFjxM/Q6ERVBj8uEAiOlhtrtzDT7hv4TTkw4YlRu7Vp+4iFOv+mEuTRVxwev1BmDAeIDSIh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orOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: f74fda78-ac00-4638-16c5-08dacd71f3b3 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2022 16:44:13.1351 (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: 3rB0gtQAJ3rMX4+D8vZl9xvpIWmtIajOV4M6TgOto0JhaNhM9oHXWuvho0OiEwLC43NrPaLS8ZGipX35eVKrkQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB5950 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?1750306050957266794?= X-GMAIL-MSGID: =?utf-8?q?1750306050957266794?= Do cleanup in f2fs_tuning_parameters() and __init_discard_policy(), let's use macro instead of number. Suggested-by: Chao Yu Signed-off-by: Yangtao Li Reviewed-by: Chao Yu --- fs/f2fs/f2fs.h | 2 ++ fs/f2fs/segment.c | 4 ++-- fs/f2fs/super.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index f0833638f59e..4694b55b6df4 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -329,6 +329,8 @@ struct discard_entry { unsigned char discard_map[SIT_VBLOCK_MAP_SIZE]; /* segment discard bitmap */ }; +/* minimum discard granularity, unit: block count */ +#define MIN_DISCARD_GRANULARITY 1 /* default discard granularity of inner discard thread, unit: block count */ #define DEFAULT_DISCARD_GRANULARITY 16 /* default maximum discard granularity of ordered discard, unit: block count */ diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 8b0b76550578..a993211ded1d 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -1070,7 +1070,7 @@ static void __init_discard_policy(struct f2fs_sb_info *sbi, dpolicy->sync = false; dpolicy->ordered = true; if (utilization(sbi) > DEF_DISCARD_URGENT_UTIL) { - dpolicy->granularity = 1; + dpolicy->granularity = MIN_DISCARD_GRANULARITY; if (atomic_read(&dcc->discard_cmd_cnt)) dpolicy->max_interval = dcc->min_discard_issue_time; @@ -1085,7 +1085,7 @@ static void __init_discard_policy(struct f2fs_sb_info *sbi, } else if (discard_type == DPOLICY_UMOUNT) { dpolicy->io_aware = false; /* we need to issue all to keep CP_TRIMMED_FLAG */ - dpolicy->granularity = 1; + dpolicy->granularity = MIN_DISCARD_GRANULARITY; dpolicy->timeout = true; } } diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 31435c8645c8..daf14b55a972 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -4080,7 +4080,8 @@ static void f2fs_tuning_parameters(struct f2fs_sb_info *sbi) /* adjust parameters according to the volume size */ if (MAIN_SEGS(sbi) <= SMALL_VOLUME_SEGMENTS) { if (f2fs_block_unit_discard(sbi)) - SM_I(sbi)->dcc_info->discard_granularity = 1; + SM_I(sbi)->dcc_info->discard_granularity = + MIN_DISCARD_GRANULARITY; SM_I(sbi)->ipu_policy = 1 << F2FS_IPU_FORCE | 1 << F2FS_IPU_HONOR_OPU_WRITE; } From patchwork Wed Nov 23 16:44:02 2022 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: 25082 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2898866wrr; Wed, 23 Nov 2022 08:45:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf5LWC92mfxh+LomjlmEq47QVGfatQ1ONx1APYkuJBzw+VmI8ofWcAqCXEnljudeKd4lMe0v X-Received: by 2002:a05:6402:3ce:b0:469:40c:ecfb with SMTP id t14-20020a05640203ce00b00469040cecfbmr23485729edw.164.1669221937008; Wed, 23 Nov 2022 08:45:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1669221937; cv=pass; d=google.com; s=arc-20160816; b=hbKF2galhXrD5IPV2f3q9jyMGPxDVv/rPYx62up5Iw5O93B4vpwGnLdEP4WcbZrtW+ /7mr5uLEQaaglzHvWh3T2ZLyKNWG3ecuwYrXGOypBXAn/qbpQGG8Rkn9KoWHv8izKTQg x8K++Ac5BN3kJyvAFyMHlR22IzVaqPbLwf3qc6O0bmnHciSJbnYBtMCC7o4IyY2Y+3Zt r7uy8uIN2glfD2gV1HBCdemv7Wx1mC0n/WTTaiEQXckMLPgQqN7DTTvCK/04obW20sCQ WRaUo+Ynmyedlsk2y81csaHbhOalBNid4vTe2k7S1cu3y2HxcqMWx/TI3h1cYQ7AVcNb f2QQ== 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=5BuKWrKR5jYRhSucLIT5VYO4TKn8i0Ezryo9kyMfzno=; b=wpbi4U64Jfglrt0UkBS89Qx9el9OnvJ/xqZGhHaC5fep/csq7zQocjucU8RVMTSzL4 Srg/5KLoHu8q0xTvAkQcHXKvEcg7qSHkHEtIdvpk+DT9mEWAN2Q221WuZYSi2rC75hVB W+Rocp/prOzC0yu48UME6ggt7cdaNOmwPYW6FNS6QJFGsgaTG4Fi+lYCw8ql86b9NQGe xno6Lnnhbqo3DN8cX058EYlRMVaVaabiOOU+j7s09DOvCMviqTonMRy5LDEvQogvtvCo FwctPjExeOTXHR84UaRppvNmyjSXoXo38rx22HbqOzwIYvmDFnzdCSiIItSsU01WUzPO nW8A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=IwCs67mh; 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 dd9-20020a1709069b8900b0078c4a772ea7si16517156ejc.11.2022.11.23.08.45.10; Wed, 23 Nov 2022 08:45:36 -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=IwCs67mh; 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 S239160AbiKWQoV (ORCPT + 99 others); Wed, 23 Nov 2022 11:44:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39564 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239140AbiKWQoS (ORCPT ); Wed, 23 Nov 2022 11:44:18 -0500 Received: from APC01-PSA-obe.outbound.protection.outlook.com (mail-psaapc01on2130.outbound.protection.outlook.com [40.107.255.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B7A36DFC7 for ; Wed, 23 Nov 2022 08:44:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PyuXd/UGZCoPmLJK6f9mii2nNGoMipGuMBNz8hXN9841nDZYgwXNmRw27KqiDFzyedNoEzgTF4SDDzZOYpQ/DA/s7TRrLSg7g+nuXwo/B7V5VabVfLL4SGqN9Kd/VZp3i+MQNhgcoAxI+Dnhbbd0YTuHtBzhyllDhDO1Ur/YqvP2LrXmupZW9tKb9jZBXXPYRAW2wG4M5C6QbjtxUAkbpRvxTIi571yLOfpmNX64lab0Edvc/GvmoBrJCBDnCfpuZzJyeuOzTiW7w6Lq9m09dVKzxXQbI8TLJHWfWILHTBchjjelkqcN8k4z5rcWxHllxUCW22YL0xgq9ezqSyl4MQ== 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=5BuKWrKR5jYRhSucLIT5VYO4TKn8i0Ezryo9kyMfzno=; b=anSh9Dtaui0pTtIkrnhiY+3M8MYFM3Nx1KCYmvziqXz++3papB1JdGJxjUL8Eulk/gVWSQGeIiOZM3HlEsooY+G9GhSKIM1Lv0EWsfaV1Qvsle6DlWUuoEe3x6MaHa6PnUCDNy8GGETw60r7q7rq/5SIjCjuKFGPmq8Y+1A+tuXEGliZnVazPJNwtTTctnx7Zncc1RO/1+GkKRt10W/4mDalFaJ4/RAfhcvr/AC6YYUN2LBosRwr46XeSvFNFsmky2nsfaVTJMjmZvbXUcoq+cLSfe+boXCQxrY7YorSQj9xRnHs79+2eNmebjI+yj6UlvndtLHkqMEebtyK4cESvw== 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=5BuKWrKR5jYRhSucLIT5VYO4TKn8i0Ezryo9kyMfzno=; b=IwCs67mhZ8pfI003N3JY9/WRLShfG8rYVsMI8YE6AXQgX0dqYkE2LMgUFQrOh1b7wMkvL1dx+Hmc7PkmVgqnMrLoTMhPmm97NORANuyjh23BCmIGltODvre/wbvXqaJiyifA28/4ZklameZ75vp2dVIdNqTlDdfRYf2udCKTDAF56UG8NvakdBOF5hKH+QBftO9rHduG3udW2A+BSJ70RW05taSJVRkPoRv/sZ+AhF3Vj0ZFG86yflRMil10f4MbMiOdRdE0dmk/tWFlsVAgXC9+WZa0kst8HAc/dEEYyUkQem1EcFLuqcCrOB5oAxzGqNF81NUIYv6dTtbbwCTC3A== 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 TYZPR06MB5950.apcprd06.prod.outlook.com (2603:1096:400:333::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5857.8; Wed, 23 Nov 2022 16:44:14 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::1230:5f04:fe98:d139]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::1230:5f04:fe98:d139%7]) with mapi id 15.20.5834.015; Wed, 23 Nov 2022 16:44:14 +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 v2 2/2] f2fs: introduce discard_urgent_util sysfs node Date: Thu, 24 Nov 2022 00:44:02 +0800 Message-Id: <20221123164402.13849-2-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20221123164402.13849-1-frank.li@vivo.com> References: <20221123164402.13849-1-frank.li@vivo.com> X-ClientProxiedBy: SGXP274CA0011.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::23) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|TYZPR06MB5950:EE_ X-MS-Office365-Filtering-Correlation-Id: eb6e2629-dcc9-406d-d275-08dacd71f46a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AgazdcgZ7b5yaMhRPULo3JhmIsni17STqZjOHkEVCJ4hgiGPSkERjycAKsLOr7tZUzsuR/XudzRi0Xcmi7z71QlzzQK89wpFMp5JmVtpgM25V94GxKoc1aLwlA9PP4BvCGp/eDPVbJ8IUTLZCmj7LLgWcc1mIcNwOHL4FcC9fBryql6ObcWC2PTvfB/5+7024h+1QQVp16xPNQi0m5scaCUVlkYOvPPfuiJTHG7rCV1OqrvGu8ylZNu7F+7ltJyXE3o1pkhIDctAqW/Qis92bio5XFtourLLQpV4AEPCFDspiuUVQStEAyGR1melTdrQWfCDVx/hAlUZ83lOCLO+QrSnYY4k4OSKccQao8qiQ3knpZb1lghkQM4o/GQ4kUQvZu7UR8Z2Y8PeVT5tg37gC3AQrL/QGRAxjpqax3IvkgFbKkU95g7TbLwAiOI5KIYUPQPyCT+ehV+mo1pOq/u8Uj9icY2F8OidUAPWo7oX+97em4dBo3OvUHrD/YCFvFhGblodePkTzJQ/xkya09UsMutUcr58pJkKBR0JDVion1DBlMPw24aiL+DWSg9V5W/mXqRUcwje4Jga22OLAUsC1ZVL/c4K3nv0VkCSD/PnLBDsoKQ5MweWqVhR8bVzaJC3zZZU0J24L5CQL1aGUk7uBhAOKAZO+5i+F7x/zSgTDE5zI7Uw6My6fOOk3vn/cYLa 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)(136003)(396003)(376002)(366004)(346002)(39860400002)(451199015)(2906002)(83380400001)(6506007)(66476007)(36756003)(66946007)(41300700001)(66556008)(2616005)(1076003)(86362001)(38100700002)(6512007)(52116002)(38350700002)(5660300002)(4326008)(8676002)(186003)(316002)(8936002)(26005)(19627235002)(478600001)(6486002)(6666004)(107886003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: RozpiDco9OGMnuz655u9toPxfYVtOKW6L/2IeW0e21dZZ7KPpnDMnWb3GaFyGQJSh0InhApz2PGfdhB1VL0OP8jszaGMSHcHsdB+Omy8RQuoWeP4cqUb3Ny7aoMz+Bdvdk0HvDTZ6JGeRgdQNX4tjWJK9hIE/TZ2H5pqynmj6X8tyB+HjSSDy6OcK2yR4u/O0amWdgABabwayh32twWsSkCdmW5vq2EsnwJvk/j5oL7ICIJoXhfvBZwIg0/zKaCAGXNzykt+ZjL5tMXj2TsOAFpxBDHMEMZ5UXTCGONjkrhn1KfWQKkKlD/5lt+niVOiKaHdlZ2+mT7bh1BYq5MhizliQUX8ks0NYS31A55YK+y66MfOVIjKc3Pbx9RjtiEuPwOJW0YghNPd/Gg4Sgy9K5uam2nF55nvLWffrYCYXuzO0IWk9kuTIgexM3/J54PNqgPoF3hPzwB4hMglFuJLBDJ6p1V2oBHnKVL8ggT9JEFdmip5Ai12PKsIuyVxCGsvZO5IdA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ic2mSHPOQVl0Kzahoa3tvs X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: eb6e2629-dcc9-406d-d275-08dacd71f46a X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Nov 2022 16:44:14.3548 (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: 9nN3xly6AkNwxfH8FD/BimiCbsN56mrmKwzHrmQZXzFABH8iHfQfTibyOh5J9LFrljsAxj1er7OzOdWl1tNpNg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB5950 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?1750306061473720493?= X-GMAIL-MSGID: =?utf-8?q?1750306061473720493?= Through this node, you can control the background discard to run more aggressively or not aggressively when reach the utilization rate of the space. Signed-off-by: Yangtao Li Reviewed-by: Chao Yu --- Documentation/ABI/testing/sysfs-fs-f2fs | 8 ++++++++ fs/f2fs/f2fs.h | 1 + fs/f2fs/segment.c | 3 ++- fs/f2fs/sysfs.c | 9 +++++++++ 4 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs index 24e7cb77f265..c9cd9dbafdb1 100644 --- a/Documentation/ABI/testing/sysfs-fs-f2fs +++ b/Documentation/ABI/testing/sysfs-fs-f2fs @@ -646,3 +646,11 @@ Date: October 2022 Contact: "Yangtao Li" Description: Show the current gc_mode as a string. This is a read-only entry. + +What: /sys/fs/f2fs//discard_urgent_util +Date: November 2022 +Contact: "Yangtao Li" +Description: When space utilization exceeds this, do background DISCARD aggressively. + Does DISCARD forcibly in a period of given min_discard_issue_time when the number + of discards is not 0 and set discard granularity to 1. + Default: 80 diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 4694b55b6df4..296683648d4f 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -413,6 +413,7 @@ struct discard_cmd_control { unsigned int min_discard_issue_time; /* min. interval between discard issue */ unsigned int mid_discard_issue_time; /* mid. interval between discard issue */ unsigned int max_discard_issue_time; /* max. interval between discard issue */ + unsigned int discard_urgent_util; /* utilization which issue discard proactively */ unsigned int discard_granularity; /* discard granularity */ unsigned int max_ordered_discard; /* maximum discard granularity issued by lba order */ unsigned int undiscard_blks; /* # of undiscard blocks */ diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index a993211ded1d..3029b6b08d02 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -1069,7 +1069,7 @@ static void __init_discard_policy(struct f2fs_sb_info *sbi, dpolicy->io_aware = true; dpolicy->sync = false; dpolicy->ordered = true; - if (utilization(sbi) > DEF_DISCARD_URGENT_UTIL) { + if (utilization(sbi) > dcc->discard_urgent_util) { dpolicy->granularity = MIN_DISCARD_GRANULARITY; if (atomic_read(&dcc->discard_cmd_cnt)) dpolicy->max_interval = @@ -2085,6 +2085,7 @@ static int create_discard_cmd_control(struct f2fs_sb_info *sbi) dcc->min_discard_issue_time = DEF_MIN_DISCARD_ISSUE_TIME; dcc->mid_discard_issue_time = DEF_MID_DISCARD_ISSUE_TIME; dcc->max_discard_issue_time = DEF_MAX_DISCARD_ISSUE_TIME; + dcc->discard_urgent_util = DEF_DISCARD_URGENT_UTIL; dcc->undiscard_blks = 0; dcc->next_pos = 0; dcc->root = RB_ROOT_CACHED; diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index 33ec467b3772..a4745d596310 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -493,6 +493,13 @@ static ssize_t __sbi_store(struct f2fs_attr *a, return count; } + if (!strcmp(a->attr.name, "discard_urgent_util")) { + if (t > 100) + return -EINVAL; + *ui = t; + return count; + } + if (!strcmp(a->attr.name, "migration_granularity")) { if (t == 0 || t > sbi->segs_per_sec) return -EINVAL; @@ -800,6 +807,7 @@ F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, max_discard_request, max_discard_req F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, min_discard_issue_time, min_discard_issue_time); F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, mid_discard_issue_time, mid_discard_issue_time); F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, max_discard_issue_time, max_discard_issue_time); +F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, discard_urgent_util, discard_urgent_util); F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, discard_granularity, discard_granularity); F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, max_ordered_discard, max_ordered_discard); F2FS_RW_ATTR(RESERVED_BLOCKS, f2fs_sb_info, reserved_blocks, reserved_blocks); @@ -930,6 +938,7 @@ static struct attribute *f2fs_attrs[] = { ATTR_LIST(min_discard_issue_time), ATTR_LIST(mid_discard_issue_time), ATTR_LIST(max_discard_issue_time), + ATTR_LIST(discard_urgent_util), ATTR_LIST(discard_granularity), ATTR_LIST(max_ordered_discard), ATTR_LIST(pending_discard),