Commit 28ced9a8 authored by Trond Myklebust's avatar Trond Myklebust

pNFS: Don't allocate more pages than we need to fit a layoutget response

For the 'files' and 'flexfiles' layout types, we do not expect the reply
to be any larger than 4k. The block and scsi layout types are a little more
greedy, so we keep allocating the maximum response size for now.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent a2791d3a
...@@ -1164,6 +1164,7 @@ static struct pnfs_layoutdriver_type filelayout_type = { ...@@ -1164,6 +1164,7 @@ static struct pnfs_layoutdriver_type filelayout_type = {
.id = LAYOUT_NFSV4_1_FILES, .id = LAYOUT_NFSV4_1_FILES,
.name = "LAYOUT_NFSV4_1_FILES", .name = "LAYOUT_NFSV4_1_FILES",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.max_layoutget_response = 4096, /* 1 page or so... */
.alloc_layout_hdr = filelayout_alloc_layout_hdr, .alloc_layout_hdr = filelayout_alloc_layout_hdr,
.free_layout_hdr = filelayout_free_layout_hdr, .free_layout_hdr = filelayout_free_layout_hdr,
.alloc_lseg = filelayout_alloc_lseg, .alloc_lseg = filelayout_alloc_lseg,
......
...@@ -2356,6 +2356,7 @@ static struct pnfs_layoutdriver_type flexfilelayout_type = { ...@@ -2356,6 +2356,7 @@ static struct pnfs_layoutdriver_type flexfilelayout_type = {
.name = "LAYOUT_FLEX_FILES", .name = "LAYOUT_FLEX_FILES",
.owner = THIS_MODULE, .owner = THIS_MODULE,
.flags = PNFS_LAYOUTGET_ON_OPEN, .flags = PNFS_LAYOUTGET_ON_OPEN,
.max_layoutget_response = 4096, /* 1 page or so... */
.set_layoutdriver = ff_layout_set_layoutdriver, .set_layoutdriver = ff_layout_set_layoutdriver,
.alloc_layout_hdr = ff_layout_alloc_layout_hdr, .alloc_layout_hdr = ff_layout_alloc_layout_hdr,
.free_layout_hdr = ff_layout_free_layout_hdr, .free_layout_hdr = ff_layout_free_layout_hdr,
......
...@@ -991,6 +991,7 @@ pnfs_alloc_init_layoutget_args(struct inode *ino, ...@@ -991,6 +991,7 @@ pnfs_alloc_init_layoutget_args(struct inode *ino,
gfp_t gfp_flags) gfp_t gfp_flags)
{ {
struct nfs_server *server = pnfs_find_server(ino, ctx); struct nfs_server *server = pnfs_find_server(ino, ctx);
size_t max_reply_sz = server->pnfs_curr_ld->max_layoutget_response;
size_t max_pages = max_response_pages(server); size_t max_pages = max_response_pages(server);
struct nfs4_layoutget *lgp; struct nfs4_layoutget *lgp;
...@@ -1000,6 +1001,12 @@ pnfs_alloc_init_layoutget_args(struct inode *ino, ...@@ -1000,6 +1001,12 @@ pnfs_alloc_init_layoutget_args(struct inode *ino,
if (lgp == NULL) if (lgp == NULL)
return NULL; return NULL;
if (max_reply_sz) {
size_t npages = (max_reply_sz + PAGE_SIZE - 1) >> PAGE_SHIFT;
if (npages < max_pages)
max_pages = npages;
}
lgp->args.layout.pages = nfs4_alloc_pages(max_pages, gfp_flags); lgp->args.layout.pages = nfs4_alloc_pages(max_pages, gfp_flags);
if (!lgp->args.layout.pages) { if (!lgp->args.layout.pages) {
kfree(lgp); kfree(lgp);
......
...@@ -125,6 +125,7 @@ struct pnfs_layoutdriver_type { ...@@ -125,6 +125,7 @@ struct pnfs_layoutdriver_type {
struct module *owner; struct module *owner;
unsigned flags; unsigned flags;
unsigned max_deviceinfo_size; unsigned max_deviceinfo_size;
unsigned max_layoutget_response;
int (*set_layoutdriver) (struct nfs_server *, const struct nfs_fh *); int (*set_layoutdriver) (struct nfs_server *, const struct nfs_fh *);
int (*clear_layoutdriver) (struct nfs_server *); int (*clear_layoutdriver) (struct nfs_server *);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment