浏览代码

virtio_blk: don't blindly derefence req->rq_disk

request->rq_disk is only set for FS requests or BLOCK_PC requests
originating from the generic block layer scsi ioctls.  It's not set
for requests origination from other soures or internal cache flush
commands implemented by the patch I'll send after this.

So instead of using it to get at the private data in do_virtblk_request
setup queue->queuedata and use it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Christoph Hellwig 16 年之前
父节点
当前提交
6c3b46f745
共有 1 个文件被更改,包括 2 次插入2 次删除
  1. 2 2
      drivers/block/virtio_blk.c

+ 2 - 2
drivers/block/virtio_blk.c

@@ -124,12 +124,11 @@ static bool do_req(struct request_queue *q, struct virtio_blk *vblk,
 
 
 static void do_virtblk_request(struct request_queue *q)
 static void do_virtblk_request(struct request_queue *q)
 {
 {
-	struct virtio_blk *vblk = NULL;
+	struct virtio_blk *vblk = q->queuedata;
 	struct request *req;
 	struct request *req;
 	unsigned int issued = 0;
 	unsigned int issued = 0;
 
 
 	while ((req = blk_peek_request(q)) != NULL) {
 	while ((req = blk_peek_request(q)) != NULL) {
-		vblk = req->rq_disk->private_data;
 		BUG_ON(req->nr_phys_segments + 2 > vblk->sg_elems);
 		BUG_ON(req->nr_phys_segments + 2 > vblk->sg_elems);
 
 
 		/* If this request fails, stop queue and wait for something to
 		/* If this request fails, stop queue and wait for something to
@@ -249,6 +248,7 @@ static int virtblk_probe(struct virtio_device *vdev)
 		goto out_put_disk;
 		goto out_put_disk;
 	}
 	}
 
 
+	vblk->disk->queue->queuedata = vblk;
 	queue_flag_set_unlocked(QUEUE_FLAG_VIRT, vblk->disk->queue);
 	queue_flag_set_unlocked(QUEUE_FLAG_VIRT, vblk->disk->queue);
 
 
 	if (index < 26) {
 	if (index < 26) {