Skip to content

Commit 43a67dd

Browse files
calebsanderaxboe
authored andcommitted
block: flip iter directions in blk_rq_integrity_map_user()
blk_rq_integrity_map_user() creates the ubuf iter with ITER_DEST for write-direction operations and ITER_SOURCE for read-direction ones. This is backwards; writes use the user buffer as a source for metadata and reads use it as a destination. Switch to the rq_data_dir() helper, which maps writes to ITER_SOURCE (WRITE) and reads to ITER_DEST(READ). Signed-off-by: Caleb Sander Mateos <[email protected]> Fixes: fe8f4ca ("block: modify bio_integrity_map_user to accept iov_iter as argument") Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent c09a8b0 commit 43a67dd

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

block/blk-integrity.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,8 @@ int blk_rq_integrity_map_user(struct request *rq, void __user *ubuf,
117117
{
118118
int ret;
119119
struct iov_iter iter;
120-
unsigned int direction;
121120

122-
if (op_is_write(req_op(rq)))
123-
direction = ITER_DEST;
124-
else
125-
direction = ITER_SOURCE;
126-
iov_iter_ubuf(&iter, direction, ubuf, bytes);
121+
iov_iter_ubuf(&iter, rq_data_dir(rq), ubuf, bytes);
127122
ret = bio_integrity_map_user(rq->bio, &iter);
128123
if (ret)
129124
return ret;

0 commit comments

Comments
 (0)