diff options
author | Jan Blunck <jblunck@suse.de> | 2008-02-14 22:34:32 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-15 00:13:33 -0500 |
commit | 4ac9137858e08a19f29feac4e1f4df7c268b0ba5 (patch) | |
tree | f5b5d84fd12fcc2b0ba0e7ce1a79ff381ad8f5dd /fs/nfsd | |
parent | c5e725f33b733a77de622e91b6ba5645fcf070be (diff) |
Embed a struct path into struct nameidata instead of nd->{dentry,mnt}
This is the central patch of a cleanup series. In most cases there is no good
reason why someone would want to use a dentry for itself. This series reflects
that fact and embeds a struct path into nameidata.
Together with the other patches of this series
- it enforced the correct order of getting/releasing the reference count on
<dentry,vfsmount> pairs
- it prepares the VFS for stacking support since it is essential to have a
struct path in every place where the stack can be traversed
- it reduces the overall code size:
without patch series:
text data bss dec hex filename
5321639 858418 715768 6895825 6938d1 vmlinux
with patch series:
text data bss dec hex filename
5320026 858418 715768 6894212 693284 vmlinux
This patch:
Switch from nd->{dentry,mnt} to nd->path.{dentry,mnt} everywhere.
[akpm@linux-foundation.org: coding-style fixes]
[akpm@linux-foundation.org: fix cifs]
[akpm@linux-foundation.org: fix smack]
Signed-off-by: Jan Blunck <jblunck@suse.de>
Signed-off-by: Andreas Gruenbacher <agruen@suse.de>
Acked-by: Christoph Hellwig <hch@lst.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Casey Schaufler <casey@schaufler-ca.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/export.c | 35 | ||||
-rw-r--r-- | fs/nfsd/nfs4recover.c | 32 | ||||
-rw-r--r-- | fs/nfsd/nfs4state.c | 2 |
3 files changed, 35 insertions, 34 deletions
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index 346570f6d848..2ac0e30285c2 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c | |||
@@ -169,8 +169,8 @@ static int expkey_parse(struct cache_detail *cd, char *mesg, int mlen) | |||
169 | goto out; | 169 | goto out; |
170 | 170 | ||
171 | dprintk("Found the path %s\n", buf); | 171 | dprintk("Found the path %s\n", buf); |
172 | key.ek_mnt = nd.mnt; | 172 | key.ek_mnt = nd.path.mnt; |
173 | key.ek_dentry = nd.dentry; | 173 | key.ek_dentry = nd.path.dentry; |
174 | 174 | ||
175 | ek = svc_expkey_update(&key, ek); | 175 | ek = svc_expkey_update(&key, ek); |
176 | if (ek) | 176 | if (ek) |
@@ -507,7 +507,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen) | |||
507 | struct svc_export exp, *expp; | 507 | struct svc_export exp, *expp; |
508 | int an_int; | 508 | int an_int; |
509 | 509 | ||
510 | nd.dentry = NULL; | 510 | nd.path.dentry = NULL; |
511 | exp.ex_path = NULL; | 511 | exp.ex_path = NULL; |
512 | 512 | ||
513 | /* fs locations */ | 513 | /* fs locations */ |
@@ -547,8 +547,8 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen) | |||
547 | 547 | ||
548 | exp.h.flags = 0; | 548 | exp.h.flags = 0; |
549 | exp.ex_client = dom; | 549 | exp.ex_client = dom; |
550 | exp.ex_mnt = nd.mnt; | 550 | exp.ex_mnt = nd.path.mnt; |
551 | exp.ex_dentry = nd.dentry; | 551 | exp.ex_dentry = nd.path.dentry; |
552 | exp.ex_path = kstrdup(buf, GFP_KERNEL); | 552 | exp.ex_path = kstrdup(buf, GFP_KERNEL); |
553 | err = -ENOMEM; | 553 | err = -ENOMEM; |
554 | if (!exp.ex_path) | 554 | if (!exp.ex_path) |
@@ -610,7 +610,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen) | |||
610 | goto out; | 610 | goto out; |
611 | } | 611 | } |
612 | 612 | ||
613 | err = check_export(nd.dentry->d_inode, exp.ex_flags, | 613 | err = check_export(nd.path.dentry->d_inode, exp.ex_flags, |
614 | exp.ex_uuid); | 614 | exp.ex_uuid); |
615 | if (err) goto out; | 615 | if (err) goto out; |
616 | } | 616 | } |
@@ -629,7 +629,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen) | |||
629 | nfsd4_fslocs_free(&exp.ex_fslocs); | 629 | nfsd4_fslocs_free(&exp.ex_fslocs); |
630 | kfree(exp.ex_uuid); | 630 | kfree(exp.ex_uuid); |
631 | kfree(exp.ex_path); | 631 | kfree(exp.ex_path); |
632 | if (nd.dentry) | 632 | if (nd.path.dentry) |
633 | path_release(&nd); | 633 | path_release(&nd); |
634 | out_no_path: | 634 | out_no_path: |
635 | if (dom) | 635 | if (dom) |
@@ -1030,7 +1030,7 @@ exp_export(struct nfsctl_export *nxp) | |||
1030 | goto out_unlock; | 1030 | goto out_unlock; |
1031 | err = -EINVAL; | 1031 | err = -EINVAL; |
1032 | 1032 | ||
1033 | exp = exp_get_by_name(clp, nd.mnt, nd.dentry, NULL); | 1033 | exp = exp_get_by_name(clp, nd.path.mnt, nd.path.dentry, NULL); |
1034 | 1034 | ||
1035 | memset(&new, 0, sizeof(new)); | 1035 | memset(&new, 0, sizeof(new)); |
1036 | 1036 | ||
@@ -1038,7 +1038,8 @@ exp_export(struct nfsctl_export *nxp) | |||
1038 | if ((nxp->ex_flags & NFSEXP_FSID) && | 1038 | if ((nxp->ex_flags & NFSEXP_FSID) && |
1039 | (!IS_ERR(fsid_key = exp_get_fsid_key(clp, nxp->ex_dev))) && | 1039 | (!IS_ERR(fsid_key = exp_get_fsid_key(clp, nxp->ex_dev))) && |
1040 | fsid_key->ek_mnt && | 1040 | fsid_key->ek_mnt && |
1041 | (fsid_key->ek_mnt != nd.mnt || fsid_key->ek_dentry != nd.dentry) ) | 1041 | (fsid_key->ek_mnt != nd.path.mnt || |
1042 | fsid_key->ek_dentry != nd.path.dentry)) | ||
1042 | goto finish; | 1043 | goto finish; |
1043 | 1044 | ||
1044 | if (!IS_ERR(exp)) { | 1045 | if (!IS_ERR(exp)) { |
@@ -1054,7 +1055,7 @@ exp_export(struct nfsctl_export *nxp) | |||
1054 | goto finish; | 1055 | goto finish; |
1055 | } | 1056 | } |
1056 | 1057 | ||
1057 | err = check_export(nd.dentry->d_inode, nxp->ex_flags, NULL); | 1058 | err = check_export(nd.path.dentry->d_inode, nxp->ex_flags, NULL); |
1058 | if (err) goto finish; | 1059 | if (err) goto finish; |
1059 | 1060 | ||
1060 | err = -ENOMEM; | 1061 | err = -ENOMEM; |
@@ -1067,8 +1068,8 @@ exp_export(struct nfsctl_export *nxp) | |||
1067 | if (!new.ex_path) | 1068 | if (!new.ex_path) |
1068 | goto finish; | 1069 | goto finish; |
1069 | new.ex_client = clp; | 1070 | new.ex_client = clp; |
1070 | new.ex_mnt = nd.mnt; | 1071 | new.ex_mnt = nd.path.mnt; |
1071 | new.ex_dentry = nd.dentry; | 1072 | new.ex_dentry = nd.path.dentry; |
1072 | new.ex_flags = nxp->ex_flags; | 1073 | new.ex_flags = nxp->ex_flags; |
1073 | new.ex_anon_uid = nxp->ex_anon_uid; | 1074 | new.ex_anon_uid = nxp->ex_anon_uid; |
1074 | new.ex_anon_gid = nxp->ex_anon_gid; | 1075 | new.ex_anon_gid = nxp->ex_anon_gid; |
@@ -1148,7 +1149,7 @@ exp_unexport(struct nfsctl_export *nxp) | |||
1148 | goto out_domain; | 1149 | goto out_domain; |
1149 | 1150 | ||
1150 | err = -EINVAL; | 1151 | err = -EINVAL; |
1151 | exp = exp_get_by_name(dom, nd.mnt, nd.dentry, NULL); | 1152 | exp = exp_get_by_name(dom, nd.path.mnt, nd.path.dentry, NULL); |
1152 | path_release(&nd); | 1153 | path_release(&nd); |
1153 | if (IS_ERR(exp)) | 1154 | if (IS_ERR(exp)) |
1154 | goto out_domain; | 1155 | goto out_domain; |
@@ -1185,12 +1186,12 @@ exp_rootfh(svc_client *clp, char *path, struct knfsd_fh *f, int maxsize) | |||
1185 | printk("nfsd: exp_rootfh path not found %s", path); | 1186 | printk("nfsd: exp_rootfh path not found %s", path); |
1186 | return err; | 1187 | return err; |
1187 | } | 1188 | } |
1188 | inode = nd.dentry->d_inode; | 1189 | inode = nd.path.dentry->d_inode; |
1189 | 1190 | ||
1190 | dprintk("nfsd: exp_rootfh(%s [%p] %s:%s/%ld)\n", | 1191 | dprintk("nfsd: exp_rootfh(%s [%p] %s:%s/%ld)\n", |
1191 | path, nd.dentry, clp->name, | 1192 | path, nd.path.dentry, clp->name, |
1192 | inode->i_sb->s_id, inode->i_ino); | 1193 | inode->i_sb->s_id, inode->i_ino); |
1193 | exp = exp_parent(clp, nd.mnt, nd.dentry, NULL); | 1194 | exp = exp_parent(clp, nd.path.mnt, nd.path.dentry, NULL); |
1194 | if (IS_ERR(exp)) { | 1195 | if (IS_ERR(exp)) { |
1195 | err = PTR_ERR(exp); | 1196 | err = PTR_ERR(exp); |
1196 | goto out; | 1197 | goto out; |
@@ -1200,7 +1201,7 @@ exp_rootfh(svc_client *clp, char *path, struct knfsd_fh *f, int maxsize) | |||
1200 | * fh must be initialized before calling fh_compose | 1201 | * fh must be initialized before calling fh_compose |
1201 | */ | 1202 | */ |
1202 | fh_init(&fh, maxsize); | 1203 | fh_init(&fh, maxsize); |
1203 | if (fh_compose(&fh, exp, nd.dentry, NULL)) | 1204 | if (fh_compose(&fh, exp, nd.path.dentry, NULL)) |
1204 | err = -EINVAL; | 1205 | err = -EINVAL; |
1205 | else | 1206 | else |
1206 | err = 0; | 1207 | err = 0; |
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index 1602cd00dd45..a7a8fdf86ea7 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c | |||
@@ -120,9 +120,9 @@ out_no_tfm: | |||
120 | static void | 120 | static void |
121 | nfsd4_sync_rec_dir(void) | 121 | nfsd4_sync_rec_dir(void) |
122 | { | 122 | { |
123 | mutex_lock(&rec_dir.dentry->d_inode->i_mutex); | 123 | mutex_lock(&rec_dir.path.dentry->d_inode->i_mutex); |
124 | nfsd_sync_dir(rec_dir.dentry); | 124 | nfsd_sync_dir(rec_dir.path.dentry); |
125 | mutex_unlock(&rec_dir.dentry->d_inode->i_mutex); | 125 | mutex_unlock(&rec_dir.path.dentry->d_inode->i_mutex); |
126 | } | 126 | } |
127 | 127 | ||
128 | int | 128 | int |
@@ -142,9 +142,9 @@ nfsd4_create_clid_dir(struct nfs4_client *clp) | |||
142 | nfs4_save_user(&uid, &gid); | 142 | nfs4_save_user(&uid, &gid); |
143 | 143 | ||
144 | /* lock the parent */ | 144 | /* lock the parent */ |
145 | mutex_lock(&rec_dir.dentry->d_inode->i_mutex); | 145 | mutex_lock(&rec_dir.path.dentry->d_inode->i_mutex); |
146 | 146 | ||
147 | dentry = lookup_one_len(dname, rec_dir.dentry, HEXDIR_LEN-1); | 147 | dentry = lookup_one_len(dname, rec_dir.path.dentry, HEXDIR_LEN-1); |
148 | if (IS_ERR(dentry)) { | 148 | if (IS_ERR(dentry)) { |
149 | status = PTR_ERR(dentry); | 149 | status = PTR_ERR(dentry); |
150 | goto out_unlock; | 150 | goto out_unlock; |
@@ -154,11 +154,11 @@ nfsd4_create_clid_dir(struct nfs4_client *clp) | |||
154 | dprintk("NFSD: nfsd4_create_clid_dir: DIRECTORY EXISTS\n"); | 154 | dprintk("NFSD: nfsd4_create_clid_dir: DIRECTORY EXISTS\n"); |
155 | goto out_put; | 155 | goto out_put; |
156 | } | 156 | } |
157 | status = vfs_mkdir(rec_dir.dentry->d_inode, dentry, S_IRWXU); | 157 | status = vfs_mkdir(rec_dir.path.dentry->d_inode, dentry, S_IRWXU); |
158 | out_put: | 158 | out_put: |
159 | dput(dentry); | 159 | dput(dentry); |
160 | out_unlock: | 160 | out_unlock: |
161 | mutex_unlock(&rec_dir.dentry->d_inode->i_mutex); | 161 | mutex_unlock(&rec_dir.path.dentry->d_inode->i_mutex); |
162 | if (status == 0) { | 162 | if (status == 0) { |
163 | clp->cl_firststate = 1; | 163 | clp->cl_firststate = 1; |
164 | nfsd4_sync_rec_dir(); | 164 | nfsd4_sync_rec_dir(); |
@@ -221,7 +221,7 @@ nfsd4_list_rec_dir(struct dentry *dir, recdir_func *f) | |||
221 | 221 | ||
222 | nfs4_save_user(&uid, &gid); | 222 | nfs4_save_user(&uid, &gid); |
223 | 223 | ||
224 | filp = dentry_open(dget(dir), mntget(rec_dir.mnt), O_RDONLY); | 224 | filp = dentry_open(dget(dir), mntget(rec_dir.path.mnt), O_RDONLY); |
225 | status = PTR_ERR(filp); | 225 | status = PTR_ERR(filp); |
226 | if (IS_ERR(filp)) | 226 | if (IS_ERR(filp)) |
227 | goto out; | 227 | goto out; |
@@ -286,9 +286,9 @@ nfsd4_unlink_clid_dir(char *name, int namlen) | |||
286 | 286 | ||
287 | dprintk("NFSD: nfsd4_unlink_clid_dir. name %.*s\n", namlen, name); | 287 | dprintk("NFSD: nfsd4_unlink_clid_dir. name %.*s\n", namlen, name); |
288 | 288 | ||
289 | mutex_lock(&rec_dir.dentry->d_inode->i_mutex); | 289 | mutex_lock(&rec_dir.path.dentry->d_inode->i_mutex); |
290 | dentry = lookup_one_len(name, rec_dir.dentry, namlen); | 290 | dentry = lookup_one_len(name, rec_dir.path.dentry, namlen); |
291 | mutex_unlock(&rec_dir.dentry->d_inode->i_mutex); | 291 | mutex_unlock(&rec_dir.path.dentry->d_inode->i_mutex); |
292 | if (IS_ERR(dentry)) { | 292 | if (IS_ERR(dentry)) { |
293 | status = PTR_ERR(dentry); | 293 | status = PTR_ERR(dentry); |
294 | return status; | 294 | return status; |
@@ -297,7 +297,7 @@ nfsd4_unlink_clid_dir(char *name, int namlen) | |||
297 | if (!dentry->d_inode) | 297 | if (!dentry->d_inode) |
298 | goto out; | 298 | goto out; |
299 | 299 | ||
300 | status = nfsd4_clear_clid_dir(rec_dir.dentry, dentry); | 300 | status = nfsd4_clear_clid_dir(rec_dir.path.dentry, dentry); |
301 | out: | 301 | out: |
302 | dput(dentry); | 302 | dput(dentry); |
303 | return status; | 303 | return status; |
@@ -347,12 +347,12 @@ nfsd4_recdir_purge_old(void) { | |||
347 | 347 | ||
348 | if (!rec_dir_init) | 348 | if (!rec_dir_init) |
349 | return; | 349 | return; |
350 | status = nfsd4_list_rec_dir(rec_dir.dentry, purge_old); | 350 | status = nfsd4_list_rec_dir(rec_dir.path.dentry, purge_old); |
351 | if (status == 0) | 351 | if (status == 0) |
352 | nfsd4_sync_rec_dir(); | 352 | nfsd4_sync_rec_dir(); |
353 | if (status) | 353 | if (status) |
354 | printk("nfsd4: failed to purge old clients from recovery" | 354 | printk("nfsd4: failed to purge old clients from recovery" |
355 | " directory %s\n", rec_dir.dentry->d_name.name); | 355 | " directory %s\n", rec_dir.path.dentry->d_name.name); |
356 | return; | 356 | return; |
357 | } | 357 | } |
358 | 358 | ||
@@ -373,10 +373,10 @@ int | |||
373 | nfsd4_recdir_load(void) { | 373 | nfsd4_recdir_load(void) { |
374 | int status; | 374 | int status; |
375 | 375 | ||
376 | status = nfsd4_list_rec_dir(rec_dir.dentry, load_recdir); | 376 | status = nfsd4_list_rec_dir(rec_dir.path.dentry, load_recdir); |
377 | if (status) | 377 | if (status) |
378 | printk("nfsd4: failed loading clients from recovery" | 378 | printk("nfsd4: failed loading clients from recovery" |
379 | " directory %s\n", rec_dir.dentry->d_name.name); | 379 | " directory %s\n", rec_dir.path.dentry->d_name.name); |
380 | return status; | 380 | return status; |
381 | } | 381 | } |
382 | 382 | ||
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index f6744bc03dae..be2b9ecd230a 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -3261,7 +3261,7 @@ nfs4_reset_recoverydir(char *recdir) | |||
3261 | if (status) | 3261 | if (status) |
3262 | return status; | 3262 | return status; |
3263 | status = -ENOTDIR; | 3263 | status = -ENOTDIR; |
3264 | if (S_ISDIR(nd.dentry->d_inode->i_mode)) { | 3264 | if (S_ISDIR(nd.path.dentry->d_inode->i_mode)) { |
3265 | nfs4_set_recdir(recdir); | 3265 | nfs4_set_recdir(recdir); |
3266 | status = 0; | 3266 | status = 0; |
3267 | } | 3267 | } |