[PATCH 08/13] Introduce path_get()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Bharata B Rao
Date: Monday, October 22, 2007 - 12:00 am

From: Jan Blunck <jblunck@suse.de>

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

Signed-off-by: Jan Blunck <jblunck@suse.de>
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
Signed-off-by: Bharata B Rao <bharata@linux.vnet.ibm.com>
Acked-by: Christoph Hellwig <hch@lst.de>
---
 fs/namei.c            |   17 +++++++++++++++--
 fs/unionfs/super.c    |    2 +-
 include/linux/namei.h |    6 ------
 include/linux/path.h  |    1 +
 4 files changed, 17 insertions(+), 9 deletions(-)

--- a/fs/namei.c
+++ b/fs/namei.c
@@ -363,6 +363,19 @@ int deny_write_access(struct file * file
 }
 
 /**
+ * path_get - get a reference to a path
+ * @path: path to get the reference to
+ *
+ * Given a path increment the reference count to the dentry and the vfsmount.
+ */
+void path_get(struct path *path)
+{
+	mntget(path->mnt);
+	dget(path->dentry);
+}
+EXPORT_SYMBOL(path_get);
+
+/**
  * path_put - put a reference to a path
  * @path: path to put the reference to
  *
@@ -1161,8 +1174,8 @@ static int fastcall do_path_lookup(int d
 		if (retval)
 			goto fput_fail;
 
-		nd->path.mnt = mntget(file->f_path.mnt);
-		nd->path.dentry = dget(dentry);
+		nd->path = file->f_path;
+		path_get(&file->f_path);
 
 		fput_light(file, fput_needed);
 	}
--- a/fs/unionfs/super.c
+++ b/fs/unionfs/super.c
@@ -544,7 +544,7 @@ static int unionfs_remount_fs(struct sup
 	memcpy(tmp_lower_paths, UNIONFS_D(sb->s_root)->lower_paths,
 	       cur_branches * sizeof(struct path));
 	for (i = 0; i < cur_branches; i++)
-		pathget(&tmp_lower_paths[i]); /* drop refs at end of fxn */
+		path_get(&tmp_lower_paths[i]); /* drop refs at end of fxn */
 
 	/*******************************************************************
 	 * For each branch command, do path_lookup on the requested branch,
--- a/include/linux/namei.h
+++ b/include/linux/namei.h
@@ -94,10 +94,4 @@ static inline char *nd_get_link(struct n
 	return nd->saved_names[nd->depth];
 }
 
-static inline void pathget(struct path *path)
-{
-	mntget(path->mnt);
-	dget(path->dentry);
-}
-
 #endif /* _LINUX_NAMEI_H */
--- a/include/linux/path.h
+++ b/include/linux/path.h
@@ -9,6 +9,7 @@ struct path {
 	struct dentry *dentry;
 };
 
+extern void path_get(struct path *);
 extern void path_put(struct path *);
 
 #endif  /* _LINUX_PATH_H */
-
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 00/13] Use struct path in struct nameidata, Bharata B Rao, (Sun Oct 21, 11:53 pm)
[PATCH 01/13] Don't touch fs_struct in drivers, Bharata B Rao, (Sun Oct 21, 11:54 pm)
[PATCH 02/13] Don't touch fs_struct in usermodehelper, Bharata B Rao, (Sun Oct 21, 11:55 pm)
[PATCH 03/13] Remove path_release_on_umount(), Bharata B Rao, (Sun Oct 21, 11:56 pm)
[PATCH 04/13] Move struct path into its own header, Bharata B Rao, (Sun Oct 21, 11:57 pm)
[PATCH 06/13] Introduce path_put(), Bharata B Rao, (Sun Oct 21, 11:59 pm)
[PATCH 08/13] Introduce path_get(), Bharata B Rao, (Mon Oct 22, 12:00 am)
[PATCH 09/13] Use struct path in fs_struct, Bharata B Rao, (Mon Oct 22, 12:01 am)
[PATCH 10/13] Make set_fs_{root,pwd} take a struct path, Bharata B Rao, (Mon Oct 22, 12:02 am)
[PATCH 12/13] Use struct path argument in proc_get_link(), Bharata B Rao, (Mon Oct 22, 12:03 am)
Re: [PATCH 13/13] Rename {__}d_path() to {__}print_path() ..., Christoph Hellwig, (Mon Oct 22, 3:14 am)
Re: [PATCH 00/13] Use struct path in struct nameidata, Christoph Hellwig, (Mon Oct 22, 6:57 am)
Re: [PATCH 00/13] Use struct path in struct nameidata, Andrew Morton, (Mon Oct 22, 3:56 pm)
Re: [PATCH 00/13] Use struct path in struct nameidata, Bharata B Rao, (Mon Oct 22, 7:33 pm)
Re: [PATCH 00/13] Use struct path in struct nameidata, Bharata B Rao, (Tue Oct 23, 8:31 pm)