[PATCH v2 04/10] block: Handle meta bounce buffer correctly in case of split
Anuj Gupta
anuj20.g at samsung.com
Wed Jun 26 03:06:54 PDT 2024
Do not inherit BIP_COPY_USER for cloned bio.
Also make sure that bounce buffer is copied back to user-space in
entirety when the parent bio completes.
Signed-off-by: Anuj Gupta <anuj20.g at samsung.com>
---
block/bio-integrity.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index 5e7596b74ef1..845d4038afb1 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -105,9 +105,12 @@ static void bio_integrity_unpin_bvec(struct bio_vec *bv, int nr_vecs,
static void bio_integrity_uncopy_user(struct bio_integrity_payload *bip)
{
+ struct bio *bio = bip->bip_bio;
+ struct blk_integrity *bi = blk_get_integrity(bio->bi_bdev->bd_disk);
unsigned short nr_vecs = bip->bip_max_vcnt - 1;
struct bio_vec *copy = &bip->bip_vec[1];
- size_t bytes = bip->bip_iter.bi_size;
+ size_t bytes = bio_integrity_bytes(bi,
+ bvec_iter_sectors(bip->bio_iter));
struct iov_iter iter;
int ret;
@@ -277,6 +280,7 @@ static int bio_integrity_copy_user(struct bio *bio, struct bio_vec *bvec,
bip->bip_flags |= BIP_INTEGRITY_USER | BIP_COPY_USER;
bip->bip_iter.bi_sector = seed;
bip->bip_vcnt = nr_vecs;
+ bip->bio_iter = bio->bi_iter;
return 0;
free_bip:
bio_integrity_free(bio);
@@ -656,8 +660,8 @@ int bio_integrity_clone(struct bio *bio, struct bio *bio_src,
bip->bip_vcnt = bip_src->bip_vcnt;
bip->bip_iter = bip_src->bip_iter;
- bip->bip_flags = bip_src->bip_flags & ~BIP_BLOCK_INTEGRITY;
-
+ bip->bip_flags = bip_src->bip_flags & ~(BIP_BLOCK_INTEGRITY |
+ BIP_COPY_USER);
return 0;
}
--
2.25.1
More information about the Linux-nvme
mailing list