public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/7] struct path related cleanups of d_path() code
@ 2007-10-29 12:41 Jan Blunck
  2007-10-29 12:41 ` [PATCH 1/7] One less parameter to __d_path Jan Blunck
                   ` (7 more replies)
  0 siblings, 8 replies; 15+ messages in thread
From: Jan Blunck @ 2007-10-29 12:41 UTC (permalink / raw)
  To: Linux-Kernel Mailinglist, Christoph Hellwig, Andreas Gruenbacher


Here are some more struct path cleanups. 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 structures I need to replace existing
<dentry,vfsmount> pairs and embed a struct path instead.

Andreas,
since JJ just posted the AppArmor related d_path() patches I don't include
them here too.

Comments?

Jan


>>one-less-parameter-to-__d_path.patch<<
One less parameter to __d_path

>>d_path-kerneldoc_cleanup.diff<<
d_path: kerneldoc cleanup

>>d_path-Use_struct_path_in_struct_avc_audit_data.diff<<
d_path: Use struct path in struct avc_audit_data

>>d_path-Make_proc_get_link_use_a_struct_path_argument.diff<<
d_path: Make proc_get_link() use a struct path argument

>>d_path_Make_get_dcookie_use_a_struct_path_argument.diff<<
d_path: Make get_dcookie() use a struct path argument

>>d_path-use_struct_path.diff<<
d_path: Make d_path() use a struct path

>>nfsd-svc_export_use_struct_path.diff<<
Use struct path in struct svc_export

-- 


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 1/7] One less parameter to __d_path
  2007-10-29 12:41 [PATCH 0/7] struct path related cleanups of d_path() code Jan Blunck
@ 2007-10-29 12:41 ` Jan Blunck
  2007-10-29 12:41 ` [PATCH 2/7] d_path: kerneldoc cleanup Jan Blunck
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Jan Blunck @ 2007-10-29 12:41 UTC (permalink / raw)
  To: Linux-Kernel Mailinglist, Christoph Hellwig, Andreas Gruenbacher

[-- Attachment #1: vfs/one-less-parameter-to-__d_path.patch --]
[-- Type: text/plain, Size: 1833 bytes --]

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 <agruen@suse.de>
Signed-off-by: Jan Blunck <jblunck@suse.de>
---
 fs/dcache.c |   12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

Index: b/fs/dcache.c
===================================================================
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -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 *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? */
@@ -1868,7 +1867,7 @@ char * d_path(struct dentry *dentry, str
 	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);

-- 


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 2/7] d_path: kerneldoc cleanup
  2007-10-29 12:41 [PATCH 0/7] struct path related cleanups of d_path() code Jan Blunck
  2007-10-29 12:41 ` [PATCH 1/7] One less parameter to __d_path Jan Blunck
@ 2007-10-29 12:41 ` Jan Blunck
  2007-10-29 12:41 ` [PATCH 3/7] d_path: Use struct path in struct avc_audit_data Jan Blunck
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Jan Blunck @ 2007-10-29 12:41 UTC (permalink / raw)
  To: Linux-Kernel Mailinglist, Christoph Hellwig, Andreas Gruenbacher

[-- Attachment #1: vfs/d_path-kerneldoc_cleanup.diff --]
[-- Type: text/plain, Size: 1937 bytes --]

Move and update d_path() kernel API documentation.

Signed-off-by: Jan Blunck <jblunck@suse.de>
---
 fs/dcache.c |   35 ++++++++++++++++-------------------
 1 file changed, 16 insertions(+), 19 deletions(-)

Index: b/fs/dcache.c
===================================================================
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -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;

-- 


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 3/7] d_path: Use struct path in struct avc_audit_data
  2007-10-29 12:41 [PATCH 0/7] struct path related cleanups of d_path() code Jan Blunck
  2007-10-29 12:41 ` [PATCH 1/7] One less parameter to __d_path Jan Blunck
  2007-10-29 12:41 ` [PATCH 2/7] d_path: kerneldoc cleanup Jan Blunck
@ 2007-10-29 12:41 ` Jan Blunck
  2007-10-29 12:41 ` [PATCH 4/7] d_path: Make proc_get_link() use a struct path argument Jan Blunck
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Jan Blunck @ 2007-10-29 12:41 UTC (permalink / raw)
  To: Linux-Kernel Mailinglist, Christoph Hellwig, Andreas Gruenbacher; +Cc: dwmw2

[-- Attachment #1: vfs/d_path-Use_struct_path_in_struct_avc_audit_data.diff --]
[-- Type: text/plain, Size: 10321 bytes --]

audit_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.

Signed-off-by: Jan Blunck <jblunck@suse.de>
---
 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(-)

Index: b/include/linux/audit.h
===================================================================
--- a/include/linux/audit.h
+++ b/include/linux/audit.h
@@ -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
Index: b/kernel/audit.c
===================================================================
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -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);
 }
 
 /**
Index: b/kernel/auditsc.c
===================================================================
--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -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 a
 			if ((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(&current->fs->lock);
-		context->pwd = dget(current->fs->pwd.dentry);
-		context->pwdmnt = mntget(current->fs->pwd.mnt);
+		context->pwd = current->fs->pwd;
+		path_get(&current->fs->pwd);
 		read_unlock(&current->fs->lock);
 	}
 
Index: b/security/selinux/avc.c
===================================================================
--- a/security/selinux/avc.c
+++ b/security/selinux/avc.c
@@ -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)
Index: b/security/selinux/hooks.c
===================================================================
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -1106,8 +1106,8 @@ static inline int dentry_has_perm(struct
 	struct 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 inod
 
 	AVC_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 inod
 			return 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(struct 
 		return 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 dent
 	struct 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(struct
 		return -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);
Index: b/security/selinux/include/avc.h
===================================================================
--- a/security/selinux/include/avc.h
+++ b/security/selinux/include/avc.h
@@ -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 {

-- 


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 4/7] d_path: Make proc_get_link() use a struct path argument
  2007-10-29 12:41 [PATCH 0/7] struct path related cleanups of d_path() code Jan Blunck
                   ` (2 preceding siblings ...)
  2007-10-29 12:41 ` [PATCH 3/7] d_path: Use struct path in struct avc_audit_data Jan Blunck
@ 2007-10-29 12:41 ` Jan Blunck
  2007-10-29 12:41 ` [PATCH 5/7] d_path: Make get_dcookie() " Jan Blunck
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Jan Blunck @ 2007-10-29 12:41 UTC (permalink / raw)
  To: Linux-Kernel Mailinglist, Christoph Hellwig, Andreas Gruenbacher

[-- Attachment #1: vfs/d_path-Make_proc_get_link_use_a_struct_path_argument.diff --]
[-- Type: text/plain, Size: 7657 bytes --]

proc_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.

Signed-off-by: Jan Blunck <jblunck@suse.de>
---
 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(-)

Index: b/fs/proc/base.c
===================================================================
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -153,7 +153,7 @@ static int get_nr_threads(struct task_st
 	return 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 *i
 	return 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(struct
 	if (!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 *in
 		spin_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 *in
 	return -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;
Index: b/fs/proc/internal.h
===================================================================
--- a/fs/proc/internal.h
+++ b/fs/proc/internal.h
@@ -45,7 +45,7 @@ extern int nommu_vma_show(struct seq_fil
 extern 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 *);
Index: b/fs/proc/task_mmu.c
===================================================================
--- a/fs/proc/task_mmu.c
+++ b/fs/proc/task_mmu.c
@@ -73,7 +73,7 @@ int task_statm(struct mm_struct *mm, int
 	return 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;
 	}
 
Index: b/fs/proc/task_nommu.c
===================================================================
--- a/fs/proc/task_nommu.c
+++ b/fs/proc/task_nommu.c
@@ -104,7 +104,7 @@ int task_statm(struct mm_struct *mm, int
 	return 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;
 	}
 
Index: b/include/linux/proc_fs.h
===================================================================
--- a/include/linux/proc_fs.h
+++ b/include/linux/proc_fs.h
@@ -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);
 };
 

-- 


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 5/7] d_path: Make get_dcookie() use a struct path argument
  2007-10-29 12:41 [PATCH 0/7] struct path related cleanups of d_path() code Jan Blunck
                   ` (3 preceding siblings ...)
  2007-10-29 12:41 ` [PATCH 4/7] d_path: Make proc_get_link() use a struct path argument Jan Blunck
@ 2007-10-29 12:41 ` Jan Blunck
  2007-10-29 12:41 ` [PATCH 6/7] d_path: Make d_path() use a struct path Jan Blunck
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 15+ messages in thread
From: Jan Blunck @ 2007-10-29 12:41 UTC (permalink / raw)
  To: Linux-Kernel Mailinglist, Christoph Hellwig, Andreas Gruenbacher

[-- Attachment #1: vfs/d_path_Make_get_dcookie_use_a_struct_path_argument.diff --]
[-- Type: text/plain, Size: 7169 bytes --]

get_dcookie() is always called with a dentry and a vfsmount from a struct
path. Make get_dcookie() take it directly as an argument.

Signed-off-by: Jan Blunck <jblunck@suse.de>
---
 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(-)

Index: b/arch/powerpc/oprofile/cell/spu_task_sync.c
===================================================================
--- a/arch/powerpc/oprofile/cell/spu_task_sync.c
+++ b/arch/powerpc/oprofile/cell/spu_task_sync.c
@@ -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);
Index: b/drivers/oprofile/buffer_sync.c
===================================================================
--- a/drivers/oprofile/buffer_sync.c
+++ b/drivers/oprofile/buffer_sync.c
@@ -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(st
 			continue;
 		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(stru
 			continue;
 
 		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 {
Index: b/fs/dcookies.c
===================================================================
--- a/fs/dcookies.c
+++ b/fs/dcookies.c
@@ -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);
 }
 
Index: b/include/linux/dcookies.h
===================================================================
--- a/include/linux/dcookies.h
+++ b/include/linux/dcookies.h
@@ -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 */

-- 


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 6/7] d_path: Make d_path() use a struct path
  2007-10-29 12:41 [PATCH 0/7] struct path related cleanups of d_path() code Jan Blunck
                   ` (4 preceding siblings ...)
  2007-10-29 12:41 ` [PATCH 5/7] d_path: Make get_dcookie() " Jan Blunck
@ 2007-10-29 12:41 ` Jan Blunck
  2007-11-02  6:45   ` Bharata B Rao
  2007-11-02 18:03   ` [PATCH 6/7] d_path: Make d_path() use a struct path (2nd try) Jan Blunck
  2007-10-29 12:41 ` [PATCH 7/7] Use struct path in struct svc_export Jan Blunck
  2007-11-05 10:28 ` [PATCH 0/7] struct path related cleanups of d_path() code Christoph Hellwig
  7 siblings, 2 replies; 15+ messages in thread
From: Jan Blunck @ 2007-10-29 12:41 UTC (permalink / raw)
  To: Linux-Kernel Mailinglist, Christoph Hellwig, Andreas Gruenbacher

[-- Attachment #1: vfs/d_path-use_struct_path.diff --]
[-- Type: text/plain, Size: 8772 bytes --]

d_path() is used on a <dentry,vfsmount> pair. Lets use a struct path to
reflect this.

Signed-off-by: Jan Blunck <jblunck@suse.de>
---
 drivers/md/bitmap.c               |    8 +-------
 drivers/usb/gadget/file_storage.c |    3 +--
 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 +-
 13 files changed, 24 insertions(+), 32 deletions(-)

Index: b/drivers/md/bitmap.c
===================================================================
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -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;
 }
Index: b/drivers/usb/gadget/file_storage.c
===================================================================
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -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 {
Index: b/fs/compat_ioctl.c
===================================================================
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -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 = "?";
 	}
Index: b/fs/dcache.c
===================================================================
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -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(&current->fs->lock);
 	root = current->fs->root;
 	path_get(&current->fs->root);
 	read_unlock(&current->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;
Index: b/fs/dcookies.c
===================================================================
--- a/fs/dcookies.c
+++ b/fs/dcookies.c
@@ -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);
Index: b/fs/ecryptfs/super.c
===================================================================
--- a/fs/ecryptfs/super.c
+++ b/fs/ecryptfs/super.c
@@ -163,8 +163,7 @@ static void ecryptfs_clear_inode(struct 
 static 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;
Index: b/fs/nfsd/export.c
===================================================================
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -346,10 +346,11 @@ static void svc_export_request(struct ca
 {
 	/*  client path */
 	struct svc_export *exp = container_of(h, struct svc_export, h);
+	struct path path = { .dentry = exp->ex_dentry, .mnt = exp->ex_mnt };
 	char *pth;
 
 	qword_add(bpp, blen, exp->ex_client->name);
-	pth = d_path(exp->ex_dentry, exp->ex_mnt, *bpp, *blen);
+	pth = d_path(&path, *bpp, *blen);
 	if (IS_ERR(pth)) {
 		/* is this correct? */
 		(*bpp)[0] = '\n';
Index: b/fs/proc/base.c
===================================================================
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1054,7 +1054,7 @@ static int do_proc_readlink(struct path 
 	if (!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;
Index: b/fs/seq_file.c
===================================================================
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -353,9 +353,11 @@ int seq_path(struct seq_file *m,
 	     struct vfsmount *mnt, struct dentry *dentry,
 	     char *esc)
 {
+	struct path path = { .dentry = dentry, .mnt = mnt };
+
 	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, s, m->size - m->count);
 		if (!IS_ERR(p)) {
 			while (s <= p) {
 				char c = *p++;
Index: b/fs/sysfs/file.c
===================================================================
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -355,9 +355,8 @@ static int sysfs_open_file(struct inode 
 	int 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 */
Index: b/fs/unionfs/super.c
===================================================================
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -974,8 +974,7 @@ static int unionfs_show_options(struct s
 
 	seq_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);
Index: b/include/linux/dcache.h
===================================================================
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -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.. */
 
 /**
Index: b/kernel/audit.c
===================================================================
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1407,7 +1407,7 @@ void audit_log_d_path(struct audit_buffe
 		audit_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>");

-- 


^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 7/7] Use struct path in struct svc_export
  2007-10-29 12:41 [PATCH 0/7] struct path related cleanups of d_path() code Jan Blunck
                   ` (5 preceding siblings ...)
  2007-10-29 12:41 ` [PATCH 6/7] d_path: Make d_path() use a struct path Jan Blunck
@ 2007-10-29 12:41 ` Jan Blunck
  2007-11-01 21:47   ` J. Bruce Fields
  2007-11-05 10:28 ` [PATCH 0/7] struct path related cleanups of d_path() code Christoph Hellwig
  7 siblings, 1 reply; 15+ messages in thread
From: Jan Blunck @ 2007-10-29 12:41 UTC (permalink / raw)
  To: Linux-Kernel Mailinglist, Christoph Hellwig, Andreas Gruenbacher
  Cc: bfields, neilb

[-- Attachment #1: vfs/nfsd-svc_export_use_struct_path.diff --]
[-- Type: text/plain, Size: 19726 bytes --]

I'm embedding struct path into struct svc_export.

Signed-off-by: Jan Blunck <jblunck@suse.de>
---
 fs/nfsd/export.c            |   69 +++++++++++++++++++++-----------------------
 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(+), 78 deletions(-)

Index: b/fs/nfsd/export.c
===================================================================
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -332,10 +332,9 @@ static void nfsd4_fslocs_free(struct nfs
 static 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);
 }
@@ -346,11 +345,10 @@ static void svc_export_request(struct ca
 {
 	/*  client path */
 	struct svc_export *exp = container_of(h, struct svc_export, h);
-	struct path path = { .dentry = exp->ex_dentry, .mnt = exp->ex_mnt };
 	char *pth;
 
 	qword_add(bpp, blen, exp->ex_client->name);
-	pth = d_path(&path, *bpp, *blen);
+	pth = d_path(&exp->ex_path, *bpp, *blen);
 	if (IS_ERR(pth)) {
 		/* is this correct? */
 		(*bpp)[0] = '\n';
@@ -509,7 +507,7 @@ static int svc_export_parse(struct cache
 	int an_int;
 
 	nd.path.dentry = NULL;
-	exp.ex_path = NULL;
+	exp.ex_pathname = NULL;
 
 	/* fs locations */
 	exp.ex_fslocs.locations = NULL;
@@ -548,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 */
@@ -629,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:
@@ -654,7 +652,7 @@ static int svc_export_show(struct seq_fi
 		return 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, '(');
@@ -681,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)
@@ -692,9 +690,9 @@ static void svc_export_init(struct cache
 
 	kref_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;
@@ -712,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;
@@ -756,8 +754,8 @@ svc_export_lookup(struct svc_export *exp
 	struct 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);
@@ -773,8 +771,8 @@ svc_export_update(struct svc_export *new
 	struct 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,
@@ -816,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;
 
@@ -871,8 +869,8 @@ static svc_export *exp_get_by_name(svc_c
 		return 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)
@@ -969,7 +967,7 @@ static int exp_fsid_hash(svc_client *clp
 static 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)) {
@@ -983,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)) {
@@ -1065,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;
@@ -1091,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))
@@ -1363,7 +1360,7 @@ exp_pseudoroot(struct svc_rqst *rqstp, s
 		return 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);
Index: b/fs/nfsd/nfs3proc.c
===================================================================
--- a/fs/nfsd/nfs3proc.c
+++ b/fs/nfsd/nfs3proc.c
@@ -67,7 +67,7 @@ nfsd3_proc_getattr(struct svc_rqst *rqst
 	if (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);
 
Index: b/fs/nfsd/nfs3xdr.c
===================================================================
--- a/fs/nfsd/nfs3xdr.c
+++ b/fs/nfsd/nfs3xdr.c
@@ -217,7 +217,7 @@ encode_post_op_attr(struct svc_rqst *rqs
 	        int 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;
Index: b/fs/nfsd/nfs4proc.c
===================================================================
--- a/fs/nfsd/nfs4proc.c
+++ b/fs/nfsd/nfs4proc.c
@@ -658,7 +658,7 @@ nfsd4_setattr(struct svc_rqst *rqstp, st
 			return 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;
 }
 
Index: b/fs/nfsd/nfs4xdr.c
===================================================================
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -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;
 		}
Index: b/fs/nfsd/nfsfh.c
===================================================================
--- a/fs/nfsd/nfsfh.c
+++ b/fs/nfsd/nfsfh.c
@@ -46,7 +46,7 @@ static int nfsd_acceptable(void *expv, s
 		return 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, s
 		dput(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 sv
 	struct 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;
Index: b/fs/nfsd/nfsproc.c
===================================================================
--- a/fs/nfsd/nfsproc.c
+++ b/fs/nfsd/nfsproc.c
@@ -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));
 }
Index: b/fs/nfsd/nfsxdr.c
===================================================================
--- a/fs/nfsd/nfsxdr.c
+++ b/fs/nfsd/nfsxdr.c
@@ -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);
 }
 
Index: b/fs/nfsd/vfs.c
===================================================================
--- a/fs/nfsd/vfs.c
+++ b/fs/nfsd/vfs.c
@@ -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 *rqst
 	if (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, struct
 
 		DQUOT_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, stru
 	case 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, st
 	if (!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;
Index: b/include/linux/nfsd/export.h
===================================================================
--- a/include/linux/nfsd/export.h
+++ b/include/linux/nfsd/export.h
@@ -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;

-- 


^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 7/7] Use struct path in struct svc_export
  2007-10-29 12:41 ` [PATCH 7/7] Use struct path in struct svc_export Jan Blunck
@ 2007-11-01 21:47   ` J. Bruce Fields
  0 siblings, 0 replies; 15+ messages in thread
From: J. Bruce Fields @ 2007-11-01 21:47 UTC (permalink / raw)
  To: Jan Blunck
  Cc: Linux-Kernel Mailinglist, Christoph Hellwig, Andreas Gruenbacher,
	neilb

On Mon, Oct 29, 2007 at 01:41:27PM +0100, Jan Blunck wrote:
> I'm embedding struct path into struct svc_export.

Fine by me.... (For what it's worth:

Acked-by: J. Bruce Fields <bfields@citi.umich.edu>

)

--b.

> 
> Signed-off-by: Jan Blunck <jblunck@suse.de>
> ---
>  fs/nfsd/export.c            |   69 +++++++++++++++++++++-----------------------
>  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(+), 78 deletions(-)
> 
> Index: b/fs/nfsd/export.c
> ===================================================================
> --- a/fs/nfsd/export.c
> +++ b/fs/nfsd/export.c
> @@ -332,10 +332,9 @@ static void nfsd4_fslocs_free(struct nfs
>  static 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);
>  }
> @@ -346,11 +345,10 @@ static void svc_export_request(struct ca
>  {
>  	/*  client path */
>  	struct svc_export *exp = container_of(h, struct svc_export, h);
> -	struct path path = { .dentry = exp->ex_dentry, .mnt = exp->ex_mnt };
>  	char *pth;
>  
>  	qword_add(bpp, blen, exp->ex_client->name);
> -	pth = d_path(&path, *bpp, *blen);
> +	pth = d_path(&exp->ex_path, *bpp, *blen);
>  	if (IS_ERR(pth)) {
>  		/* is this correct? */
>  		(*bpp)[0] = '\n';
> @@ -509,7 +507,7 @@ static int svc_export_parse(struct cache
>  	int an_int;
>  
>  	nd.path.dentry = NULL;
> -	exp.ex_path = NULL;
> +	exp.ex_pathname = NULL;
>  
>  	/* fs locations */
>  	exp.ex_fslocs.locations = NULL;
> @@ -548,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 */
> @@ -629,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:
> @@ -654,7 +652,7 @@ static int svc_export_show(struct seq_fi
>  		return 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, '(');
> @@ -681,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)
> @@ -692,9 +690,9 @@ static void svc_export_init(struct cache
>  
>  	kref_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;
> @@ -712,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;
> @@ -756,8 +754,8 @@ svc_export_lookup(struct svc_export *exp
>  	struct 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);
> @@ -773,8 +771,8 @@ svc_export_update(struct svc_export *new
>  	struct 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,
> @@ -816,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;
>  
> @@ -871,8 +869,8 @@ static svc_export *exp_get_by_name(svc_c
>  		return 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)
> @@ -969,7 +967,7 @@ static int exp_fsid_hash(svc_client *clp
>  static 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)) {
> @@ -983,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)) {
> @@ -1065,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;
> @@ -1091,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))
> @@ -1363,7 +1360,7 @@ exp_pseudoroot(struct svc_rqst *rqstp, s
>  		return 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);
> Index: b/fs/nfsd/nfs3proc.c
> ===================================================================
> --- a/fs/nfsd/nfs3proc.c
> +++ b/fs/nfsd/nfs3proc.c
> @@ -67,7 +67,7 @@ nfsd3_proc_getattr(struct svc_rqst *rqst
>  	if (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);
>  
> Index: b/fs/nfsd/nfs3xdr.c
> ===================================================================
> --- a/fs/nfsd/nfs3xdr.c
> +++ b/fs/nfsd/nfs3xdr.c
> @@ -217,7 +217,7 @@ encode_post_op_attr(struct svc_rqst *rqs
>  	        int 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;
> Index: b/fs/nfsd/nfs4proc.c
> ===================================================================
> --- a/fs/nfsd/nfs4proc.c
> +++ b/fs/nfsd/nfs4proc.c
> @@ -658,7 +658,7 @@ nfsd4_setattr(struct svc_rqst *rqstp, st
>  			return 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;
>  }
>  
> Index: b/fs/nfsd/nfs4xdr.c
> ===================================================================
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -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;
>  		}
> Index: b/fs/nfsd/nfsfh.c
> ===================================================================
> --- a/fs/nfsd/nfsfh.c
> +++ b/fs/nfsd/nfsfh.c
> @@ -46,7 +46,7 @@ static int nfsd_acceptable(void *expv, s
>  		return 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, s
>  		dput(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 sv
>  	struct 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;
> Index: b/fs/nfsd/nfsproc.c
> ===================================================================
> --- a/fs/nfsd/nfsproc.c
> +++ b/fs/nfsd/nfsproc.c
> @@ -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));
>  }
> Index: b/fs/nfsd/nfsxdr.c
> ===================================================================
> --- a/fs/nfsd/nfsxdr.c
> +++ b/fs/nfsd/nfsxdr.c
> @@ -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);
>  }
>  
> Index: b/fs/nfsd/vfs.c
> ===================================================================
> --- a/fs/nfsd/vfs.c
> +++ b/fs/nfsd/vfs.c
> @@ -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 *rqst
>  	if (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, struct
>  
>  		DQUOT_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, stru
>  	case 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, st
>  	if (!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;
> Index: b/include/linux/nfsd/export.h
> ===================================================================
> --- a/include/linux/nfsd/export.h
> +++ b/include/linux/nfsd/export.h
> @@ -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;
> 
> -- 
> 

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 6/7] d_path: Make d_path() use a struct path
  2007-10-29 12:41 ` [PATCH 6/7] d_path: Make d_path() use a struct path Jan Blunck
@ 2007-11-02  6:45   ` Bharata B Rao
  2007-11-02  7:03     ` Bryan Wu
  2007-11-02 17:57     ` Jan Blunck
  2007-11-02 18:03   ` [PATCH 6/7] d_path: Make d_path() use a struct path (2nd try) Jan Blunck
  1 sibling, 2 replies; 15+ messages in thread
From: Bharata B Rao @ 2007-11-02  6:45 UTC (permalink / raw)
  To: Jan Blunck
  Cc: Linux-Kernel Mailinglist, Christoph Hellwig, Andreas Gruenbacher

On 10/29/07, Jan Blunck <jblunck@suse.de> wrote:
>
>

Did you miss the d_path() caller arch/blackfin/kernel/traps.c:printk_address() ?

Regards,
Bharata.
-- 
"Men come and go but mountains remain" -- Ruskin Bond.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 6/7] d_path: Make d_path() use a struct path
  2007-11-02  6:45   ` Bharata B Rao
@ 2007-11-02  7:03     ` Bryan Wu
  2007-11-02 17:57     ` Jan Blunck
  1 sibling, 0 replies; 15+ messages in thread
From: Bryan Wu @ 2007-11-02  7:03 UTC (permalink / raw)
  To: Bharata B Rao
  Cc: Jan Blunck, Linux-Kernel Mailinglist, Christoph Hellwig,
	Andreas Gruenbacher

On 11/2/07, Bharata B Rao <bharata.rao@gmail.com> wrote:
> On 10/29/07, Jan Blunck <jblunck@suse.de> wrote:
> >
> >
>
> Did you miss the d_path() caller arch/blackfin/kernel/traps.c:printk_address() ?
>

Yes, I remember I saw that before.
Please send patch again.
-Bryan Wu

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 6/7] d_path: Make d_path() use a struct path
  2007-11-02  6:45   ` Bharata B Rao
  2007-11-02  7:03     ` Bryan Wu
@ 2007-11-02 17:57     ` Jan Blunck
  1 sibling, 0 replies; 15+ messages in thread
From: Jan Blunck @ 2007-11-02 17:57 UTC (permalink / raw)
  To: Bharata B Rao
  Cc: Linux-Kernel Mailinglist, Christoph Hellwig, Andreas Gruenbacher

On Fri, Nov 02, Bharata B Rao wrote:

> 
> Did you miss the d_path() caller arch/blackfin/kernel/traps.c:printk_address() ?
> 

Sorry, yes I missed that one.

^ permalink raw reply	[flat|nested] 15+ messages in thread

* [PATCH 6/7] d_path: Make d_path() use a struct path (2nd try)
  2007-10-29 12:41 ` [PATCH 6/7] d_path: Make d_path() use a struct path Jan Blunck
  2007-11-02  6:45   ` Bharata B Rao
@ 2007-11-02 18:03   ` Jan Blunck
  2007-11-03  3:53     ` Bryan Wu
  1 sibling, 1 reply; 15+ messages in thread
From: Jan Blunck @ 2007-11-02 18:03 UTC (permalink / raw)
  To: Linux-Kernel Mailinglist, Christoph Hellwig, Andreas Gruenbacher
  Cc: Bryan Wu, Bharata B Rao

d_path() is used on a <dentry,vfsmount> pair. Lets use a struct path to
reflect this.

Signed-off-by: Jan Blunck <jblunck@suse.de>
---
 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(-)

Index: b/arch/blackfin/kernel/traps.c
===================================================================
--- a/arch/blackfin/kernel/traps.c
+++ b/arch/blackfin/kernel/traps.c
@@ -98,15 +98,13 @@ static int printk_address(unsigned long 
 			struct 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 ...
Index: b/drivers/md/bitmap.c
===================================================================
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -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;
 }
Index: b/drivers/usb/gadget/file_storage.c
===================================================================
--- a/drivers/usb/gadget/file_storage.c
+++ b/drivers/usb/gadget/file_storage.c
@@ -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_ga
 		if (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;
 			}
Index: b/fs/compat_ioctl.c
===================================================================
--- a/fs/compat_ioctl.c
+++ b/fs/compat_ioctl.c
@@ -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 = "?";
 	}
Index: b/fs/dcache.c
===================================================================
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -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(&current->fs->lock);
 	root = current->fs->root;
 	path_get(&current->fs->root);
 	read_unlock(&current->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;
Index: b/fs/dcookies.c
===================================================================
--- a/fs/dcookies.c
+++ b/fs/dcookies.c
@@ -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);
Index: b/fs/ecryptfs/super.c
===================================================================
--- a/fs/ecryptfs/super.c
+++ b/fs/ecryptfs/super.c
@@ -163,8 +163,7 @@ static void ecryptfs_clear_inode(struct 
 static 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;
Index: b/fs/nfsd/export.c
===================================================================
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -346,10 +346,11 @@ static void svc_export_request(struct ca
 {
 	/*  client path */
 	struct svc_export *exp = container_of(h, struct svc_export, h);
+	struct path path = { .dentry = exp->ex_dentry, .mnt = exp->ex_mnt };
 	char *pth;
 
 	qword_add(bpp, blen, exp->ex_client->name);
-	pth = d_path(exp->ex_dentry, exp->ex_mnt, *bpp, *blen);
+	pth = d_path(&path, *bpp, *blen);
 	if (IS_ERR(pth)) {
 		/* is this correct? */
 		(*bpp)[0] = '\n';
Index: b/fs/proc/base.c
===================================================================
--- a/fs/proc/base.c
+++ b/fs/proc/base.c
@@ -1054,7 +1054,7 @@ static int do_proc_readlink(struct path 
 	if (!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;
Index: b/fs/seq_file.c
===================================================================
--- a/fs/seq_file.c
+++ b/fs/seq_file.c
@@ -353,9 +353,11 @@ int seq_path(struct seq_file *m,
 	     struct vfsmount *mnt, struct dentry *dentry,
 	     char *esc)
 {
+	struct path path = { .dentry = dentry, .mnt = mnt };
+
 	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, s, m->size - m->count);
 		if (!IS_ERR(p)) {
 			while (s <= p) {
 				char c = *p++;
Index: b/fs/sysfs/file.c
===================================================================
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -355,9 +355,8 @@ static int sysfs_open_file(struct inode 
 	int 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 */
Index: b/fs/unionfs/super.c
===================================================================
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -974,8 +974,7 @@ static int unionfs_show_options(struct s
 
 	seq_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);
Index: b/include/linux/dcache.h
===================================================================
--- a/include/linux/dcache.h
+++ b/include/linux/dcache.h
@@ -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.. */
 
 /**
Index: b/kernel/audit.c
===================================================================
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -1407,7 +1407,7 @@ void audit_log_d_path(struct audit_buffe
 		audit_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>");

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 6/7] d_path: Make d_path() use a struct path (2nd try)
  2007-11-02 18:03   ` [PATCH 6/7] d_path: Make d_path() use a struct path (2nd try) Jan Blunck
@ 2007-11-03  3:53     ` Bryan Wu
  0 siblings, 0 replies; 15+ messages in thread
From: Bryan Wu @ 2007-11-03  3:53 UTC (permalink / raw)
  To: Jan Blunck
  Cc: Linux-Kernel Mailinglist, Christoph Hellwig, Andreas Gruenbacher,
	Bharata B Rao

On 11/3/07, Jan Blunck <jblunck@suse.de> wrote:
> d_path() is used on a <dentry,vfsmount> pair. Lets use a struct path to
> reflect this.
>
> Signed-off-by: Jan Blunck <jblunck@suse.de>
> ---
>  arch/blackfin/kernel/traps.c      |   12 +++++-------
Thanks,Acked-by: Bryan Wu <bryan.wu@analog.com>

>  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(-)
>
> Index: b/arch/blackfin/kernel/traps.c
> ===================================================================
> --- a/arch/blackfin/kernel/traps.c
> +++ b/arch/blackfin/kernel/traps.c
> @@ -98,15 +98,13 @@ static int printk_address(unsigned long
>                         struct 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 ...
> Index: b/drivers/md/bitmap.c
> ===================================================================
> --- a/drivers/md/bitmap.c
> +++ b/drivers/md/bitmap.c
> @@ -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;
>  }
> Index: b/drivers/usb/gadget/file_storage.c
> ===================================================================
> --- a/drivers/usb/gadget/file_storage.c
> +++ b/drivers/usb/gadget/file_storage.c
> @@ -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_ga
>                 if (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;
>                         }
> Index: b/fs/compat_ioctl.c
> ===================================================================
> --- a/fs/compat_ioctl.c
> +++ b/fs/compat_ioctl.c
> @@ -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 = "?";
>         }
> Index: b/fs/dcache.c
> ===================================================================
> --- a/fs/dcache.c
> +++ b/fs/dcache.c
> @@ -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(&current->fs->lock);
>         root = current->fs->root;
>         path_get(&current->fs->root);
>         read_unlock(&current->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;
> Index: b/fs/dcookies.c
> ===================================================================
> --- a/fs/dcookies.c
> +++ b/fs/dcookies.c
> @@ -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);
> Index: b/fs/ecryptfs/super.c
> ===================================================================
> --- a/fs/ecryptfs/super.c
> +++ b/fs/ecryptfs/super.c
> @@ -163,8 +163,7 @@ static void ecryptfs_clear_inode(struct
>  static 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;
> Index: b/fs/nfsd/export.c
> ===================================================================
> --- a/fs/nfsd/export.c
> +++ b/fs/nfsd/export.c
> @@ -346,10 +346,11 @@ static void svc_export_request(struct ca
>  {
>         /*  client path */
>         struct svc_export *exp = container_of(h, struct svc_export, h);
> +       struct path path = { .dentry = exp->ex_dentry, .mnt = exp->ex_mnt };
>         char *pth;
>
>         qword_add(bpp, blen, exp->ex_client->name);
> -       pth = d_path(exp->ex_dentry, exp->ex_mnt, *bpp, *blen);
> +       pth = d_path(&path, *bpp, *blen);
>         if (IS_ERR(pth)) {
>                 /* is this correct? */
>                 (*bpp)[0] = '\n';
> Index: b/fs/proc/base.c
> ===================================================================
> --- a/fs/proc/base.c
> +++ b/fs/proc/base.c
> @@ -1054,7 +1054,7 @@ static int do_proc_readlink(struct path
>         if (!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;
> Index: b/fs/seq_file.c
> ===================================================================
> --- a/fs/seq_file.c
> +++ b/fs/seq_file.c
> @@ -353,9 +353,11 @@ int seq_path(struct seq_file *m,
>              struct vfsmount *mnt, struct dentry *dentry,
>              char *esc)
>  {
> +       struct path path = { .dentry = dentry, .mnt = mnt };
> +
>         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, s, m->size - m->count);
>                 if (!IS_ERR(p)) {
>                         while (s <= p) {
>                                 char c = *p++;
> Index: b/fs/sysfs/file.c
> ===================================================================
> --- a/fs/sysfs/file.c
> +++ b/fs/sysfs/file.c
> @@ -355,9 +355,8 @@ static int sysfs_open_file(struct inode
>         int 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 */
> Index: b/fs/unionfs/super.c
> ===================================================================
> --- a/fs/unionfs/super.c
> +++ b/fs/unionfs/super.c
> @@ -974,8 +974,7 @@ static int unionfs_show_options(struct s
>
>         seq_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);
> Index: b/include/linux/dcache.h
> ===================================================================
> --- a/include/linux/dcache.h
> +++ b/include/linux/dcache.h
> @@ -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.. */
>
>  /**
> Index: b/kernel/audit.c
> ===================================================================
> --- a/kernel/audit.c
> +++ b/kernel/audit.c
> @@ -1407,7 +1407,7 @@ void audit_log_d_path(struct audit_buffe
>                 audit_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>");
>

^ permalink raw reply	[flat|nested] 15+ messages in thread

* Re: [PATCH 0/7] struct path related cleanups of d_path() code
  2007-10-29 12:41 [PATCH 0/7] struct path related cleanups of d_path() code Jan Blunck
                   ` (6 preceding siblings ...)
  2007-10-29 12:41 ` [PATCH 7/7] Use struct path in struct svc_export Jan Blunck
@ 2007-11-05 10:28 ` Christoph Hellwig
  7 siblings, 0 replies; 15+ messages in thread
From: Christoph Hellwig @ 2007-11-05 10:28 UTC (permalink / raw)
  To: Jan Blunck
  Cc: Linux-Kernel Mailinglist, Christoph Hellwig, Andreas Gruenbacher

On Mon, Oct 29, 2007 at 01:41:20PM +0100, Jan Blunck wrote:
> 
> Here are some more struct path cleanups. 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 structures I need to replace existing
> <dentry,vfsmount> pairs and embed a struct path instead.

All these patches look good to me, but please reorder patch 6 to apply before
patch 7 in your current series.  Also it would be nice if you could also
convert seq_path to take a struct path while you're at it.


^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2007-11-05 10:29 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-29 12:41 [PATCH 0/7] struct path related cleanups of d_path() code Jan Blunck
2007-10-29 12:41 ` [PATCH 1/7] One less parameter to __d_path Jan Blunck
2007-10-29 12:41 ` [PATCH 2/7] d_path: kerneldoc cleanup Jan Blunck
2007-10-29 12:41 ` [PATCH 3/7] d_path: Use struct path in struct avc_audit_data Jan Blunck
2007-10-29 12:41 ` [PATCH 4/7] d_path: Make proc_get_link() use a struct path argument Jan Blunck
2007-10-29 12:41 ` [PATCH 5/7] d_path: Make get_dcookie() " Jan Blunck
2007-10-29 12:41 ` [PATCH 6/7] d_path: Make d_path() use a struct path Jan Blunck
2007-11-02  6:45   ` Bharata B Rao
2007-11-02  7:03     ` Bryan Wu
2007-11-02 17:57     ` Jan Blunck
2007-11-02 18:03   ` [PATCH 6/7] d_path: Make d_path() use a struct path (2nd try) Jan Blunck
2007-11-03  3:53     ` Bryan Wu
2007-10-29 12:41 ` [PATCH 7/7] Use struct path in struct svc_export Jan Blunck
2007-11-01 21:47   ` J. Bruce Fields
2007-11-05 10:28 ` [PATCH 0/7] struct path related cleanups of d_path() code Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox