diff options
Diffstat (limited to 'fs/nfsd/export.c')
| -rw-r--r-- | fs/nfsd/export.c | 73 |
1 files changed, 52 insertions, 21 deletions
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index c2a4f71d87dd..c0fcb7ab7f6d 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c | |||
| @@ -28,9 +28,6 @@ | |||
| 28 | typedef struct auth_domain svc_client; | 28 | typedef struct auth_domain svc_client; |
| 29 | typedef struct svc_export svc_export; | 29 | typedef struct svc_export svc_export; |
| 30 | 30 | ||
| 31 | static void exp_do_unexport(svc_export *unexp); | ||
| 32 | static int exp_verify_string(char *cp, int max); | ||
| 33 | |||
| 34 | /* | 31 | /* |
| 35 | * We have two caches. | 32 | * We have two caches. |
| 36 | * One maps client+vfsmnt+dentry to export options - the export map | 33 | * One maps client+vfsmnt+dentry to export options - the export map |
| @@ -802,6 +799,7 @@ exp_find_key(svc_client *clp, int fsid_type, u32 *fsidv, struct cache_req *reqp) | |||
| 802 | return ek; | 799 | return ek; |
| 803 | } | 800 | } |
| 804 | 801 | ||
| 802 | #ifdef CONFIG_NFSD_DEPRECATED | ||
| 805 | static int exp_set_key(svc_client *clp, int fsid_type, u32 *fsidv, | 803 | static int exp_set_key(svc_client *clp, int fsid_type, u32 *fsidv, |
| 806 | struct svc_export *exp) | 804 | struct svc_export *exp) |
| 807 | { | 805 | { |
| @@ -852,6 +850,7 @@ exp_get_fsid_key(svc_client *clp, int fsid) | |||
| 852 | 850 | ||
| 853 | return exp_find_key(clp, FSID_NUM, fsidv, NULL); | 851 | return exp_find_key(clp, FSID_NUM, fsidv, NULL); |
| 854 | } | 852 | } |
| 853 | #endif | ||
| 855 | 854 | ||
| 856 | static svc_export *exp_get_by_name(svc_client *clp, const struct path *path, | 855 | static svc_export *exp_get_by_name(svc_client *clp, const struct path *path, |
| 857 | struct cache_req *reqp) | 856 | struct cache_req *reqp) |
| @@ -893,6 +892,7 @@ static struct svc_export *exp_parent(svc_client *clp, struct path *path) | |||
| 893 | return exp; | 892 | return exp; |
| 894 | } | 893 | } |
| 895 | 894 | ||
| 895 | #ifdef CONFIG_NFSD_DEPRECATED | ||
| 896 | /* | 896 | /* |
| 897 | * Hashtable locking. Write locks are placed only by user processes | 897 | * Hashtable locking. Write locks are placed only by user processes |
| 898 | * wanting to modify export information. | 898 | * wanting to modify export information. |
| @@ -925,6 +925,19 @@ exp_writeunlock(void) | |||
| 925 | { | 925 | { |
| 926 | up_write(&hash_sem); | 926 | up_write(&hash_sem); |
| 927 | } | 927 | } |
| 928 | #else | ||
| 929 | |||
| 930 | /* hash_sem not needed once deprecated interface is removed */ | ||
| 931 | void exp_readlock(void) {} | ||
| 932 | static inline void exp_writelock(void){} | ||
| 933 | void exp_readunlock(void) {} | ||
| 934 | static inline void exp_writeunlock(void){} | ||
| 935 | |||
| 936 | #endif | ||
| 937 | |||
| 938 | #ifdef CONFIG_NFSD_DEPRECATED | ||
| 939 | static void exp_do_unexport(svc_export *unexp); | ||
| 940 | static int exp_verify_string(char *cp, int max); | ||
| 928 | 941 | ||
| 929 | static void exp_fsid_unhash(struct svc_export *exp) | 942 | static void exp_fsid_unhash(struct svc_export *exp) |
| 930 | { | 943 | { |
| @@ -935,10 +948,9 @@ static void exp_fsid_unhash(struct svc_export *exp) | |||
| 935 | 948 | ||
| 936 | ek = exp_get_fsid_key(exp->ex_client, exp->ex_fsid); | 949 | ek = exp_get_fsid_key(exp->ex_client, exp->ex_fsid); |
| 937 | if (!IS_ERR(ek)) { | 950 | if (!IS_ERR(ek)) { |
| 938 | ek->h.expiry_time = get_seconds()-1; | 951 | sunrpc_invalidate(&ek->h, &svc_expkey_cache); |
| 939 | cache_put(&ek->h, &svc_expkey_cache); | 952 | cache_put(&ek->h, &svc_expkey_cache); |
| 940 | } | 953 | } |
| 941 | svc_expkey_cache.nextcheck = get_seconds(); | ||
| 942 | } | 954 | } |
| 943 | 955 | ||
| 944 | static int exp_fsid_hash(svc_client *clp, struct svc_export *exp) | 956 | static int exp_fsid_hash(svc_client *clp, struct svc_export *exp) |
| @@ -973,10 +985,9 @@ static void exp_unhash(struct svc_export *exp) | |||
| 973 | 985 | ||
| 974 | 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); |
| 975 | if (!IS_ERR(ek)) { | 987 | if (!IS_ERR(ek)) { |
| 976 | ek->h.expiry_time = get_seconds()-1; | 988 | sunrpc_invalidate(&ek->h, &svc_expkey_cache); |
| 977 | cache_put(&ek->h, &svc_expkey_cache); | 989 | cache_put(&ek->h, &svc_expkey_cache); |
| 978 | } | 990 | } |
| 979 | svc_expkey_cache.nextcheck = get_seconds(); | ||
| 980 | } | 991 | } |
| 981 | 992 | ||
| 982 | /* | 993 | /* |
| @@ -1097,8 +1108,7 @@ out: | |||
| 1097 | static void | 1108 | static void |
| 1098 | exp_do_unexport(svc_export *unexp) | 1109 | exp_do_unexport(svc_export *unexp) |
| 1099 | { | 1110 | { |
| 1100 | unexp->h.expiry_time = get_seconds()-1; | 1111 | sunrpc_invalidate(&unexp->h, &svc_export_cache); |
| 1101 | svc_export_cache.nextcheck = get_seconds(); | ||
| 1102 | exp_unhash(unexp); | 1112 | exp_unhash(unexp); |
| 1103 | exp_fsid_unhash(unexp); | 1113 | exp_fsid_unhash(unexp); |
| 1104 | } | 1114 | } |
| @@ -1150,6 +1160,7 @@ out_unlock: | |||
| 1150 | exp_writeunlock(); | 1160 | exp_writeunlock(); |
| 1151 | return err; | 1161 | return err; |
| 1152 | } | 1162 | } |
| 1163 | #endif /* CONFIG_NFSD_DEPRECATED */ | ||
| 1153 | 1164 | ||
| 1154 | /* | 1165 | /* |
| 1155 | * Obtain the root fh on behalf of a client. | 1166 | * Obtain the root fh on behalf of a client. |
| @@ -1459,25 +1470,43 @@ static void show_secinfo_flags(struct seq_file *m, int flags) | |||
| 1459 | show_expflags(m, flags, NFSEXP_SECINFO_FLAGS); | 1470 | show_expflags(m, flags, NFSEXP_SECINFO_FLAGS); |
| 1460 | } | 1471 | } |
| 1461 | 1472 | ||
| 1473 | static bool secinfo_flags_equal(int f, int g) | ||
| 1474 | { | ||
| 1475 | f &= NFSEXP_SECINFO_FLAGS; | ||
| 1476 | g &= NFSEXP_SECINFO_FLAGS; | ||
| 1477 | return f == g; | ||
| 1478 | } | ||
| 1479 | |||
| 1480 | static int show_secinfo_run(struct seq_file *m, struct exp_flavor_info **fp, struct exp_flavor_info *end) | ||
| 1481 | { | ||
| 1482 | int flags; | ||
| 1483 | |||
| 1484 | flags = (*fp)->flags; | ||
| 1485 | seq_printf(m, ",sec=%d", (*fp)->pseudoflavor); | ||
| 1486 | (*fp)++; | ||
| 1487 | while (*fp != end && secinfo_flags_equal(flags, (*fp)->flags)) { | ||
| 1488 | seq_printf(m, ":%d", (*fp)->pseudoflavor); | ||
| 1489 | (*fp)++; | ||
| 1490 | } | ||
| 1491 | return flags; | ||
| 1492 | } | ||
| 1493 | |||
| 1462 | static void show_secinfo(struct seq_file *m, struct svc_export *exp) | 1494 | static void show_secinfo(struct seq_file *m, struct svc_export *exp) |
| 1463 | { | 1495 | { |
| 1464 | struct exp_flavor_info *f; | 1496 | struct exp_flavor_info *f; |
| 1465 | struct exp_flavor_info *end = exp->ex_flavors + exp->ex_nflavors; | 1497 | struct exp_flavor_info *end = exp->ex_flavors + exp->ex_nflavors; |
| 1466 | int lastflags = 0, first = 0; | 1498 | int flags; |
| 1467 | 1499 | ||
| 1468 | if (exp->ex_nflavors == 0) | 1500 | if (exp->ex_nflavors == 0) |
| 1469 | return; | 1501 | return; |
| 1470 | for (f = exp->ex_flavors; f < end; f++) { | 1502 | f = exp->ex_flavors; |
| 1471 | if (first || f->flags != lastflags) { | 1503 | flags = show_secinfo_run(m, &f, end); |
| 1472 | if (!first) | 1504 | if (!secinfo_flags_equal(flags, exp->ex_flags)) |
| 1473 | show_secinfo_flags(m, lastflags); | 1505 | show_secinfo_flags(m, flags); |
| 1474 | seq_printf(m, ",sec=%d", f->pseudoflavor); | 1506 | while (f != end) { |
| 1475 | lastflags = f->flags; | 1507 | flags = show_secinfo_run(m, &f, end); |
| 1476 | } else { | 1508 | show_secinfo_flags(m, flags); |
| 1477 | seq_printf(m, ":%d", f->pseudoflavor); | ||
| 1478 | } | ||
| 1479 | } | 1509 | } |
| 1480 | show_secinfo_flags(m, lastflags); | ||
| 1481 | } | 1510 | } |
| 1482 | 1511 | ||
| 1483 | static void exp_flags(struct seq_file *m, int flag, int fsid, | 1512 | static void exp_flags(struct seq_file *m, int flag, int fsid, |
| @@ -1532,6 +1561,7 @@ const struct seq_operations nfs_exports_op = { | |||
| 1532 | .show = e_show, | 1561 | .show = e_show, |
| 1533 | }; | 1562 | }; |
| 1534 | 1563 | ||
| 1564 | #ifdef CONFIG_NFSD_DEPRECATED | ||
| 1535 | /* | 1565 | /* |
| 1536 | * Add or modify a client. | 1566 | * Add or modify a client. |
| 1537 | * Change requests may involve the list of host addresses. The list of | 1567 | * Change requests may involve the list of host addresses. The list of |
| @@ -1563,7 +1593,7 @@ exp_addclient(struct nfsctl_client *ncp) | |||
| 1563 | /* Insert client into hashtable. */ | 1593 | /* Insert client into hashtable. */ |
| 1564 | for (i = 0; i < ncp->cl_naddr; i++) { | 1594 | for (i = 0; i < ncp->cl_naddr; i++) { |
| 1565 | ipv6_addr_set_v4mapped(ncp->cl_addrlist[i].s_addr, &addr6); | 1595 | ipv6_addr_set_v4mapped(ncp->cl_addrlist[i].s_addr, &addr6); |
| 1566 | auth_unix_add_addr(&addr6, dom); | 1596 | auth_unix_add_addr(&init_net, &addr6, dom); |
| 1567 | } | 1597 | } |
| 1568 | auth_unix_forget_old(dom); | 1598 | auth_unix_forget_old(dom); |
| 1569 | auth_domain_put(dom); | 1599 | auth_domain_put(dom); |
| @@ -1621,6 +1651,7 @@ exp_verify_string(char *cp, int max) | |||
| 1621 | printk(KERN_NOTICE "nfsd: couldn't validate string %s\n", cp); | 1651 | printk(KERN_NOTICE "nfsd: couldn't validate string %s\n", cp); |
| 1622 | return 0; | 1652 | return 0; |
| 1623 | } | 1653 | } |
| 1654 | #endif /* CONFIG_NFSD_DEPRECATED */ | ||
| 1624 | 1655 | ||
| 1625 | /* | 1656 | /* |
| 1626 | * Initialize the exports module. | 1657 | * Initialize the exports module. |
