diff options
Diffstat (limited to 'drivers/vhost/vsock.c')
-rw-r--r-- | drivers/vhost/vsock.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c index 98ed5be132c6..bc42d38ae031 100644 --- a/drivers/vhost/vsock.c +++ b/drivers/vhost/vsock.c | |||
@@ -27,14 +27,14 @@ enum { | |||
27 | }; | 27 | }; |
28 | 28 | ||
29 | /* Used to track all the vhost_vsock instances on the system. */ | 29 | /* Used to track all the vhost_vsock instances on the system. */ |
30 | static DEFINE_SPINLOCK(vhost_vsock_lock); | 30 | static DEFINE_MUTEX(vhost_vsock_mutex); |
31 | static DEFINE_READ_MOSTLY_HASHTABLE(vhost_vsock_hash, 8); | 31 | static DEFINE_READ_MOSTLY_HASHTABLE(vhost_vsock_hash, 8); |
32 | 32 | ||
33 | struct vhost_vsock { | 33 | struct vhost_vsock { |
34 | struct vhost_dev dev; | 34 | struct vhost_dev dev; |
35 | struct vhost_virtqueue vqs[2]; | 35 | struct vhost_virtqueue vqs[2]; |
36 | 36 | ||
37 | /* Link to global vhost_vsock_hash, writes use vhost_vsock_lock */ | 37 | /* Link to global vhost_vsock_hash, writes use vhost_vsock_mutex */ |
38 | struct hlist_node hash; | 38 | struct hlist_node hash; |
39 | 39 | ||
40 | struct vhost_work send_pkt_work; | 40 | struct vhost_work send_pkt_work; |
@@ -51,7 +51,7 @@ static u32 vhost_transport_get_local_cid(void) | |||
51 | return VHOST_VSOCK_DEFAULT_HOST_CID; | 51 | return VHOST_VSOCK_DEFAULT_HOST_CID; |
52 | } | 52 | } |
53 | 53 | ||
54 | /* Callers that dereference the return value must hold vhost_vsock_lock or the | 54 | /* Callers that dereference the return value must hold vhost_vsock_mutex or the |
55 | * RCU read lock. | 55 | * RCU read lock. |
56 | */ | 56 | */ |
57 | static struct vhost_vsock *vhost_vsock_get(u32 guest_cid) | 57 | static struct vhost_vsock *vhost_vsock_get(u32 guest_cid) |
@@ -584,10 +584,10 @@ static int vhost_vsock_dev_release(struct inode *inode, struct file *file) | |||
584 | { | 584 | { |
585 | struct vhost_vsock *vsock = file->private_data; | 585 | struct vhost_vsock *vsock = file->private_data; |
586 | 586 | ||
587 | spin_lock_bh(&vhost_vsock_lock); | 587 | mutex_lock(&vhost_vsock_mutex); |
588 | if (vsock->guest_cid) | 588 | if (vsock->guest_cid) |
589 | hash_del_rcu(&vsock->hash); | 589 | hash_del_rcu(&vsock->hash); |
590 | spin_unlock_bh(&vhost_vsock_lock); | 590 | mutex_unlock(&vhost_vsock_mutex); |
591 | 591 | ||
592 | /* Wait for other CPUs to finish using vsock */ | 592 | /* Wait for other CPUs to finish using vsock */ |
593 | synchronize_rcu(); | 593 | synchronize_rcu(); |
@@ -631,10 +631,10 @@ static int vhost_vsock_set_cid(struct vhost_vsock *vsock, u64 guest_cid) | |||
631 | return -EINVAL; | 631 | return -EINVAL; |
632 | 632 | ||
633 | /* Refuse if CID is already in use */ | 633 | /* Refuse if CID is already in use */ |
634 | spin_lock_bh(&vhost_vsock_lock); | 634 | mutex_lock(&vhost_vsock_mutex); |
635 | other = vhost_vsock_get(guest_cid); | 635 | other = vhost_vsock_get(guest_cid); |
636 | if (other && other != vsock) { | 636 | if (other && other != vsock) { |
637 | spin_unlock_bh(&vhost_vsock_lock); | 637 | mutex_unlock(&vhost_vsock_mutex); |
638 | return -EADDRINUSE; | 638 | return -EADDRINUSE; |
639 | } | 639 | } |
640 | 640 | ||
@@ -643,7 +643,7 @@ static int vhost_vsock_set_cid(struct vhost_vsock *vsock, u64 guest_cid) | |||
643 | 643 | ||
644 | vsock->guest_cid = guest_cid; | 644 | vsock->guest_cid = guest_cid; |
645 | hash_add_rcu(vhost_vsock_hash, &vsock->hash, guest_cid); | 645 | hash_add_rcu(vhost_vsock_hash, &vsock->hash, guest_cid); |
646 | spin_unlock_bh(&vhost_vsock_lock); | 646 | mutex_unlock(&vhost_vsock_mutex); |
647 | 647 | ||
648 | return 0; | 648 | return 0; |
649 | } | 649 | } |