All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Asias He <asias@redhat.com>
Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org
Subject: Re: [PATCH 1/3] virtio-blk: Call del_gendisk() before disable guest kick
Date: Fri, 25 May 2012 10:07:48 +0300	[thread overview]
Message-ID: <20120525070747.GG15474@redhat.com> (raw)
In-Reply-To: <1337913289-23486-2-git-send-email-asias@redhat.com>

On Fri, May 25, 2012 at 10:34:47AM +0800, Asias He wrote:
> 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: Rusty Russell <rusty@rustcorp.com.au>
> Cc: "Michael S. Tsirkin" <mst@redhat.com>
> Cc: virtualization@lists.linux-foundation.org
> Cc: kvm@vger.kernel.org
> Signed-off-by: Asias He <asias@redhat.com>


Acked-by: Michael S. Tsirkin <mst@redhat.com>

> ---
>  drivers/block/virtio_blk.c |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
> index 693187d..1bed517 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)
>  	vblk->config_enable = false;
>  	mutex_unlock(&vblk->config_lock);
>  
> +	del_gendisk(vblk->disk);
> +
>  	/* Stop all the virtqueues. */
>  	vdev->config->reset(vdev);
>  
>  	flush_work(&vblk->config_work);
>  
> -	del_gendisk(vblk->disk);
> -
>  	/* Abort requests dispatched to driver. */
>  	spin_lock_irqsave(&vblk->lock, flags);
>  	while ((vbr = virtqueue_detach_unused_buf(vblk->vq))) {
> -- 
> 1.7.10.2

  reply	other threads:[~2012-05-25  7:07 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-25  2:34 [PATCH 0/3] Fix hot-unplug race in virtio-blk Asias He
2012-05-25  2:34 ` [PATCH 1/3] virtio-blk: Call del_gendisk() before disable guest kick Asias He
2012-05-25  7:07   ` Michael S. Tsirkin [this message]
2012-05-25  2:34 ` Asias He
2012-05-25  2:34 ` [PATCH 2/3] virtio-blk: Reset device after blk_cleanup_queue() Asias He
2012-05-25  2:34 ` Asias He
2012-05-25  6:52   ` Michael S. Tsirkin
2012-05-25  7:03     ` Asias He
2012-05-25  7:06       ` Michael S. Tsirkin
2012-05-25  7:06       ` Michael S. Tsirkin
2012-05-25  7:08   ` Michael S. Tsirkin
2012-05-25  2:34 ` [PATCH 3/3] virtio-blk: Use block layer provided spinlock Asias He
2012-05-25  7:02   ` Michael S. Tsirkin
2012-05-25  7:23     ` Asias He
2012-05-25  8:03     ` [PATCH v2 " Asias He
2012-05-25 13:10       ` Michael S. Tsirkin
2012-06-01  8:49       ` Michael S. Tsirkin
2012-05-25  2:34 ` [PATCH " Asias He
2012-06-04  0:41 ` [PATCH 0/3] Fix hot-unplug race in virtio-blk Rusty Russell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120525070747.GG15474@redhat.com \
    --to=mst@redhat.com \
    --cc=asias@redhat.com \
    --cc=kvm@vger.kernel.org \
    --cc=virtualization@lists.linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.