diff options
author | Christoph Hellwig <hch@lst.de> | 2016-07-19 05:31:49 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2016-07-20 19:38:29 -0400 |
commit | f9596695bee6a88d17118ee9f2f826f96b826644 (patch) | |
tree | 95375f2d42332471400ac5ce73343e50aad016ef | |
parent | 4eef39c90665fe73689b176dcd8cdff4a9a91274 (diff) |
virtio_blk: use blk_rq_map_kern
Similar to how SCSI and NVMe prepare passthrough requests. This avoids
poking into request internals too much.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r-- | drivers/block/virtio_blk.c | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 5fd2e0ac2711..a85a14355efa 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c | |||
@@ -236,25 +236,23 @@ static int virtio_queue_rq(struct blk_mq_hw_ctx *hctx, | |||
236 | static int virtblk_get_id(struct gendisk *disk, char *id_str) | 236 | static int virtblk_get_id(struct gendisk *disk, char *id_str) |
237 | { | 237 | { |
238 | struct virtio_blk *vblk = disk->private_data; | 238 | struct virtio_blk *vblk = disk->private_data; |
239 | struct request_queue *q = vblk->disk->queue; | ||
239 | struct request *req; | 240 | struct request *req; |
240 | struct bio *bio; | ||
241 | int err; | 241 | int err; |
242 | 242 | ||
243 | bio = bio_map_kern(vblk->disk->queue, id_str, VIRTIO_BLK_ID_BYTES, | 243 | req = blk_get_request(q, READ, GFP_KERNEL); |
244 | GFP_KERNEL); | 244 | if (IS_ERR(req)) |
245 | if (IS_ERR(bio)) | ||
246 | return PTR_ERR(bio); | ||
247 | |||
248 | req = blk_make_request(vblk->disk->queue, bio, GFP_KERNEL); | ||
249 | if (IS_ERR(req)) { | ||
250 | bio_put(bio); | ||
251 | return PTR_ERR(req); | 245 | return PTR_ERR(req); |
252 | } | 246 | blk_rq_set_block_pc(req); |
253 | |||
254 | req->cmd_type = REQ_TYPE_DRV_PRIV; | 247 | req->cmd_type = REQ_TYPE_DRV_PRIV; |
248 | |||
249 | err = blk_rq_map_kern(q, req, id_str, VIRTIO_BLK_ID_BYTES, GFP_KERNEL); | ||
250 | if (err) | ||
251 | goto out; | ||
252 | |||
255 | err = blk_execute_rq(vblk->disk->queue, vblk->disk, req, false); | 253 | err = blk_execute_rq(vblk->disk->queue, vblk->disk, req, false); |
254 | out: | ||
256 | blk_put_request(req); | 255 | blk_put_request(req); |
257 | |||
258 | return err; | 256 | return err; |
259 | } | 257 | } |
260 | 258 | ||