Unionfs: port to 2.6.39
authorErez Zadok <ezk@cs.sunysb.edu>
Sat, 30 Apr 2011 05:33:19 +0000 (01:33 -0400)
committerErez Zadok <ezk@cs.sunysb.edu>
Fri, 12 Aug 2011 02:39:28 +0000 (22:39 -0400)
Remove lock/unlock_kernel in ->fasync.
Convert from ->get_sb to ->mount op.
Remove include to smp_lock.h, added sched.h.
Convert from path_lookup(nd) to kern_path(path).

Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu>
fs/unionfs/main.c
fs/unionfs/super.c
fs/unionfs/union.h

index 9ee58eb48034fe06bdc546ca17812e48219dd251..dbed9fa636c848afb00d0b0b7b2619ccc229f7b9 100644 (file)
@@ -215,14 +215,14 @@ void unionfs_reinterpose(struct dentry *dentry)
  * 2) it exists
  * 3) is a directory
  */
-int check_branch(struct nameidata *nd)
+int check_branch(const struct path *path)
 {
        /* XXX: remove in ODF code -- stacking unions allowed there */
-       if (!strcmp(nd->path.dentry->d_sb->s_type->name, UNIONFS_NAME))
+       if (!strcmp(path->dentry->d_sb->s_type->name, UNIONFS_NAME))
                return -EINVAL;
-       if (!nd->path.dentry->d_inode)
+       if (!path->dentry->d_inode)
                return -ENOENT;
-       if (!S_ISDIR(nd->path.dentry->d_inode->i_mode))
+       if (!S_ISDIR(path->dentry->d_inode->i_mode))
                return -ENOTDIR;
        return 0;
 }
@@ -274,7 +274,7 @@ int parse_branch_mode(const char *name, int *perms)
 static int parse_dirs_option(struct super_block *sb, struct unionfs_dentry_info
                             *lower_root_info, char *options)
 {
-       struct nameidata nd;
+       struct path path;
        char *name;
        int err = 0;
        int branches = 1;
@@ -350,7 +350,7 @@ static int parse_dirs_option(struct super_block *sb, struct unionfs_dentry_info
                        goto out;
                }
 
-               err = path_lookup(name, LOOKUP_FOLLOW, &nd);
+               err = kern_path(name, LOOKUP_FOLLOW, &path);
                if (err) {
                        printk(KERN_ERR "unionfs: error accessing "
                               "lower directory '%s' (error %d)\n",
@@ -358,16 +358,16 @@ static int parse_dirs_option(struct super_block *sb, struct unionfs_dentry_info
                        goto out;
                }
 
-               err = check_branch(&nd);
+               err = check_branch(&path);
                if (err) {
                        printk(KERN_ERR "unionfs: lower directory "
                               "'%s' is not a valid branch\n", name);
-                       path_put(&nd.path);
+                       path_put(&path);
                        goto out;
                }
 
-               lower_root_info->lower_paths[bindex].dentry = nd.path.dentry;
-               lower_root_info->lower_paths[bindex].mnt = nd.path.mnt;
+               lower_root_info->lower_paths[bindex].dentry = path.dentry;
+               lower_root_info->lower_paths[bindex].mnt = path.mnt;
 
                set_branchperms(sb, bindex, perms);
                set_branch_count(sb, bindex, 0);
@@ -693,22 +693,23 @@ out:
        return err;
 }
 
-static int unionfs_get_sb(struct file_system_type *fs_type,
-                         int flags, const char *dev_name,
-                         void *raw_data, struct vfsmount *mnt)
+static struct dentry *unionfs_mount(struct file_system_type *fs_type,
+                                   int flags, const char *dev_name,
+                                   void *raw_data)
 {
-       int err;
-       err = get_sb_nodev(fs_type, flags, raw_data, unionfs_read_super, mnt);
-       if (!err)
-               UNIONFS_SB(mnt->mnt_sb)->dev_name =
+       struct dentry *dentry;
+
+       dentry = mount_nodev(fs_type, flags, raw_data, unionfs_read_super);
+       if (!PTR_ERR(dentry))
+               UNIONFS_SB(dentry->d_sb)->dev_name =
                        kstrdup(dev_name, GFP_KERNEL);
-       return err;
+       return dentry;
 }
 
 static struct file_system_type unionfs_fs_type = {
        .owner          = THIS_MODULE,
        .name           = UNIONFS_NAME,
-       .get_sb         = unionfs_get_sb,
+       .mount          = unionfs_mount,
        .kill_sb        = generic_shutdown_super,
        .fs_flags       = FS_REVAL_DOT,
 };
index 45bb9bf939089a8e70cd6edf2f2874b8a2fff949..59948841662a7b79360d8cfdde22dc2c287d4cf5 100644 (file)
@@ -183,7 +183,7 @@ static noinline_for_stack int do_remount_mode_option(
        int err = -EINVAL;
        int perms, idx;
        char *modename = strchr(optarg, '=');
-       struct nameidata nd;
+       struct path path;
 
        /* by now, optarg contains the branch name */
        if (!*optarg) {
@@ -210,7 +210,7 @@ static noinline_for_stack int do_remount_mode_option(
         * and cache-coherency resolved, we'll address the branch-path
         * uniqueness.
         */
-       err = path_lookup(optarg, LOOKUP_FOLLOW, &nd);
+       err = kern_path(optarg, LOOKUP_FOLLOW, &path);
        if (err) {
                printk(KERN_ERR "unionfs: error accessing "
                       "lower directory \"%s\" (error %d)\n",
@@ -218,10 +218,10 @@ static noinline_for_stack int do_remount_mode_option(
                goto out;
        }
        for (idx = 0; idx < cur_branches; idx++)
-               if (nd.path.mnt == new_lower_paths[idx].mnt &&
-                   nd.path.dentry == new_lower_paths[idx].dentry)
+               if (path.mnt == new_lower_paths[idx].mnt &&
+                   path.dentry == new_lower_paths[idx].dentry)
                        break;
-       path_put(&nd.path);     /* no longer needed */
+       path_put(&path);        /* no longer needed */
        if (idx == cur_branches) {
                err = -ENOENT;  /* err may have been reset above */
                printk(KERN_ERR "unionfs: branch \"%s\" "
@@ -244,7 +244,7 @@ static noinline_for_stack int do_remount_del_option(
 {
        int err = -EINVAL;
        int idx;
-       struct nameidata nd;
+       struct path path;
 
        /* optarg contains the branch name to delete */
 
@@ -254,7 +254,7 @@ static noinline_for_stack int do_remount_del_option(
         * and cache-coherency resolved, we'll address the branch-path
         * uniqueness.
         */
-       err = path_lookup(optarg, LOOKUP_FOLLOW, &nd);
+       err = kern_path(optarg, LOOKUP_FOLLOW, &path);
        if (err) {
                printk(KERN_ERR "unionfs: error accessing "
                       "lower directory \"%s\" (error %d)\n",
@@ -262,10 +262,10 @@ static noinline_for_stack int do_remount_del_option(
                goto out;
        }
        for (idx = 0; idx < cur_branches; idx++)
-               if (nd.path.mnt == new_lower_paths[idx].mnt &&
-                   nd.path.dentry == new_lower_paths[idx].dentry)
+               if (path.mnt == new_lower_paths[idx].mnt &&
+                   path.dentry == new_lower_paths[idx].dentry)
                        break;
-       path_put(&nd.path);     /* no longer needed */
+       path_put(&path);        /* no longer needed */
        if (idx == cur_branches) {
                printk(KERN_ERR "unionfs: branch \"%s\" "
                       "not found\n", optarg);
@@ -311,7 +311,7 @@ static noinline_for_stack int do_remount_add_option(
        int perms;
        int idx = 0;            /* default: insert at beginning */
        char *new_branch , *modename = NULL;
-       struct nameidata nd;
+       struct path path;
 
        /*
         * optarg can be of several forms:
@@ -339,7 +339,7 @@ static noinline_for_stack int do_remount_add_option(
         * and cache-coherency resolved, we'll address the branch-path
         * uniqueness.
         */
-       err = path_lookup(optarg, LOOKUP_FOLLOW, &nd);
+       err = kern_path(optarg, LOOKUP_FOLLOW, &path);
        if (err) {
                printk(KERN_ERR "unionfs: error accessing "
                       "lower directory \"%s\" (error %d)\n",
@@ -347,10 +347,10 @@ static noinline_for_stack int do_remount_add_option(
                goto out;
        }
        for (idx = 0; idx < cur_branches; idx++)
-               if (nd.path.mnt == new_lower_paths[idx].mnt &&
-                   nd.path.dentry == new_lower_paths[idx].dentry)
+               if (path.mnt == new_lower_paths[idx].mnt &&
+                   path.dentry == new_lower_paths[idx].dentry)
                        break;
-       path_put(&nd.path);     /* no longer needed */
+       path_put(&path);        /* no longer needed */
        if (idx == cur_branches) {
                printk(KERN_ERR "unionfs: branch \"%s\" "
                       "not found\n", optarg);
@@ -379,7 +379,7 @@ found_insertion_point:
                       "branch \"%s\"\n", modename, new_branch);
                goto out;
        }
-       err = path_lookup(new_branch, LOOKUP_FOLLOW, &nd);
+       err = kern_path(new_branch, LOOKUP_FOLLOW, &path);
        if (err) {
                printk(KERN_ERR "unionfs: error accessing "
                       "lower directory \"%s\" (error %d)\n",
@@ -393,11 +393,11 @@ found_insertion_point:
         * because this code base doesn't support stacking unionfs: the ODF
         * code base supports that correctly.
         */
-       err = check_branch(&nd);
+       err = check_branch(&path);
        if (err) {
                printk(KERN_ERR "unionfs: lower directory "
                       "\"%s\" is not a valid branch\n", optarg);
-               path_put(&nd.path);
+               path_put(&path);
                goto out;
        }
 
@@ -414,10 +414,10 @@ found_insertion_point:
                memmove(&new_lower_paths[idx+1], &new_lower_paths[idx],
                        (cur_branches - idx) * sizeof(struct path));
        }
-       new_lower_paths[idx].dentry = nd.path.dentry;
-       new_lower_paths[idx].mnt = nd.path.mnt;
+       new_lower_paths[idx].dentry = path.dentry;
+       new_lower_paths[idx].mnt = path.mnt;
 
-       new_data[idx].sb = nd.path.dentry->d_sb;
+       new_data[idx].sb = path.dentry->d_sb;
        atomic_set(&new_data[idx].open_files, 0);
        new_data[idx].branchperms = perms;
        new_data[idx].branch_id = ++*high_branch_id; /* assign new branch ID */
@@ -569,10 +569,10 @@ static int unionfs_remount_fs(struct super_block *sb, int *flags,
                path_get(&tmp_lower_paths[i]); /* drop refs at end of fxn */
 
        /*******************************************************************
-        * For each branch command, do path_lookup on the requested branch,
+        * For each branch command, do kern_path on the requested branch,
         * and apply the change to a temp branch list.  To handle errors, we
         * already dup'ed the old arrays (above), and increased the refcnts
-        * on various f/s objects.  So now we can do all the path_lookups
+        * on various f/s objects.  So now we can do all the kern_path'ss
         * and branch-management commands on the new arrays.  If it fail mid
         * way, we free the tmp arrays and *put all objects.  If we succeed,
         * then we free old arrays and *put its objects, and then replace
index 6c7b9aaf9e8dc5f65dde54d02aadd5bd51f91071..b634babaa836a343d39251db33b3fedd22e6b030 100644 (file)
@@ -33,7 +33,6 @@
 #include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
-#include <linux/smp_lock.h>
 #include <linux/statfs.h>
 #include <linux/string.h>
 #include <linux/vmalloc.h>
@@ -47,6 +46,7 @@
 #include <linux/mman.h>
 #include <linux/backing-dev.h>
 #include <linux/splice.h>
+#include <linux/sched.h>
 
 #include <asm/system.h>
 
@@ -537,7 +537,7 @@ static inline int is_robranch(const struct dentry *dentry)
 /*
  * EXTERNALS:
  */
-extern int check_branch(struct nameidata *nd);
+extern int check_branch(const struct path *path);
 extern int parse_branch_mode(const char *name, int *perms);
 
 /* locking helpers */