Skip to content

Commit

Permalink
block: reuse original bio_vec array for integrity during clone
Browse files Browse the repository at this point in the history
Modify bio_integrity_clone to reuse the original bvec array instead of
allocating and copying it, similar to how bio data path is cloned.

Suggested-by: Christoph Hellwig <[email protected]>
Signed-off-by: Anuj Gupta <[email protected]>
Signed-off-by: Christoph Hellwig <[email protected]>
Reviewed-by: Martin K. Petersen <[email protected]>
Reviewed-by: Ming Lei <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Anuj Gupta authored and axboe committed Jul 4, 2024
1 parent a18df07 commit ba94223
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions block/bio-integrity.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio,
&bip->bip_max_vcnt, gfp_mask);
if (!bip->bip_vec)
goto err;
} else {
} else if (nr_vecs) {
bip->bip_vec = bip->bip_inline_vecs;
}

Expand Down Expand Up @@ -562,14 +562,11 @@ 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, 0);
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->bip_vcnt = bip_src->bip_vcnt;
bip->bip_vec = bip_src->bip_vec;
bip->bip_iter = bip_src->bip_iter;
bip->bip_flags = bip_src->bip_flags & ~BIP_BLOCK_INTEGRITY;

Expand Down

0 comments on commit ba94223

Please sign in to comment.