vhost: lock receive queue, not the socket
authorJason Wang <jasowang@redhat.com>
Mon, 17 Jan 2011 08:11:17 +0000 (16:11 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Sun, 13 Mar 2011 21:08:04 +0000 (23:08 +0200)
vhost takes a sock lock to try and prevent
the skb from being pulled from the receive queue
after skb_peek.  However this is not the right lock to use for that,
sk_receive_queue.lock is. Fix that up.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
drivers/vhost/net.c

index 0329c41..5720301 100644 (file)
@@ -213,12 +213,13 @@ static int peek_head_len(struct sock *sk)
 {
        struct sk_buff *head;
        int len = 0;
+       unsigned long flags;
 
-       lock_sock(sk);
+       spin_lock_irqsave(&sk->sk_receive_queue.lock, flags);
        head = skb_peek(&sk->sk_receive_queue);
-       if (head)
+       if (likely(head))
                len = head->len;
-       release_sock(sk);
+       spin_unlock_irqrestore(&sk->sk_receive_queue.lock, flags);
        return len;
 }