Message ID | 20190717105255.63488-8-jasowang@redhat.com |
---|---|
State | New, archived |
Headers | show |
Series |
|
Related | show |
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index cf47e6e348f4..1a67f889cbc1 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -1065,12 +1065,12 @@ static int get_rx_bufs(struct vhost_virtqueue *vq, } heads[headcount].id = cpu_to_vhost32(vq, d); len = iov_length(vq->iov + seg, in); - heads[headcount].len = cpu_to_vhost32(vq, len); datalen -= len; + heads[headcount].len = cpu_to_vhost32(vq, + datalen >= 0 ? len : len + datalen); ++headcount; seg += in; } - heads[headcount - 1].len = cpu_to_vhost32(vq, len + datalen); *iovcount = seg; if (unlikely(log)) *log_num = nlogs;
This patch tries to calculate last used length once instead of twice. This can help to convert to use shadow used ring API for RX. Signed-off-by: Jason Wang <jasowang@redhat.com> --- drivers/vhost/net.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)