]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
block: unify the synchronous bi_end_io callbacks
authorChristoph Hellwig <hch@lst.de>
Tue, 7 Apr 2026 14:05:25 +0000 (16:05 +0200)
committerJens Axboe <axboe@kernel.dk>
Tue, 7 Apr 2026 14:22:24 +0000 (08:22 -0600)
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>
Link: https://patch.msgid.link/20260407140538.633364-3-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
block/bio.c

index c8234d347fc555ff1471ae039f7d4f311e2827f2..434e41182c050a0b0cc147cb4d3f76c8908d0d6c 100644 (file)
@@ -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)