From: Benny Halevy <bhalevy@panasas.com>
To: Trond Myklebust <trond.myklebust@fys.uio.no>
Cc: linux-nfs@vger.kernel.org
Subject: Re: [PATCH 1/4] sunrpc: don't shorten buflen twice in xdr_shrink_pagelen
Date: Thu, 19 Aug 2010 08:49:19 +0300 [thread overview]
Message-ID: <4C6CC5DF.7060708@panasas.com> (raw)
In-Reply-To: <1282169797.8540.125.camel@heimdal.trondhjem.org>
On Aug. 19, 2010, 1:16 +0300, Trond Myklebust <trond.myklebust@fys.uio.no> wrote:
> On Wed, 2010-08-18 at 17:26 -0400, Trond Myklebust wrote:
>> On Wed, 2010-08-18 at 23:42 +0300, Benny Halevy wrote:
>>> On Jan. 14, 2009, 2:50 +0200, andros@netapp.com wrote:
>>>> From: Andy Adamson <andros@netapp.com>
>>>>
>>>> The buflen is reset for all cases at the end of xdr_shrink_pagelen.
>>>> The data left in the tail after xdr_read_pages is not processed when the
>>>> buflen is incorrectly set.
>>>
>>> Note that in this case we also lose (len - tail->iov_len)
>>> bytes from the buffered data in pages.
>>
>> We don't really need to do that. The amount of free space in the tail
>> (as opposed to space occupied by data) can be calculated as:
>>
>> buf->buflen - buf->head->iov_len - buf->page_len - buf->tail->iov_len;
>>
> Something like the following:
>
> ---------------------------------------------------------------------------------------------
> SUNRPC: Don't truncate tail data unnecessarily in xdr_shrink_pagelen
>
> From: Trond Myklebust <Trond.Myklebust@netapp.com>
>
> If we have unused buffer space, then we should make use of that rather
> than unnecessarily truncating the message.
Makes sense.
The patch looks good to me.
Benny
>
> Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
> ---
>
> net/sunrpc/xdr.c | 11 ++++++++++-
> 1 files changed, 10 insertions(+), 1 deletions(-)
>
>
> diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
> index 3317db3..3bbef7f 100644
> --- a/net/sunrpc/xdr.c
> +++ b/net/sunrpc/xdr.c
> @@ -396,12 +396,21 @@ xdr_shrink_pagelen(struct xdr_buf *buf, size_t len)
> struct kvec *tail;
> size_t copy;
> unsigned int pglen = buf->page_len;
> + unsigned int tailbuf_len;
>
> tail = buf->tail;
> BUG_ON (len > pglen);
>
> + tailbuf_len = buf->buflen - buf->head->iov_len - buf->page_len;
> +
> /* Shift the tail first */
> - if (tail->iov_len != 0) {
> + if (tailbuf_len != 0) {
> + unsigned int free_space = tailbuf_len - tail->iov_len;
> +
> + if (len < free_space)
> + free_space = len;
> + tail->iov_len += free_space;
> +
> copy = len;
> if (tail->iov_len > len) {
> char *p = (char *)tail->iov_base + len;
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2010-08-19 5:49 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-18 20:41 [PATCH 0/4] fix up xdr_shrink_pagelen Benny Halevy
2010-08-18 20:42 ` [PATCH 1/4] sunrpc: don't shorten buflen twice in xdr_shrink_pagelen Benny Halevy
2010-08-18 21:26 ` Trond Myklebust
2010-08-18 22:16 ` Trond Myklebust
2010-08-19 5:49 ` Benny Halevy [this message]
2010-08-18 20:42 ` [PATCH 2/4] sunrpc: clean up xdr_shrink_pagelen use of temporary pointer Benny Halevy
2010-08-18 20:42 ` [PATCH 3/4] sunrpc: don't use the copy variable in nested block Benny Halevy
2010-08-18 20:43 ` [PATCH 4/4] sunrpc: simplify xdr_shrijk_pagelen use of "copy" Benny Halevy
2010-08-18 21:19 ` Trond Myklebust
2010-08-19 5:39 ` Benny Halevy
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=4C6CC5DF.7060708@panasas.com \
--to=bhalevy@panasas.com \
--cc=linux-nfs@vger.kernel.org \
--cc=trond.myklebust@fys.uio.no \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).