aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2010-08-29 12:13:16 -0400
committerTrond Myklebust <Trond.Myklebust@netapp.com>2010-08-29 12:13:16 -0400
commitcf187c2d7ec763cdd459fe43933a5cc4f5f48e1b (patch)
tree05e87ee64fb3243b7fedb66c9a64caa6adad2c07
parent42d6d8ab51ca04afcb8a64759076da624cdb71e8 (diff)
SUNRPC: Don't truncate tail data unnecessarily in xdr_shrink_pagelen
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>
-rw-r--r--net/sunrpc/xdr.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index 3317db3cb102..3bbef7f5f826 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)
396 struct kvec *tail; 396 struct kvec *tail;
397 size_t copy; 397 size_t copy;
398 unsigned int pglen = buf->page_len; 398 unsigned int pglen = buf->page_len;
399 unsigned int tailbuf_len;
399 400
400 tail = buf->tail; 401 tail = buf->tail;
401 BUG_ON (len > pglen); 402 BUG_ON (len > pglen);
402 403
404 tailbuf_len = buf->buflen - buf->head->iov_len - buf->page_len;
405
403 /* Shift the tail first */ 406 /* Shift the tail first */
404 if (tail->iov_len != 0) { 407 if (tailbuf_len != 0) {
408 unsigned int free_space = tailbuf_len - tail->iov_len;
409
410 if (len < free_space)
411 free_space = len;
412 tail->iov_len += free_space;
413
405 copy = len; 414 copy = len;
406 if (tail->iov_len > len) { 415 if (tail->iov_len > len) {
407 char *p = (char *)tail->iov_base + len; 416 char *p = (char *)tail->iov_base + len;