Commit 213b067c authored by Eric W. Biederman's avatar Eric W. Biederman

nsfs: Simplify __ns_get_path

Move mntget from the very beginning of __ns_get_path to
the success path of __ns_get_path, and remove the mntget
calls.

This removes the possibility that there will be a mntget/mntput
pair of __ns_get_path has to retry, and generally simplifies the code.
Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
parent 78725596
...@@ -51,7 +51,7 @@ static void nsfs_evict(struct inode *inode) ...@@ -51,7 +51,7 @@ static void nsfs_evict(struct inode *inode)
static void *__ns_get_path(struct path *path, struct ns_common *ns) static void *__ns_get_path(struct path *path, struct ns_common *ns)
{ {
struct vfsmount *mnt = mntget(nsfs_mnt); struct vfsmount *mnt = nsfs_mnt;
struct qstr qname = { .name = "", }; struct qstr qname = { .name = "", };
struct dentry *dentry; struct dentry *dentry;
struct inode *inode; struct inode *inode;
...@@ -67,7 +67,7 @@ static void *__ns_get_path(struct path *path, struct ns_common *ns) ...@@ -67,7 +67,7 @@ static void *__ns_get_path(struct path *path, struct ns_common *ns)
rcu_read_unlock(); rcu_read_unlock();
ns->ops->put(ns); ns->ops->put(ns);
got_it: got_it:
path->mnt = mnt; path->mnt = mntget(mnt);
path->dentry = dentry; path->dentry = dentry;
return NULL; return NULL;
slow: slow:
...@@ -75,7 +75,6 @@ static void *__ns_get_path(struct path *path, struct ns_common *ns) ...@@ -75,7 +75,6 @@ static void *__ns_get_path(struct path *path, struct ns_common *ns)
inode = new_inode_pseudo(mnt->mnt_sb); inode = new_inode_pseudo(mnt->mnt_sb);
if (!inode) { if (!inode) {
ns->ops->put(ns); ns->ops->put(ns);
mntput(mnt);
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
inode->i_ino = ns->inum; inode->i_ino = ns->inum;
...@@ -88,7 +87,6 @@ static void *__ns_get_path(struct path *path, struct ns_common *ns) ...@@ -88,7 +87,6 @@ static void *__ns_get_path(struct path *path, struct ns_common *ns)
dentry = d_alloc_pseudo(mnt->mnt_sb, &qname); dentry = d_alloc_pseudo(mnt->mnt_sb, &qname);
if (!dentry) { if (!dentry) {
iput(inode); iput(inode);
mntput(mnt);
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
} }
d_instantiate(dentry, inode); d_instantiate(dentry, inode);
...@@ -97,7 +95,6 @@ static void *__ns_get_path(struct path *path, struct ns_common *ns) ...@@ -97,7 +95,6 @@ static void *__ns_get_path(struct path *path, struct ns_common *ns)
if (d) { if (d) {
d_delete(dentry); /* make sure ->d_prune() does nothing */ d_delete(dentry); /* make sure ->d_prune() does nothing */
dput(dentry); dput(dentry);
mntput(mnt);
cpu_relax(); cpu_relax();
return ERR_PTR(-EAGAIN); return ERR_PTR(-EAGAIN);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment