Message ID | 20240626100700.3629-5-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:54PM +0530, Anuj Gupta wrote: > @@ -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)); Maybe add a well documented helper that calculates the metadata bytes based on the iter given that this is probably going to become more common now that we're doing proper cloning? > - bip->bip_flags = bip_src->bip_flags & ~BIP_BLOCK_INTEGRITY; > - > + bip->bip_flags = bip_src->bip_flags & ~(BIP_BLOCK_INTEGRITY | > + BIP_COPY_USER); We're probably better off say what flags should be cloned and not which ones should not. Preferably with a new #define in bio.h.
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; }
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@samsung.com> --- block/bio-integrity.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-)