struct path related cleanups of d_path() code (V2)
Subsystems (14)
cover struct path related cleanups of d_path() code (V2)
Andrew,
please apply this series to -mm. I just added the seq_file patch, another nfsd cleanup and changed the patch order.
This patch series changes d_path() to take a struct path argument. The existing users are changed to give struct path more deeply into the call chain. In some cases I replaced existing <dentry,vfsmount> pairs and embed a struct path instead.
Thanks,
Jan
Quoted 1 line
Quoted 1 line
one-less-parameter-to-__d_path.patch<<
One less parameter to __d_path
Quoted 1 line
Quoted 1 line
d_path-kerneldoc_cleanup.diff<<
d_path: kerneldoc cleanup
Quoted 1 line
Quoted 1 line
d_path-Use_struct_path_in_struct_avc_audit_data.diff<<
d_path: Use struct path in struct avc_audit_data
Quoted 1 line
Quoted 1 line
d_path-Make_proc_get_link_use_a_struct_path_argument.diff<<
d_path: Make proc_get_link() use a struct path argument
Quoted 1 line
Quoted 1 line
d_path_Make_get_dcookie_use_a_struct_path_argument.diff<<
d_path: Make get_dcookie() use a struct path argument
Quoted 1 line
Quoted 1 line
nfsd-svc_export_use_struct_path.diff<<
Use struct path in struct svc_export
Quoted 1 line
Quoted 1 line
nfsd-svc_expkey_use_struct_path.diff<<
Use struct path in struct svc_expkey
Quoted 1 line
Quoted 1 line
d_path-Make_seq_path_use_a_struct_path_argument.diff<<
d_path: Make seq_path() use a struct path argument
Quoted 1 line
Quoted 1 line
d_path-use_struct_path.diff<<
d_path: Make d_path() use a struct path
PATCH 1/9 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.
--- fs/dcache.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-)
fs/dcache.c +5 -7
@@ -1778,9 +1778,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;
@@ -1805,7 +1804,7 @@ static char * __d_path( struct dentry *dfor (;;) {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? */
@@ -1868,7 +1867,7 @@ char * d_path(struct dentry *dentry, strpath_get (¤t->fs->root);read_unlock (¤t->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);
PATCH 2/9 d_path: kerneldoc cleanup
In reply to Jan BlunckMove and update d_path() kernel API documentation.
--- fs/dcache.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-)
fs/dcache.c +16 -19
@@ -1762,22 +1762,6 @@ shouldnt_be_hashed: goto shouldnt_be_hashed; } -/** -* d_path - return the path of a dentry -* @dentry: dentry to report -* @vfsmnt: vfsmnt to which the dentry belongs -* @root: root dentry -* @rootmnt: vfsmnt to which the root dentry belongs -* @buffer: buffer to return value in -* @buflen: buffer length -* -* Convert a dentry into an ASCII path name. If the entry has been deleted -* the string " (deleted)" is appended. Note that this is ambiguous. -* -* Returns the buffer or an error code if the path was too long. -* -* "buflen" should be positive. Caller holds the dcache_lock. -*/ static char *__d_path (struct dentry *dentry,struct vfsmount *vfsmnt,struct path *root,char *buffer,int buflen) {
@@ -1845,9 +1829,22 @@ Elong:return ERR_PTR (-ENAMETOOLONG ); } -/* write full pathname into buffer and return start of pathname */ -char *d_path (struct dentry *dentry,struct vfsmount *vfsmnt, -char *buf,int buflen) +/** +* d_path - return the path of a dentry +* @dentry: dentry to report +* @vfsmnt: vfsmnt to which the dentry belongs +* @buf: buffer to return value in +* @buflen: buffer length +* +* Convert a dentry into an ASCII path name. If the entry has been deleted +* the string " (deleted)" is appended. Note that this is ambiguous. +* +* Returns the buffer or an error code if the path was too long. +* +* "buflen" should be positive. Caller holds the dcache_lock. +*/ +char *d_path (struct dentry *dentry,struct vfsmount *vfsmnt, +char *buf,int buflen) {char *res;struct path root;
PATCH 3/9 d_path: Use struct path in struct avc_audit_data
In reply to Jan Blunckaudit_log_d_path() is a d_path() wrapper that is used by the audit code. To use a struct path in audit_log_d_path() I need to embed it into struct avc_audit_data.
--- include/linux/audit.h | 5 ++--- kernel/audit.c | 12 ++++++------ kernel/auditsc.c | 28 +++++++++++----------------- security/selinux/avc.c | 13 ++++++++----- security/selinux/hooks.c | 28 ++++++++++++---------------- security/selinux/include/avc.h | 6 ++---- 6 files changed, 41 insertions(+), 51 deletions(-)
include/linux/audit.h +2 -3
@@ -527,8 +527,7 @@ extern const char * audit_log_n_untr const char *string);extern void audit_log_d_path (struct audit_buffer *ab,const char *prefix, -struct dentry *dentry, -struct vfsmount *vfsmnt); +struct path *path);extern void audit_log_lost (const char *message);/* Private API (for audit.c only) */ extern int audit_filter_user (struct netlink_skb_parms *cb,int type);
@@ -545,7 +544,7 @@ extern int audit_enabled;#define audit_log_hex (a,b,l) do { ; } while (0)#define audit_log_untrustedstring (a,s) do { ; } while (0)#define audit_log_n_untrustedstring (a,n,s) do { ; } while (0) -#define audit_log_d_path (b,p,d,v) do { ; } while (0) +#define audit_log_d_path (b,p,d) do { ; } while (0)#define audit_enabled 0#endif #endif
kernel/audit.c +6 -6
@@ -1394,26 +1394,26 @@ const char *audit_log_untrustedstring(st/* This is a helper-function to print the escaped d_path */ void audit_log_d_path (struct audit_buffer *ab,const char *prefix, -struct dentry *dentry,struct vfsmount *vfsmnt) +struct path *path) { -char *p, *path; +char *p, *pathname;if (prefix)audit_log_format (ab," %s" , prefix);/* We will allow 11 spaces for ' (deleted)' to be appended */ - path =kmalloc (PATH_MAX +11 , ab->gfp_mask); -if (!path) { + pathname =kmalloc (PATH_MAX +11 , ab->gfp_mask); +if (!pathname) {audit_log_format (ab,"<no memory>" );return ; } - p =d_path (dentry, vfsmnt, path,PATH_MAX +11 ); + p =d_path (path->dentry, path->mnt, pathname,PATH_MAX +11 );if (IS_ERR (p)) {/* Should never happen since we send PATH_MAX */ /* FIXME: can we save some information here? */ audit_log_format (ab,"<too long>" ); }else audit_log_untrustedstring (ab, p); -kfree (path); +kfree (pathname); }/**
kernel/auditsc.c +11 -17
@@ -201,8 +201,7 @@ struct audit_context {int name_count;struct audit_names names[AUDIT_NAMES ];char * filterkey;/* key for rule that triggered record */ -struct dentry * pwd; -struct vfsmount * pwdmnt; +struct path pwd;struct audit_context *previous;/* For nested syscalls */ struct audit_aux_data *aux;struct audit_aux_data *aux_pids;
@@ -758,12 +757,9 @@ static inline void audit_free_names(stru__putname (context->names[i].name); } context->name_count =0 ; -if (context->pwd) -dput (context->pwd); -if (context->pwdmnt) -mntput (context->pwdmnt); - context->pwd =NULL ; - context->pwdmnt =NULL ; +path_put (&context->pwd); + context->pwd.dentry =NULL ; + context->pwd.mnt =NULL ; }static inline void audit_free_aux (struct audit_context *context)
@@ -910,8 +906,7 @@ static void audit_log_task_info(struct aif ((vma->vm_flags &VM_EXECUTABLE ) && vma->vm_file) {audit_log_d_path (ab,"exe=" , - vma->vm_file->f_path.dentry, - vma->vm_file->f_path.mnt); + &vma->vm_file->f_path);break ; } vma = vma->vm_next;
@@ -1177,10 +1172,10 @@ static void audit_log_exit(struct audit_ context->target_sid)) call_panic =1 ; -if (context->pwd && context->pwdmnt) { +if (context->pwd.dentry && context->pwd.mnt) { ab =audit_log_start (context,GFP_KERNEL ,AUDIT_CWD );if (ab) { -audit_log_d_path (ab,"cwd=" , context->pwd, context->pwdmnt); +audit_log_d_path (ab,"cwd=" , &context->pwd);audit_log_end (ab); } }
@@ -1203,8 +1198,7 @@ static void audit_log_exit(struct audit_case 0 :/* name was specified as a relative path and the * directory component is the cwd */ -audit_log_d_path (ab," name=" , context->pwd, - context->pwdmnt); +audit_log_d_path (ab," name=" , &context->pwd);break ;default :/* log the name's directory component */
@@ -1526,10 +1520,10 @@ void __audit_getname(const char *name) context->names[context->name_count].ino = (unsigned long )-1 ; context->names[context->name_count].osid =0 ; ++context->name_count; -if (!context->pwd) { +if (!context->pwd.dentry) {read_lock (¤t->fs->lock); - context->pwd =dget (current->fs->pwd.dentry); - context->pwdmnt =mntget (current->fs->pwd.mnt); + context->pwd = current->fs->pwd; +path_get (¤t->fs->pwd);read_unlock (¤t->fs->lock); }
security/selinux/avc.c +8 -5
@@ -568,10 +568,11 @@ void avc_audit(u32 ssid, u32 tsid,audit_log_format (ab," capability=%d" , a->u.cap);break ;case AVC_AUDIT_DATA_FS : -if (a->u.fs.dentry) { -struct dentry *dentry = a->u.fs.dentry; -if (a->u.fs.mnt) { -audit_log_d_path (ab,"path=" , dentry, a->u.fs.mnt); +if (a->u.fs.path.dentry) { +struct dentry *dentry = a->u.fs.path.dentry; +if (a->u.fs.path.mnt) { +audit_log_d_path (ab,"path=" , + &a->u.fs.path); }else {audit_log_format (ab," name=" );audit_log_untrustedstring (ab, dentry->d_name.name);
@@ -626,8 +627,10 @@ void avc_audit(u32 ssid, u32 tsid,case AF_UNIX : u =unix_sk (sk);if (u->dentry) { +struct path path = { .dentry = u->dentry, + .mnt = u->mnt };audit_log_d_path (ab,"path=" , - u->dentry, u->mnt); + &path);break ; }if (!u->addr)
security/selinux/hooks.c +12 -16
@@ -1106,8 +1106,8 @@ static inline int dentry_has_perm(structstruct inode *inode = dentry->d_inode;struct avc_audit_data ad;AVC_AUDIT_DATA_INIT (&ad,FS ); - ad.u.fs.mnt = mnt; - ad.u.fs.dentry = dentry; + ad.u.fs.path.mnt = mnt; + ad.u.fs.path.dentry = dentry;return inode_has_perm (tsk, inode, av, &ad); }
@@ -1125,15 +1125,12 @@ static int file_has_perm(struct task_str {struct task_security_struct *tsec = tsk->security;struct file_security_struct *fsec = file->f_security; -struct vfsmount *mnt = file->f_path.mnt; -struct dentry *dentry = file->f_path.dentry; -struct inode *inode = dentry->d_inode; +struct inode *inode = file->f_path.dentry->d_inode;struct avc_audit_data ad;int rc;AVC_AUDIT_DATA_INIT (&ad,FS ); - ad.u.fs.mnt = mnt; - ad.u.fs.dentry = dentry; + ad.u.fs.path = file->f_path;if (tsec->sid != fsec->sid) { rc = avc_has_perm(tsec->sid, fsec->sid,
@@ -1168,7 +1165,7 @@ static int may_create(struct inode *dir, sbsec = dir->i_sb->s_security;AVC_AUDIT_DATA_INIT (&ad,FS ); - ad.u.fs.dentry = dentry; + ad.u.fs.path.dentry = dentry; rc = avc_has_perm(tsec->sid, dsec->sid, SECCLASS_DIR, DIR__ADD_NAME | DIR__SEARCH,
@@ -1226,7 +1223,7 @@ static int may_link(struct inode *dir, isec = dentry->d_inode->i_security;AVC_AUDIT_DATA_INIT (&ad,FS ); - ad.u.fs.dentry = dentry; + ad.u.fs.path.dentry = dentry; av =DIR__SEARCH ; av |= (kind ?DIR__REMOVE_NAME :DIR__ADD_NAME );
@@ -1273,7 +1270,7 @@ static inline int may_rename(struct inodAVC_AUDIT_DATA_INIT (&ad,FS ); - ad.u.fs.dentry = old_dentry; + ad.u.fs.path.dentry = old_dentry; rc =avc_has_perm (tsec->sid, old_dsec->sid,SECCLASS_DIR ,DIR__REMOVE_NAME |DIR__SEARCH , &ad);if (rc)
@@ -1289,7 +1286,7 @@ static inline int may_rename(struct inodreturn rc; } - ad.u.fs.dentry = new_dentry; + ad.u.fs.path.dentry = new_dentry; av =DIR__ADD_NAME |DIR__SEARCH ;if (new_dentry->d_inode) av |=DIR__REMOVE_NAME ;
@@ -1668,8 +1665,7 @@ static int selinux_bprm_set_security(str }AVC_AUDIT_DATA_INIT (&ad,FS ); - ad.u.fs.mnt = bprm->file->f_path.mnt; - ad.u.fs.dentry = bprm->file->f_path.dentry; + ad.u.fs.path = bprm->file->f_path;if (bprm->file->f_path.mnt->mnt_flags &MNT_NOSUID ) newsid = tsec->sid;
@@ -2065,7 +2061,7 @@ static int selinux_sb_kern_mount(structreturn rc;AVC_AUDIT_DATA_INIT (&ad,FS ); - ad.u.fs.dentry = sb->s_root; + ad.u.fs.path.dentry = sb->s_root;return superblock_has_perm (current, sb,FILESYSTEM__MOUNT , &ad); }
@@ -2074,7 +2070,7 @@ static int selinux_sb_statfs(struct dentstruct avc_audit_data ad;AVC_AUDIT_DATA_INIT (&ad,FS ); - ad.u.fs.dentry = dentry->d_sb->s_root; + ad.u.fs.path.dentry = dentry->d_sb->s_root;return superblock_has_perm (current, dentry->d_sb,FILESYSTEM__GETATTR , &ad); }
@@ -2337,7 +2333,7 @@ static int selinux_inode_setxattr(structreturn -EPERM ;AVC_AUDIT_DATA_INIT (&ad,FS ); - ad.u.fs.dentry = dentry; + ad.u.fs.path.dentry = dentry; rc =avc_has_perm (tsec->sid, isec->sid, isec->sclass,FILE__RELABELFROM , &ad);
security/selinux/include/avc.h +2 -4
@@ -13,6 +13,7 @@#include <linux/spinlock.h> #include <linux/init.h> #include <linux/in6.h> +#include <linux/path.h> #include <asm/system.h> #include "flask.h" #include "av_permissions.h"
@@ -30,8 +31,6 @@ extern int selinux_enforcing;struct avc_entry ;struct task_struct ; -struct vfsmount ; -struct dentry ;struct inode ;struct sock ;struct sk_buff ;
@@ -46,8 +45,7 @@ struct avc_audit_data {struct task_struct *tsk;union {struct { -struct vfsmount *mnt; -struct dentry *dentry; +struct path path;struct inode *inode; } fs;struct {
PATCH 4/9 d_path: Make proc_get_link() use a struct path argument
In reply to Jan Blunckproc_get_link() is always called with a dentry and a vfsmount from a struct path. Make proc_get_link() take it directly as an argument.
--- fs/proc/base.c | 60 ++++++++++++++++++++---------------------------- fs/proc/internal.h | 2 - fs/proc/task_mmu.c | 6 ++-- fs/proc/task_nommu.c | 6 ++-- include/linux/proc_fs.h | 2 - 5 files changed, 34 insertions(+), 42 deletions(-)
fs/proc/base.c +26 -34
@@ -153,7 +153,7 @@ static int get_nr_threads(struct task_streturn count; } -static int proc_cwd_link (struct inode *inode,struct dentry **dentry,struct vfsmount **mnt) +static int proc_cwd_link (struct inode *inode,struct path *path) {struct task_struct *task =get_proc_task (inode);struct fs_struct *fs =NULL ;
@@ -165,8 +165,8 @@ static int proc_cwd_link(struct inode *i }if (fs) {read_lock (&fs->lock); - *mnt =mntget (fs->pwd.mnt); - *dentry =dget (fs->pwd.dentry); + *path = fs->pwd; +path_get (&fs->pwd);read_unlock (&fs->lock); result =0 ;put_fs_struct (fs);
@@ -174,7 +174,7 @@ static int proc_cwd_link(struct inode *ireturn result; } -static int proc_root_link (struct inode *inode,struct dentry **dentry,struct vfsmount **mnt) +static int proc_root_link (struct inode *inode,struct path *path) {struct task_struct *task =get_proc_task (inode);struct fs_struct *fs =NULL ;
@@ -186,8 +186,8 @@ static int proc_root_link(struct inode * }if (fs) {read_lock (&fs->lock); - *mnt =mntget (fs->root.mnt); - *dentry =dget (fs->root.dentry); + *path = fs->root; +path_get (&fs->root);read_unlock (&fs->lock); result =0 ;put_fs_struct (fs);
@@ -1039,34 +1039,30 @@ static void *proc_pid_follow_link(structif (!proc_fd_access_allowed (inode)) goto out; - error =PROC_I (inode)->op.proc_get_link (inode, &nd->path.dentry, - &nd->path.mnt); + error =PROC_I (inode)->op.proc_get_link (inode, &nd->path); nd->last_type =LAST_BIND ; out:return ERR_PTR (error); } -static int do_proc_readlink (struct dentry *dentry,struct vfsmount *mnt, -char __user *buffer,int buflen) +static int do_proc_readlink (struct path *path,char __user *buffer,int buflen) { -struct inode * inode;char *tmp = (char *)__get_free_page (GFP_TEMPORARY ); -char *path; +char *pathname;int len;if (!tmp)return -ENOMEM ; - inode = dentry->d_inode; - path =d_path (dentry, mnt, tmp,PAGE_SIZE ); - len =PTR_ERR (path); -if (IS_ERR (path)) + pathname =d_path (path->dentry, path->mnt, tmp,PAGE_SIZE ); + len =PTR_ERR (pathname); +if (IS_ERR (pathname)) goto out; - len = tmp +PAGE_SIZE -1 - path; + len = tmp +PAGE_SIZE -1 - pathname;if (len > buflen) len = buflen; -if (copy_to_user (buffer, path, len)) +if (copy_to_user (buffer, pathname, len)) len = -EFAULT ; out:free_page ((unsigned long )tmp);
@@ -1077,20 +1073,18 @@ static int proc_pid_readlink(struct dent {int error = -EACCES ;struct inode *inode = dentry->d_inode; -struct dentry *de; -struct vfsmount *mnt =NULL ; +struct path path;/* Are we allowed to snoop on the tasks file descriptors? */ if (!proc_fd_access_allowed (inode)) goto out; - error =PROC_I (inode)->op.proc_get_link (inode, &de, &mnt); + error =PROC_I (inode)->op.proc_get_link (inode, &path);if (error) goto out; - error =do_proc_readlink (de, mnt, buffer, buflen); -dput (de); -mntput (mnt); + error =do_proc_readlink (&path, buffer, buflen); +path_put (&path); out:return error; }
@@ -1317,8 +1311,7 @@ out:#define PROC_FDINFO_MAX 64 -static int proc_fd_info (struct inode *inode,struct dentry **dentry, -struct vfsmount **mnt,char *info) +static int proc_fd_info (struct inode *inode,struct path *path,char *info) {struct task_struct *task =get_proc_task (inode);struct files_struct *files =NULL ;
@@ -1337,10 +1330,10 @@ static int proc_fd_info(struct inode *inspin_lock (&files->file_lock); file =fcheck_files (files, fd);if (file) { -if (mnt) - *mnt =mntget (file->f_path.mnt); -if (dentry) - *dentry =dget (file->f_path.dentry); +if (path) { + *path = file->f_path; +path_get (&file->f_path); + }if (info)snprintf (info,PROC_FDINFO_MAX , "pos:\t%lli\n"
@@ -1357,10 +1350,9 @@ static int proc_fd_info(struct inode *inreturn -ENOENT ; } -static int proc_fd_link (struct inode *inode,struct dentry **dentry, -struct vfsmount **mnt) +static int proc_fd_link (struct inode *inode,struct path *path) { -return proc_fd_info (inode, dentry, mnt,NULL ); +return proc_fd_info (inode, path,NULL ); }static int tid_fd_revalidate (struct dentry *dentry,struct nameidata *nd)
@@ -1554,7 +1546,7 @@ static ssize_t proc_fdinfo_read(struct f size_t len, loff_t *ppos) { char tmp[PROC_FDINFO_MAX]; -int err =proc_fd_info (file->f_path.dentry->d_inode,NULL ,NULL , tmp); +int err =proc_fd_info (file->f_path.dentry->d_inode,NULL , tmp);if (!err) err =simple_read_from_buffer (buf, len, ppos, tmp,strlen (tmp));return err;
fs/proc/internal.h +1 -1
@@ -45,7 +45,7 @@ extern int nommu_vma_show(struct seq_filextern int maps_protect;extern void create_seq_entry (char *name,mode_t mode,const struct file_operations *f); -extern int proc_exe_link (struct inode *,struct dentry **,struct vfsmount **); +extern int proc_exe_link (struct inode *,struct path *);extern int proc_tid_stat (struct task_struct *,char *);extern int proc_tgid_stat (struct task_struct *,char *);extern int proc_pid_status (struct task_struct *,char *);
fs/proc/task_mmu.c +3 -3
@@ -73,7 +73,7 @@ int task_statm(struct mm_struct *mm, intreturn mm->total_vm; } -int proc_exe_link (struct inode *inode,struct dentry **dentry,struct vfsmount **mnt) +int proc_exe_link (struct inode *inode,struct path *path) {struct vm_area_struct * vma;int result = -ENOENT ;
@@ -96,8 +96,8 @@ int proc_exe_link(struct inode *inode, s }if (vma) { - *mnt =mntget (vma->vm_file->f_path.mnt); - *dentry =dget (vma->vm_file->f_path.dentry); + *path = vma->vm_file->f_path; +path_get (&vma->vm_file->f_path); result =0 ; }
fs/proc/task_nommu.c +3 -3
@@ -104,7 +104,7 @@ int task_statm(struct mm_struct *mm, intreturn size; } -int proc_exe_link (struct inode *inode,struct dentry **dentry,struct vfsmount **mnt) +int proc_exe_link (struct inode *inode,struct path *path) {struct vm_list_struct *vml;struct vm_area_struct *vma;
@@ -127,8 +127,8 @@ int proc_exe_link(struct inode *inode, s }if (vma) { - *mnt =mntget (vma->vm_file->f_path.mnt); - *dentry =dget (vma->vm_file->f_path.dentry); + *path = vma->vm_file->f_path; +path_get (&vma->vm_file->f_path); result =0 ; }
include/linux/proc_fs.h +1 -1
@@ -257,7 +257,7 @@ extern void kclist_add(struct kcore_list#endif union proc_op { -int (*proc_get_link)(struct inode *,struct dentry **,struct vfsmount **); +int (*proc_get_link)(struct inode *,struct path *);int (*proc_read)(struct task_struct *task,char *page); };
PATCH 5/9 d_path: Make get_dcookie() use a struct path argument
In reply to Jan Blunckget_dcookie() is always called with a dentry and a vfsmount from a struct path. Make get_dcookie() take it directly as an argument.
--- arch/powerpc/oprofile/cell/spu_task_sync.c | 15 +++++--------- drivers/oprofile/buffer_sync.c | 21 ++++++++----------- fs/dcookies.c | 31 ++++++++++++----------------- include/linux/dcookies.h | 15 ++++++-------- 4 files changed, 35 insertions(+), 47 deletions(-)
arch/powerpc/oprofile/cell/spu_task_sync.c +6 -9
@@ -198,14 +198,13 @@ out:* dcookie user still being registered (namely, the reader * of the event buffer). */ -static inline unsigned long fast_get_dcookie (struct dentry *dentry, -struct vfsmount *vfsmnt) +static inline unsigned long fast_get_dcookie (struct path *path) {unsigned long cookie; -if (dentry->d_cookie) -return (unsigned long )dentry; -get_dcookie (dentry, vfsmnt, &cookie); +if (path->dentry->d_cookie) +return (unsigned long )path->dentry; +get_dcookie (path, &cookie);return cookie; }
@@ -240,8 +239,7 @@ get_exec_dcookie_and_offset(struct spu *continue ;if (!(vma->vm_flags &VM_EXECUTABLE ))continue ; - app_cookie =fast_get_dcookie (vma->vm_file->f_dentry, - vma->vm_file->f_vfsmnt); + app_cookie =fast_get_dcookie (&vma->vm_file->f_path);pr_debug ("got dcookie for %s\n" , vma->vm_file->f_dentry->d_name.name); app = vma->vm_file;
@@ -262,8 +260,7 @@ get_exec_dcookie_and_offset(struct spu *break ; } - *spu_bin_dcookie =fast_get_dcookie (vma->vm_file->f_dentry, - vma->vm_file->f_vfsmnt); + *spu_bin_dcookie =fast_get_dcookie (&vma->vm_file->f_path);pr_debug ("got dcookie for %s\n" , vma->vm_file->f_dentry->d_name.name);up_read (&mm->mmap_sem);
drivers/oprofile/buffer_sync.c +9 -12
@@ -187,23 +187,22 @@ void sync_stop(void)end_sync (); } - +/* Optimisation. We can manage without taking the dcookie sem * because we cannot reach this code without at least one * dcookie user still being registered (namely, the reader * of the event buffer). */ -static inline unsigned long fast_get_dcookie (struct dentry * dentry, -struct vfsmount * vfsmnt) +static inline unsigned long fast_get_dcookie (struct path *path) {unsigned long cookie; - -if (dentry->d_cookie) -return (unsigned long )dentry; -get_dcookie (dentry, vfsmnt, &cookie); + +if (path->dentry->d_cookie) +return (unsigned long )path->dentry; +get_dcookie (path, &cookie);return cookie; } - +/* Look up the dcookie for the task's first VM_EXECUTABLE mapping, * which corresponds loosely to "application name". This is * not strictly necessary but allows oprofile to associate
@@ -222,8 +221,7 @@ static unsigned long get_exec_dcookie(stcontinue ;if (!(vma->vm_flags &VM_EXECUTABLE ))continue ; - cookie =fast_get_dcookie (vma->vm_file->f_path.dentry, - vma->vm_file->f_path.mnt); + cookie =fast_get_dcookie (&vma->vm_file->f_path);break ; }
@@ -248,8 +246,7 @@ static unsigned long lookup_dcookie(strucontinue ;if (vma->vm_file) { - cookie =fast_get_dcookie (vma->vm_file->f_path.dentry, - vma->vm_file->f_path.mnt); + cookie =fast_get_dcookie (&vma->vm_file->f_path); *offset = (vma->vm_pgoff <<PAGE_SHIFT ) + addr - vma->vm_start; }else {
fs/dcookies.c +13 -18
@@ -24,6 +24,7 @@#include <linux/errno.h> #include <linux/dcookies.h> #include <linux/mutex.h> +#include <linux/path.h> #include <asm/uaccess.h> /* The dcookies are allocated from a kmem_cache and
@@ -31,8 +32,7 @@* code here is particularly performance critical */ struct dcookie_struct { -struct dentry * dentry; -struct vfsmount * vfsmnt; +struct path path;struct list_head hash_list; };
@@ -51,7 +51,7 @@ static inline int is_live(void)/* The dentry is locked, its address will do for the cookie */ static inline unsigned long dcookie_value (struct dcookie_struct * dcs) { -return (unsigned long )dcs->dentry; +return (unsigned long )dcs->path.dentry; }
@@ -89,19 +89,16 @@ static void hash_dcookie(struct dcookie_ } -static struct dcookie_struct *alloc_dcookie (struct dentry * dentry, -struct vfsmount * vfsmnt) +static struct dcookie_struct *alloc_dcookie (struct path *path) {struct dcookie_struct * dcs =kmem_cache_alloc (dcookie_cache,GFP_KERNEL );if (!dcs)return NULL ; - dentry->d_cookie = dcs; - - dcs->dentry =dget (dentry); - dcs->vfsmnt =mntget (vfsmnt); + path->dentry->d_cookie = dcs; + dcs->path = *path; +path_get (path);hash_dcookie (dcs); -return dcs; }
@@ -109,8 +106,7 @@ static struct dcookie_struct * alloc_dco/* This is the main kernel-side routine that retrieves the cookie * value for a dentry/vfsmnt pair. */ -int get_dcookie (struct dentry * dentry,struct vfsmount * vfsmnt, -unsigned long * cookie) +int get_dcookie (struct path *path,unsigned long * cookie) {int err =0 ;struct dcookie_struct * dcs;
@@ -122,10 +118,10 @@ int get_dcookie(struct dentry * dentry, goto out; } - dcs = dentry->d_cookie; + dcs = path->dentry->d_cookie;if (!dcs) - dcs =alloc_dcookie (dentry, vfsmnt); + dcs =alloc_dcookie (path);if (!dcs) { err = -ENOMEM ;
@@ -174,7 +170,7 @@ asmlinkage long sys_lookup_dcookie(u64 c goto out;/* FIXME: (deleted) ? */ - path =d_path (dcs->dentry, dcs->vfsmnt, kbuf,PAGE_SIZE ); + path =d_path (dcs->path.dentry, dcs->path.mnt, kbuf,PAGE_SIZE );if (IS_ERR (path)) { err =PTR_ERR (path);
@@ -254,9 +250,8 @@ out_kmem:static void free_dcookie (struct dcookie_struct * dcs) { - dcs->dentry->d_cookie =NULL ; -dput (dcs->dentry); -mntput (dcs->vfsmnt); + dcs->path.dentry->d_cookie =NULL ; +path_put (&dcs->path);kmem_cache_free (dcookie_cache, dcs); }
include/linux/dcookies.h +7 -8
@@ -13,6 +13,7 @@#ifdef CONFIG_PROFILING #include <linux/dcache.h> +#include <linux/path.h> #include <linux/types.h> struct dcookie_user ;
@@ -43,8 +44,7 @@ void dcookie_unregister(struct dcookie_u* * Returns 0 on success, with *cookie filled in */ -int get_dcookie (struct dentry * dentry,struct vfsmount * vfsmnt, -unsigned long * cookie); +int get_dcookie (struct path *path,unsigned long *cookie);#else
@@ -57,13 +57,12 @@ static inline void dcookie_unregister(st {return ; } - -static inline int get_dcookie (struct dentry * dentry, -struct vfsmount * vfsmnt,unsigned long * cookie) + +static inline int get_dcookie (struct path *path,unsigned long *cookie) {return -ENOSYS ; -} - +} +#endif /* CONFIG_PROFILING */ - +#endif /* DCOOKIES_H */
PATCH 6/9 Use struct path in struct svc_export
In reply to Jan BlunckI'm embedding struct path into struct svc_export.
--- fs/nfsd/export.c | 68 +++++++++++++++++++++----------------------- fs/nfsd/nfs3proc.c | 2 - fs/nfsd/nfs3xdr.c | 4 +- fs/nfsd/nfs4proc.c | 4 +- fs/nfsd/nfs4xdr.c | 12 +++---- fs/nfsd/nfsfh.c | 26 ++++++++-------- fs/nfsd/nfsproc.c | 6 +-- fs/nfsd/nfsxdr.c | 2 - fs/nfsd/vfs.c | 22 +++++++------- include/linux/nfsd/export.h | 5 +-- 10 files changed, 74 insertions(+), 77 deletions(-)
fs/nfsd/export.c +33 -35
@@ -332,10 +332,9 @@ static void nfsd4_fslocs_free(struct nfsstatic void svc_export_put (struct kref *ref) { struct svc_export *exp = container_of(ref, struct svc_export, h.ref); -dput (exp->ex_dentry); -mntput (exp->ex_mnt); +path_put (&exp->ex_path);auth_domain_put (exp->ex_client); -kfree (exp->ex_path); +kfree (exp->ex_pathname);nfsd4_fslocs_free (&exp->ex_fslocs);kfree (exp); }
@@ -349,7 +348,7 @@ static void svc_export_request(struct cachar *pth;qword_add (bpp, blen, exp->ex_client->name); - pth =d_path (exp->ex_dentry, exp->ex_mnt, *bpp, *blen); + pth =d_path (exp->ex_path.dentry, exp->ex_path.mnt, *bpp, *blen);if (IS_ERR (pth)) {/* is this correct? */ (*bpp)[0 ] ='\n' ;
@@ -508,7 +507,7 @@ static int svc_export_parse(struct cacheint an_int; nd.path.dentry =NULL ; - exp.ex_path =NULL ; + exp.ex_pathname =NULL ;/* fs locations */ exp.ex_fslocs.locations =NULL ;
@@ -547,11 +546,11 @@ static int svc_export_parse(struct cache exp.h.flags =0 ; exp.ex_client = dom; - exp.ex_mnt = nd.path.mnt; - exp.ex_dentry = nd.path.dentry; - exp.ex_path =kstrdup (buf,GFP_KERNEL ); + exp.ex_path.mnt = nd.path.mnt; + exp.ex_path.dentry = nd.path.dentry; + exp.ex_pathname =kstrdup (buf,GFP_KERNEL ); err = -ENOMEM ; -if (!exp.ex_path) +if (!exp.ex_pathname) goto out;/* expiry */
@@ -628,7 +627,7 @@ static int svc_export_parse(struct cache out:nfsd4_fslocs_free (&exp.ex_fslocs);kfree (exp.ex_uuid); -kfree (exp.ex_path); +kfree (exp.ex_pathname);if (nd.path.dentry)path_put (&nd.path); out_no_path:
@@ -653,7 +652,7 @@ static int svc_export_show(struct seq_fireturn 0 ; } exp = container_of(h, struct svc_export, h); -seq_path (m, exp->ex_mnt, exp->ex_dentry," \t\n\\" ); +seq_path (m, exp->ex_path.mnt, exp->ex_path.dentry," \t\n\\" );seq_putc (m,'\t' );seq_escape (m, exp->ex_client->name," \t\n\\" );seq_putc (m,'(' );
@@ -680,8 +679,8 @@ static int svc_export_match(struct cache struct svc_export *orig = container_of(a, struct svc_export, h); struct svc_export *new = container_of(b, struct svc_export, h);return orig->ex_client == new->ex_client && - orig->ex_dentry == new->ex_dentry && - orig->ex_mnt == new->ex_mnt; + orig->ex_path.dentry == new->ex_path.dentry && + orig->ex_path.mnt == new->ex_path.mnt; }static void svc_export_init (struct cache_head *cnew,struct cache_head *citem)
@@ -691,9 +690,9 @@ static void svc_export_init(struct cachekref_get (&item->ex_client->ref); new->ex_client = item->ex_client; - new->ex_dentry =dget (item->ex_dentry); - new->ex_mnt =mntget (item->ex_mnt); - new->ex_path =NULL ; + new->ex_path.dentry =dget (item->ex_path.dentry); + new->ex_path.mnt =mntget (item->ex_path.mnt); + new->ex_pathname =NULL ; new->ex_fslocs.locations =NULL ; new->ex_fslocs.locations_count =0 ; new->ex_fslocs.migrated =0 ;
@@ -711,8 +710,8 @@ static void export_update(struct cache_h new->ex_fsid = item->ex_fsid; new->ex_uuid = item->ex_uuid; item->ex_uuid =NULL ; - new->ex_path = item->ex_path; - item->ex_path =NULL ; + new->ex_pathname = item->ex_pathname; + item->ex_pathname =NULL ; new->ex_fslocs.locations = item->ex_fslocs.locations; item->ex_fslocs.locations =NULL ; new->ex_fslocs.locations_count = item->ex_fslocs.locations_count;
@@ -755,8 +754,8 @@ svc_export_lookup(struct svc_export *expstruct cache_head *ch;int hash; hash =hash_ptr (exp->ex_client,EXPORT_HASHBITS ); - hash ^=hash_ptr (exp->ex_dentry,EXPORT_HASHBITS ); - hash ^=hash_ptr (exp->ex_mnt,EXPORT_HASHBITS ); + hash ^=hash_ptr (exp->ex_path.dentry,EXPORT_HASHBITS ); + hash ^=hash_ptr (exp->ex_path.mnt,EXPORT_HASHBITS ); ch =sunrpc_cache_lookup (&svc_export_cache, &exp->h, hash);
@@ -772,8 +771,8 @@ svc_export_update(struct svc_export *newstruct cache_head *ch;int hash; hash =hash_ptr (old->ex_client,EXPORT_HASHBITS ); - hash ^=hash_ptr (old->ex_dentry,EXPORT_HASHBITS ); - hash ^=hash_ptr (old->ex_mnt,EXPORT_HASHBITS ); + hash ^=hash_ptr (old->ex_path.dentry,EXPORT_HASHBITS ); + hash ^=hash_ptr (old->ex_path.mnt,EXPORT_HASHBITS ); ch = sunrpc_cache_update(&svc_export_cache, &new->h, &old->h,
@@ -815,8 +814,8 @@ static int exp_set_key(svc_client *clp, key.ek_client = clp; key.ek_fsidtype = fsid_type;memcpy (key.ek_fsid, fsidv,key_len (fsid_type)); - key.ek_mnt = exp->ex_mnt; - key.ek_dentry = exp->ex_dentry; + key.ek_mnt = exp->ex_path.mnt; + key.ek_dentry = exp->ex_path.dentry; key.h.expiry_time =NEVER ; key.h.flags =0 ;
@@ -870,8 +869,8 @@ static svc_export *exp_get_by_name(svc_creturn ERR_PTR (-ENOENT ); key.ex_client = clp; - key.ex_mnt = mnt; - key.ex_dentry = dentry; + key.ex_path.mnt = mnt; + key.ex_path.dentry = dentry; exp =svc_export_lookup (&key);if (exp ==NULL )
@@ -968,7 +967,7 @@ static int exp_fsid_hash(svc_client *clpstatic int exp_hash (struct auth_domain *clp,struct svc_export *exp) {u32 fsid[2 ]; -struct inode *inode = exp->ex_dentry->d_inode; +struct inode *inode = exp->ex_path.dentry->d_inode;dev_t dev = inode->i_sb->s_dev;if (old_valid_dev (dev)) {
@@ -982,7 +981,7 @@ static int exp_hash(struct auth_domain *static void exp_unhash (struct svc_export *exp) {struct svc_expkey *ek; -struct inode *inode = exp->ex_dentry->d_inode; +struct inode *inode = exp->ex_path.dentry->d_inode; ek =exp_get_key (exp->ex_client, inode->i_sb->s_dev, inode->i_ino);if (!IS_ERR (ek)) {
@@ -1064,12 +1063,11 @@ exp_export(struct nfsctl_export *nxp) new.h.expiry_time =NEVER ; new.h.flags =0 ; - new.ex_path =kstrdup (nxp->ex_path,GFP_KERNEL ); -if (!new.ex_path) + new.ex_pathname =kstrdup (nxp->ex_path,GFP_KERNEL ); +if (!new.ex_pathname) goto finish; new.ex_client = clp; - new.ex_mnt = nd.path.mnt; - new.ex_dentry = nd.path.dentry; + new.ex_path = nd.path; new.ex_flags = nxp->ex_flags; new.ex_anon_uid = nxp->ex_anon_uid; new.ex_anon_gid = nxp->ex_anon_gid;
@@ -1090,8 +1088,8 @@ exp_export(struct nfsctl_export *nxp) }else err =0 ; finish: -if (new.ex_path) -kfree (new.ex_path); +if (new.ex_pathname) +kfree (new.ex_pathname);if (exp)exp_put (exp);if (fsid_key && !IS_ERR (fsid_key))
@@ -1362,7 +1360,7 @@ exp_pseudoroot(struct svc_rqst *rqstp, sreturn nfserr_perm;if (IS_ERR (exp))return nfserrno (PTR_ERR (exp)); - rv =fh_compose (fhp, exp, exp->ex_dentry,NULL ); + rv =fh_compose (fhp, exp, exp->ex_path.dentry,NULL );if (rv) goto out; rv =check_nfsd_access (exp, rqstp);
fs/nfsd/nfs3proc.c +1 -1
@@ -67,7 +67,7 @@ nfsd3_proc_getattr(struct svc_rqst *rqstif (nfserr)RETURN_STATUS (nfserr); - err =vfs_getattr (resp->fh.fh_export->ex_mnt, + err =vfs_getattr (resp->fh.fh_export->ex_path.mnt, resp->fh.fh_dentry, &resp->stat); nfserr =nfserrno (err);
fs/nfsd/nfs3xdr.c +2 -2
@@ -217,7 +217,7 @@ encode_post_op_attr(struct svc_rqst *rqsint err;struct kstat stat; - err =vfs_getattr (fhp->fh_export->ex_mnt, dentry, &stat); + err =vfs_getattr (fhp->fh_export->ex_path.mnt, dentry, &stat);if (!err) { *p++ = xdr_one;/* attributes follow */ lease_get_mtime (dentry->d_inode, &stat.mtime);
@@ -269,7 +269,7 @@ void fill_post_wcc(struct svc_fh *fhp)if (fhp->fh_post_saved)printk ("nfsd: inode locked twice during operation.\n" ); - err =vfs_getattr (fhp->fh_export->ex_mnt, fhp->fh_dentry, + err =vfs_getattr (fhp->fh_export->ex_path.mnt, fhp->fh_dentry, &fhp->fh_post_attr);if (err) fhp->fh_post_saved =0 ;
fs/nfsd/nfs4proc.c +2 -2
@@ -658,7 +658,7 @@ nfsd4_setattr(struct svc_rqst *rqstp, streturn status; } } - status =mnt_want_write (cstate->current_fh.fh_export->ex_mnt); + status =mnt_want_write (cstate->current_fh.fh_export->ex_path.mnt);if (status)return status; status = nfs_ok;
@@ -670,7 +670,7 @@ nfsd4_setattr(struct svc_rqst *rqstp, st status =nfsd_setattr (rqstp, &cstate->current_fh, &setattr->sa_iattr,0 , (time_t )0 ); out: -mnt_drop_write (cstate->current_fh.fh_export->ex_mnt); +mnt_drop_write (cstate->current_fh.fh_export->ex_path.mnt);return status; }
fs/nfsd/nfs4xdr.c +6 -6
@@ -1325,9 +1325,9 @@ static char *nfsd4_path(struct svc_rqst *stat =exp_pseudoroot (rqstp, &tmp_fh);if (*stat)return NULL ; - rootpath = tmp_fh.fh_export->ex_path; + rootpath = tmp_fh.fh_export->ex_pathname; - path = exp->ex_path; + path = exp->ex_pathname;if (strncmp (path, rootpath,strlen (rootpath))) { dprintk("nfsd: fs_locations failed;"
@@ -1476,7 +1476,7 @@ nfsd4_encode_fattr(struct svc_fh *fhp, s goto out; } - err =vfs_getattr (exp->ex_mnt, dentry, &stat); + err =vfs_getattr (exp->ex_path.mnt, dentry, &stat);if (err) goto out_nfserr; if ((bmval0 & (FATTR4_WORD0_FILES_FREE | FATTR4_WORD0_FILES_TOTAL |
@@ -1828,9 +1828,9 @@ out_acl:if (bmval1 &FATTR4_WORD1_MOUNTED_ON_FILEID ) {if ((buflen -=8 ) <0 ) goto out_resource; -if (exp->ex_mnt->mnt_root->d_inode == dentry->d_inode) { - err =vfs_getattr (exp->ex_mnt->mnt_parent, - exp->ex_mnt->mnt_mountpoint, &stat); +if (exp->ex_path.mnt->mnt_root->d_inode == dentry->d_inode) { + err =vfs_getattr (exp->ex_path.mnt->mnt_parent, + exp->ex_path.mnt->mnt_mountpoint, &stat);if (err) goto out_nfserr; }
fs/nfsd/nfsfh.c +13 -13
@@ -46,7 +46,7 @@ static int nfsd_acceptable(void *expv, sreturn 1 ; tdentry =dget (dentry); -while (tdentry != exp->ex_dentry && !IS_ROOT (tdentry)) { +while (tdentry != exp->ex_path.dentry && !IS_ROOT (tdentry)) {/* make sure parents give x permission to user */ int err; parent =dget_parent (tdentry);
@@ -58,9 +58,9 @@ static int nfsd_acceptable(void *expv, sdput (tdentry); tdentry = parent; } -if (tdentry != exp->ex_dentry) +if (tdentry != exp->ex_path.dentry)dprintk ("nfsd_acceptable failed at %p %s\n" , tdentry, tdentry->d_name.name); - rv = (tdentry == exp->ex_dentry); + rv = (tdentry == exp->ex_path.dentry);dput (tdentry);return rv; }
@@ -203,9 +203,9 @@ fh_verify(struct svc_rqst *rqstp, struct fileid_type = fh->fh_fileid_type;if (fileid_type ==FILEID_ROOT ) - dentry =dget (exp->ex_dentry); + dentry =dget (exp->ex_path.dentry);else { - dentry =exportfs_decode_fh (exp->ex_mnt, fid, + dentry =exportfs_decode_fh (exp->ex_path.mnt, fid, data_left, fileid_type, nfsd_acceptable, exp); }
@@ -289,7 +289,7 @@ out:static void _fh_update (struct svc_fh *fhp,struct svc_export *exp,struct dentry *dentry) { -if (dentry != exp->ex_dentry) { +if (dentry != exp->ex_path.dentry) {struct fid *fid = (struct fid *) (fhp->fh_handle.fh_auth + fhp->fh_handle.fh_size/4 -1 );int maxsize = (fhp->fh_maxsize - fhp->fh_handle.fh_size)/4 ;
@@ -334,12 +334,12 @@ fh_compose(struct svc_fh *fhp, struct svstruct inode * inode = dentry->d_inode;struct dentry *parent = dentry->d_parent;__u32 *datap; -dev_t ex_dev = exp->ex_dentry->d_inode->i_sb->s_dev; -int root_export = (exp->ex_dentry == exp->ex_dentry->d_sb->s_root); +dev_t ex_dev = exp->ex_path.dentry->d_inode->i_sb->s_dev; +int root_export = (exp->ex_path.dentry == exp->ex_path.dentry->d_sb->s_root);dprintk ("nfsd: fh_compose(exp %02x:%02x/%ld %s/%s, ino=%ld)\n" ,MAJOR (ex_dev),MINOR (ex_dev), - (long ) exp->ex_dentry->d_inode->i_ino, + (long ) exp->ex_path.dentry->d_inode->i_ino, parent->d_name.name, dentry->d_name.name, (inode ? inode->i_ino :0 ));
@@ -381,7 +381,7 @@ fh_compose(struct svc_fh *fhp, struct sv/* FALL THROUGH */ case FSID_MAJOR_MINOR :case FSID_ENCODE_DEV : -if (!(exp->ex_dentry->d_inode->i_sb->s_type->fs_flags +if (!(exp->ex_path.dentry->d_inode->i_sb->s_type->fs_flags &FS_REQUIRES_DEV )) goto retry;break ;
@@ -444,7 +444,7 @@ fh_compose(struct svc_fh *fhp, struct sv fhp->fh_handle.ofh_dev =old_encode_dev (ex_dev); fhp->fh_handle.ofh_xdev = fhp->fh_handle.ofh_dev; fhp->fh_handle.ofh_xino = -ino_t_to_u32 (exp->ex_dentry->d_inode->i_ino); +ino_t_to_u32 (exp->ex_path.dentry->d_inode->i_ino); fhp->fh_handle.ofh_dirino =ino_t_to_u32 (parent_ino (dentry));if (inode)_fh_update_old (dentry, exp, &fhp->fh_handle);
@@ -455,7 +455,7 @@ fh_compose(struct svc_fh *fhp, struct sv datap = fhp->fh_handle.fh_auth+0 ; fhp->fh_handle.fh_fsid_type = fsid_type;mk_fsid (fsid_type, datap, ex_dev, - exp->ex_dentry->d_inode->i_ino, + exp->ex_path.dentry->d_inode->i_ino, exp->ex_fsid, exp->ex_uuid); len =key_len (fsid_type);
@@ -561,7 +561,7 @@ enum fsid_source fsid_source(struct svc_case FSID_DEV :case FSID_ENCODE_DEV :case FSID_MAJOR_MINOR : -if (fhp->fh_export->ex_dentry->d_inode->i_sb->s_type->fs_flags +if (fhp->fh_export->ex_path.dentry->d_inode->i_sb->s_type->fs_flags &FS_REQUIRES_DEV )return FSIDSOURCE_DEV ;break ;
fs/nfsd/nfsproc.c +3 -3
@@ -41,7 +41,7 @@ static __be32 nfsd_return_attrs(__be32 err, struct nfsd_attrstat *resp) { if (err) return err; - return nfserrno(vfs_getattr(resp->fh.fh_export->ex_mnt, + return nfserrno(vfs_getattr(resp->fh.fh_export->ex_path.mnt, resp->fh.fh_dentry, &resp->stat)); }
@@ -49,7 +49,7 @@ static __be32 nfsd_return_dirop(__be32 err, struct nfsd_diropres *resp) { if (err) return err; - return nfserrno(vfs_getattr(resp->fh.fh_export->ex_mnt, + return nfserrno(vfs_getattr(resp->fh.fh_export->ex_path.mnt, resp->fh.fh_dentry, &resp->stat)); }
@@ -164,7 +164,7 @@ nfsd_proc_read(struct svc_rqst *rqstp, s &resp->count);if (nfserr)return nfserr; -return nfserrno (vfs_getattr (resp->fh.fh_export->ex_mnt, +return nfserrno (vfs_getattr (resp->fh.fh_export->ex_path.mnt, resp->fh.fh_dentry, &resp->stat)); }
fs/nfsd/nfsxdr.c +1 -1
@@ -206,7 +206,7 @@ encode_fattr(struct svc_rqst *rqstp, __b__be32 *nfs2svc_encode_fattr (struct svc_rqst *rqstp,__be32 *p,struct svc_fh *fhp) {struct kstat stat; -vfs_getattr (fhp->fh_export->ex_mnt, fhp->fh_dentry, &stat); +vfs_getattr (fhp->fh_export->ex_path.mnt, fhp->fh_dentry, &stat);return encode_fattr (rqstp, p, fhp, &stat); }
fs/nfsd/vfs.c +11 -11
@@ -101,7 +101,7 @@ nfsd_cross_mnt(struct svc_rqst *rqstp, s {struct svc_export *exp = *expp, *exp2 =NULL ;struct dentry *dentry = *dpp; -struct vfsmount *mnt =mntget (exp->ex_mnt); +struct vfsmount *mnt =mntget (exp->ex_path.mnt);struct dentry *mounts =dget (dentry);int err =0 ;
@@ -156,7 +156,7 @@ nfsd_lookup_dentry(struct svc_rqst *rqstif (isdotent (name, len)) {if (len==1 ) dentry =dget (dparent); -else if (dparent != exp->ex_dentry) { +else if (dparent != exp->ex_path.dentry) { dentry =dget_parent (dparent); }else if (!EX_NOHIDE (exp)) dentry =dget (dparent);/* .. == . just like at / */
@@ -164,7 +164,7 @@ nfsd_lookup_dentry(struct svc_rqst *rqst/* checking mountpoint crossing is very different when stepping up */ struct svc_export *exp2 =NULL ;struct dentry *dp; -struct vfsmount *mnt =mntget (exp->ex_mnt); +struct vfsmount *mnt =mntget (exp->ex_path.mnt); dentry =dget (dparent);while (dentry == mnt->mnt_root &&follow_up (&mnt, &dentry)) ;
@@ -721,7 +721,7 @@ nfsd_open(struct svc_rqst *rqstp, structDQUOT_INIT (inode); } - *filp =dentry_open (dget (dentry),mntget (fhp->fh_export->ex_mnt), flags); + *filp =dentry_open (dget (dentry),mntget (fhp->fh_export->ex_path.mnt), flags);if (IS_ERR (*filp)) host_err =PTR_ERR (*filp); out_nfserr:
@@ -1242,11 +1242,11 @@ nfsd_create(struct svc_rqst *rqstp, strucase S_IFBLK :case S_IFIFO :case S_IFSOCK : - host_err =mnt_want_write (fhp->fh_export->ex_mnt); + host_err =mnt_want_write (fhp->fh_export->ex_path.mnt);if (host_err)break ; host_err =vfs_mknod (dirp, dchild, iap->ia_mode, rdev); -mnt_drop_write (fhp->fh_export->ex_mnt); +mnt_drop_write (fhp->fh_export->ex_path.mnt);break ;default :printk ("nfsd: bad file type %o in nfsd_create\n" , type);
@@ -1457,7 +1457,7 @@ nfsd_readlink(struct svc_rqst *rqstp, stif (!inode->i_op || !inode->i_op->readlink) goto out; -touch_atime (fhp->fh_export->ex_mnt, dentry); +touch_atime (fhp->fh_export->ex_path.mnt, dentry);/* N.B. Why does this call need a get_fs()?? * Remove the set_fs and watch the fireworks:-) --okir */
@@ -1680,9 +1680,9 @@ nfsd_rename(struct svc_rqst *rqstp, stru } host_err = -EXDEV ; -if (ffhp->fh_export->ex_mnt != tfhp->fh_export->ex_mnt) +if (ffhp->fh_export->ex_path.mnt != tfhp->fh_export->ex_path.mnt) goto out_dput_new; - host_err =mnt_want_write (ffhp->fh_export->ex_mnt); + host_err =mnt_want_write (ffhp->fh_export->ex_path.mnt);if (host_err) goto out_dput_new;
@@ -1866,7 +1866,7 @@ nfsd_permission(struct svc_rqst *rqstp, inode->i_mode,IS_IMMUTABLE (inode)?" immut" :"" ,IS_APPEND (inode)?" append" :"" , - __mnt_is_readonly(exp->ex_mnt)? " ro" : ""); + __mnt_is_readonly(exp->ex_path.mnt)? " ro" : "");dprintk (" owner %d/%d user %d/%d\n" , inode->i_uid, inode->i_gid, current->fsuid, current->fsgid);#endif
@@ -1877,7 +1877,7 @@ nfsd_permission(struct svc_rqst *rqstp,*/ if (!(acc &MAY_LOCAL_ACCESS ))if (acc & (MAY_WRITE |MAY_SATTR |MAY_TRUNC )) { -if (exp_rdonly (rqstp, exp) ||__mnt_is_readonly (exp->ex_mnt)) +if (exp_rdonly (rqstp, exp) ||__mnt_is_readonly (exp->ex_path.mnt))return nfserr_rofs;if (/* (acc & MAY_WRITE) && */ IS_IMMUTABLE (inode))return nfserr_perm;
include/linux/nfsd/export.h +2 -3
@@ -84,9 +84,8 @@ struct svc_export {struct cache_head h;struct auth_domain * ex_client;int ex_flags; -struct vfsmount * ex_mnt; -struct dentry * ex_dentry; -char * ex_path; +struct path ex_path; +char * ex_pathname;uid_t ex_anon_uid;gid_t ex_anon_gid;int ex_fsid;
PATCH 7/9 Use struct path in struct svc_expkey
In reply to Jan BlunckI'm embedding struct path into struct svc_expkey.
--- fs/nfsd/export.c | 30 +++++++++++++----------------- include/linux/nfsd/export.h | 3 +-- 2 files changed, 14 insertions(+), 19 deletions(-)
fs/nfsd/export.c +13 -17
@@ -63,10 +63,8 @@ static void expkey_put(struct kref *ref) struct svc_expkey *key = container_of(ref, struct svc_expkey, h.ref);if (test_bit (CACHE_VALID , &key->h.flags) && - !test_bit (CACHE_NEGATIVE , &key->h.flags)) { -dput (key->ek_dentry); -mntput (key->ek_mnt); - } + !test_bit (CACHE_NEGATIVE , &key->h.flags)) +path_put (&key->ek_path);auth_domain_put (key->ek_client);kfree (key); }
@@ -169,9 +167,8 @@ static int expkey_parse(struct cache_det goto out;dprintk ("Found the path %s\n" , buf); - key.ek_mnt = nd.path.mnt; - key.ek_dentry = nd.path.dentry; - + key.ek_path = nd.path; + ek =svc_expkey_update (&key, ek);if (ek)cache_put (&ek->h, &svc_expkey_cache);
@@ -206,7 +203,7 @@ static int expkey_show(struct seq_file *if (test_bit (CACHE_VALID , &h->flags) && !test_bit (CACHE_NEGATIVE , &h->flags)) {seq_printf (m," " ); -seq_path (m, ek->ek_mnt, ek->ek_dentry,"\\ \t\n" ); +seq_path (m, ek->ek_path.mnt, ek->ek_path.dentry,"\\ \t\n" ); }seq_printf (m,"\n" );return 0 ;
@@ -243,8 +240,8 @@ static inline void expkey_update(struct struct svc_expkey *new = container_of(cnew, struct svc_expkey, h); struct svc_expkey *item = container_of(citem, struct svc_expkey, h); - new->ek_mnt =mntget (item->ek_mnt); - new->ek_dentry =dget (item->ek_dentry); + new->ek_path = item->ek_path; +path_get (&item->ek_path); }static struct cache_head *expkey_alloc (void )
@@ -814,8 +811,7 @@ static int exp_set_key(svc_client *clp, key.ek_client = clp; key.ek_fsidtype = fsid_type;memcpy (key.ek_fsid, fsidv,key_len (fsid_type)); - key.ek_mnt = exp->ex_path.mnt; - key.ek_dentry = exp->ex_path.dentry; + key.ek_path = exp->ex_path; key.h.expiry_time =NEVER ; key.h.flags =0 ;
@@ -864,7 +860,7 @@ static svc_export *exp_get_by_name(svc_c {struct svc_export *exp, key;int err; - +if (!clp)return ERR_PTR (-ENOENT );
@@ -1036,9 +1032,9 @@ exp_export(struct nfsctl_export *nxp)/* must make sure there won't be an ex_fsid clash */ if ((nxp->ex_flags &NFSEXP_FSID ) && (!IS_ERR (fsid_key =exp_get_fsid_key (clp, nxp->ex_dev))) && - fsid_key->ek_mnt && - (fsid_key->ek_mnt != nd.path.mnt || - fsid_key->ek_dentry != nd.path.dentry)) + fsid_key->ek_path.mnt && + (fsid_key->ek_path.mnt != nd.path.mnt || + fsid_key->ek_path.dentry != nd.path.dentry)) goto finish;if (!IS_ERR (exp)) {
@@ -1219,7 +1215,7 @@ static struct svc_export *exp_find(strucif (IS_ERR (ek))return ERR_PTR (PTR_ERR (ek)); - exp =exp_get_by_name (clp, ek->ek_mnt, ek->ek_dentry, reqp); + exp =exp_get_by_name (clp, ek->ek_path.mnt, ek->ek_path.dentry, reqp);cache_put (&ek->h, &svc_expkey_cache);if (IS_ERR (exp))
include/linux/nfsd/export.h +1 -2
@@ -106,8 +106,7 @@ struct svc_expkey {int ek_fsidtype;u32 ek_fsid[6 ]; -struct vfsmount * ek_mnt; -struct dentry * ek_dentry; +struct path ek_path; };#define EX_SECURE (exp) (!((exp)->ex_flags & NFSEXP_INSECURE_PORT))
Re: [PATCH 7/9] Use struct path in struct svc_expkey
Quoted 1 line · Jan Blunck
I'm embedding struct path into struct
svc_expkey.
Looks straightforward to me, thanks.
--b.
Quoted 113 lines
Signed-off-by Jan Blunck <[email protected]>--- fs/nfsd/export.c | 30 +++++++++++++----------------- include/linux/nfsd/export.h | 3 +-- 2 files changed, 14 insertions(+), 19 deletions(-)Index:
b/fs/nfsd/export.c
===================================================================fs/nfsd/export.c +13
-17@@ -63,10 +63,8 @@ static void expkey_put(struct kref *ref) struct svc_expkey *key = container_of(ref, struct svc_expkey, h.ref);if (test_bit (CACHE_VALID , &key->h.flags) && - !test_bit (CACHE_NEGATIVE , &key->h.flags)) { -dput (key->ek_dentry); -mntput (key->ek_mnt); - } + !test_bit (CACHE_NEGATIVE , &key->h.flags)) +path_put (&key->ek_path);auth_domain_put (key->ek_client);kfree (key); }@@ -169,9 +167,8 @@ static int expkey_parse(struct cache_det goto out;dprintk ("Found the path %s\n" , buf); - key.ek_mnt = nd.path.mnt; - key.ek_dentry = nd.path.dentry; - + key.ek_path = nd.path; + ek =svc_expkey_update (&key, ek);if (ek)cache_put (&ek->h, &svc_expkey_cache);@@ -206,7 +203,7 @@ static int expkey_show(struct seq_file *if (test_bit (CACHE_VALID , &h->flags) && !test_bit (CACHE_NEGATIVE , &h->flags)) {seq_printf (m," " ); -seq_path (m, ek->ek_mnt, ek->ek_dentry,"\\ \t\n" ); +seq_path (m, ek->ek_path.mnt, ek->ek_path.dentry,"\\ \t\n" ); }seq_printf (m,"\n" );return 0 ;@@ -243,8 +240,8 @@ static inline void expkey_update(struct struct svc_expkey *new = container_of(cnew, struct svc_expkey, h); struct svc_expkey *item = container_of(citem, struct svc_expkey, h); - new->ek_mnt =mntget (item->ek_mnt); - new->ek_dentry =dget (item->ek_dentry); + new->ek_path = item->ek_path; +path_get (&item->ek_path); }static struct cache_head *expkey_alloc (void )@@ -814,8 +811,7 @@ static int exp_set_key(svc_client *clp, key.ek_client = clp; key.ek_fsidtype = fsid_type;memcpy (key.ek_fsid, fsidv,key_len (fsid_type)); - key.ek_mnt = exp->ex_path.mnt; - key.ek_dentry = exp->ex_path.dentry; + key.ek_path = exp->ex_path; key.h.expiry_time =NEVER ; key.h.flags =0 ;@@ -864,7 +860,7 @@ static svc_export *exp_get_by_name(svc_c {struct svc_export *exp, key;int err; - +if (!clp)return ERR_PTR (-ENOENT );@@ -1036,9 +1032,9 @@ exp_export(struct nfsctl_export *nxp)/* must make sure there won't be an ex_fsid clash */ if ((nxp->ex_flags &NFSEXP_FSID ) && (!IS_ERR (fsid_key =exp_get_fsid_key (clp, nxp->ex_dev))) && - fsid_key->ek_mnt && - (fsid_key->ek_mnt != nd.path.mnt || - fsid_key->ek_dentry != nd.path.dentry)) + fsid_key->ek_path.mnt && + (fsid_key->ek_path.mnt != nd.path.mnt || + fsid_key->ek_path.dentry != nd.path.dentry)) goto finish;if (!IS_ERR (exp)) {@@ -1219,7 +1215,7 @@ static struct svc_export *exp_find(strucif (IS_ERR (ek))return ERR_PTR (PTR_ERR (ek)); - exp =exp_get_by_name (clp, ek->ek_mnt, ek->ek_dentry, reqp); + exp =exp_get_by_name (clp, ek->ek_path.mnt, ek->ek_path.dentry, reqp);cache_put (&ek->h, &svc_expkey_cache);if (IS_ERR (exp))Index:
b/include/linux/nfsd/export.h
===================================================================include/linux/nfsd/export.h +1
-2@@ -106,8 +106,7 @@ struct svc_expkey {int ek_fsidtype;u32 ek_fsid[6 ]; -struct vfsmount * ek_mnt; -struct dentry * ek_dentry; +struct path ek_path; };#define EX_SECURE (exp) (!((exp)->ex_flags & NFSEXP_INSECURE_PORT))
PATCH 8/9 d_path: Make seq_path() use a struct path argument
In reply to Jan Blunckseq_path() is always called with a dentry and a vfsmount from a struct path. Make seq_path() take it directly as an argument.
--- drivers/md/md.c | 3 +-- fs/namespace.c | 6 ++++-- fs/nfsd/export.c | 4 ++-- fs/proc/nommu.c | 2 +- fs/proc/task_mmu.c | 2 +- fs/seq_file.c | 7 +++---- include/linux/seq_file.h | 5 ++--- mm/mempolicy.c | 2 +- mm/swapfile.c | 2 +- 9 files changed, 16 insertions(+), 17 deletions(-)
drivers/md/md.c +1 -2
@@ -5011,8 +5011,7 @@ static int md_seq_show(struct seq_file * chunk_kb ? "KB" : "B");if (bitmap->file) {seq_printf (seq,", file: " ); -seq_path (seq, bitmap->file->f_path.mnt, - bitmap->file->f_path.dentry," \t\n" ); +seq_path (seq, &bitmap->file->f_path," \t\n" ); }seq_printf (seq,"\n" );
fs/namespace.c +4 -2
@@ -684,10 +684,11 @@ static int show_vfsmnt(struct seq_file * { 0, NULL } };struct proc_fs_info *fs_infop; +struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };mangle (m, mnt->mnt_devname ? mnt->mnt_devname :"none" );seq_putc (m,' ' ); -seq_path (m, mnt, mnt->mnt_root," \t\n\\" ); +seq_path (m, &mnt_path," \t\n\\" );seq_putc (m,' ' );mangle (m, mnt->mnt_sb->s_type->name);if (mnt->mnt_sb->s_subtype && mnt->mnt_sb->s_subtype[0 ]) {
@@ -721,6 +722,7 @@ struct seq_operations mounts_op = {static int show_vfsstat (struct seq_file *m,void *v) { struct vfsmount *mnt = list_entry(v, struct vfsmount, mnt_list); +struct path mnt_path = { .dentry = mnt->mnt_root, .mnt = mnt };int err =0 ;/* device */
@@ -732,7 +734,7 @@ static int show_vfsstat(struct seq_file/* mount point */ seq_puts (m," mounted on " ); -seq_path (m, mnt, mnt->mnt_root," \t\n\\" ); +seq_path (m, &mnt_path," \t\n\\" );seq_putc (m,' ' );/* file system type */
fs/nfsd/export.c +2 -2
@@ -203,7 +203,7 @@ static int expkey_show(struct seq_file *if (test_bit (CACHE_VALID , &h->flags) && !test_bit (CACHE_NEGATIVE , &h->flags)) {seq_printf (m," " ); -seq_path (m, ek->ek_path.mnt, ek->ek_path.dentry,"\\ \t\n" ); +seq_path (m, &ek->ek_path,"\\ \t\n" ); }seq_printf (m,"\n" );return 0 ;
@@ -649,7 +649,7 @@ static int svc_export_show(struct seq_fireturn 0 ; } exp = container_of(h, struct svc_export, h); -seq_path (m, exp->ex_path.mnt, exp->ex_path.dentry," \t\n\\" ); +seq_path (m, &exp->ex_path," \t\n\\" );seq_putc (m,'\t' );seq_escape (m, exp->ex_client->name," \t\n\\" );seq_putc (m,'(' );
fs/proc/nommu.c +1 -1
@@ -67,7 +67,7 @@ int nommu_vma_show(struct seq_file *m, sif (len <1 ) len =1 ;seq_printf (m,"%*c" , len,' ' ); -seq_path (m, file->f_path.mnt, file->f_path.dentry,"" ); +seq_path (m, &file->f_path,"" ); }seq_putc (m,'\n' );
fs/proc/task_mmu.c +1 -1
@@ -268,7 +268,7 @@ static int show_map(struct seq_file *m,*/ if (file) {pad_len_spaces (m, len); -seq_path (m, file->f_path.mnt, file->f_path.dentry,"\n" ); +seq_path (m, &file->f_path,"\n" ); }else {const char *name =arch_vma_name (vma);if (!name) {
fs/seq_file.c +3 -4
@@ -349,13 +349,12 @@ int seq_printf(struct seq_file *m, const }EXPORT_SYMBOL (seq_printf); -int seq_path (struct seq_file *m, -struct vfsmount *mnt,struct dentry *dentry, -char *esc) +int seq_path (struct seq_file *m,struct path *path,char *esc) {if (m->count < m->size) {char *s = m->buf + m->count; -char *p =d_path (dentry, mnt, s, m->size - m->count); +char *p =d_path (path->dentry, path->mnt, s, + m->size - m->count);if (!IS_ERR (p)) {while (s <= p) {char c = *p++;
include/linux/seq_file.h +2 -3
@@ -8,8 +8,7 @@struct seq_operations ;struct file ; -struct vfsmount ; -struct dentry ; +struct path ;struct inode ;struct seq_file {
@@ -43,7 +42,7 @@ int seq_puts(struct seq_file *m, const cint seq_printf (struct seq_file *,const char *, ...) __attribute__ ((format (printf,2 ,3 ))); -int seq_path (struct seq_file *,struct vfsmount *,struct dentry *,char *); +int seq_path (struct seq_file *,struct path *,char *);int single_open (struct file *,int (*)(struct seq_file *,void *),void *);int single_release (struct inode *,struct file *);
mm/mempolicy.c +1 -1
@@ -1968,7 +1968,7 @@ int show_numa_map(struct seq_file *m, voif (file) {seq_printf (m," file=" ); -seq_path (m, file->f_path.mnt, file->f_path.dentry,"\n\t= " ); +seq_path (m, &file->f_path,"\n\t= " ); }else if (vma->vm_start <= mm->brk && vma->vm_end >= mm->start_brk) {seq_printf (m," heap" ); } else if (vma->vm_start <= mm->start_stack &&
mm/swapfile.c +1 -1
@@ -1370,7 +1370,7 @@ static int swap_show(struct seq_file *sw } file = ptr->swap_file; - len =seq_path (swap, file->f_path.mnt, file->f_path.dentry," \t\n\\" ); + len =seq_path (swap, &file->f_path," \t\n\\" ); seq_printf(swap, "%*s%s\t%u\t%u\t%d\n", len < 40 ? 40 - len : 1, " ", S_ISBLK(file->f_path.dentry->d_inode->i_mode) ?
PATCH 9/9 d_path: Make d_path() use a struct path
In reply to Jan Blunckd_path() is used on a <dentry,vfsmount> pair. Lets use a struct path to reflect this.
--- arch/blackfin/kernel/traps.c | 12 +++++------- drivers/md/bitmap.c | 8 +------- drivers/usb/gadget/file_storage.c | 8 +++----- fs/compat_ioctl.c | 2 +- fs/dcache.c | 12 +++++------- fs/dcookies.c | 2 +- fs/ecryptfs/super.c | 5 ++--- fs/nfsd/export.c | 3 ++- fs/proc/base.c | 2 +- fs/seq_file.c | 4 +++- fs/sysfs/file.c | 5 ++--- fs/unionfs/super.c | 3 +-- include/linux/dcache.h | 5 +++-- kernel/audit.c | 2 +- 14 files changed, 31 insertions(+), 42 deletions(-)
arch/blackfin/kernel/traps.c +5 -7
@@ -98,15 +98,13 @@ static int printk_address(unsigned longstruct vm_area_struct *vma = vml->vma;if (address >= vma->vm_start && address < vma->vm_end) { +char _tmpbuf[256 ];char *name = p->comm;struct file *file = vma->vm_file; -if (file) { -char _tmpbuf[256 ]; - name =d_path (file->f_dentry, - file->f_vfsmnt, - _tmpbuf, -sizeof (_tmpbuf)); - } + +if (file) + name =d_path (&file->f_path, _tmpbuf, +sizeof (_tmpbuf));/* FLAT does not have its text aligned to the start of * the map while FDPIC ELF does ...
drivers/md/bitmap.c +1 -7
@@ -206,16 +206,10 @@ static void bitmap_checkfree(struct bitm/* copy the pathname of a file to a buffer */ char *file_path (struct file *file,char *buf,int count) { -struct dentry *d; -struct vfsmount *v; -if (!buf)return NULL ; - d = file->f_path.dentry; - v = file->f_path.mnt; - - buf =d_path (d, v, buf, count); + buf =d_path (&file->f_path, buf, count);return IS_ERR (buf) ?NULL : buf; }
drivers/usb/gadget/file_storage.c +3 -5
@@ -3567,8 +3567,7 @@ static ssize_t show_file(struct device *down_read (&fsg->filesem);if (backing_file_is_open (curlun)) {// Get the complete pathname - p =d_path (curlun->filp->f_path.dentry, - curlun->filp->f_path.mnt, buf,PAGE_SIZE -1 ); + p =d_path (&curlun->filp->f_path, buf,PAGE_SIZE -1 );if (IS_ERR (p)) rc =PTR_ERR (p);else {
@@ -3985,9 +3984,8 @@ static int __init fsg_bind(struct usb_gaif (backing_file_is_open (curlun)) { p =NULL ;if (pathbuf) { - p =d_path (curlun->filp->f_path.dentry, - curlun->filp->f_path.mnt, - pathbuf,PATH_MAX ); + p =d_path (&curlun->filp->f_path, + pathbuf,PATH_MAX );if (IS_ERR (p)) p =NULL ; }
fs/compat_ioctl.c +1 -1
@@ -3544,7 +3544,7 @@ static void compat_ioctl_error(struct fi/* find the name of the device. */ path = (char *)__get_free_page (GFP_KERNEL );if (path) { - fn =d_path (filp->f_path.dentry, filp->f_path.mnt, path,PAGE_SIZE ); + fn =d_path (&filp->f_path, path,PAGE_SIZE );if (IS_ERR (fn)) fn ="?" ; }
fs/dcache.c +5 -7
@@ -1831,8 +1831,7 @@ Elong:/** * d_path - return the path of a dentry -* @dentry: dentry to report -* @vfsmnt: vfsmnt to which the dentry belongs +* @path: path to report * @buf: buffer to return value in * @buflen: buffer length *
@@ -1843,8 +1842,7 @@ Elong:* * "buflen" should be positive. Caller holds the dcache_lock. */ -char *d_path (struct dentry *dentry,struct vfsmount *vfsmnt, -char *buf,int buflen) +char *d_path (struct path *path,char *buf,int buflen) {char *res;struct path root;
@@ -1856,15 +1854,15 @@ char *d_path(struct dentry *dentry, stru* user wants to identify the object in /proc/pid/fd/. The little hack * below allows us to generate a name for these objects on demand: */ -if (dentry->d_op && dentry->d_op->d_dname) -return dentry->d_op->d_dname (dentry, buf, buflen); +if (path->dentry->d_op && path->dentry->d_op->d_dname) +return path->dentry->d_op->d_dname (path->dentry, buf, buflen);read_lock (¤t->fs->lock); root = current->fs->root;path_get (¤t->fs->root);read_unlock (¤t->fs->lock);spin_lock (&dcache_lock); - res =__d_path (dentry, vfsmnt, &root, buf, buflen); + res =__d_path (path->dentry, path->mnt, &root, buf, buflen);spin_unlock (&dcache_lock);path_put (&root);return res;
fs/dcookies.c +1 -1
@@ -170,7 +170,7 @@ asmlinkage long sys_lookup_dcookie(u64 c goto out;/* FIXME: (deleted) ? */ - path =d_path (dcs->path.dentry, dcs->path.mnt, kbuf,PAGE_SIZE ); + path =d_path (&dcs->path, kbuf,PAGE_SIZE );if (IS_ERR (path)) { err =PTR_ERR (path);
fs/ecryptfs/super.c +2 -3
@@ -163,8 +163,7 @@ static void ecryptfs_clear_inode(structstatic int ecryptfs_show_options (struct seq_file *m,struct vfsmount *mnt) {struct super_block *sb = mnt->mnt_sb; -struct dentry *lower_root_dentry =ecryptfs_dentry_to_lower (sb->s_root); -struct vfsmount *lower_mnt =ecryptfs_dentry_to_lower_mnt (sb->s_root); +struct path *lower_root = &ecryptfs_dentry_to_private (sb->s_root)->lower_path;char *tmp_page;char *path;int rc =0 ;
@@ -174,7 +173,7 @@ static int ecryptfs_show_options(struct rc = -ENOMEM ; goto out; } - path =d_path (lower_root_dentry, lower_mnt, tmp_page,PAGE_SIZE ); + path =d_path (lower_root, tmp_page,PAGE_SIZE );if (IS_ERR (path)) { rc =PTR_ERR (path); goto out;
fs/nfsd/export.c +1 -1
@@ -345,7 +345,7 @@ static void svc_export_request(struct cachar *pth;qword_add (bpp, blen, exp->ex_client->name); - pth =d_path (exp->ex_path.dentry, exp->ex_path.mnt, *bpp, *blen); + pth =d_path (&exp->ex_path, *bpp, *blen);if (IS_ERR (pth)) {/* is this correct? */ (*bpp)[0 ] ='\n' ;
fs/proc/base.c +1 -1
@@ -1054,7 +1054,7 @@ static int do_proc_readlink(struct pathif (!tmp)return -ENOMEM ; - pathname =d_path (path->dentry, path->mnt, tmp,PAGE_SIZE ); + pathname =d_path (path, tmp,PAGE_SIZE ); len =PTR_ERR (pathname);if (IS_ERR (pathname)) goto out;
fs/seq_file.c +1 -2
@@ -353,8 +353,7 @@ int seq_path(struct seq_file *m, struct {if (m->count < m->size) {char *s = m->buf + m->count; -char *p =d_path (path->dentry, path->mnt, s, - m->size - m->count); +char *p =d_path (path, s, m->size - m->count);if (!IS_ERR (p)) {while (s <= p) {char c = *p++;
fs/sysfs/file.c +2 -3
@@ -355,9 +355,8 @@ static int sysfs_open_file(struct inodeint error;char *p; - p =d_path (file->f_dentry, sysfs_mount, last_sysfs_file, -sizeof (last_sysfs_file)); -if (p) + p =d_path (&file->f_path, last_sysfs_file,sizeof (last_sysfs_file)); +if (!IS_ERR (p))memmove (last_sysfs_file, p,strlen (p) +1 );/* need attr_sd for attr and ops, its parent for kobj */
fs/unionfs/super.c +1 -2
@@ -974,8 +974,7 @@ static int unionfs_show_options(struct sseq_printf (m,",dirs=" );for (bindex = bstart; bindex <= bend; bindex++) { - path =d_path (unionfs_lower_dentry_idx (sb->s_root, bindex), -unionfs_lower_mnt_idx (sb->s_root, bindex), + path =d_path (&UNIONFS_D (sb->s_root)->lower_paths[bindex], tmp_page,PAGE_SIZE );if (IS_ERR (path)) { ret =PTR_ERR (path);
include/linux/dcache.h +3 -2
@@ -10,6 +10,7 @@#include <linux/rcupdate.h> struct nameidata ; +struct path ;struct vfsmount ;/*
@@ -300,8 +301,8 @@ extern int d_validate(struct dentry *, s*/ extern char *dynamic_dname (struct dentry *,char *,int ,const char *, ...); -extern char *d_path (struct dentry *,struct vfsmount *,char *,int ); - +extern char *d_path (struct path *,char *,int ); +/* Allocation counts.. */ /**
kernel/audit.c +1 -1
@@ -1407,7 +1407,7 @@ void audit_log_d_path(struct audit_buffeaudit_log_format (ab,"<no memory>" );return ; } - p =d_path (path->dentry, path->mnt, pathname,PATH_MAX +11 ); + p =d_path (path, pathname,PATH_MAX +11 );if (IS_ERR (p)) {/* Should never happen since we send PATH_MAX */ /* FIXME: can we save some information here? */ audit_log_format (ab,"<too long>" );