From: Christoph Hellwig <hch@lst.de>
To: Christian Brauner <brauner@kernel.org>
Cc: "Darrick J. Wong" <djwong@kernel.org>,
linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: [PATCH 2/3] iomap: use bio_complete_in_task for buffered write failures
Date: Mon, 28 Sep 2026 11:11:08 +0200 [thread overview]
Message-ID: <20260928091111.3986811-3-hch@lst.de> (raw)
In-Reply-To: <20260928091111.3986811-1-hch@lst.de>
Use bio_complete_in_task to defer the bio completion handler to task
context instead of the homegrown deferral.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
fs/iomap/ioend.c | 48 ++----------------------------------------------
1 file changed, 2 insertions(+), 46 deletions(-)
diff --git a/fs/iomap/ioend.c b/fs/iomap/ioend.c
index 7bbbb417f915..1c8840bde1ff 100644
--- a/fs/iomap/ioend.c
+++ b/fs/iomap/ioend.c
@@ -74,57 +74,13 @@ static u32 iomap_finish_ioend_buffered_write(struct iomap_ioend *ioend)
return folio_count;
}
-static DEFINE_SPINLOCK(failed_ioend_lock);
-static LIST_HEAD(failed_ioend_list);
-
-static void
-iomap_fail_ioends(
- struct work_struct *work)
-{
- struct iomap_ioend *ioend;
- struct list_head tmp;
- unsigned long flags;
-
- spin_lock_irqsave(&failed_ioend_lock, flags);
- list_replace_init(&failed_ioend_list, &tmp);
- spin_unlock_irqrestore(&failed_ioend_lock, flags);
-
- while ((ioend = list_first_entry_or_null(&tmp, struct iomap_ioend,
- io_list))) {
- list_del_init(&ioend->io_list);
- iomap_finish_ioend_buffered_write(ioend);
- cond_resched();
- }
-}
-
-static DECLARE_WORK(failed_ioend_work, iomap_fail_ioends);
-
-static void iomap_fail_ioend_buffered(struct iomap_ioend *ioend)
-{
- unsigned long flags;
-
- /*
- * Bounce I/O errors to a workqueue to avoid nested i_lock acquisitions
- * in the fserror code. The caller no longer owns the ioend reference
- * after the spinlock drops.
- */
- spin_lock_irqsave(&failed_ioend_lock, flags);
- if (list_empty(&failed_ioend_list))
- WARN_ON_ONCE(!schedule_work(&failed_ioend_work));
- list_add_tail(&ioend->io_list, &failed_ioend_list);
- spin_unlock_irqrestore(&failed_ioend_lock, flags);
-}
-
static void ioend_writeback_end_bio(struct bio *bio)
{
struct iomap_ioend *ioend = iomap_ioend_from_bio(bio);
- ioend->io_error = blk_status_to_errno(bio->bi_status);
- if (ioend->io_error) {
- iomap_fail_ioend_buffered(ioend);
+ if (bio->bi_status && bio_complete_in_task(bio))
return;
- }
-
+ ioend->io_error = blk_status_to_errno(bio->bi_status);
iomap_finish_ioend_buffered_write(ioend);
}
--
2.53.0
next prev parent reply other threads:[~2026-09-28 9:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 9:11 use bio_complete_in_task for iomap error reporting Christoph Hellwig
2026-09-28 9:11 ` [PATCH 1/3] iomap: use bio_complete_in_task for buffered read failures Christoph Hellwig
2026-09-29 0:23 ` Darrick J. Wong
2026-09-29 15:23 ` Andrey Albershteyn
2026-09-28 9:11 ` Christoph Hellwig [this message]
2026-09-29 0:29 ` [PATCH 2/3] iomap: use bio_complete_in_task for buffered write failures Darrick J. Wong
2026-09-29 15:24 ` Andrey Albershteyn
2026-09-28 9:11 ` [PATCH 3/3] iomap: use bio_complete_in_task for buffered simple dio read failures Christoph Hellwig
2026-09-29 0:30 ` Darrick J. Wong
2026-09-29 15:24 ` Andrey Albershteyn
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=20260928091111.3986811-3-hch@lst.de \
--to=hch@lst.de \
--cc=brauner@kernel.org \
--cc=djwong@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@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