Skip to content

Commit e64c390

Browse files
author
Al Viro
committed
switch rqst_exp_parent()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent 91c9fa8 commit e64c390

3 files changed

Lines changed: 23 additions & 28 deletions

File tree

‎fs/nfsd/export.c‎

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,24 +1299,19 @@ rqst_exp_find(struct svc_rqst *rqstp, int fsid_type, u32 *fsidv)
12991299
}
13001300

13011301
struct svc_export *
1302-
rqst_exp_parent(struct svc_rqst *rqstp, struct vfsmount *mnt,
1303-
struct dentry *dentry)
1302+
rqst_exp_parent(struct svc_rqst *rqstp, struct path *path)
13041303
{
1305-
struct svc_export *exp;
1306-
struct path path = {.mnt = mnt, .dentry = dentry};
1307-
1308-
dget(dentry);
1309-
exp = rqst_exp_get_by_name(rqstp, &path);
1310-
1311-
while (PTR_ERR(exp) == -ENOENT && !IS_ROOT(dentry)) {
1312-
struct dentry *parent;
1304+
struct dentry *saved = dget(path->dentry);
1305+
struct svc_export *exp = rqst_exp_get_by_name(rqstp, path);
13131306

1314-
parent = dget_parent(dentry);
1315-
dput(dentry);
1316-
dentry = parent;
1317-
exp = rqst_exp_get_by_name(rqstp, &path);
1307+
while (PTR_ERR(exp) == -ENOENT && !IS_ROOT(path->dentry)) {
1308+
struct dentry *parent = dget_parent(path->dentry);
1309+
dput(path->dentry);
1310+
path->dentry = parent;
1311+
exp = rqst_exp_get_by_name(rqstp, path);
13181312
}
1319-
dput(dentry);
1313+
dput(path->dentry);
1314+
path->dentry = saved;
13201315
return exp;
13211316
}
13221317

‎fs/nfsd/vfs.c‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -169,28 +169,29 @@ nfsd_lookup_dentry(struct svc_rqst *rqstp, struct svc_fh *fhp,
169169
/* checking mountpoint crossing is very different when stepping up */
170170
struct svc_export *exp2 = NULL;
171171
struct dentry *dp;
172-
struct vfsmount *mnt = mntget(exp->ex_path.mnt);
173-
dentry = dget(dparent);
174-
while(dentry == mnt->mnt_root && follow_up(&mnt, &dentry))
172+
struct path path = {.mnt = mntget(exp->ex_path.mnt),
173+
.dentry = dget(dparent)};
174+
175+
while (path.dentry == path.mnt->mnt_root &&
176+
follow_up(&path.mnt, &path.dentry))
175177
;
176-
dp = dget_parent(dentry);
177-
dput(dentry);
178-
dentry = dp;
178+
dp = dget_parent(path.dentry);
179+
dput(path.dentry);
180+
path.dentry = dp;
179181

180-
exp2 = rqst_exp_parent(rqstp, mnt, dentry);
182+
exp2 = rqst_exp_parent(rqstp, &path);
181183
if (PTR_ERR(exp2) == -ENOENT) {
182-
dput(dentry);
183184
dentry = dget(dparent);
184185
} else if (IS_ERR(exp2)) {
185186
host_err = PTR_ERR(exp2);
186-
dput(dentry);
187-
mntput(mnt);
187+
path_put(&path);
188188
goto out_nfserr;
189189
} else {
190+
dentry = dget(path.dentry);
190191
exp_put(exp);
191192
exp = exp2;
192193
}
193-
mntput(mnt);
194+
path_put(&path);
194195
}
195196
} else {
196197
fh_lock(fhp);

‎include/linux/nfsd/export.h‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ void exp_readunlock(void);
127127
struct svc_export * rqst_exp_get_by_name(struct svc_rqst *,
128128
struct path *);
129129
struct svc_export * rqst_exp_parent(struct svc_rqst *,
130-
struct vfsmount *mnt,
131-
struct dentry *dentry);
130+
struct path *);
132131
int exp_rootfh(struct auth_domain *,
133132
char *path, struct knfsd_fh *, int maxsize);
134133
__be32 exp_pseudoroot(struct svc_rqst *, struct svc_fh *);

0 commit comments

Comments
 (0)