summaryrefslogtreecommitdiffstats
path: root/fs/9p/fid.c
diff options
context:
space:
mode:
authorDominique Martinet <asmadeus@codewreck.org>2022-06-12 09:05:39 +0200
committerDominique Martinet <dominique.martinet@atmark-techno.com>2022-07-02 11:52:21 +0200
commitdafbe689736f62c696ac64809b17bdc752cfbe76 (patch)
tree8a4774deab90c8ae0255de0eed33f57c86433354 /fs/9p/fid.c
parent9p fid refcount: add a 9p_fid_ref tracepoint (diff)
downloadlinux-dafbe689736f62c696ac64809b17bdc752cfbe76.tar.xz
linux-dafbe689736f62c696ac64809b17bdc752cfbe76.zip
9p fid refcount: cleanup p9_fid_put calls
Simplify p9_fid_put cleanup path in many 9p functions since the function is noop on null or error fids. Also make the *_add_fid() helpers "steal" the fid by nulling its pointer, so put after them will be noop. This should lead to no change of behaviour Link: https://lkml.kernel.org/r/20220612085330.1451496-7-asmadeus@codewreck.org Reviewed-by: Tyler Hicks <tyhicks@linux.microsoft.com> Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
Diffstat (limited to 'fs/9p/fid.c')
-rw-r--r--fs/9p/fid.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/fs/9p/fid.c b/fs/9p/fid.c
index d792499349c4..289a85eae2ae 100644
--- a/fs/9p/fid.c
+++ b/fs/9p/fid.c
@@ -31,11 +31,15 @@ static inline void __add_fid(struct dentry *dentry, struct p9_fid *fid)
* @fid: fid to add
*
*/
-void v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid)
+void v9fs_fid_add(struct dentry *dentry, struct p9_fid **pfid)
{
+ struct p9_fid *fid = *pfid;
+
spin_lock(&dentry->d_lock);
__add_fid(dentry, fid);
spin_unlock(&dentry->d_lock);
+
+ *pfid = NULL;
}
/**
@@ -72,11 +76,15 @@ static struct p9_fid *v9fs_fid_find_inode(struct inode *inode, kuid_t uid)
*
*/
-void v9fs_open_fid_add(struct inode *inode, struct p9_fid *fid)
+void v9fs_open_fid_add(struct inode *inode, struct p9_fid **pfid)
{
+ struct p9_fid *fid = *pfid;
+
spin_lock(&inode->i_lock);
hlist_add_head(&fid->ilist, (struct hlist_head *)&inode->i_private);
spin_unlock(&inode->i_lock);
+
+ *pfid = NULL;
}
@@ -189,13 +197,13 @@ static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry,
else
uname = v9ses->uname;
- root_fid = p9_client_attach(v9ses->clnt, NULL, uname, uid,
- v9ses->aname);
- if (IS_ERR(root_fid))
- return root_fid;
+ fid = p9_client_attach(v9ses->clnt, NULL, uname, uid,
+ v9ses->aname);
+ if (IS_ERR(fid))
+ return fid;
- p9_fid_get(root_fid);
- v9fs_fid_add(dentry->d_sb->s_root, root_fid);
+ root_fid = p9_fid_get(fid);
+ v9fs_fid_add(dentry->d_sb->s_root, &fid);
}
/* If we are root ourself just return that */
if (dentry->d_sb->s_root == dentry)