macvtap: use prepare_to_wait/finish_wait to ensure mb
authorHong zhi guo <honkiko@gmail.com>
Wed, 6 Jun 2012 22:36:27 +0000 (22:36 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 7 Jun 2012 20:18:54 +0000 (13:18 -0700)
instead of raw assignment to current->state

Signed-off-by: Hong Zhiguo <honkiko@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/macvtap.c

index 2ee56de7b0cabc4d3611a93ee26a7218e2555958..0737bd4d16696e4a90475a124f17568f87eb2c14 100644 (file)
@@ -847,13 +847,12 @@ static ssize_t macvtap_do_read(struct macvtap_queue *q, struct kiocb *iocb,
                               const struct iovec *iv, unsigned long len,
                               int noblock)
 {
-       DECLARE_WAITQUEUE(wait, current);
+       DEFINE_WAIT(wait);
        struct sk_buff *skb;
        ssize_t ret = 0;
 
-       add_wait_queue(sk_sleep(&q->sk), &wait);
        while (len) {
-               current->state = TASK_INTERRUPTIBLE;
+               prepare_to_wait(sk_sleep(&q->sk), &wait, TASK_INTERRUPTIBLE);
 
                /* Read frames from the queue */
                skb = skb_dequeue(&q->sk.sk_receive_queue);
@@ -875,8 +874,7 @@ static ssize_t macvtap_do_read(struct macvtap_queue *q, struct kiocb *iocb,
                break;
        }
 
-       current->state = TASK_RUNNING;
-       remove_wait_queue(sk_sleep(&q->sk), &wait);
+       finish_wait(sk_sleep(&q->sk), &wait);
        return ret;
 }