virtio-blk: Call revalidate_disk() upon online disk resize
[pandora-kernel.git] / drivers / block / virtio_blk.c
index 4f018c4..c5f7b2c 100644 (file)
@@ -343,6 +343,7 @@ static void virtblk_config_changed_work(struct work_struct *work)
                  cap_str_10, cap_str_2);
 
        set_capacity(vblk->disk, capacity);
+       revalidate_disk(vblk->disk);
 done:
        mutex_unlock(&vblk->config_lock);
 }
@@ -546,8 +547,7 @@ static void __devexit virtblk_remove(struct virtio_device *vdev)
 {
        struct virtio_blk *vblk = vdev->priv;
        int index = vblk->index;
-       struct virtblk_req *vbr;
-       unsigned long flags;
+       int refc;
 
        /* Prevent config work handler from accessing the device. */
        mutex_lock(&vblk->config_lock);
@@ -555,26 +555,22 @@ static void __devexit virtblk_remove(struct virtio_device *vdev)
        mutex_unlock(&vblk->config_lock);
 
        del_gendisk(vblk->disk);
+       blk_cleanup_queue(vblk->disk->queue);
 
        /* Stop all the virtqueues. */
        vdev->config->reset(vdev);
 
        flush_work(&vblk->config_work);
 
-       /* Abort requests dispatched to driver. */
-       spin_lock_irqsave(&vblk->lock, flags);
-       while ((vbr = virtqueue_detach_unused_buf(vblk->vq))) {
-               __blk_end_request_all(vbr->req, -EIO);
-               mempool_free(vbr, vblk->pool);
-       }
-       spin_unlock_irqrestore(&vblk->lock, flags);
-
-       blk_cleanup_queue(vblk->disk->queue);
+       refc = atomic_read(&disk_to_dev(vblk->disk)->kobj.kref.refcount);
        put_disk(vblk->disk);
        mempool_destroy(vblk->pool);
        vdev->config->del_vqs(vdev);
        kfree(vblk);
-       ida_simple_remove(&vd_index_ida, index);
+
+       /* Only free device id if we don't have any users */
+       if (refc == 1)
+               ida_simple_remove(&vd_index_ida, index);
 }
 
 static const struct virtio_device_id id_table[] = {