From patchwork Thu Nov 17 14:35:09 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: 21694 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp436381wrr; Thu, 17 Nov 2022 06:41:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf5ZItC5dpNuFEND2TubLwtb7m89AxYtVhZEoK6R2VZd1A3jWUCiq7280Fy95kWDUAnuC8r4 X-Received: by 2002:a17:906:7ca:b0:78d:95d8:f8db with SMTP id m10-20020a17090607ca00b0078d95d8f8dbmr2256743ejc.592.1668696093394; Thu, 17 Nov 2022 06:41:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1668696093; cv=pass; d=google.com; s=arc-20160816; b=h/E0zheeWZPzsdHYNESvARNutyBhSVk9PMJLMiJPvQ7O/toBMeg8bFFIIsTVAsAkmu kjvGsOZyK6EkMwueoc3kHA92Xs7GfLRXXKRoiiPplSqAr+FJSpXVtn9JZ9PBi7yX3K0C yHF+M1x8wTPpwWhXr9NZaUmEzYafFARFdkOHN/6Xmyka/3koKdj7qbDrufBqv/Kl6ZHr hMLlCqAhlrAKmXOaPiI1wy3ZxocOx36SCunIlNUKxlEEzygofa5PV6Vj7ZK6/GGRbsqk i6lO4tMGbEeFmj8IS5mVmzKQNGrS0bejlmgvpa0Cq4fJLDmy4Dq8uSZFgIFPRMxwxJYN Jxxw== 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=a0BKuEF8syyRgU4XzAFT6Af59SNVkq3BbSzf6j607pc=; b=XU1sfeeVDki4OdIWc/AXcgwYOfIfJoklWj1Wjo2H79HzwL/29kcTn6ZSpaIt4sG1i6 TdgkZCd9T0r8eXiwZJEyM3yvt5BhB4UMJaI6jkJx6UM4Mp8WxGKYePhEpDOt5eQZf97E c6eCvDgG1wmEunKe73ka9rNckvbhsIrVd9+ZyhvF4oCWbMxGfMkNoSo+8SqK9vtEpEUJ M9qQCVQr5fC4+VjvgubtjJCXwxy+xwqJGxPUCVUA/QOIStypCzVkuKVJWQ1ZvBDKeYCP Wb1TaP+jNr5SI8/3NTF/gcHQN8E1MVxIU4dY0vqpHn5jAsO2S0YhljukfD7R44wBxetF nbaw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@vivo.com header.s=selector2 header.b=j0l4cDh+; 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 qk18-20020a1709077f9200b0078849a014e9si867574ejc.196.2022.11.17.06.41.08; Thu, 17 Nov 2022 06:41:33 -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=j0l4cDh+; 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 S239977AbiKQOhs (ORCPT + 99 others); Thu, 17 Nov 2022 09:37:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240323AbiKQOhV (ORCPT ); Thu, 17 Nov 2022 09:37:21 -0500 Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2098.outbound.protection.outlook.com [40.107.215.98]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 33ACD8220C for ; Thu, 17 Nov 2022 06:35:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hjytyMugGyIPIxr+apUWEEpHp8z4PEDxvZHGiyLX040tERtTO6hjRqWMSZt0Zdx6g+3+bxLm8+AXpQe15GYGkYMbVK9hWynfA8MDljcjoCdqnWXnFgHKXtDCyDlbHWTWVDjCJU8h30RlCw2X5fYdORl901CzE8VpDVSnKCW9Rc7ZfdtKwnOHoudyNjDS+ZbW620KZySILxv3ljrhEcEk47LkVBYEfSkOvWplPIGNpqlw4arr8eHYy/JNcI3X82HXluuBQkYiplPJ8ajs5LagUOxGl57Dv6DAFOyNorR5SHV0i3cPkXzWSz2Gwq00ErfXlEPCO5jXeT+be2b6t/F80A== 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=a0BKuEF8syyRgU4XzAFT6Af59SNVkq3BbSzf6j607pc=; b=oLygAO35MLcB8Tx9D1+RHC4gLH5D7M7JIG05Ud15/iMuVhIHwHrr8VXYIiJjNcbaXaF0tnV/7QcAacDomVn+PYS+ok3FWX8ZtRh6y8xuMJ2rzCyAEpqMvkKutC04P16Fmcy890AbgWPZfCeCVc7oC7TcS68QWhmRxqULUtbt5HWqV3teLCJLglDnsjXsaKiXqfb+YH2/W515MBjoEDyDOeDLPE5NZiDBckD65tQINby3hygpG6Cw0DYaMwr526XxbOKa8xtPT7VG9bOLJxn0PKhgB3KD5+JZi1E6SOYLBNdhAvGiLEq3OEp7zPWO7kkweMFHlNy4RZ+6PEgVcB3JuA== 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=a0BKuEF8syyRgU4XzAFT6Af59SNVkq3BbSzf6j607pc=; b=j0l4cDh+ZaFmmfjLa5SEI1kolAu9CnxlRGrFskHeYo4838EofYf+UbWTpn/QLIWScEYCNLLNhvayWSzcAEYKdrXlVyz0oG+x+RK0l41ccPvtureybnR+0prOJlT7F7/bz7VHybSSEnd3lCGcFnNsv3p9xk+30/cCZrA/jydI0nRupnHQM6qehdFNq2SFDTOoswTJozTNblfIW3bqoN73Mqg20jymjD9+abrThM1yev3Vk9jeE/NvoiYGvw1eR+P9HaB+urY1Jp4KJS6VIdbqJGTL0e+fMUakzn5aJQvnMTKQwSNnew/CWzaZC7Kn9f7f20OjLSuxU+2kRsQcb6yulA== 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 PSAPR06MB4311.apcprd06.prod.outlook.com (2603:1096:301:81::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5813.19; Thu, 17 Nov 2022 14:35:19 +0000 Received: from SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::1230:5f04:fe98:d139]) by SEZPR06MB5269.apcprd06.prod.outlook.com ([fe80::1230:5f04:fe98:d139%9]) with mapi id 15.20.5813.019; Thu, 17 Nov 2022 14:35:19 +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: introduce discard_urgent_util sysfs node Date: Thu, 17 Nov 2022 22:35:09 +0800 Message-Id: <20221117143509.58913-1-frank.li@vivo.com> X-Mailer: git-send-email 2.35.1 X-ClientProxiedBy: TYAPR03CA0006.apcprd03.prod.outlook.com (2603:1096:404:14::18) To SEZPR06MB5269.apcprd06.prod.outlook.com (2603:1096:101:78::6) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5269:EE_|PSAPR06MB4311:EE_ X-MS-Office365-Filtering-Correlation-Id: 97f2e7af-e06a-4802-f98c-08dac8a8f372 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5tGV2PCVO8D6hlBmJElz3zHyzxXzF3iqEH3DDhCu68nH2Vu9jlbqTnHwop4q1XUyCD83xtGIIeF3U76IfQSiaz4Ekj7s+VKRUEcb8nUX9mZARl1mIsRXiQrhzgbAaonp1Kqy7x5Md7TQ8kf3WcTyuujyFpfzdSqfh5r21czEJWcL3MFJoYOlyNm+KDV7BG5LVk3Fv4YA7MSjXfDv4rCkfXgmxioYyfAShJrW2D8VvNfcB/SvX+5C4ODOEUmFiDNzG5aCQUpDSfkf9ugqQnB1r5dsapIJtEnsIcCkt2reB0Z8XOm8RvQ1DoyNJ3hlvSutg5ofSDdEIgC8n2sO5YQ3L5OTU6qqUd0rh1J2PJfAgpGDTt7LmF2MXaN9TQNAXRbVVSv4cNk5/XwV1Yy2F9i775OdcN262a0F72qmUeYSbEsFx5ljw+7JhEl8BiW9Fkn9Ab5gYXeE2+6+uoiSYGh+m4b3zxsVaSTueMuoxCNCljBQQ7pl2nCJc7Ac1o2L1jkZTNpEZCknf+4RRkU00x4ZatIOaK5E7+MfPFqoL9T0tFFGeOTS5VA6eC8D54V3nbA+q7e33klgqq6W5Bnp8RlbUHSfrtYNfF1bEMlFPeRHG3dSa5pepjXzUA0VO3+OYVy4qwr+CcRZQ9d8a6RW3VxAnZ1cTsc+2HoSlgwJG+NgFjLmXdlwLqzmXAHR86cXKSG4 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)(346002)(376002)(136003)(39860400002)(396003)(451199015)(2616005)(52116002)(6506007)(1076003)(26005)(186003)(6512007)(83380400001)(38100700002)(38350700002)(2906002)(5660300002)(6486002)(8936002)(107886003)(6666004)(478600001)(8676002)(316002)(66476007)(41300700001)(4326008)(66556008)(66946007)(19627235002)(86362001)(36756003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ocv0tYCLDAy6eUxc5HWWVexNptNxR8JJ1JVFMieE6L7GH8oHc4ovm/6V+5wW8nEeYJjwq9/DOk3IpZ46igi+oJlqfvZ1jlRgO2IN1RZun29EA5EikaxAV74bXn/PjSvO12zFjJo94dlzhhIZpqacWE8AwYBJk3SNaMWpraMQrhdWChl2VPaYsiGT6UR0zaCvqMLdiT2pCLUIbKG4UVFDpgUs5ZsFEFXwIBLINAr2TV/q1/lykmPSqA9kfE0PNu2CyGfzVrP+Poh83jmCW/BcugWoY5Rw+/JEUlwPdGTfDcsFIFJlId5C/YibywLT2A0LJTBxWy2VoUiS4YL5STTYYqa7lk5G4KJ5B1KAF4A/IKCLIO7SQEvuqjALRg2YfQ6Y+qeFLlXOH6ZmK3qz88bZ3MnMx5qlRQVJSKDGApkaF0NK7U7IUJzz7DyXVDMvaCMlHoWXlDtv7xUA0XTDyx7Le37M8seTNALizeL0FAul3NUPXLlr+HA6O3RyuZsdrt/qE6gUt32AL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OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: 97f2e7af-e06a-4802-f98c-08dac8a8f372 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5269.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 Nov 2022 14:35:19.2836 (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: OoOGhUUAFY94Zg93ssuG7jf6vzOlIki9lY/Nn8DdnDwFSmLnPQZG6IT9AXrQq0/NKCC5oiHCsQSRBv9X03t4UA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PSAPR06MB4311 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?1749754674861906825?= X-GMAIL-MSGID: =?utf-8?q?1749754674861906825?= Through this node, you can control the background discard to run more aggressively when reach the utilization rate of the space. Signed-off-by: Yangtao Li --- 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..202ac1bfc6f2 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 dedac413bf64..fe42ac74491d 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -411,6 +411,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 8b0b76550578..575c24b42df9 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 = 1; 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 97bf0dbb0974..a7dc726054b9 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 == 0 || 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; @@ -795,6 +802,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); @@ -925,6 +933,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),