From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Jens Axboe <axboe@kernel.dk>, Carlos Maiolino <cem@kernel.org>,
Damien Le Moal <dlemoal@kernel.org>,
Hans Holmberg <hans.holmberg@wdc.com>,
linux-block@vger.kernel.org, linux-xfs@vger.kernel.org
Subject: Re: [PATCH 1/3] block: add a bio_reuse helper
Date: Fri, 9 Jan 2026 08:19:06 -0800 [thread overview]
Message-ID: <20260109161906.GN15551@frogsfrogsfrogs> (raw)
In-Reply-To: <20260106075914.1614368-2-hch@lst.de>
On Tue, Jan 06, 2026 at 08:58:52AM +0100, Christoph Hellwig wrote:
> Add a helper to allow an existing bio to be resubmitted withtout
> having to re-add the payload.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> Reviewed-by: Hans Holmberg <hans.holmberg@wdc.com>
> Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
> ---
> block/bio.c | 29 +++++++++++++++++++++++++++++
> include/linux/bio.h | 1 +
> 2 files changed, 30 insertions(+)
>
> diff --git a/block/bio.c b/block/bio.c
> index e726c0e280a8..ed99368c662f 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -311,6 +311,35 @@ void bio_reset(struct bio *bio, struct block_device *bdev, blk_opf_t opf)
> }
> EXPORT_SYMBOL(bio_reset);
General question about bio_reset -- it calls bio_uninit, which strips
off the integrity and crypt metadata. I /think/ that will all get
re-added if necessary during the subsequent bio submission, right?
For your zonegc case, I wonder if it's actually a good idea to keep that
metadata attached as long as the bdev doesn't change across reuse?
--D
> +/**
> + * bio_reuse - reuse a bio with the payload left intact
> + * @bio bio to reuse
> + *
> + * Allow reusing an existing bio for another operation with all set up
> + * fields including the payload, device and end_io handler left intact.
> + *
> + * Typically used for bios first used to read data which is then written
> + * to another location without modification. This must be used by the
> + * I/O submitter on an bio that is not in flight. Can't be used for
> + * cloned bios.
> + */
> +void bio_reuse(struct bio *bio)
> +{
> + unsigned short vcnt = bio->bi_vcnt, i;
> + bio_end_io_t *end_io = bio->bi_end_io;
> + void *private = bio->bi_private;
> +
> + WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED));
> +
> + bio_reset(bio, bio->bi_bdev, bio->bi_opf);
> + for (i = 0; i < vcnt; i++)
> + bio->bi_iter.bi_size += bio->bi_io_vec[i].bv_len;
> + bio->bi_vcnt = vcnt;
> + bio->bi_private = private;
> + bio->bi_end_io = end_io;
> +}
> +EXPORT_SYMBOL_GPL(bio_reuse);
> +
> static struct bio *__bio_chain_endio(struct bio *bio)
> {
> struct bio *parent = bio->bi_private;
> diff --git a/include/linux/bio.h b/include/linux/bio.h
> index ad2d57908c1c..c0190f8badde 100644
> --- a/include/linux/bio.h
> +++ b/include/linux/bio.h
> @@ -414,6 +414,7 @@ static inline void bio_init_inline(struct bio *bio, struct block_device *bdev,
> }
> extern void bio_uninit(struct bio *);
> void bio_reset(struct bio *bio, struct block_device *bdev, blk_opf_t opf);
> +void bio_reuse(struct bio *bio);
> void bio_chain(struct bio *, struct bio *);
>
> int __must_check bio_add_page(struct bio *bio, struct page *page, unsigned len,
> --
> 2.47.3
>
>
next prev parent reply other threads:[~2026-01-09 16:19 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-06 7:58 improve zoned XFS GC buffer management v2 Christoph Hellwig
2026-01-06 7:58 ` [PATCH 1/3] block: add a bio_reuse helper Christoph Hellwig
2026-01-09 12:12 ` Carlos Maiolino
2026-01-09 16:19 ` Darrick J. Wong [this message]
2026-01-09 16:25 ` Christoph Hellwig
2026-01-10 0:50 ` Darrick J. Wong
2026-01-09 16:30 ` Carlos Maiolino
2026-01-12 20:22 ` Jens Axboe
2026-01-06 7:58 ` [PATCH 2/3] xfs: use bio_reuse in the zone GC code Christoph Hellwig
2026-01-09 12:13 ` Carlos Maiolino
2026-01-06 7:58 ` [PATCH 3/3] xfs: rework zone GC buffer management Christoph Hellwig
2026-01-09 12:24 ` Carlos Maiolino
2026-01-09 15:03 ` improve zoned XFS GC buffer management v2 Carlos Maiolino
-- strict thread matches above, loose matches on Subject: below --
2026-01-14 13:06 improve zoned XFS GC buffer management v4 Christoph Hellwig
2026-01-14 13:06 ` [PATCH 1/3] block: add a bio_reuse helper Christoph Hellwig
2026-01-13 7:19 improve zoned XFS GC buffer management v3 Christoph Hellwig
2026-01-13 7:19 ` [PATCH 1/3] block: add a bio_reuse helper Christoph Hellwig
2025-12-18 6:31 improve zoned XFS GC buffer management Christoph Hellwig
2025-12-18 6:31 ` [PATCH 1/3] block: add a bio_reuse helper Christoph Hellwig
2025-12-18 6:43 ` Damien Le Moal
2025-12-18 9:20 ` Hannes Reinecke
2025-12-18 9:35 ` Christoph Hellwig
2025-12-18 9:40 ` Ming Lei
2025-12-18 9:45 ` Christoph Hellwig
2025-12-19 7:45 ` Hans Holmberg
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=20260109161906.GN15551@frogsfrogsfrogs \
--to=djwong@kernel.org \
--cc=axboe@kernel.dk \
--cc=cem@kernel.org \
--cc=dlemoal@kernel.org \
--cc=hans.holmberg@wdc.com \
--cc=hch@lst.de \
--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