Commit 1680e906 authored by Michael S. Tsirkin's avatar Michael S. Tsirkin

vhost-net: avoid flush under lock

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: default avatarMichael S. Tsirkin <mst@redhat.com>
parent 7b3384fc
...@@ -534,11 +534,16 @@ static long vhost_net_set_backend(struct vhost_net *n, unsigned index, int fd) ...@@ -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); rcu_assign_pointer(vq->private_data, sock);
vhost_net_enable_vq(n, vq); vhost_net_enable_vq(n, vq);
done: done:
mutex_unlock(&vq->mutex);
if (oldsock) { if (oldsock) {
vhost_net_flush_vq(n, index); vhost_net_flush_vq(n, index);
fput(oldsock->file); fput(oldsock->file);
} }
mutex_unlock(&n->dev.mutex);
return 0;
err_vq: err_vq:
mutex_unlock(&vq->mutex); mutex_unlock(&vq->mutex);
err: err:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment