From patchwork Wed Aug 7 11:07:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liao Yuanhong X-Patchwork-Id: 13756153 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 15474C52D6F for ; Wed, 7 Aug 2024 11:07:45 +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 1sbeW8-0008Qi-4S; Wed, 07 Aug 2024 11:07:43 +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 1sbeW5-0008Qa-Hk for linux-f2fs-devel@lists.sourceforge.net; Wed, 07 Aug 2024 11:07:41 +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=S6S1VeZ1IA7yyuDlVJSC2QYXi9n0B8EHO4qzVyL2Yes=; b=fx5W6jLepnlWSUUJfxiCHq4PfR B3qprE+EsxKKWTeIVKYNwmSL2wk6ZoJZv5PHCSLlGclNRTpdItZzcNAB5Yw+yOm5xKGsuiD/VWIbQ 5C8CNS89AAkUkUnhUJ+0kFnXuNhrpx+LW7FcG1mtdbH+MAoEOV+7uH3jAzaWys/YxDBk=; 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=S6S1VeZ1IA7yyuDlVJSC2QYXi9n0B8EHO4qzVyL2Yes=; b=c atQqRXRBoYgJVbElDEoaqEn7r24bjolQiwt1mecZLKChf4POA/1kqJYM7MEVoSy699LDaWZ+mb1fx cEaGgw75opm5QUk4hb2ZPGAT7n6GUEAr+YTqk0M+a5d1uOyaheT277QHMyIpdlDYcRPUzcq4XSoBB dsFbhP7Z4idmtXRM=; Received: from mail-eastasiaazon11010034.outbound.protection.outlook.com ([52.101.128.34] helo=HK2PR02CU002.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 1sbeW4-00023R-3r for linux-f2fs-devel@lists.sourceforge.net; Wed, 07 Aug 2024 11:07:40 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FZ/1oLYqnz50N8nH1GiLC/pY3ABBkp9o28sVi1KOHjQNbvG2vHpJ1uNx8Q1dsnF0FNuwZ2Yk0hjqY0s2t0TVNS2riyZ/QlJXy72VmERyQea8uXy0avKbDKO2f8gL7u3C6Vc4jP4hDWjnJecoymR910eeZNehAOE+CpZcLdfTVoMILq0DMPpmWtqG/lYmG8Kq2BIsPJyq1kz41R+CJzv6ptMI5Ss+oWRcPubygjl1Qz7MS1RKD4CPxkAS2OO3YuzLSDKwD0IJfgQTBKd9CCBz1AT4HF/j/Dr/MozHwB/Kvg7UUpkZVs7V/aG8w7gDNGjk9v50mx8G13yNcehr367ppg== 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=S6S1VeZ1IA7yyuDlVJSC2QYXi9n0B8EHO4qzVyL2Yes=; b=vAT7N0wfpG4PpcmNYkJUz7g6bdpG98mHXn+vFq0CLQNVfUoHdujWUBYWYSYnp07QC9PzBCx572L+D6BkpHcIvb9Fbz+N2HQfzgppWBQsSY/yPd7yTO95KV8vHvpr2ebMnAKmMgUdD7rj83XMpLkIYt7/mMq7+Rt8zy2YKMy/j2E8HVfQlLMYqPzSnBQT/5MDhvZ6MOcfaW5n9XLqONsZ+ee/EODBh5HGz+fnC2Z3uLlxw00i9FUMv/EXsrNgg77HuV/cH9cKKoltll0z9KjfvHJiw3tIi9FGW4UW7ji7F/2q1OMVchvEWvNwbmbReevdrQGCJv8PgtPlfx7h8wFZjg== 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=S6S1VeZ1IA7yyuDlVJSC2QYXi9n0B8EHO4qzVyL2Yes=; b=HN1bq6IpuwYcBR4N21H0hvzk/B6QC4nGnW6YddLe5v4nCDR6ac3YiaBsz1m6Q946oo6By/xcTnsyTtBtydKzd4ljvZoiquVcaAHYFw1zejGwZgFQoH9D88CHJAepOX93+OOpDTT92Rp+rXSsQnIWUxz3ZKIg1gOgu+RZlEvx7ddonvwRwT1ahHyL9TA2X6kYXfe0mnl64qdNU+vPX1NJ/WuXky8e+vPmxzvFooOnPOQRpEEJ2jxjxLhxKhtktLRrX1127gfOFpCOotgm1GKnB/uUNhoL/5kHOrXwNCKgE6x5ndyVScib3DbbB02uBmTEvrGitPVLX6AD7q3XDdCw9w== 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 TYSPR06MB7341.apcprd06.prod.outlook.com (2603:1096:405:98::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7828.26; Wed, 7 Aug 2024 11:07:30 +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.7849.008; Wed, 7 Aug 2024 11:07:30 +0000 To: Jaegeuk Kim , Chao Yu Date: Wed, 7 Aug 2024 19:07:15 +0800 Message-Id: <20240807110715.6541-1-liaoyuanhong@vivo.com> X-Mailer: git-send-email 2.25.1 X-ClientProxiedBy: TY2PR04CA0013.apcprd04.prod.outlook.com (2603:1096:404:f6::25) To SEZPR06MB5576.apcprd06.prod.outlook.com (2603:1096:101:c9::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SEZPR06MB5576:EE_|TYSPR06MB7341:EE_ X-MS-Office365-Filtering-Correlation-Id: 79342b04-2dac-4c50-3f1d-08dcb6d12128 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|1800799024|52116014|376014|38350700014; X-Microsoft-Antispam-Message-Info: BbPsRbdPlucCCR9PCzBN0brVC4aSUzFHn3hrnBFmKMcaBGSrVKZpCOjWhen8t5uCY0Ldtke8Ej15ZBQZaPmwJ0u9ZlkbR7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dEw7iHj7agSO0DQDvqttQey1SL91ZAKXCGnv9GSROScviEneAhJTVY0nKO0xBjBHSO95hhbuunpdjpZIM9+U7Y+YKOqjRAUOK0rNqPyhQ3LSDfU9DqIJDdS5LVHCKR67WYahejsCxS2fZA/12aBjYK63HHAZYO9H2Vdh8J4fxfwfsnjdM78UqSlP6nc8MXc8YGmWN8SwLtEpiKGCm/og/LDODN7jFjYLuPg6sdQGgaoXTUe36TOjD2ZwXtAxFmHaPLMGwg== 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)(366016)(1800799024)(52116014)(376014)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: y4n7/99mig7lBVQ0JQhVxvAaSvVxcqmjAy2yJh3v3DRAO9BwGKLeZNdxyQm5EnaOry71zi0wFJGsbvgUO6UUhijhzenxjV79c8oQ6CBSymU1jrX41NSP7+NNz6jgJz7nnQbrlDdqn38AGoHWzO0bifmCsqF9Ej9cLoVxwCvS5Y+1Vi/VMwMXpn/octOkTggUIDs2nUTPujz7Zlk0jeN6Dazk6LSSDqnGVFMeM6unVwWuvTagi4NSF0VYCl96eaexIQY5lq7vFtK6NaRZH7dw4ZYGqYr4jKP2pIhbrZxDJ5l0ctk1fC2P+q9yg20TBuKh/mHk8+P5G1hqyNwlO/0xSTk5DcA7Nv/T5RKOdUYHcq5fiqQJKgMIoXQ8C3Ul1jAyvwdAAYT6oi/vD+NlD6yit+XwjYd6pnnLezZ10hb8mheOmwYbSYWNkGNpFTN+LJYRgCqkZCzEp8osa0YLKNf43CdXlB343XJIzKamAV/czFOX1hJ+YkZ2Lyeu8zArV9st+EC0OSAGBgBg61lNiycWTVrweBfLFmpJaM/Txoovq9Az4O7VGjbBFOmoEIe+gMsJ4JFxEie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f1d-08dcb6d12128 X-MS-Exchange-CrossTenant-AuthSource: SEZPR06MB5576.apcprd06.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Aug 2024 11:07:30.2640 (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: z2BJauS5VnNNsjaW+sjfKdhiJEfGUvFd1hPPsRexMphamNReXpzvEVvpq/hbnXezz2Fc3wqYFwm2oADqW1BBFQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYSPR06MB7341 X-Headers-End: 1sbeW4-00023R-3r Subject: [f2fs-dev] [PATCH] f2fs:Add a threshold for the FG_GC of zone UFS 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, liaoyuanhong@vivo.com, bo.wu@vivo.com, linux-f2fs-devel@lists.sourceforge.net Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net Right now, when a zone UFS device gets close to running out of space and starts FG_GC, the system continues to execute FG_GC even if there is a few dirty space available for reclamation. This can make everything else slow down or just hang. Since the function for calculating remaining space operates in sections as the smallest unit (has_enough_free_secs), it only makes sense to reclaim space in multiples of sections. Additionally, the larger the zone size, the slower the reclamation speed. If the total size of dirty blocks is less than one section, not only is the reclamation efficiency very poor, but the system will continue to be stuck in FG_GC. So, we really need to set a limit. If the clutter is less than this limit, we shouldn't waste our time with FG_GC. It's just too slow at that point and doesn't clear up enough space to matter. Signed-off-by: Liao Yuanhong Signed-off-by: Wu Bo --- fs/f2fs/f2fs.h | 6 ++++++ fs/f2fs/segment.c | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 51fd5063a69c..aeff0d2a644f 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -133,6 +133,12 @@ typedef u32 nid_t; #define COMPRESS_EXT_NUM 16 +/* + * Avoid entering the FG-GC when the total size + * of dirty blocks is below this value + */ +#define FOREGROUND_GC_THRESHOLD 2 + enum blkzone_allocation_policy { BLKZONE_ALLOC_PRIOR_SEQ, /* Prioritize writing to sequential zones */ BLKZONE_ALLOC_ONLY_SEQ, /* Only allow writing to sequential zones */ diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 741e46f9d0fd..5ad7b5362079 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -418,6 +418,8 @@ int f2fs_commit_atomic_write(struct inode *inode) */ void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need) { + block_t invalid_user_blocks = sbi->user_block_count - written_block_count(sbi); + if (f2fs_cp_error(sbi)) return; @@ -438,6 +440,12 @@ void f2fs_balance_fs(struct f2fs_sb_info *sbi, bool need) if (has_enough_free_secs(sbi, 0, 0)) return; + /* + * If there aren't enough dirty segments, GC is not required. + */ + if (invalid_user_blocks < FOREGROUND_GC_THRESHOLD * BLKS_PER_SEC(sbi)) + return; + if (test_opt(sbi, GC_MERGE) && sbi->gc_thread && sbi->gc_thread->f2fs_gc_task) { DEFINE_WAIT(wait);