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

Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
---
 fs/nfs/getroot.c |   76 ++++++++++++++++++++++++++++++++---------------------
 1 files changed, 46 insertions(+), 30 deletions(-)

diff --git a/fs/nfs/getroot.c b/fs/nfs/getroot.c
index ada369a..7428f7d 100644
--- a/fs/nfs/getroot.c
+++ b/fs/nfs/getroot.c
@@ -78,46 +78,52 @@ struct dentry *nfs_get_root(struct super_block *sb, struct nfs_fh *mntfh)
 {
 	struct nfs_server *server = NFS_SB(sb);
 	struct nfs_fsinfo fsinfo;
-	struct nfs_fattr fattr;
-	struct dentry *mntroot;
+	struct dentry *ret;
 	struct inode *inode;
 	int error;
 
 	/* get the actual root for this mount */
-	fsinfo.fattr = &fattr;
+	fsinfo.fattr = nfs_alloc_fattr();
+	if (fsinfo.fattr == NULL)
+		return ERR_PTR(-ENOMEM);
 
 	error = server->nfs_client->rpc_ops->getroot(server, mntfh, &fsinfo);
 	if (error < 0) {
 		dprintk("nfs_get_root: getattr error = %d\n", -error);
-		return ERR_PTR(error);
+		ret = ERR_PTR(error);
+		goto out;
 	}
 
 	inode = nfs_fhget(sb, mntfh, fsinfo.fattr);
 	if (IS_ERR(inode)) {
 		dprintk("nfs_get_root: get root inode failed\n");
-		return ERR_CAST(inode);
+		ret = ERR_CAST(inode);
+		goto out;
 	}
 
 	error = nfs_superblock_set_dummy_root(sb, inode);
-	if (error != 0)
-		return ERR_PTR(error);
+	if (error != 0) {
+		ret = ERR_PTR(error);
+		goto out;
+	}
 
 	/* root dentries normally start off anonymous and get spliced in later
 	 * if the dentry tree reaches them; however if the dentry already
 	 * exists, we'll pick it up at this point and use it as the root
 	 */
-	mntroot = d_obtain_alias(inode);
-	if (IS_ERR(mntroot)) {
+	ret = d_obtain_alias(inode);
+	if (IS_ERR(ret)) {
 		dprintk("nfs_get_root: get root dentry failed\n");
-		return mntroot;
+		goto out;
 	}
 
-	security_d_instantiate(mntroot, inode);
+	security_d_instantiate(ret, inode);
 
-	if (!mntroot->d_op)
-		mntroot->d_op = server->nfs_client->rpc_ops->dentry_ops;
-
-	return mntroot;
+	if (ret->d_op == NULL)
+		ret->d_op = server->nfs_client->rpc_ops->dentry_ops;
+out:
+	nfs_free_fattr(fsinfo.fattr);
+	return ret;
 }
 
 #ifdef CONFIG_NFS_V4
@@ -168,8 +174,8 @@ out:
 struct dentry *nfs4_get_root(struct super_block *sb, struct nfs_fh *mntfh)
 {
 	struct nfs_server *server = NFS_SB(sb);
-	struct nfs_fattr fattr;
-	struct dentry *mntroot;
+	struct nfs_fattr *fattr = NULL;
+	struct dentry *ret;
 	struct inode *inode;
 	int error;
 
@@ -183,40 +189,50 @@ struct dentry *nfs4_get_root(struct super_block *sb, struct nfs_fh *mntfh)
 		return ERR_PTR(error);
 	}
 
+	fattr = nfs_alloc_fattr();
+	if (fattr == NULL)
+		return ERR_PTR(-ENOMEM);;
+
 	/* get the actual root for this mount */
-	error = server->nfs_client->rpc_ops->getattr(server, mntfh, &fattr);
+	error = server->nfs_client->rpc_ops->getattr(server, mntfh, fattr);
 	if (error < 0) {
 		dprintk("nfs_get_root: getattr error = %d\n", -error);
-		return ERR_PTR(error);
+		ret = ERR_PTR(error);
+		goto out;
 	}
 
-	inode = nfs_fhget(sb, mntfh, &fattr);
+	inode = nfs_fhget(sb, mntfh, fattr);
 	if (IS_ERR(inode)) {
 		dprintk("nfs_get_root: get root inode failed\n");
-		return ERR_CAST(inode);
+		ret = ERR_CAST(inode);
+		goto out;
 	}
 
 	error = nfs_superblock_set_dummy_root(sb, inode);
-	if (error != 0)
-		return ERR_PTR(error);
+	if (error != 0) {
+		ret = ERR_PTR(error);
+		goto out;
+	}
 
 	/* root dentries normally start off anonymous and get spliced in later
 	 * if the dentry tree reaches them; however if the dentry already
 	 * exists, we'll pick it up at this point and use it as the root
 	 */
-	mntroot = d_obtain_alias(inode);
-	if (IS_ERR(mntroot)) {
+	ret = d_obtain_alias(inode);
+	if (IS_ERR(ret)) {
 		dprintk("nfs_get_root: get root dentry failed\n");
-		return mntroot;
+		goto out;
 	}
 
-	security_d_instantiate(mntroot, inode);
+	security_d_instantiate(ret, inode);
 
-	if (!mntroot->d_op)
-		mntroot->d_op = server->nfs_client->rpc_ops->dentry_ops;
+	if (ret->d_op == NULL)
+		ret->d_op = server->nfs_client->rpc_ops->dentry_ops;
 
+out:
+	nfs_free_fattr(fattr);
 	dprintk("<-- nfs4_get_root()\n");
-	return mntroot;
+	return ret;
 }
 
 #endif /* CONFIG_NFS_V4 */
-- 
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               ` Trond Myklebust [this message]
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-9-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