aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2012-05-21 23:20:23 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-05-21 23:20:23 -0400
commit99262a3dafa3290866512ddfb32609198f8973e9 (patch)
tree6f74764150cd9c38d9ffacbeb5054b696537e154 /drivers/block
parentbf67f3a5c456a18f2e8d062f7e88506ef2cd9837 (diff)
parentc6190804f1dc5357b57825f0491eb31fc9ccf130 (diff)
Merge tag 'virtio-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus
Pull virtio updates from Rusty Russell. * tag 'virtio-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux-2.6-for-linus: virtio: fix typo in comment virtio-mmio: Devices parameter parsing virtio_blk: Drop unused request tracking list virtio-blk: Fix hot-unplug race in remove method virtio: Use ida to allocate virtio index virtio: balloon: separate out common code between remove and freeze functions virtio: balloon: drop restore_common() 9p: disconnect channel when PCI device is removed virtio: update documentation to v0.9.5 of spec
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/virtio_blk.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 0d39f2f4294a..693187df7601 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -29,9 +29,6 @@ struct virtio_blk
29 /* The disk structure for the kernel. */ 29 /* The disk structure for the kernel. */
30 struct gendisk *disk; 30 struct gendisk *disk;
31 31
32 /* Request tracking. */
33 struct list_head reqs;
34
35 mempool_t *pool; 32 mempool_t *pool;
36 33
37 /* Process context for config space updates */ 34 /* Process context for config space updates */
@@ -55,7 +52,6 @@ struct virtio_blk
55 52
56struct virtblk_req 53struct virtblk_req
57{ 54{
58 struct list_head list;
59 struct request *req; 55 struct request *req;
60 struct virtio_blk_outhdr out_hdr; 56 struct virtio_blk_outhdr out_hdr;
61 struct virtio_scsi_inhdr in_hdr; 57 struct virtio_scsi_inhdr in_hdr;
@@ -99,7 +95,6 @@ static void blk_done(struct virtqueue *vq)
99 } 95 }
100 96
101 __blk_end_request_all(vbr->req, error); 97 __blk_end_request_all(vbr->req, error);
102 list_del(&vbr->list);
103 mempool_free(vbr, vblk->pool); 98 mempool_free(vbr, vblk->pool);
104 } 99 }
105 /* In case queue is stopped waiting for more buffers. */ 100 /* In case queue is stopped waiting for more buffers. */
@@ -184,7 +179,6 @@ static bool do_req(struct request_queue *q, struct virtio_blk *vblk,
184 return false; 179 return false;
185 } 180 }
186 181
187 list_add_tail(&vbr->list, &vblk->reqs);
188 return true; 182 return true;
189} 183}
190 184
@@ -437,7 +431,6 @@ static int __devinit virtblk_probe(struct virtio_device *vdev)
437 goto out_free_index; 431 goto out_free_index;
438 } 432 }
439 433
440 INIT_LIST_HEAD(&vblk->reqs);
441 spin_lock_init(&vblk->lock); 434 spin_lock_init(&vblk->lock);
442 vblk->vdev = vdev; 435 vblk->vdev = vdev;
443 vblk->sg_elems = sg_elems; 436 vblk->sg_elems = sg_elems;
@@ -583,21 +576,29 @@ static void __devexit virtblk_remove(struct virtio_device *vdev)
583{ 576{
584 struct virtio_blk *vblk = vdev->priv; 577 struct virtio_blk *vblk = vdev->priv;
585 int index = vblk->index; 578 int index = vblk->index;
579 struct virtblk_req *vbr;
580 unsigned long flags;
586 581
587 /* Prevent config work handler from accessing the device. */ 582 /* Prevent config work handler from accessing the device. */
588 mutex_lock(&vblk->config_lock); 583 mutex_lock(&vblk->config_lock);
589 vblk->config_enable = false; 584 vblk->config_enable = false;
590 mutex_unlock(&vblk->config_lock); 585 mutex_unlock(&vblk->config_lock);
591 586
592 /* Nothing should be pending. */
593 BUG_ON(!list_empty(&vblk->reqs));
594
595 /* Stop all the virtqueues. */ 587 /* Stop all the virtqueues. */
596 vdev->config->reset(vdev); 588 vdev->config->reset(vdev);
597 589
598 flush_work(&vblk->config_work); 590 flush_work(&vblk->config_work);
599 591
600 del_gendisk(vblk->disk); 592 del_gendisk(vblk->disk);
593
594 /* Abort requests dispatched to driver. */
595 spin_lock_irqsave(&vblk->lock, flags);
596 while ((vbr = virtqueue_detach_unused_buf(vblk->vq))) {
597 __blk_end_request_all(vbr->req, -EIO);
598 mempool_free(vbr, vblk->pool);
599 }
600 spin_unlock_irqrestore(&vblk->lock, flags);
601
601 blk_cleanup_queue(vblk->disk->queue); 602 blk_cleanup_queue(vblk->disk->queue);
602 put_disk(vblk->disk); 603 put_disk(vblk->disk);
603 mempool_destroy(vblk->pool); 604 mempool_destroy(vblk->pool);