diff options
author | Kent Overstreet <kmo@daterainc.com> | 2015-01-18 10:16:31 -0500 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2015-02-05 11:30:40 -0500 |
commit | 26e49cfc7e988a76bf1e55cef0d9e438e5489180 (patch) | |
tree | 43a2a3590738ef4097b63719e35fcc761a66e844 /block/scsi_ioctl.c | |
parent | 1dfa0f68c040080c5fefa7211b4ec34d202f8570 (diff) |
block: pass iov_iter to the BLOCK_PC mapping functions
Make use of a new interface provided by iov_iter, backed by
scatter-gather list of iovec, instead of the old interface based on
sg_iovec. Also use iov_iter_advance() instead of manual iteration.
This commit should contain only literal replacements, without
functional changes.
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Doug Gilbert <dgilbert@interlog.com>
Cc: "James E.J. Bottomley" <JBottomley@parallels.com>
Signed-off-by: Kent Overstreet <kmo@daterainc.com>
[dpark: add more description in commit message]
Signed-off-by: Dongsu Park <dongsu.park@profitbricks.com>
[hch: fixed to do a deep clone of the iov_iter, and to properly use
the iov_iter direction]
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Ming Lei <tom.leiming@gmail.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'block/scsi_ioctl.c')
-rw-r--r-- | block/scsi_ioctl.c | 17 |
1 files changed, 4 insertions, 13 deletions
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c index 28163fad3c5d..e1f71c396193 100644 --- a/block/scsi_ioctl.c +++ b/block/scsi_ioctl.c | |||
@@ -332,7 +332,7 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk, | |||
332 | 332 | ||
333 | ret = 0; | 333 | ret = 0; |
334 | if (hdr->iovec_count) { | 334 | if (hdr->iovec_count) { |
335 | size_t iov_data_len; | 335 | struct iov_iter i; |
336 | struct iovec *iov = NULL; | 336 | struct iovec *iov = NULL; |
337 | 337 | ||
338 | ret = rw_copy_check_uvector(-1, hdr->dxferp, hdr->iovec_count, | 338 | ret = rw_copy_check_uvector(-1, hdr->dxferp, hdr->iovec_count, |
@@ -342,20 +342,11 @@ static int sg_io(struct request_queue *q, struct gendisk *bd_disk, | |||
342 | goto out_free_cdb; | 342 | goto out_free_cdb; |
343 | } | 343 | } |
344 | 344 | ||
345 | iov_data_len = ret; | ||
346 | ret = 0; | ||
347 | |||
348 | /* SG_IO howto says that the shorter of the two wins */ | 345 | /* SG_IO howto says that the shorter of the two wins */ |
349 | if (hdr->dxfer_len < iov_data_len) { | 346 | iov_iter_init(&i, rq_data_dir(rq), iov, hdr->iovec_count, |
350 | hdr->iovec_count = iov_shorten(iov, | 347 | min_t(unsigned, ret, hdr->dxfer_len)); |
351 | hdr->iovec_count, | ||
352 | hdr->dxfer_len); | ||
353 | iov_data_len = hdr->dxfer_len; | ||
354 | } | ||
355 | 348 | ||
356 | ret = blk_rq_map_user_iov(q, rq, NULL, (struct sg_iovec *) iov, | 349 | ret = blk_rq_map_user_iov(q, rq, NULL, &i, GFP_KERNEL); |
357 | hdr->iovec_count, | ||
358 | iov_data_len, GFP_KERNEL); | ||
359 | kfree(iov); | 350 | kfree(iov); |
360 | } else if (hdr->dxfer_len) | 351 | } else if (hdr->dxfer_len) |
361 | ret = blk_rq_map_user(q, rq, NULL, hdr->dxferp, hdr->dxfer_len, | 352 | ret = blk_rq_map_user(q, rq, NULL, hdr->dxferp, hdr->dxfer_len, |