public inbox for linux-nfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Trond Myklebust <Trond.Myklebust@netapp.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 10/24] NFSv4: Reduce stack footprint of nfs4_proc_access() and nfs3_proc_access()
Date: Fri, 16 Apr 2010 16:31:08 -0400	[thread overview]
Message-ID: <1271449882-8580-11-git-send-email-Trond.Myklebust@netapp.com> (raw)
In-Reply-To: <1271449882-8580-10-git-send-email-Trond.Myklebust@netapp.com>

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
---
 fs/nfs/nfs3proc.c |   17 ++++++++++-------
 fs/nfs/nfs4proc.c |   11 +++++++----
 2 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index 72334c1..9d5d02f 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -181,13 +181,10 @@ nfs3_proc_lookup(struct inode *dir, struct qstr *name,
 
 static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry)
 {
-	struct nfs_fattr	fattr;
 	struct nfs3_accessargs	arg = {
 		.fh		= NFS_FH(inode),
 	};
-	struct nfs3_accessres	res = {
-		.fattr		= &fattr,
-	};
+	struct nfs3_accessres	res;
 	struct rpc_message msg = {
 		.rpc_proc	= &nfs3_procedures[NFS3PROC_ACCESS],
 		.rpc_argp	= &arg,
@@ -195,7 +192,7 @@ static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry)
 		.rpc_cred	= entry->cred,
 	};
 	int mode = entry->mask;
-	int status;
+	int status = -ENOMEM;
 
 	dprintk("NFS call  access\n");
 
@@ -212,9 +209,13 @@ static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry)
 		if (mode & MAY_EXEC)
 			arg.access |= NFS3_ACCESS_EXECUTE;
 	}
-	nfs_fattr_init(&fattr);
+
+	res.fattr = nfs_alloc_fattr();
+	if (res.fattr == NULL)
+		goto out;
+
 	status = rpc_call_sync(NFS_CLIENT(inode), &msg, 0);
-	nfs_refresh_inode(inode, &fattr);
+	nfs_refresh_inode(inode, res.fattr);
 	if (status == 0) {
 		entry->mask = 0;
 		if (res.access & NFS3_ACCESS_READ)
@@ -224,6 +225,8 @@ static int nfs3_proc_access(struct inode *inode, struct nfs_access_entry *entry)
 		if (res.access & (NFS3_ACCESS_LOOKUP|NFS3_ACCESS_EXECUTE))
 			entry->mask |= MAY_EXEC;
 	}
+	nfs_free_fattr(res.fattr);
+out:
 	dprintk("NFS reply access: %d\n", status);
 	return status;
 }
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 6380670..3acce87 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -2404,14 +2404,12 @@ static int nfs4_proc_lookup(struct inode *dir, struct qstr *name, struct nfs_fh
 static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry)
 {
 	struct nfs_server *server = NFS_SERVER(inode);
-	struct nfs_fattr fattr;
 	struct nfs4_accessargs args = {
 		.fh = NFS_FH(inode),
 		.bitmask = server->attr_bitmask,
 	};
 	struct nfs4_accessres res = {
 		.server = server,
-		.fattr = &fattr,
 	};
 	struct rpc_message msg = {
 		.rpc_proc = &nfs4_procedures[NFSPROC4_CLNT_ACCESS],
@@ -2438,7 +2436,11 @@ static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry
 		if (mode & MAY_EXEC)
 			args.access |= NFS4_ACCESS_EXECUTE;
 	}
-	nfs_fattr_init(&fattr);
+
+	res.fattr = nfs_alloc_fattr();
+	if (res.fattr == NULL)
+		return -ENOMEM;
+
 	status = nfs4_call_sync(server, &msg, &args, &res, 0);
 	if (!status) {
 		entry->mask = 0;
@@ -2448,8 +2450,9 @@ static int _nfs4_proc_access(struct inode *inode, struct nfs_access_entry *entry
 			entry->mask |= MAY_WRITE;
 		if (res.access & (NFS4_ACCESS_LOOKUP|NFS4_ACCESS_EXECUTE))
 			entry->mask |= MAY_EXEC;
-		nfs_refresh_inode(inode, &fattr);
+		nfs_refresh_inode(inode, res.fattr);
 	}
+	nfs_free_fattr(res.fattr);
 	return status;
 }
 
-- 
1.6.6.1


  reply	other threads:[~2010-04-16 20:31 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-16 20:30 [PATCH 00/24] Reduce the stack foot print of the NFS client Trond Myklebust
2010-04-16 20:30 ` [PATCH 01/24] NFS: Add helper functions for allocating filehandles and fattr structs Trond Myklebust
2010-04-16 20:31   ` [PATCH 02/24] NFSv4: Eliminate nfs4_path_walk() Trond Myklebust
2010-04-16 20:31     ` [PATCH 03/24] NFS: Reduce the stack footprint of nfs_follow_mountpoint() Trond Myklebust
2010-04-16 20:31       ` [PATCH 04/24] NFS: Reduce the stack footprint of nfs_create_server Trond Myklebust
2010-04-16 20:31         ` [PATCH 05/24] NFSv4: Reduce the stack footprint of try_location() Trond Myklebust
2010-04-16 20:31           ` [PATCH 06/24] NFS: Reduce the stack footprint of nfs_lookup Trond Myklebust
2010-04-16 20:31             ` [PATCH 07/24] NFS: Reduce the stack footprint of nfs_follow_remote_path() Trond Myklebust
2010-04-16 20:31               ` [PATCH 08/24] NFSv4: Reduce stack footprint of nfs4_get_root() Trond Myklebust
2010-04-16 20:31                 ` [PATCH 09/24] NFSv4: Reduce the stack footprint of nfs4_remote_referral_get_sb Trond Myklebust
2010-04-16 20:31                   ` Trond Myklebust [this message]
2010-04-16 20:31                     ` [PATCH 11/24] NFS: Reduce stack footprint of nfs_revalidate_inode() Trond Myklebust
2010-04-16 20:31                       ` [PATCH 12/24] NFS: Reduce stack footprint of nfs3_proc_rename() and nfs4_proc_rename() Trond Myklebust
2010-04-16 20:31                         ` [PATCH 13/24] NFS: Reduce stack footprint of nfs_readdir() Trond Myklebust
2010-04-16 20:31                           ` [PATCH 14/24] NFS: Reduce the stack footprint of nfs_link() Trond Myklebust
2010-04-16 20:31                             ` [PATCH 15/24] NFS: Reduce stack footprint of nfs3_proc_readlink() Trond Myklebust
2010-04-16 20:31                               ` [PATCH 16/24] NFS: Reduce stack footprint of nfs_proc_remove() Trond Myklebust
2010-04-16 20:31                                 ` [PATCH 17/24] NFS: Reduce the stack footprint of nfs_rmdir Trond Myklebust
2010-04-16 20:31                                   ` [PATCH 18/24] NFS: Reduce the stack footprint of nfs_proc_create Trond Myklebust
2010-04-16 20:31                                     ` [PATCH 19/24] NFS: Reduce the stack footprint of nfs_proc_symlink() Trond Myklebust
2010-04-16 20:31                                       ` [PATCH 20/24] NFS: Reduce stack footprint of nfs4_proc_create() Trond Myklebust
2010-04-16 20:31                                         ` [PATCH 21/24] NFS: Reduce stack footprint of nfs_setattr() Trond Myklebust
2010-04-16 20:31                                           ` [PATCH 22/24] NFS: Reduce stack footprint of nfs_statfs() Trond Myklebust
2010-04-16 20:31                                             ` [PATCH 23/24] NFS: Reduce stack footprint of nfs3_proc_getacl() and nfs3_proc_setacl() Trond Myklebust
2010-04-16 20:31                                               ` [PATCH 24/24] NFS: Prevent the mount code from looping forever on broken exports Trond Myklebust
2010-04-19 21:03                 ` [PATCH 08/24] NFSv4: Reduce stack footprint of nfs4_get_root() Chuck Lever
2010-04-19 21:43 ` [PATCH 00/24] Reduce the stack foot print of the NFS client Chuck Lever
2010-04-19 23:29   ` Trond Myklebust
     [not found]     ` <1271719778.25129.73.camel-bi+AKbBUZKY6gyzm1THtWbp2dZbC/Bob@public.gmane.org>
2010-04-19 23:37       ` 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=1271449882-8580-11-git-send-email-Trond.Myklebust@netapp.com \
    --to=trond.myklebust@netapp.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