From: Chao Yu <chao@kernel.org>
To: jaegeuk@kernel.org
Cc: linux-f2fs-devel@lists.sourceforge.net,
linux-kernel@vger.kernel.org, Chao Yu <chao@kernel.org>
Subject: [PATCH] f2fs: make FAULT_DISCARD obsolete
Date: Mon, 15 Dec 2025 20:28:03 +0800 [thread overview]
Message-ID: <20251215122803.3495320-1-chao@kernel.org> (raw)
__blkdev_issue_discard() in __submit_discard_cmd() will never fail, so
let's make FAULT_DISCARD fault injection obsolete.
Signed-off-by: Chao Yu <chao@kernel.org>
---
Documentation/ABI/testing/sysfs-fs-f2fs | 2 +-
Documentation/filesystems/f2fs.rst | 2 +-
fs/f2fs/f2fs.h | 2 +-
fs/f2fs/segment.c | 18 +++---------------
4 files changed, 6 insertions(+), 18 deletions(-)
diff --git a/Documentation/ABI/testing/sysfs-fs-f2fs b/Documentation/ABI/testing/sysfs-fs-f2fs
index 770470e0598b..7920c233d8ec 100644
--- a/Documentation/ABI/testing/sysfs-fs-f2fs
+++ b/Documentation/ABI/testing/sysfs-fs-f2fs
@@ -732,7 +732,7 @@ Description: Support configuring fault injection type, should be
FAULT_TRUNCATE 0x00000400
FAULT_READ_IO 0x00000800
FAULT_CHECKPOINT 0x00001000
- FAULT_DISCARD 0x00002000
+ FAULT_DISCARD 0x00002000 (obsolete)
FAULT_WRITE_IO 0x00004000
FAULT_SLAB_ALLOC 0x00008000
FAULT_DQUOT_INIT 0x00010000
diff --git a/Documentation/filesystems/f2fs.rst b/Documentation/filesystems/f2fs.rst
index 9b3b835a174e..27aa4032c7cd 100644
--- a/Documentation/filesystems/f2fs.rst
+++ b/Documentation/filesystems/f2fs.rst
@@ -206,7 +206,7 @@ fault_type=%d Support configuring fault injection type, should be
FAULT_TRUNCATE 0x00000400
FAULT_READ_IO 0x00000800
FAULT_CHECKPOINT 0x00001000
- FAULT_DISCARD 0x00002000
+ FAULT_DISCARD 0x00002000 (obsolete)
FAULT_WRITE_IO 0x00004000
FAULT_SLAB_ALLOC 0x00008000
FAULT_DQUOT_INIT 0x00010000
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index d7600979218e..65ca1a5eaa88 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -54,7 +54,7 @@ enum {
FAULT_TRUNCATE,
FAULT_READ_IO,
FAULT_CHECKPOINT,
- FAULT_DISCARD,
+ FAULT_DISCARD, /* it's obsolete due to __blkdev_issue_discard() will never fail */
FAULT_WRITE_IO,
FAULT_SLAB_ALLOC,
FAULT_DQUOT_INIT,
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
index c26424f47686..5168026b2960 100644
--- a/fs/f2fs/segment.c
+++ b/fs/f2fs/segment.c
@@ -1286,7 +1286,6 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi,
&(dcc->fstrim_list) : &(dcc->wait_list);
blk_opf_t flag = dpolicy->sync ? REQ_SYNC : 0;
block_t lstart, start, len, total_len;
- int err = 0;
if (dc->state != D_PREP)
return 0;
@@ -1327,7 +1326,7 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi,
dc->di.len = 0;
- while (total_len && *issued < dpolicy->max_requests && !err) {
+ while (total_len && *issued < dpolicy->max_requests) {
struct bio *bio = NULL;
unsigned long flags;
bool last = true;
@@ -1343,17 +1342,6 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi,
dc->di.len += len;
- err = 0;
- if (time_to_inject(sbi, FAULT_DISCARD)) {
- err = -EIO;
- spin_lock_irqsave(&dc->lock, flags);
- if (dc->state == D_PARTIAL)
- dc->state = D_SUBMIT;
- spin_unlock_irqrestore(&dc->lock, flags);
-
- break;
- }
-
__blkdev_issue_discard(bdev, SECTOR_FROM_BLOCK(start),
SECTOR_FROM_BLOCK(len), GFP_NOFS, &bio);
f2fs_bug_on(sbi, !bio);
@@ -1392,11 +1380,11 @@ static int __submit_discard_cmd(struct f2fs_sb_info *sbi,
len = total_len;
}
- if (!err && len) {
+ if (len) {
dcc->undiscard_blks -= len;
__update_discard_tree_range(sbi, bdev, lstart, start, len);
}
- return err;
+ return 0;
}
static void __insert_discard_cmd(struct f2fs_sb_info *sbi,
--
2.49.0
reply other threads:[~2025-12-15 12:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20251215122803.3495320-1-chao@kernel.org \
--to=chao@kernel.org \
--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).