Skip to content

Commit d0e5fc7

Browse files
johnpgarryaxboe
authored andcommitted
block: Correct comments on bio_alloc_clone() and bio_init_clone()
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 <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent b0e497d commit d0e5fc7

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

block/bio.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -897,10 +897,11 @@ static int __bio_clone(struct bio *bio, struct bio *bio_src, gfp_t gfp)
897897
* @gfp: allocation priority
898898
* @bs: bio_set to allocate from
899899
*
900-
* Allocate a new bio that is a clone of @bio_src. The caller owns the returned
901-
* bio, but not the actual data it points to.
902-
*
903-
* The caller must ensure that the return bio is not freed before @bio_src.
900+
* Allocate a new bio that is a clone of @bio_src. This reuses the bio_vecs
901+
* pointed to by @bio_src->bi_io_vec, and clones the iterator pointing to
902+
* the current position in it. The caller owns the returned bio, but not
903+
* the bio_vecs, and must ensure the bio is freed before the memory
904+
* pointed to by @bio_Src->bi_io_vecs.
904905
*/
905906
struct bio *bio_alloc_clone(struct block_device *bdev, struct bio *bio_src,
906907
gfp_t gfp, struct bio_set *bs)
@@ -929,9 +930,7 @@ EXPORT_SYMBOL(bio_alloc_clone);
929930
* @gfp: allocation priority
930931
*
931932
* Initialize a new bio in caller provided memory that is a clone of @bio_src.
932-
* The caller owns the returned bio, but not the actual data it points to.
933-
*
934-
* The caller must ensure that @bio_src is not freed before @bio.
933+
* The same bio_vecs reuse and bio lifetime rules as bio_alloc_clone() apply.
935934
*/
936935
int bio_init_clone(struct block_device *bdev, struct bio *bio,
937936
struct bio *bio_src, gfp_t gfp)

0 commit comments

Comments
 (0)