Skip to content

Commit a63bb99

Browse files
author
Al Viro
committed
[PATCH] switch nfsd to kern_path()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
1 parent c1a2a47 commit a63bb99

4 files changed

Lines changed: 56 additions & 58 deletions

File tree

‎fs/nfsd/export.c‎

Lines changed: 23 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -162,20 +162,18 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
162162
cache_put(&ek->h, &svc_expkey_cache);
163163
else err = -ENOMEM;
164164
} else {
165-
struct nameidata nd;
166-
err = path_lookup(buf, 0, &nd);
165+
err = kern_path(buf, 0, &key.ek_path);
167166
if (err)
168167
goto out;
169168

170169
dprintk("Found the path %s\n", buf);
171-
key.ek_path = nd.path;
172170

173171
ek = svc_expkey_update(&key, ek);
174172
if (ek)
175173
cache_put(&ek->h, &svc_expkey_cache);
176174
else
177175
err = -ENOMEM;
178-
path_put(&nd.path);
176+
path_put(&key.ek_path);
179177
}
180178
cache_flush();
181179
out:
@@ -991,7 +989,7 @@ exp_export(struct nfsctl_export *nxp)
991989
struct svc_export *exp = NULL;
992990
struct svc_export new;
993991
struct svc_expkey *fsid_key = NULL;
994-
struct nameidata nd;
992+
struct path path;
995993
int err;
996994

997995
/* Consistency check */
@@ -1014,21 +1012,21 @@ exp_export(struct nfsctl_export *nxp)
10141012

10151013

10161014
/* Look up the dentry */
1017-
err = path_lookup(nxp->ex_path, 0, &nd);
1015+
err = kern_path(nxp->ex_path, 0, &path);
10181016
if (err)
10191017
goto out_put_clp;
10201018
err = -EINVAL;
10211019

1022-
exp = exp_get_by_name(clp, nd.path.mnt, nd.path.dentry, NULL);
1020+
exp = exp_get_by_name(clp, path.mnt, path.dentry, NULL);
10231021

10241022
memset(&new, 0, sizeof(new));
10251023

10261024
/* must make sure there won't be an ex_fsid clash */
10271025
if ((nxp->ex_flags & NFSEXP_FSID) &&
10281026
(!IS_ERR(fsid_key = exp_get_fsid_key(clp, nxp->ex_dev))) &&
10291027
fsid_key->ek_path.mnt &&
1030-
(fsid_key->ek_path.mnt != nd.path.mnt ||
1031-
fsid_key->ek_path.dentry != nd.path.dentry))
1028+
(fsid_key->ek_path.mnt != path.mnt ||
1029+
fsid_key->ek_path.dentry != path.dentry))
10321030
goto finish;
10331031

10341032
if (!IS_ERR(exp)) {
@@ -1044,7 +1042,7 @@ exp_export(struct nfsctl_export *nxp)
10441042
goto finish;
10451043
}
10461044

1047-
err = check_export(nd.path.dentry->d_inode, nxp->ex_flags, NULL);
1045+
err = check_export(path.dentry->d_inode, nxp->ex_flags, NULL);
10481046
if (err) goto finish;
10491047

10501048
err = -ENOMEM;
@@ -1057,7 +1055,7 @@ exp_export(struct nfsctl_export *nxp)
10571055
if (!new.ex_pathname)
10581056
goto finish;
10591057
new.ex_client = clp;
1060-
new.ex_path = nd.path;
1058+
new.ex_path = path;
10611059
new.ex_flags = nxp->ex_flags;
10621060
new.ex_anon_uid = nxp->ex_anon_uid;
10631061
new.ex_anon_gid = nxp->ex_anon_gid;
@@ -1083,7 +1081,7 @@ exp_export(struct nfsctl_export *nxp)
10831081
exp_put(exp);
10841082
if (fsid_key && !IS_ERR(fsid_key))
10851083
cache_put(&fsid_key->h, &svc_expkey_cache);
1086-
path_put(&nd.path);
1084+
path_put(&path);
10871085
out_put_clp:
10881086
auth_domain_put(clp);
10891087
out_unlock:
@@ -1114,7 +1112,7 @@ exp_unexport(struct nfsctl_export *nxp)
11141112
{
11151113
struct auth_domain *dom;
11161114
svc_export *exp;
1117-
struct nameidata nd;
1115+
struct path path;
11181116
int err;
11191117

11201118
/* Consistency check */
@@ -1131,13 +1129,13 @@ exp_unexport(struct nfsctl_export *nxp)
11311129
goto out_unlock;
11321130
}
11331131

1134-
err = path_lookup(nxp->ex_path, 0, &nd);
1132+
err = kern_path(nxp->ex_path, 0, &path);
11351133
if (err)
11361134
goto out_domain;
11371135

11381136
err = -EINVAL;
1139-
exp = exp_get_by_name(dom, nd.path.mnt, nd.path.dentry, NULL);
1140-
path_put(&nd.path);
1137+
exp = exp_get_by_name(dom, path.mnt, path.dentry, NULL);
1138+
path_put(&path);
11411139
if (IS_ERR(exp))
11421140
goto out_domain;
11431141

@@ -1159,26 +1157,26 @@ exp_unexport(struct nfsctl_export *nxp)
11591157
* since its harder to fool a kernel module than a user space program.
11601158
*/
11611159
int
1162-
exp_rootfh(svc_client *clp, char *path, struct knfsd_fh *f, int maxsize)
1160+
exp_rootfh(svc_client *clp, char *name, struct knfsd_fh *f, int maxsize)
11631161
{
11641162
struct svc_export *exp;
1165-
struct nameidata nd;
1163+
struct path path;
11661164
struct inode *inode;
11671165
struct svc_fh fh;
11681166
int err;
11691167

11701168
err = -EPERM;
11711169
/* NB: we probably ought to check that it's NUL-terminated */
1172-
if (path_lookup(path, 0, &nd)) {
1173-
printk("nfsd: exp_rootfh path not found %s", path);
1170+
if (kern_path(name, 0, &path)) {
1171+
printk("nfsd: exp_rootfh path not found %s", name);
11741172
return err;
11751173
}
1176-
inode = nd.path.dentry->d_inode;
1174+
inode = path.dentry->d_inode;
11771175

11781176
dprintk("nfsd: exp_rootfh(%s [%p] %s:%s/%ld)\n",
1179-
path, nd.path.dentry, clp->name,
1177+
name, path.dentry, clp->name,
11801178
inode->i_sb->s_id, inode->i_ino);
1181-
exp = exp_parent(clp, nd.path.mnt, nd.path.dentry, NULL);
1179+
exp = exp_parent(clp, path.mnt, path.dentry, NULL);
11821180
if (IS_ERR(exp)) {
11831181
err = PTR_ERR(exp);
11841182
goto out;
@@ -1188,15 +1186,15 @@ exp_rootfh(svc_client *clp, char *path, struct knfsd_fh *f, int maxsize)
11881186
* fh must be initialized before calling fh_compose
11891187
*/
11901188
fh_init(&fh, maxsize);
1191-
if (fh_compose(&fh, exp, nd.path.dentry, NULL))
1189+
if (fh_compose(&fh, exp, path.dentry, NULL))
11921190
err = -EINVAL;
11931191
else
11941192
err = 0;
11951193
memcpy(f, &fh.fh_handle, sizeof(struct knfsd_fh));
11961194
fh_put(&fh);
11971195
exp_put(exp);
11981196
out:
1199-
path_put(&nd.path);
1197+
path_put(&path);
12001198
return err;
12011199
}
12021200

‎fs/nfsd/nfs4recover.c‎

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
#define NFSDDBG_FACILITY NFSDDBG_PROC
5252

5353
/* Globals */
54-
static struct nameidata rec_dir;
54+
static struct path rec_dir;
5555
static int rec_dir_init = 0;
5656

5757
static void
@@ -121,9 +121,9 @@ nfs4_make_rec_clidname(char *dname, struct xdr_netobj *clname)
121121
static void
122122
nfsd4_sync_rec_dir(void)
123123
{
124-
mutex_lock(&rec_dir.path.dentry->d_inode->i_mutex);
125-
nfsd_sync_dir(rec_dir.path.dentry);
126-
mutex_unlock(&rec_dir.path.dentry->d_inode->i_mutex);
124+
mutex_lock(&rec_dir.dentry->d_inode->i_mutex);
125+
nfsd_sync_dir(rec_dir.dentry);
126+
mutex_unlock(&rec_dir.dentry->d_inode->i_mutex);
127127
}
128128

129129
int
@@ -143,9 +143,9 @@ nfsd4_create_clid_dir(struct nfs4_client *clp)
143143
nfs4_save_user(&uid, &gid);
144144

145145
/* lock the parent */
146-
mutex_lock(&rec_dir.path.dentry->d_inode->i_mutex);
146+
mutex_lock(&rec_dir.dentry->d_inode->i_mutex);
147147

148-
dentry = lookup_one_len(dname, rec_dir.path.dentry, HEXDIR_LEN-1);
148+
dentry = lookup_one_len(dname, rec_dir.dentry, HEXDIR_LEN-1);
149149
if (IS_ERR(dentry)) {
150150
status = PTR_ERR(dentry);
151151
goto out_unlock;
@@ -155,15 +155,15 @@ nfsd4_create_clid_dir(struct nfs4_client *clp)
155155
dprintk("NFSD: nfsd4_create_clid_dir: DIRECTORY EXISTS\n");
156156
goto out_put;
157157
}
158-
status = mnt_want_write(rec_dir.path.mnt);
158+
status = mnt_want_write(rec_dir.mnt);
159159
if (status)
160160
goto out_put;
161-
status = vfs_mkdir(rec_dir.path.dentry->d_inode, dentry, S_IRWXU);
162-
mnt_drop_write(rec_dir.path.mnt);
161+
status = vfs_mkdir(rec_dir.dentry->d_inode, dentry, S_IRWXU);
162+
mnt_drop_write(rec_dir.mnt);
163163
out_put:
164164
dput(dentry);
165165
out_unlock:
166-
mutex_unlock(&rec_dir.path.dentry->d_inode->i_mutex);
166+
mutex_unlock(&rec_dir.dentry->d_inode->i_mutex);
167167
if (status == 0) {
168168
clp->cl_firststate = 1;
169169
nfsd4_sync_rec_dir();
@@ -226,7 +226,7 @@ nfsd4_list_rec_dir(struct dentry *dir, recdir_func *f)
226226

227227
nfs4_save_user(&uid, &gid);
228228

229-
filp = dentry_open(dget(dir), mntget(rec_dir.path.mnt), O_RDONLY);
229+
filp = dentry_open(dget(dir), mntget(rec_dir.mnt), O_RDONLY);
230230
status = PTR_ERR(filp);
231231
if (IS_ERR(filp))
232232
goto out;
@@ -291,9 +291,9 @@ nfsd4_unlink_clid_dir(char *name, int namlen)
291291

292292
dprintk("NFSD: nfsd4_unlink_clid_dir. name %.*s\n", namlen, name);
293293

294-
mutex_lock(&rec_dir.path.dentry->d_inode->i_mutex);
295-
dentry = lookup_one_len(name, rec_dir.path.dentry, namlen);
296-
mutex_unlock(&rec_dir.path.dentry->d_inode->i_mutex);
294+
mutex_lock(&rec_dir.dentry->d_inode->i_mutex);
295+
dentry = lookup_one_len(name, rec_dir.dentry, namlen);
296+
mutex_unlock(&rec_dir.dentry->d_inode->i_mutex);
297297
if (IS_ERR(dentry)) {
298298
status = PTR_ERR(dentry);
299299
return status;
@@ -302,7 +302,7 @@ nfsd4_unlink_clid_dir(char *name, int namlen)
302302
if (!dentry->d_inode)
303303
goto out;
304304

305-
status = nfsd4_clear_clid_dir(rec_dir.path.dentry, dentry);
305+
status = nfsd4_clear_clid_dir(rec_dir.dentry, dentry);
306306
out:
307307
dput(dentry);
308308
return status;
@@ -318,7 +318,7 @@ nfsd4_remove_clid_dir(struct nfs4_client *clp)
318318
if (!rec_dir_init || !clp->cl_firststate)
319319
return;
320320

321-
status = mnt_want_write(rec_dir.path.mnt);
321+
status = mnt_want_write(rec_dir.mnt);
322322
if (status)
323323
goto out;
324324
clp->cl_firststate = 0;
@@ -327,7 +327,7 @@ nfsd4_remove_clid_dir(struct nfs4_client *clp)
327327
nfs4_reset_user(uid, gid);
328328
if (status == 0)
329329
nfsd4_sync_rec_dir();
330-
mnt_drop_write(rec_dir.path.mnt);
330+
mnt_drop_write(rec_dir.mnt);
331331
out:
332332
if (status)
333333
printk("NFSD: Failed to remove expired client state directory"
@@ -357,17 +357,17 @@ nfsd4_recdir_purge_old(void) {
357357

358358
if (!rec_dir_init)
359359
return;
360-
status = mnt_want_write(rec_dir.path.mnt);
360+
status = mnt_want_write(rec_dir.mnt);
361361
if (status)
362362
goto out;
363-
status = nfsd4_list_rec_dir(rec_dir.path.dentry, purge_old);
363+
status = nfsd4_list_rec_dir(rec_dir.dentry, purge_old);
364364
if (status == 0)
365365
nfsd4_sync_rec_dir();
366-
mnt_drop_write(rec_dir.path.mnt);
366+
mnt_drop_write(rec_dir.mnt);
367367
out:
368368
if (status)
369369
printk("nfsd4: failed to purge old clients from recovery"
370-
" directory %s\n", rec_dir.path.dentry->d_name.name);
370+
" directory %s\n", rec_dir.dentry->d_name.name);
371371
}
372372

373373
static int
@@ -387,10 +387,10 @@ int
387387
nfsd4_recdir_load(void) {
388388
int status;
389389

390-
status = nfsd4_list_rec_dir(rec_dir.path.dentry, load_recdir);
390+
status = nfsd4_list_rec_dir(rec_dir.dentry, load_recdir);
391391
if (status)
392392
printk("nfsd4: failed loading clients from recovery"
393-
" directory %s\n", rec_dir.path.dentry->d_name.name);
393+
" directory %s\n", rec_dir.dentry->d_name.name);
394394
return status;
395395
}
396396

@@ -412,7 +412,7 @@ nfsd4_init_recdir(char *rec_dirname)
412412

413413
nfs4_save_user(&uid, &gid);
414414

415-
status = path_lookup(rec_dirname, LOOKUP_FOLLOW | LOOKUP_DIRECTORY,
415+
status = kern_path(rec_dirname, LOOKUP_FOLLOW | LOOKUP_DIRECTORY,
416416
&rec_dir);
417417
if (status)
418418
printk("NFSD: unable to find recovery directory %s\n",
@@ -429,5 +429,5 @@ nfsd4_shutdown_recdir(void)
429429
if (!rec_dir_init)
430430
return;
431431
rec_dir_init = 0;
432-
path_put(&rec_dir.path);
432+
path_put(&rec_dir);
433433
}

‎fs/nfsd/nfs4state.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3284,17 +3284,17 @@ int
32843284
nfs4_reset_recoverydir(char *recdir)
32853285
{
32863286
int status;
3287-
struct nameidata nd;
3287+
struct path path;
32883288

3289-
status = path_lookup(recdir, LOOKUP_FOLLOW, &nd);
3289+
status = kern_path(recdir, LOOKUP_FOLLOW, &path);
32903290
if (status)
32913291
return status;
32923292
status = -ENOTDIR;
3293-
if (S_ISDIR(nd.path.dentry->d_inode->i_mode)) {
3293+
if (S_ISDIR(path.dentry->d_inode->i_mode)) {
32943294
nfs4_set_recdir(recdir);
32953295
status = 0;
32963296
}
3297-
path_put(&nd.path);
3297+
path_put(&path);
32983298
return status;
32993299
}
33003300

‎fs/nfsd/nfsctl.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size)
341341

342342
static ssize_t failover_unlock_fs(struct file *file, char *buf, size_t size)
343343
{
344-
struct nameidata nd;
344+
struct path path;
345345
char *fo_path;
346346
int error;
347347

@@ -356,13 +356,13 @@ static ssize_t failover_unlock_fs(struct file *file, char *buf, size_t size)
356356
if (qword_get(&buf, fo_path, size) < 0)
357357
return -EINVAL;
358358

359-
error = path_lookup(fo_path, 0, &nd);
359+
error = kern_path(fo_path, 0, &path);
360360
if (error)
361361
return error;
362362

363-
error = nlmsvc_unlock_all_by_sb(nd.path.mnt->mnt_sb);
363+
error = nlmsvc_unlock_all_by_sb(path.mnt->mnt_sb);
364364

365-
path_put(&nd.path);
365+
path_put(&path);
366366
return error;
367367
}
368368

0 commit comments

Comments
 (0)