Skip to content

Commit 0311419

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: copy back bounce buffer to user-space correctly in case of split
Copy back the bounce buffer to user-space in entirety when the parent bio completes. The existing code uses bip_iter.bi_size for sizing the copy, which can be modified. So move away from that and fetch it from the vector passed to the block layer. While at it, switch to using better variable names. Fixes: 492c5d4 ("block: bio-integrity: directly map user buffers") Signed-off-by: Christoph Hellwig <[email protected]> Signed-off-by: Anuj Gupta <[email protected]> Reviewed-by: Keith Busch <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 5dbb3cb commit 0311419

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

block/bio-integrity.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -118,17 +118,18 @@ static void bio_integrity_unpin_bvec(struct bio_vec *bv, int nr_vecs,
118118

119119
static void bio_integrity_uncopy_user(struct bio_integrity_payload *bip)
120120
{
121-
unsigned short nr_vecs = bip->bip_max_vcnt - 1;
122-
struct bio_vec *copy = &bip->bip_vec[1];
123-
size_t bytes = bip->bip_iter.bi_size;
124-
struct iov_iter iter;
121+
unsigned short orig_nr_vecs = bip->bip_max_vcnt - 1;
122+
struct bio_vec *orig_bvecs = &bip->bip_vec[1];
123+
struct bio_vec *bounce_bvec = &bip->bip_vec[0];
124+
size_t bytes = bounce_bvec->bv_len;
125+
struct iov_iter orig_iter;
125126
int ret;
126127

127-
iov_iter_bvec(&iter, ITER_DEST, copy, nr_vecs, bytes);
128-
ret = copy_to_iter(bvec_virt(bip->bip_vec), bytes, &iter);
128+
iov_iter_bvec(&orig_iter, ITER_DEST, orig_bvecs, orig_nr_vecs, bytes);
129+
ret = copy_to_iter(bvec_virt(bounce_bvec), bytes, &orig_iter);
129130
WARN_ON_ONCE(ret != bytes);
130131

131-
bio_integrity_unpin_bvec(copy, nr_vecs, true);
132+
bio_integrity_unpin_bvec(orig_bvecs, orig_nr_vecs, true);
132133
}
133134

134135
/**

0 commit comments

Comments
 (0)