Skip to content

Commit ba94223

Browse files
Anuj Guptaaxboe
authored andcommitted
block: reuse original bio_vec array for integrity during clone
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]>
1 parent a18df07 commit ba94223

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

block/bio-integrity.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ struct bio_integrity_payload *bio_integrity_alloc(struct bio *bio,
7676
&bip->bip_max_vcnt, gfp_mask);
7777
if (!bip->bip_vec)
7878
goto err;
79-
} else {
79+
} else if (nr_vecs) {
8080
bip->bip_vec = bip->bip_inline_vecs;
8181
}
8282

@@ -562,14 +562,11 @@ int bio_integrity_clone(struct bio *bio, struct bio *bio_src,
562562

563563
BUG_ON(bip_src == NULL);
564564

565-
bip = bio_integrity_alloc(bio, gfp_mask, bip_src->bip_vcnt);
565+
bip = bio_integrity_alloc(bio, gfp_mask, 0);
566566
if (IS_ERR(bip))
567567
return PTR_ERR(bip);
568568

569-
memcpy(bip->bip_vec, bip_src->bip_vec,
570-
bip_src->bip_vcnt * sizeof(struct bio_vec));
571-
572-
bip->bip_vcnt = bip_src->bip_vcnt;
569+
bip->bip_vec = bip_src->bip_vec;
573570
bip->bip_iter = bip_src->bip_iter;
574571
bip->bip_flags = bip_src->bip_flags & ~BIP_BLOCK_INTEGRITY;
575572

0 commit comments

Comments
 (0)