Message ID | 20240626100700.3629-4-anuj20.g@samsung.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | [v2,01/10] block: change rq_integrity_vec to respect the iterator | expand |
On Wed, Jun 26, 2024 at 03:36:53PM +0530, Anuj Gupta wrote: > If bio_integrity_copy_user is used to process the meta buffer, bip_max_vcnt > is one greater than bip_vcnt. Why? > @@ -647,12 +647,12 @@ int bio_integrity_clone(struct bio *bio, struct bio *bio_src, > > BUG_ON(bip_src == NULL); > > - bip = bio_integrity_alloc(bio, gfp_mask, bip_src->bip_vcnt); > + bip = bio_integrity_alloc(bio, gfp_mask, bip_src->bip_max_vcnt); > if (IS_ERR(bip)) > return PTR_ERR(bip); > > memcpy(bip->bip_vec, bip_src->bip_vec, > - bip_src->bip_vcnt * sizeof(struct bio_vec)); > + bip_src->bip_max_vcnt * sizeof(struct bio_vec)); > > bip->bip_vcnt = bip_src->bip_vcnt; > bip->bip_iter = bip_src->bip_iter; So trying to compare this to how the bio data path is cloned, it seems like bio_integrity_clone is still copying the bvec array. With the concept of the immutable bvecs we've had for years this should not be required. That is reuse the actual bio_vecs, and just copy the iter similar to bio_alloc_clone/__bio_clone.
diff --git a/block/bio-integrity.c b/block/bio-integrity.c index af79d9fbf413..5e7596b74ef1 100644 --- a/block/bio-integrity.c +++ b/block/bio-integrity.c @@ -647,12 +647,12 @@ int bio_integrity_clone(struct bio *bio, struct bio *bio_src, BUG_ON(bip_src == NULL); - bip = bio_integrity_alloc(bio, gfp_mask, bip_src->bip_vcnt); + bip = bio_integrity_alloc(bio, gfp_mask, bip_src->bip_max_vcnt); if (IS_ERR(bip)) return PTR_ERR(bip); memcpy(bip->bip_vec, bip_src->bip_vec, - bip_src->bip_vcnt * sizeof(struct bio_vec)); + bip_src->bip_max_vcnt * sizeof(struct bio_vec)); bip->bip_vcnt = bip_src->bip_vcnt; bip->bip_iter = bip_src->bip_iter;