[PATCH 4/4] fs/unionfs/: Don't duplicate the struct nameidata

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Josef 'Jeff' Sipek
Date: Monday, January 29, 2007 - 1:37 pm

The only fields that we have to watch out for are the dentry and vfsmount.
Additionally, this makes Unionfs gentler on the stack as nameidata is rather
large.

Signed-off-by: Josef 'Jeff' Sipek <jsipek@cs.sunysb.edu>
---
 fs/unionfs/inode.c |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/fs/unionfs/inode.c b/fs/unionfs/inode.c
index 3b4a388..1b2e8a8 100644
--- a/fs/unionfs/inode.c
+++ b/fs/unionfs/inode.c
@@ -191,15 +191,25 @@ static struct dentry *unionfs_lookup(struct inode *parent,
 				     struct dentry *dentry,
 				     struct nameidata *nd)
 {
-	struct nameidata lowernd; /* TODO: be gentler to the stack */
+	struct path path_save;
+	struct dentry *ret;
 
-	if (nd)
-		memcpy(&lowernd, nd, sizeof(struct nameidata));
-	else
-		memset(&lowernd, 0, sizeof(struct nameidata));
+	/* save the dentry & vfsmnt from namei */
+	if (nd) {
+		path_save.dentry = nd->dentry;
+		path_save.mnt = nd->mnt;
+	}
 
 	/* The locking is done by unionfs_lookup_backend. */
-	return unionfs_lookup_backend(dentry, &lowernd, INTERPOSE_LOOKUP);
+	ret = unionfs_lookup_backend(dentry, nd, INTERPOSE_LOOKUP);
+
+	/* restore the dentry & vfsmnt in namei */
+	if (nd) {
+		nd->dentry = path_save.dentry;
+		nd->mnt = path_save.mnt;
+	}
+
+	return ret;
 }
 
 static int unionfs_link(struct dentry *old_dentry, struct inode *dir,
-- 
1.5.0.rc1.g5355

-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[GIT PULL -mm] Unionfs updates/cleanups, Josef 'Jeff' Sipek, (Mon Jan 29, 1:37 pm)
[PATCH 1/4] fs/unionfs/: Remove stale_inode.c, Josef 'Jeff' Sipek, (Mon Jan 29, 1:37 pm)
[PATCH 2/4] fs/unionfs/: possible cleanups, Josef 'Jeff' Sipek, (Mon Jan 29, 1:37 pm)
[PATCH 3/4] fs/unionfs/: Andrew Morton's comments, Josef 'Jeff' Sipek, (Mon Jan 29, 1:37 pm)
[PATCH 4/4] fs/unionfs/: Don't duplicate the struct nameidata, Josef 'Jeff' Sipek, (Mon Jan 29, 1:37 pm)
[PATCH 4/4] fs/unionfs/: Don't duplicate the struct nameidata, Josef 'Jeff' Sipek, (Mon Jan 29, 1:37 pm)
Re: [PATCH 4/4] fs/unionfs/: Don't duplicate the struct na ..., Christoph Hellwig, (Tue Jan 30, 2:42 am)