aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/vhost
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2011-11-27 12:05:58 -0500
committerMichael S. Tsirkin <mst@redhat.com>2012-02-28 02:13:22 -0500
commitea5d404655ba3b356d0c06d6a3c4f24112124522 (patch)
tree092a40fd222d3565ca4b5188c85dba65c1305583 /drivers/vhost
parentd550dda192c1bd039afb774b99485e88b70d7cb8 (diff)
vhost: fix release path lockdep checks
We shouldn't hold any locks on release path. Pass a flag to vhost_dev_cleanup to use the lockdep info correctly. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Tested-by: Sasha Levin <levinsasha928@gmail.com>
Diffstat (limited to 'drivers/vhost')
-rw-r--r--drivers/vhost/net.c2
-rw-r--r--drivers/vhost/vhost.c9
-rw-r--r--drivers/vhost/vhost.h2
3 files changed, 7 insertions, 6 deletions
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index 9dab1f51dd43..f0da2c32fbde 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -588,7 +588,7 @@ static int vhost_net_release(struct inode *inode, struct file *f)
588 588
589 vhost_net_stop(n, &tx_sock, &rx_sock); 589 vhost_net_stop(n, &tx_sock, &rx_sock);
590 vhost_net_flush(n); 590 vhost_net_flush(n);
591 vhost_dev_cleanup(&n->dev); 591 vhost_dev_cleanup(&n->dev, false);
592 if (tx_sock) 592 if (tx_sock)
593 fput(tx_sock->file); 593 fput(tx_sock->file);
594 if (rx_sock) 594 if (rx_sock)
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c
index ae66278e4dcf..385d8ee0d2d1 100644
--- a/drivers/vhost/vhost.c
+++ b/drivers/vhost/vhost.c
@@ -405,7 +405,7 @@ long vhost_dev_reset_owner(struct vhost_dev *dev)
405 if (!memory) 405 if (!memory)
406 return -ENOMEM; 406 return -ENOMEM;
407 407
408 vhost_dev_cleanup(dev); 408 vhost_dev_cleanup(dev, true);
409 409
410 memory->nregions = 0; 410 memory->nregions = 0;
411 RCU_INIT_POINTER(dev->memory, memory); 411 RCU_INIT_POINTER(dev->memory, memory);
@@ -436,8 +436,8 @@ int vhost_zerocopy_signal_used(struct vhost_virtqueue *vq)
436 return j; 436 return j;
437} 437}
438 438
439/* Caller should have device mutex */ 439/* Caller should have device mutex if and only if locked is set */
440void vhost_dev_cleanup(struct vhost_dev *dev) 440void vhost_dev_cleanup(struct vhost_dev *dev, bool locked)
441{ 441{
442 int i; 442 int i;
443 443
@@ -474,7 +474,8 @@ void vhost_dev_cleanup(struct vhost_dev *dev)
474 dev->log_file = NULL; 474 dev->log_file = NULL;
475 /* No one will access memory at this point */ 475 /* No one will access memory at this point */
476 kfree(rcu_dereference_protected(dev->memory, 476 kfree(rcu_dereference_protected(dev->memory,
477 lockdep_is_held(&dev->mutex))); 477 locked ==
478 lockdep_is_held(&dev->mutex)));
478 RCU_INIT_POINTER(dev->memory, NULL); 479 RCU_INIT_POINTER(dev->memory, NULL);
479 WARN_ON(!list_empty(&dev->work_list)); 480 WARN_ON(!list_empty(&dev->work_list));
480 if (dev->worker) { 481 if (dev->worker) {
diff --git a/drivers/vhost/vhost.h b/drivers/vhost/vhost.h
index a801e2821d03..8dcf4cca6bf2 100644
--- a/drivers/vhost/vhost.h
+++ b/drivers/vhost/vhost.h
@@ -163,7 +163,7 @@ struct vhost_dev {
163long vhost_dev_init(struct vhost_dev *, struct vhost_virtqueue *vqs, int nvqs); 163long vhost_dev_init(struct vhost_dev *, struct vhost_virtqueue *vqs, int nvqs);
164long vhost_dev_check_owner(struct vhost_dev *); 164long vhost_dev_check_owner(struct vhost_dev *);
165long vhost_dev_reset_owner(struct vhost_dev *); 165long vhost_dev_reset_owner(struct vhost_dev *);
166void vhost_dev_cleanup(struct vhost_dev *); 166void vhost_dev_cleanup(struct vhost_dev *, bool locked);
167long vhost_dev_ioctl(struct vhost_dev *, unsigned int ioctl, unsigned long arg); 167long vhost_dev_ioctl(struct vhost_dev *, unsigned int ioctl, unsigned long arg);
168int vhost_vq_access_ok(struct vhost_virtqueue *vq); 168int vhost_vq_access_ok(struct vhost_virtqueue *vq);
169int vhost_log_access_ok(struct vhost_dev *); 169int vhost_log_access_ok(struct vhost_dev *);