From: Andreas Gruenbacher <agruen@suse.de>
To: linux-kernel@vger.kernel.org, Neil Brown <neilb@cse.unsw.edu.au>,
Trond Myklebust <trond.myklebust@fys.uio.no>
Cc: Olaf Kirch <okir@suse.de>,
"Andries E. Brouwer" <Andries.Brouwer@cwi.nl>,
Andrew Morton <akpm@osdl.org>
Subject: [nfsacl v2 07/16] Lazy RPC receive buffer allocation
Date: Sun, 27 Feb 2005 18:00:01 +0100 [thread overview]
Message-ID: <20050227170313.353432000@blunzn.suse.de> (raw)
In-Reply-To: <20050227165954.566746000@blunzn.suse.de>
[-- Attachment #1: nfsacl-lazy-rpc-receive-buffer-allocation.patch --]
[-- Type: text/plain, Size: 4788 bytes --]
Allow to allocate pages in the receive buffer lazily. Used for the GETACL
RPC, which has a big maximum reply size, but a small average reply size.
Signed-off-by: Olaf Kirch <okir@suse.de>
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
Index: linux-2.6.11-rc5/include/linux/sunrpc/xdr.h
===================================================================
--- linux-2.6.11-rc5.orig/include/linux/sunrpc/xdr.h
+++ linux-2.6.11-rc5/include/linux/sunrpc/xdr.h
@@ -160,7 +160,7 @@ typedef struct {
typedef size_t (*skb_read_actor_t)(skb_reader_t *desc, void *to, size_t len);
-extern void xdr_partial_copy_from_skb(struct xdr_buf *, unsigned int,
+extern int xdr_partial_copy_from_skb(struct xdr_buf *, unsigned int,
skb_reader_t *, skb_read_actor_t);
struct socket;
Index: linux-2.6.11-rc5/net/sunrpc/xdr.c
===================================================================
--- linux-2.6.11-rc5.orig/net/sunrpc/xdr.c
+++ linux-2.6.11-rc5/net/sunrpc/xdr.c
@@ -176,7 +176,7 @@ xdr_inline_pages(struct xdr_buf *xdr, un
xdr->buflen += len;
}
-void
+int
xdr_partial_copy_from_skb(struct xdr_buf *xdr, unsigned int base,
skb_reader_t *desc,
skb_read_actor_t copy_actor)
@@ -190,7 +190,7 @@ xdr_partial_copy_from_skb(struct xdr_buf
len -= base;
ret = copy_actor(desc, (char *)xdr->head[0].iov_base + base, len);
if (ret != len || !desc->count)
- return;
+ return 0;
base = 0;
} else
base -= len;
@@ -210,6 +210,13 @@ xdr_partial_copy_from_skb(struct xdr_buf
do {
char *kaddr;
+ /* ACL likes to be lazy in allocating pages - ACLs
+ * are small by default but can get huge. */
+ if (unlikely(*ppage == NULL)) {
+ if (!(*ppage = alloc_page(GFP_ATOMIC)))
+ return -ENOMEM;
+ }
+
len = PAGE_CACHE_SIZE;
kaddr = kmap_atomic(*ppage, KM_SKB_SUNRPC_DATA);
if (base) {
@@ -226,13 +233,15 @@ xdr_partial_copy_from_skb(struct xdr_buf
flush_dcache_page(*ppage);
kunmap_atomic(kaddr, KM_SKB_SUNRPC_DATA);
if (ret != len || !desc->count)
- return;
+ return 0;
ppage++;
} while ((pglen -= len) != 0);
copy_tail:
len = xdr->tail[0].iov_len;
if (base < len)
copy_actor(desc, (char *)xdr->tail[0].iov_base + base, len - base);
+
+ return 0;
}
Index: linux-2.6.11-rc5/net/sunrpc/xprt.c
===================================================================
--- linux-2.6.11-rc5.orig/net/sunrpc/xprt.c
+++ linux-2.6.11-rc5/net/sunrpc/xprt.c
@@ -725,7 +725,8 @@ csum_partial_copy_to_xdr(struct xdr_buf
goto no_checksum;
desc.csum = csum_partial(skb->data, desc.offset, skb->csum);
- xdr_partial_copy_from_skb(xdr, 0, &desc, skb_read_and_csum_bits);
+ if (xdr_partial_copy_from_skb(xdr, 0, &desc, skb_read_and_csum_bits) < 0)
+ return -1;
if (desc.offset != skb->len) {
unsigned int csum2;
csum2 = skb_checksum(skb, desc.offset, skb->len - desc.offset, 0);
@@ -737,7 +738,8 @@ csum_partial_copy_to_xdr(struct xdr_buf
return -1;
return 0;
no_checksum:
- xdr_partial_copy_from_skb(xdr, 0, &desc, skb_read_bits);
+ if (xdr_partial_copy_from_skb(xdr, 0, &desc, skb_read_bits) < 0)
+ return -1;
if (desc.count)
return -1;
return 0;
@@ -907,6 +909,7 @@ tcp_read_request(struct rpc_xprt *xprt,
struct rpc_rqst *req;
struct xdr_buf *rcvbuf;
size_t len;
+ int r;
/* Find and lock the request corresponding to this xid */
spin_lock(&xprt->sock_lock);
@@ -927,16 +930,30 @@ tcp_read_request(struct rpc_xprt *xprt,
len = xprt->tcp_reclen - xprt->tcp_offset;
memcpy(&my_desc, desc, sizeof(my_desc));
my_desc.count = len;
- xdr_partial_copy_from_skb(rcvbuf, xprt->tcp_copied,
+ r = xdr_partial_copy_from_skb(rcvbuf, xprt->tcp_copied,
&my_desc, tcp_copy_data);
desc->count -= len;
desc->offset += len;
} else
- xdr_partial_copy_from_skb(rcvbuf, xprt->tcp_copied,
+ r = xdr_partial_copy_from_skb(rcvbuf, xprt->tcp_copied,
desc, tcp_copy_data);
xprt->tcp_copied += len;
xprt->tcp_offset += len;
+ if (r < 0) {
+ /* Error when copying to the receive buffer,
+ * usually because we weren't able to allocate
+ * additional buffer pages. All we can do now
+ * is turn off XPRT_COPY_DATA, so the request
+ * will not receive any additional updates,
+ * and time out.
+ * Any remaining data from this record will
+ * be discarded.
+ */
+ xprt->tcp_flags &= ~XPRT_COPY_DATA;
+ goto out;
+ }
+
if (xprt->tcp_copied == req->rq_private_buf.buflen)
xprt->tcp_flags &= ~XPRT_COPY_DATA;
else if (xprt->tcp_offset == xprt->tcp_reclen) {
@@ -949,6 +966,7 @@ tcp_read_request(struct rpc_xprt *xprt,
req->rq_task->tk_pid);
xprt_complete_rqst(xprt, req, xprt->tcp_copied);
}
+out:
spin_unlock(&xprt->sock_lock);
tcp_check_recm(xprt);
}
--
Andreas Gruenbacher <agruen@suse.de>
SUSE Labs, SUSE LINUX PRODUCTS GMBH
next prev parent reply other threads:[~2005-02-27 17:42 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-02-27 16:59 [nfsacl v2 00/16] NFSACL protocol extension for NFSv3 Andreas Gruenbacher
2005-02-27 16:59 ` [nfsacl v2 01/16] acl kconfig cleanup Andreas Gruenbacher
[not found] ` <4225FAE8.80308@tomt.net>
2005-03-02 17:49 ` Andreas Gruenbacher
2005-02-27 16:59 ` [nfsacl v2 02/16] Qsort Andreas Gruenbacher
2005-02-27 22:54 ` Andreas Gruenbacher
2005-02-27 16:59 ` [nfsacl v2 03/16] Return -ENOSYS for RPC programs that are unavailable Andreas Gruenbacher
2005-02-27 16:59 ` [nfsacl v2 04/16] Add missing -EOPNOTSUPP => NFS3ERR_NOTSUPP mapping in nfsd Andreas Gruenbacher
2005-02-27 16:59 ` [nfsacl v2 05/16] Allow multiple programs to listen on the same port Andreas Gruenbacher
2005-02-27 17:00 ` [nfsacl v2 06/16] Allow multiple programs to share the same transport Andreas Gruenbacher
2005-02-27 17:00 ` Andreas Gruenbacher [this message]
2005-02-27 17:00 ` [nfsacl v2 08/16] Encode and decode arbitrary XDR arrays Andreas Gruenbacher
2005-02-27 17:00 ` [nfsacl v2 09/16] Add noacl nfs mount option Andreas Gruenbacher
2005-02-27 17:00 ` [nfsacl v2 10/16] Infrastructure and server side of nfsacl Andreas Gruenbacher
2005-02-27 22:56 ` Andreas Gruenbacher
2005-02-27 17:00 ` [nfsacl v2 11/16] Solaris nfsacl workaround Andreas Gruenbacher
2005-02-27 17:00 ` [nfsacl v2 12/16] nfs mknod cleanup Andreas Gruenbacher
2005-02-27 17:00 ` [nfsacl v2 13/16] nfs mkdir cleanup Andreas Gruenbacher
2005-02-27 17:00 ` [nfsacl v2 14/16] Client side of nfsacl Andreas Gruenbacher
2005-02-27 17:00 ` [nfsacl v2 15/16] ACL umask handling workaround in nfs client Andreas Gruenbacher
2005-03-02 15:49 ` Andreas Gruenbacher
2005-02-27 17:00 ` [nfsacl v2 16/16] Cache acls on the nfs client side Andreas Gruenbacher
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=20050227170313.353432000@blunzn.suse.de \
--to=agruen@suse.de \
--cc=Andries.Brouwer@cwi.nl \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=neilb@cse.unsw.edu.au \
--cc=okir@suse.de \
--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
all inboxes | Powered by JetHome®