[patch 00/10] Use struct path in struct nameidata - Kernel

This is a discussion on [patch 00/10] Use struct path in struct nameidata - Kernel ; This is a respin of the patch series Andreas posted last month. It leaves out the restructuring of the intent which will be done at a later point in time. There are three preparing patches that remove unneeded code IMHO. ...

+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 20 of 26

Thread: [patch 00/10] Use struct path in struct nameidata

  1. [patch 00/10] Use struct path in struct nameidata

    This is a respin of the patch series Andreas posted last month. It leaves out
    the restructuring of the intent which will be done at a later point in time.

    There are three preparing patches that remove unneeded code IMHO. I haven't
    got feedback from Takashi since he is on holiday. Please, can somebody else
    acknowledge the changes?

    Comments?
    Jan
    --

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  2. [patch 08/10] Introduce path_get()

    This introduces the symmetric function to path_put() for getting a reference
    to the dentry and vfsmount of a struct path in the right order.

    Signed-off-by: Jan Blunck
    Signed-off-by: Andreas Gruenbacher
    ---
    fs/namei.c | 17 +++++++++++++++--
    include/linux/path.h | 1 +
    2 files changed, 16 insertions(+), 2 deletions(-)

    Index: b/fs/namei.c
    ================================================== =================
    --- a/fs/namei.c
    +++ b/fs/namei.c
    @@ -348,6 +348,20 @@ int deny_write_access(struct file * file
    }

    /**
    + * path_get - get a reference to a path
    + * @path: path to get the reference to
    + *
    + * Given a path increment the reference count to the dentry and the vfsmount.
    + */
    +struct path *path_get(struct path *path)
    +{
    + mntget(path->mnt);
    + dget(path->dentry);
    + return path;
    +}
    +EXPORT_SYMBOL(path_get);
    +
    +/**
    * path_put - put a reference to a path
    * @path: path to put the reference to
    *
    @@ -1145,8 +1159,7 @@ static int fastcall do_path_lookup(int d
    if (retval)
    goto fput_fail;

    - nd->path.mnt = mntget(file->f_path.mnt);
    - nd->path.dentry = dget(dentry);
    + nd->path = *path_get(&file->f_path);

    fput_light(file, fput_needed);
    }
    Index: b/include/linux/path.h
    ================================================== =================
    --- a/include/linux/path.h
    +++ b/include/linux/path.h
    @@ -9,6 +9,7 @@ struct path {
    struct dentry *dentry;
    };

    +extern struct path *path_get(struct path *);
    extern void path_put(struct path *);

    #endif /* _LINUX_PATH_H */

    --

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  3. [patch 10/10] Make set_fs_{root,pwd} take a struct path

    In nearly all cases the set_fs_{root,pwd}() calls work on a struct
    path. Change the function to reflect this and use path_get() here.

    Signed-off-by: Jan Blunck
    Signed-off-by: Andreas Gruenbacher
    ---
    fs/namespace.c | 26 ++++++++++++--------------
    fs/open.c | 12 ++++--------
    include/linux/fs_struct.h | 4 ++--
    3 files changed, 18 insertions(+), 24 deletions(-)

    Index: b/fs/namespace.c
    ================================================== =================
    --- a/fs/namespace.c
    +++ b/fs/namespace.c
    @@ -1580,15 +1580,13 @@ out1:
    * Replace the fs->{rootmnt,root} with {mnt,dentry}. Put the old values.
    * It can block. Requires the big lock held.
    */
    -void set_fs_root(struct fs_struct *fs, struct vfsmount *mnt,
    - struct dentry *dentry)
    +void set_fs_root(struct fs_struct *fs, struct path *path)
    {
    struct path old_root;

    write_lock(&fs->lock);
    old_root = fs->root;
    - fs->root.mnt = mntget(mnt);
    - fs->root.dentry = dget(dentry);
    + fs->root = *path_get(path);
    write_unlock(&fs->lock);
    if (old_root.dentry)
    path_put(&old_root);
    @@ -1598,15 +1596,13 @@ void set_fs_root(struct fs_struct *fs, s
    * Replace the fs->{pwdmnt,pwd} with {mnt,dentry}. Put the old values.
    * It can block. Requires the big lock held.
    */
    -void set_fs_pwd(struct fs_struct *fs, struct vfsmount *mnt,
    - struct dentry *dentry)
    +void set_fs_pwd(struct fs_struct *fs, struct path *path)
    {
    struct path old_pwd;

    write_lock(&fs->lock);
    old_pwd = fs->pwd;
    - fs->pwd.mnt = mntget(mnt);
    - fs->pwd.dentry = dget(dentry);
    + fs->pwd = *path_get(path);
    write_unlock(&fs->lock);

    if (old_pwd.dentry)
    @@ -1627,12 +1623,10 @@ static void chroot_fs_refs(struct nameid
    task_unlock(p);
    if (fs->root.dentry == old_nd->path.dentry
    && fs->root.mnt == old_nd->path.mnt)
    - set_fs_root(fs, new_nd->path.mnt,
    - new_nd->path.dentry);
    + set_fs_root(fs, &new_nd->path);
    if (fs->pwd.dentry == old_nd->path.dentry
    && fs->pwd.mnt == old_nd->path.mnt)
    - set_fs_pwd(fs, new_nd->path.mnt,
    - new_nd->path.dentry);
    + set_fs_pwd(fs, &new_nd->path);
    put_fs_struct(fs);
    } else
    task_unlock(p);
    @@ -1774,6 +1768,7 @@ static void __init init_mount_tree(void)
    {
    struct vfsmount *mnt;
    struct mnt_namespace *ns;
    + struct path root;

    mnt = do_kern_mount("rootfs", 0, "rootfs", NULL);
    if (IS_ERR(mnt))
    @@ -1792,8 +1787,11 @@ static void __init init_mount_tree(void)
    init_task.nsproxy->mnt_ns = ns;
    get_mnt_ns(ns);

    - set_fs_pwd(current->fs, ns->root, ns->root->mnt_root);
    - set_fs_root(current->fs, ns->root, ns->root->mnt_root);
    + root.mnt = ns->root;
    + root.dentry = ns->root->mnt_root;
    +
    + set_fs_pwd(current->fs, &root);
    + set_fs_root(current->fs, &root);
    }

    void __init mnt_init(unsigned long mempages)
    Index: b/fs/open.c
    ================================================== =================
    --- a/fs/open.c
    +++ b/fs/open.c
    @@ -490,7 +490,7 @@ asmlinkage long sys_chdir(const char __u
    if (error)
    goto dput_and_out;

    - set_fs_pwd(current->fs, nd.path.mnt, nd.path.dentry);
    + set_fs_pwd(current->fs, &nd.path);

    dput_and_out:
    path_put(&nd.path);
    @@ -501,9 +501,7 @@ out:
    asmlinkage long sys_fchdir(unsigned int fd)
    {
    struct file *file;
    - struct dentry *dentry;
    struct inode *inode;
    - struct vfsmount *mnt;
    int error;

    error = -EBADF;
    @@ -511,9 +509,7 @@ asmlinkage long sys_fchdir(unsigned int
    if (!file)
    goto out;

    - dentry = file->f_path.dentry;
    - mnt = file->f_path.mnt;
    - inode = dentry->d_inode;
    + inode = file->f_path.dentry->d_inode;

    error = -ENOTDIR;
    if (!S_ISDIR(inode->i_mode))
    @@ -521,7 +517,7 @@ asmlinkage long sys_fchdir(unsigned int

    error = file_permission(file, MAY_EXEC);
    if (!error)
    - set_fs_pwd(current->fs, mnt, dentry);
    + set_fs_pwd(current->fs, &file->f_path);
    out_putf:
    fput(file);
    out:
    @@ -545,7 +541,7 @@ asmlinkage long sys_chroot(const char __
    if (!capable(CAP_SYS_CHROOT))
    goto dput_and_out;

    - set_fs_root(current->fs, nd.path.mnt, nd.path.dentry);
    + set_fs_root(current->fs, &nd.path);
    set_fs_altroot();
    error = 0;
    dput_and_out:
    Index: b/include/linux/fs_struct.h
    ================================================== =================
    --- a/include/linux/fs_struct.h
    +++ b/include/linux/fs_struct.h
    @@ -20,8 +20,8 @@ extern struct kmem_cache *fs_cachep;

    extern void exit_fs(struct task_struct *);
    extern void set_fs_altroot(void);
    -extern void set_fs_root(struct fs_struct *, struct vfsmount *, struct dentry *);
    -extern void set_fs_pwd(struct fs_struct *, struct vfsmount *, struct dentry *);
    +extern void set_fs_root(struct fs_struct *, struct path *);
    +extern void set_fs_pwd(struct fs_struct *, struct path *);
    extern struct fs_struct *copy_fs_struct(struct fs_struct *);
    extern void put_fs_struct(struct fs_struct *);


    --

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  4. [patch 04/10] Move struct path into its own header

    Move the definition of struct path into its own header file for further
    patches.

    Signed-off-by: Jan Blunck
    Signed-off-by: Andreas Gruenbacher
    ---
    include/linux/namei.h | 6 +-----
    include/linux/path.h | 12 ++++++++++++
    2 files changed, 13 insertions(+), 5 deletions(-)

    Index: b/include/linux/namei.h
    ================================================== =================
    --- a/include/linux/namei.h
    +++ b/include/linux/namei.h
    @@ -3,6 +3,7 @@

    #include
    #include
    +#include

    struct vfsmount;

    @@ -29,11 +30,6 @@ struct nameidata {
    } intent;
    };

    -struct path {
    - struct vfsmount *mnt;
    - struct dentry *dentry;
    -};
    -
    /*
    * Type of the last component on LOOKUP_PARENT
    */
    Index: b/include/linux/path.h
    ================================================== =================
    --- /dev/null
    +++ b/include/linux/path.h
    @@ -0,0 +1,12 @@
    +#ifndef _LINUX_PATH_H
    +#define _LINUX_PATH_H
    +
    +struct dentry;
    +struct vfsmount;
    +
    +struct path {
    + struct vfsmount *mnt;
    + struct dentry *dentry;
    +};
    +
    +#endif /* _LINUX_PATH_H */

    --

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  5. [patch 06/10] Introduce path_put()

    * Add path_put() functions for releasing a reference to the dentry and
    vfsmount of a struct path in the right order

    * Switch from path_release(nd) to path_put(&nd->path)

    * Rename dput_path() to path_put_conditional()

    Signed-off-by: Jan Blunck
    Signed-off-by: Andreas Gruenbacher
    ---
    arch/alpha/kernel/osf_sys.c | 2
    arch/mips/kernel/sysirix.c | 6 +-
    arch/parisc/hpux/sys_hpux.c | 2
    arch/powerpc/platforms/cell/spufs/syscalls.c | 2
    arch/sparc64/solaris/fs.c | 4 -
    drivers/md/dm-table.c | 2
    drivers/mtd/mtdsuper.c | 4 -
    fs/afs/mntpt.c | 2
    fs/autofs4/root.c | 2
    fs/block_dev.c | 2
    fs/coda/pioctl.c | 4 -
    fs/compat.c | 4 -
    fs/configfs/symlink.c | 4 -
    fs/dquot.c | 2
    fs/ecryptfs/main.c | 2
    fs/exec.c | 4 -
    fs/ext3/super.c | 4 -
    fs/ext4/super.c | 4 -
    fs/gfs2/ops_fstype.c | 2
    fs/inotify_user.c | 4 -
    fs/namei.c | 56 ++++++++++++++-------------
    fs/namespace.c | 20 ++++-----
    fs/nfs/namespace.c | 2
    fs/nfsctl.c | 2
    fs/nfsd/export.c | 10 ++--
    fs/nfsd/nfs4recover.c | 2
    fs/nfsd/nfs4state.c | 2
    fs/open.c | 22 +++++-----
    fs/proc/base.c | 2
    fs/reiserfs/super.c | 8 +--
    fs/stat.c | 6 +-
    fs/utimes.c | 2
    fs/xattr.c | 16 +++----
    fs/xfs/linux-2.6/xfs_ioctl.c | 2
    include/linux/namei.h | 1
    include/linux/path.h | 2
    kernel/auditfilter.c | 4 -
    net/sunrpc/rpc_pipe.c | 2
    net/unix/af_unix.c | 6 +-
    39 files changed, 118 insertions(+), 111 deletions(-)

    Index: b/arch/alpha/kernel/osf_sys.c
    ================================================== =================
    --- a/arch/alpha/kernel/osf_sys.c
    +++ b/arch/alpha/kernel/osf_sys.c
    @@ -261,7 +261,7 @@ osf_statfs(char __user *path, struct osf
    retval = user_path_walk(path, &nd);
    if (!retval) {
    retval = do_osf_statfs(nd.path.dentry, buffer, bufsiz);
    - path_release(&nd);
    + path_put(&nd.path);
    }
    return retval;
    }
    Index: b/arch/mips/kernel/sysirix.c
    ================================================== =================
    --- a/arch/mips/kernel/sysirix.c
    +++ b/arch/mips/kernel/sysirix.c
    @@ -711,7 +711,7 @@ asmlinkage int irix_statfs(const char __
    }

    dput_and_out:
    - path_release(&nd);
    + path_put(&nd.path);
    out:
    return error;
    }
    @@ -1385,7 +1385,7 @@ asmlinkage int irix_statvfs(char __user
    error |= __put_user(0, &buf->f_fstr[i]);

    dput_and_out:
    - path_release(&nd);
    + path_put(&nd.path);
    out:
    return error;
    }
    @@ -1636,7 +1636,7 @@ asmlinkage int irix_statvfs64(char __use
    error |= __put_user(0, &buf->f_fstr[i]);

    dput_and_out:
    - path_release(&nd);
    + path_put(&nd.path);
    out:
    return error;
    }
    Index: b/arch/parisc/hpux/sys_hpux.c
    ================================================== =================
    --- a/arch/parisc/hpux/sys_hpux.c
    +++ b/arch/parisc/hpux/sys_hpux.c
    @@ -222,7 +222,7 @@ asmlinkage long hpux_statfs(const char _
    error = vfs_statfs_hpux(nd.path.dentry, &tmp);
    if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
    error = -EFAULT;
    - path_release(&nd);
    + path_put(&nd.path);
    }
    return error;
    }
    Index: b/arch/powerpc/platforms/cell/spufs/syscalls.c
    ================================================== =================
    --- a/arch/powerpc/platforms/cell/spufs/syscalls.c
    +++ b/arch/powerpc/platforms/cell/spufs/syscalls.c
    @@ -91,7 +91,7 @@ asmlinkage long do_spu_create(const char
    LOOKUP_OPEN|LOOKUP_CREATE, &nd);
    if (!ret) {
    ret = spufs_create(&nd, flags, mode, neighbor);
    - path_release(&nd);
    + path_put(&nd.path);
    }
    putname(tmp);
    }
    Index: b/arch/sparc64/solaris/fs.c
    ================================================== =================
    --- a/arch/sparc64/solaris/fs.c
    +++ b/arch/sparc64/solaris/fs.c
    @@ -436,7 +436,7 @@ asmlinkage int solaris_statvfs(u32 path,
    if (!error) {
    struct inode *inode = nd.path.dentry->d_inode;
    error = report_statvfs(nd.path.mnt, inode, buf);
    - path_release(&nd);
    + path_put(&nd.path);
    }
    return error;
    }
    @@ -466,7 +466,7 @@ asmlinkage int solaris_statvfs64(u32 pat
    if (!error) {
    struct inode *inode = nd.path.dentry->d_inode;
    error = report_statvfs64(nd.path.mnt, inode, buf);
    - path_release(&nd);
    + path_put(&nd.path);
    }
    unlock_kernel();
    return error;
    Index: b/drivers/md/dm-table.c
    ================================================== =================
    --- a/drivers/md/dm-table.c
    +++ b/drivers/md/dm-table.c
    @@ -370,7 +370,7 @@ static int lookup_device(const char *pat
    *dev = inode->i_rdev;

    out:
    - path_release(&nd);
    + path_put(&nd.path);
    return r;
    }

    Index: b/drivers/mtd/mtdsuper.c
    ================================================== =================
    --- a/drivers/mtd/mtdsuper.c
    +++ b/drivers/mtd/mtdsuper.c
    @@ -203,7 +203,7 @@ int get_sb_mtd(struct file_system_type *
    goto not_an_MTD_device;

    mtdnr = iminor(nd.path.dentry->d_inode);
    - path_release(&nd);
    + path_put(&nd.path);

    return get_sb_mtd_nr(fs_type, flags, dev_name, data, mtdnr, fill_super,
    mnt);
    @@ -214,7 +214,7 @@ not_an_MTD_device:
    "MTD: Attempt to mount non-MTD device \"%s\"\n",
    dev_name);
    out:
    - path_release(&nd);
    + path_put(&nd.path);
    return ret;

    }
    Index: b/fs/afs/mntpt.c
    ================================================== =================
    --- a/fs/afs/mntpt.c
    +++ b/fs/afs/mntpt.c
    @@ -227,7 +227,7 @@ static void *afs_mntpt_follow_link(struc

    newmnt = afs_mntpt_do_automount(nd->path.dentry);
    if (IS_ERR(newmnt)) {
    - path_release(nd);
    + path_put(&nd->path);
    return (void *)newmnt;
    }

    Index: b/fs/autofs4/root.c
    ================================================== =================
    --- a/fs/autofs4/root.c
    +++ b/fs/autofs4/root.c
    @@ -383,7 +383,7 @@ done:
    return NULL;

    out_error:
    - path_release(nd);
    + path_put(&nd->path);
    return ERR_PTR(status);
    }

    Index: b/fs/block_dev.c
    ================================================== =================
    --- a/fs/block_dev.c
    +++ b/fs/block_dev.c
    @@ -1398,7 +1398,7 @@ struct block_device *lookup_bdev(const c
    if (!bdev)
    goto fail;
    out:
    - path_release(&nd);
    + path_put(&nd.path);
    return bdev;
    fail:
    bdev = ERR_PTR(error);
    Index: b/fs/coda/pioctl.c
    ================================================== =================
    --- a/fs/coda/pioctl.c
    +++ b/fs/coda/pioctl.c
    @@ -80,7 +80,7 @@ static int coda_pioctl(struct inode * in

    /* return if it is not a Coda inode */
    if ( target_inode->i_sb != inode->i_sb ) {
    - path_release(&nd);
    + path_put(&nd.path);
    return -EINVAL;
    }

    @@ -89,7 +89,7 @@ static int coda_pioctl(struct inode * in

    error = venus_pioctl(inode->i_sb, &(cnp->c_fid), cmd, &data);

    - path_release(&nd);
    + path_put(&nd.path);
    return error;
    }

    Index: b/fs/compat.c
    ================================================== =================
    --- a/fs/compat.c
    +++ b/fs/compat.c
    @@ -244,7 +244,7 @@ asmlinkage long compat_sys_statfs(const
    error = vfs_statfs(nd.path.dentry, &tmp);
    if (!error)
    error = put_compat_statfs(buf, &tmp);
    - path_release(&nd);
    + path_put(&nd.path);
    }
    return error;
    }
    @@ -312,7 +312,7 @@ asmlinkage long compat_sys_statfs64(cons
    error = vfs_statfs(nd.path.dentry, &tmp);
    if (!error)
    error = put_compat_statfs64(buf, &tmp);
    - path_release(&nd);
    + path_put(&nd.path);
    }
    return error;
    }
    Index: b/fs/configfs/symlink.c
    ================================================== =================
    --- a/fs/configfs/symlink.c
    +++ b/fs/configfs/symlink.c
    @@ -103,7 +103,7 @@ static int get_target(const char *symnam
    *target = configfs_get_config_item(nd->path.dentry);
    if (!*target) {
    ret = -ENOENT;
    - path_release(nd);
    + path_put(&nd->path);
    }
    } else
    ret = -EPERM;
    @@ -141,7 +141,7 @@ int configfs_symlink(struct inode *dir,
    ret = create_link(parent_item, target_item, dentry);

    config_item_put(target_item);
    - path_release(&nd);
    + path_put(&nd.path);

    out_put:
    config_item_put(parent_item);
    Index: b/fs/dquot.c
    ================================================== =================
    --- a/fs/dquot.c
    +++ b/fs/dquot.c
    @@ -1553,7 +1553,7 @@ int vfs_quota_on(struct super_block *sb,
    error = vfs_quota_on_inode(nd.path.dentry->d_inode, type,
    format_id);
    out_path:
    - path_release(&nd);
    + path_put(&nd.path);
    return error;
    }

    Index: b/fs/ecryptfs/main.c
    ================================================== =================
    --- a/fs/ecryptfs/main.c
    +++ b/fs/ecryptfs/main.c
    @@ -500,7 +500,7 @@ static int ecryptfs_read_super(struct su
    rc = 0;
    goto out;
    out_free:
    - path_release(&nd);
    + path_put(&nd.path);
    out:
    return rc;
    }
    Index: b/fs/exec.c
    ================================================== =================
    --- a/fs/exec.c
    +++ b/fs/exec.c
    @@ -174,7 +174,7 @@ out:
    return error;
    exit:
    release_open_intent(&nd);
    - path_release(&nd);
    + path_put(&nd.path);
    goto out;
    }

    @@ -698,7 +698,7 @@ out:
    }
    }
    release_open_intent(&nd);
    - path_release(&nd);
    + path_put(&nd.path);
    }
    goto out;
    }
    Index: b/fs/ext3/super.c
    ================================================== =================
    --- a/fs/ext3/super.c
    +++ b/fs/ext3/super.c
    @@ -2648,7 +2648,7 @@ static int ext3_quota_on(struct super_bl
    return err;
    /* Quotafile not on the same filesystem? */
    if (nd.path.mnt->mnt_sb != sb) {
    - path_release(&nd);
    + path_put(&nd.path);
    return -EXDEV;
    }
    /* Quotafile not of fs root? */
    @@ -2656,7 +2656,7 @@ static int ext3_quota_on(struct super_bl
    printk(KERN_WARNING
    "EXT3-fs: Quota file not on filesystem root. "
    "Journalled quota will not work.\n");
    - path_release(&nd);
    + path_put(&nd.path);
    return vfs_quota_on(sb, type, format_id, path);
    }

    Index: b/fs/ext4/super.c
    ================================================== =================
    --- a/fs/ext4/super.c
    +++ b/fs/ext4/super.c
    @@ -2768,7 +2768,7 @@ static int ext4_quota_on(struct super_bl
    return err;
    /* Quotafile not on the same filesystem? */
    if (nd.path.mnt->mnt_sb != sb) {
    - path_release(&nd);
    + path_put(&nd.path);
    return -EXDEV;
    }
    /* Quotafile not of fs root? */
    @@ -2776,7 +2776,7 @@ static int ext4_quota_on(struct super_bl
    printk(KERN_WARNING
    "EXT4-fs: Quota file not on filesystem root. "
    "Journalled quota will not work.\n");
    - path_release(&nd);
    + path_put(&nd.path);
    return vfs_quota_on(sb, type, format_id, path);
    }

    Index: b/fs/gfs2/ops_fstype.c
    ================================================== =================
    --- a/fs/gfs2/ops_fstype.c
    +++ b/fs/gfs2/ops_fstype.c
    @@ -844,7 +844,7 @@ static struct super_block* get_gfs2_sb(c
    "mount point %s\n", dev_name);

    free_nd:
    - path_release(&nd);
    + path_put(&nd.path);
    out:
    return sb;
    }
    Index: b/fs/inotify_user.c
    ================================================== =================
    --- a/fs/inotify_user.c
    +++ b/fs/inotify_user.c
    @@ -351,7 +351,7 @@ static int find_inode(const char __user
    /* you can only watch an inode if you have read permissions on it */
    error = vfs_permission(nd, MAY_READ);
    if (error)
    - path_release(nd);
    + path_put(&nd->path);
    return error;
    }

    @@ -648,7 +648,7 @@ asmlinkage long sys_inotify_add_watch(in
    ret = create_watch(dev, inode, mask);
    mutex_unlock(&dev->up_mutex);

    - path_release(&nd);
    + path_put(&nd.path);
    fput_and_out:
    fput_light(filp, fput_needed);
    return ret;
    Index: b/fs/namei.c
    ================================================== =================
    --- a/fs/namei.c
    +++ b/fs/namei.c
    @@ -347,11 +347,18 @@ int deny_write_access(struct file * file
    return 0;
    }

    -void path_release(struct nameidata *nd)
    +/**
    + * path_put - put a reference to a path
    + * @path: path to put the reference to
    + *
    + * Given a path decrement the reference count to the dentry and the vfsmount.
    + */
    +void path_put(struct path *path)
    {
    - dput(nd->path.dentry);
    - mntput(nd->path.mnt);
    + dput(path->dentry);
    + mntput(path->mnt);
    }
    +EXPORT_SYMBOL(path_put);

    /**
    * release_open_intent - free up open intent resources
    @@ -536,7 +543,7 @@ static __always_inline int __vfs_follow_
    goto fail;

    if (*link == '/') {
    - path_release(nd);
    + path_put(&nd->path);
    if (!walk_init_root(link, nd))
    /* weird __emul_prefix() stuff did it */
    goto out;
    @@ -552,18 +559,18 @@ out:
    */
    name = __getname();
    if (unlikely(!name)) {
    - path_release(nd);
    + path_put(&nd->path);
    return -ENOMEM;
    }
    strcpy(name, nd->last.name);
    nd->last.name = name;
    return 0;
    fail:
    - path_release(nd);
    + path_put(&nd->path);
    return PTR_ERR(link);
    }

    -static inline void dput_path(struct path *path, struct nameidata *nd)
    +static void path_put_conditional(struct path *path, struct nameidata *nd)
    {
    dput(path->dentry);
    if (path->mnt != nd->path.mnt)
    @@ -636,8 +643,8 @@ static inline int do_follow_link(struct
    nd->depth--;
    return err;
    loop:
    - dput_path(path, nd);
    - path_release(nd);
    + path_put_conditional(path, nd);
    + path_put(&nd->path);
    return err;
    }

    @@ -978,10 +985,10 @@ return_reval:
    return_base:
    return 0;
    out_dput:
    - dput_path(&next, nd);
    + path_put_conditional(&next, nd);
    break;
    }
    - path_release(nd);
    + path_put(&nd->path);
    return_err:
    return err;
    }
    @@ -1055,7 +1062,7 @@ static int __emul_lookup_dentry(const ch
    mntput(old_mnt);
    return 1;
    }
    - path_release(nd);
    + path_put(&nd->path);
    }
    nd->path.dentry = old_dentry;
    nd->path.mnt = old_mnt;
    @@ -1215,7 +1222,7 @@ static int __path_lookup_intent_open(int
    if (IS_ERR(nd->intent.open.file)) {
    if (err == 0) {
    err = PTR_ERR(nd->intent.open.file);
    - path_release(nd);
    + path_put(&nd->path);
    }
    } else if (err != 0)
    release_open_intent(nd);
    @@ -1775,11 +1782,11 @@ ok:
    return 0;

    exit_dput:
    - dput_path(&path, nd);
    + path_put_conditional(&path, nd);
    exit:
    if (!IS_ERR(nd->intent.open.file))
    release_open_intent(nd);
    - path_release(nd);
    + path_put(&nd->path);
    return error;

    do_link:
    @@ -1950,7 +1957,7 @@ asmlinkage long sys_mknodat(int dfd, con
    dput(dentry);
    }
    mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
    - path_release(&nd);
    + path_put(&nd.path);
    out:
    putname(tmp);

    @@ -2010,7 +2017,7 @@ asmlinkage long sys_mkdirat(int dfd, con
    dput(dentry);
    out_unlock:
    mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
    - path_release(&nd);
    + path_put(&nd.path);
    out:
    putname(tmp);
    out_err:
    @@ -2118,7 +2125,7 @@ static long do_rmdir(int dfd, const char
    exit2:
    mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
    exit1:
    - path_release(&nd);
    + path_put(&nd.path);
    exit:
    putname(name);
    return error;
    @@ -2201,7 +2208,7 @@ static long do_unlinkat(int dfd, const c
    if (inode)
    iput(inode); /* truncate the inode here */
    exit1:
    - path_release(&nd);
    + path_put(&nd.path);
    exit:
    putname(name);
    return error;
    @@ -2278,7 +2285,7 @@ asmlinkage long sys_symlinkat(const char
    dput(dentry);
    out_unlock:
    mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
    - path_release(&nd);
    + path_put(&nd.path);
    out:
    putname(to);
    out_putname:
    @@ -2375,9 +2382,9 @@ asmlinkage long sys_linkat(int olddfd, c
    out_unlock:
    mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
    out_release:
    - path_release(&nd);
    + path_put(&nd.path);
    out:
    - path_release(&old_nd);
    + path_put(&old_nd.path);
    exit:
    putname(to);

    @@ -2605,9 +2612,9 @@ exit4:
    exit3:
    unlock_rename(new_dir, old_dir);
    exit2:
    - path_release(&newnd);
    + path_put(&newnd.path);
    exit1:
    - path_release(&oldnd);
    + path_put(&oldnd.path);
    exit:
    return error;
    }
    @@ -2805,7 +2812,6 @@ EXPORT_SYMBOL(page_symlink);
    EXPORT_SYMBOL(page_symlink_inode_operations);
    EXPORT_SYMBOL(path_lookup);
    EXPORT_SYMBOL(vfs_path_lookup);
    -EXPORT_SYMBOL(path_release);
    EXPORT_SYMBOL(permission);
    EXPORT_SYMBOL(vfs_permission);
    EXPORT_SYMBOL(file_permission);
    Index: b/fs/namespace.c
    ================================================== =================
    --- a/fs/namespace.c
    +++ b/fs/namespace.c
    @@ -942,7 +942,7 @@ static int do_loopback(struct nameidata

    out:
    up_write(&namespace_sem);
    - path_release(&old_nd);
    + path_put(&old_nd.path);
    return err;
    }

    @@ -1057,8 +1057,8 @@ out1:
    out:
    up_write(&namespace_sem);
    if (!err)
    - path_release(&parent_nd);
    - path_release(&old_nd);
    + path_put(&parent_nd.path);
    + path_put(&old_nd.path);
    return err;
    }

    @@ -1442,7 +1442,7 @@ long do_mount(char *dev_name, char *dir_
    retval = do_new_mount(&nd, type_page, flags, mnt_flags,
    dev_name, data_page);
    dput_out:
    - path_release(&nd);
    + path_put(&nd.path);
    return retval;
    }

    @@ -1698,7 +1698,7 @@ asmlinkage long sys_pivot_root(const cha

    error = security_sb_pivotroot(&old_nd, &new_nd);
    if (error) {
    - path_release(&old_nd);
    + path_put(&old_nd.path);
    goto out1;
    }

    @@ -1761,15 +1761,15 @@ asmlinkage long sys_pivot_root(const cha
    chroot_fs_refs(&user_nd, &new_nd);
    security_sb_post_pivotroot(&user_nd, &new_nd);
    error = 0;
    - path_release(&root_parent);
    - path_release(&parent_nd);
    + path_put(&root_parent.path);
    + path_put(&parent_nd.path);
    out2:
    mutex_unlock(&old_nd.path.dentry->d_inode->i_mutex);
    up_write(&namespace_sem);
    - path_release(&user_nd);
    - path_release(&old_nd);
    + path_put(&user_nd.path);
    + path_put(&old_nd.path);
    out1:
    - path_release(&new_nd);
    + path_put(&new_nd.path);
    out0:
    unlock_kernel();
    return error;
    Index: b/fs/nfs/namespace.c
    ================================================== =================
    --- a/fs/nfs/namespace.c
    +++ b/fs/nfs/namespace.c
    @@ -148,7 +148,7 @@ out:
    dprintk("<-- nfs_follow_mountpoint() = %d\n", err);
    return ERR_PTR(err);
    out_err:
    - path_release(nd);
    + path_put(&nd->path);
    goto out;
    out_follow:
    while (d_mountpoint(nd->path.dentry) &&
    Index: b/fs/nfsctl.c
    ================================================== =================
    --- a/fs/nfsctl.c
    +++ b/fs/nfsctl.c
    @@ -43,7 +43,7 @@ static struct file *do_open(char *name,
    if (!error)
    return dentry_open(nd.path.dentry, nd.path.mnt, flags);

    - path_release(&nd);
    + path_put(&nd.path);
    return ERR_PTR(error);
    }

    Index: b/fs/nfsd/export.c
    ================================================== =================
    --- a/fs/nfsd/export.c
    +++ b/fs/nfsd/export.c
    @@ -177,7 +177,7 @@ static int expkey_parse(struct cache_det
    cache_put(&ek->h, &svc_expkey_cache);
    else
    err = -ENOMEM;
    - path_release(&nd);
    + path_put(&nd.path);
    }
    cache_flush();
    out:
    @@ -632,7 +632,7 @@ static int svc_export_parse(struct cache
    kfree(exp.ex_uuid);
    kfree(exp.ex_path);
    if (nd.path.dentry)
    - path_release(&nd);
    + path_put(&nd.path);
    out_no_path:
    if (dom)
    auth_domain_put(dom);
    @@ -1100,7 +1100,7 @@ finish:
    cache_put(&fsid_key->h, &svc_expkey_cache);
    if (clp)
    auth_domain_put(clp);
    - path_release(&nd);
    + path_put(&nd.path);
    out_unlock:
    exp_writeunlock();
    out:
    @@ -1152,7 +1152,7 @@ exp_unexport(struct nfsctl_export *nxp)

    err = -EINVAL;
    exp = exp_get_by_name(dom, nd.path.mnt, nd.path.dentry, NULL);
    - path_release(&nd);
    + path_put(&nd.path);
    if (IS_ERR(exp))
    goto out_domain;

    @@ -1211,7 +1211,7 @@ exp_rootfh(svc_client *clp, char *path,
    fh_put(&fh);
    exp_put(exp);
    out:
    - path_release(&nd);
    + path_put(&nd.path);
    return err;
    }

    Index: b/fs/nfsd/nfs4recover.c
    ================================================== =================
    --- a/fs/nfsd/nfs4recover.c
    +++ b/fs/nfsd/nfs4recover.c
    @@ -417,5 +417,5 @@ nfsd4_shutdown_recdir(void)
    if (!rec_dir_init)
    return;
    rec_dir_init = 0;
    - path_release(&rec_dir);
    + path_put(&rec_dir.path);
    }
    Index: b/fs/nfsd/nfs4state.c
    ================================================== =================
    --- a/fs/nfsd/nfs4state.c
    +++ b/fs/nfsd/nfs4state.c
    @@ -3342,7 +3342,7 @@ nfs4_reset_recoverydir(char *recdir)
    nfs4_set_recdir(recdir);
    status = 0;
    }
    - path_release(&nd);
    + path_put(&nd.path);
    return status;
    }

    Index: b/fs/open.c
    ================================================== =================
    --- a/fs/open.c
    +++ b/fs/open.c
    @@ -130,7 +130,7 @@ asmlinkage long sys_statfs(const char __
    error = vfs_statfs_native(nd.path.dentry, &tmp);
    if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
    error = -EFAULT;
    - path_release(&nd);
    + path_put(&nd.path);
    }
    return error;
    }
    @@ -149,7 +149,7 @@ asmlinkage long sys_statfs64(const char
    error = vfs_statfs64(nd.path.dentry, &tmp);
    if (!error && copy_to_user(buf, &tmp, sizeof(tmp)))
    error = -EFAULT;
    - path_release(&nd);
    + path_put(&nd.path);
    }
    return error;
    }
    @@ -277,7 +277,7 @@ static long do_sys_truncate(const char _
    put_write_and_out:
    put_write_access(inode);
    dput_and_out:
    - path_release(&nd);
    + path_put(&nd.path);
    out:
    return error;
    }
    @@ -462,7 +462,7 @@ asmlinkage long sys_faccessat(int dfd, c
    res = -EROFS;

    out_path_release:
    - path_release(&nd);
    + path_put(&nd.path);
    out:
    current->fsuid = old_fsuid;
    current->fsgid = old_fsgid;
    @@ -493,7 +493,7 @@ asmlinkage long sys_chdir(const char __u
    set_fs_pwd(current->fs, nd.path.mnt, nd.path.dentry);

    dput_and_out:
    - path_release(&nd);
    + path_put(&nd.path);
    out:
    return error;
    }
    @@ -549,7 +549,7 @@ asmlinkage long sys_chroot(const char __
    set_fs_altroot();
    error = 0;
    dput_and_out:
    - path_release(&nd);
    + path_put(&nd.path);
    out:
    return error;
    }
    @@ -621,7 +621,7 @@ asmlinkage long sys_fchmodat(int dfd, co
    mutex_unlock(&inode->i_mutex);

    dput_and_out:
    - path_release(&nd);
    + path_put(&nd.path);
    out:
    return error;
    }
    @@ -675,7 +675,7 @@ asmlinkage long sys_chown(const char __u
    if (error)
    goto out;
    error = chown_common(nd.path.dentry, user, group);
    - path_release(&nd);
    + path_put(&nd.path);
    out:
    return error;
    }
    @@ -695,7 +695,7 @@ asmlinkage long sys_fchownat(int dfd, co
    if (error)
    goto out;
    error = chown_common(nd.path.dentry, user, group);
    - path_release(&nd);
    + path_put(&nd.path);
    out:
    return error;
    }
    @@ -709,7 +709,7 @@ asmlinkage long sys_lchown(const char __
    if (error)
    goto out;
    error = chown_common(nd.path.dentry, user, group);
    - path_release(&nd);
    + path_put(&nd.path);
    out:
    return error;
    }
    @@ -889,7 +889,7 @@ struct file *nameidata_to_filp(struct na
    filp = __dentry_open(nd->path.dentry, nd->path.mnt, flags, filp,
    NULL);
    else
    - path_release(nd);
    + path_put(&nd->path);
    return filp;
    }

    Index: b/fs/proc/base.c
    ================================================== =================
    --- a/fs/proc/base.c
    +++ b/fs/proc/base.c
    @@ -938,7 +938,7 @@ static void *proc_pid_follow_link(struct
    int error = -EACCES;

    /* We don't need a base pointer in the /proc filesystem */
    - path_release(nd);
    + path_put(&nd->path);

    /* Are we allowed to snoop on the tasks file descriptors? */
    if (!proc_fd_access_allowed(inode))
    Index: b/fs/reiserfs/super.c
    ================================================== =================
    --- a/fs/reiserfs/super.c
    +++ b/fs/reiserfs/super.c
    @@ -1986,20 +1986,20 @@ static int reiserfs_quota_on(struct supe
    return err;
    /* Quotafile not on the same filesystem? */
    if (nd.path.mnt->mnt_sb != sb) {
    - path_release(&nd);
    + path_put(&nd.path);
    return -EXDEV;
    }
    /* We must not pack tails for quota files on reiserfs for quota IO to work */
    if (!REISERFS_I(nd.path.dentry->d_inode)->i_flags & i_nopack_mask) {
    reiserfs_warning(sb,
    "reiserfs: Quota file must have tail packing disabled.");
    - path_release(&nd);
    + path_put(&nd.path);
    return -EINVAL;
    }
    /* Not journalling quota? No more tests needed... */
    if (!REISERFS_SB(sb)->s_qf_names[USRQUOTA] &&
    !REISERFS_SB(sb)->s_qf_names[GRPQUOTA]) {
    - path_release(&nd);
    + path_put(&nd.path);
    return vfs_quota_on(sb, type, format_id, path);
    }
    /* Quotafile not of fs root? */
    @@ -2007,7 +2007,7 @@ static int reiserfs_quota_on(struct supe
    reiserfs_warning(sb,
    "reiserfs: Quota file not on filesystem root. "
    "Journalled quota will not work.");
    - path_release(&nd);
    + path_put(&nd.path);
    return vfs_quota_on(sb, type, format_id, path);
    }

    Index: b/fs/stat.c
    ================================================== =================
    --- a/fs/stat.c
    +++ b/fs/stat.c
    @@ -63,7 +63,7 @@ int vfs_stat_fd(int dfd, char __user *na
    error = __user_walk_fd(dfd, name, LOOKUP_FOLLOW, &nd);
    if (!error) {
    error = vfs_getattr(nd.path.mnt, nd.path.dentry, stat);
    - path_release(&nd);
    + path_put(&nd.path);
    }
    return error;
    }
    @@ -83,7 +83,7 @@ int vfs_lstat_fd(int dfd, char __user *n
    error = __user_walk_fd(dfd, name, 0, &nd);
    if (!error) {
    error = vfs_getattr(nd.path.mnt, nd.path.dentry, stat);
    - path_release(&nd);
    + path_put(&nd.path);
    }
    return error;
    }
    @@ -313,7 +313,7 @@ asmlinkage long sys_readlinkat(int dfd,
    buf, bufsiz);
    }
    }
    - path_release(&nd);
    + path_put(&nd.path);
    }
    return error;
    }
    Index: b/fs/utimes.c
    ================================================== =================
    --- a/fs/utimes.c
    +++ b/fs/utimes.c
    @@ -124,7 +124,7 @@ dput_and_out:
    if (f)
    fput(f);
    else
    - path_release(&nd);
    + path_put(&nd.path);
    out:
    return error;
    }
    Index: b/fs/xattr.c
    ================================================== =================
    --- a/fs/xattr.c
    +++ b/fs/xattr.c
    @@ -236,7 +236,7 @@ sys_setxattr(char __user *path, char __u
    if (error)
    return error;
    error = setxattr(nd.path.dentry, name, value, size, flags);
    - path_release(&nd);
    + path_put(&nd.path);
    return error;
    }

    @@ -251,7 +251,7 @@ sys_lsetxattr(char __user *path, char __
    if (error)
    return error;
    error = setxattr(nd.path.dentry, name, value, size, flags);
    - path_release(&nd);
    + path_put(&nd.path);
    return error;
    }

    @@ -321,7 +321,7 @@ sys_getxattr(char __user *path, char __u
    if (error)
    return error;
    error = getxattr(nd.path.dentry, name, value, size);
    - path_release(&nd);
    + path_put(&nd.path);
    return error;
    }

    @@ -336,7 +336,7 @@ sys_lgetxattr(char __user *path, char __
    if (error)
    return error;
    error = getxattr(nd.path.dentry, name, value, size);
    - path_release(&nd);
    + path_put(&nd.path);
    return error;
    }

    @@ -395,7 +395,7 @@ sys_listxattr(char __user *path, char __
    if (error)
    return error;
    error = listxattr(nd.path.dentry, list, size);
    - path_release(&nd);
    + path_put(&nd.path);
    return error;
    }

    @@ -409,7 +409,7 @@ sys_llistxattr(char __user *path, char _
    if (error)
    return error;
    error = listxattr(nd.path.dentry, list, size);
    - path_release(&nd);
    + path_put(&nd.path);
    return error;
    }

    @@ -456,7 +456,7 @@ sys_removexattr(char __user *path, char
    if (error)
    return error;
    error = removexattr(nd.path.dentry, name);
    - path_release(&nd);
    + path_put(&nd.path);
    return error;
    }

    @@ -470,7 +470,7 @@ sys_lremovexattr(char __user *path, char
    if (error)
    return error;
    error = removexattr(nd.path.dentry, name);
    - path_release(&nd);
    + path_put(&nd.path);
    return error;
    }

    Index: b/fs/xfs/linux-2.6/xfs_ioctl.c
    ================================================== =================
    --- a/fs/xfs/linux-2.6/xfs_ioctl.c
    +++ b/fs/xfs/linux-2.6/xfs_ioctl.c
    @@ -94,7 +94,7 @@ xfs_find_handle(
    ASSERT(nd.path.dentry);
    ASSERT(nd.path.dentry->d_inode);
    inode = igrab(nd.path.dentry->d_inode);
    - path_release(&nd);
    + path_put(&nd.path);
    break;
    }

    Index: b/include/linux/namei.h
    ================================================== =================
    --- a/include/linux/namei.h
    +++ b/include/linux/namei.h
    @@ -66,7 +66,6 @@ extern int FASTCALL(__user_walk_fd(int d
    extern int FASTCALL(path_lookup(const char *, unsigned, struct nameidata *));
    extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
    const char *, unsigned int, struct nameidata *);
    -extern void path_release(struct nameidata *);

    extern int __user_path_lookup_open(const char __user *, unsigned lookup_flags, struct nameidata *nd, int open_flags);
    extern int path_lookup_open(int dfd, const char *name, unsigned lookup_flags, struct nameidata *, int open_flags);
    Index: b/include/linux/path.h
    ================================================== =================
    --- a/include/linux/path.h
    +++ b/include/linux/path.h
    @@ -9,4 +9,6 @@ struct path {
    struct dentry *dentry;
    };

    +extern void path_put(struct path *);
    +
    #endif /* _LINUX_PATH_H */
    Index: b/kernel/auditfilter.c
    ================================================== =================
    --- a/kernel/auditfilter.c
    +++ b/kernel/auditfilter.c
    @@ -1123,11 +1123,11 @@ static int audit_get_nd(char *path, stru
    static void audit_put_nd(struct nameidata *ndp, struct nameidata *ndw)
    {
    if (ndp) {
    - path_release(ndp);
    + path_put(&ndp->path);
    kfree(ndp);
    }
    if (ndw) {
    - path_release(ndw);
    + path_put(&ndw->path);
    kfree(ndw);
    }
    }
    Index: b/net/sunrpc/rpc_pipe.c
    ================================================== =================
    --- a/net/sunrpc/rpc_pipe.c
    +++ b/net/sunrpc/rpc_pipe.c
    @@ -483,7 +483,7 @@ rpc_lookup_parent(char *path, struct nam
    static void
    rpc_release_path(struct nameidata *nd)
    {
    - path_release(nd);
    + path_put(&nd->path);
    rpc_put_mount();
    }

    Index: b/net/unix/af_unix.c
    ================================================== =================
    --- a/net/unix/af_unix.c
    +++ b/net/unix/af_unix.c
    @@ -743,7 +743,7 @@ static struct sock *unix_find_other(stru
    if (u->sk_type == type)
    touch_atime(nd.path.mnt, nd.path.dentry);

    - path_release(&nd);
    + path_put(&nd.path);

    err=-EPROTOTYPE;
    if (u->sk_type != type) {
    @@ -764,7 +764,7 @@ static struct sock *unix_find_other(stru
    return u;

    put_fail:
    - path_release(&nd);
    + path_put(&nd.path);
    fail:
    *error=err;
    return NULL;
    @@ -877,7 +877,7 @@ out_mknod_dput:
    dput(dentry);
    out_mknod_unlock:
    mutex_unlock(&nd.path.dentry->d_inode->i_mutex);
    - path_release(&nd);
    + path_put(&nd.path);
    out_mknod_parent:
    if (err==-EEXIST)
    err=-EADDRINUSE;

    --

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  6. Re: [patch 02/10] Dont touch fs_struct in usermodehelper

    On Thu, Sep 27, 2007 at 04:12:02PM +0200, jblunck@suse.de wrote:
    > This test seems to be unnecessary since we always have rootfs mounted before
    > calling a usermodehelper.


    Are you sure this is true? I thought we called the usermode helper for
    hotplug _very_ early in the boot sequence when the device tree starts to
    get populated.

    But things could have changed from the 2.5 days when this was first
    added, if so, nevermind me

    thanks,

    greg k-h
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  7. Re: [patch 02/10] Dont touch fs_struct in usermodehelper

    On Thu, Sep 27, 2007 at 10:46:04AM -0700, Greg KH wrote:
    > On Thu, Sep 27, 2007 at 04:12:02PM +0200, jblunck@suse.de wrote:
    > > This test seems to be unnecessary since we always have rootfs mounted before
    > > calling a usermodehelper.

    >
    > Are you sure this is true? I thought we called the usermode helper for
    > hotplug _very_ early in the boot sequence when the device tree starts to
    > get populated.


    rootfs is mounted by init_mount_tree, and curret->fs is set up for init
    there aswell. This is called by mnt_init, which is called by
    vfs_caches_init, which is called by start_kernel far before we go to
    rest_init which finally creates a thread to call kernel_init which then
    calls do_basic_setup which calls do_initcalls to initialize drivers and
    afterwards runs the initrd/initramfs.

    While the actual function names in main.c changed quite a bit we've
    initialized the initial namespace very early on since the 2.5 days.
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  8. Re: [patch 02/10] Dont touch fs_struct in usermodehelper

    On Thu, Sep 27, 2007 at 10:39:22PM +0200, Christoph Hellwig wrote:
    > On Thu, Sep 27, 2007 at 10:46:04AM -0700, Greg KH wrote:
    > > On Thu, Sep 27, 2007 at 04:12:02PM +0200, jblunck@suse.de wrote:
    > > > This test seems to be unnecessary since we always have rootfs mounted before
    > > > calling a usermodehelper.

    > >
    > > Are you sure this is true? I thought we called the usermode helper for
    > > hotplug _very_ early in the boot sequence when the device tree starts to
    > > get populated.

    >
    > rootfs is mounted by init_mount_tree, and curret->fs is set up for init
    > there aswell. This is called by mnt_init, which is called by
    > vfs_caches_init, which is called by start_kernel far before we go to
    > rest_init which finally creates a thread to call kernel_init which then
    > calls do_basic_setup which calls do_initcalls to initialize drivers and
    > afterwards runs the initrd/initramfs.
    >
    > While the actual function names in main.c changed quite a bit we've
    > initialized the initial namespace very early on since the 2.5 days.


    Ah, ok, great, thanks for correcting me. I have no objection to this
    patch then.

    thanks,

    greg k-h
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  9. Re: [patch 01/10] Dont touch fs_struct in drivers

    On Thu, Sep 27, 2007 at 04:12:01PM +0200, jblunck@suse.de wrote:
    > The sound drivers and the pnpbios core test for current->root != NULL. This
    > test seems to be unnecessary since we always have rootfs mounted before
    > initializing the drivers.


    Looks good. Amazing how far this crap has spread..

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  10. Re: [patch 06/10] Introduce path_put()

    On Thu, Sep 27, 2007 at 04:12:06PM +0200, jblunck@suse.de wrote:
    > * Add path_put() functions for releasing a reference to the dentry and
    > vfsmount of a struct path in the right order
    >
    > * Switch from path_release(nd) to path_put(&nd->path)
    >
    > * Rename dput_path() to path_put_conditional()


    Looks correct. As mentioned in the previous round I'm not a big fan
    personally of killing path_release, but as others are I'm not going to
    NACK this.
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  11. Re: [patch 02/10] Dont touch fs_struct in usermodehelper

    On Thu, Sep 27, 2007 at 04:12:02PM +0200, jblunck@suse.de wrote:
    > This test seems to be unnecessary since we always have rootfs mounted before
    > calling a usermodehelper.


    Ok.

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  12. Re: [patch 03/10] Remove path_release_on_umount()

    On Thu, Sep 27, 2007 at 04:12:03PM +0200, jblunck@suse.de wrote:
    > path_release_on_umount() should only be called from sys_umount(). I merged the
    > function into sys_umount() instead of having in in namei.c.


    Yeah, getting rid of this one makes a lot sense.

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  13. Re: [patch 04/10] Move struct path into its own header

    On Thu, Sep 27, 2007 at 04:12:04PM +0200, jblunck@suse.de wrote:
    > Move the definition of struct path into its own header file for further
    > patches.


    Ok.

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  14. Re: [patch 05/10] Embed a struct path into struct nameidata instead of nd->{dentry,mnt}

    On Thu, Sep 27, 2007 at 04:12:05PM +0200, jblunck@suse.de wrote:
    > Switch from nd->{dentry,mnt} to nd->path.{dentry,mnt} everywhere.


    Ok.

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  15. Re: [patch 07/10] Use path_put() in a few places instead of {mnt,d}put()

    On Thu, Sep 27, 2007 at 04:12:07PM +0200, jblunck@suse.de wrote:
    > Use path_put() in a few places instead of {mnt,d}put()


    Looks good.

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  16. Re: [patch 10/10] Make set_fs_{root,pwd} take a struct path

    On Thu, Sep 27, 2007 at 04:12:10PM +0200, jblunck@suse.de wrote:
    > In nearly all cases the set_fs_{root,pwd}() calls work on a struct
    > path. Change the function to reflect this and use path_get() here.


    Looks good.

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  17. Re: [patch 08/10] Introduce path_get()

    On Thu, Sep 27, 2007 at 04:12:08PM +0200, jblunck@suse.de wrote:
    > This introduces the symmetric function to path_put() for getting a reference
    > to the dentry and vfsmount of a struct path in the right order.


    Looks good in general,

    > /**
    > + * path_get - get a reference to a path
    > + * @path: path to get the reference to
    > + *
    > + * Given a path increment the reference count to the dentry and the vfsmount.
    > + */
    > +struct path *path_get(struct path *path)
    > +{
    > + mntget(path->mnt);
    > + dget(path->dentry);
    > + return path;
    > +}


    but the calling convention is rather odd, because the only thing callers
    might do with this is to dereference and then assign it. Maybe this
    should just return void to make it more clear what's going on?

    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  18. Re: [patch 09/10] Use struct path in fs_struct

    > - res = __d_path(dentry, vfsmnt, root, rootmnt, buf, buflen);
    > + res = __d_path(dentry, vfsmnt, root.dentry, root.mnt, buf, buflen);


    __d_path should probably switch to taking a struct path * aswell.

    Otherwise fine.
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  19. Re: [patch 09/10] Use struct path in fs_struct

    On Friday 28 September 2007 20:42, Christoph Hellwig wrote:
    > __d_path should probably switch to taking a struct path * aswell.


    Indeed, it now easily can. Here we go...


    One less parameter to __d_path

    All callers to __d_path pass the dentry and vfsmount of a struct
    path to __d_path. Pass the struct path directly, instead.

    Signed-off-by: Andreas Gruenbacher

    Index: linux-2.6/fs/dcache.c
    ================================================== =================
    --- linux-2.6.orig/fs/dcache.c
    +++ linux-2.6/fs/dcache.c
    @@ -1781,9 +1781,8 @@ shouldnt_be_hashed:
    *
    * "buflen" should be positive. Caller holds the dcache_lock.
    */
    -static char * __d_path( struct dentry *dentry, struct vfsmount *vfsmnt,
    - struct dentry *root, struct vfsmount *rootmnt,
    - char *buffer, int buflen)
    +static char * __d_path(struct dentry *dentry, struct vfsmount *vfsmnt,
    + struct path *root, char *buffer, int buflen)
    {
    char * end = buffer+buflen;
    char * retval;
    @@ -1808,7 +1807,7 @@ static char * __d_path( struct dentry *d
    for (; {
    struct dentry * parent;

    - if (dentry == root && vfsmnt == rootmnt)
    + if (dentry == root->dentry && vfsmnt == root->mnt)
    break;
    if (dentry == vfsmnt->mnt_root || IS_ROOT(dentry)) {
    /* Global root? */
    @@ -1870,7 +1869,7 @@ char * d_path(struct dentry *dentry, str
    root = *path_get(&current->fs->root);
    read_unlock(&current->fs->lock);
    spin_lock(&dcache_lock);
    - res = __d_path(dentry, vfsmnt, root.dentry, root.mnt, buf, buflen);
    + res = __d_path(dentry, vfsmnt, &root, buf, buflen);
    spin_unlock(&dcache_lock);
    path_put(&root);
    return res;
    @@ -1936,8 +1935,7 @@ asmlinkage long sys_getcwd(char __user *
    unsigned long len;
    char * cwd;

    - cwd = __d_path(pwd.dentry, pwd.mnt, root.dentry, root.mnt,
    - page, PAGE_SIZE);
    + cwd = __d_path(pwd.dentry, pwd.mnt, &root, page, PAGE_SIZE);
    spin_unlock(&dcache_lock);

    error = PTR_ERR(cwd);
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

  20. [patch] Combine path_put and path_put_conditional

    Here is another cleanup on top of Jan's set. Comments?


    The name path_put_conditional (formerly, dput_path) is a little unclear.
    Replace (path_put_conditional + path_put) with path_walk_put_both,
    "put a pair of paths after a path_walk" (see the kerneldoc).

    Signed-off-by: Andreas Gruenbacher

    Index: linux-2.6/fs/namei.c
    ================================================== =================
    --- linux-2.6.orig/fs/namei.c
    +++ linux-2.6/fs/namei.c
    @@ -582,11 +582,22 @@ fail:
    return PTR_ERR(link);
    }

    -static void path_put_conditional(struct path *path, struct nameidata *nd)
    -{
    - dput(path->dentry);
    - if (path->mnt != nd->path.mnt)
    - mntput(path->mnt);
    +/**
    + * path_walk_put_both - put a pair of paths after a path_walk
    + * @path1: first path to put
    + * @path2: second path to put
    + *
    + * When walking a path we keep the same vfsmnt reference while on the same
    + * filesystem, and grab a reference to the new vfsmnt when crossing mount
    + * points. Put both @path1 and @path2 under this assumption.
    + */
    +static void path_walk_put_both(struct path *path1, struct path *path2)
    +{
    + dput(path1->dentry);
    + dput(path2->dentry);
    + mntput(path1->mnt);
    + if (path1->mnt != path2->mnt)
    + mntput(path2->mnt);
    }

    static inline void path_to_nameidata(struct path *path, struct nameidata *nd)
    @@ -654,8 +665,7 @@ static inline int do_follow_link(struct
    nd->depth--;
    return err;
    loop:
    - path_put_conditional(path, nd);
    - path_put(&nd->path);
    + path_walk_put_both(path, &nd->path);
    return err;
    }

    @@ -996,8 +1006,8 @@ return_reval:
    return_base:
    return 0;
    out_dput:
    - path_put_conditional(&next, nd);
    - break;
    + path_walk_put_both(&next, &nd->path);
    + goto return_err;
    }
    path_put(&nd->path);
    return_err:
    @@ -1777,11 +1787,15 @@ ok:
    return 0;

    exit_dput:
    - path_put_conditional(&path, nd);
    + path_walk_put_both(&path, &nd->path);
    + goto exit_intent;
    +
    exit:
    + path_put(&nd->path);
    +
    +exit_intent:
    if (!IS_ERR(nd->intent.open.file))
    release_open_intent(nd);
    - path_put(&nd->path);
    return error;

    do_link:
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at http://www.tux.org/lkml/

+ Reply to Thread
Page 1 of 2 1 2 LastLast