fid.c (6636b6dcc3db2258cd0585b8078c1c225c4b6dde) fid.c (ff5e72ebef41068789c93b0666cebde80cc8bd8c)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * V9FS FID Management
4 *
5 * Copyright (C) 2007 by Latchesar Ionkov <lucho@ionkov.net>
6 * Copyright (C) 2005, 2006 by Eric Van Hensbergen <ericvh@gmail.com>
7 */
8

--- 14 unchanged lines hidden (view full) ---

23 * v9fs_fid_add - add a fid to a dentry
24 * @dentry: dentry that the fid is being added to
25 * @fid: fid to add
26 *
27 */
28
29static inline void __add_fid(struct dentry *dentry, struct p9_fid *fid)
30{
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * V9FS FID Management
4 *
5 * Copyright (C) 2007 by Latchesar Ionkov <lucho@ionkov.net>
6 * Copyright (C) 2005, 2006 by Eric Van Hensbergen <ericvh@gmail.com>
7 */
8

--- 14 unchanged lines hidden (view full) ---

23 * v9fs_fid_add - add a fid to a dentry
24 * @dentry: dentry that the fid is being added to
25 * @fid: fid to add
26 *
27 */
28
29static inline void __add_fid(struct dentry *dentry, struct p9_fid *fid)
30{
31 atomic_set(&fid->count, 1);
32 hlist_add_head(&fid->dlist, (struct hlist_head *)&dentry->d_fsdata);
33}
34
35void v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid)
36{
37 spin_lock(&dentry->d_lock);
38 __add_fid(dentry, fid);
39 spin_unlock(&dentry->d_lock);

--- 17 unchanged lines hidden (view full) ---

57 h = (struct hlist_head *)&inode->i_private;
58 hlist_for_each_entry(fid, h, ilist) {
59 if (uid_eq(fid->uid, uid)) {
60 ret = fid;
61 break;
62 }
63 }
64 if (ret && !IS_ERR(ret))
31 hlist_add_head(&fid->dlist, (struct hlist_head *)&dentry->d_fsdata);
32}
33
34void v9fs_fid_add(struct dentry *dentry, struct p9_fid *fid)
35{
36 spin_lock(&dentry->d_lock);
37 __add_fid(dentry, fid);
38 spin_unlock(&dentry->d_lock);

--- 17 unchanged lines hidden (view full) ---

56 h = (struct hlist_head *)&inode->i_private;
57 hlist_for_each_entry(fid, h, ilist) {
58 if (uid_eq(fid->uid, uid)) {
59 ret = fid;
60 break;
61 }
62 }
63 if (ret && !IS_ERR(ret))
65 atomic_inc(&ret->count);
64 refcount_inc(&ret->count);
66 spin_unlock(&inode->i_lock);
67 return ret;
68}
69
70/**
71 * v9fs_open_fid_add - add an open fid to an inode
72 * @dentry: inode that the fid is being added to
73 * @fid: fid to add
74 *
75 */
76
77void v9fs_open_fid_add(struct inode *inode, struct p9_fid *fid)
78{
79 spin_lock(&inode->i_lock);
65 spin_unlock(&inode->i_lock);
66 return ret;
67}
68
69/**
70 * v9fs_open_fid_add - add an open fid to an inode
71 * @dentry: inode that the fid is being added to
72 * @fid: fid to add
73 *
74 */
75
76void v9fs_open_fid_add(struct inode *inode, struct p9_fid *fid)
77{
78 spin_lock(&inode->i_lock);
80 atomic_set(&fid->count, 1);
81 hlist_add_head(&fid->ilist, (struct hlist_head *)&inode->i_private);
82 spin_unlock(&inode->i_lock);
83}
84
85
86/**
87 * v9fs_fid_find - retrieve a fid that belongs to the specified uid
88 * @dentry: dentry to look for fid in

--- 16 unchanged lines hidden (view full) ---

105
106 /* we'll recheck under lock if there's anything to look in */
107 if (!ret && dentry->d_fsdata) {
108 struct hlist_head *h = (struct hlist_head *)&dentry->d_fsdata;
109 spin_lock(&dentry->d_lock);
110 hlist_for_each_entry(fid, h, dlist) {
111 if (any || uid_eq(fid->uid, uid)) {
112 ret = fid;
79 hlist_add_head(&fid->ilist, (struct hlist_head *)&inode->i_private);
80 spin_unlock(&inode->i_lock);
81}
82
83
84/**
85 * v9fs_fid_find - retrieve a fid that belongs to the specified uid
86 * @dentry: dentry to look for fid in

--- 16 unchanged lines hidden (view full) ---

103
104 /* we'll recheck under lock if there's anything to look in */
105 if (!ret && dentry->d_fsdata) {
106 struct hlist_head *h = (struct hlist_head *)&dentry->d_fsdata;
107 spin_lock(&dentry->d_lock);
108 hlist_for_each_entry(fid, h, dlist) {
109 if (any || uid_eq(fid->uid, uid)) {
110 ret = fid;
113 atomic_inc(&ret->count);
111 refcount_inc(&ret->count);
114 break;
115 }
116 }
117 spin_unlock(&dentry->d_lock);
118 }
119
120 return ret;
121}

--- 74 unchanged lines hidden (view full) ---

196 v9ses->aname);
197 if (IS_ERR(fid))
198 return fid;
199
200 v9fs_fid_add(dentry->d_sb->s_root, fid);
201 }
202 /* If we are root ourself just return that */
203 if (dentry->d_sb->s_root == dentry) {
112 break;
113 }
114 }
115 spin_unlock(&dentry->d_lock);
116 }
117
118 return ret;
119}

--- 74 unchanged lines hidden (view full) ---

194 v9ses->aname);
195 if (IS_ERR(fid))
196 return fid;
197
198 v9fs_fid_add(dentry->d_sb->s_root, fid);
199 }
200 /* If we are root ourself just return that */
201 if (dentry->d_sb->s_root == dentry) {
204 atomic_inc(&fid->count);
202 refcount_inc(&fid->count);
205 return fid;
206 }
207 /*
208 * Do a multipath walk with attached root.
209 * When walking parent we need to make sure we
210 * don't have a parallel rename happening
211 */
212 down_read(&v9ses->rename_sem);

--- 32 unchanged lines hidden (view full) ---

245 if (!IS_ERR(fid)) {
246 spin_lock(&dentry->d_lock);
247 if (d_unhashed(dentry)) {
248 spin_unlock(&dentry->d_lock);
249 p9_client_clunk(fid);
250 fid = ERR_PTR(-ENOENT);
251 } else {
252 __add_fid(dentry, fid);
203 return fid;
204 }
205 /*
206 * Do a multipath walk with attached root.
207 * When walking parent we need to make sure we
208 * don't have a parallel rename happening
209 */
210 down_read(&v9ses->rename_sem);

--- 32 unchanged lines hidden (view full) ---

243 if (!IS_ERR(fid)) {
244 spin_lock(&dentry->d_lock);
245 if (d_unhashed(dentry)) {
246 spin_unlock(&dentry->d_lock);
247 p9_client_clunk(fid);
248 fid = ERR_PTR(-ENOENT);
249 } else {
250 __add_fid(dentry, fid);
253 atomic_inc(&fid->count);
251 refcount_inc(&fid->count);
254 spin_unlock(&dentry->d_lock);
255 }
256 }
257err_out:
258 up_read(&v9ses->rename_sem);
259 return fid;
260}
261

--- 65 unchanged lines hidden ---
252 spin_unlock(&dentry->d_lock);
253 }
254 }
255err_out:
256 up_read(&v9ses->rename_sem);
257 return fid;
258}
259

--- 65 unchanged lines hidden ---