提交 ea5d4046 编写于 作者: M Michael S. Tsirkin

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: NMichael S. Tsirkin <mst@redhat.com>
Tested-by: NSasha Levin <levinsasha928@gmail.com>
上级 d550dda1
...@@ -588,7 +588,7 @@ static int vhost_net_release(struct inode *inode, struct file *f) ...@@ -588,7 +588,7 @@ static int vhost_net_release(struct inode *inode, struct file *f)
vhost_net_stop(n, &tx_sock, &rx_sock); vhost_net_stop(n, &tx_sock, &rx_sock);
vhost_net_flush(n); vhost_net_flush(n);
vhost_dev_cleanup(&n->dev); vhost_dev_cleanup(&n->dev, false);
if (tx_sock) if (tx_sock)
fput(tx_sock->file); fput(tx_sock->file);
if (rx_sock) if (rx_sock)
......
...@@ -405,7 +405,7 @@ long vhost_dev_reset_owner(struct vhost_dev *dev) ...@@ -405,7 +405,7 @@ long vhost_dev_reset_owner(struct vhost_dev *dev)
if (!memory) if (!memory)
return -ENOMEM; return -ENOMEM;
vhost_dev_cleanup(dev); vhost_dev_cleanup(dev, true);
memory->nregions = 0; memory->nregions = 0;
RCU_INIT_POINTER(dev->memory, memory); RCU_INIT_POINTER(dev->memory, memory);
...@@ -436,8 +436,8 @@ int vhost_zerocopy_signal_used(struct vhost_virtqueue *vq) ...@@ -436,8 +436,8 @@ int vhost_zerocopy_signal_used(struct vhost_virtqueue *vq)
return j; return j;
} }
/* Caller should have device mutex */ /* Caller should have device mutex if and only if locked is set */
void vhost_dev_cleanup(struct vhost_dev *dev) void vhost_dev_cleanup(struct vhost_dev *dev, bool locked)
{ {
int i; int i;
...@@ -474,7 +474,8 @@ void vhost_dev_cleanup(struct vhost_dev *dev) ...@@ -474,7 +474,8 @@ void vhost_dev_cleanup(struct vhost_dev *dev)
dev->log_file = NULL; dev->log_file = NULL;
/* No one will access memory at this point */ /* No one will access memory at this point */
kfree(rcu_dereference_protected(dev->memory, kfree(rcu_dereference_protected(dev->memory,
lockdep_is_held(&dev->mutex))); locked ==
lockdep_is_held(&dev->mutex)));
RCU_INIT_POINTER(dev->memory, NULL); RCU_INIT_POINTER(dev->memory, NULL);
WARN_ON(!list_empty(&dev->work_list)); WARN_ON(!list_empty(&dev->work_list));
if (dev->worker) { if (dev->worker) {
......
...@@ -163,7 +163,7 @@ struct vhost_dev { ...@@ -163,7 +163,7 @@ struct vhost_dev {
long vhost_dev_init(struct vhost_dev *, struct vhost_virtqueue *vqs, int nvqs); long vhost_dev_init(struct vhost_dev *, struct vhost_virtqueue *vqs, int nvqs);
long vhost_dev_check_owner(struct vhost_dev *); long vhost_dev_check_owner(struct vhost_dev *);
long vhost_dev_reset_owner(struct vhost_dev *); long vhost_dev_reset_owner(struct vhost_dev *);
void vhost_dev_cleanup(struct vhost_dev *); void vhost_dev_cleanup(struct vhost_dev *, bool locked);
long vhost_dev_ioctl(struct vhost_dev *, unsigned int ioctl, unsigned long arg); long vhost_dev_ioctl(struct vhost_dev *, unsigned int ioctl, unsigned long arg);
int vhost_vq_access_ok(struct vhost_virtqueue *vq); int vhost_vq_access_ok(struct vhost_virtqueue *vq);
int vhost_log_access_ok(struct vhost_dev *); int vhost_log_access_ok(struct vhost_dev *);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册