Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[PATCH] switch nfsd to kern_path()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

Al Viro a63bb996 c1a2a475

+56 -58
+23 -25
fs/nfsd/export.c
··· 162 162 cache_put(&ek->h, &svc_expkey_cache); 163 163 else err = -ENOMEM; 164 164 } else { 165 - struct nameidata nd; 166 - err = path_lookup(buf, 0, &nd); 165 + err = kern_path(buf, 0, &key.ek_path); 167 166 if (err) 168 167 goto out; 169 168 170 169 dprintk("Found the path %s\n", buf); 171 - key.ek_path = nd.path; 172 170 173 171 ek = svc_expkey_update(&key, ek); 174 172 if (ek) 175 173 cache_put(&ek->h, &svc_expkey_cache); 176 174 else 177 175 err = -ENOMEM; 178 - path_put(&nd.path); 176 + path_put(&key.ek_path); 179 177 } 180 178 cache_flush(); 181 179 out: ··· 989 991 struct svc_export *exp = NULL; 990 992 struct svc_export new; 991 993 struct svc_expkey *fsid_key = NULL; 992 - struct nameidata nd; 994 + struct path path; 993 995 int err; 994 996 995 997 /* Consistency check */ ··· 1012 1014 1013 1015 1014 1016 /* Look up the dentry */ 1015 - err = path_lookup(nxp->ex_path, 0, &nd); 1017 + err = kern_path(nxp->ex_path, 0, &path); 1016 1018 if (err) 1017 1019 goto out_put_clp; 1018 1020 err = -EINVAL; 1019 1021 1020 - exp = exp_get_by_name(clp, nd.path.mnt, nd.path.dentry, NULL); 1022 + exp = exp_get_by_name(clp, path.mnt, path.dentry, NULL); 1021 1023 1022 1024 memset(&new, 0, sizeof(new)); 1023 1025 ··· 1025 1027 if ((nxp->ex_flags & NFSEXP_FSID) && 1026 1028 (!IS_ERR(fsid_key = exp_get_fsid_key(clp, nxp->ex_dev))) && 1027 1029 fsid_key->ek_path.mnt && 1028 - (fsid_key->ek_path.mnt != nd.path.mnt || 1029 - fsid_key->ek_path.dentry != nd.path.dentry)) 1030 + (fsid_key->ek_path.mnt != path.mnt || 1031 + fsid_key->ek_path.dentry != path.dentry)) 1030 1032 goto finish; 1031 1033 1032 1034 if (!IS_ERR(exp)) { ··· 1042 1044 goto finish; 1043 1045 } 1044 1046 1045 - err = check_export(nd.path.dentry->d_inode, nxp->ex_flags, NULL); 1047 + err = check_export(path.dentry->d_inode, nxp->ex_flags, NULL); 1046 1048 if (err) goto finish; 1047 1049 1048 1050 err = -ENOMEM; ··· 1055 1057 if (!new.ex_pathname) 1056 1058 goto finish; 1057 1059 new.ex_client = clp; 1058 - new.ex_path = nd.path; 1060 + new.ex_path = path; 1059 1061 new.ex_flags = nxp->ex_flags; 1060 1062 new.ex_anon_uid = nxp->ex_anon_uid; 1061 1063 new.ex_anon_gid = nxp->ex_anon_gid; ··· 1081 1083 exp_put(exp); 1082 1084 if (fsid_key && !IS_ERR(fsid_key)) 1083 1085 cache_put(&fsid_key->h, &svc_expkey_cache); 1084 - path_put(&nd.path); 1086 + path_put(&path); 1085 1087 out_put_clp: 1086 1088 auth_domain_put(clp); 1087 1089 out_unlock: ··· 1112 1114 { 1113 1115 struct auth_domain *dom; 1114 1116 svc_export *exp; 1115 - struct nameidata nd; 1117 + struct path path; 1116 1118 int err; 1117 1119 1118 1120 /* Consistency check */ ··· 1129 1131 goto out_unlock; 1130 1132 } 1131 1133 1132 - err = path_lookup(nxp->ex_path, 0, &nd); 1134 + err = kern_path(nxp->ex_path, 0, &path); 1133 1135 if (err) 1134 1136 goto out_domain; 1135 1137 1136 1138 err = -EINVAL; 1137 - exp = exp_get_by_name(dom, nd.path.mnt, nd.path.dentry, NULL); 1138 - path_put(&nd.path); 1139 + exp = exp_get_by_name(dom, path.mnt, path.dentry, NULL); 1140 + path_put(&path); 1139 1141 if (IS_ERR(exp)) 1140 1142 goto out_domain; 1141 1143 ··· 1157 1159 * since its harder to fool a kernel module than a user space program. 1158 1160 */ 1159 1161 int 1160 - exp_rootfh(svc_client *clp, char *path, struct knfsd_fh *f, int maxsize) 1162 + exp_rootfh(svc_client *clp, char *name, struct knfsd_fh *f, int maxsize) 1161 1163 { 1162 1164 struct svc_export *exp; 1163 - struct nameidata nd; 1165 + struct path path; 1164 1166 struct inode *inode; 1165 1167 struct svc_fh fh; 1166 1168 int err; 1167 1169 1168 1170 err = -EPERM; 1169 1171 /* NB: we probably ought to check that it's NUL-terminated */ 1170 - if (path_lookup(path, 0, &nd)) { 1171 - printk("nfsd: exp_rootfh path not found %s", path); 1172 + if (kern_path(name, 0, &path)) { 1173 + printk("nfsd: exp_rootfh path not found %s", name); 1172 1174 return err; 1173 1175 } 1174 - inode = nd.path.dentry->d_inode; 1176 + inode = path.dentry->d_inode; 1175 1177 1176 1178 dprintk("nfsd: exp_rootfh(%s [%p] %s:%s/%ld)\n", 1177 - path, nd.path.dentry, clp->name, 1179 + name, path.dentry, clp->name, 1178 1180 inode->i_sb->s_id, inode->i_ino); 1179 - exp = exp_parent(clp, nd.path.mnt, nd.path.dentry, NULL); 1181 + exp = exp_parent(clp, path.mnt, path.dentry, NULL); 1180 1182 if (IS_ERR(exp)) { 1181 1183 err = PTR_ERR(exp); 1182 1184 goto out; ··· 1186 1188 * fh must be initialized before calling fh_compose 1187 1189 */ 1188 1190 fh_init(&fh, maxsize); 1189 - if (fh_compose(&fh, exp, nd.path.dentry, NULL)) 1191 + if (fh_compose(&fh, exp, path.dentry, NULL)) 1190 1192 err = -EINVAL; 1191 1193 else 1192 1194 err = 0; ··· 1194 1196 fh_put(&fh); 1195 1197 exp_put(exp); 1196 1198 out: 1197 - path_put(&nd.path); 1199 + path_put(&path); 1198 1200 return err; 1199 1201 } 1200 1202
+25 -25
fs/nfsd/nfs4recover.c
··· 51 51 #define NFSDDBG_FACILITY NFSDDBG_PROC 52 52 53 53 /* Globals */ 54 - static struct nameidata rec_dir; 54 + static struct path rec_dir; 55 55 static int rec_dir_init = 0; 56 56 57 57 static void ··· 121 121 static void 122 122 nfsd4_sync_rec_dir(void) 123 123 { 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); 127 127 } 128 128 129 129 int ··· 143 143 nfs4_save_user(&uid, &gid); 144 144 145 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 149 if (IS_ERR(dentry)) { 150 150 status = PTR_ERR(dentry); 151 151 goto out_unlock; ··· 155 155 dprintk("NFSD: nfsd4_create_clid_dir: DIRECTORY EXISTS\n"); 156 156 goto out_put; 157 157 } 158 - status = mnt_want_write(rec_dir.path.mnt); 158 + status = mnt_want_write(rec_dir.mnt); 159 159 if (status) 160 160 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); 163 163 out_put: 164 164 dput(dentry); 165 165 out_unlock: 166 - mutex_unlock(&rec_dir.path.dentry->d_inode->i_mutex); 166 + mutex_unlock(&rec_dir.dentry->d_inode->i_mutex); 167 167 if (status == 0) { 168 168 clp->cl_firststate = 1; 169 169 nfsd4_sync_rec_dir(); ··· 226 226 227 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 230 status = PTR_ERR(filp); 231 231 if (IS_ERR(filp)) 232 232 goto out; ··· 291 291 292 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); 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); 297 297 if (IS_ERR(dentry)) { 298 298 status = PTR_ERR(dentry); 299 299 return status; ··· 302 302 if (!dentry->d_inode) 303 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); 306 306 out: 307 307 dput(dentry); 308 308 return status; ··· 318 318 if (!rec_dir_init || !clp->cl_firststate) 319 319 return; 320 320 321 - status = mnt_want_write(rec_dir.path.mnt); 321 + status = mnt_want_write(rec_dir.mnt); 322 322 if (status) 323 323 goto out; 324 324 clp->cl_firststate = 0; ··· 327 327 nfs4_reset_user(uid, gid); 328 328 if (status == 0) 329 329 nfsd4_sync_rec_dir(); 330 - mnt_drop_write(rec_dir.path.mnt); 330 + mnt_drop_write(rec_dir.mnt); 331 331 out: 332 332 if (status) 333 333 printk("NFSD: Failed to remove expired client state directory" ··· 357 357 358 358 if (!rec_dir_init) 359 359 return; 360 - status = mnt_want_write(rec_dir.path.mnt); 360 + status = mnt_want_write(rec_dir.mnt); 361 361 if (status) 362 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 364 if (status == 0) 365 365 nfsd4_sync_rec_dir(); 366 - mnt_drop_write(rec_dir.path.mnt); 366 + mnt_drop_write(rec_dir.mnt); 367 367 out: 368 368 if (status) 369 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 373 373 static int ··· 387 387 nfsd4_recdir_load(void) { 388 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 391 if (status) 392 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 394 return status; 395 395 } 396 396 ··· 412 412 413 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 416 &rec_dir); 417 417 if (status) 418 418 printk("NFSD: unable to find recovery directory %s\n", ··· 429 429 if (!rec_dir_init) 430 430 return; 431 431 rec_dir_init = 0; 432 - path_put(&rec_dir.path); 432 + path_put(&rec_dir); 433 433 }
+4 -4
fs/nfsd/nfs4state.c
··· 3284 3284 nfs4_reset_recoverydir(char *recdir) 3285 3285 { 3286 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 3290 if (status) 3291 3291 return status; 3292 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 3294 nfs4_set_recdir(recdir); 3295 3295 status = 0; 3296 3296 } 3297 - path_put(&nd.path); 3297 + path_put(&path); 3298 3298 return status; 3299 3299 } 3300 3300
+4 -4
fs/nfsd/nfsctl.c
··· 341 341 342 342 static ssize_t failover_unlock_fs(struct file *file, char *buf, size_t size) 343 343 { 344 - struct nameidata nd; 344 + struct path path; 345 345 char *fo_path; 346 346 int error; 347 347 ··· 356 356 if (qword_get(&buf, fo_path, size) < 0) 357 357 return -EINVAL; 358 358 359 - error = path_lookup(fo_path, 0, &nd); 359 + error = kern_path(fo_path, 0, &path); 360 360 if (error) 361 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 366 return error; 367 367 } 368 368