Skip to content

Commit f892437

Browse files
Christoph Hellwigaxboe
authored andcommitted
block: call bio_integrity_unmap_free_user from blk_rq_unmap_user
blk_rq_unmap_user always unmaps user space pass-through request. If such a request has integrity data attached it must come from a user mapping as well. Call bio_integrity_unmap_free_user from blk_rq_unmap_user and remove the nvme_unmap_bio wrapper in the nvme driver. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Kanchan Joshi <[email protected]> Reviewed-by: Anuj Gupta <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]> Reviewed-by: Martin K. Petersen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent bf4c89f commit f892437

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

block/bio-integrity.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ void bio_integrity_unmap_free_user(struct bio *bio)
174174
bio->bi_integrity = NULL;
175175
bio->bi_opf &= ~REQ_INTEGRITY;
176176
}
177-
EXPORT_SYMBOL(bio_integrity_unmap_free_user);
178177

179178
/**
180179
* bio_integrity_add_page - Attach integrity metadata

block/blk-map.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -757,6 +757,9 @@ int blk_rq_unmap_user(struct bio *bio)
757757
bio_release_pages(bio, bio_data_dir(bio) == READ);
758758
}
759759

760+
if (bio_integrity(bio))
761+
bio_integrity_unmap_free_user(bio);
762+
760763
next_bio = bio;
761764
bio = bio->bi_next;
762765
blk_mq_map_bio_put(next_bio);

drivers/nvme/host/ioctl.c

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,6 @@ static struct request *nvme_alloc_user_request(struct request_queue *q,
112112
return req;
113113
}
114114

115-
static void nvme_unmap_bio(struct bio *bio)
116-
{
117-
if (bio_integrity(bio))
118-
bio_integrity_unmap_free_user(bio);
119-
blk_rq_unmap_user(bio);
120-
}
121-
122115
static int nvme_map_user_request(struct request *req, u64 ubuffer,
123116
unsigned bufflen, void __user *meta_buffer, unsigned meta_len,
124117
u32 meta_seed, struct io_uring_cmd *ioucmd, unsigned int flags)
@@ -165,7 +158,7 @@ static int nvme_map_user_request(struct request *req, u64 ubuffer,
165158

166159
out_unmap:
167160
if (bio)
168-
nvme_unmap_bio(bio);
161+
blk_rq_unmap_user(bio);
169162
out:
170163
blk_mq_free_request(req);
171164
return ret;
@@ -203,7 +196,7 @@ static int nvme_submit_user_cmd(struct request_queue *q,
203196
if (result)
204197
*result = le64_to_cpu(nvme_req(req)->result.u64);
205198
if (bio)
206-
nvme_unmap_bio(bio);
199+
blk_rq_unmap_user(bio);
207200
blk_mq_free_request(req);
208201

209202
if (effects)
@@ -414,7 +407,7 @@ static void nvme_uring_task_cb(struct io_uring_cmd *ioucmd,
414407
struct nvme_uring_cmd_pdu *pdu = nvme_uring_cmd_pdu(ioucmd);
415408

416409
if (pdu->bio)
417-
nvme_unmap_bio(pdu->bio);
410+
blk_rq_unmap_user(pdu->bio);
418411
io_uring_cmd_done(ioucmd, pdu->status, pdu->result, issue_flags);
419412
}
420413

@@ -440,7 +433,7 @@ static enum rq_end_io_ret nvme_uring_cmd_end_io(struct request *req,
440433
*/
441434
if (blk_rq_is_poll(req)) {
442435
if (pdu->bio)
443-
nvme_unmap_bio(pdu->bio);
436+
blk_rq_unmap_user(pdu->bio);
444437
io_uring_cmd_iopoll_done(ioucmd, pdu->result, pdu->status);
445438
} else {
446439
io_uring_cmd_do_in_task_lazy(ioucmd, nvme_uring_task_cb);

0 commit comments

Comments
 (0)