diff options
author | Trond Myklebust <trond.myklebust@hammerspace.com> | 2018-09-03 13:12:15 -0400 |
---|---|---|
committer | Trond Myklebust <trond.myklebust@hammerspace.com> | 2018-09-30 15:35:16 -0400 |
commit | 28ced9a84cd2f9fc68a081fb3b34e70c5d459be3 (patch) | |
tree | 2fce92ffd58bdf780ba75c51838f95f38cfe6f00 | |
parent | a2791d3a2cee9432e78bbdcfde586ef54e32d223 (diff) |
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: Trond Myklebust <trond.myklebust@hammerspace.com>
-rw-r--r-- | fs/nfs/filelayout/filelayout.c | 1 | ||||
-rw-r--r-- | fs/nfs/flexfilelayout/flexfilelayout.c | 1 | ||||
-rw-r--r-- | fs/nfs/pnfs.c | 7 | ||||
-rw-r--r-- | fs/nfs/pnfs.h | 1 |
4 files changed, 10 insertions, 0 deletions
diff --git a/fs/nfs/filelayout/filelayout.c b/fs/nfs/filelayout/filelayout.c index d175724ff566..61f46facb39c 100644 --- a/fs/nfs/filelayout/filelayout.c +++ b/fs/nfs/filelayout/filelayout.c | |||
@@ -1164,6 +1164,7 @@ static struct pnfs_layoutdriver_type filelayout_type = { | |||
1164 | .id = LAYOUT_NFSV4_1_FILES, | 1164 | .id = LAYOUT_NFSV4_1_FILES, |
1165 | .name = "LAYOUT_NFSV4_1_FILES", | 1165 | .name = "LAYOUT_NFSV4_1_FILES", |
1166 | .owner = THIS_MODULE, | 1166 | .owner = THIS_MODULE, |
1167 | .max_layoutget_response = 4096, /* 1 page or so... */ | ||
1167 | .alloc_layout_hdr = filelayout_alloc_layout_hdr, | 1168 | .alloc_layout_hdr = filelayout_alloc_layout_hdr, |
1168 | .free_layout_hdr = filelayout_free_layout_hdr, | 1169 | .free_layout_hdr = filelayout_free_layout_hdr, |
1169 | .alloc_lseg = filelayout_alloc_lseg, | 1170 | .alloc_lseg = filelayout_alloc_lseg, |
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c index cae43333ef16..86bcba40ca61 100644 --- a/fs/nfs/flexfilelayout/flexfilelayout.c +++ b/fs/nfs/flexfilelayout/flexfilelayout.c | |||
@@ -2356,6 +2356,7 @@ static struct pnfs_layoutdriver_type flexfilelayout_type = { | |||
2356 | .name = "LAYOUT_FLEX_FILES", | 2356 | .name = "LAYOUT_FLEX_FILES", |
2357 | .owner = THIS_MODULE, | 2357 | .owner = THIS_MODULE, |
2358 | .flags = PNFS_LAYOUTGET_ON_OPEN, | 2358 | .flags = PNFS_LAYOUTGET_ON_OPEN, |
2359 | .max_layoutget_response = 4096, /* 1 page or so... */ | ||
2359 | .set_layoutdriver = ff_layout_set_layoutdriver, | 2360 | .set_layoutdriver = ff_layout_set_layoutdriver, |
2360 | .alloc_layout_hdr = ff_layout_alloc_layout_hdr, | 2361 | .alloc_layout_hdr = ff_layout_alloc_layout_hdr, |
2361 | .free_layout_hdr = ff_layout_free_layout_hdr, | 2362 | .free_layout_hdr = ff_layout_free_layout_hdr, |
diff --git a/fs/nfs/pnfs.c b/fs/nfs/pnfs.c index 6b5b2d36f502..c5672c02afd6 100644 --- a/fs/nfs/pnfs.c +++ b/fs/nfs/pnfs.c | |||
@@ -991,6 +991,7 @@ pnfs_alloc_init_layoutget_args(struct inode *ino, | |||
991 | gfp_t gfp_flags) | 991 | gfp_t gfp_flags) |
992 | { | 992 | { |
993 | struct nfs_server *server = pnfs_find_server(ino, ctx); | 993 | struct nfs_server *server = pnfs_find_server(ino, ctx); |
994 | size_t max_reply_sz = server->pnfs_curr_ld->max_layoutget_response; | ||
994 | size_t max_pages = max_response_pages(server); | 995 | size_t max_pages = max_response_pages(server); |
995 | struct nfs4_layoutget *lgp; | 996 | struct nfs4_layoutget *lgp; |
996 | 997 | ||
@@ -1000,6 +1001,12 @@ pnfs_alloc_init_layoutget_args(struct inode *ino, | |||
1000 | if (lgp == NULL) | 1001 | if (lgp == NULL) |
1001 | return NULL; | 1002 | return NULL; |
1002 | 1003 | ||
1004 | if (max_reply_sz) { | ||
1005 | size_t npages = (max_reply_sz + PAGE_SIZE - 1) >> PAGE_SHIFT; | ||
1006 | if (npages < max_pages) | ||
1007 | max_pages = npages; | ||
1008 | } | ||
1009 | |||
1003 | lgp->args.layout.pages = nfs4_alloc_pages(max_pages, gfp_flags); | 1010 | lgp->args.layout.pages = nfs4_alloc_pages(max_pages, gfp_flags); |
1004 | if (!lgp->args.layout.pages) { | 1011 | if (!lgp->args.layout.pages) { |
1005 | kfree(lgp); | 1012 | kfree(lgp); |
diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index ece367ebde69..e2e9fcd5341d 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h | |||
@@ -125,6 +125,7 @@ struct pnfs_layoutdriver_type { | |||
125 | struct module *owner; | 125 | struct module *owner; |
126 | unsigned flags; | 126 | unsigned flags; |
127 | unsigned max_deviceinfo_size; | 127 | unsigned max_deviceinfo_size; |
128 | unsigned max_layoutget_response; | ||
128 | 129 | ||
129 | int (*set_layoutdriver) (struct nfs_server *, const struct nfs_fh *); | 130 | int (*set_layoutdriver) (struct nfs_server *, const struct nfs_fh *); |
130 | int (*clear_layoutdriver) (struct nfs_server *); | 131 | int (*clear_layoutdriver) (struct nfs_server *); |