]> Pileus Git - ~andy/linux/commitdiff
vhost-net: avoid flush under lock
authorMichael S. Tsirkin <mst@redhat.com>
Thu, 15 Jul 2010 12:19:12 +0000 (15:19 +0300)
committerMichael S. Tsirkin <mst@redhat.com>
Thu, 15 Jul 2010 12:26:12 +0000 (15:26 +0300)
We flush under vq mutex when changing backends.
This creates a deadlock as workqueue being flushed
needs this lock as well.

https://bugzilla.redhat.com/show_bug.cgi?id=612421

Drop the vq mutex before flush: we have the device mutex
which is sufficient to prevent another ioctl from touching
the vq.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/vhost/net.c

index 2406377a6e5eac8b848b52e5e5d3d6a37bceb3b7..2764e0fbf29b957be432a210b349ce06000e8472 100644 (file)
@@ -534,11 +534,16 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd)
        rcu_assign_pointer(vq->private_data, sock);
        vhost_net_enable_vq(n, vq);
 done:
+       mutex_unlock(&vq->mutex);
+
        if (oldsock) {
                vhost_net_flush_vq(n, index);
                fput(oldsock->file);
        }
 
+       mutex_unlock(&n->dev.mutex);
+       return 0;
+
 err_vq:
        mutex_unlock(&vq->mutex);
 err: