From: Chao Yu <chao@kernel.org>
To: Yangtao Li <frank.li@vivo.com>, jaegeuk@kernel.org
Cc: linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net
Subject: Re: [f2fs-dev] [PATCH] f2fs: introduce discard_urgent_util sysfs node
Date: Wed, 23 Nov 2022 23:32:23 +0800 [thread overview]
Message-ID: <3cc667aa-cff0-f2c8-84d0-995871f31d7d@kernel.org> (raw)
In-Reply-To: <20221117143509.58913-1-frank.li@vivo.com>
On 2022/11/17 22:35, Yangtao Li wrote:
> 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 <frank.li@vivo.com>
> ---
> 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" <frank.li@vivo.com>
> Description: Show the current gc_mode as a string.
> This is a read-only entry.
> +
> +What: /sys/fs/f2fs/<disk>/discard_urgent_util
> +Date: November 2022
> +Contact: "Yangtao Li" <frank.li@vivo.com>
> +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)
0 is allowed?
Thanks,
> + 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),
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
prev parent reply other threads:[~2022-11-23 15:32 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-17 14:35 [f2fs-dev] [PATCH] f2fs: introduce discard_urgent_util sysfs node Yangtao Li via Linux-f2fs-devel
2022-11-23 15:32 ` Chao Yu [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3cc667aa-cff0-f2c8-84d0-995871f31d7d@kernel.org \
--to=chao@kernel.org \
--cc=frank.li@vivo.com \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).