]> git.baikalelectronics.ru Git - kernel.git/commit
tuntap: do not zerocopy if iov needs more pages than MAX_SKB_FRAGS
authorJason Wang <jasowang@redhat.com>
Thu, 18 Jul 2013 02:55:15 +0000 (10:55 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 18 Jul 2013 20:04:25 +0000 (13:04 -0700)
commit40571dceae8b604e52849150a9372a4c10a60aec
tree832392fed4bc4e2deebebae235d46debf5b15fc5
parent3fe13962928a6a337fc92db6821b42d6fad1a261
tuntap: do not zerocopy if iov needs more pages than MAX_SKB_FRAGS

We try to linearize part of the skb when the number of iov is greater than
MAX_SKB_FRAGS. This is not enough since each single vector may occupy more than
one pages, so zerocopy_sg_fromiovec() may still fail and may break the guest
network.

Solve this problem by calculate the pages needed for iov before trying to do
zerocopy and switch to use copy instead of zerocopy if it needs more than
MAX_SKB_FRAGS.

This is done through introducing a new helper to count the pages for iov, and
call uarg->callback() manually when switching from zerocopy to copy to notify
vhost.

We can do further optimization on top.

The bug were introduced from commit d63657f3214639cefbfb8c5ee2ae189e6231a63b
(tun: experimental zero copy tx support)

Cc: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/tun.c