aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fs/nfsd/export.c48
-rw-r--r--fs/nfsd/nfs4recover.c50
-rw-r--r--fs/nfsd/nfs4state.c8
-rw-r--r--fs/nfsd/nfsctl.c8
4 files changed, 56 insertions, 58 deletions
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index 2fa61f003fff..676201dbdf84 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -162,20 +162,18 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen)
162 cache_put(&ek->h, &svc_expkey_cache); 162 cache_put(&ek->h, &svc_expkey_cache);
163 else err = -ENOMEM; 163 else err = -ENOMEM;
164 } else { 164 } else {
165 struct nameidata nd; 165 err = kern_path(buf, 0, &key.ek_path);
166 err = path_lookup(buf, 0, &nd);
167 if (err) 166 if (err)
168 goto out; 167 goto out;
169 168
170 dprintk("Found the path %s\n", buf); 169 dprintk("Found the path %s\n", buf);
171 key.ek_path = nd.path;
172 170
173 ek = svc_expkey_update(&key, ek); 171 ek = svc_expkey_update(&key, ek);
174 if (ek) 172 if (ek)
175 cache_put(&ek->h, &svc_expkey_cache); 173 cache_put(&ek->h, &svc_expkey_cache);
176 else 174 else
177 err = -ENOMEM; 175 err = -ENOMEM;
178 path_put(&nd.path); 176 path_put(&key.ek_path);
179 } 177 }
180 cache_flush(); 178 cache_flush();
181 out: 179 out:
@@ -991,7 +989,7 @@ exp_export(struct nfsctl_export *nxp)
991 struct svc_export *exp = NULL; 989 struct svc_export *exp = NULL;
992 struct svc_export new; 990 struct svc_export new;
993 struct svc_expkey *fsid_key = NULL; 991 struct svc_expkey *fsid_key = NULL;
994 struct nameidata nd; 992 struct path path;
995 int err; 993 int err;
996 994
997 /* Consistency check */ 995 /* Consistency check */
@@ -1014,12 +1012,12 @@ exp_export(struct nfsctl_export *nxp)
1014 1012
1015 1013
1016 /* Look up the dentry */ 1014 /* Look up the dentry */
1017 err = path_lookup(nxp->ex_path, 0, &nd); 1015 err = kern_path(nxp->ex_path, 0, &path);
1018 if (err) 1016 if (err)
1019 goto out_put_clp; 1017 goto out_put_clp;
1020 err = -EINVAL; 1018 err = -EINVAL;
1021 1019
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);
1023 1021
1024 memset(&new, 0, sizeof(new)); 1022 memset(&new, 0, sizeof(new));
1025 1023
@@ -1027,8 +1025,8 @@ exp_export(struct nfsctl_export *nxp)
1027 if ((nxp->ex_flags & NFSEXP_FSID) && 1025 if ((nxp->ex_flags & NFSEXP_FSID) &&
1028 (!IS_ERR(fsid_key = exp_get_fsid_key(clp, nxp->ex_dev))) && 1026 (!IS_ERR(fsid_key = exp_get_fsid_key(clp, nxp->ex_dev))) &&
1029 fsid_key->ek_path.mnt && 1027 fsid_key->ek_path.mnt &&
1030 (fsid_key->ek_path.mnt != nd.path.mnt || 1028 (fsid_key->ek_path.mnt != path.mnt ||
1031 fsid_key->ek_path.dentry != nd.path.dentry)) 1029 fsid_key->ek_path.dentry != path.dentry))
1032 goto finish; 1030 goto finish;
1033 1031
1034 if (!IS_ERR(exp)) { 1032 if (!IS_ERR(exp)) {
@@ -1044,7 +1042,7 @@ exp_export(struct nfsctl_export *nxp)
1044 goto finish; 1042 goto finish;
1045 } 1043 }
1046 1044
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);
1048 if (err) goto finish; 1046 if (err) goto finish;
1049 1047
1050 err = -ENOMEM; 1048 err = -ENOMEM;
@@ -1057,7 +1055,7 @@ exp_export(struct nfsctl_export *nxp)
1057 if (!new.ex_pathname) 1055 if (!new.ex_pathname)
1058 goto finish; 1056 goto finish;
1059 new.ex_client = clp; 1057 new.ex_client = clp;
1060 new.ex_path = nd.path; 1058 new.ex_path = path;
1061 new.ex_flags = nxp->ex_flags; 1059 new.ex_flags = nxp->ex_flags;
1062 new.ex_anon_uid = nxp->ex_anon_uid; 1060 new.ex_anon_uid = nxp->ex_anon_uid;
1063 new.ex_anon_gid = nxp->ex_anon_gid; 1061 new.ex_anon_gid = nxp->ex_anon_gid;
@@ -1083,7 +1081,7 @@ finish:
1083 exp_put(exp); 1081 exp_put(exp);
1084 if (fsid_key && !IS_ERR(fsid_key)) 1082 if (fsid_key && !IS_ERR(fsid_key))
1085 cache_put(&fsid_key->h, &svc_expkey_cache); 1083 cache_put(&fsid_key->h, &svc_expkey_cache);
1086 path_put(&nd.path); 1084 path_put(&path);
1087out_put_clp: 1085out_put_clp:
1088 auth_domain_put(clp); 1086 auth_domain_put(clp);
1089out_unlock: 1087out_unlock:
@@ -1114,7 +1112,7 @@ exp_unexport(struct nfsctl_export *nxp)
1114{ 1112{
1115 struct auth_domain *dom; 1113 struct auth_domain *dom;
1116 svc_export *exp; 1114 svc_export *exp;
1117 struct nameidata nd; 1115 struct path path;
1118 int err; 1116 int err;
1119 1117
1120 /* Consistency check */ 1118 /* Consistency check */
@@ -1131,13 +1129,13 @@ exp_unexport(struct nfsctl_export *nxp)
1131 goto out_unlock; 1129 goto out_unlock;
1132 } 1130 }
1133 1131
1134 err = path_lookup(nxp->ex_path, 0, &nd); 1132 err = kern_path(nxp->ex_path, 0, &path);
1135 if (err) 1133 if (err)
1136 goto out_domain; 1134 goto out_domain;
1137 1135
1138 err = -EINVAL; 1136 err = -EINVAL;
1139 exp = exp_get_by_name(dom, nd.path.mnt, nd.path.dentry, NULL); 1137 exp = exp_get_by_name(dom, path.mnt, path.dentry, NULL);
1140 path_put(&nd.path); 1138 path_put(&path);
1141 if (IS_ERR(exp)) 1139 if (IS_ERR(exp))
1142 goto out_domain; 1140 goto out_domain;
1143 1141
@@ -1159,26 +1157,26 @@ out_unlock:
1159 * since its harder to fool a kernel module than a user space program. 1157 * since its harder to fool a kernel module than a user space program.
1160 */ 1158 */
1161int 1159int
1162exp_rootfh(svc_client *clp, char *path, struct knfsd_fh *f, int maxsize) 1160exp_rootfh(svc_client *clp, char *name, struct knfsd_fh *f, int maxsize)
1163{ 1161{
1164 struct svc_export *exp; 1162 struct svc_export *exp;
1165 struct nameidata nd; 1163 struct path path;
1166 struct inode *inode; 1164 struct inode *inode;
1167 struct svc_fh fh; 1165 struct svc_fh fh;
1168 int err; 1166 int err;
1169 1167
1170 err = -EPERM; 1168 err = -EPERM;
1171 /* NB: we probably ought to check that it's NUL-terminated */ 1169 /* NB: we probably ought to check that it's NUL-terminated */
1172 if (path_lookup(path, 0, &nd)) { 1170 if (kern_path(name, 0, &path)) {
1173 printk("nfsd: exp_rootfh path not found %s", path); 1171 printk("nfsd: exp_rootfh path not found %s", name);
1174 return err; 1172 return err;
1175 } 1173 }
1176 inode = nd.path.dentry->d_inode; 1174 inode = path.dentry->d_inode;
1177 1175
1178 dprintk("nfsd: exp_rootfh(%s [%p] %s:%s/%ld)\n", 1176 dprintk("nfsd: exp_rootfh(%s [%p] %s:%s/%ld)\n",
1179 path, nd.path.dentry, clp->name, 1177 name, path.dentry, clp->name,
1180 inode->i_sb->s_id, inode->i_ino); 1178 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);
1182 if (IS_ERR(exp)) { 1180 if (IS_ERR(exp)) {
1183 err = PTR_ERR(exp); 1181 err = PTR_ERR(exp);
1184 goto out; 1182 goto out;
@@ -1188,7 +1186,7 @@ exp_rootfh(svc_client *clp, char *path, struct knfsd_fh *f, int maxsize)
1188 * fh must be initialized before calling fh_compose 1186 * fh must be initialized before calling fh_compose
1189 */ 1187 */
1190 fh_init(&fh, maxsize); 1188 fh_init(&fh, maxsize);
1191 if (fh_compose(&fh, exp, nd.path.dentry, NULL)) 1189 if (fh_compose(&fh, exp, path.dentry, NULL))
1192 err = -EINVAL; 1190 err = -EINVAL;
1193 else 1191 else
1194 err = 0; 1192 err = 0;
@@ -1196,7 +1194,7 @@ exp_rootfh(svc_client *clp, char *path, struct knfsd_fh *f, int maxsize)
1196 fh_put(&fh); 1194 fh_put(&fh);
1197 exp_put(exp); 1195 exp_put(exp);
1198out: 1196out:
1199 path_put(&nd.path); 1197 path_put(&path);
1200 return err; 1198 return err;
1201} 1199}
1202 1200
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c
index 145b3c877a27..bb93946ace22 100644
--- a/fs/nfsd/nfs4recover.c
+++ b/fs/nfsd/nfs4recover.c
@@ -51,7 +51,7 @@
51#define NFSDDBG_FACILITY NFSDDBG_PROC 51#define NFSDDBG_FACILITY NFSDDBG_PROC
52 52
53/* Globals */ 53/* Globals */
54static struct nameidata rec_dir; 54static struct path rec_dir;
55static int rec_dir_init = 0; 55static int rec_dir_init = 0;
56 56
57static void 57static void
@@ -121,9 +121,9 @@ out_no_tfm:
121static void 121static void
122nfsd4_sync_rec_dir(void) 122nfsd4_sync_rec_dir(void)
123{ 123{
124 mutex_lock(&rec_dir.path.dentry->d_inode->i_mutex); 124 mutex_lock(&rec_dir.dentry->d_inode->i_mutex);
125 nfsd_sync_dir(rec_dir.path.dentry); 125 nfsd_sync_dir(rec_dir.dentry);
126 mutex_unlock(&rec_dir.path.dentry->d_inode->i_mutex); 126 mutex_unlock(&rec_dir.dentry->d_inode->i_mutex);
127} 127}
128 128
129int 129int
@@ -143,9 +143,9 @@ nfsd4_create_clid_dir(struct nfs4_client *clp)
143 nfs4_save_user(&uid, &gid); 143 nfs4_save_user(&uid, &gid);
144 144
145 /* lock the parent */ 145 /* lock the parent */
146 mutex_lock(&rec_dir.path.dentry->d_inode->i_mutex); 146 mutex_lock(&rec_dir.dentry->d_inode->i_mutex);
147 147
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);
149 if (IS_ERR(dentry)) { 149 if (IS_ERR(dentry)) {
150 status = PTR_ERR(dentry); 150 status = PTR_ERR(dentry);
151 goto out_unlock; 151 goto out_unlock;
@@ -155,15 +155,15 @@ nfsd4_create_clid_dir(struct nfs4_client *clp)
155 dprintk("NFSD: nfsd4_create_clid_dir: DIRECTORY EXISTS\n"); 155 dprintk("NFSD: nfsd4_create_clid_dir: DIRECTORY EXISTS\n");
156 goto out_put; 156 goto out_put;
157 } 157 }
158 status = mnt_want_write(rec_dir.path.mnt); 158 status = mnt_want_write(rec_dir.mnt);
159 if (status) 159 if (status)
160 goto out_put; 160 goto out_put;
161 status = vfs_mkdir(rec_dir.path.dentry->d_inode, dentry, S_IRWXU); 161 status = vfs_mkdir(rec_dir.dentry->d_inode, dentry, S_IRWXU);
162 mnt_drop_write(rec_dir.path.mnt); 162 mnt_drop_write(rec_dir.mnt);
163out_put: 163out_put:
164 dput(dentry); 164 dput(dentry);
165out_unlock: 165out_unlock:
166 mutex_unlock(&rec_dir.path.dentry->d_inode->i_mutex); 166 mutex_unlock(&rec_dir.dentry->d_inode->i_mutex);
167 if (status == 0) { 167 if (status == 0) {
168 clp->cl_firststate = 1; 168 clp->cl_firststate = 1;
169 nfsd4_sync_rec_dir(); 169 nfsd4_sync_rec_dir();
@@ -226,7 +226,7 @@ nfsd4_list_rec_dir(struct dentry *dir, recdir_func *f)
226 226
227 nfs4_save_user(&uid, &gid); 227 nfs4_save_user(&uid, &gid);
228 228
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);
230 status = PTR_ERR(filp); 230 status = PTR_ERR(filp);
231 if (IS_ERR(filp)) 231 if (IS_ERR(filp))
232 goto out; 232 goto out;
@@ -291,9 +291,9 @@ nfsd4_unlink_clid_dir(char *name, int namlen)
291 291
292 dprintk("NFSD: nfsd4_unlink_clid_dir. name %.*s\n", namlen, name); 292 dprintk("NFSD: nfsd4_unlink_clid_dir. name %.*s\n", namlen, name);
293 293
294 mutex_lock(&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.path.dentry, namlen); 295 dentry = lookup_one_len(name, rec_dir.dentry, namlen);
296 mutex_unlock(&rec_dir.path.dentry->d_inode->i_mutex); 296 mutex_unlock(&rec_dir.dentry->d_inode->i_mutex);
297 if (IS_ERR(dentry)) { 297 if (IS_ERR(dentry)) {
298 status = PTR_ERR(dentry); 298 status = PTR_ERR(dentry);
299 return status; 299 return status;
@@ -302,7 +302,7 @@ nfsd4_unlink_clid_dir(char *name, int namlen)
302 if (!dentry->d_inode) 302 if (!dentry->d_inode)
303 goto out; 303 goto out;
304 304
305 status = nfsd4_clear_clid_dir(rec_dir.path.dentry, dentry); 305 status = nfsd4_clear_clid_dir(rec_dir.dentry, dentry);
306out: 306out:
307 dput(dentry); 307 dput(dentry);
308 return status; 308 return status;
@@ -318,7 +318,7 @@ nfsd4_remove_clid_dir(struct nfs4_client *clp)
318 if (!rec_dir_init || !clp->cl_firststate) 318 if (!rec_dir_init || !clp->cl_firststate)
319 return; 319 return;
320 320
321 status = mnt_want_write(rec_dir.path.mnt); 321 status = mnt_want_write(rec_dir.mnt);
322 if (status) 322 if (status)
323 goto out; 323 goto out;
324 clp->cl_firststate = 0; 324 clp->cl_firststate = 0;
@@ -327,7 +327,7 @@ nfsd4_remove_clid_dir(struct nfs4_client *clp)
327 nfs4_reset_user(uid, gid); 327 nfs4_reset_user(uid, gid);
328 if (status == 0) 328 if (status == 0)
329 nfsd4_sync_rec_dir(); 329 nfsd4_sync_rec_dir();
330 mnt_drop_write(rec_dir.path.mnt); 330 mnt_drop_write(rec_dir.mnt);
331out: 331out:
332 if (status) 332 if (status)
333 printk("NFSD: Failed to remove expired client state directory" 333 printk("NFSD: Failed to remove expired client state directory"
@@ -357,17 +357,17 @@ nfsd4_recdir_purge_old(void) {
357 357
358 if (!rec_dir_init) 358 if (!rec_dir_init)
359 return; 359 return;
360 status = mnt_want_write(rec_dir.path.mnt); 360 status = mnt_want_write(rec_dir.mnt);
361 if (status) 361 if (status)
362 goto out; 362 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);
364 if (status == 0) 364 if (status == 0)
365 nfsd4_sync_rec_dir(); 365 nfsd4_sync_rec_dir();
366 mnt_drop_write(rec_dir.path.mnt); 366 mnt_drop_write(rec_dir.mnt);
367out: 367out:
368 if (status) 368 if (status)
369 printk("nfsd4: failed to purge old clients from recovery" 369 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);
371} 371}
372 372
373static int 373static int
@@ -387,10 +387,10 @@ int
387nfsd4_recdir_load(void) { 387nfsd4_recdir_load(void) {
388 int status; 388 int status;
389 389
390 status = nfsd4_list_rec_dir(rec_dir.path.dentry, load_recdir); 390 status = nfsd4_list_rec_dir(rec_dir.dentry, load_recdir);
391 if (status) 391 if (status)
392 printk("nfsd4: failed loading clients from recovery" 392 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);
394 return status; 394 return status;
395} 395}
396 396
@@ -412,7 +412,7 @@ nfsd4_init_recdir(char *rec_dirname)
412 412
413 nfs4_save_user(&uid, &gid); 413 nfs4_save_user(&uid, &gid);
414 414
415 status = path_lookup(rec_dirname, LOOKUP_FOLLOW | LOOKUP_DIRECTORY, 415 status = kern_path(rec_dirname, LOOKUP_FOLLOW | LOOKUP_DIRECTORY,
416 &rec_dir); 416 &rec_dir);
417 if (status) 417 if (status)
418 printk("NFSD: unable to find recovery directory %s\n", 418 printk("NFSD: unable to find recovery directory %s\n",
@@ -429,5 +429,5 @@ nfsd4_shutdown_recdir(void)
429 if (!rec_dir_init) 429 if (!rec_dir_init)
430 return; 430 return;
431 rec_dir_init = 0; 431 rec_dir_init = 0;
432 path_put(&rec_dir.path); 432 path_put(&rec_dir);
433} 433}
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index 0cc7ff5d5ab5..b0bebc552a11 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -3284,17 +3284,17 @@ int
3284nfs4_reset_recoverydir(char *recdir) 3284nfs4_reset_recoverydir(char *recdir)
3285{ 3285{
3286 int status; 3286 int status;
3287 struct nameidata nd; 3287 struct path path;
3288 3288
3289 status = path_lookup(recdir, LOOKUP_FOLLOW, &nd); 3289 status = kern_path(recdir, LOOKUP_FOLLOW, &path);
3290 if (status) 3290 if (status)
3291 return status; 3291 return status;
3292 status = -ENOTDIR; 3292 status = -ENOTDIR;
3293 if (S_ISDIR(nd.path.dentry->d_inode->i_mode)) { 3293 if (S_ISDIR(path.dentry->d_inode->i_mode)) {
3294 nfs4_set_recdir(recdir); 3294 nfs4_set_recdir(recdir);
3295 status = 0; 3295 status = 0;
3296 } 3296 }
3297 path_put(&nd.path); 3297 path_put(&path);
3298 return status; 3298 return status;
3299} 3299}
3300 3300
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
index 97543df58242..e3f9783fdcf7 100644
--- a/fs/nfsd/nfsctl.c
+++ b/fs/nfsd/nfsctl.c
@@ -341,7 +341,7 @@ static ssize_t failover_unlock_ip(struct file *file, char *buf, size_t size)
341 341
342static ssize_t failover_unlock_fs(struct file *file, char *buf, size_t size) 342static ssize_t failover_unlock_fs(struct file *file, char *buf, size_t size)
343{ 343{
344 struct nameidata nd; 344 struct path path;
345 char *fo_path; 345 char *fo_path;
346 int error; 346 int error;
347 347
@@ -356,13 +356,13 @@ static ssize_t failover_unlock_fs(struct file *file, char *buf, size_t size)
356 if (qword_get(&buf, fo_path, size) < 0) 356 if (qword_get(&buf, fo_path, size) < 0)
357 return -EINVAL; 357 return -EINVAL;
358 358
359 error = path_lookup(fo_path, 0, &nd); 359 error = kern_path(fo_path, 0, &path);
360 if (error) 360 if (error)
361 return error; 361 return error;
362 362
363 error = nlmsvc_unlock_all_by_sb(nd.path.mnt->mnt_sb); 363 error = nlmsvc_unlock_all_by_sb(path.mnt->mnt_sb);
364 364
365 path_put(&nd.path); 365 path_put(&path);
366 return error; 366 return error;
367} 367}
368 368