From: Christoph Hellwig <hch@lst.de>
To: Jens Axboe <axboe@kernel.dk>
Cc: Carlos Maiolino <cem@kernel.org>,
Bart Van Assche <bvanassche@acm.org>,
Damien Le Moal <dlemoal@kernel.org>,
linux-block@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: [PATCH 2/5] block: unify the synchronous bi_end_io callbacks
Date: Tue, 7 Apr 2026 16:05:25 +0200 [thread overview]
Message-ID: <20260407140538.633364-3-hch@lst.de> (raw)
In-Reply-To: <20260407140538.633364-1-hch@lst.de>
Put the bio in bio_await_chain after waiting for the completion, and
share the now identical callbacks between submit_bio_wait and
bio_await_chain.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
---
block/bio.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/block/bio.c b/block/bio.c
index c8234d347fc5..434e41182c05 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -1462,7 +1462,7 @@ void bio_iov_iter_unbounce(struct bio *bio, bool is_error, bool mark_dirty)
bio_iov_iter_unbounce_read(bio, is_error, mark_dirty);
}
-static void submit_bio_wait_endio(struct bio *bio)
+static void bio_wait_end_io(struct bio *bio)
{
complete(bio->bi_private);
}
@@ -1484,7 +1484,7 @@ int submit_bio_wait(struct bio *bio)
bio->bi_bdev->bd_disk->lockdep_map);
bio->bi_private = &done;
- bio->bi_end_io = submit_bio_wait_endio;
+ bio->bi_end_io = bio_wait_end_io;
bio->bi_opf |= REQ_SYNC;
submit_bio(bio);
blk_wait_io(&done);
@@ -1523,12 +1523,6 @@ int bdev_rw_virt(struct block_device *bdev, sector_t sector, void *data,
}
EXPORT_SYMBOL_GPL(bdev_rw_virt);
-static void bio_wait_end_io(struct bio *bio)
-{
- complete(bio->bi_private);
- bio_put(bio);
-}
-
/*
* bio_await_chain - ends @bio and waits for every chained bio to complete
*/
@@ -1541,6 +1535,7 @@ void bio_await_chain(struct bio *bio)
bio->bi_end_io = bio_wait_end_io;
bio_endio(bio);
blk_wait_io(&done);
+ bio_put(bio);
}
void __bio_advance(struct bio *bio, unsigned bytes)
--
2.47.3
next prev parent reply other threads:[~2026-04-07 14:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-07 14:05 refactor submit_bio_wait and bio await helpers v3 Christoph Hellwig
2026-04-07 14:05 ` [PATCH 1/5] xfs: fix number of GC bvecs Christoph Hellwig
2026-04-07 14:05 ` Christoph Hellwig [this message]
2026-04-08 7:56 ` [PATCH 2/5] block: unify the synchronous bi_end_io callbacks Chaitanya Kulkarni
2026-04-07 14:05 ` [PATCH 3/5] block: factor out a bio_await helper Christoph Hellwig
2026-04-07 14:59 ` Bart Van Assche
2026-04-08 5:11 ` Christoph Hellwig
2026-04-07 14:05 ` [PATCH 4/5] block: add a bio_submit_or_kill helper Christoph Hellwig
2026-04-07 15:04 ` Bart Van Assche
2026-04-07 18:37 ` Bart Van Assche
2026-04-08 5:16 ` Christoph Hellwig
2026-04-07 14:05 ` [PATCH 5/5] xfs: use bio_await in xfs_zone_gc_reset_sync Christoph Hellwig
2026-04-08 7:57 ` Chaitanya Kulkarni
2026-04-07 14:22 ` refactor submit_bio_wait and bio await helpers v3 Jens Axboe
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=20260407140538.633364-3-hch@lst.de \
--to=hch@lst.de \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=cem@kernel.org \
--cc=dlemoal@kernel.org \
--cc=linux-block@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