From: "Michael S. Tsirkin" <mst@redhat.com>
To: Jason Wang <jasowang@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
wangyunjian@huawei.com
Subject: Re: [PATCH net 2/2] macvtap: handle ubuf refcount correctly when meet erros
Date: Wed, 30 Nov 2016 15:58:05 +0200 [thread overview]
Message-ID: <20161130155758-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <1480483072-14201-2-git-send-email-jasowang@redhat.com>
On Wed, Nov 30, 2016 at 01:17:52PM +0800, Jason Wang wrote:
> We trigger uarg->callback() immediately after we decide do datacopy
> even if caller want to do zerocopy. This will cause the callback
> (vhost_net_zerocopy_callback) decrease the refcount. But when we meet
> an error afterwards, the error handling in vhost handle_tx() will try
> to decrease it again. This is wrong and fix this by delay the
> uarg->callback() until we're sure there's no errors.
>
> Signed-off-by: Jason Wang <jasowang@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
> ---
> The patch is needed for -stable.
> ---
> drivers/net/macvtap.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/macvtap.c b/drivers/net/macvtap.c
> index bceca28..7869b06 100644
> --- a/drivers/net/macvtap.c
> +++ b/drivers/net/macvtap.c
> @@ -742,13 +742,8 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
>
> if (zerocopy)
> err = zerocopy_sg_from_iter(skb, from);
> - else {
> + else
> err = skb_copy_datagram_from_iter(skb, 0, from, len);
> - if (!err && m && m->msg_control) {
> - struct ubuf_info *uarg = m->msg_control;
> - uarg->callback(uarg, false);
> - }
> - }
>
> if (err)
> goto err_kfree;
> @@ -779,7 +774,11 @@ static ssize_t macvtap_get_user(struct macvtap_queue *q, struct msghdr *m,
> skb_shinfo(skb)->destructor_arg = m->msg_control;
> skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY;
> skb_shinfo(skb)->tx_flags |= SKBTX_SHARED_FRAG;
> + } else if (m && m->msg_control) {
> + struct ubuf_info *uarg = m->msg_control;
> + uarg->callback(uarg, false);
> }
> +
> if (vlan) {
> skb->dev = vlan->dev;
> dev_queue_xmit(skb);
> --
> 2.7.4
next prev parent reply other threads:[~2016-11-30 13:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-30 5:17 [PATCH net 1/2] tun: handle ubuf refcount correctly when meet erros Jason Wang
2016-11-30 5:17 ` [PATCH net 2/2] macvtap: " Jason Wang
2016-11-30 13:58 ` Michael S. Tsirkin [this message]
2016-11-30 13:57 ` [PATCH net 1/2] tun: " Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161130155758-mutt-send-email-mst@kernel.org \
--to=mst@redhat.com \
--cc=jasowang@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=wangyunjian@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.