virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] vhost-net: avoid flush under lock
@ 2010-07-15 12:19 Michael S. Tsirkin
  2010-07-15 12:37 ` Michael S. Tsirkin
  2010-07-15 18:17 ` Sridhar Samudrala
  0 siblings, 2 replies; 3+ messages in thread
From: Michael S. Tsirkin @ 2010-07-15 12:19 UTC (permalink / raw)
  Cc: Michael S. Tsirkin, Sridhar Samudrala, David S. Miller,
	Arnd Bergmann, Paul E. McKenney, kvm, virtualization, netdev,
	linux-kernel

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 |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 28d7786..50df58e6 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -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:
-- 
1.7.2.rc0.14.g41c1c

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-07-15 18:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-15 12:19 [PATCH] vhost-net: avoid flush under lock Michael S. Tsirkin
2010-07-15 12:37 ` Michael S. Tsirkin
2010-07-15 18:17 ` Sridhar Samudrala

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).