Skip to content

Commit

Permalink
vhost-net: avoid flush under lock
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Michael S. Tsirkin committed Jul 15, 2010
1 parent 7b3384f commit 1680e90
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/vhost/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 1680e90

Please sign in to comment.