From patchwork Mon Sep 9 22:19:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daeho Jeong X-Patchwork-Id: 13797643 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 5A6F7ECE58E for ; Mon, 9 Sep 2024 22:20:14 +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 1snmk2-0004sH-Jh; Mon, 09 Sep 2024 22:20:14 +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 1snmjy-0004rl-D1 for linux-f2fs-devel@lists.sourceforge.net; Mon, 09 Sep 2024 22:20:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: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=96o2jLIHz/bI5xeY8SRyIJjzjj2HXt3FtxwUFI6EfOI=; b=FVcOWtXgvUhx8lbeeKj1Qs3apH UsGdTEGOJe0brnRJdIDo4YrFphVasTALptsHwww7smiVFaU+VSMi43P9QlMYfq/B9gZvdgpP9LxY8 b0aM2nMwZecli5JJyJiJZTTODhPf+QF0euRZiqhXHag1b3SGOMt7d9RDzMQabCGZvM7k=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:Message-ID:Date:Subject:Cc:To:From :Sender:Reply-To:Content-Type: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=96o2jLIHz/bI5xeY8SRyIJjzjj2HXt3FtxwUFI6EfOI=; b=L 7s4MN5SyzNzCzbDu5FjF0SPjxU78gK/UBazMABVBaqHAmlGhN5XMMHMgRN26bocKGef9YW6cgZdTP 0Xnjf3B7TlvqFSHh1hEZ6ax5XETgU+RCVxlD049pzYYYIzrHIL0dQ3xus4M6OU/kBHNmJR7iMdEav Fr6AhxnNj5SqCjno=; Received: from mail-pj1-f41.google.com ([209.85.216.41]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1snmjq-0006gP-Pq for linux-f2fs-devel@lists.sourceforge.net; Mon, 09 Sep 2024 22:20:03 +0000 Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-2d88edf1340so3120097a91.1 for ; Mon, 09 Sep 2024 15:20:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725920392; x=1726525192; darn=lists.sourceforge.net; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=96o2jLIHz/bI5xeY8SRyIJjzjj2HXt3FtxwUFI6EfOI=; b=ayx3EnjCIzRjYJ+TgWnPaz877YxPT9s8396w6mpgyRy72l2FQhjXsRvfWVoIyYIRPr Ob2vLz5bwuYyjPCcFxaAYpD3dYMnia28HuEUmtaX3PR1viUoollF2rQN0uSOUzePoSj8 lznQbr09KIa9V/nW4rFuIvGImLeR5zu8nVuj6nqbr/QMFFI2/8wdn8Tz7kRd30rCagHK lrtclAR1iAb1QufXLAv5ROVEQc2H9wyUVj2RTwWL/WUXzzML4uNQAmZt4+bt+tqZN2qE Bfp0OQffJ0UM+IIVVsV36AlbO6voy+di6jT7zxj75nB75ZyvpLf4Etob++rEMTf1tkSv cQ0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725920392; x=1726525192; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=96o2jLIHz/bI5xeY8SRyIJjzjj2HXt3FtxwUFI6EfOI=; b=QBbs/dHRafVdk99LFLX9jHhcp3sYIsXw/cUee1JzBQ5vGAM3sTE8NBje715U4Bd+hz EhBGJAgLBN8azCqKINVo6ShklkNw7ZKjMPN97Qrxz8MYC3lMWZfE9vyIY9btb/qCrqew nolKc4gb7M05P97XGlu7mLvI6vIpr2mor5ibZcS6WaXZuXzFMXym1SJRt8xPOpwsZk8t d//CyY0KwNmBxZTmelhVjNpB/ZDPZUi0cEeXOklc7bTRTejcVWzALr4QJiy/tmS1KFTl OZ0Et9Jx401RI6JYxT4dPZCmAalt41Q+J+/iiE0MJ6Ifb45X6jRaarC5AYI2igdg0MY9 D5UQ== X-Forwarded-Encrypted: i=1; AJvYcCXe1VZpHK3uAR2r4dnf8luro4HqzEUaA/aAAY6J+exxt3WCFeXWZ4LPXBbwTMjo16Tng4nrYRhhlB1ChfLw4g9U@lists.sourceforge.net X-Gm-Message-State: AOJu0YzM30tnPukM8MwxyrBWKawGkcg6dnpqdGVBqwjjvUKXwWRFCJeN XTrQAlAZROAZ7/dlj4eR26s5a2F+b7D6pjsD5O9boLLCDjGJR2PR X-Google-Smtp-Source: AGHT+IGYtptBMoCRyIFLyR68NFRnQCLG+PIh/2i8YAvc5XVEbC/o5hvfd2WlnY6N4BtfpvmnF8kruQ== X-Received: by 2002:a17:90a:e651:b0:2d8:f99d:48d2 with SMTP id 98e67ed59e1d1-2dad50fcd09mr10727795a91.29.1725920391729; Mon, 09 Sep 2024 15:19:51 -0700 (PDT) Received: from daehojeong-desktop.mtv.corp.google.com ([2a00:79e0:2e14:7:ed56:14c3:db02:6c66]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2db04988470sm5016840a91.54.2024.09.09.15.19.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 15:19:51 -0700 (PDT) From: Daeho Jeong To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com Date: Mon, 9 Sep 2024 15:19:40 -0700 Message-ID: <20240909221946.2004046-1-daeho43@gmail.com> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog MIME-Version: 1.0 X-Headers-End: 1snmjq-0006gP-Pq Subject: [f2fs-dev] [PATCH v2 1/7] f2fs: make BG GC more aggressive for zoned devices 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: , Cc: Daeho Jeong Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net From: Daeho Jeong Since we don't have any GC on device side for zoned devices, need more aggressive BG GC. So, tune the parameters for that. Signed-off-by: Daeho Jeong Reviewed-by: Chao Yu --- fs/f2fs/f2fs.h | 20 ++++++++++++++++++-- fs/f2fs/gc.c | 25 +++++++++++++++++++++---- fs/f2fs/gc.h | 21 +++++++++++++++++++++ fs/f2fs/super.c | 5 +++++ 4 files changed, 65 insertions(+), 6 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index ac19c61f0c3e..5e4db3ba534a 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -2854,13 +2854,26 @@ static inline bool is_inflight_io(struct f2fs_sb_info *sbi, int type) return false; } +static inline bool is_inflight_read_io(struct f2fs_sb_info *sbi) +{ + return get_pages(sbi, F2FS_RD_DATA) || get_pages(sbi, F2FS_DIO_READ); +} + static inline bool is_idle(struct f2fs_sb_info *sbi, int type) { + bool zoned_gc = (type == GC_TIME && + F2FS_HAS_FEATURE(sbi, F2FS_FEATURE_BLKZONED)); + if (sbi->gc_mode == GC_URGENT_HIGH) return true; - if (is_inflight_io(sbi, type)) - return false; + if (zoned_gc) { + if (is_inflight_read_io(sbi)) + return false; + } else { + if (is_inflight_io(sbi, type)) + return false; + } if (sbi->gc_mode == GC_URGENT_MID) return true; @@ -2869,6 +2882,9 @@ static inline bool is_idle(struct f2fs_sb_info *sbi, int type) (type == DISCARD_TIME || type == GC_TIME)) return true; + if (zoned_gc) + return true; + return f2fs_time_over(sbi, type); } diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 724bbcb447d3..46e3bc26b78a 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -116,7 +116,17 @@ static int gc_thread_func(void *data) goto next; } - if (has_enough_invalid_blocks(sbi)) + if (f2fs_sb_has_blkzoned(sbi)) { + if (has_enough_free_blocks(sbi, LIMIT_NO_ZONED_GC)) { + wait_ms = gc_th->no_gc_sleep_time; + f2fs_up_write(&sbi->gc_lock); + goto next; + } + if (wait_ms == gc_th->no_gc_sleep_time) + wait_ms = gc_th->max_sleep_time; + } + + if (need_to_boost_gc(sbi)) decrease_sleep_time(gc_th, &wait_ms); else increase_sleep_time(gc_th, &wait_ms); @@ -179,9 +189,16 @@ int f2fs_start_gc_thread(struct f2fs_sb_info *sbi) return -ENOMEM; gc_th->urgent_sleep_time = DEF_GC_THREAD_URGENT_SLEEP_TIME; - gc_th->min_sleep_time = DEF_GC_THREAD_MIN_SLEEP_TIME; - gc_th->max_sleep_time = DEF_GC_THREAD_MAX_SLEEP_TIME; - gc_th->no_gc_sleep_time = DEF_GC_THREAD_NOGC_SLEEP_TIME; + + if (f2fs_sb_has_blkzoned(sbi)) { + gc_th->min_sleep_time = DEF_GC_THREAD_MIN_SLEEP_TIME_ZONED; + gc_th->max_sleep_time = DEF_GC_THREAD_MAX_SLEEP_TIME_ZONED; + gc_th->no_gc_sleep_time = DEF_GC_THREAD_NOGC_SLEEP_TIME_ZONED; + } else { + gc_th->min_sleep_time = DEF_GC_THREAD_MIN_SLEEP_TIME; + gc_th->max_sleep_time = DEF_GC_THREAD_MAX_SLEEP_TIME; + gc_th->no_gc_sleep_time = DEF_GC_THREAD_NOGC_SLEEP_TIME; + } gc_th->gc_wake = false; diff --git a/fs/f2fs/gc.h b/fs/f2fs/gc.h index a8ea3301b815..55c4ba73362e 100644 --- a/fs/f2fs/gc.h +++ b/fs/f2fs/gc.h @@ -15,6 +15,11 @@ #define DEF_GC_THREAD_MAX_SLEEP_TIME 60000 #define DEF_GC_THREAD_NOGC_SLEEP_TIME 300000 /* wait 5 min */ +/* GC sleep parameters for zoned deivces */ +#define DEF_GC_THREAD_MIN_SLEEP_TIME_ZONED 10 +#define DEF_GC_THREAD_MAX_SLEEP_TIME_ZONED 20 +#define DEF_GC_THREAD_NOGC_SLEEP_TIME_ZONED 60000 + /* choose candidates from sections which has age of more than 7 days */ #define DEF_GC_THREAD_AGE_THRESHOLD (60 * 60 * 24 * 7) #define DEF_GC_THREAD_CANDIDATE_RATIO 20 /* select 20% oldest sections as candidates */ @@ -25,6 +30,9 @@ #define LIMIT_INVALID_BLOCK 40 /* percentage over total user space */ #define LIMIT_FREE_BLOCK 40 /* percentage over invalid + free space */ +#define LIMIT_NO_ZONED_GC 60 /* percentage over total user space of no gc for zoned devices */ +#define LIMIT_BOOST_ZONED_GC 25 /* percentage over total user space of boosted gc for zoned devices */ + #define DEF_GC_FAILED_PINNED_FILES 2048 #define MAX_GC_FAILED_PINNED_FILES USHRT_MAX @@ -152,6 +160,12 @@ static inline void decrease_sleep_time(struct f2fs_gc_kthread *gc_th, *wait -= min_time; } +static inline bool has_enough_free_blocks(struct f2fs_sb_info *sbi, + unsigned int limit_perc) +{ + return free_sections(sbi) > ((sbi->total_sections * limit_perc) / 100); +} + static inline bool has_enough_invalid_blocks(struct f2fs_sb_info *sbi) { block_t user_block_count = sbi->user_block_count; @@ -167,3 +181,10 @@ static inline bool has_enough_invalid_blocks(struct f2fs_sb_info *sbi) free_user_blocks(sbi) < limit_free_user_blocks(invalid_user_blocks)); } + +static inline bool need_to_boost_gc(struct f2fs_sb_info *sbi) +{ + if (f2fs_sb_has_blkzoned(sbi)) + return !has_enough_free_blocks(sbi, LIMIT_BOOST_ZONED_GC); + return has_enough_invalid_blocks(sbi); +} diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index 3959fd137cc9..ca2101ad918e 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -707,6 +707,11 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount) if (!strcmp(name, "on")) { F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_ON; } else if (!strcmp(name, "off")) { + if (f2fs_sb_has_blkzoned(sbi)) { + f2fs_warn(sbi, "zoned devices need bggc"); + kfree(name); + return -EINVAL; + } F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_OFF; } else if (!strcmp(name, "sync")) { F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_SYNC; From patchwork Mon Sep 9 22:19:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daeho Jeong X-Patchwork-Id: 13797639 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 D5A81ECE57E for ; Mon, 9 Sep 2024 22:20:02 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1snmjn-0000LT-Mr; Mon, 09 Sep 2024 22:20:00 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1snmjm-0000LL-IR for linux-f2fs-devel@lists.sourceforge.net; Mon, 09 Sep 2024 22:19:59 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=iGCC+Dv6h85N/mf1N7X2UqBFYf5VzPR2k8+fGtZL+fQ=; b=Q0oin4kCqgdFGy7Zzqkh+qvVM+ t4C0nRa7+61lpc/EG67YGcQY2ZC6Vk6WgNq4EhhdahF1KQEnhHe20mxyrprCIB5Z5j1rtfJBCfjC5 taHLmHNHAHxazXxDtOdR/EG0dQSmo7TbhzMc8MS/VVBQ1xyvnnGymCqtlUPgp8pGEDCk=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=iGCC+Dv6h85N/mf1N7X2UqBFYf5VzPR2k8+fGtZL+fQ=; b=AcvUMeVLHhi7xbOC0LfS1uVAMC PYYFDyjwXJzN1p86pQdRdS1G2oX+FVuyBdyiS2Gi5RlkpBsbt7b52/Du9zcq9QjhQtpV0HYlI7df/ GL0om/neTv+TQxGBMsmzDikY8xnIF1tGcVL4K39KrH0CdQpZak9TwboA5uOQvbsMTlqI=; Received: from mail-pj1-f42.google.com ([209.85.216.42]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1snmjm-0006gD-GK for linux-f2fs-devel@lists.sourceforge.net; Mon, 09 Sep 2024 22:19:59 +0000 Received: by mail-pj1-f42.google.com with SMTP id 98e67ed59e1d1-2d8a744aa9bso3137367a91.3 for ; Mon, 09 Sep 2024 15:19:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725920393; x=1726525193; darn=lists.sourceforge.net; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=iGCC+Dv6h85N/mf1N7X2UqBFYf5VzPR2k8+fGtZL+fQ=; b=Ab5Rtyz1W061Bl8S20VWDEYPQ1OS0pf/o5Pc7N/bkv+c5wgMN3iXcgafFxmHSOSsL4 guwLN/yqhpE9Rc0xiMuCxzfCZE2y15DOs6nz8rQhNkMvQfLj9SonLvuHsUrN2OT8SQkg +kj4ModDtnWSL2ZvXkHqX1PlCBwcFvpkgy+0KRLja/7Q8GoojEvJPz9RtyIyzaCApkpM VxHaFZ4PQmSGA/AXv4Ae8PShJEOdzlObnBK/zaA1aukTnQZEGhQr8/uc+8mX+HnCfB4Q ODh6TJnvqXNtw7L1YP2YvNIBVwkOlcUCJFaDK73Ms6pOt1sDjT4IZrgQ1n+MG8EwBbKn gV/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725920393; x=1726525193; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iGCC+Dv6h85N/mf1N7X2UqBFYf5VzPR2k8+fGtZL+fQ=; b=LwAtsn+YQnFxzPAGxN7hvJoqiUMLeX7MhFAGYZQD8GNPojCGjziMv5g0+QG0IfaCoH JTQW/DPz6GmJzaaLysNt2AzoqTM7TS7SJ5OzPd5NNyAiW+2rXJDsNBzplhDNnvJmAFvG 2bpSwTjFBftPaIawJoG8iuz+V6fuGkOuaVAZTbNSwjlrqn3+3mMkh77NxuL353wbQM3B 1guqE7ES1PVzp2PWdFAs+OgBAWI2Ve501NThH0Q9PscO8cR8F7GdnNHM23qXyZucQpLD dH5fh7idrqeiyOnSqWWCmj3FJiq1J+cg1IX1574oWJSjB82q6skIbj2JHkBoDsFPUGv8 aCcg== X-Forwarded-Encrypted: i=1; AJvYcCULFSH9dBTHJ0Uudgl/Tf5ahsClbQc42xU+QYlItcDktHwytlfoKktxEBkeNBKmNVuBpBFRjHx4WQBoRx0QpIqO@lists.sourceforge.net X-Gm-Message-State: AOJu0Yyrtev9hMOx4lI3LTXvKlU2RB1RlwDHM2gvyyblJMBcZmvrI1sF DJG0qjcVKk/2yldNumFrqp2hczGFN/b79VzfiaCmo15YD+x29rZp X-Google-Smtp-Source: AGHT+IF+poKijXFR+9kbWavXc48h+JssHCWV+FY/Q/DkkEudniftOuE5WGPJoQNdnuKDdb0lIOEa+w== X-Received: by 2002:a17:90a:ae13:b0:2c8:e888:26a2 with SMTP id 98e67ed59e1d1-2dad4efda3bmr11982776a91.13.1725920392551; Mon, 09 Sep 2024 15:19:52 -0700 (PDT) Received: from daehojeong-desktop.mtv.corp.google.com ([2a00:79e0:2e14:7:ed56:14c3:db02:6c66]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2db04988470sm5016840a91.54.2024.09.09.15.19.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 15:19:52 -0700 (PDT) From: Daeho Jeong To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com Date: Mon, 9 Sep 2024 15:19:41 -0700 Message-ID: <20240909221946.2004046-2-daeho43@gmail.com> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240909221946.2004046-1-daeho43@gmail.com> References: <20240909221946.2004046-1-daeho43@gmail.com> MIME-Version: 1.0 X-Headers-End: 1snmjm-0006gD-GK Subject: [f2fs-dev] [PATCH v2 2/7] f2fs: introduce migration_window_granularity 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: , Cc: Daeho Jeong Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net From: Daeho Jeong We can control the scanning window granularity for GC migration. For more frequent scanning and GC on zoned devices, we need a fine grained control knob for it. Signed-off-by: Daeho Jeong Reviewed-by: Chao Yu --- v2: introduced a new migration_window_granularity instead of changing the meaning of the current migration_granularity --- Documentation/ABI/testing/sysfs-fs-f2fs | 8 +++++++ fs/f2fs/f2fs.h | 2 ++ fs/f2fs/gc.c | 31 +++++++++++++++++-------- fs/f2fs/gc.h | 1 + fs/f2fs/super.c | 2 ++ fs/f2fs/sysfs.c | 7 ++++++ 6 files changed, 41 insertions(+), 10 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs index cad6c3dc1f9c..9165f617d216 100644 --- a/Documentation/ABI/testing/sysfs-fs-f2fs +++ b/Documentation/ABI/testing/sysfs-fs-f2fs @@ -763,3 +763,11 @@ Date: November 2023 Contact: "Chao Yu" Description: It controls to enable/disable IO aware feature for background discard. By default, the value is 1 which indicates IO aware is on. + +What: /sys/fs/f2fs//migration_window_granularity +Date: September 2024 +Contact: "Daeho Jeong" +Description: Controls migration window granularity of garbage collection on large + section. it can control the scanning window granularity for GC migration + in a unit of segment, while migration_granularity controls the number + of segments which can be migrated at the same turn. diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 5e4db3ba534a..a00e01e66e08 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1685,6 +1685,8 @@ struct f2fs_sb_info { unsigned int max_victim_search; /* migration granularity of garbage collection, unit: segment */ unsigned int migration_granularity; + /* migration window granularity of garbage collection, unit: segment */ + unsigned int migration_window_granularity; /* * for stat information. diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 46e3bc26b78a..5cd316d2102d 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -1708,24 +1708,34 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi, struct blk_plug plug; unsigned int segno = start_segno; unsigned int end_segno = start_segno + SEGS_PER_SEC(sbi); + unsigned int sec_end_segno; int seg_freed = 0, migrated = 0; unsigned char type = IS_DATASEG(get_seg_entry(sbi, segno)->type) ? SUM_TYPE_DATA : SUM_TYPE_NODE; unsigned char data_type = (type == SUM_TYPE_DATA) ? DATA : NODE; int submitted = 0; - if (__is_large_section(sbi)) - end_segno = rounddown(end_segno, SEGS_PER_SEC(sbi)); + if (__is_large_section(sbi)) { + sec_end_segno = rounddown(end_segno, SEGS_PER_SEC(sbi)); - /* - * zone-capacity can be less than zone-size in zoned devices, - * resulting in less than expected usable segments in the zone, - * calculate the end segno in the zone which can be garbage collected - */ - if (f2fs_sb_has_blkzoned(sbi)) - end_segno -= SEGS_PER_SEC(sbi) - + /* + * zone-capacity can be less than zone-size in zoned devices, + * resulting in less than expected usable segments in the zone, + * calculate the end segno in the zone which can be garbage + * collected + */ + if (f2fs_sb_has_blkzoned(sbi)) + sec_end_segno -= SEGS_PER_SEC(sbi) - f2fs_usable_segs_in_sec(sbi, segno); + if (gc_type == BG_GC) + end_segno = start_segno + + sbi->migration_window_granularity; + + if (end_segno > sec_end_segno) + end_segno = sec_end_segno; + } + sanity_check_seg_type(sbi, get_seg_entry(sbi, segno)->type); /* readahead multi ssa blocks those have contiguous address */ @@ -1803,7 +1813,8 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi, if (__is_large_section(sbi)) sbi->next_victim_seg[gc_type] = - (segno + 1 < end_segno) ? segno + 1 : NULL_SEGNO; + (segno + 1 < sec_end_segno) ? + segno + 1 : NULL_SEGNO; skip: f2fs_put_page(sum_page, 0); } diff --git a/fs/f2fs/gc.h b/fs/f2fs/gc.h index 55c4ba73362e..245f93663745 100644 --- a/fs/f2fs/gc.h +++ b/fs/f2fs/gc.h @@ -32,6 +32,7 @@ #define LIMIT_NO_ZONED_GC 60 /* percentage over total user space of no gc for zoned devices */ #define LIMIT_BOOST_ZONED_GC 25 /* percentage over total user space of boosted gc for zoned devices */ +#define DEF_MIGRATION_WINDOW_GRANULARITY_ZONED 3 #define DEF_GC_FAILED_PINNED_FILES 2048 #define MAX_GC_FAILED_PINNED_FILES USHRT_MAX diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index ca2101ad918e..7b4908545793 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c @@ -3791,6 +3791,8 @@ static void init_sb_info(struct f2fs_sb_info *sbi) sbi->next_victim_seg[FG_GC] = NULL_SEGNO; sbi->max_victim_search = DEF_MAX_VICTIM_SEARCH; sbi->migration_granularity = SEGS_PER_SEC(sbi); + sbi->migration_window_granularity = f2fs_sb_has_blkzoned(sbi) ? + DEF_MIGRATION_WINDOW_GRANULARITY_ZONED : SEGS_PER_SEC(sbi); sbi->seq_file_ra_mul = MIN_RA_MUL; sbi->max_fragment_chunk = DEF_FRAGMENT_SIZE; sbi->max_fragment_hole = DEF_FRAGMENT_SIZE; diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index fee7ee45ceaa..66d15609d5ad 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -561,6 +561,11 @@ static ssize_t __sbi_store(struct f2fs_attr *a, return -EINVAL; } + if (!strcmp(a->attr.name, "migration_window_granularity")) { + if (t == 0 || t > SEGS_PER_SEC(sbi)) + return -EINVAL; + } + if (!strcmp(a->attr.name, "gc_urgent")) { if (t == 0) { sbi->gc_mode = GC_NORMAL; @@ -1001,6 +1006,7 @@ F2FS_SBI_RW_ATTR(gc_pin_file_thresh, gc_pin_file_threshold); F2FS_SBI_RW_ATTR(gc_reclaimed_segments, gc_reclaimed_segs); F2FS_SBI_GENERAL_RW_ATTR(max_victim_search); F2FS_SBI_GENERAL_RW_ATTR(migration_granularity); +F2FS_SBI_GENERAL_RW_ATTR(migration_window_granularity); F2FS_SBI_GENERAL_RW_ATTR(dir_level); #ifdef CONFIG_F2FS_IOSTAT F2FS_SBI_GENERAL_RW_ATTR(iostat_enable); @@ -1140,6 +1146,7 @@ static struct attribute *f2fs_attrs[] = { ATTR_LIST(min_ssr_sections), ATTR_LIST(max_victim_search), ATTR_LIST(migration_granularity), + ATTR_LIST(migration_window_granularity), ATTR_LIST(dir_level), ATTR_LIST(ram_thresh), ATTR_LIST(ra_nid_pages), From patchwork Mon Sep 9 22:19:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daeho Jeong X-Patchwork-Id: 13797640 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 7B9CDECE589 for ; Mon, 9 Sep 2024 22:20:12 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1snmjz-0000NA-B6; Mon, 09 Sep 2024 22:20:12 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1snmjx-0000Mg-2c for linux-f2fs-devel@lists.sourceforge.net; Mon, 09 Sep 2024 22:20:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=7ju9SGTU3qrpQt9b2K14pzpemAOmcwhjJLKLVpOR2qY=; b=Nw5qVRmiuc8By+G50MaozRqKCv Z+3VEXH7lBdMJPWKd23zjRhCtpAQABuab9dF6LWSXs9XMKTTPqps2r6iYJDj130DFzVES8o0b+jQm T31quaD7ZGhqqliZD4PMdRTj3H/WJFiZgFr29VScNBXZqlUKqH8Z8lXYYKA/kQmxitmI=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=7ju9SGTU3qrpQt9b2K14pzpemAOmcwhjJLKLVpOR2qY=; b=YsM+e9t2k+fEBDhB3QDOc/E+OL DjpKk5Af/26LEohWEIcD9OwflThUzhHUyNvsL0AON7uJn9MrkxYNLr7I/mnZ3l6RqTWzsGgtamoI7 5cf4BgLhxRG5ozWWwVG7JnzefVvUtEhn5+bsrYAZLp+xteCpdKjcLNNG9Yi0g93h//Ag=; Received: from mail-pj1-f41.google.com ([209.85.216.41]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1snmjs-0006gS-Dj for linux-f2fs-devel@lists.sourceforge.net; Mon, 09 Sep 2024 22:20:05 +0000 Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-2d8a54f1250so3193545a91.0 for ; Mon, 09 Sep 2024 15:20:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725920394; x=1726525194; darn=lists.sourceforge.net; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7ju9SGTU3qrpQt9b2K14pzpemAOmcwhjJLKLVpOR2qY=; b=RpflnFyX8gt5udYK4xdopWonMBCB3m/0OwrMCdcNMcXouzeyU92DAnIpQtc1juvNoY KyE4LOMSgGkjPvhQ9Att4Y+cj+4rmctajIj63IEmfKgxzmvXZ2kLrJRUnqKX6ox5p/4a wvNRAFWO5wZty7CW5wR/gy7NIk+2xrs/bR9HCN9ojS/2vfqA9+lrg3gMtHlqe4sUWvSw cWDgd7wmg3OMY3w2lfDZNnVhxLSSJuUTZ8B+1WQ4GibJfZPm3B6rftvHyFBz/M4GeSeI ON360nLv1sM92b3Z1RspEZHhoytpt5k8X+fUb1p9nTjlynwx26sKuVlmHv0Zs73xTyvv qZsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725920394; x=1726525194; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7ju9SGTU3qrpQt9b2K14pzpemAOmcwhjJLKLVpOR2qY=; b=C0i7NmWvsIMm5Fu0hsUh473AmPM3xfSrmstPyF9ergDSuEotmmPFxef43RnpuBE1I/ 3KLokP/3r7fl4JryMoS2bTwLsTtd636bi/0WDy83rzQeOpRhZ2mdpthH7OkxCsaePlXm b0mJ8tFcescLdZEHbV8i8Gei5qsEaSOK7NrD5hTlNA/KC5v2I2xHq1NM+8N9tafClmX5 iBRK3V0V3/tJV2REhguiaG+tsWQlKdyNMSlCwcinbnJHNS9Y+FNSiM2HFbpJqKvzM/eK D92eySG6+TMG/V515vcXHIBgGjQBEk8rYTw2fG5Y2YIu4dC/0EoanTSyjaXPKJTn/UQr OmKw== X-Forwarded-Encrypted: i=1; AJvYcCVO/ZdlFCyGi+ilsbv9H4Ml8ruk4+1YKEdyoiAESBeXRfGzoO1KxNDMtI/zwFJp9f8GZuRNr4v1w749mrM72g8v@lists.sourceforge.net X-Gm-Message-State: AOJu0YxKWKFpWu9R1SEKaChnZCO/itt+3cGoCI3t3Ee7ZnfUfrXQbuqN D2IXQjZo0CGz9oDPV/YFSPIvyqTdYV+VLrGiZ4lH2E5XYRyD+mee X-Google-Smtp-Source: AGHT+IEiweGW9x3af6N5AmUP+sYWfEa5idVX2NKd9Gi5tR4l5i+m0dhJU50vaHHcEmOfeF3QpFpMLg== X-Received: by 2002:a17:90a:f16:b0:2cc:ef14:89e3 with SMTP id 98e67ed59e1d1-2dad4ef808cmr14005403a91.15.1725920393685; Mon, 09 Sep 2024 15:19:53 -0700 (PDT) Received: from daehojeong-desktop.mtv.corp.google.com ([2a00:79e0:2e14:7:ed56:14c3:db02:6c66]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2db04988470sm5016840a91.54.2024.09.09.15.19.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 15:19:53 -0700 (PDT) From: Daeho Jeong To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com Date: Mon, 9 Sep 2024 15:19:42 -0700 Message-ID: <20240909221946.2004046-3-daeho43@gmail.com> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240909221946.2004046-1-daeho43@gmail.com> References: <20240909221946.2004046-1-daeho43@gmail.com> MIME-Version: 1.0 X-Headers-End: 1snmjs-0006gS-Dj Subject: [f2fs-dev] [PATCH v2 3/7] f2fs: add reserved_segments sysfs node 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: , Cc: Daeho Jeong Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net From: Daeho Jeong For the fine tuning of GC behavior, add reserved_segments sysfs node. Signed-off-by: Daeho Jeong Reviewed-by: Chao Yu --- Documentation/ABI/testing/sysfs-fs-f2fs | 6 ++++++ fs/f2fs/sysfs.c | 2 ++ 2 files changed, 8 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs index 9165f617d216..deff703035e1 100644 --- a/Documentation/ABI/testing/sysfs-fs-f2fs +++ b/Documentation/ABI/testing/sysfs-fs-f2fs @@ -771,3 +771,9 @@ Description: Controls migration window granularity of garbage collection on larg section. it can control the scanning window granularity for GC migration in a unit of segment, while migration_granularity controls the number of segments which can be migrated at the same turn. + +What: /sys/fs/f2fs//reserved_segments +Date: September 2024 +Contact: "Daeho Jeong" +Description: In order to fine tune GC behavior, we can control the number of + reserved segments. diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index 66d15609d5ad..761d1abd46a8 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -974,6 +974,7 @@ SM_INFO_GENERAL_RW_ATTR(min_fsync_blocks); SM_INFO_GENERAL_RW_ATTR(min_seq_blocks); SM_INFO_GENERAL_RW_ATTR(min_hot_blocks); SM_INFO_GENERAL_RW_ATTR(min_ssr_sections); +SM_INFO_GENERAL_RW_ATTR(reserved_segments); /* DCC_INFO ATTR */ DCC_INFO_RW_ATTR(max_small_discards, max_discards); @@ -1144,6 +1145,7 @@ static struct attribute *f2fs_attrs[] = { ATTR_LIST(min_seq_blocks), ATTR_LIST(min_hot_blocks), ATTR_LIST(min_ssr_sections), + ATTR_LIST(reserved_segments), ATTR_LIST(max_victim_search), ATTR_LIST(migration_granularity), ATTR_LIST(migration_window_granularity), From patchwork Mon Sep 9 22:19:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daeho Jeong X-Patchwork-Id: 13797642 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 12E76ECE58C for ; Mon, 9 Sep 2024 22:20:13 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1snmk0-0005xK-7y; Mon, 09 Sep 2024 22:20:12 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1snmjx-0005wc-Pn for linux-f2fs-devel@lists.sourceforge.net; Mon, 09 Sep 2024 22:20:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=OACeXNWxgnQWjl/GPxHOu7e05WAZ024o5ed3CF2Sd1M=; b=H/zOhoReMycQ+q12eN21YsPVSF OQGKu7yYsX+8c4B1t9NLgNPS7Wkb542Dw0gqtUNis0eduQhD3sDMmTaGR1/8ne7b+DZLml9w635vK G/2luY+hvRoVg7SEMuLYwfwq7tzVtYRIPRumG7JrvbOasgc6R/47fqroJfrr7Ui+4JFw=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=OACeXNWxgnQWjl/GPxHOu7e05WAZ024o5ed3CF2Sd1M=; b=bHizEnA5X6uS+asp9LrbKjTqoz wHCXb9eB+QQKGNDz+eRsKYOZQ489+ZvdPLAWe/iSShY/ymACj3fS6HgOhplhdShS9XCjZoryLDodj Bd1HYmc8N/oorwGLaPy6qG4eCKfGNR0E6HmcT1SLwKTqxFD9vqGGXpuWZMycQLkeSpEQ=; Received: from mail-pj1-f53.google.com ([209.85.216.53]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1snmju-0006gW-12 for linux-f2fs-devel@lists.sourceforge.net; Mon, 09 Sep 2024 22:20:06 +0000 Received: by mail-pj1-f53.google.com with SMTP id 98e67ed59e1d1-2d88690837eso32556a91.2 for ; Mon, 09 Sep 2024 15:20:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725920395; x=1726525195; darn=lists.sourceforge.net; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=OACeXNWxgnQWjl/GPxHOu7e05WAZ024o5ed3CF2Sd1M=; b=DcOjRaNsAAobNvDPQDkvL1zPi+Fv+gvbcHGIQ8XIxnVqwI98D8Pwl0pj42Rtmsy7NK yilMCCxTdNqOtnKST4Ip9EXSKr0i/YtThRRPskk2fMERx2zd8Gj+QfWiF12WkvaddCdo VOfDs8rCFF8CxKLjThvejf18+YstecqnEzwaWlO9OeQbPIsy/wwMgaMmKDBvd3OwNGMv zTTdAY9jKVSfixw1Kd7xD1cOCSNX1B5cJjo5bzM9ubNcFlXsmlGjzmJQ1RpTT07mQm4J /sFzm2cpei5xdEt5Oh31BvLvJ2Q4gQigYGGfE3FqUuGL2UCyUWC1CblkXRWYheGZdlSj ETxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725920395; x=1726525195; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=OACeXNWxgnQWjl/GPxHOu7e05WAZ024o5ed3CF2Sd1M=; b=Bp0SGQtxMwuyyuKPA+6SzcL1wBZdGgU6C3mKJ7H9m82oTpXqRZtUO7BewKuHFKgkT7 Hfp8SHKKgrymjKPsMYWj/c97LNnlqPv5z/xmeWWrkNijS5G6NFSRbId/mc2hjRepvtC3 LBQRvaTwxnieSfknvnrQqYndxtiCfQhKhzM7jQxHRN0P2Xxu1rgEAtQ56mpiF/M9VkN8 xPT079+S+yJaWfDB/2lm9R1G7HbZZOVxFu56Z30zfJBv5tIgFHWboH4zSyuGDmPh3VST djaWTDwtqEH/4cSPFqIraIX3JNfl86LraRB5gw2nmqdvFFFwY+jR6ioEWyJUMjWeYph6 gC/w== X-Forwarded-Encrypted: i=1; AJvYcCXV9l8G1bFeXqv9RQjum9NcgZIaMp3A8aNFadSbu7clyqnl2dNOyhekkkPCdtL9ADcjHtdJS17BsfUHKphz7u7o@lists.sourceforge.net X-Gm-Message-State: AOJu0Yxa/3HJMtfsrqPJ7+42+aUo21cmSiTvWrID5gk0gNF4p6A08+Hr dXFT0f63q6LNZdyUU9+61K5U2Hag5u5Rj1LUcn9qWMjUC6S8kjE+ X-Google-Smtp-Source: AGHT+IFiVrAHTyaAA3aagaI8EUCRG30d1RLs1T2oXVIq2zT/RwpjuVnxkZL2lJMP2ePV+f8MLzLbIQ== X-Received: by 2002:a17:90a:d48a:b0:2d3:c638:ec67 with SMTP id 98e67ed59e1d1-2dad4bab1acmr12586878a91.0.1725920395010; Mon, 09 Sep 2024 15:19:55 -0700 (PDT) Received: from daehojeong-desktop.mtv.corp.google.com ([2a00:79e0:2e14:7:ed56:14c3:db02:6c66]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2db04988470sm5016840a91.54.2024.09.09.15.19.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 15:19:54 -0700 (PDT) From: Daeho Jeong To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com Date: Mon, 9 Sep 2024 15:19:43 -0700 Message-ID: <20240909221946.2004046-4-daeho43@gmail.com> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240909221946.2004046-1-daeho43@gmail.com> References: <20240909221946.2004046-1-daeho43@gmail.com> MIME-Version: 1.0 X-Headers-End: 1snmju-0006gW-12 Subject: [f2fs-dev] [PATCH v2 4/7] f2fs: increase BG GC migration window granularity when boosted for zoned devices 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: , Cc: Daeho Jeong Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net From: Daeho Jeong Need bigger BG GC migration window granularity when free section is running low. Signed-off-by: Daeho Jeong Reviewed-by: Chao Yu --- fs/f2fs/gc.c | 12 ++++++++++-- fs/f2fs/gc.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 5cd316d2102d..9a3d3994cf2b 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -1728,10 +1728,18 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi, sec_end_segno -= SEGS_PER_SEC(sbi) - f2fs_usable_segs_in_sec(sbi, segno); - if (gc_type == BG_GC) - end_segno = start_segno + + if (gc_type == BG_GC) { + unsigned int window_granularity = sbi->migration_window_granularity; + if (f2fs_sb_has_blkzoned(sbi) && + !has_enough_free_blocks(sbi, + LIMIT_BOOST_ZONED_GC)) + window_granularity *= BOOST_GC_MULTIPLE; + + end_segno = start_segno + window_granularity; + } + if (end_segno > sec_end_segno) end_segno = sec_end_segno; } diff --git a/fs/f2fs/gc.h b/fs/f2fs/gc.h index 245f93663745..78abeebd68b5 100644 --- a/fs/f2fs/gc.h +++ b/fs/f2fs/gc.h @@ -33,6 +33,7 @@ #define LIMIT_NO_ZONED_GC 60 /* percentage over total user space of no gc for zoned devices */ #define LIMIT_BOOST_ZONED_GC 25 /* percentage over total user space of boosted gc for zoned devices */ #define DEF_MIGRATION_WINDOW_GRANULARITY_ZONED 3 +#define BOOST_GC_MULTIPLE 5 #define DEF_GC_FAILED_PINNED_FILES 2048 #define MAX_GC_FAILED_PINNED_FILES USHRT_MAX From patchwork Mon Sep 9 22:19:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daeho Jeong X-Patchwork-Id: 13797641 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 16022ECE58D for ; Mon, 9 Sep 2024 22:20:13 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1snmjy-0005wv-Pl; Mon, 09 Sep 2024 22:20:10 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1snmjq-0005wK-Lh for linux-f2fs-devel@lists.sourceforge.net; Mon, 09 Sep 2024 22:20:02 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=m4K3+hj6aGpbXAqhJlIDqPuZ5OSvQ2hWwcmdr3buziA=; b=LrGS6i2xgogDdyUvimSpckGsA9 V+igbdCQEkbvHaFKG1Nh3kDfqwjP4jmxpN7lvB+DkZ0f7k60XVt2TtJPZ8zkSANlzKwUadkQMqNAl eDLoMTlBYecAIuVo0ur1kjmxaH5ahxACKobdvs7HpTI2LgmPSNyvLRx1mir0iAG3gEi8=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=m4K3+hj6aGpbXAqhJlIDqPuZ5OSvQ2hWwcmdr3buziA=; b=BLAknr8ak/d+9gbYWNlnAo5jYF OiXpkSWv5EuXtf5X3ETKjqaEk3kI5MrkFIKJDYIvcmpjylx23YICDn41IGcX3a4YM6sb3bS68GhiG +gMT8DJ8q8VCEol0XoPSQnFfYTpnnI72jZsFFhVbOg0N4l3JfCZ7wrXCxaJUd5uxV1lc=; Received: from mail-pj1-f43.google.com ([209.85.216.43]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1snmjp-0006gL-Qw for linux-f2fs-devel@lists.sourceforge.net; Mon, 09 Sep 2024 22:20:02 +0000 Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-2d877e9054eso3277780a91.3 for ; Mon, 09 Sep 2024 15:20:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725920396; x=1726525196; darn=lists.sourceforge.net; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=m4K3+hj6aGpbXAqhJlIDqPuZ5OSvQ2hWwcmdr3buziA=; b=C3t28zQpxeyk19N/hIsPwvMTm/mQFlU4VjSoURyubphyjR36HMZvVrwhaDF70Fo2eV xVnnJ6vpQ+h3PGle5K+EoL6leKunteBkay1GjEHMlchwCWK7dbq1VLUbJ05XdUy+hd3b 3vTX6USl/fRSoVBmTzRLNm4qjSGBgFruB74nC2A2bNwfY7yRUQjpz6L8eTfHqgyEuLO6 bw8/rgCeMbFua4L0rNZO3zBJQOPpSYM9zXfWx6HBgyqapl+Wa/dm+gHyGs2UGoV3yOC3 IukNjzH37GzFWfY3OJKq2EsxiODAKpXw3jRn+0o/nE+linSd/IRDAGw2fSBw/TOaB0s1 X/rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725920396; x=1726525196; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=m4K3+hj6aGpbXAqhJlIDqPuZ5OSvQ2hWwcmdr3buziA=; b=M1IVwesA40who/CS+u8mMR5yAzDynQ6s8upfGPGs6wXXRey4/3WJeMVzxpqlR/65ka F0ua51aHv9+Eo30fybwQQlYJUkZvEM0PC99tyPAtWrEo/o0P16hw+HMfg0e4tJD34Wny gwq2t3szn7UIHX31F1rqmEfPG0cUsBnSD00f6I848cmaGBb6i39pKmTnFfpW9iZomRqz j854wOx0+gxXv+TU1tRpkur+4GnhJDmHvtWLwel7fb2W7lOSMP1KIxr900t7te9eDmTq 0DPYAJKIEThDC7wUjQ927vKlybdMgR4XHZWBmWtSwS7fbT1wHEaM2ovHeS2VchkYeDJ/ dEmQ== X-Forwarded-Encrypted: i=1; AJvYcCWSoAacd7cvxa/SK8HzsfdxEILH3HdLlJnO3qD3k70E3W1Sn30TCIAoElX2ajUCm2PdtupeobBPX0kZXH2OldQS@lists.sourceforge.net X-Gm-Message-State: AOJu0YzTEGxvDXXM2pjlITg824/U0EL/hrnXrYM7iHWRlWDKHL8lBQtj tmeWeoEuwX/ZKBouL816bPgVkdbc9NgEn6oC9byCqTj6VMTbsBAu X-Google-Smtp-Source: AGHT+IGkmDIg9KV3CCSmtY+SzcDsmrRyyyiLqHx8z9OM9jAnq0cDAY0hqnch/xtkfI29tRAs6tMX+A== X-Received: by 2002:a17:90b:3846:b0:2da:89ac:75b9 with SMTP id 98e67ed59e1d1-2daffa7fcaamr11312122a91.11.1725920395881; Mon, 09 Sep 2024 15:19:55 -0700 (PDT) Received: from daehojeong-desktop.mtv.corp.google.com ([2a00:79e0:2e14:7:ed56:14c3:db02:6c66]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2db04988470sm5016840a91.54.2024.09.09.15.19.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 15:19:55 -0700 (PDT) From: Daeho Jeong To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com Date: Mon, 9 Sep 2024 15:19:44 -0700 Message-ID: <20240909221946.2004046-5-daeho43@gmail.com> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240909221946.2004046-1-daeho43@gmail.com> References: <20240909221946.2004046-1-daeho43@gmail.com> MIME-Version: 1.0 X-Headers-End: 1snmjp-0006gL-Qw Subject: [f2fs-dev] [PATCH v2 5/7] f2fs: do FG_GC when GC boosting is required for zoned devices 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: , Cc: Daeho Jeong Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net From: Daeho Jeong Under low free section count, we need to use FG_GC instead of BG_GC to recover free sections. Signed-off-by: Daeho Jeong Reviewed-by: Chao Yu --- v2: moved up the one_time field for better padding. --- fs/f2fs/f2fs.h | 1 + fs/f2fs/gc.c | 24 +++++++++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index a00e01e66e08..62880fbb9e20 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -1293,6 +1293,7 @@ struct f2fs_gc_control { bool no_bg_gc; /* check the space and stop bg_gc */ bool should_migrate_blocks; /* should migrate blocks */ bool err_gc_skipped; /* return EAGAIN if GC skipped */ + bool one_time; /* require one time GC in one migration unit */ unsigned int nr_free_secs; /* # of free sections to do GC */ }; diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 9a3d3994cf2b..a59fec64eccf 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -81,6 +81,8 @@ static int gc_thread_func(void *data) continue; } + gc_control.one_time = false; + /* * [GC triggering condition] * 0. GC is not conducted currently. @@ -126,15 +128,19 @@ static int gc_thread_func(void *data) wait_ms = gc_th->max_sleep_time; } - if (need_to_boost_gc(sbi)) + if (need_to_boost_gc(sbi)) { decrease_sleep_time(gc_th, &wait_ms); - else + if (f2fs_sb_has_blkzoned(sbi)) + gc_control.one_time = true; + } else { increase_sleep_time(gc_th, &wait_ms); + } do_gc: stat_inc_gc_call_count(sbi, foreground ? FOREGROUND : BACKGROUND); - sync_mode = F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_SYNC; + sync_mode = (F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_SYNC) || + gc_control.one_time; /* foreground GC was been triggered via f2fs_balance_fs() */ if (foreground) @@ -1701,7 +1707,7 @@ static int __get_victim(struct f2fs_sb_info *sbi, unsigned int *victim, static int do_garbage_collect(struct f2fs_sb_info *sbi, unsigned int start_segno, struct gc_inode_list *gc_list, int gc_type, - bool force_migrate) + bool force_migrate, bool one_time) { struct page *sum_page; struct f2fs_summary_block *sum; @@ -1728,7 +1734,7 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi, sec_end_segno -= SEGS_PER_SEC(sbi) - f2fs_usable_segs_in_sec(sbi, segno); - if (gc_type == BG_GC) { + if (gc_type == BG_GC || one_time) { unsigned int window_granularity = sbi->migration_window_granularity; @@ -1911,7 +1917,8 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control) } seg_freed = do_garbage_collect(sbi, segno, &gc_list, gc_type, - gc_control->should_migrate_blocks); + gc_control->should_migrate_blocks, + gc_control->one_time); if (seg_freed < 0) goto stop; @@ -1922,6 +1929,9 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control) total_sec_freed++; } + if (gc_control->one_time) + goto stop; + if (gc_type == FG_GC) { sbi->cur_victim_sec = NULL_SEGNO; @@ -2047,7 +2057,7 @@ int f2fs_gc_range(struct f2fs_sb_info *sbi, }; do_garbage_collect(sbi, segno, &gc_list, FG_GC, - dry_run_sections == 0); + dry_run_sections == 0, false); put_gc_inode(&gc_list); if (!dry_run && get_valid_blocks(sbi, segno, true)) From patchwork Mon Sep 9 22:19:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daeho Jeong X-Patchwork-Id: 13797644 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 AEA4AECE57E for ; Mon, 9 Sep 2024 22:20:13 +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 1snmk1-0004s5-RB; Mon, 09 Sep 2024 22:20:13 +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 1snmjy-0004rq-DA for linux-f2fs-devel@lists.sourceforge.net; Mon, 09 Sep 2024 22:20:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=cla/Hu+x6KHpSAchLiy/oR8hbHuRD9DRfoz1PxleRLw=; b=l6Gx0gZrAcj0i8U54R3a+VRMMu 0nIo7gewC0lmR71P/XKJZZO9R2uu/Lbyp0NyqBrps0exI5LDI9nvvWCTarLw4eu0IoJNdirZ0kVJf 7WVgordOmxlrNnwquYZ1GaHfopkPtrECj+ZFuAwNZMOff/ZvqZj5ELMD+V6A8Ki7yPis=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=cla/Hu+x6KHpSAchLiy/oR8hbHuRD9DRfoz1PxleRLw=; b=P1Ue6z283wROSEqXx74SX3ed9k thmbJ94Djo400jI1oMnmBJv3aq49paFFsJfKC2xvYF6M3Ikgms3Uj7hRCTLwmAaOPIAmVfguE9Xd4 WlKQ7zxVXp52pXInbO93MttDUJIFyJqQHtueYXhwwWIp7vmQFTrdMX2Is1ySY9zD2Nro=; Received: from mail-pj1-f45.google.com ([209.85.216.45]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1snmjv-0006gp-Ds for linux-f2fs-devel@lists.sourceforge.net; Mon, 09 Sep 2024 22:20:08 +0000 Received: by mail-pj1-f45.google.com with SMTP id 98e67ed59e1d1-2d88c0f8e79so3807203a91.3 for ; Mon, 09 Sep 2024 15:20:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725920397; x=1726525197; darn=lists.sourceforge.net; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cla/Hu+x6KHpSAchLiy/oR8hbHuRD9DRfoz1PxleRLw=; b=FKuRfkmpTSF/cHzdhmjs7nulSsaGvSnc7zoyKs/6YGfdMd7IWrPvrN3exzPBYsn5Q3 Xl/P7dmAoL8G6MLzj2rKfU8bVxDIqeY988TRcP7SoPUr/SBJZoRpcnR82KSiBpByQZ9H /PjpsHCLBc9ez8edoNSCT+lc2gQgpL5j0esluTez/Ma25QA25N37oXtKBz5YioCuc4Dm X+BAKHLQlHGNw4qT0jwUbII0GfaBcUZlIP9yT6Tq7BDBKDe5mFXtFsevoXcVZzdZQ27V YWVNMBjUlPtCjNIpLIjLlAt2H6nrbpd99N45k15udDixydWg3z1Om44Br3vEocULSRJW fFtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725920397; x=1726525197; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cla/Hu+x6KHpSAchLiy/oR8hbHuRD9DRfoz1PxleRLw=; b=l3B49OvYDXbWjW8toxJ3TatyZZJ+zXSPwatLYazcx6cGtWR0W0DEKGA7aczC9++u30 rfxDUaUnYkS0oZxfV348Y8qCt5vCu2Wx6BXA3VWuPx4Q0K+V9LW6nBxBa/jLxP1LyejZ +IactX53jDNaawcy2wUihPkuWr2RkcPliRblkYYrg8OETqNY9JF5pzx+rPVSlbT6uCJB 6F6/uzd4geQtpJTNXobG8rnpjAFQ7VJMzA4lhiqCJLEHyTBTRpS+0VJxLz9TAMiLOIvB wqrqlmJoawdKk6AmqUoaG2UdMlBIMijL8bGNA1uHxRsURapKLno/GewYeeX9ZzQQHpN1 c1Cg== X-Forwarded-Encrypted: i=1; AJvYcCVQ3a4ctE8TNyAqkua4d6ClW+RbN/T4vwcOnwDmVTMogsFfd3XStzjH2AhpUrEUn+39KoSKct3By4xsPzG3et5j@lists.sourceforge.net X-Gm-Message-State: AOJu0YwfZGwiR7dhVU0FBHdNW19QXKBIIgcawxHtM5WDS0Z9+EpkDjUo BrB2o+caIWOpkkb/l9RYCUUDOLIORr40bLuebTqITdvEvemAnIUjBw75Rg== X-Google-Smtp-Source: AGHT+IGfEphEYe8iguFpalf0M6+gnZinIeoQ6xP0sK1afOnwfJgv0XG/DI5+vE4JW3HwyJDIpFiDKw== X-Received: by 2002:a17:90b:3c43:b0:2da:5156:1253 with SMTP id 98e67ed59e1d1-2dad50141cbmr2814276a91.21.1725920396721; Mon, 09 Sep 2024 15:19:56 -0700 (PDT) Received: from daehojeong-desktop.mtv.corp.google.com ([2a00:79e0:2e14:7:ed56:14c3:db02:6c66]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2db04988470sm5016840a91.54.2024.09.09.15.19.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 15:19:56 -0700 (PDT) From: Daeho Jeong To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com Date: Mon, 9 Sep 2024 15:19:45 -0700 Message-ID: <20240909221946.2004046-6-daeho43@gmail.com> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240909221946.2004046-1-daeho43@gmail.com> References: <20240909221946.2004046-1-daeho43@gmail.com> MIME-Version: 1.0 X-Headers-End: 1snmjv-0006gp-Ds Subject: [f2fs-dev] [PATCH v2 6/7] f2fs: create gc_no_zoned_gc_percent and gc_boost_zoned_gc_percent 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: , Cc: Daeho Jeong Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net From: Daeho Jeong Added control knobs for gc_no_zoned_gc_percent and gc_boost_zoned_gc_percent. Signed-off-by: Daeho Jeong Reviewed-by: Chao Yu --- Documentation/ABI/testing/sysfs-fs-f2fs | 14 ++++++++++++++ fs/f2fs/gc.c | 12 +++++++++--- fs/f2fs/gc.h | 4 ++++ fs/f2fs/sysfs.c | 4 ++++ 4 files changed, 31 insertions(+), 3 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs index deff703035e1..f3c533b523cd 100644 --- a/Documentation/ABI/testing/sysfs-fs-f2fs +++ b/Documentation/ABI/testing/sysfs-fs-f2fs @@ -777,3 +777,17 @@ Date: September 2024 Contact: "Daeho Jeong" Description: In order to fine tune GC behavior, we can control the number of reserved segments. + +What: /sys/fs/f2fs//gc_no_zoned_gc_percent +Date: September 2024 +Contact: "Daeho Jeong" +Description: If the percentage of free sections over total sections is above this + number, F2FS do not garbage collection for zoned devices through the + background GC thread. the default number is "60". + +What: /sys/fs/f2fs//gc_boost_zoned_gc_percent +Date: September 2024 +Contact: "Daeho Jeong" +Description: If the percentage of free sections over total sections is under this + number, F2FS boosts garbage collection for zoned devices through the + background GC thread. the default number is "25". diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index a59fec64eccf..319b4b80ba72 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -119,7 +119,8 @@ static int gc_thread_func(void *data) } if (f2fs_sb_has_blkzoned(sbi)) { - if (has_enough_free_blocks(sbi, LIMIT_NO_ZONED_GC)) { + if (has_enough_free_blocks(sbi, + gc_th->no_zoned_gc_percent)) { wait_ms = gc_th->no_gc_sleep_time; f2fs_up_write(&sbi->gc_lock); goto next; @@ -200,10 +201,14 @@ int f2fs_start_gc_thread(struct f2fs_sb_info *sbi) gc_th->min_sleep_time = DEF_GC_THREAD_MIN_SLEEP_TIME_ZONED; gc_th->max_sleep_time = DEF_GC_THREAD_MAX_SLEEP_TIME_ZONED; gc_th->no_gc_sleep_time = DEF_GC_THREAD_NOGC_SLEEP_TIME_ZONED; + gc_th->no_zoned_gc_percent = LIMIT_NO_ZONED_GC; + gc_th->boost_zoned_gc_percent = LIMIT_BOOST_ZONED_GC; } else { gc_th->min_sleep_time = DEF_GC_THREAD_MIN_SLEEP_TIME; gc_th->max_sleep_time = DEF_GC_THREAD_MAX_SLEEP_TIME; gc_th->no_gc_sleep_time = DEF_GC_THREAD_NOGC_SLEEP_TIME; + gc_th->no_zoned_gc_percent = 0; + gc_th->boost_zoned_gc_percent = 0; } gc_th->gc_wake = false; @@ -1740,8 +1745,9 @@ static int do_garbage_collect(struct f2fs_sb_info *sbi, if (f2fs_sb_has_blkzoned(sbi) && !has_enough_free_blocks(sbi, - LIMIT_BOOST_ZONED_GC)) - window_granularity *= BOOST_GC_MULTIPLE; + sbi->gc_thread->boost_zoned_gc_percent)) + window_granularity *= + BOOST_GC_MULTIPLE; end_segno = start_segno + window_granularity; } diff --git a/fs/f2fs/gc.h b/fs/f2fs/gc.h index 78abeebd68b5..c063310c8dde 100644 --- a/fs/f2fs/gc.h +++ b/fs/f2fs/gc.h @@ -61,6 +61,10 @@ struct f2fs_gc_kthread { * caller of f2fs_balance_fs() * will wait on this wait queue. */ + + /* for gc control for zoned devices */ + unsigned int no_zoned_gc_percent; + unsigned int boost_zoned_gc_percent; }; struct gc_inode_list { diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index 761d1abd46a8..60693ec39a03 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -965,6 +965,8 @@ GC_THREAD_RW_ATTR(gc_urgent_sleep_time, urgent_sleep_time); GC_THREAD_RW_ATTR(gc_min_sleep_time, min_sleep_time); GC_THREAD_RW_ATTR(gc_max_sleep_time, max_sleep_time); GC_THREAD_RW_ATTR(gc_no_gc_sleep_time, no_gc_sleep_time); +GC_THREAD_RW_ATTR(gc_no_zoned_gc_percent, no_zoned_gc_percent); +GC_THREAD_RW_ATTR(gc_boost_zoned_gc_percent, boost_zoned_gc_percent); /* SM_INFO ATTR */ SM_INFO_RW_ATTR(reclaim_segments, rec_prefree_segments); @@ -1123,6 +1125,8 @@ static struct attribute *f2fs_attrs[] = { ATTR_LIST(gc_min_sleep_time), ATTR_LIST(gc_max_sleep_time), ATTR_LIST(gc_no_gc_sleep_time), + ATTR_LIST(gc_no_zoned_gc_percent), + ATTR_LIST(gc_boost_zoned_gc_percent), ATTR_LIST(gc_idle), ATTR_LIST(gc_urgent), ATTR_LIST(reclaim_segments), From patchwork Mon Sep 9 22:19:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daeho Jeong X-Patchwork-Id: 13797645 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 DBEA1ECE58D for ; Mon, 9 Sep 2024 22:20:15 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-4.v29.lw.sourceforge.com) by sfs-ml-4.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1snmk3-0000kP-IP; Mon, 09 Sep 2024 22:20:15 +0000 Received: from [172.30.29.66] (helo=mx.sourceforge.net) by sfs-ml-4.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1snmjx-0000k1-QN for linux-f2fs-devel@lists.sourceforge.net; Mon, 09 Sep 2024 22:20:09 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=vQJ/nGsQ4DEh1vdP8K9rNtdn0Y5Ouc5JbFoWYWKuiIg=; b=OA3eeDf8XGsTNNEYLpAfRW0x5V L+mJgOuVETG6/ux7k3bssbFMsK+GHJ/lvmDDaZwQlYM8GKgdupgly6bSge8RLpSCR9/GOicf30axs lHjoz/34WUzh+mO3Tv9w55oOzNVPbq+Zs45ph05OnJhdE4gE1uGSP3f7pOBl0RYHTAv8=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=vQJ/nGsQ4DEh1vdP8K9rNtdn0Y5Ouc5JbFoWYWKuiIg=; b=C4ud15BX0crNKAtpYBXffqgtKo ZE4j9ho8ZRrpHi9xq12zdnQV1g43RoUFmQWfF9KS1BUz71BZgqjM9/87ASiEYqWYaX+hMhWJW5WB3 jFSfh/3pLZL366YdksyWWkoBb49LXv/iH9ZQOQPWxt/oQel8K2fIaMaKW1HBcxOXDtU4=; Received: from mail-pj1-f43.google.com ([209.85.216.43]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.95) id 1snmjr-0006gQ-L2 for linux-f2fs-devel@lists.sourceforge.net; Mon, 09 Sep 2024 22:20:04 +0000 Received: by mail-pj1-f43.google.com with SMTP id 98e67ed59e1d1-2d87196ec9fso3144816a91.1 for ; Mon, 09 Sep 2024 15:20:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1725920398; x=1726525198; darn=lists.sourceforge.net; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vQJ/nGsQ4DEh1vdP8K9rNtdn0Y5Ouc5JbFoWYWKuiIg=; b=g1wJqfZsUexypoXlOPEndYxH144hki3IXvnaLImj4FTmmbgdLG8JqaKm2oc2GwhYk7 bnaEd90abxXPK7zYXoc4cedwUyIS5vzcVARaxnxAjTy95JoomYV1131rQ4rQ4IgqUlO2 JuEyX5YofcI2+pZZBjyfp3QwPsRLdMpfZK1vNLvSRP5FZ2Mz9rLpdrxaDotXjKzBaUrR 9zKSbwF2MeqX9h+yvi6nxIRFhwUaro4j1ZKQjxE7QVd0gnn8/nKxuctp09lBs979fXGg lusYk8+hlGlwZpBu/v1yqUIOnjT389/Qi0FhwAtYPTd58LRJL1s8xEDWxm95+KU16CPq R+DA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1725920398; x=1726525198; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vQJ/nGsQ4DEh1vdP8K9rNtdn0Y5Ouc5JbFoWYWKuiIg=; b=wS8ID7dK99k4snyimjbpncKUIQEqCYxfIzI+q8OBfZlsEcKd9XHukH8l23zHKrWAqp JMN9AuLfxaHtkV5rY8naHYXhiQCVqMl5PAsxNvDrJ0gc1pmoxSZ8Ya5IAqN/j8z4bQKZ OS9uP7WmMz2qRrPEHLYYVDG4nrESM/YvWPQBAEugPi/rurwZ7JNvZsr7owEcVy5AAkeD 9aXyCzwsj+dw9oEOx4KTzt3jME6NFUbnKe87InsJGCBdPjR5YlR8/2x0D+zovq7FKcaG LEA0cVrPSLzKFaWbyDJU07GRYOrEfaK4rBYVot7WGo7xbDHeQAWgVCqou2k1g9DzulMd zxDw== X-Forwarded-Encrypted: i=1; AJvYcCWjE2HkDZd3HaXSfhr2TEpG68ojl0lBNg2UnlaocGYRlho/n6RZn0hpOag2SyKR2GowjL/u7HNHNPaJEYcKNPl0@lists.sourceforge.net X-Gm-Message-State: AOJu0YwX0qtQN9IaMIVwtMR/eBMmkoYn1GSQmLFYl9Z/TwuzvZt00Yd4 TnVcFVucjGMgwZndPs4llX8VYYmXFrQNpJrJPIejFmHBNPGRn4Lt X-Google-Smtp-Source: AGHT+IHVPTHzH7+XMEkQw48bj2F5rk5bRhOLsm40meb4RM6lVxu1iirHvVJM165fPzUtiQ5uQiQbUw== X-Received: by 2002:a17:90b:4a88:b0:2d3:c05c:c51 with SMTP id 98e67ed59e1d1-2dad4b9af79mr12449301a91.0.1725920397740; Mon, 09 Sep 2024 15:19:57 -0700 (PDT) Received: from daehojeong-desktop.mtv.corp.google.com ([2a00:79e0:2e14:7:ed56:14c3:db02:6c66]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2db04988470sm5016840a91.54.2024.09.09.15.19.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Sep 2024 15:19:57 -0700 (PDT) From: Daeho Jeong To: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com Date: Mon, 9 Sep 2024 15:19:46 -0700 Message-ID: <20240909221946.2004046-7-daeho43@gmail.com> X-Mailer: git-send-email 2.46.0.598.g6f2099f65c-goog In-Reply-To: <20240909221946.2004046-1-daeho43@gmail.com> References: <20240909221946.2004046-1-daeho43@gmail.com> MIME-Version: 1.0 X-Headers-End: 1snmjr-0006gQ-L2 Subject: [f2fs-dev] [PATCH v2 7/7] f2fs: add valid block ratio not to do excessive GC for one time GC 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: , Cc: Daeho Jeong Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net From: Daeho Jeong We need to introduce a valid block ratio threshold not to trigger excessive GC for zoned deivces. The initial value of it is 95%. So, F2FS will stop the thread from intiating GC for sections having valid blocks exceeding the ratio. Signed-off-by: Daeho Jeong Reviewed-by: Chao Yu --- v2: use CAP_BLKS_PER_SEC instead of BLKS_PER_SEC --- Documentation/ABI/testing/sysfs-fs-f2fs | 8 ++++++++ fs/f2fs/f2fs.h | 2 +- fs/f2fs/gc.c | 16 ++++++++++++---- fs/f2fs/gc.h | 2 ++ fs/f2fs/segment.c | 6 ++++-- fs/f2fs/segment.h | 1 + fs/f2fs/sysfs.c | 2 ++ 7 files changed, 30 insertions(+), 7 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs index f3c533b523cd..2fcb16ca10d3 100644 --- a/Documentation/ABI/testing/sysfs-fs-f2fs +++ b/Documentation/ABI/testing/sysfs-fs-f2fs @@ -791,3 +791,11 @@ Contact: "Daeho Jeong" Description: If the percentage of free sections over total sections is under this number, F2FS boosts garbage collection for zoned devices through the background GC thread. the default number is "25". + +What: /sys/fs/f2fs//gc_valid_thresh_ratio +Date: September 2024 +Contact: "Daeho Jeong" +Description: It controls the valid block ratio threshold not to trigger excessive GC + for zoned deivces. The initial value of it is 95(%). F2FS will stop the + background GC thread from intiating GC for sections having valid blocks + exceeding the ratio. diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h index 62880fbb9e20..2bfad046dc74 100644 --- a/fs/f2fs/f2fs.h +++ b/fs/f2fs/f2fs.h @@ -3920,7 +3920,7 @@ void f2fs_destroy_garbage_collection_cache(void); /* victim selection function for cleaning and SSR */ int f2fs_get_victim(struct f2fs_sb_info *sbi, unsigned int *result, int gc_type, int type, char alloc_mode, - unsigned long long age); + unsigned long long age, bool one_time); /* * recovery.c diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c index 319b4b80ba72..d3e3104c4492 100644 --- a/fs/f2fs/gc.c +++ b/fs/f2fs/gc.c @@ -196,6 +196,7 @@ int f2fs_start_gc_thread(struct f2fs_sb_info *sbi) return -ENOMEM; gc_th->urgent_sleep_time = DEF_GC_THREAD_URGENT_SLEEP_TIME; + gc_th->valid_thresh_ratio = DEF_GC_THREAD_VALID_THRESH_RATIO; if (f2fs_sb_has_blkzoned(sbi)) { gc_th->min_sleep_time = DEF_GC_THREAD_MIN_SLEEP_TIME_ZONED; @@ -396,6 +397,11 @@ static inline unsigned int get_gc_cost(struct f2fs_sb_info *sbi, if (p->alloc_mode == SSR) return get_seg_entry(sbi, segno)->ckpt_valid_blocks; + if (p->one_time_gc && (get_valid_blocks(sbi, segno, true) >= + CAP_BLKS_PER_SEC(sbi) * sbi->gc_thread->valid_thresh_ratio / + 100)) + return UINT_MAX; + /* alloc_mode == LFS */ if (p->gc_mode == GC_GREEDY) return get_valid_blocks(sbi, segno, true); @@ -770,7 +776,7 @@ static int f2fs_gc_pinned_control(struct inode *inode, int gc_type, */ int f2fs_get_victim(struct f2fs_sb_info *sbi, unsigned int *result, int gc_type, int type, char alloc_mode, - unsigned long long age) + unsigned long long age, bool one_time) { struct dirty_seglist_info *dirty_i = DIRTY_I(sbi); struct sit_info *sm = SIT_I(sbi); @@ -787,6 +793,7 @@ int f2fs_get_victim(struct f2fs_sb_info *sbi, unsigned int *result, p.alloc_mode = alloc_mode; p.age = age; p.age_threshold = sbi->am.age_threshold; + p.one_time_gc = one_time; retry: select_policy(sbi, gc_type, type, &p); @@ -1698,13 +1705,14 @@ static int gc_data_segment(struct f2fs_sb_info *sbi, struct f2fs_summary *sum, } static int __get_victim(struct f2fs_sb_info *sbi, unsigned int *victim, - int gc_type) + int gc_type, bool one_time) { struct sit_info *sit_i = SIT_I(sbi); int ret; down_write(&sit_i->sentry_lock); - ret = f2fs_get_victim(sbi, victim, gc_type, NO_CHECK_TYPE, LFS, 0); + ret = f2fs_get_victim(sbi, victim, gc_type, NO_CHECK_TYPE, + LFS, 0, one_time); up_write(&sit_i->sentry_lock); return ret; } @@ -1911,7 +1919,7 @@ int f2fs_gc(struct f2fs_sb_info *sbi, struct f2fs_gc_control *gc_control) goto stop; } retry: - ret = __get_victim(sbi, &segno, gc_type); + ret = __get_victim(sbi, &segno, gc_type, gc_control->one_time); if (ret) { /* allow to search victim from sections has pinned data */ if (ret == -ENODATA && gc_type == FG_GC && diff --git a/fs/f2fs/gc.h b/fs/f2fs/gc.h index c063310c8dde..2914b678bf8f 100644 --- a/fs/f2fs/gc.h +++ b/fs/f2fs/gc.h @@ -25,6 +25,7 @@ #define DEF_GC_THREAD_CANDIDATE_RATIO 20 /* select 20% oldest sections as candidates */ #define DEF_GC_THREAD_MAX_CANDIDATE_COUNT 10 /* select at most 10 sections as candidates */ #define DEF_GC_THREAD_AGE_WEIGHT 60 /* age weight */ +#define DEF_GC_THREAD_VALID_THRESH_RATIO 95 /* do not GC over 95% valid block ratio for one time GC */ #define DEFAULT_ACCURACY_CLASS 10000 /* accuracy class */ #define LIMIT_INVALID_BLOCK 40 /* percentage over total user space */ @@ -65,6 +66,7 @@ struct f2fs_gc_kthread { /* for gc control for zoned devices */ unsigned int no_zoned_gc_percent; unsigned int boost_zoned_gc_percent; + unsigned int valid_thresh_ratio; }; struct gc_inode_list { diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 78c3198a6308..26f5abc62461 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c @@ -3052,7 +3052,8 @@ static int get_ssr_segment(struct f2fs_sb_info *sbi, int type, sanity_check_seg_type(sbi, seg_type); /* f2fs_need_SSR() already forces to do this */ - if (!f2fs_get_victim(sbi, &segno, BG_GC, seg_type, alloc_mode, age)) { + if (!f2fs_get_victim(sbi, &segno, BG_GC, seg_type, + alloc_mode, age, false)) { curseg->next_segno = segno; return 1; } @@ -3079,7 +3080,8 @@ static int get_ssr_segment(struct f2fs_sb_info *sbi, int type, for (; cnt-- > 0; reversed ? i-- : i++) { if (i == seg_type) continue; - if (!f2fs_get_victim(sbi, &segno, BG_GC, i, alloc_mode, age)) { + if (!f2fs_get_victim(sbi, &segno, BG_GC, i, + alloc_mode, age, false)) { curseg->next_segno = segno; return 1; } diff --git a/fs/f2fs/segment.h b/fs/f2fs/segment.h index bfc01a521cb9..43db2d3e8c85 100644 --- a/fs/f2fs/segment.h +++ b/fs/f2fs/segment.h @@ -188,6 +188,7 @@ struct victim_sel_policy { unsigned int min_segno; /* segment # having min. cost */ unsigned long long age; /* mtime of GCed section*/ unsigned long long age_threshold;/* age threshold */ + bool one_time_gc; /* one time GC */ }; struct seg_entry { diff --git a/fs/f2fs/sysfs.c b/fs/f2fs/sysfs.c index 60693ec39a03..83e52f6061d0 100644 --- a/fs/f2fs/sysfs.c +++ b/fs/f2fs/sysfs.c @@ -967,6 +967,7 @@ GC_THREAD_RW_ATTR(gc_max_sleep_time, max_sleep_time); GC_THREAD_RW_ATTR(gc_no_gc_sleep_time, no_gc_sleep_time); GC_THREAD_RW_ATTR(gc_no_zoned_gc_percent, no_zoned_gc_percent); GC_THREAD_RW_ATTR(gc_boost_zoned_gc_percent, boost_zoned_gc_percent); +GC_THREAD_RW_ATTR(gc_valid_thresh_ratio, valid_thresh_ratio); /* SM_INFO ATTR */ SM_INFO_RW_ATTR(reclaim_segments, rec_prefree_segments); @@ -1127,6 +1128,7 @@ static struct attribute *f2fs_attrs[] = { ATTR_LIST(gc_no_gc_sleep_time), ATTR_LIST(gc_no_zoned_gc_percent), ATTR_LIST(gc_boost_zoned_gc_percent), + ATTR_LIST(gc_valid_thresh_ratio), ATTR_LIST(gc_idle), ATTR_LIST(gc_urgent), ATTR_LIST(reclaim_segments),