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 06/24] NFS: Reduce the stack footprint of nfs_lookup
Date: Fri, 16 Apr 2010 16:31:04 -0400	[thread overview]
Message-ID: <1271449882-8580-7-git-send-email-Trond.Myklebust@netapp.com> (raw)
In-Reply-To: <1271449882-8580-6-git-send-email-Trond.Myklebust@netapp.com>

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
---
 fs/nfs/dir.c      |   45 +++++++++++++++++++++++++++++++++++----------
 fs/nfs/nfs3proc.c |   10 ++++++----
 2 files changed, 41 insertions(+), 14 deletions(-)

diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index be46f26..4da45ab 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -776,9 +776,9 @@ static int nfs_lookup_revalidate(struct dentry * dentry, struct nameidata *nd)
 	struct inode *dir;
 	struct inode *inode;
 	struct dentry *parent;
+	struct nfs_fh *fhandle = NULL;
+	struct nfs_fattr *fattr = NULL;
 	int error;
-	struct nfs_fh fhandle;
-	struct nfs_fattr fattr;
 
 	parent = dget_parent(dentry);
 	dir = parent->d_inode;
@@ -811,14 +811,22 @@ static int nfs_lookup_revalidate(struct dentry * dentry, struct nameidata *nd)
 	if (NFS_STALE(inode))
 		goto out_bad;
 
-	error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, &fhandle, &fattr);
+	error = -ENOMEM;
+	fhandle = nfs_alloc_fhandle();
+	fattr = nfs_alloc_fattr();
+	if (fhandle == NULL || fattr == NULL)
+		goto out_error;
+
+	error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr);
 	if (error)
 		goto out_bad;
-	if (nfs_compare_fh(NFS_FH(inode), &fhandle))
+	if (nfs_compare_fh(NFS_FH(inode), fhandle))
 		goto out_bad;
-	if ((error = nfs_refresh_inode(inode, &fattr)) != 0)
+	if ((error = nfs_refresh_inode(inode, fattr)) != 0)
 		goto out_bad;
 
+	nfs_free_fattr(fattr);
+	nfs_free_fhandle(fhandle);
 out_set_verifier:
 	nfs_set_verifier(dentry, nfs_save_change_attribute(dir));
  out_valid:
@@ -840,11 +848,21 @@ out_zap_parent:
 		shrink_dcache_parent(dentry);
 	}
 	d_drop(dentry);
+	nfs_free_fattr(fattr);
+	nfs_free_fhandle(fhandle);
 	dput(parent);
 	dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) is invalid\n",
 			__func__, dentry->d_parent->d_name.name,
 			dentry->d_name.name);
 	return 0;
+out_error:
+	nfs_free_fattr(fattr);
+	nfs_free_fhandle(fhandle);
+	dput(parent);
+	dfprintk(LOOKUPCACHE, "NFS: %s(%s/%s) lookup returned error %d\n",
+			__func__, dentry->d_parent->d_name.name,
+			dentry->d_name.name, error);
+	return error;
 }
 
 /*
@@ -909,9 +927,9 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru
 	struct dentry *res;
 	struct dentry *parent;
 	struct inode *inode = NULL;
+	struct nfs_fh *fhandle = NULL;
+	struct nfs_fattr *fattr = NULL;
 	int error;
-	struct nfs_fh fhandle;
-	struct nfs_fattr fattr;
 
 	dfprintk(VFS, "NFS: lookup(%s/%s)\n",
 		dentry->d_parent->d_name.name, dentry->d_name.name);
@@ -921,7 +939,6 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru
 	if (dentry->d_name.len > NFS_SERVER(dir)->namelen)
 		goto out;
 
-	res = ERR_PTR(-ENOMEM);
 	dentry->d_op = NFS_PROTO(dir)->dentry_ops;
 
 	/*
@@ -934,17 +951,23 @@ static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, stru
 		goto out;
 	}
 
+	res = ERR_PTR(-ENOMEM);
+	fhandle = nfs_alloc_fhandle();
+	fattr = nfs_alloc_fattr();
+	if (fhandle == NULL || fattr == NULL)
+		goto out;
+
 	parent = dentry->d_parent;
 	/* Protect against concurrent sillydeletes */
 	nfs_block_sillyrename(parent);
-	error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, &fhandle, &fattr);
+	error = NFS_PROTO(dir)->lookup(dir, &dentry->d_name, fhandle, fattr);
 	if (error == -ENOENT)
 		goto no_entry;
 	if (error < 0) {
 		res = ERR_PTR(error);
 		goto out_unblock_sillyrename;
 	}
-	inode = nfs_fhget(dentry->d_sb, &fhandle, &fattr);
+	inode = nfs_fhget(dentry->d_sb, fhandle, fattr);
 	res = (struct dentry *)inode;
 	if (IS_ERR(res))
 		goto out_unblock_sillyrename;
@@ -960,6 +983,8 @@ no_entry:
 out_unblock_sillyrename:
 	nfs_unblock_sillyrename(parent);
 out:
+	nfs_free_fattr(fattr);
+	nfs_free_fhandle(fhandle);
 	return res;
 }
 
diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c
index e701002..72334c1 100644
--- a/fs/nfs/nfs3proc.c
+++ b/fs/nfs/nfs3proc.c
@@ -144,14 +144,12 @@ static int
 nfs3_proc_lookup(struct inode *dir, struct qstr *name,
 		 struct nfs_fh *fhandle, struct nfs_fattr *fattr)
 {
-	struct nfs_fattr	dir_attr;
 	struct nfs3_diropargs	arg = {
 		.fh		= NFS_FH(dir),
 		.name		= name->name,
 		.len		= name->len
 	};
 	struct nfs3_diropres	res = {
-		.dir_attr	= &dir_attr,
 		.fh		= fhandle,
 		.fattr		= fattr
 	};
@@ -163,16 +161,20 @@ nfs3_proc_lookup(struct inode *dir, struct qstr *name,
 	int			status;
 
 	dprintk("NFS call  lookup %s\n", name->name);
-	nfs_fattr_init(&dir_attr);
+	res.dir_attr = nfs_alloc_fattr();
+	if (res.dir_attr == NULL)
+		return -ENOMEM;
+
 	nfs_fattr_init(fattr);
 	status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
-	nfs_refresh_inode(dir, &dir_attr);
+	nfs_refresh_inode(dir, res.dir_attr);
 	if (status >= 0 && !(fattr->valid & NFS_ATTR_FATTR)) {
 		msg.rpc_proc = &nfs3_procedures[NFS3PROC_GETATTR];
 		msg.rpc_argp = fhandle;
 		msg.rpc_resp = fattr;
 		status = rpc_call_sync(NFS_CLIENT(dir), &msg, 0);
 	}
+	nfs_free_fattr(res.dir_attr);
 	dprintk("NFS reply lookup: %d\n", status);
 	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           ` Trond Myklebust [this message]
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                   ` [PATCH 10/24] NFSv4: Reduce stack footprint of nfs4_proc_access() and nfs3_proc_access() Trond Myklebust
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-7-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