diff mbox series

[4/4] fs: simplify vfs_path_lookup

Message ID 20200926092051.115577-5-hch@lst.de
State New
Headers show
Series [1/4] fs: remove the unused fs_lookup_param function | expand

Commit Message

Christoph Hellwig Sept. 26, 2020, 9:20 a.m. UTC
vfs_path_lookup is only used to lookup mount points.  So drop the dentry
parameter that is always set to mnt->mnt_root, remove the unused export
and rename the function to mount_path_lookup.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/internal.h  |  4 ++--
 fs/namei.c     | 16 +++-------------
 fs/namespace.c |  8 +++-----
 3 files changed, 8 insertions(+), 20 deletions(-)

Comments

Al Viro Sept. 26, 2020, 2:46 p.m. UTC | #1
On Sat, Sep 26, 2020 at 11:20:51AM +0200, Christoph Hellwig wrote:
> vfs_path_lookup is only used to lookup mount points.  So drop the dentry
> parameter that is always set to mnt->mnt_root, remove the unused export
> and rename the function to mount_path_lookup.

NAK.  It's a general-purpose API and simplifications are not worth bothering
with.
diff mbox series

Patch

diff --git a/fs/internal.h b/fs/internal.h
index 695e12bc285061..bbdae2648f6b7d 100644
--- a/fs/internal.h
+++ b/fs/internal.h
@@ -71,8 +71,8 @@  extern int finish_clean_context(struct fs_context *fc);
 /*
  * namei.c
  */
-extern int vfs_path_lookup(struct dentry *, struct vfsmount *,
-			   const char *, unsigned int, struct path *);
+int mount_path_lookup(struct vfsmount *mnt, const char *name,
+		      unsigned int flags, struct path *path);
 long do_rmdir(int dfd, struct filename *name);
 long do_unlinkat(int dfd, struct filename *name);
 int may_linkat(struct path *link);
diff --git a/fs/namei.c b/fs/namei.c
index 90e1cb008ae449..30f7caf5eda79b 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -2453,26 +2453,16 @@  int kern_path(const char *name, unsigned int flags, struct path *path)
 }
 EXPORT_SYMBOL(kern_path);
 
-/**
- * vfs_path_lookup - lookup a file path relative to a dentry-vfsmount pair
- * @dentry:  pointer to dentry of the base directory
- * @mnt: pointer to vfs mount of the base directory
- * @name: pointer to file name
- * @flags: lookup flags
- * @path: pointer to struct path to fill
- */
-int vfs_path_lookup(struct dentry *dentry, struct vfsmount *mnt,
-		    const char *name, unsigned int flags,
-		    struct path *path)
+int mount_path_lookup(struct vfsmount *mnt, const char *name,
+		unsigned int flags, struct path *path)
 {
 	struct nameidata nd;
 
 	nd.root.mnt = mnt;
-	nd.root.dentry = dentry;
+	nd.root.dentry = mnt->mnt_root;
 	return filename_lookup(AT_FDCWD, getname_kernel(name),
 			       flags | LOOKUP_ROOT, path, &nd);
 }
-EXPORT_SYMBOL(vfs_path_lookup);
 
 static int lookup_one_len_common(const char *name, struct dentry *base,
 				 int len, struct qstr *this)
diff --git a/fs/namespace.c b/fs/namespace.c
index bae0e95b3713a3..0e904b27f7baeb 100644
--- a/fs/namespace.c
+++ b/fs/namespace.c
@@ -3368,9 +3368,8 @@  struct dentry *mount_subtree(struct vfsmount *m, const char *name)
 	ns->mounts++;
 	list_add(&mnt->mnt_list, &ns->list);
 
-	err = vfs_path_lookup(m->mnt_root, m,
-			name, LOOKUP_FOLLOW|LOOKUP_AUTOMOUNT, &path);
-
+	err = mount_path_lookup(m, name, LOOKUP_FOLLOW | LOOKUP_AUTOMOUNT,
+				&path);
 	put_mnt_ns(ns);
 
 	if (err)
@@ -4060,8 +4059,7 @@  static int mntns_install(struct nsset *nsset, struct ns_common *ns)
 	nsproxy->mnt_ns = mnt_ns;
 
 	/* Find the root */
-	err = vfs_path_lookup(mnt_ns->root->mnt.mnt_root, &mnt_ns->root->mnt,
-				"/", LOOKUP_DOWN, &root);
+	err = mount_path_lookup(&mnt_ns->root->mnt, "/", LOOKUP_DOWN, &root);
 	if (err) {
 		/* revert to old namespace */
 		nsproxy->mnt_ns = old_mnt_ns;