block: Correct comment on bio_alloc_clone()
PATCH 1/1 block: Correct comment on bio_alloc_clone()
Correct the comment that the source bio must not be freed before the clone.
block/bio.c +1 -1
@@ -900,7 +900,7 @@ static int __bio_clone(struct bio *bio, struct bio *bio_src, gfp_t gfp)* 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. +* The caller must ensure that @bio_src is not freed before the returned bio. */ struct bio *bio_alloc_clone (struct block_device *bdev,struct bio *bio_src,gfp_t gfp,struct bio_set *bs)
Signature · 1 line
2.43.5
Quoted 1 line · John Garry
Correct the comment that the source bio must not be freed before the clone.
Note that while this version is better, it's not actually true either. The bi_io_vec used by the clone must be freed after the clone, but it might might not be owned by the passed in bio_src.
Quoted 7 lines · Christoph Hellwig
Quoted 1 line · John Garry
Correct the comment that the source bio must not be freed before the clone.
Note that while this version is better, it's not actually true either. The
bi_io_vecused by the clone must be freed after the clone, but it might might not be owned by the passed inbio_src.
This is the complete function comment today:
* 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.
So I can have this:
* 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, bi_io_vec.
*
* The caller must ensure that the returned bio is freed before bi_io_vec.
ok?
Quoted 6 lines · John Garry
So I can have this:
* 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,bi_io_vec.
Well, bi_io_vec isn't really the data, but the indirection pointing to the data. I guess we need to come up with consistent terminology first before we can make good sense of this.
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.
Quoted 9 lines · Christoph Hellwig
Well,
bi_io_vecisn't really the data, but the indirection pointing to the data. I guess we need to come up with consistent terminology first before we can make good sense of this.Allocate a new bio that is a clone of @bio_src. This reuses the
bio_vecspointed 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 thebio_vecs, and must ensure the bio is freed before the memory pointed to by @bio_Src->bi_io_vecs.
ok, fine.
BTW, the comment for bio_init_clone() was much the same as bio_alloc_clone(), modulo what I tried to originally remedy. I can just mention that that the same bio_src->bi_io_vec lifecycle rules apply there (as bio_alloc_clone())
Quoted 4 lines · John Garry
BTW, the comment for
bio_init_clone()was much the same asbio_alloc_clone(), modulo what I tried to originally remedy. I can just mention that that the samebio_src->bi_io_veclifecycle rules apply there (asbio_alloc_clone())
Sounds good.