From patchwork Tue Sep 24 09:56:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liao Yuanhong X-Patchwork-Id: 13810632 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 38F9ECF9C6B for ; Tue, 24 Sep 2024 09:57:02 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1st2I1-0002o5-TN; Tue, 24 Sep 2024 09:57:01 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1st2I0-0002nx-Sg for linux-f2fs-devel@lists.sourceforge.net; Tue, 24 Sep 2024 09:57:00 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=MIME-Version:Content-Type:Content-Transfer-Encoding :Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:In-Reply-To:References:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=rxVstS/tsmft28TiJt82p9fPxgOqFdFZeDzVMSpD8pQ=; b=A0/unp3m97UBV8ovnzURNNv7x2 uJiDYnV3DJvjWPnCfvzNw388f/jJ+0tIP5KNgKt7jy1JY/eTdcu8HFS/9KfpQ22S2D2x1jgdaohaE 5xS+NjrXPm0osv1bnFgRnyqYhWZz94vuigb0EN/xj9j+6Q75uRZAXbD0qegUtP+d+Jso=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:Content-ID:Content-Description:Resent-Date :Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Id:List-Help:List-Unsubscribe:List-Subscribe:List-Post: List-Owner:List-Archive; bh=rxVstS/tsmft28TiJt82p9fPxgOqFdFZeDzVMSpD8pQ=; b=W hUUBcFwxO0ZmjrFdR6LE16v7XFDMJdKI/JQLPkXcyQRigzoGrHd+fH/jLsKJdmpwuqY1NIekLEEys IwEslL8WV9C2+9w5g2uaIn3a4NPGz/5tG3q4+LWVZ5r7EPazJ+m1HbxLU1TeBf9B7EoTIOJKMaddv mHeeHFEw7aHQnXow=; Received: from mail-psaapc01on2043.outbound.protection.outlook.com ([40.107.255.43] helo=APC01-PSA-obe.outbound.protection.outlook.com) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1st2Hz-0007hy-7U for linux-f2fs-devel@lists.sourceforge.net; Tue, 24 Sep 2024 09:57:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wuiIg44iJb/YzonZLYFnZFqr70jmsRQZ+eBchwRVYRjUoJr22XSpC+BC4IxYmMva1IetnI9xnCqpXafloEj6rzja7o0NLZ5vZor8Cm4K8SLIRQrZCx6LPmdPPcUDtk5frg949nVRqQRtlqBDOnkn6l8a3cQxgG1B00kH4MfFIrOc9fKPUEo7/ZhStygRRkXBgQCPB/ClCLmGpKRx34QiLmmb3AqjJTwSQvcE+sttDV2h2RM1GYGNTbEdVXJ57o2iBA2Asqnj3gnjc9kI8pssrOHAj5NTBpWNhqEI3CEb/Ne0X7dxFd1oavxmTFkKdrtNTzwkXMZxSBbkH6RnN7szmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=rxVstS/tsmft28TiJt82p9fPxgOqFdFZeDzVMSpD8pQ=; b=osyx0F5YNInox2bMwmNA7Q+nG6xuQowd4HFxfh/iNvXloxrbSbxBC3nfEjK/usQe8OcfjQhjHGU9aW6tR0fYlbZYNd3bNnTHi2YbCsA1SY9LUNoGyvwqunYo+PmJT3tZ8sDOS2V3I22t13K/yprCwcQd1nJvqUQRSmFpWedwJyddGEXQMKIfNy0upxbLFg9/PrctZnxdKzA6aBLGvU5LFJAJDm19Ykf74NsLPDkDmXmuIVAUCPf5y0nTVo6C+HRgg25BnpfYoqlsl+Q98EZEfYwV506rYKmIC715GG2jcaKRykTIsWQSkVKcZ4vTR04/IKhz0a3sFRImZFxQQwDkWQ== 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=rxVstS/tsmft28TiJt82p9fPxgOqFdFZeDzVMSpD8pQ=; b=Ll9qjpSHD1G/eFSGZb3ScYDzNNfzrpm8ftJ3OOXUewjXQIA//a8Rg0MvsVKp8RqJx8u6PMO2oz0KSGacSyvWKnHq+aNv5c4FrHfiQdx0Cci3DXUZ5PnKhqb/Pb4MAP44NemLjwO+V9FxSWiBj1P8qHuLixXWkG5f38BUYeKXj2r3y7YsEWX5yTBQAz54Ag6b0gmRXko/6eHuRc5D0g75qfsc9JD8tjcCcU+vT48f2I/p7W1+iiGlWlEQxeNAvOGstYJW864wWNRgg9z7zlq5Ve52u5UFjomtEoQaXh0kSBUpvEMmmN/bZ632FRhuMbQobCC80wQS6FXwMVJp8sA07Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=vivo.com; Received: from SEZPR06MB5576.apcprd06.prod.outlook.com (2603:1096:101:c9::14) by TYZPR06MB5482.apcprd06.prod.outlook.com (2603:1096:400:287::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7982.25; Tue, 24 Sep 2024 09:56:45 +0000 Received: from SEZPR06MB5576.apcprd06.prod.outlook.com ([fe80::5c0a:2748:6a72:99b6]) by SEZPR06MB5576.apcprd06.prod.outlook.com ([fe80::5c0a:2748:6a72:99b6%4]) with mapi id 15.20.7982.022; Tue, 24 Sep 2024 09:56:45 +0000 To: Jaegeuk Kim , Chao Yu Date: Tue, 24 Sep 2024 17:56:36 +0800 Message-Id: <20240924095636.19457-1-liaoyuanhong@vivo.com> X-Mailer: git-send-email 2.25.1 X-ClientProxiedBy: TYAPR04CA0007.apcprd04.prod.outlook.com (2603:1096:404:15::19) To SEZPR06MB5576.apcprd06.prod.outlook.com (2603:1096:101:c9::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5576:EE_|TYZPR06MB5482:EE_ X-MS-Office365-Filtering-Correlation-Id: a6fdcd25-b9dc-4bc3-216a-08dcdc7f32d1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: jfMAblKeb3R4k+D7AwxTdwCajL6k7ak9L8cP2szBJiW3gLv8IRRsOukS9C3KoH0vpkQldtxPK4wUVAMHnnimPvtv6BM24C9x5yFXOWQAa0YCnmwkgDM+UAgy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hM4xdeF9FvShQh5qQlvikPJOkbqs4+pWDF00D0HkVyYA5We3xwoB9Pb6drEz0rjrplI4gfLl7UsXShgshu5Gnd4qmIJYkKPQbdEkzYOmEZ7ujdckgBM3Qkj+hnR20DOLqpgXycb7L7YSTXDKmndf54vclr+LFz9NQ+ObUKYDzWaiw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:SEZPR06MB5576.apcprd06.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(376014)(1800799024)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tWcFZ0Gg1RRk5oNDU4Qwc6iqw++84qqqaTkcDrYDjrjWJb4Mz1vKS5VYLtUDNeB7Oo2uB+mlDZzOoUs1Gy77VIqhCk7faZEaIdkB89Mrx3vl0zQSHN8MqrOcPPdtz2kY835KQhqVU5oRcURTILkxQ6IcWfaf13HmFmzNAbLkvFkRA+8sHooVkwx/4H/N/TYY61jal+QhInpRlCz7SZEZ/oxSgXehhJQn+cOH9/9o1ch5BM4x+zxUHb6I5CEvJYzIKKYdCCpLSjxkQXBqIAARudmZGyXXpqv4Ng7t6uuPAOuTJnd7oMzGLsDPUSCHZWyx+oIRRsZ1ucazHpP17uw9cUGX6dH+PUXjHqe5Fqmb2ysXGM92s3FoNsnN8N9fO1e2UEXdfci9jdPVnXVCxhTJPo/ugEGnByGmewLZhRKwmb6EYdyw/GjfdRRR2c08Uccb/ucYO0Xi9IEJPB66nxu9CmPH9+IjLCX6/Qx4/4lJyQf1+PI5cWRN2Ej3YaYgO/m6E42E2EhKEXxR92BbKDw9iUF2DR4I1tNMbcodhp5JpSiOC0Wk6Y0D+OYwDmUEpXBT55hxmhKBkUGicE7bN5vdOaGjeoAX7AdAjgZionA3qJGjCVjtqSZwUCbjKR1jRcSpmwBMCTZwF/GkyPYGrKmE2Y6Auqn+bywGbG9kXz/XxujHFNf6j8grrz8L3tYYiWyB6oG22Tpfvkk6odYY3YjS5jNpbbvJla9VxP7NQD9bicsyGm79K5bZ8v+VMAmeIBV/X2HGqbwjfiVdtdJ4UEcfdMWXXxbkHjYQ7DcK6Cve1A9nJ4XTbkd5PSuBXrOH2MIPVbIsCwSmXTDiWTn1z1NXgCIjgdSROQJalXaPBBkyEvq7kOXOb2h1+F/HTxV7D4WvpqlB/z9D2PhTvtiFP/oXouCxrsrcgomzyHjKPE1Xthf1pDVQNZAPHlzkjrD1FLTiOhDPQJjsorkzZtp/EDDd/a7KAX5n5GL7xjhulx9MSA6e2X4YM73vimUMPRuI+i6bR3JAQjiV5HahUhAZL6bOm6nTCFC+h0WDUlEyvoBkdlenC9/WunP5d/BiN5kMZ+T4yXQedTF5wTrcLT5J4E2pz3wSpAECkKuHtVj89yXNfBIfRhd7z27lkwk7rSS4WohtuINo8mHVXDm/dAENKiD3jHrrXJBrfC7akP7pY/+UIQjzfQChbdo7rOBtdU2LpMLW8wB/N/qIfHgSH4PMav/QqtNiecU4VvHTZVuEXEaMySt2aaYZArzmLYL3ZH7Zj8Of3D53HDpMMAwv93Ie1l8Hk2HwibmbAej1MMXhKGRiBtrZhEqIkUhCBEf113dL33FUQRgV0HQscyvK7eIUIeWbsbmseR0V5o1QvZvgxeWlWrQB4JiG1lzwbTGFCmDr6b9iMJwiaXq07K3YOUpBtyRat+FNHvP67BfA5+fVR1eyrDP9MCHsCeK+qcAVdIOJbcdjE6t9ZTFf2RYBqjmtjiZU0Jyzm/YkYBl8MoDwDGl2/hBG5GtiBIXsHx+PC6EBAFojttgegrDInQCMKs/tiU/JHYmEijRZdAvWnE9fjN72UFUfi/8ScBbAJmST/tQCdZMa X-OriginatorOrg: vivo.com X-MS-Exchange-CrossTenant-Network-Message-Id: a6fdcd25-b9dc-4bc3-216a-08dcdc7f32d1 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5576.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Sep 2024 09:56:45.2700 (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: WR4CU+V+W8CKaJbx3U56b0qEgwlaspIhKXIH+jy9EiyHsFgaQsFxZFVYbaqcx6XZxQ+YlkbqeJnQJIf0nvHjOw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR06MB5482 X-Headers-End: 1st2Hz-0007hy-7U Subject: [f2fs-dev] [PATCH] f2fs-tools:provide a more reasonable ovp rate for manually setting rsvd X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Liao Yuanhong via Linux-f2fs-devel From: Liao Yuanhong Reply-To: Liao Yuanhong Cc: linux-kernel@vger.kernel.org, Liao Yuanhong , linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net The f2fs-tools support manual configuration of rsvd and ovp rate. In cases where only a small rsvd is set, the automatically calculated ovp rate can be very large, resulting in the reserved space of the entire file system being almost the same as before, failing to achieve the goal of reducing space usage. Therefore, for cases where only rsvd is set and ovp rate is not, we will provide the same ovp rate as in normal situations, which exceeds overprovision_segment_buffer, and does not occupy additional space. Signed-off-by: Liao Yuanhong --- fsck/resize.c | 2 +- include/f2fs_fs.h | 8 ++++---- mkfs/f2fs_format.c | 15 ++++++++++++--- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/fsck/resize.c b/fsck/resize.c index 049ddd3..eca6555 100644 --- a/fsck/resize.c +++ b/fsck/resize.c @@ -147,7 +147,7 @@ safe_resize: /* Let's determine the best reserved and overprovisioned space */ if (c.new_overprovision == 0) - c.new_overprovision = get_best_overprovision(sb); + c.new_overprovision = get_best_overprovision(sb, true); c.new_reserved_segments = (100 / c.new_overprovision + 1 + NR_CURSEG_TYPE) * diff --git a/include/f2fs_fs.h b/include/f2fs_fs.h index 870a6e4..038002a 100644 --- a/include/f2fs_fs.h +++ b/include/f2fs_fs.h @@ -1760,13 +1760,13 @@ extern uint32_t f2fs_get_usable_segments(struct f2fs_super_block *sb); #define ZONE_ALIGN(blks) SIZE_ALIGN(blks, c.blks_per_seg * \ c.segs_per_zone) -static inline uint32_t get_reserved(struct f2fs_super_block *sb, double ovp) +static inline uint32_t get_reserved(struct f2fs_super_block *sb, double ovp, bool conf_reserved) { uint32_t usable_main_segs = f2fs_get_usable_segments(sb); uint32_t segs_per_sec = round_up(usable_main_segs, get_sb(section_count)); uint32_t reserved; - if (c.conf_reserved_sections) + if (c.conf_reserved_sections && conf_reserved) reserved = c.conf_reserved_sections * segs_per_sec; else reserved = (100 / ovp + 1 + NR_CURSEG_TYPE) * segs_per_sec; @@ -1781,7 +1781,7 @@ static inline uint32_t overprovision_segment_buffer(struct f2fs_super_block *sb) return 6 * get_sb(segs_per_sec); } -static inline double get_best_overprovision(struct f2fs_super_block *sb) +static inline double get_best_overprovision(struct f2fs_super_block *sb, bool conf_reserved) { double ovp, candidate, end, diff, space; double max_ovp = 0, max_space = 0; @@ -1799,7 +1799,7 @@ static inline double get_best_overprovision(struct f2fs_super_block *sb) } for (; candidate <= end; candidate += diff) { - reserved = get_reserved(sb, candidate); + reserved = get_reserved(sb, candidate, conf_reserved); ovp = (usable_main_segs - reserved) * candidate / 100; if (ovp < 0) continue; diff --git a/mkfs/f2fs_format.c b/mkfs/f2fs_format.c index e26a513..9c917c9 100644 --- a/mkfs/f2fs_format.c +++ b/mkfs/f2fs_format.c @@ -480,10 +480,19 @@ static int f2fs_prepare_super_block(void) * overprovision ratio and reserved seg count based on avg usable * segs_per_sec. */ - if (c.overprovision == 0) - c.overprovision = get_best_overprovision(sb); + if (c.overprovision == 0) { - c.reserved_segments = get_reserved(sb, c.overprovision); + /* + * If rsvd is manually set but ovp rate is not, + * provide the same ovp rate as in normal allocation. + */ + if (c.conf_reserved_sections) + c.overprovision = get_best_overprovision(sb, false); + else + c.overprovision = get_best_overprovision(sb, true); + } + + c.reserved_segments = get_reserved(sb, c.overprovision, true); if (c.feature & F2FS_FEATURE_RO) { c.overprovision = 0;