diff options
author | Asias He <asias@redhat.com> | 2012-05-24 22:34:47 -0400 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2012-07-30 00:00:51 -0400 |
commit | 02e2b124943648fba0a2ccee5c3656a5653e0151 (patch) | |
tree | d93d06c9d3ba8c94015017040c0c5c7185f3ffc3 /drivers/block | |
parent | 0bc1a2ef19b45bb23617b203bc631b44609f17ba (diff) |
virtio-blk: Call del_gendisk() before disable guest kick
del_gendisk() might not return due to failing to remove the
/sys/block/vda/serial sysfs entry when another thread (udev) is
trying to read it.
virtblk_remove()
vdev->config->reset() : guest will not kick us through interrupt
del_gendisk()
device_del()
kobject_del(): got stuck, sysfs entry ref count non zero
sysfs_open_file(): user space process read /sys/block/vda/serial
sysfs_get_active() : got sysfs entry ref count
dev_attr_show()
virtblk_serial_show()
blk_execute_rq() : got stuck, interrupt is disabled
request cannot be finished
This patch fixes it by calling del_gendisk() before we disable guest's
interrupt so that the request sent in virtblk_serial_show() will be
finished and del_gendisk() will success.
This fixes another race in hot-unplug process.
It is save to call del_gendisk(vblk->disk) before
flush_work(&vblk->config_work) which might access vblk->disk, because
vblk->disk is not freed until put_disk(vblk->disk).
Cc: virtualization@lists.linux-foundation.org
Cc: kvm@vger.kernel.org
Cc: stable@kernel.org
Signed-off-by: Asias He <asias@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'drivers/block')
-rw-r--r-- | drivers/block/virtio_blk.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c index 693187df7601..1bed51712dd1 100644 --- a/drivers/block/virtio_blk.c +++ b/drivers/block/virtio_blk.c | |||
@@ -584,13 +584,13 @@ static void __devexit virtblk_remove(struct virtio_device *vdev) | |||
584 | vblk->config_enable = false; | 584 | vblk->config_enable = false; |
585 | mutex_unlock(&vblk->config_lock); | 585 | mutex_unlock(&vblk->config_lock); |
586 | 586 | ||
587 | del_gendisk(vblk->disk); | ||
588 | |||
587 | /* Stop all the virtqueues. */ | 589 | /* Stop all the virtqueues. */ |
588 | vdev->config->reset(vdev); | 590 | vdev->config->reset(vdev); |
589 | 591 | ||
590 | flush_work(&vblk->config_work); | 592 | flush_work(&vblk->config_work); |
591 | 593 | ||
592 | del_gendisk(vblk->disk); | ||
593 | |||
594 | /* Abort requests dispatched to driver. */ | 594 | /* Abort requests dispatched to driver. */ |
595 | spin_lock_irqsave(&vblk->lock, flags); | 595 | spin_lock_irqsave(&vblk->lock, flags); |
596 | while ((vbr = virtqueue_detach_unused_buf(vblk->vq))) { | 596 | while ((vbr = virtqueue_detach_unused_buf(vblk->vq))) { |