From mboxrd@z Thu Jan 1 00:00:00 1970 From: piaojun Subject: Re: [V9fs-developer] [PATCH] net/9p: avoid request size exceed to the virtqueue number in the zero copy Date: Mon, 6 Aug 2018 16:32:59 +0800 Message-ID: <5B6807BB.9010803@huawei.com> References: <5B63FB4D.1050703@huawei.com> Mime-Version: 1.0 Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Cc: , Linux Kernel Mailing List , To: jiangyiwen , Eric Van Hensbergen , Ron Minnich , Latchesar Ionkov , Dominique Martinet Return-path: In-Reply-To: <5B63FB4D.1050703@huawei.com> Sender: linux-kernel-owner@vger.kernel.org List-Id: netdev.vger.kernel.org Hi Yiwen, On 2018/8/3 14:50, jiangyiwen wrote: > Unfortunately, when the address(input and response headers) are not > at page boundary, it will need two extra entry in the zero copy, or > else it will cause sg array out of bounds. > > To avoid the problem, we should subtract two pages for maxsize. > > Signed-off-by: Yiwen Jiang > --- > net/9p/trans_virtio.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c > index 6265d1d..63591b2 100644 > --- a/net/9p/trans_virtio.c > +++ b/net/9p/trans_virtio.c > @@ -754,11 +754,12 @@ static void p9_virtio_remove(struct virtio_device *vdev) > .cancel = p9_virtio_cancel, > /* > * We leave one entry for input and one entry for response > - * headers. We also skip one more entry to accomodate, address > - * that are not at page boundary, that can result in an extra > - * page in zero copy. > + * headers. We also skip three more entrys to accomodate > + * (input + response headers + data pages), address > + * that are not at page boundary, that can result in > + * an extra page in zero copy. Here should be two extra pages. Thanks, Jun > */ > - .maxsize = PAGE_SIZE * (VIRTQUEUE_NUM - 3), > + .maxsize = PAGE_SIZE * (VIRTQUEUE_NUM - 5), > .def = 1, > .owner = THIS_MODULE, > }; >