Re: [PATCH 06/17] switch macvtap to ->read_iter()

From: Ben Hutchings
Date: Sun Nov 23 2014 - 18:30:23 EST


On Sat, 2014-11-22 at 04:32 +0000, Al Viro wrote:
> Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
> ---
> drivers/net/macvtap.c | 39 ++++++++++++++++-----------------------
> 1 file changed, 16 insertions(+), 23 deletions(-)
>
> diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
> index cea99d4..cdd820f 100644
> --- a/drivers/net/macvtap.c
> +++ b/drivers/net/macvtap.c
> @@ -829,16 +829,17 @@ done:
> }
>
> static ssize_t macvtap_do_read(struct macvtap_queue *q,
> - const struct iovec *iv, unsigned long segs,
> - unsigned long len,
> + struct iov_iter *to,
> int noblock)
> {
> DEFINE_WAIT(wait);
> struct sk_buff *skb;
> ssize_t ret = 0;
> - struct iov_iter iter;
>
> - while (len) {
> + if (!iov_iter_count(to))
> + return 0;
> +
> + while (1) {
> if (!noblock)
> prepare_to_wait(sk_sleep(&q->sk), &wait,
> TASK_INTERRUPTIBLE);
> @@ -856,37 +857,27 @@ static ssize_t macvtap_do_read(struct macvtap_queue *q,
> }
> /* Nothing to read, let's sleep */
> schedule();
> - continue;
> }
> - iov_iter_init(&iter, READ, iv, segs, len);
> - ret = macvtap_put_user(q, skb, &iter);
> + }
> + if (skb) {
> + ret = macvtap_put_user(q, skb, to);
> kfree_skb(skb);
> - break;
[...]

You need to leave this break at the bottom of the loop body, or change
it to:

do {
...
} while (!skb);

Ben.

--
Ben Hutchings
Never put off till tomorrow what you can avoid all together.

Attachment: signature.asc
Description: This is a digitally signed message part