[PATCH 09/13] Use struct path in fs_struct
From: Jan Blunck <[EMAIL PROTECTED]> * Use struct path in fs_struct. Signed-off-by: Andreas Gruenbacher <[EMAIL PROTECTED]> Signed-off-by: Jan Blunck <[EMAIL PROTECTED]> Signed-off-by: Bharata B Rao <[EMAIL PROTECTED]> Acked-by: Christoph Hellwig <[EMAIL PROTECTED]> --- fs/dcache.c | 34 --- fs/namei.c| 53 ++ fs/namespace.c| 57 -- fs/proc/base.c|8 +++--- include/linux/fs_struct.h |6 +--- init/do_mounts.c |6 ++-- kernel/auditsc.c |4 +-- kernel/exit.c | 12 +++-- kernel/fork.c | 18 +++--- 9 files changed, 87 insertions(+), 111 deletions(-) --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1851,8 +1851,7 @@ char * d_path(struct dentry *dentry, str char *buf, int buflen) { char *res; - struct vfsmount *rootmnt; - struct dentry *root; + struct path root; /* * We have various synthetic filesystems that never get mounted. On @@ -1865,14 +1864,13 @@ char * d_path(struct dentry *dentry, str return dentry->d_op->d_dname(dentry, buf, buflen); read_lock(>fs->lock); - rootmnt = mntget(current->fs->rootmnt); - root = dget(current->fs->root); + root = current->fs->root; + path_get(>fs->root); read_unlock(>fs->lock); spin_lock(_lock); - res = __d_path(dentry, vfsmnt, root, rootmnt, buf, buflen); + res = __d_path(dentry, vfsmnt, root.dentry, root.mnt, buf, buflen); spin_unlock(_lock); - dput(root); - mntput(rootmnt); + path_put(); return res; } @@ -1918,28 +1916,28 @@ char *dynamic_dname(struct dentry *dentr asmlinkage long sys_getcwd(char __user *buf, unsigned long size) { int error; - struct vfsmount *pwdmnt, *rootmnt; - struct dentry *pwd, *root; + struct path pwd, root; char *page = (char *) __get_free_page(GFP_USER); if (!page) return -ENOMEM; read_lock(>fs->lock); - pwdmnt = mntget(current->fs->pwdmnt); - pwd = dget(current->fs->pwd); - rootmnt = mntget(current->fs->rootmnt); - root = dget(current->fs->root); + pwd = current->fs->pwd; + path_get(>fs->pwd); + root = current->fs->root; + path_get(>fs->root); read_unlock(>fs->lock); error = -ENOENT; /* Has the current directory has been unlinked? */ spin_lock(_lock); - if (pwd->d_parent == pwd || !d_unhashed(pwd)) { + if (pwd.dentry->d_parent == pwd.dentry || !d_unhashed(pwd.dentry)) { unsigned long len; char * cwd; - cwd = __d_path(pwd, pwdmnt, root, rootmnt, page, PAGE_SIZE); + cwd = __d_path(pwd.dentry, pwd.mnt, root.dentry, root.mnt, + page, PAGE_SIZE); spin_unlock(_lock); error = PTR_ERR(cwd); @@ -1957,10 +1955,8 @@ asmlinkage long sys_getcwd(char __user * spin_unlock(_lock); out: - dput(pwd); - mntput(pwdmnt); - dput(root); - mntput(rootmnt); + path_put(); + path_put(); free_page((unsigned long) page); return error; } --- a/fs/namei.c +++ b/fs/namei.c @@ -550,16 +550,16 @@ walk_init_root(const char *name, struct struct fs_struct *fs = current->fs; read_lock(>lock); - if (fs->altroot && !(nd->flags & LOOKUP_NOALT)) { - nd->path.mnt = mntget(fs->altrootmnt); - nd->path.dentry = dget(fs->altroot); + if (fs->altroot.dentry && !(nd->flags & LOOKUP_NOALT)) { + nd->path = fs->altroot; + path_get(>altroot); read_unlock(>lock); if (__emul_lookup_dentry(name,nd)) return 0; read_lock(>lock); } - nd->path.mnt = mntget(fs->rootmnt); - nd->path.dentry = dget(fs->root); + nd->path = fs->root; + path_get(>root); read_unlock(>lock); return 1; } @@ -756,8 +756,8 @@ static __always_inline void follow_dotdo struct dentry *old = nd->path.dentry; read_lock(>lock); - if (nd->path.dentry == fs->root && - nd->path.mnt == fs->rootmnt) { + if (nd->path.dentry == fs->root.dentry && + nd->path.mnt == fs->root.mnt) { read_unlock(>lock); break; } @@ -1079,8 +1079,8 @@ static int __emul_lookup_dentry(const ch */ nd->last_type = LAST_ROOT; read_lock(>lock); - nd->path.mnt = mntget(fs->rootmnt); - nd->path.dentry = dget(fs->root); + nd->path = fs->root; +
[PATCH 09/13] Use struct path in fs_struct
From: Jan Blunck [EMAIL PROTECTED] * Use struct path in fs_struct. Signed-off-by: Andreas Gruenbacher [EMAIL PROTECTED] Signed-off-by: Jan Blunck [EMAIL PROTECTED] Signed-off-by: Bharata B Rao [EMAIL PROTECTED] Acked-by: Christoph Hellwig [EMAIL PROTECTED] --- fs/dcache.c | 34 --- fs/namei.c| 53 ++ fs/namespace.c| 57 -- fs/proc/base.c|8 +++--- include/linux/fs_struct.h |6 +--- init/do_mounts.c |6 ++-- kernel/auditsc.c |4 +-- kernel/exit.c | 12 +++-- kernel/fork.c | 18 +++--- 9 files changed, 87 insertions(+), 111 deletions(-) --- a/fs/dcache.c +++ b/fs/dcache.c @@ -1851,8 +1851,7 @@ char * d_path(struct dentry *dentry, str char *buf, int buflen) { char *res; - struct vfsmount *rootmnt; - struct dentry *root; + struct path root; /* * We have various synthetic filesystems that never get mounted. On @@ -1865,14 +1864,13 @@ char * d_path(struct dentry *dentry, str return dentry-d_op-d_dname(dentry, buf, buflen); read_lock(current-fs-lock); - rootmnt = mntget(current-fs-rootmnt); - root = dget(current-fs-root); + root = current-fs-root; + path_get(current-fs-root); read_unlock(current-fs-lock); spin_lock(dcache_lock); - res = __d_path(dentry, vfsmnt, root, rootmnt, buf, buflen); + res = __d_path(dentry, vfsmnt, root.dentry, root.mnt, buf, buflen); spin_unlock(dcache_lock); - dput(root); - mntput(rootmnt); + path_put(root); return res; } @@ -1918,28 +1916,28 @@ char *dynamic_dname(struct dentry *dentr asmlinkage long sys_getcwd(char __user *buf, unsigned long size) { int error; - struct vfsmount *pwdmnt, *rootmnt; - struct dentry *pwd, *root; + struct path pwd, root; char *page = (char *) __get_free_page(GFP_USER); if (!page) return -ENOMEM; read_lock(current-fs-lock); - pwdmnt = mntget(current-fs-pwdmnt); - pwd = dget(current-fs-pwd); - rootmnt = mntget(current-fs-rootmnt); - root = dget(current-fs-root); + pwd = current-fs-pwd; + path_get(current-fs-pwd); + root = current-fs-root; + path_get(current-fs-root); read_unlock(current-fs-lock); error = -ENOENT; /* Has the current directory has been unlinked? */ spin_lock(dcache_lock); - if (pwd-d_parent == pwd || !d_unhashed(pwd)) { + if (pwd.dentry-d_parent == pwd.dentry || !d_unhashed(pwd.dentry)) { unsigned long len; char * cwd; - cwd = __d_path(pwd, pwdmnt, root, rootmnt, page, PAGE_SIZE); + cwd = __d_path(pwd.dentry, pwd.mnt, root.dentry, root.mnt, + page, PAGE_SIZE); spin_unlock(dcache_lock); error = PTR_ERR(cwd); @@ -1957,10 +1955,8 @@ asmlinkage long sys_getcwd(char __user * spin_unlock(dcache_lock); out: - dput(pwd); - mntput(pwdmnt); - dput(root); - mntput(rootmnt); + path_put(pwd); + path_put(root); free_page((unsigned long) page); return error; } --- a/fs/namei.c +++ b/fs/namei.c @@ -550,16 +550,16 @@ walk_init_root(const char *name, struct struct fs_struct *fs = current-fs; read_lock(fs-lock); - if (fs-altroot !(nd-flags LOOKUP_NOALT)) { - nd-path.mnt = mntget(fs-altrootmnt); - nd-path.dentry = dget(fs-altroot); + if (fs-altroot.dentry !(nd-flags LOOKUP_NOALT)) { + nd-path = fs-altroot; + path_get(fs-altroot); read_unlock(fs-lock); if (__emul_lookup_dentry(name,nd)) return 0; read_lock(fs-lock); } - nd-path.mnt = mntget(fs-rootmnt); - nd-path.dentry = dget(fs-root); + nd-path = fs-root; + path_get(fs-root); read_unlock(fs-lock); return 1; } @@ -756,8 +756,8 @@ static __always_inline void follow_dotdo struct dentry *old = nd-path.dentry; read_lock(fs-lock); - if (nd-path.dentry == fs-root - nd-path.mnt == fs-rootmnt) { + if (nd-path.dentry == fs-root.dentry + nd-path.mnt == fs-root.mnt) { read_unlock(fs-lock); break; } @@ -1079,8 +1079,8 @@ static int __emul_lookup_dentry(const ch */ nd-last_type = LAST_ROOT; read_lock(fs-lock); - nd-path.mnt = mntget(fs-rootmnt); - nd-path.dentry = dget(fs-root); +