aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/export.c
diff options
context:
space:
mode:
authorJan Blunck <jblunck@suse.de>2008-02-14 22:38:39 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-15 00:17:08 -0500
commit5477549161480432d053565d2720f08626baf9e3 (patch)
tree0993666627a6f53f5c7cc9277a329760ccc1002d /fs/nfsd/export.c
parent448678a0f3cdd0157f00e98bd337e32030273637 (diff)
Use struct path in struct svc_export
I'm embedding struct path into struct svc_export. [akpm@linux-foundation.org: coding-style fixes] [ezk@cs.sunysb.edu: NFSD: fix wrong mnt_writer count in rename] Signed-off-by: Jan Blunck <jblunck@suse.de> Acked-by: J. Bruce Fields <bfields@citi.umich.edu> Acked-by: Christoph Hellwig <hch@infradead.org> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: "J. Bruce Fields" <bfields@fieldses.org> Cc: Neil Brown <neilb@suse.de> Cc: Trond Myklebust <trond.myklebust@fys.uio.no> Signed-off-by: Erez Zadok <ezk@cs.sunysb.edu> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/nfsd/export.c')
-rw-r--r--fs/nfsd/export.c67
1 files changed, 32 insertions, 35 deletions
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index 717413f07e9a..7d7896814fa4 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -332,10 +332,9 @@ static void nfsd4_fslocs_free(struct nfsd4_fs_locations *fsloc)
332static void svc_export_put(struct kref *ref) 332static void svc_export_put(struct kref *ref)
333{ 333{
334 struct svc_export *exp = container_of(ref, struct svc_export, h.ref); 334 struct svc_export *exp = container_of(ref, struct svc_export, h.ref);
335 dput(exp->ex_dentry); 335 path_put(&exp->ex_path);
336 mntput(exp->ex_mnt);
337 auth_domain_put(exp->ex_client); 336 auth_domain_put(exp->ex_client);
338 kfree(exp->ex_path); 337 kfree(exp->ex_pathname);
339 nfsd4_fslocs_free(&exp->ex_fslocs); 338 nfsd4_fslocs_free(&exp->ex_fslocs);
340 kfree(exp); 339 kfree(exp);
341} 340}
@@ -349,7 +348,7 @@ static void svc_export_request(struct cache_detail *cd,
349 char *pth; 348 char *pth;
350 349
351 qword_add(bpp, blen, exp->ex_client->name); 350 qword_add(bpp, blen, exp->ex_client->name);
352 pth = d_path(exp->ex_dentry, exp->ex_mnt, *bpp, *blen); 351 pth = d_path(exp->ex_path.dentry, exp->ex_path.mnt, *bpp, *blen);
353 if (IS_ERR(pth)) { 352 if (IS_ERR(pth)) {
354 /* is this correct? */ 353 /* is this correct? */
355 (*bpp)[0] = '\n'; 354 (*bpp)[0] = '\n';
@@ -508,7 +507,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
508 int an_int; 507 int an_int;
509 508
510 nd.path.dentry = NULL; 509 nd.path.dentry = NULL;
511 exp.ex_path = NULL; 510 exp.ex_pathname = NULL;
512 511
513 /* fs locations */ 512 /* fs locations */
514 exp.ex_fslocs.locations = NULL; 513 exp.ex_fslocs.locations = NULL;
@@ -547,11 +546,11 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
547 546
548 exp.h.flags = 0; 547 exp.h.flags = 0;
549 exp.ex_client = dom; 548 exp.ex_client = dom;
550 exp.ex_mnt = nd.path.mnt; 549 exp.ex_path.mnt = nd.path.mnt;
551 exp.ex_dentry = nd.path.dentry; 550 exp.ex_path.dentry = nd.path.dentry;
552 exp.ex_path = kstrdup(buf, GFP_KERNEL); 551 exp.ex_pathname = kstrdup(buf, GFP_KERNEL);
553 err = -ENOMEM; 552 err = -ENOMEM;
554 if (!exp.ex_path) 553 if (!exp.ex_pathname)
555 goto out; 554 goto out;
556 555
557 /* expiry */ 556 /* expiry */
@@ -628,7 +627,7 @@ static int svc_export_parse(struct cache_detail *cd, char *mesg, int mlen)
628 out: 627 out:
629 nfsd4_fslocs_free(&exp.ex_fslocs); 628 nfsd4_fslocs_free(&exp.ex_fslocs);
630 kfree(exp.ex_uuid); 629 kfree(exp.ex_uuid);
631 kfree(exp.ex_path); 630 kfree(exp.ex_pathname);
632 if (nd.path.dentry) 631 if (nd.path.dentry)
633 path_put(&nd.path); 632 path_put(&nd.path);
634 out_no_path: 633 out_no_path:
@@ -653,7 +652,7 @@ static int svc_export_show(struct seq_file *m,
653 return 0; 652 return 0;
654 } 653 }
655 exp = container_of(h, struct svc_export, h); 654 exp = container_of(h, struct svc_export, h);
656 seq_path(m, exp->ex_mnt, exp->ex_dentry, " \t\n\\"); 655 seq_path(m, exp->ex_path.mnt, exp->ex_path.dentry, " \t\n\\");
657 seq_putc(m, '\t'); 656 seq_putc(m, '\t');
658 seq_escape(m, exp->ex_client->name, " \t\n\\"); 657 seq_escape(m, exp->ex_client->name, " \t\n\\");
659 seq_putc(m, '('); 658 seq_putc(m, '(');
@@ -680,8 +679,8 @@ static int svc_export_match(struct cache_head *a, struct cache_head *b)
680 struct svc_export *orig = container_of(a, struct svc_export, h); 679 struct svc_export *orig = container_of(a, struct svc_export, h);
681 struct svc_export *new = container_of(b, struct svc_export, h); 680 struct svc_export *new = container_of(b, struct svc_export, h);
682 return orig->ex_client == new->ex_client && 681 return orig->ex_client == new->ex_client &&
683 orig->ex_dentry == new->ex_dentry && 682 orig->ex_path.dentry == new->ex_path.dentry &&
684 orig->ex_mnt == new->ex_mnt; 683 orig->ex_path.mnt == new->ex_path.mnt;
685} 684}
686 685
687static void svc_export_init(struct cache_head *cnew, struct cache_head *citem) 686static void svc_export_init(struct cache_head *cnew, struct cache_head *citem)
@@ -691,9 +690,9 @@ static void svc_export_init(struct cache_head *cnew, struct cache_head *citem)
691 690
692 kref_get(&item->ex_client->ref); 691 kref_get(&item->ex_client->ref);
693 new->ex_client = item->ex_client; 692 new->ex_client = item->ex_client;
694 new->ex_dentry = dget(item->ex_dentry); 693 new->ex_path.dentry = dget(item->ex_path.dentry);
695 new->ex_mnt = mntget(item->ex_mnt); 694 new->ex_path.mnt = mntget(item->ex_path.mnt);
696 new->ex_path = NULL; 695 new->ex_pathname = NULL;
697 new->ex_fslocs.locations = NULL; 696 new->ex_fslocs.locations = NULL;
698 new->ex_fslocs.locations_count = 0; 697 new->ex_fslocs.locations_count = 0;
699 new->ex_fslocs.migrated = 0; 698 new->ex_fslocs.migrated = 0;
@@ -711,8 +710,8 @@ static void export_update(struct cache_head *cnew, struct cache_head *citem)
711 new->ex_fsid = item->ex_fsid; 710 new->ex_fsid = item->ex_fsid;
712 new->ex_uuid = item->ex_uuid; 711 new->ex_uuid = item->ex_uuid;
713 item->ex_uuid = NULL; 712 item->ex_uuid = NULL;
714 new->ex_path = item->ex_path; 713 new->ex_pathname = item->ex_pathname;
715 item->ex_path = NULL; 714 item->ex_pathname = NULL;
716 new->ex_fslocs.locations = item->ex_fslocs.locations; 715 new->ex_fslocs.locations = item->ex_fslocs.locations;
717 item->ex_fslocs.locations = NULL; 716 item->ex_fslocs.locations = NULL;
718 new->ex_fslocs.locations_count = item->ex_fslocs.locations_count; 717 new->ex_fslocs.locations_count = item->ex_fslocs.locations_count;
@@ -755,8 +754,8 @@ svc_export_lookup(struct svc_export *exp)
755 struct cache_head *ch; 754 struct cache_head *ch;
756 int hash; 755 int hash;
757 hash = hash_ptr(exp->ex_client, EXPORT_HASHBITS); 756 hash = hash_ptr(exp->ex_client, EXPORT_HASHBITS);
758 hash ^= hash_ptr(exp->ex_dentry, EXPORT_HASHBITS); 757 hash ^= hash_ptr(exp->ex_path.dentry, EXPORT_HASHBITS);
759 hash ^= hash_ptr(exp->ex_mnt, EXPORT_HASHBITS); 758 hash ^= hash_ptr(exp->ex_path.mnt, EXPORT_HASHBITS);
760 759
761 ch = sunrpc_cache_lookup(&svc_export_cache, &exp->h, 760 ch = sunrpc_cache_lookup(&svc_export_cache, &exp->h,
762 hash); 761 hash);
@@ -772,8 +771,8 @@ svc_export_update(struct svc_export *new, struct svc_export *old)
772 struct cache_head *ch; 771 struct cache_head *ch;
773 int hash; 772 int hash;
774 hash = hash_ptr(old->ex_client, EXPORT_HASHBITS); 773 hash = hash_ptr(old->ex_client, EXPORT_HASHBITS);
775 hash ^= hash_ptr(old->ex_dentry, EXPORT_HASHBITS); 774 hash ^= hash_ptr(old->ex_path.dentry, EXPORT_HASHBITS);
776 hash ^= hash_ptr(old->ex_mnt, EXPORT_HASHBITS); 775 hash ^= hash_ptr(old->ex_path.mnt, EXPORT_HASHBITS);
777 776
778 ch = sunrpc_cache_update(&svc_export_cache, &new->h, 777 ch = sunrpc_cache_update(&svc_export_cache, &new->h,
779 &old->h, 778 &old->h,
@@ -815,8 +814,8 @@ static int exp_set_key(svc_client *clp, int fsid_type, u32 *fsidv,
815 key.ek_client = clp; 814 key.ek_client = clp;
816 key.ek_fsidtype = fsid_type; 815 key.ek_fsidtype = fsid_type;
817 memcpy(key.ek_fsid, fsidv, key_len(fsid_type)); 816 memcpy(key.ek_fsid, fsidv, key_len(fsid_type));
818 key.ek_mnt = exp->ex_mnt; 817 key.ek_mnt = exp->ex_path.mnt;
819 key.ek_dentry = exp->ex_dentry; 818 key.ek_dentry = exp->ex_path.dentry;
820 key.h.expiry_time = NEVER; 819 key.h.expiry_time = NEVER;
821 key.h.flags = 0; 820 key.h.flags = 0;
822 821
@@ -870,8 +869,8 @@ static svc_export *exp_get_by_name(svc_client *clp, struct vfsmount *mnt,
870 return ERR_PTR(-ENOENT); 869 return ERR_PTR(-ENOENT);
871 870
872 key.ex_client = clp; 871 key.ex_client = clp;
873 key.ex_mnt = mnt; 872 key.ex_path.mnt = mnt;
874 key.ex_dentry = dentry; 873 key.ex_path.dentry = dentry;
875 874
876 exp = svc_export_lookup(&key); 875 exp = svc_export_lookup(&key);
877 if (exp == NULL) 876 if (exp == NULL)
@@ -968,7 +967,7 @@ static int exp_fsid_hash(svc_client *clp, struct svc_export *exp)
968static int exp_hash(struct auth_domain *clp, struct svc_export *exp) 967static int exp_hash(struct auth_domain *clp, struct svc_export *exp)
969{ 968{
970 u32 fsid[2]; 969 u32 fsid[2];
971 struct inode *inode = exp->ex_dentry->d_inode; 970 struct inode *inode = exp->ex_path.dentry->d_inode;
972 dev_t dev = inode->i_sb->s_dev; 971 dev_t dev = inode->i_sb->s_dev;
973 972
974 if (old_valid_dev(dev)) { 973 if (old_valid_dev(dev)) {
@@ -982,7 +981,7 @@ static int exp_hash(struct auth_domain *clp, struct svc_export *exp)
982static void exp_unhash(struct svc_export *exp) 981static void exp_unhash(struct svc_export *exp)
983{ 982{
984 struct svc_expkey *ek; 983 struct svc_expkey *ek;
985 struct inode *inode = exp->ex_dentry->d_inode; 984 struct inode *inode = exp->ex_path.dentry->d_inode;
986 985
987 ek = exp_get_key(exp->ex_client, inode->i_sb->s_dev, inode->i_ino); 986 ek = exp_get_key(exp->ex_client, inode->i_sb->s_dev, inode->i_ino);
988 if (!IS_ERR(ek)) { 987 if (!IS_ERR(ek)) {
@@ -1064,12 +1063,11 @@ exp_export(struct nfsctl_export *nxp)
1064 1063
1065 new.h.expiry_time = NEVER; 1064 new.h.expiry_time = NEVER;
1066 new.h.flags = 0; 1065 new.h.flags = 0;
1067 new.ex_path = kstrdup(nxp->ex_path, GFP_KERNEL); 1066 new.ex_pathname = kstrdup(nxp->ex_path, GFP_KERNEL);
1068 if (!new.ex_path) 1067 if (!new.ex_pathname)
1069 goto finish; 1068 goto finish;
1070 new.ex_client = clp; 1069 new.ex_client = clp;
1071 new.ex_mnt = nd.path.mnt; 1070 new.ex_path = nd.path;
1072 new.ex_dentry = nd.path.dentry;
1073 new.ex_flags = nxp->ex_flags; 1071 new.ex_flags = nxp->ex_flags;
1074 new.ex_anon_uid = nxp->ex_anon_uid; 1072 new.ex_anon_uid = nxp->ex_anon_uid;
1075 new.ex_anon_gid = nxp->ex_anon_gid; 1073 new.ex_anon_gid = nxp->ex_anon_gid;
@@ -1090,8 +1088,7 @@ exp_export(struct nfsctl_export *nxp)
1090 } else 1088 } else
1091 err = 0; 1089 err = 0;
1092finish: 1090finish:
1093 if (new.ex_path) 1091 kfree(new.ex_pathname);
1094 kfree(new.ex_path);
1095 if (exp) 1092 if (exp)
1096 exp_put(exp); 1093 exp_put(exp);
1097 if (fsid_key && !IS_ERR(fsid_key)) 1094 if (fsid_key && !IS_ERR(fsid_key))
@@ -1360,7 +1357,7 @@ exp_pseudoroot(struct svc_rqst *rqstp, struct svc_fh *fhp)
1360 exp = rqst_exp_find(rqstp, FSID_NUM, fsidv); 1357 exp = rqst_exp_find(rqstp, FSID_NUM, fsidv);
1361 if (IS_ERR(exp)) 1358 if (IS_ERR(exp))
1362 return nfserrno(PTR_ERR(exp)); 1359 return nfserrno(PTR_ERR(exp));
1363 rv = fh_compose(fhp, exp, exp->ex_dentry, NULL); 1360 rv = fh_compose(fhp, exp, exp->ex_path.dentry, NULL);
1364 if (rv) 1361 if (rv)
1365 goto out; 1362 goto out;
1366 rv = check_nfsd_access(exp, rqstp); 1363 rv = check_nfsd_access(exp, rqstp);