* [PATCH v2] block: Correct comments on bio_alloc_clone() and bio_init_clone()
@ 2026-02-27 10:44 John Garry
2026-02-27 13:28 ` Damien Le Moal
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: John Garry @ 2026-02-27 10:44 UTC (permalink / raw)
To: axboe, hch; +Cc: linux-block, John Garry
Correct the comments that the cloned bio must be freed before the memory
pointed to by @bio_Src->bi_io_vecs (is freed).
Christoph Hellwig contributed most the of the update wording.
Signed-off-by: John Garry <john.g.garry@oracle.com>
diff --git a/block/bio.c b/block/bio.c
index 8203bb7455a9f..156bb75f55298 100644
--- a/block/bio.c
+++ b/block/bio.c
@@ -897,10 +897,11 @@ static int __bio_clone(struct bio *bio, struct bio *bio_src, gfp_t gfp)
* @gfp: allocation priority
* @bs: bio_set to allocate from
*
- * Allocate a new bio that is a clone of @bio_src. The caller owns the returned
- * bio, but not the actual data it points to.
- *
- * The caller must ensure that the return bio is not freed before @bio_src.
+ * Allocate a new bio that is a clone of @bio_src. This reuses the bio_vecs
+ * pointed to by @bio_src->bi_io_vec, and clones the iterator pointing to
+ * the current position in it. The caller owns the returned bio, but not
+ * the bio_vecs, and must ensure the bio is freed before the memory
+ * pointed to by @bio_Src->bi_io_vecs.
*/
struct bio *bio_alloc_clone(struct block_device *bdev, struct bio *bio_src,
gfp_t gfp, struct bio_set *bs)
@@ -929,9 +930,7 @@ EXPORT_SYMBOL(bio_alloc_clone);
* @gfp: allocation priority
*
* Initialize a new bio in caller provided memory that is a clone of @bio_src.
- * The caller owns the returned bio, but not the actual data it points to.
- *
- * The caller must ensure that @bio_src is not freed before @bio.
+ * The same bio_vecs reuse and bio lifetime rules as bio_alloc_clone() apply.
*/
int bio_init_clone(struct block_device *bdev, struct bio *bio,
struct bio *bio_src, gfp_t gfp)
--
2.43.5
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH v2] block: Correct comments on bio_alloc_clone() and bio_init_clone()
2026-02-27 10:44 [PATCH v2] block: Correct comments on bio_alloc_clone() and bio_init_clone() John Garry
@ 2026-02-27 13:28 ` Damien Le Moal
2026-02-27 13:51 ` Christoph Hellwig
2026-02-27 16:48 ` Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Damien Le Moal @ 2026-02-27 13:28 UTC (permalink / raw)
To: John Garry, axboe, hch; +Cc: linux-block
On 2/27/26 19:44, John Garry wrote:
> Correct the comments that the cloned bio must be freed before the memory
> pointed to by @bio_Src->bi_io_vecs (is freed).
>
> Christoph Hellwig contributed most the of the update wording.
>
> Signed-off-by: John Garry <john.g.garry@oracle.com>
Looks good to me.
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Note: Not sure if it matters, but your patch is missing the "---" separator
between your SoB and the beginning of the diff.
>
> diff --git a/block/bio.c b/block/bio.c
> index 8203bb7455a9f..156bb75f55298 100644
> --- a/block/bio.c
> +++ b/block/bio.c
> @@ -897,10 +897,11 @@ static int __bio_clone(struct bio *bio, struct bio *bio_src, gfp_t gfp)
> * @gfp: allocation priority
> * @bs: bio_set to allocate from
> *
> - * Allocate a new bio that is a clone of @bio_src. The caller owns the returned
> - * bio, but not the actual data it points to.
> - *
> - * The caller must ensure that the return bio is not freed before @bio_src.
> + * Allocate a new bio that is a clone of @bio_src. This reuses the bio_vecs
> + * pointed to by @bio_src->bi_io_vec, and clones the iterator pointing to
> + * the current position in it. The caller owns the returned bio, but not
> + * the bio_vecs, and must ensure the bio is freed before the memory
> + * pointed to by @bio_Src->bi_io_vecs.
> */
> struct bio *bio_alloc_clone(struct block_device *bdev, struct bio *bio_src,
> gfp_t gfp, struct bio_set *bs)
> @@ -929,9 +930,7 @@ EXPORT_SYMBOL(bio_alloc_clone);
> * @gfp: allocation priority
> *
> * Initialize a new bio in caller provided memory that is a clone of @bio_src.
> - * The caller owns the returned bio, but not the actual data it points to.
> - *
> - * The caller must ensure that @bio_src is not freed before @bio.
> + * The same bio_vecs reuse and bio lifetime rules as bio_alloc_clone() apply.
> */
> int bio_init_clone(struct block_device *bdev, struct bio *bio,
> struct bio *bio_src, gfp_t gfp)
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] block: Correct comments on bio_alloc_clone() and bio_init_clone()
2026-02-27 10:44 [PATCH v2] block: Correct comments on bio_alloc_clone() and bio_init_clone() John Garry
2026-02-27 13:28 ` Damien Le Moal
@ 2026-02-27 13:51 ` Christoph Hellwig
2026-02-27 16:48 ` Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2026-02-27 13:51 UTC (permalink / raw)
To: John Garry; +Cc: axboe, hch, linux-block
> + * pointed to by @bio_Src->bi_io_vecs.
s/bio_Src/bio_src/
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2] block: Correct comments on bio_alloc_clone() and bio_init_clone()
2026-02-27 10:44 [PATCH v2] block: Correct comments on bio_alloc_clone() and bio_init_clone() John Garry
2026-02-27 13:28 ` Damien Le Moal
2026-02-27 13:51 ` Christoph Hellwig
@ 2026-02-27 16:48 ` Jens Axboe
2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2026-02-27 16:48 UTC (permalink / raw)
To: hch, John Garry; +Cc: linux-block
On Fri, 27 Feb 2026 10:44:38 +0000, John Garry wrote:
> Correct the comments that the cloned bio must be freed before the memory
> pointed to by @bio_Src->bi_io_vecs (is freed).
>
> Christoph Hellwig contributed most the of the update wording.
>
>
Applied, thanks!
[1/1] block: Correct comments on bio_alloc_clone() and bio_init_clone()
commit: 6d13f8ca6428fd5c24f5d83da37a8f297419d273
Best regards,
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-02-27 16:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-27 10:44 [PATCH v2] block: Correct comments on bio_alloc_clone() and bio_init_clone() John Garry
2026-02-27 13:28 ` Damien Le Moal
2026-02-27 13:51 ` Christoph Hellwig
2026-02-27 16:48 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox