Wrapfs/VFS: remove init_lower_nd and unexport release_lower_nd
authorErez Zadok <ezk@cs.sunysb.edu>
Tue, 5 Jan 2010 09:28:11 +0000 (04:28 -0500)
committerErez Zadok <ezk@cs.sunysb.edu>
Mon, 30 Jan 2012 00:16:13 +0000 (19:16 -0500)
Only wrapfs_create used it, and it is unnecessary to init a completely new
nameidata for the lower file system.

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
fs/namei.c
fs/wrapfs/inode.c
fs/wrapfs/lookup.c
fs/wrapfs/wrapfs.h
include/linux/namei.h

index a4189e8e9368104f79478010d0947c9536631ffe..3d150720c37182ae188eb0a3ed7bb39de76cf823 100644 (file)
@@ -492,7 +492,6 @@ void release_open_intent(struct nameidata *nd)
                        fput(file);
        }
 }
-EXPORT_SYMBOL_GPL(release_open_intent);
 
 static inline int d_revalidate(struct dentry *dentry, struct nameidata *nd)
 {
index d9d23a4527da4482392d55f928d4540136ce5e95..ca6f0d2a748559b9853a9ed485802421eeed86d2 100644 (file)
@@ -17,8 +17,7 @@ static int wrapfs_create(struct inode *dir, struct dentry *dentry,
        int err = 0;
        struct dentry *lower_dentry;
        struct dentry *lower_parent_dentry = NULL;
-       struct nameidata lower_nd;
-       struct path lower_path;
+       struct path lower_path, saved_path;
 
        wrapfs_get_lower_path(dentry, &lower_path);
        lower_dentry = lower_path.dentry;
@@ -28,15 +27,13 @@ static int wrapfs_create(struct inode *dir, struct dentry *dentry,
        if (err)
                goto out_unlock;
 
-       err = init_lower_nd(&lower_nd, LOOKUP_CREATE);
-       if (err < 0)
-               goto out;
-       err = vfs_create(lower_parent_dentry->d_inode, lower_dentry, mode,
-                        &lower_nd);
-       release_lower_nd(&lower_nd, err);
+       pathcpy(&saved_path, &nd->path);
+       pathcpy(&nd->path, &lower_path);
+       err = vfs_create(lower_parent_dentry->d_inode, lower_dentry, mode, nd);
+       pathcpy(&nd->path, &saved_path);
        if (err)
                goto out;
-       /* XXX; should we pass lower_nd.path instead of lower_path? */
+
        err = wrapfs_interpose(dentry, dir->i_sb, &lower_path);
        if (err)
                goto out;
index 480d0cda556a57ddd675c74c7a3629f408fc71b5..7f81177681ecfe38fe5e2542dee341874618df24 100644 (file)
@@ -53,73 +53,6 @@ int new_dentry_private_data(struct dentry *dentry)
        return 0;
 }
 
-/*
- * Initialize a nameidata structure (the intent part) we can pass to a lower
- * file system.  Returns 0 on success or -error (only -ENOMEM possible).
- * Inside that nd structure, this function may also return an allocated
- * struct file (for open intents).  The caller, when done with this nd, must
- * kfree the intent file (using release_lower_nd).
- *
- * XXX: this code, and the callers of this code, should be redone using
- * vfs_path_lookup() when (1) the nameidata structure is refactored into a
- * separate intent-structure, and (2) open_namei() is broken into a VFS-only
- * function and a method that other file systems can call.
- */
-int init_lower_nd(struct nameidata *nd, unsigned int flags)
-{
-       int err = 0;
-#ifdef ALLOC_LOWER_ND_FILE
-       /*
-        * XXX: one day we may need to have the lower file system return an
-        * open file for us (esp. for nfs4).
-        */
-       struct file *file;
-#endif /* ALLOC_LOWER_ND_FILE */
-
-       memset(nd, 0, sizeof(struct nameidata));
-       if (!flags)
-               return err;
-
-       switch (flags) {
-       case LOOKUP_CREATE:
-               nd->intent.open.flags |= O_CREAT;
-               /* fall through: shared code for create/open cases */
-       case LOOKUP_OPEN:
-               nd->flags = flags;
-               nd->intent.open.flags |= (FMODE_READ | FMODE_WRITE);
-#ifdef ALLOC_LOWER_ND_FILE
-               file = kzalloc(sizeof(struct file), GFP_KERNEL);
-               if (!file) {
-                       err = -ENOMEM;
-                       break; /* exit switch statement and thus return */
-               }
-               nd->intent.open.file = file;
-#endif /* ALLOC_LOWER_ND_FILE */
-               break;
-       default:
-               /*
-                * We should never get here, for now.
-                * We can add new cases here later on.
-                */
-               pr_debug("wrapfs: unknown nameidata flag 0x%x\n", flags);
-               BUG();
-               break;
-       }
-
-       return err;
-}
-
-void release_lower_nd(struct nameidata *nd, int err)
-{
-       if (!nd->intent.open.file)
-               return;
-       else if (!err)
-               release_open_intent(nd);
-#ifdef ALLOC_LOWER_ND_FILE
-       kfree(nd->intent.open.file);
-#endif /* ALLOC_LOWER_ND_FILE */
-}
-
 static int wrapfs_inode_test(struct inode *inode, void *candidate_lower_inode)
 {
        struct inode *current_lower_inode = wrapfs_lower_inode(inode);
index 1e7fcb6fec0651311af8441554b847c0d0ac8918..33ce20bb7f64da9b9daf19dd83bbe4bc5e2fbc6f 100644 (file)
@@ -51,8 +51,6 @@ extern int wrapfs_init_dentry_cache(void);
 extern void wrapfs_destroy_dentry_cache(void);
 extern int new_dentry_private_data(struct dentry *dentry);
 extern void free_dentry_private_data(struct dentry *dentry);
-extern int init_lower_nd(struct nameidata *nd, unsigned int flags);
-extern void release_lower_nd(struct nameidata *nd, int err);
 extern struct dentry *wrapfs_lookup(struct inode *dir, struct dentry *dentry,
                                    struct nameidata *nd);
 extern int wrapfs_interpose(struct dentry *dentry, struct super_block *sb,
index 7d7dfab764f5d1d31e1555f460e0736f8dfa04b3..ffc02135c483c2c6363eed8dc0a4b15b2def6656 100644 (file)
@@ -84,7 +84,6 @@ extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
 
 extern struct file *lookup_instantiate_filp(struct nameidata *nd, struct dentry *dentry,
                int (*open)(struct inode *, struct file *));
-extern void release_open_intent(struct nameidata *);
 
 extern struct dentry *lookup_one_len(const char *, struct dentry *, int);