summaryrefslogtreecommitdiffstats
path: root/net/sunrpc/xdr.c
diff options
context:
space:
mode:
authorTrond Myklebust <Trond.Myklebust@netapp.com>2010-08-29 18:13:16 +0200
committerTrond Myklebust <Trond.Myklebust@netapp.com>2010-08-29 18:13:16 +0200
commitcf187c2d7ec763cdd459fe43933a5cc4f5f48e1b (patch)
tree05e87ee64fb3243b7fedb66c9a64caa6adad2c07 /net/sunrpc/xdr.c
parentsunrpc: simplify xdr_shrink_pagelen use of "copy" (diff)
downloadlinux-cf187c2d7ec763cdd459fe43933a5cc4f5f48e1b.tar.xz
linux-cf187c2d7ec763cdd459fe43933a5cc4f5f48e1b.zip
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>
Diffstat (limited to 'net/sunrpc/xdr.c')
-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)
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;