Heinz Graalfs <[email protected]> writes:
> Deleting the disk and partitions in virtblk_remove() via del_gendisk() causes
> never ending waits when trying to synch dirty inode pages.
>
> A dummy virtqueue_notify() in virtblk_remove() is used to detect a host
> notification error, latter occurs when block device was hot-unplugged.
> When the dummy host kick failed blk_cleanup_queue() should be invoked
> prior to del_gendisk().
>
> Signed-off-by: Heinz Graalfs <[email protected]>
> ---
>  drivers/block/virtio_blk.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
> index 6472395..98f081a 100644
> --- a/drivers/block/virtio_blk.c
> +++ b/drivers/block/virtio_blk.c
> @@ -880,8 +880,14 @@ static void virtblk_remove(struct virtio_device *vdev)
>       vblk->config_enable = false;
>       mutex_unlock(&vblk->config_lock);
>  
> -     del_gendisk(vblk->disk);
> -     blk_cleanup_queue(vblk->disk->queue);
> +     virtqueue_notify(vblk->vq);
> +     if (virtqueue_is_broken(vblk->vq)) {
> +             blk_cleanup_queue(vblk->disk->queue);
> +             del_gendisk(vblk->disk);
> +     } else {
> +             del_gendisk(vblk->disk);
> +             blk_cleanup_queue(vblk->disk->queue);
> +     }

This seems horribly wrong.  Firstly, it's ugly to have a gratuitous
kick.  Secondly, it's racy: what if there's a hot unplug (or other
failure) after your virtqueue_is_broken() test?  We should be doing I/O
failures which should be handled by del_gendisk() correctly.

Cheers,
Rusty.
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

Reply via email to