public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Ming Lei <ming.lei@redhat.com>
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: Thu, 18 Dec 2025 17:40:00 +0800	[thread overview]
Message-ID: <aUPL8Jr39N-SIf_W@fedora> (raw)
In-Reply-To: <20251218063234.1539374-2-hch@lst.de>

On Thu, Dec 18, 2025 at 07:31:45AM +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>
> ---
>  block/bio.c         | 25 +++++++++++++++++++++++++
>  include/linux/bio.h |  1 +
>  2 files changed, 26 insertions(+)
> 
> diff --git a/block/bio.c b/block/bio.c
> index e726c0e280a8..1b68ae877468 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -311,6 +311,31 @@ void bio_reset(struct bio *bio, struct block_device *bdev, blk_opf_t opf)
>  }
>  EXPORT_SYMBOL(bio_reset);
>  
> +/**
> + * 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.
> + */
> +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;

The incoming bio can't be a cloned bio, so

	WARN_ON_ONCE(bio_flagged(bio, BIO_CLONED));

should be added.

Otherwise, it looks fine.

Thanks,
Ming


  parent reply	other threads:[~2025-12-18  9:40 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2025-12-18  9:45     ` Christoph Hellwig
2025-12-19  7:45   ` Hans Holmberg
2025-12-18  6:31 ` [PATCH 2/3] xfs: use bio_reuse in the zone GC code Christoph Hellwig
2025-12-18  6:45   ` Damien Le Moal
2025-12-19  7:48   ` Hans Holmberg
2025-12-18  6:31 ` [PATCH 3/3] xfs: rework zone GC buffer management Christoph Hellwig
2025-12-18  7:12   ` Damien Le Moal
2025-12-19  8:06   ` Hans Holmberg
  -- strict thread matches above, loose matches on Subject: below --
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
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-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
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

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=aUPL8Jr39N-SIf_W@fedora \
    --to=ming.lei@redhat.com \
    --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