diff options
| author | Christoph Hellwig <hch@lst.de> | 2026-09-09 09:08:52 +0300 |
|---|---|---|
| committer | Jens Axboe <axboe@kernel.dk> | 2026-09-11 07:25:21 -0600 |
| commit | 584e6e36b6d0b95af00e0ee38bab43607152c981 (patch) | |
| tree | f75e77ea4b6e5a6835110e8af855dd18ab8f5686 /block | |
| parent | 7848da3b1ec374620318bba49328093c99e846d4 (diff) | |
| download | linux-next-584e6e36b6d0b95af00e0ee38bab43607152c981.tar.gz linux-next-584e6e36b6d0b95af00e0ee38bab43607152c981.zip | |
block: add a bio_prepare_reissue helper
Add a helper to a clear a bio for reissue without a lot of the
pointless clearing and reinitializing done by bio_reset and bio_reuse,
and keeping the page pinning flag intact.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Link: https://patch.msgid.link/20260909060924.1102037-4-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'block')
| -rw-r--r-- | block/bio.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/block/bio.c b/block/bio.c index 67846e765f4a..9654acfab113 100644 --- a/block/bio.c +++ b/block/bio.c @@ -320,6 +320,26 @@ void bio_reuse(struct bio *bio, blk_opf_t opf) } EXPORT_SYMBOL_GPL(bio_reuse); +/** + * bio_prepare_reissue - prepare a bio for reuissing the original I/O + * @bio: bio to reuse + * @bdev: block device to use the bio for + * + * Prepare @bio to be resubmitted to retry the original operation. + * The caller must reset bio->bi_iter to the original state. + */ +void bio_prepare_reissue(struct bio *bio, struct block_device *bdev) +{ + bio->bi_bdev = bdev; + bio_associate_blkg(bio); + bio->bi_flags &= + (BIO_PAGE_PINNED | BIO_CLONED | BIO_QUIET | BIO_REFFED); + bio->bi_status = BLK_STS_OK; + bio->bi_bvec_gap_bit = 0; + atomic_set(&bio->__bi_remaining, 1); +} +EXPORT_SYMBOL_GPL(bio_prepare_reissue); + static struct bio *__bio_chain_endio(struct bio *bio) { struct bio *parent = bio->bi_private; |
