Skip to content

Commit

Permalink
SUNRPC: Don't truncate tail data unnecessarily in xdr_shrink_pagelen
Browse files Browse the repository at this point in the history
If we have unused buffer space, then we should make use of that rather
than unnecessarily truncating the message.

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
  • Loading branch information
Trond Myklebust authored and Trond Myklebust committed Aug 29, 2010
1 parent 42d6d8a commit cf187c2
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion net/sunrpc/xdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit cf187c2

Please sign in to comment.