diff mbox

[RFC,v3,41/45] rpc: Allow to demand-allocate pages to encode into

Message ID 4bf77d045d2bd3494c695229cd0505b7002cc9a2.1429868795.git.agruenba@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Andreas Grünbacher April 24, 2015, 11:04 a.m. UTC
When encoding large, variable-length objects such as acls into xdr_bufs, it is
easier to allocate buffer pages on demand rather than computing the required
buffer size beforehand.

Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
---
 net/sunrpc/xdr.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Trond Myklebust May 28, 2015, 11:24 p.m. UTC | #1
On Fri, Apr 24, 2015 at 7:04 AM, Andreas Gruenbacher
<andreas.gruenbacher@gmail.com> wrote:
> When encoding large, variable-length objects such as acls into xdr_bufs, it is
> easier to allocate buffer pages on demand rather than computing the required
> buffer size beforehand.
>
> Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com>
> ---
>  net/sunrpc/xdr.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
> index 4439ac4..062951b 100644
> --- a/net/sunrpc/xdr.c
> +++ b/net/sunrpc/xdr.c
> @@ -537,6 +537,14 @@ static __be32 *xdr_get_next_encode_buffer(struct xdr_stream *xdr,
>          */
>         xdr->scratch.iov_base = xdr->p;
>         xdr->scratch.iov_len = frag1bytes;
> +
> +       if (!*xdr->page_ptr) {
> +               struct page *page = alloc_page(GFP_KERNEL);
> +               if (!page)
> +                       return ERR_PTR(-ENOMEM);
> +               *xdr->page_ptr = page;
> +       }
> +
>         p = page_address(*xdr->page_ptr);
>         /*
>          * Note this is where the next encode will start after we've
>

xdr_get_next_encode() should return NULL on failure, not ENOMEM.
Why is this trying to do a GFP_KERNEL allocation inside an XDR routine
anyway? That's not an I/O safe sleep.

Trond
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andreas Grünbacher May 29, 2015, 3:46 p.m. UTC | #2
2015-05-29 1:24 GMT+02:00 Trond Myklebust <trond.myklebust@primarydata.com>:
> xdr_get_next_encode() should return NULL on failure, not ENOMEM.
> Why is this trying to do a GFP_KERNEL allocation inside an XDR routine
> anyway? That's not an I/O safe sleep.

Fixed, thanks.

Andreas
--
To unsubscribe from this list: send the line "unsubscribe linux-fsdevel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/net/sunrpc/xdr.c b/net/sunrpc/xdr.c
index 4439ac4..062951b 100644
--- a/net/sunrpc/xdr.c
+++ b/net/sunrpc/xdr.c
@@ -537,6 +537,14 @@  static __be32 *xdr_get_next_encode_buffer(struct xdr_stream *xdr,
 	 */
 	xdr->scratch.iov_base = xdr->p;
 	xdr->scratch.iov_len = frag1bytes;
+
+	if (!*xdr->page_ptr) {
+		struct page *page = alloc_page(GFP_KERNEL);
+		if (!page)
+			return ERR_PTR(-ENOMEM);
+		*xdr->page_ptr = page;
+	}
+
 	p = page_address(*xdr->page_ptr);
 	/*
 	 * Note this is where the next encode will start after we've