aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfsd/export.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfsd/export.c')
-rw-r--r--fs/nfsd/export.c84
1 files changed, 52 insertions, 32 deletions
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c
index c2a4f71d87dd..b9566e46219f 100644
--- a/fs/nfsd/export.c
+++ b/fs/nfsd/export.c
@@ -1,4 +1,3 @@
1#define MSNFS /* HACK HACK */
2/* 1/*
3 * NFS exporting and validation. 2 * NFS exporting and validation.
4 * 3 *
@@ -28,9 +27,6 @@
28typedef struct auth_domain svc_client; 27typedef struct auth_domain svc_client;
29typedef struct svc_export svc_export; 28typedef struct svc_export svc_export;
30 29
31static void exp_do_unexport(svc_export *unexp);
32static int exp_verify_string(char *cp, int max);
33
34/* 30/*
35 * We have two caches. 31 * We have two caches.
36 * One maps client+vfsmnt+dentry to export options - the export map 32 * One maps client+vfsmnt+dentry to export options - the export map
@@ -303,7 +299,6 @@ svc_expkey_update(struct svc_expkey *new, struct svc_expkey *old)
303 299
304#define EXPORT_HASHBITS 8 300#define EXPORT_HASHBITS 8
305#define EXPORT_HASHMAX (1<< EXPORT_HASHBITS) 301#define EXPORT_HASHMAX (1<< EXPORT_HASHBITS)
306#define EXPORT_HASHMASK (EXPORT_HASHMAX -1)
307 302
308static struct cache_head *export_table[EXPORT_HASHMAX]; 303static struct cache_head *export_table[EXPORT_HASHMAX];
309 304
@@ -802,6 +797,7 @@ exp_find_key(svc_client *clp, int fsid_type, u32 *fsidv, struct cache_req *reqp)
802 return ek; 797 return ek;
803} 798}
804 799
800#ifdef CONFIG_NFSD_DEPRECATED
805static int exp_set_key(svc_client *clp, int fsid_type, u32 *fsidv, 801static int exp_set_key(svc_client *clp, int fsid_type, u32 *fsidv,
806 struct svc_export *exp) 802 struct svc_export *exp)
807{ 803{
@@ -852,6 +848,7 @@ exp_get_fsid_key(svc_client *clp, int fsid)
852 848
853 return exp_find_key(clp, FSID_NUM, fsidv, NULL); 849 return exp_find_key(clp, FSID_NUM, fsidv, NULL);
854} 850}
851#endif
855 852
856static svc_export *exp_get_by_name(svc_client *clp, const struct path *path, 853static svc_export *exp_get_by_name(svc_client *clp, const struct path *path,
857 struct cache_req *reqp) 854 struct cache_req *reqp)
@@ -893,6 +890,7 @@ static struct svc_export *exp_parent(svc_client *clp, struct path *path)
893 return exp; 890 return exp;
894} 891}
895 892
893#ifdef CONFIG_NFSD_DEPRECATED
896/* 894/*
897 * Hashtable locking. Write locks are placed only by user processes 895 * Hashtable locking. Write locks are placed only by user processes
898 * wanting to modify export information. 896 * wanting to modify export information.
@@ -925,6 +923,19 @@ exp_writeunlock(void)
925{ 923{
926 up_write(&hash_sem); 924 up_write(&hash_sem);
927} 925}
926#else
927
928/* hash_sem not needed once deprecated interface is removed */
929void exp_readlock(void) {}
930static inline void exp_writelock(void){}
931void exp_readunlock(void) {}
932static inline void exp_writeunlock(void){}
933
934#endif
935
936#ifdef CONFIG_NFSD_DEPRECATED
937static void exp_do_unexport(svc_export *unexp);
938static int exp_verify_string(char *cp, int max);
928 939
929static void exp_fsid_unhash(struct svc_export *exp) 940static void exp_fsid_unhash(struct svc_export *exp)
930{ 941{
@@ -935,10 +946,9 @@ static void exp_fsid_unhash(struct svc_export *exp)
935 946
936 ek = exp_get_fsid_key(exp->ex_client, exp->ex_fsid); 947 ek = exp_get_fsid_key(exp->ex_client, exp->ex_fsid);
937 if (!IS_ERR(ek)) { 948 if (!IS_ERR(ek)) {
938 ek->h.expiry_time = get_seconds()-1; 949 sunrpc_invalidate(&ek->h, &svc_expkey_cache);
939 cache_put(&ek->h, &svc_expkey_cache); 950 cache_put(&ek->h, &svc_expkey_cache);
940 } 951 }
941 svc_expkey_cache.nextcheck = get_seconds();
942} 952}
943 953
944static int exp_fsid_hash(svc_client *clp, struct svc_export *exp) 954static int exp_fsid_hash(svc_client *clp, struct svc_export *exp)
@@ -973,10 +983,9 @@ static void exp_unhash(struct svc_export *exp)
973 983
974 ek = exp_get_key(exp->ex_client, inode->i_sb->s_dev, inode->i_ino); 984 ek = exp_get_key(exp->ex_client, inode->i_sb->s_dev, inode->i_ino);
975 if (!IS_ERR(ek)) { 985 if (!IS_ERR(ek)) {
976 ek->h.expiry_time = get_seconds()-1; 986 sunrpc_invalidate(&ek->h, &svc_expkey_cache);
977 cache_put(&ek->h, &svc_expkey_cache); 987 cache_put(&ek->h, &svc_expkey_cache);
978 } 988 }
979 svc_expkey_cache.nextcheck = get_seconds();
980} 989}
981 990
982/* 991/*
@@ -1097,8 +1106,7 @@ out:
1097static void 1106static void
1098exp_do_unexport(svc_export *unexp) 1107exp_do_unexport(svc_export *unexp)
1099{ 1108{
1100 unexp->h.expiry_time = get_seconds()-1; 1109 sunrpc_invalidate(&unexp->h, &svc_export_cache);
1101 svc_export_cache.nextcheck = get_seconds();
1102 exp_unhash(unexp); 1110 exp_unhash(unexp);
1103 exp_fsid_unhash(unexp); 1111 exp_fsid_unhash(unexp);
1104} 1112}
@@ -1150,6 +1158,7 @@ out_unlock:
1150 exp_writeunlock(); 1158 exp_writeunlock();
1151 return err; 1159 return err;
1152} 1160}
1161#endif /* CONFIG_NFSD_DEPRECATED */
1153 1162
1154/* 1163/*
1155 * Obtain the root fh on behalf of a client. 1164 * Obtain the root fh on behalf of a client.
@@ -1345,12 +1354,6 @@ exp_pseudoroot(struct svc_rqst *rqstp, struct svc_fh *fhp)
1345 if (IS_ERR(exp)) 1354 if (IS_ERR(exp))
1346 return nfserrno(PTR_ERR(exp)); 1355 return nfserrno(PTR_ERR(exp));
1347 rv = fh_compose(fhp, exp, exp->ex_path.dentry, NULL); 1356 rv = fh_compose(fhp, exp, exp->ex_path.dentry, NULL);
1348 if (rv)
1349 goto out;
1350 rv = check_nfsd_access(exp, rqstp);
1351 if (rv)
1352 fh_put(fhp);
1353out:
1354 exp_put(exp); 1357 exp_put(exp);
1355 return rv; 1358 return rv;
1356} 1359}
@@ -1433,9 +1436,6 @@ static struct flags {
1433 { NFSEXP_NOSUBTREECHECK, {"no_subtree_check", ""}}, 1436 { NFSEXP_NOSUBTREECHECK, {"no_subtree_check", ""}},
1434 { NFSEXP_NOAUTHNLM, {"insecure_locks", ""}}, 1437 { NFSEXP_NOAUTHNLM, {"insecure_locks", ""}},
1435 { NFSEXP_V4ROOT, {"v4root", ""}}, 1438 { NFSEXP_V4ROOT, {"v4root", ""}},
1436#ifdef MSNFS
1437 { NFSEXP_MSNFS, {"msnfs", ""}},
1438#endif
1439 { 0, {"", ""}} 1439 { 0, {"", ""}}
1440}; 1440};
1441 1441
@@ -1459,25 +1459,43 @@ static void show_secinfo_flags(struct seq_file *m, int flags)
1459 show_expflags(m, flags, NFSEXP_SECINFO_FLAGS); 1459 show_expflags(m, flags, NFSEXP_SECINFO_FLAGS);
1460} 1460}
1461 1461
1462static bool secinfo_flags_equal(int f, int g)
1463{
1464 f &= NFSEXP_SECINFO_FLAGS;
1465 g &= NFSEXP_SECINFO_FLAGS;
1466 return f == g;
1467}
1468
1469static int show_secinfo_run(struct seq_file *m, struct exp_flavor_info **fp, struct exp_flavor_info *end)
1470{
1471 int flags;
1472
1473 flags = (*fp)->flags;
1474 seq_printf(m, ",sec=%d", (*fp)->pseudoflavor);
1475 (*fp)++;
1476 while (*fp != end && secinfo_flags_equal(flags, (*fp)->flags)) {
1477 seq_printf(m, ":%d", (*fp)->pseudoflavor);
1478 (*fp)++;
1479 }
1480 return flags;
1481}
1482
1462static void show_secinfo(struct seq_file *m, struct svc_export *exp) 1483static void show_secinfo(struct seq_file *m, struct svc_export *exp)
1463{ 1484{
1464 struct exp_flavor_info *f; 1485 struct exp_flavor_info *f;
1465 struct exp_flavor_info *end = exp->ex_flavors + exp->ex_nflavors; 1486 struct exp_flavor_info *end = exp->ex_flavors + exp->ex_nflavors;
1466 int lastflags = 0, first = 0; 1487 int flags;
1467 1488
1468 if (exp->ex_nflavors == 0) 1489 if (exp->ex_nflavors == 0)
1469 return; 1490 return;
1470 for (f = exp->ex_flavors; f < end; f++) { 1491 f = exp->ex_flavors;
1471 if (first || f->flags != lastflags) { 1492 flags = show_secinfo_run(m, &f, end);
1472 if (!first) 1493 if (!secinfo_flags_equal(flags, exp->ex_flags))
1473 show_secinfo_flags(m, lastflags); 1494 show_secinfo_flags(m, flags);
1474 seq_printf(m, ",sec=%d", f->pseudoflavor); 1495 while (f != end) {
1475 lastflags = f->flags; 1496 flags = show_secinfo_run(m, &f, end);
1476 } else { 1497 show_secinfo_flags(m, flags);
1477 seq_printf(m, ":%d", f->pseudoflavor);
1478 }
1479 } 1498 }
1480 show_secinfo_flags(m, lastflags);
1481} 1499}
1482 1500
1483static void exp_flags(struct seq_file *m, int flag, int fsid, 1501static void exp_flags(struct seq_file *m, int flag, int fsid,
@@ -1532,6 +1550,7 @@ const struct seq_operations nfs_exports_op = {
1532 .show = e_show, 1550 .show = e_show,
1533}; 1551};
1534 1552
1553#ifdef CONFIG_NFSD_DEPRECATED
1535/* 1554/*
1536 * Add or modify a client. 1555 * Add or modify a client.
1537 * Change requests may involve the list of host addresses. The list of 1556 * Change requests may involve the list of host addresses. The list of
@@ -1563,7 +1582,7 @@ exp_addclient(struct nfsctl_client *ncp)
1563 /* Insert client into hashtable. */ 1582 /* Insert client into hashtable. */
1564 for (i = 0; i < ncp->cl_naddr; i++) { 1583 for (i = 0; i < ncp->cl_naddr; i++) {
1565 ipv6_addr_set_v4mapped(ncp->cl_addrlist[i].s_addr, &addr6); 1584 ipv6_addr_set_v4mapped(ncp->cl_addrlist[i].s_addr, &addr6);
1566 auth_unix_add_addr(&addr6, dom); 1585 auth_unix_add_addr(&init_net, &addr6, dom);
1567 } 1586 }
1568 auth_unix_forget_old(dom); 1587 auth_unix_forget_old(dom);
1569 auth_domain_put(dom); 1588 auth_domain_put(dom);
@@ -1621,6 +1640,7 @@ exp_verify_string(char *cp, int max)
1621 printk(KERN_NOTICE "nfsd: couldn't validate string %s\n", cp); 1640 printk(KERN_NOTICE "nfsd: couldn't validate string %s\n", cp);
1622 return 0; 1641 return 0;
1623} 1642}
1643#endif /* CONFIG_NFSD_DEPRECATED */
1624 1644
1625/* 1645/*
1626 * Initialize the exports module. 1646 * Initialize the exports module.