From: Daeho Jeong <daeho43@gmail.com>
To: linux-kernel@vger.kernel.org,
linux-f2fs-devel@lists.sourceforge.net, kernel-team@android.com
Cc: Daeho Jeong <daehojeong@google.com>, Yohan Joung <yohan.joung@sk.com>
Subject: [PATCH] f2fs: do not use granularity control for segment or section unit discard
Date: Thu, 20 Feb 2025 07:49:04 -0800 [thread overview]
Message-ID: <20250220154904.2698964-1-daeho43@gmail.com> (raw)
From: Daeho Jeong <daehojeong@google.com>
When we support segment or section unit discard, we should only focus on
how actively we submit discard commands for only one type of size, such
as segment or section. In this case, we don't have to manage smaller
sized discards.
Reported-by: Yohan Joung <yohan.joung@sk.com>
Signed-off-by: Daeho Jeong <daehojeong@google.com>
---
fs/f2fs/segment.c | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index c282e8a0a2ec..4316ff7aa0d1 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1661,12 +1661,20 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi,
f2fs_time_over(sbi, UMOUNT_DISCARD_TIMEOUT))
break;
- if (i + 1 < dpolicy->granularity)
- break;
+ /*
+ * Do not granularity control for segment or section
+ * unit discard, since we have only one type of discard length.
+ */
+ if (f2fs_block_unit_discard(sbi)) {
+ if (i + 1 < dpolicy->granularity)
+ break;
- if (i + 1 < dcc->max_ordered_discard && dpolicy->ordered) {
- __issue_discard_cmd_orderly(sbi, dpolicy, &issued);
- return issued;
+ if (i + 1 < dcc->max_ordered_discard &&
+ dpolicy->ordered) {
+ __issue_discard_cmd_orderly(sbi, dpolicy,
+ &issued);
+ return issued;
+ }
}
pend_list = &dcc->pend_list[i];
@@ -1701,6 +1709,13 @@ static int __issue_discard_cmd(struct f2fs_sb_info *sbi,
if (issued >= dpolicy->max_requests || io_interrupted)
break;
+
+ /*
+ * We only use the largest discard unit for segment or
+ * section unit discard.
+ */
+ if (!f2fs_block_unit_discard(sbi))
+ break;
}
if (dpolicy->type == DPOLICY_UMOUNT && issued) {
@@ -2320,10 +2335,6 @@ static int create_discard_cmd_control(struct f2fs_sb_info *sbi)
dcc->discard_granularity = DEFAULT_DISCARD_GRANULARITY;
dcc->max_ordered_discard = DEFAULT_MAX_ORDERED_DISCARD_GRANULARITY;
dcc->discard_io_aware = DPOLICY_IO_AWARE_ENABLE;
- if (F2FS_OPTION(sbi).discard_unit == DISCARD_UNIT_SEGMENT)
- dcc->discard_granularity = BLKS_PER_SEG(sbi);
- else if (F2FS_OPTION(sbi).discard_unit == DISCARD_UNIT_SECTION)
- dcc->discard_granularity = BLKS_PER_SEC(sbi);
INIT_LIST_HEAD(&dcc->entry_list);
for (i = 0; i < MAX_PLIST_NUM; i++)
--
2.48.1.601.g30ceb7b040-goog
next reply other threads:[~2025-02-20 15:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-20 15:49 Daeho Jeong [this message]
2025-02-21 2:19 ` [f2fs-dev] [PATCH] f2fs: do not use granularity control for segment or section unit discard Chao Yu
2025-02-21 15:54 ` Daeho Jeong
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=20250220154904.2698964-1-daeho43@gmail.com \
--to=daeho43@gmail.com \
--cc=daehojeong@google.com \
--cc=kernel-team@android.com \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=yohan.joung@sk.com \
/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