From: Trond Myklebust <trondmy@gmail.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 2/7] pNFS: Don't allocate more pages than we need to fit a layoutget response
Date: Wed, 5 Sep 2018 15:23:55 -0400 [thread overview]
Message-ID: <20180905192400.107485-3-trond.myklebust@hammerspace.com> (raw)
In-Reply-To: <20180905192400.107485-2-trond.myklebust@hammerspace.com>
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>
---
fs/nfs/filelayout/filelayout.c | 1 +
fs/nfs/flexfilelayout/flexfilelayout.c | 1 +
fs/nfs/pnfs.c | 7 +++++++
fs/nfs/pnfs.h | 1 +
4 files changed, 10 insertions(+)
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 = {
.id = LAYOUT_NFSV4_1_FILES,
.name = "LAYOUT_NFSV4_1_FILES",
.owner = THIS_MODULE,
+ .max_layoutget_response = 4096, /* 1 page or so... */
.alloc_layout_hdr = filelayout_alloc_layout_hdr,
.free_layout_hdr = filelayout_free_layout_hdr,
.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 = {
.name = "LAYOUT_FLEX_FILES",
.owner = THIS_MODULE,
.flags = PNFS_LAYOUTGET_ON_OPEN,
+ .max_layoutget_response = 4096, /* 1 page or so... */
.set_layoutdriver = ff_layout_set_layoutdriver,
.alloc_layout_hdr = ff_layout_alloc_layout_hdr,
.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,
gfp_t gfp_flags)
{
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);
struct nfs4_layoutget *lgp;
@@ -1000,6 +1001,12 @@ pnfs_alloc_init_layoutget_args(struct inode *ino,
if (lgp == 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);
if (!lgp->args.layout.pages) {
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 {
struct module *owner;
unsigned flags;
unsigned max_deviceinfo_size;
+ unsigned max_layoutget_response;
int (*set_layoutdriver) (struct nfs_server *, const struct nfs_fh *);
int (*clear_layoutdriver) (struct nfs_server *);
--
2.17.1
next prev parent reply other threads:[~2018-09-05 23:56 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-09-05 19:23 [PATCH 0/7] Misc NFS + pNFS performance enhancements Trond Myklebust
2018-09-05 19:23 ` [PATCH 1/7] pNFS: Don't zero out the array in nfs4_alloc_pages() Trond Myklebust
2018-09-05 19:23 ` Trond Myklebust [this message]
2018-09-05 19:23 ` [PATCH 3/7] NFS: Convert lookups of the lock context to RCU Trond Myklebust
2018-09-05 19:23 ` [PATCH 4/7] NFS: Simplify internal check for whether file is open for write Trond Myklebust
2018-09-05 19:23 ` [PATCH 5/7] NFS: Convert lookups of the open context to RCU Trond Myklebust
2018-09-05 19:23 ` [PATCH 6/7] NFSv4: Convert open state lookup to use RCU Trond Myklebust
2018-09-05 19:24 ` [PATCH 7/7] NFSv4: Convert struct nfs4_state to use refcount_t Trond Myklebust
2018-09-28 16:34 ` [PATCH 5/7] NFS: Convert lookups of the open context to RCU Olga Kornievskaia
2018-09-28 16:54 ` Olga Kornievskaia
2018-09-28 17:49 ` Trond Myklebust
2018-09-28 18:31 ` Olga Kornievskaia
2018-09-28 18:53 ` Trond Myklebust
2018-09-28 19:10 ` Olga Kornievskaia
2018-09-28 19:55 ` Olga Kornievskaia
2018-09-28 20:07 ` Trond Myklebust
2018-09-28 20:19 ` Olga Kornievskaia
2018-09-28 20:38 ` Trond Myklebust
2018-10-03 18:38 ` Olga Kornievskaia
2018-10-04 15:22 ` Trond Myklebust
2018-10-04 15:49 ` Olga Kornievskaia
2018-10-04 16:13 ` Trond Myklebust
2018-10-04 16:31 ` Olga Kornievskaia
2018-10-04 16:42 ` Trond Myklebust
2018-10-04 18:51 ` Olga Kornievskaia
2018-10-03 22:05 ` [PATCH 2/7] pNFS: Don't allocate more pages than we need to fit a layoutget response NeilBrown
2018-09-05 19:33 ` [PATCH 0/7] Misc NFS + pNFS performance enhancements Chuck Lever
2018-09-05 20:36 ` Trond Myklebust
2018-09-07 15:44 ` Chuck Lever
2018-09-10 1:35 ` Trond Myklebust
2018-09-10 16:14 ` Chuck Lever
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=20180905192400.107485-3-trond.myklebust@hammerspace.com \
--to=trondmy@gmail.com \
--cc=linux-nfs@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).