Skip to content

Commit c58c72d

Browse files
tyhicksmartinetd
authored andcommitted
9p: Make the path walk logic more clear about when cloning is required
Cloning during a path component walk is only needed when the old fid used for the walk operation is the root fid. Make that clear by comparing the two fids rather than using an additional variable. Link: https://lkml.kernel.org/r/20220527000003.355812-4-tyhicks@linux.microsoft.com Signed-off-by: Tyler Hicks <tyhicks@linux.microsoft.com> Signed-off-by: Dominique Martinet <asmadeus@codewreck.org>
1 parent cba83f4 commit c58c72d

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

fs/9p/fid.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry,
150150
{
151151
struct dentry *ds;
152152
const unsigned char **wnames, *uname;
153-
int i, n, l, clone, access;
153+
int i, n, l, access;
154154
struct v9fs_session_info *v9ses;
155155
struct p9_fid *fid, *root_fid, *old_fid;
156156

@@ -214,15 +214,15 @@ static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry,
214214
}
215215
fid = root_fid;
216216
old_fid = root_fid;
217-
clone = 1;
218217
i = 0;
219218
while (i < n) {
220219
l = min(n - i, P9_MAXWELEM);
221220
/*
222221
* We need to hold rename lock when doing a multipath
223222
* walk to ensure none of the patch component change
224223
*/
225-
fid = p9_client_walk(old_fid, l, &wnames[i], clone);
224+
fid = p9_client_walk(old_fid, l, &wnames[i],
225+
old_fid == root_fid /* clone */);
226226
/* non-cloning walk will return the same fid */
227227
if (fid != old_fid) {
228228
p9_client_clunk(old_fid);
@@ -233,7 +233,6 @@ static struct p9_fid *v9fs_fid_lookup_with_uid(struct dentry *dentry,
233233
goto err_out;
234234
}
235235
i += l;
236-
clone = 0;
237236
}
238237
kfree(wnames);
239238
fid_out:

0 commit comments

Comments
 (0)