diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-26 01:49:19 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-07-26 01:49:19 -0400 |
commit | 2dad3206db5c3832cde1f58650027fea3ff7adf3 (patch) | |
tree | 96314a554afdab5904a939793156d4ae23ec11c1 /fs/nfsd | |
parent | 84635d68be4b846ba984a89f386524153330c597 (diff) | |
parent | 0c12eaffdf09466f36a9ffe970dda8f4aeb6efc0 (diff) |
Merge branch 'for-3.1' of git://linux-nfs.org/~bfields/linux
* 'for-3.1' of git://linux-nfs.org/~bfields/linux:
nfsd: don't break lease on CLAIM_DELEGATE_CUR
locks: rename lock-manager ops
nfsd4: update nfsv4.1 implementation notes
nfsd: turn on reply cache for NFSv4
nfsd4: call nfsd4_release_compoundargs from pc_release
nfsd41: Deny new lock before RECLAIM_COMPLETE done
fs: locks: remove init_once
nfsd41: check the size of request
nfsd41: error out when client sets maxreq_sz or maxresp_sz too small
nfsd4: fix file leak on open_downgrade
nfsd4: remember to put RW access on stateid destruction
NFSD: Added TEST_STATEID operation
NFSD: added FREE_STATEID operation
svcrpc: fix list-corrupting race on nfsd shutdown
rpc: allow autoloading of gss mechanisms
svcauth_unix.c: quiet sparse noise
svcsock.c: include sunrpc.h to quiet sparse noise
nfsd: Remove deprecated nfsctl system call and related code.
NFSD: allow OP_DESTROY_CLIENTID to be only op in COMPOUND
Fix up trivial conflicts in Documentation/feature-removal-schedule.txt
Diffstat (limited to 'fs/nfsd')
-rw-r--r-- | fs/nfsd/Kconfig | 12 | ||||
-rw-r--r-- | fs/nfsd/cache.h | 2 | ||||
-rw-r--r-- | fs/nfsd/export.c | 418 | ||||
-rw-r--r-- | fs/nfsd/lockd.c | 2 | ||||
-rw-r--r-- | fs/nfsd/nfs4proc.c | 58 | ||||
-rw-r--r-- | fs/nfsd/nfs4state.c | 265 | ||||
-rw-r--r-- | fs/nfsd/nfs4xdr.c | 144 | ||||
-rw-r--r-- | fs/nfsd/nfscache.c | 3 | ||||
-rw-r--r-- | fs/nfsd/nfsctl.c | 343 | ||||
-rw-r--r-- | fs/nfsd/nfssvc.c | 33 | ||||
-rw-r--r-- | fs/nfsd/state.h | 1 | ||||
-rw-r--r-- | fs/nfsd/xdr4.h | 30 |
12 files changed, 449 insertions, 862 deletions
diff --git a/fs/nfsd/Kconfig b/fs/nfsd/Kconfig index fbb2a5ef5817..10e6366608f2 100644 --- a/fs/nfsd/Kconfig +++ b/fs/nfsd/Kconfig | |||
@@ -28,18 +28,6 @@ config NFSD | |||
28 | 28 | ||
29 | If unsure, say N. | 29 | If unsure, say N. |
30 | 30 | ||
31 | config NFSD_DEPRECATED | ||
32 | bool "Include support for deprecated syscall interface to NFSD" | ||
33 | depends on NFSD | ||
34 | default y | ||
35 | help | ||
36 | The syscall interface to nfsd was obsoleted in 2.6.0 by a new | ||
37 | filesystem based interface. The old interface is due for removal | ||
38 | in 2.6.40. If you wish to remove the interface before then | ||
39 | say N. | ||
40 | |||
41 | In unsure, say Y. | ||
42 | |||
43 | config NFSD_V2_ACL | 31 | config NFSD_V2_ACL |
44 | bool | 32 | bool |
45 | depends on NFSD | 33 | depends on NFSD |
diff --git a/fs/nfsd/cache.h b/fs/nfsd/cache.h index d892be61016c..93cc9d34c459 100644 --- a/fs/nfsd/cache.h +++ b/fs/nfsd/cache.h | |||
@@ -69,7 +69,7 @@ enum { | |||
69 | 69 | ||
70 | int nfsd_reply_cache_init(void); | 70 | int nfsd_reply_cache_init(void); |
71 | void nfsd_reply_cache_shutdown(void); | 71 | void nfsd_reply_cache_shutdown(void); |
72 | int nfsd_cache_lookup(struct svc_rqst *, int); | 72 | int nfsd_cache_lookup(struct svc_rqst *); |
73 | void nfsd_cache_update(struct svc_rqst *, int, __be32 *); | 73 | void nfsd_cache_update(struct svc_rqst *, int, __be32 *); |
74 | 74 | ||
75 | #ifdef CONFIG_NFSD_V4 | 75 | #ifdef CONFIG_NFSD_V4 |
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index b9566e46219f..f4cc1e2bfc54 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c | |||
@@ -797,58 +797,6 @@ exp_find_key(svc_client *clp, int fsid_type, u32 *fsidv, struct cache_req *reqp) | |||
797 | return ek; | 797 | return ek; |
798 | } | 798 | } |
799 | 799 | ||
800 | #ifdef CONFIG_NFSD_DEPRECATED | ||
801 | static int exp_set_key(svc_client *clp, int fsid_type, u32 *fsidv, | ||
802 | struct svc_export *exp) | ||
803 | { | ||
804 | struct svc_expkey key, *ek; | ||
805 | |||
806 | key.ek_client = clp; | ||
807 | key.ek_fsidtype = fsid_type; | ||
808 | memcpy(key.ek_fsid, fsidv, key_len(fsid_type)); | ||
809 | key.ek_path = exp->ex_path; | ||
810 | key.h.expiry_time = NEVER; | ||
811 | key.h.flags = 0; | ||
812 | |||
813 | ek = svc_expkey_lookup(&key); | ||
814 | if (ek) | ||
815 | ek = svc_expkey_update(&key,ek); | ||
816 | if (ek) { | ||
817 | cache_put(&ek->h, &svc_expkey_cache); | ||
818 | return 0; | ||
819 | } | ||
820 | return -ENOMEM; | ||
821 | } | ||
822 | |||
823 | /* | ||
824 | * Find the client's export entry matching xdev/xino. | ||
825 | */ | ||
826 | static inline struct svc_expkey * | ||
827 | exp_get_key(svc_client *clp, dev_t dev, ino_t ino) | ||
828 | { | ||
829 | u32 fsidv[3]; | ||
830 | |||
831 | if (old_valid_dev(dev)) { | ||
832 | mk_fsid(FSID_DEV, fsidv, dev, ino, 0, NULL); | ||
833 | return exp_find_key(clp, FSID_DEV, fsidv, NULL); | ||
834 | } | ||
835 | mk_fsid(FSID_ENCODE_DEV, fsidv, dev, ino, 0, NULL); | ||
836 | return exp_find_key(clp, FSID_ENCODE_DEV, fsidv, NULL); | ||
837 | } | ||
838 | |||
839 | /* | ||
840 | * Find the client's export entry matching fsid | ||
841 | */ | ||
842 | static inline struct svc_expkey * | ||
843 | exp_get_fsid_key(svc_client *clp, int fsid) | ||
844 | { | ||
845 | u32 fsidv[2]; | ||
846 | |||
847 | mk_fsid(FSID_NUM, fsidv, 0, 0, fsid, NULL); | ||
848 | |||
849 | return exp_find_key(clp, FSID_NUM, fsidv, NULL); | ||
850 | } | ||
851 | #endif | ||
852 | 800 | ||
853 | static svc_export *exp_get_by_name(svc_client *clp, const struct path *path, | 801 | static svc_export *exp_get_by_name(svc_client *clp, const struct path *path, |
854 | struct cache_req *reqp) | 802 | struct cache_req *reqp) |
@@ -890,275 +838,7 @@ static struct svc_export *exp_parent(svc_client *clp, struct path *path) | |||
890 | return exp; | 838 | return exp; |
891 | } | 839 | } |
892 | 840 | ||
893 | #ifdef CONFIG_NFSD_DEPRECATED | ||
894 | /* | ||
895 | * Hashtable locking. Write locks are placed only by user processes | ||
896 | * wanting to modify export information. | ||
897 | * Write locking only done in this file. Read locking | ||
898 | * needed externally. | ||
899 | */ | ||
900 | |||
901 | static DECLARE_RWSEM(hash_sem); | ||
902 | |||
903 | void | ||
904 | exp_readlock(void) | ||
905 | { | ||
906 | down_read(&hash_sem); | ||
907 | } | ||
908 | |||
909 | static inline void | ||
910 | exp_writelock(void) | ||
911 | { | ||
912 | down_write(&hash_sem); | ||
913 | } | ||
914 | |||
915 | void | ||
916 | exp_readunlock(void) | ||
917 | { | ||
918 | up_read(&hash_sem); | ||
919 | } | ||
920 | |||
921 | static inline void | ||
922 | exp_writeunlock(void) | ||
923 | { | ||
924 | up_write(&hash_sem); | ||
925 | } | ||
926 | #else | ||
927 | |||
928 | /* hash_sem not needed once deprecated interface is removed */ | ||
929 | void exp_readlock(void) {} | ||
930 | static inline void exp_writelock(void){} | ||
931 | void exp_readunlock(void) {} | ||
932 | static inline void exp_writeunlock(void){} | ||
933 | |||
934 | #endif | ||
935 | |||
936 | #ifdef CONFIG_NFSD_DEPRECATED | ||
937 | static void exp_do_unexport(svc_export *unexp); | ||
938 | static int exp_verify_string(char *cp, int max); | ||
939 | |||
940 | static void exp_fsid_unhash(struct svc_export *exp) | ||
941 | { | ||
942 | struct svc_expkey *ek; | ||
943 | |||
944 | if ((exp->ex_flags & NFSEXP_FSID) == 0) | ||
945 | return; | ||
946 | |||
947 | ek = exp_get_fsid_key(exp->ex_client, exp->ex_fsid); | ||
948 | if (!IS_ERR(ek)) { | ||
949 | sunrpc_invalidate(&ek->h, &svc_expkey_cache); | ||
950 | cache_put(&ek->h, &svc_expkey_cache); | ||
951 | } | ||
952 | } | ||
953 | |||
954 | static int exp_fsid_hash(svc_client *clp, struct svc_export *exp) | ||
955 | { | ||
956 | u32 fsid[2]; | ||
957 | |||
958 | if ((exp->ex_flags & NFSEXP_FSID) == 0) | ||
959 | return 0; | ||
960 | |||
961 | mk_fsid(FSID_NUM, fsid, 0, 0, exp->ex_fsid, NULL); | ||
962 | return exp_set_key(clp, FSID_NUM, fsid, exp); | ||
963 | } | ||
964 | |||
965 | static int exp_hash(struct auth_domain *clp, struct svc_export *exp) | ||
966 | { | ||
967 | u32 fsid[2]; | ||
968 | struct inode *inode = exp->ex_path.dentry->d_inode; | ||
969 | dev_t dev = inode->i_sb->s_dev; | ||
970 | |||
971 | if (old_valid_dev(dev)) { | ||
972 | mk_fsid(FSID_DEV, fsid, dev, inode->i_ino, 0, NULL); | ||
973 | return exp_set_key(clp, FSID_DEV, fsid, exp); | ||
974 | } | ||
975 | mk_fsid(FSID_ENCODE_DEV, fsid, dev, inode->i_ino, 0, NULL); | ||
976 | return exp_set_key(clp, FSID_ENCODE_DEV, fsid, exp); | ||
977 | } | ||
978 | 841 | ||
979 | static void exp_unhash(struct svc_export *exp) | ||
980 | { | ||
981 | struct svc_expkey *ek; | ||
982 | struct inode *inode = exp->ex_path.dentry->d_inode; | ||
983 | |||
984 | ek = exp_get_key(exp->ex_client, inode->i_sb->s_dev, inode->i_ino); | ||
985 | if (!IS_ERR(ek)) { | ||
986 | sunrpc_invalidate(&ek->h, &svc_expkey_cache); | ||
987 | cache_put(&ek->h, &svc_expkey_cache); | ||
988 | } | ||
989 | } | ||
990 | |||
991 | /* | ||
992 | * Export a file system. | ||
993 | */ | ||
994 | int | ||
995 | exp_export(struct nfsctl_export *nxp) | ||
996 | { | ||
997 | svc_client *clp; | ||
998 | struct svc_export *exp = NULL; | ||
999 | struct svc_export new; | ||
1000 | struct svc_expkey *fsid_key = NULL; | ||
1001 | struct path path; | ||
1002 | int err; | ||
1003 | |||
1004 | /* Consistency check */ | ||
1005 | err = -EINVAL; | ||
1006 | if (!exp_verify_string(nxp->ex_path, NFS_MAXPATHLEN) || | ||
1007 | !exp_verify_string(nxp->ex_client, NFSCLNT_IDMAX)) | ||
1008 | goto out; | ||
1009 | |||
1010 | dprintk("exp_export called for %s:%s (%x/%ld fl %x).\n", | ||
1011 | nxp->ex_client, nxp->ex_path, | ||
1012 | (unsigned)nxp->ex_dev, (long)nxp->ex_ino, | ||
1013 | nxp->ex_flags); | ||
1014 | |||
1015 | /* Try to lock the export table for update */ | ||
1016 | exp_writelock(); | ||
1017 | |||
1018 | /* Look up client info */ | ||
1019 | if (!(clp = auth_domain_find(nxp->ex_client))) | ||
1020 | goto out_unlock; | ||
1021 | |||
1022 | |||
1023 | /* Look up the dentry */ | ||
1024 | err = kern_path(nxp->ex_path, 0, &path); | ||
1025 | if (err) | ||
1026 | goto out_put_clp; | ||
1027 | err = -EINVAL; | ||
1028 | |||
1029 | exp = exp_get_by_name(clp, &path, NULL); | ||
1030 | |||
1031 | memset(&new, 0, sizeof(new)); | ||
1032 | |||
1033 | /* must make sure there won't be an ex_fsid clash */ | ||
1034 | if ((nxp->ex_flags & NFSEXP_FSID) && | ||
1035 | (!IS_ERR(fsid_key = exp_get_fsid_key(clp, nxp->ex_dev))) && | ||
1036 | fsid_key->ek_path.mnt && | ||
1037 | (fsid_key->ek_path.mnt != path.mnt || | ||
1038 | fsid_key->ek_path.dentry != path.dentry)) | ||
1039 | goto finish; | ||
1040 | |||
1041 | if (!IS_ERR(exp)) { | ||
1042 | /* just a flags/id/fsid update */ | ||
1043 | |||
1044 | exp_fsid_unhash(exp); | ||
1045 | exp->ex_flags = nxp->ex_flags; | ||
1046 | exp->ex_anon_uid = nxp->ex_anon_uid; | ||
1047 | exp->ex_anon_gid = nxp->ex_anon_gid; | ||
1048 | exp->ex_fsid = nxp->ex_dev; | ||
1049 | |||
1050 | err = exp_fsid_hash(clp, exp); | ||
1051 | goto finish; | ||
1052 | } | ||
1053 | |||
1054 | err = check_export(path.dentry->d_inode, &nxp->ex_flags, NULL); | ||
1055 | if (err) goto finish; | ||
1056 | |||
1057 | err = -ENOMEM; | ||
1058 | |||
1059 | dprintk("nfsd: creating export entry %p for client %p\n", exp, clp); | ||
1060 | |||
1061 | new.h.expiry_time = NEVER; | ||
1062 | new.h.flags = 0; | ||
1063 | new.ex_pathname = kstrdup(nxp->ex_path, GFP_KERNEL); | ||
1064 | if (!new.ex_pathname) | ||
1065 | goto finish; | ||
1066 | new.ex_client = clp; | ||
1067 | new.ex_path = path; | ||
1068 | new.ex_flags = nxp->ex_flags; | ||
1069 | new.ex_anon_uid = nxp->ex_anon_uid; | ||
1070 | new.ex_anon_gid = nxp->ex_anon_gid; | ||
1071 | new.ex_fsid = nxp->ex_dev; | ||
1072 | |||
1073 | exp = svc_export_lookup(&new); | ||
1074 | if (exp) | ||
1075 | exp = svc_export_update(&new, exp); | ||
1076 | |||
1077 | if (!exp) | ||
1078 | goto finish; | ||
1079 | |||
1080 | if (exp_hash(clp, exp) || | ||
1081 | exp_fsid_hash(clp, exp)) { | ||
1082 | /* failed to create at least one index */ | ||
1083 | exp_do_unexport(exp); | ||
1084 | cache_flush(); | ||
1085 | } else | ||
1086 | err = 0; | ||
1087 | finish: | ||
1088 | kfree(new.ex_pathname); | ||
1089 | if (!IS_ERR_OR_NULL(exp)) | ||
1090 | exp_put(exp); | ||
1091 | if (!IS_ERR_OR_NULL(fsid_key)) | ||
1092 | cache_put(&fsid_key->h, &svc_expkey_cache); | ||
1093 | path_put(&path); | ||
1094 | out_put_clp: | ||
1095 | auth_domain_put(clp); | ||
1096 | out_unlock: | ||
1097 | exp_writeunlock(); | ||
1098 | out: | ||
1099 | return err; | ||
1100 | } | ||
1101 | |||
1102 | /* | ||
1103 | * Unexport a file system. The export entry has already | ||
1104 | * been removed from the client's list of exported fs's. | ||
1105 | */ | ||
1106 | static void | ||
1107 | exp_do_unexport(svc_export *unexp) | ||
1108 | { | ||
1109 | sunrpc_invalidate(&unexp->h, &svc_export_cache); | ||
1110 | exp_unhash(unexp); | ||
1111 | exp_fsid_unhash(unexp); | ||
1112 | } | ||
1113 | |||
1114 | |||
1115 | /* | ||
1116 | * unexport syscall. | ||
1117 | */ | ||
1118 | int | ||
1119 | exp_unexport(struct nfsctl_export *nxp) | ||
1120 | { | ||
1121 | struct auth_domain *dom; | ||
1122 | svc_export *exp; | ||
1123 | struct path path; | ||
1124 | int err; | ||
1125 | |||
1126 | /* Consistency check */ | ||
1127 | if (!exp_verify_string(nxp->ex_path, NFS_MAXPATHLEN) || | ||
1128 | !exp_verify_string(nxp->ex_client, NFSCLNT_IDMAX)) | ||
1129 | return -EINVAL; | ||
1130 | |||
1131 | exp_writelock(); | ||
1132 | |||
1133 | err = -EINVAL; | ||
1134 | dom = auth_domain_find(nxp->ex_client); | ||
1135 | if (!dom) { | ||
1136 | dprintk("nfsd: unexport couldn't find %s\n", nxp->ex_client); | ||
1137 | goto out_unlock; | ||
1138 | } | ||
1139 | |||
1140 | err = kern_path(nxp->ex_path, 0, &path); | ||
1141 | if (err) | ||
1142 | goto out_domain; | ||
1143 | |||
1144 | err = -EINVAL; | ||
1145 | exp = exp_get_by_name(dom, &path, NULL); | ||
1146 | path_put(&path); | ||
1147 | if (IS_ERR(exp)) | ||
1148 | goto out_domain; | ||
1149 | |||
1150 | exp_do_unexport(exp); | ||
1151 | exp_put(exp); | ||
1152 | err = 0; | ||
1153 | |||
1154 | out_domain: | ||
1155 | auth_domain_put(dom); | ||
1156 | cache_flush(); | ||
1157 | out_unlock: | ||
1158 | exp_writeunlock(); | ||
1159 | return err; | ||
1160 | } | ||
1161 | #endif /* CONFIG_NFSD_DEPRECATED */ | ||
1162 | 842 | ||
1163 | /* | 843 | /* |
1164 | * Obtain the root fh on behalf of a client. | 844 | * Obtain the root fh on behalf of a client. |
@@ -1367,7 +1047,6 @@ static void *e_start(struct seq_file *m, loff_t *pos) | |||
1367 | unsigned hash, export; | 1047 | unsigned hash, export; |
1368 | struct cache_head *ch; | 1048 | struct cache_head *ch; |
1369 | 1049 | ||
1370 | exp_readlock(); | ||
1371 | read_lock(&svc_export_cache.hash_lock); | 1050 | read_lock(&svc_export_cache.hash_lock); |
1372 | if (!n--) | 1051 | if (!n--) |
1373 | return SEQ_START_TOKEN; | 1052 | return SEQ_START_TOKEN; |
@@ -1418,7 +1097,6 @@ static void e_stop(struct seq_file *m, void *p) | |||
1418 | __releases(svc_export_cache.hash_lock) | 1097 | __releases(svc_export_cache.hash_lock) |
1419 | { | 1098 | { |
1420 | read_unlock(&svc_export_cache.hash_lock); | 1099 | read_unlock(&svc_export_cache.hash_lock); |
1421 | exp_readunlock(); | ||
1422 | } | 1100 | } |
1423 | 1101 | ||
1424 | static struct flags { | 1102 | static struct flags { |
@@ -1550,97 +1228,6 @@ const struct seq_operations nfs_exports_op = { | |||
1550 | .show = e_show, | 1228 | .show = e_show, |
1551 | }; | 1229 | }; |
1552 | 1230 | ||
1553 | #ifdef CONFIG_NFSD_DEPRECATED | ||
1554 | /* | ||
1555 | * Add or modify a client. | ||
1556 | * Change requests may involve the list of host addresses. The list of | ||
1557 | * exports and possibly existing uid maps are left untouched. | ||
1558 | */ | ||
1559 | int | ||
1560 | exp_addclient(struct nfsctl_client *ncp) | ||
1561 | { | ||
1562 | struct auth_domain *dom; | ||
1563 | int i, err; | ||
1564 | struct in6_addr addr6; | ||
1565 | |||
1566 | /* First, consistency check. */ | ||
1567 | err = -EINVAL; | ||
1568 | if (! exp_verify_string(ncp->cl_ident, NFSCLNT_IDMAX)) | ||
1569 | goto out; | ||
1570 | if (ncp->cl_naddr > NFSCLNT_ADDRMAX) | ||
1571 | goto out; | ||
1572 | |||
1573 | /* Lock the hashtable */ | ||
1574 | exp_writelock(); | ||
1575 | |||
1576 | dom = unix_domain_find(ncp->cl_ident); | ||
1577 | |||
1578 | err = -ENOMEM; | ||
1579 | if (!dom) | ||
1580 | goto out_unlock; | ||
1581 | |||
1582 | /* Insert client into hashtable. */ | ||
1583 | for (i = 0; i < ncp->cl_naddr; i++) { | ||
1584 | ipv6_addr_set_v4mapped(ncp->cl_addrlist[i].s_addr, &addr6); | ||
1585 | auth_unix_add_addr(&init_net, &addr6, dom); | ||
1586 | } | ||
1587 | auth_unix_forget_old(dom); | ||
1588 | auth_domain_put(dom); | ||
1589 | |||
1590 | err = 0; | ||
1591 | |||
1592 | out_unlock: | ||
1593 | exp_writeunlock(); | ||
1594 | out: | ||
1595 | return err; | ||
1596 | } | ||
1597 | |||
1598 | /* | ||
1599 | * Delete a client given an identifier. | ||
1600 | */ | ||
1601 | int | ||
1602 | exp_delclient(struct nfsctl_client *ncp) | ||
1603 | { | ||
1604 | int err; | ||
1605 | struct auth_domain *dom; | ||
1606 | |||
1607 | err = -EINVAL; | ||
1608 | if (!exp_verify_string(ncp->cl_ident, NFSCLNT_IDMAX)) | ||
1609 | goto out; | ||
1610 | |||
1611 | /* Lock the hashtable */ | ||
1612 | exp_writelock(); | ||
1613 | |||
1614 | dom = auth_domain_find(ncp->cl_ident); | ||
1615 | /* just make sure that no addresses work | ||
1616 | * and that it will expire soon | ||
1617 | */ | ||
1618 | if (dom) { | ||
1619 | err = auth_unix_forget_old(dom); | ||
1620 | auth_domain_put(dom); | ||
1621 | } | ||
1622 | |||
1623 | exp_writeunlock(); | ||
1624 | out: | ||
1625 | return err; | ||
1626 | } | ||
1627 | |||
1628 | /* | ||
1629 | * Verify that string is non-empty and does not exceed max length. | ||
1630 | */ | ||
1631 | static int | ||
1632 | exp_verify_string(char *cp, int max) | ||
1633 | { | ||
1634 | int i; | ||
1635 | |||
1636 | for (i = 0; i < max; i++) | ||
1637 | if (!cp[i]) | ||
1638 | return i; | ||
1639 | cp[i] = 0; | ||
1640 | printk(KERN_NOTICE "nfsd: couldn't validate string %s\n", cp); | ||
1641 | return 0; | ||
1642 | } | ||
1643 | #endif /* CONFIG_NFSD_DEPRECATED */ | ||
1644 | 1231 | ||
1645 | /* | 1232 | /* |
1646 | * Initialize the exports module. | 1233 | * Initialize the exports module. |
@@ -1667,10 +1254,8 @@ nfsd_export_init(void) | |||
1667 | void | 1254 | void |
1668 | nfsd_export_flush(void) | 1255 | nfsd_export_flush(void) |
1669 | { | 1256 | { |
1670 | exp_writelock(); | ||
1671 | cache_purge(&svc_expkey_cache); | 1257 | cache_purge(&svc_expkey_cache); |
1672 | cache_purge(&svc_export_cache); | 1258 | cache_purge(&svc_export_cache); |
1673 | exp_writeunlock(); | ||
1674 | } | 1259 | } |
1675 | 1260 | ||
1676 | /* | 1261 | /* |
@@ -1682,12 +1267,9 @@ nfsd_export_shutdown(void) | |||
1682 | 1267 | ||
1683 | dprintk("nfsd: shutting down export module.\n"); | 1268 | dprintk("nfsd: shutting down export module.\n"); |
1684 | 1269 | ||
1685 | exp_writelock(); | ||
1686 | |||
1687 | cache_unregister(&svc_expkey_cache); | 1270 | cache_unregister(&svc_expkey_cache); |
1688 | cache_unregister(&svc_export_cache); | 1271 | cache_unregister(&svc_export_cache); |
1689 | svcauth_unix_purge(); | 1272 | svcauth_unix_purge(); |
1690 | 1273 | ||
1691 | exp_writeunlock(); | ||
1692 | dprintk("nfsd: export shutdown complete.\n"); | 1274 | dprintk("nfsd: export shutdown complete.\n"); |
1693 | } | 1275 | } |
diff --git a/fs/nfsd/lockd.c b/fs/nfsd/lockd.c index 7c831a2731fa..77e7a5cca888 100644 --- a/fs/nfsd/lockd.c +++ b/fs/nfsd/lockd.c | |||
@@ -35,10 +35,8 @@ nlm_fopen(struct svc_rqst *rqstp, struct nfs_fh *f, struct file **filp) | |||
35 | memcpy((char*)&fh.fh_handle.fh_base, f->data, f->size); | 35 | memcpy((char*)&fh.fh_handle.fh_base, f->data, f->size); |
36 | fh.fh_export = NULL; | 36 | fh.fh_export = NULL; |
37 | 37 | ||
38 | exp_readlock(); | ||
39 | nfserr = nfsd_open(rqstp, &fh, S_IFREG, NFSD_MAY_LOCK, filp); | 38 | nfserr = nfsd_open(rqstp, &fh, S_IFREG, NFSD_MAY_LOCK, filp); |
40 | fh_put(&fh); | 39 | fh_put(&fh); |
41 | exp_readunlock(); | ||
42 | /* We return nlm error codes as nlm doesn't know | 40 | /* We return nlm error codes as nlm doesn't know |
43 | * about nfsd, but nfsd does know about nlm.. | 41 | * about nfsd, but nfsd does know about nlm.. |
44 | */ | 42 | */ |
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 3a6dbd70b34b..e80777666618 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c | |||
@@ -291,6 +291,15 @@ nfsd4_open(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
291 | if (open->op_create && open->op_claim_type != NFS4_OPEN_CLAIM_NULL) | 291 | if (open->op_create && open->op_claim_type != NFS4_OPEN_CLAIM_NULL) |
292 | return nfserr_inval; | 292 | return nfserr_inval; |
293 | 293 | ||
294 | /* | ||
295 | * RFC5661 18.51.3 | ||
296 | * Before RECLAIM_COMPLETE done, server should deny new lock | ||
297 | */ | ||
298 | if (nfsd4_has_session(cstate) && | ||
299 | !cstate->session->se_client->cl_firststate && | ||
300 | open->op_claim_type != NFS4_OPEN_CLAIM_PREVIOUS) | ||
301 | return nfserr_grace; | ||
302 | |||
294 | if (nfsd4_has_session(cstate)) | 303 | if (nfsd4_has_session(cstate)) |
295 | copy_clientid(&open->op_clientid, cstate->session); | 304 | copy_clientid(&open->op_clientid, cstate->session); |
296 | 305 | ||
@@ -998,6 +1007,15 @@ struct nfsd4_operation { | |||
998 | nfsd4op_func op_func; | 1007 | nfsd4op_func op_func; |
999 | u32 op_flags; | 1008 | u32 op_flags; |
1000 | char *op_name; | 1009 | char *op_name; |
1010 | /* | ||
1011 | * We use the DRC for compounds containing non-idempotent | ||
1012 | * operations, *except* those that are 4.1-specific (since | ||
1013 | * sessions provide their own EOS), and except for stateful | ||
1014 | * operations other than setclientid and setclientid_confirm | ||
1015 | * (since sequence numbers provide EOS for open, lock, etc in | ||
1016 | * the v4.0 case). | ||
1017 | */ | ||
1018 | bool op_cacheresult; | ||
1001 | }; | 1019 | }; |
1002 | 1020 | ||
1003 | static struct nfsd4_operation nfsd4_ops[]; | 1021 | static struct nfsd4_operation nfsd4_ops[]; |
@@ -1042,6 +1060,11 @@ static inline struct nfsd4_operation *OPDESC(struct nfsd4_op *op) | |||
1042 | return &nfsd4_ops[op->opnum]; | 1060 | return &nfsd4_ops[op->opnum]; |
1043 | } | 1061 | } |
1044 | 1062 | ||
1063 | bool nfsd4_cache_this_op(struct nfsd4_op *op) | ||
1064 | { | ||
1065 | return OPDESC(op)->op_cacheresult; | ||
1066 | } | ||
1067 | |||
1045 | static bool need_wrongsec_check(struct svc_rqst *rqstp) | 1068 | static bool need_wrongsec_check(struct svc_rqst *rqstp) |
1046 | { | 1069 | { |
1047 | struct nfsd4_compoundres *resp = rqstp->rq_resp; | 1070 | struct nfsd4_compoundres *resp = rqstp->rq_resp; |
@@ -1209,7 +1232,6 @@ encode_op: | |||
1209 | fh_put(&resp->cstate.save_fh); | 1232 | fh_put(&resp->cstate.save_fh); |
1210 | BUG_ON(resp->cstate.replay_owner); | 1233 | BUG_ON(resp->cstate.replay_owner); |
1211 | out: | 1234 | out: |
1212 | nfsd4_release_compoundargs(args); | ||
1213 | /* Reset deferral mechanism for RPC deferrals */ | 1235 | /* Reset deferral mechanism for RPC deferrals */ |
1214 | rqstp->rq_usedeferral = 1; | 1236 | rqstp->rq_usedeferral = 1; |
1215 | dprintk("nfsv4 compound returned %d\n", ntohl(status)); | 1237 | dprintk("nfsv4 compound returned %d\n", ntohl(status)); |
@@ -1232,6 +1254,7 @@ static struct nfsd4_operation nfsd4_ops[] = { | |||
1232 | [OP_CREATE] = { | 1254 | [OP_CREATE] = { |
1233 | .op_func = (nfsd4op_func)nfsd4_create, | 1255 | .op_func = (nfsd4op_func)nfsd4_create, |
1234 | .op_name = "OP_CREATE", | 1256 | .op_name = "OP_CREATE", |
1257 | .op_cacheresult = true, | ||
1235 | }, | 1258 | }, |
1236 | [OP_DELEGRETURN] = { | 1259 | [OP_DELEGRETURN] = { |
1237 | .op_func = (nfsd4op_func)nfsd4_delegreturn, | 1260 | .op_func = (nfsd4op_func)nfsd4_delegreturn, |
@@ -1249,6 +1272,7 @@ static struct nfsd4_operation nfsd4_ops[] = { | |||
1249 | [OP_LINK] = { | 1272 | [OP_LINK] = { |
1250 | .op_func = (nfsd4op_func)nfsd4_link, | 1273 | .op_func = (nfsd4op_func)nfsd4_link, |
1251 | .op_name = "OP_LINK", | 1274 | .op_name = "OP_LINK", |
1275 | .op_cacheresult = true, | ||
1252 | }, | 1276 | }, |
1253 | [OP_LOCK] = { | 1277 | [OP_LOCK] = { |
1254 | .op_func = (nfsd4op_func)nfsd4_lock, | 1278 | .op_func = (nfsd4op_func)nfsd4_lock, |
@@ -1322,10 +1346,12 @@ static struct nfsd4_operation nfsd4_ops[] = { | |||
1322 | [OP_REMOVE] = { | 1346 | [OP_REMOVE] = { |
1323 | .op_func = (nfsd4op_func)nfsd4_remove, | 1347 | .op_func = (nfsd4op_func)nfsd4_remove, |
1324 | .op_name = "OP_REMOVE", | 1348 | .op_name = "OP_REMOVE", |
1349 | .op_cacheresult = true, | ||
1325 | }, | 1350 | }, |
1326 | [OP_RENAME] = { | 1351 | [OP_RENAME] = { |
1327 | .op_name = "OP_RENAME", | 1352 | .op_name = "OP_RENAME", |
1328 | .op_func = (nfsd4op_func)nfsd4_rename, | 1353 | .op_func = (nfsd4op_func)nfsd4_rename, |
1354 | .op_cacheresult = true, | ||
1329 | }, | 1355 | }, |
1330 | [OP_RENEW] = { | 1356 | [OP_RENEW] = { |
1331 | .op_func = (nfsd4op_func)nfsd4_renew, | 1357 | .op_func = (nfsd4op_func)nfsd4_renew, |
@@ -1351,16 +1377,19 @@ static struct nfsd4_operation nfsd4_ops[] = { | |||
1351 | [OP_SETATTR] = { | 1377 | [OP_SETATTR] = { |
1352 | .op_func = (nfsd4op_func)nfsd4_setattr, | 1378 | .op_func = (nfsd4op_func)nfsd4_setattr, |
1353 | .op_name = "OP_SETATTR", | 1379 | .op_name = "OP_SETATTR", |
1380 | .op_cacheresult = true, | ||
1354 | }, | 1381 | }, |
1355 | [OP_SETCLIENTID] = { | 1382 | [OP_SETCLIENTID] = { |
1356 | .op_func = (nfsd4op_func)nfsd4_setclientid, | 1383 | .op_func = (nfsd4op_func)nfsd4_setclientid, |
1357 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, | 1384 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, |
1358 | .op_name = "OP_SETCLIENTID", | 1385 | .op_name = "OP_SETCLIENTID", |
1386 | .op_cacheresult = true, | ||
1359 | }, | 1387 | }, |
1360 | [OP_SETCLIENTID_CONFIRM] = { | 1388 | [OP_SETCLIENTID_CONFIRM] = { |
1361 | .op_func = (nfsd4op_func)nfsd4_setclientid_confirm, | 1389 | .op_func = (nfsd4op_func)nfsd4_setclientid_confirm, |
1362 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, | 1390 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_ON_ABSENT_FS, |
1363 | .op_name = "OP_SETCLIENTID_CONFIRM", | 1391 | .op_name = "OP_SETCLIENTID_CONFIRM", |
1392 | .op_cacheresult = true, | ||
1364 | }, | 1393 | }, |
1365 | [OP_VERIFY] = { | 1394 | [OP_VERIFY] = { |
1366 | .op_func = (nfsd4op_func)nfsd4_verify, | 1395 | .op_func = (nfsd4op_func)nfsd4_verify, |
@@ -1369,6 +1398,7 @@ static struct nfsd4_operation nfsd4_ops[] = { | |||
1369 | [OP_WRITE] = { | 1398 | [OP_WRITE] = { |
1370 | .op_func = (nfsd4op_func)nfsd4_write, | 1399 | .op_func = (nfsd4op_func)nfsd4_write, |
1371 | .op_name = "OP_WRITE", | 1400 | .op_name = "OP_WRITE", |
1401 | .op_cacheresult = true, | ||
1372 | }, | 1402 | }, |
1373 | [OP_RELEASE_LOCKOWNER] = { | 1403 | [OP_RELEASE_LOCKOWNER] = { |
1374 | .op_func = (nfsd4op_func)nfsd4_release_lockowner, | 1404 | .op_func = (nfsd4op_func)nfsd4_release_lockowner, |
@@ -1402,6 +1432,11 @@ static struct nfsd4_operation nfsd4_ops[] = { | |||
1402 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_AS_FIRST_OP, | 1432 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_AS_FIRST_OP, |
1403 | .op_name = "OP_SEQUENCE", | 1433 | .op_name = "OP_SEQUENCE", |
1404 | }, | 1434 | }, |
1435 | [OP_DESTROY_CLIENTID] = { | ||
1436 | .op_func = NULL, | ||
1437 | .op_flags = ALLOWED_WITHOUT_FH | ALLOWED_AS_FIRST_OP, | ||
1438 | .op_name = "OP_DESTROY_CLIENTID", | ||
1439 | }, | ||
1405 | [OP_RECLAIM_COMPLETE] = { | 1440 | [OP_RECLAIM_COMPLETE] = { |
1406 | .op_func = (nfsd4op_func)nfsd4_reclaim_complete, | 1441 | .op_func = (nfsd4op_func)nfsd4_reclaim_complete, |
1407 | .op_flags = ALLOWED_WITHOUT_FH, | 1442 | .op_flags = ALLOWED_WITHOUT_FH, |
@@ -1412,6 +1447,16 @@ static struct nfsd4_operation nfsd4_ops[] = { | |||
1412 | .op_flags = OP_HANDLES_WRONGSEC, | 1447 | .op_flags = OP_HANDLES_WRONGSEC, |
1413 | .op_name = "OP_SECINFO_NO_NAME", | 1448 | .op_name = "OP_SECINFO_NO_NAME", |
1414 | }, | 1449 | }, |
1450 | [OP_TEST_STATEID] = { | ||
1451 | .op_func = (nfsd4op_func)nfsd4_test_stateid, | ||
1452 | .op_flags = ALLOWED_WITHOUT_FH, | ||
1453 | .op_name = "OP_TEST_STATEID", | ||
1454 | }, | ||
1455 | [OP_FREE_STATEID] = { | ||
1456 | .op_func = (nfsd4op_func)nfsd4_free_stateid, | ||
1457 | .op_flags = ALLOWED_WITHOUT_FH, | ||
1458 | .op_name = "OP_FREE_STATEID", | ||
1459 | }, | ||
1415 | }; | 1460 | }; |
1416 | 1461 | ||
1417 | static const char *nfsd4_op_name(unsigned opnum) | 1462 | static const char *nfsd4_op_name(unsigned opnum) |
@@ -1424,16 +1469,6 @@ static const char *nfsd4_op_name(unsigned opnum) | |||
1424 | #define nfsd4_voidres nfsd4_voidargs | 1469 | #define nfsd4_voidres nfsd4_voidargs |
1425 | struct nfsd4_voidargs { int dummy; }; | 1470 | struct nfsd4_voidargs { int dummy; }; |
1426 | 1471 | ||
1427 | /* | ||
1428 | * TODO: At the present time, the NFSv4 server does not do XID caching | ||
1429 | * of requests. Implementing XID caching would not be a serious problem, | ||
1430 | * although it would require a mild change in interfaces since one | ||
1431 | * doesn't know whether an NFSv4 request is idempotent until after the | ||
1432 | * XDR decode. However, XID caching totally confuses pynfs (Peter | ||
1433 | * Astrand's regression testsuite for NFSv4 servers), which reuses | ||
1434 | * XID's liberally, so I've left it unimplemented until pynfs generates | ||
1435 | * better XID's. | ||
1436 | */ | ||
1437 | static struct svc_procedure nfsd_procedures4[2] = { | 1472 | static struct svc_procedure nfsd_procedures4[2] = { |
1438 | [NFSPROC4_NULL] = { | 1473 | [NFSPROC4_NULL] = { |
1439 | .pc_func = (svc_procfunc) nfsd4_proc_null, | 1474 | .pc_func = (svc_procfunc) nfsd4_proc_null, |
@@ -1449,6 +1484,7 @@ static struct svc_procedure nfsd_procedures4[2] = { | |||
1449 | .pc_encode = (kxdrproc_t) nfs4svc_encode_compoundres, | 1484 | .pc_encode = (kxdrproc_t) nfs4svc_encode_compoundres, |
1450 | .pc_argsize = sizeof(struct nfsd4_compoundargs), | 1485 | .pc_argsize = sizeof(struct nfsd4_compoundargs), |
1451 | .pc_ressize = sizeof(struct nfsd4_compoundres), | 1486 | .pc_ressize = sizeof(struct nfsd4_compoundres), |
1487 | .pc_release = nfsd4_release_compoundargs, | ||
1452 | .pc_cachetype = RC_NOCACHE, | 1488 | .pc_cachetype = RC_NOCACHE, |
1453 | .pc_xdrressize = NFSD_BUFSIZE/4, | 1489 | .pc_xdrressize = NFSD_BUFSIZE/4, |
1454 | }, | 1490 | }, |
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index e98f3c2e9492..3787ec117400 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/slab.h> | 37 | #include <linux/slab.h> |
38 | #include <linux/namei.h> | 38 | #include <linux/namei.h> |
39 | #include <linux/swap.h> | 39 | #include <linux/swap.h> |
40 | #include <linux/pagemap.h> | ||
40 | #include <linux/sunrpc/svcauth_gss.h> | 41 | #include <linux/sunrpc/svcauth_gss.h> |
41 | #include <linux/sunrpc/clnt.h> | 42 | #include <linux/sunrpc/clnt.h> |
42 | #include "xdr4.h" | 43 | #include "xdr4.h" |
@@ -60,9 +61,12 @@ static u64 current_sessionid = 1; | |||
60 | 61 | ||
61 | /* forward declarations */ | 62 | /* forward declarations */ |
62 | static struct nfs4_stateid * find_stateid(stateid_t *stid, int flags); | 63 | static struct nfs4_stateid * find_stateid(stateid_t *stid, int flags); |
64 | static struct nfs4_stateid * search_for_stateid(stateid_t *stid); | ||
65 | static struct nfs4_delegation * search_for_delegation(stateid_t *stid); | ||
63 | static struct nfs4_delegation * find_delegation_stateid(struct inode *ino, stateid_t *stid); | 66 | static struct nfs4_delegation * find_delegation_stateid(struct inode *ino, stateid_t *stid); |
64 | static char user_recovery_dirname[PATH_MAX] = "/var/lib/nfs/v4recovery"; | 67 | static char user_recovery_dirname[PATH_MAX] = "/var/lib/nfs/v4recovery"; |
65 | static void nfs4_set_recdir(char *recdir); | 68 | static void nfs4_set_recdir(char *recdir); |
69 | static int check_for_locks(struct nfs4_file *filp, struct nfs4_stateowner *lowner); | ||
66 | 70 | ||
67 | /* Locking: */ | 71 | /* Locking: */ |
68 | 72 | ||
@@ -381,14 +385,6 @@ static int nfs4_access_to_omode(u32 access) | |||
381 | BUG(); | 385 | BUG(); |
382 | } | 386 | } |
383 | 387 | ||
384 | static int nfs4_access_bmap_to_omode(struct nfs4_stateid *stp) | ||
385 | { | ||
386 | unsigned int access; | ||
387 | |||
388 | set_access(&access, stp->st_access_bmap); | ||
389 | return nfs4_access_to_omode(access); | ||
390 | } | ||
391 | |||
392 | static void unhash_generic_stateid(struct nfs4_stateid *stp) | 388 | static void unhash_generic_stateid(struct nfs4_stateid *stp) |
393 | { | 389 | { |
394 | list_del(&stp->st_hash); | 390 | list_del(&stp->st_hash); |
@@ -398,11 +394,14 @@ static void unhash_generic_stateid(struct nfs4_stateid *stp) | |||
398 | 394 | ||
399 | static void free_generic_stateid(struct nfs4_stateid *stp) | 395 | static void free_generic_stateid(struct nfs4_stateid *stp) |
400 | { | 396 | { |
401 | int oflag; | 397 | int i; |
402 | 398 | ||
403 | if (stp->st_access_bmap) { | 399 | if (stp->st_access_bmap) { |
404 | oflag = nfs4_access_bmap_to_omode(stp); | 400 | for (i = 1; i < 4; i++) { |
405 | nfs4_file_put_access(stp->st_file, oflag); | 401 | if (test_bit(i, &stp->st_access_bmap)) |
402 | nfs4_file_put_access(stp->st_file, | ||
403 | nfs4_access_to_omode(i)); | ||
404 | } | ||
406 | } | 405 | } |
407 | put_nfs4_file(stp->st_file); | 406 | put_nfs4_file(stp->st_file); |
408 | kmem_cache_free(stateid_slab, stp); | 407 | kmem_cache_free(stateid_slab, stp); |
@@ -1507,6 +1506,29 @@ nfsd4_replay_create_session(struct nfsd4_create_session *cr_ses, | |||
1507 | return slot->sl_status; | 1506 | return slot->sl_status; |
1508 | } | 1507 | } |
1509 | 1508 | ||
1509 | #define NFSD_MIN_REQ_HDR_SEQ_SZ ((\ | ||
1510 | 2 * 2 + /* credential,verifier: AUTH_NULL, length 0 */ \ | ||
1511 | 1 + /* MIN tag is length with zero, only length */ \ | ||
1512 | 3 + /* version, opcount, opcode */ \ | ||
1513 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ | ||
1514 | /* seqid, slotID, slotID, cache */ \ | ||
1515 | 4 ) * sizeof(__be32)) | ||
1516 | |||
1517 | #define NFSD_MIN_RESP_HDR_SEQ_SZ ((\ | ||
1518 | 2 + /* verifier: AUTH_NULL, length 0 */\ | ||
1519 | 1 + /* status */ \ | ||
1520 | 1 + /* MIN tag is length with zero, only length */ \ | ||
1521 | 3 + /* opcount, opcode, opstatus*/ \ | ||
1522 | XDR_QUADLEN(NFS4_MAX_SESSIONID_LEN) + \ | ||
1523 | /* seqid, slotID, slotID, slotID, status */ \ | ||
1524 | 5 ) * sizeof(__be32)) | ||
1525 | |||
1526 | static __be32 check_forechannel_attrs(struct nfsd4_channel_attrs fchannel) | ||
1527 | { | ||
1528 | return fchannel.maxreq_sz < NFSD_MIN_REQ_HDR_SEQ_SZ | ||
1529 | || fchannel.maxresp_sz < NFSD_MIN_RESP_HDR_SEQ_SZ; | ||
1530 | } | ||
1531 | |||
1510 | __be32 | 1532 | __be32 |
1511 | nfsd4_create_session(struct svc_rqst *rqstp, | 1533 | nfsd4_create_session(struct svc_rqst *rqstp, |
1512 | struct nfsd4_compound_state *cstate, | 1534 | struct nfsd4_compound_state *cstate, |
@@ -1575,6 +1597,10 @@ nfsd4_create_session(struct svc_rqst *rqstp, | |||
1575 | cr_ses->flags &= ~SESSION4_PERSIST; | 1597 | cr_ses->flags &= ~SESSION4_PERSIST; |
1576 | cr_ses->flags &= ~SESSION4_RDMA; | 1598 | cr_ses->flags &= ~SESSION4_RDMA; |
1577 | 1599 | ||
1600 | status = nfserr_toosmall; | ||
1601 | if (check_forechannel_attrs(cr_ses->fore_channel)) | ||
1602 | goto out; | ||
1603 | |||
1578 | status = nfserr_jukebox; | 1604 | status = nfserr_jukebox; |
1579 | new = alloc_init_session(rqstp, conf, cr_ses); | 1605 | new = alloc_init_session(rqstp, conf, cr_ses); |
1580 | if (!new) | 1606 | if (!new) |
@@ -1736,6 +1762,14 @@ static bool nfsd4_session_too_many_ops(struct svc_rqst *rqstp, struct nfsd4_sess | |||
1736 | return args->opcnt > session->se_fchannel.maxops; | 1762 | return args->opcnt > session->se_fchannel.maxops; |
1737 | } | 1763 | } |
1738 | 1764 | ||
1765 | static bool nfsd4_request_too_big(struct svc_rqst *rqstp, | ||
1766 | struct nfsd4_session *session) | ||
1767 | { | ||
1768 | struct xdr_buf *xb = &rqstp->rq_arg; | ||
1769 | |||
1770 | return xb->len > session->se_fchannel.maxreq_sz; | ||
1771 | } | ||
1772 | |||
1739 | __be32 | 1773 | __be32 |
1740 | nfsd4_sequence(struct svc_rqst *rqstp, | 1774 | nfsd4_sequence(struct svc_rqst *rqstp, |
1741 | struct nfsd4_compound_state *cstate, | 1775 | struct nfsd4_compound_state *cstate, |
@@ -1768,6 +1802,10 @@ nfsd4_sequence(struct svc_rqst *rqstp, | |||
1768 | if (nfsd4_session_too_many_ops(rqstp, session)) | 1802 | if (nfsd4_session_too_many_ops(rqstp, session)) |
1769 | goto out; | 1803 | goto out; |
1770 | 1804 | ||
1805 | status = nfserr_req_too_big; | ||
1806 | if (nfsd4_request_too_big(rqstp, session)) | ||
1807 | goto out; | ||
1808 | |||
1771 | status = nfserr_badslot; | 1809 | status = nfserr_badslot; |
1772 | if (seq->slotid >= session->se_fchannel.maxreqs) | 1810 | if (seq->slotid >= session->se_fchannel.maxreqs) |
1773 | goto out; | 1811 | goto out; |
@@ -2337,15 +2375,6 @@ out: | |||
2337 | return ret; | 2375 | return ret; |
2338 | } | 2376 | } |
2339 | 2377 | ||
2340 | static inline void | ||
2341 | nfs4_file_downgrade(struct nfs4_file *fp, unsigned int share_access) | ||
2342 | { | ||
2343 | if (share_access & NFS4_SHARE_ACCESS_WRITE) | ||
2344 | nfs4_file_put_access(fp, O_WRONLY); | ||
2345 | if (share_access & NFS4_SHARE_ACCESS_READ) | ||
2346 | nfs4_file_put_access(fp, O_RDONLY); | ||
2347 | } | ||
2348 | |||
2349 | static void nfsd_break_one_deleg(struct nfs4_delegation *dp) | 2378 | static void nfsd_break_one_deleg(struct nfs4_delegation *dp) |
2350 | { | 2379 | { |
2351 | /* We're assuming the state code never drops its reference | 2380 | /* We're assuming the state code never drops its reference |
@@ -2396,8 +2425,8 @@ int nfsd_change_deleg_cb(struct file_lock **onlist, int arg) | |||
2396 | } | 2425 | } |
2397 | 2426 | ||
2398 | static const struct lock_manager_operations nfsd_lease_mng_ops = { | 2427 | static const struct lock_manager_operations nfsd_lease_mng_ops = { |
2399 | .fl_break = nfsd_break_deleg_cb, | 2428 | .lm_break = nfsd_break_deleg_cb, |
2400 | .fl_change = nfsd_change_deleg_cb, | 2429 | .lm_change = nfsd_change_deleg_cb, |
2401 | }; | 2430 | }; |
2402 | 2431 | ||
2403 | 2432 | ||
@@ -2556,12 +2585,18 @@ static inline int nfs4_access_to_access(u32 nfs4_access) | |||
2556 | return flags; | 2585 | return flags; |
2557 | } | 2586 | } |
2558 | 2587 | ||
2559 | static __be32 nfs4_get_vfs_file(struct svc_rqst *rqstp, struct nfs4_file | 2588 | static __be32 nfs4_get_vfs_file(struct svc_rqst *rqstp, struct nfs4_file *fp, |
2560 | *fp, struct svc_fh *cur_fh, u32 nfs4_access) | 2589 | struct svc_fh *cur_fh, struct nfsd4_open *open) |
2561 | { | 2590 | { |
2562 | __be32 status; | 2591 | __be32 status; |
2563 | int oflag = nfs4_access_to_omode(nfs4_access); | 2592 | int oflag = nfs4_access_to_omode(open->op_share_access); |
2564 | int access = nfs4_access_to_access(nfs4_access); | 2593 | int access = nfs4_access_to_access(open->op_share_access); |
2594 | |||
2595 | /* CLAIM_DELEGATE_CUR is used in response to a broken lease; | ||
2596 | * allowing it to break the lease and return EAGAIN leaves the | ||
2597 | * client unable to make progress in returning the delegation */ | ||
2598 | if (open->op_claim_type == NFS4_OPEN_CLAIM_DELEGATE_CUR) | ||
2599 | access |= NFSD_MAY_NOT_BREAK_LEASE; | ||
2565 | 2600 | ||
2566 | if (!fp->fi_fds[oflag]) { | 2601 | if (!fp->fi_fds[oflag]) { |
2567 | status = nfsd_open(rqstp, cur_fh, S_IFREG, access, | 2602 | status = nfsd_open(rqstp, cur_fh, S_IFREG, access, |
@@ -2586,7 +2621,7 @@ nfs4_new_open(struct svc_rqst *rqstp, struct nfs4_stateid **stpp, | |||
2586 | if (stp == NULL) | 2621 | if (stp == NULL) |
2587 | return nfserr_resource; | 2622 | return nfserr_resource; |
2588 | 2623 | ||
2589 | status = nfs4_get_vfs_file(rqstp, fp, cur_fh, open->op_share_access); | 2624 | status = nfs4_get_vfs_file(rqstp, fp, cur_fh, open); |
2590 | if (status) { | 2625 | if (status) { |
2591 | kmem_cache_free(stateid_slab, stp); | 2626 | kmem_cache_free(stateid_slab, stp); |
2592 | return status; | 2627 | return status; |
@@ -2619,14 +2654,14 @@ nfs4_upgrade_open(struct svc_rqst *rqstp, struct nfs4_file *fp, struct svc_fh *c | |||
2619 | 2654 | ||
2620 | new_access = !test_bit(op_share_access, &stp->st_access_bmap); | 2655 | new_access = !test_bit(op_share_access, &stp->st_access_bmap); |
2621 | if (new_access) { | 2656 | if (new_access) { |
2622 | status = nfs4_get_vfs_file(rqstp, fp, cur_fh, op_share_access); | 2657 | status = nfs4_get_vfs_file(rqstp, fp, cur_fh, open); |
2623 | if (status) | 2658 | if (status) |
2624 | return status; | 2659 | return status; |
2625 | } | 2660 | } |
2626 | status = nfsd4_truncate(rqstp, cur_fh, open); | 2661 | status = nfsd4_truncate(rqstp, cur_fh, open); |
2627 | if (status) { | 2662 | if (status) { |
2628 | if (new_access) { | 2663 | if (new_access) { |
2629 | int oflag = nfs4_access_to_omode(new_access); | 2664 | int oflag = nfs4_access_to_omode(op_share_access); |
2630 | nfs4_file_put_access(fp, oflag); | 2665 | nfs4_file_put_access(fp, oflag); |
2631 | } | 2666 | } |
2632 | return status; | 2667 | return status; |
@@ -3137,6 +3172,37 @@ static int is_delegation_stateid(stateid_t *stateid) | |||
3137 | return stateid->si_fileid == 0; | 3172 | return stateid->si_fileid == 0; |
3138 | } | 3173 | } |
3139 | 3174 | ||
3175 | static int is_open_stateid(struct nfs4_stateid *stateid) | ||
3176 | { | ||
3177 | return stateid->st_openstp == NULL; | ||
3178 | } | ||
3179 | |||
3180 | __be32 nfs4_validate_stateid(stateid_t *stateid, int flags) | ||
3181 | { | ||
3182 | struct nfs4_stateid *stp = NULL; | ||
3183 | __be32 status = nfserr_stale_stateid; | ||
3184 | |||
3185 | if (STALE_STATEID(stateid)) | ||
3186 | goto out; | ||
3187 | |||
3188 | status = nfserr_expired; | ||
3189 | stp = search_for_stateid(stateid); | ||
3190 | if (!stp) | ||
3191 | goto out; | ||
3192 | status = nfserr_bad_stateid; | ||
3193 | |||
3194 | if (!stp->st_stateowner->so_confirmed) | ||
3195 | goto out; | ||
3196 | |||
3197 | status = check_stateid_generation(stateid, &stp->st_stateid, flags); | ||
3198 | if (status) | ||
3199 | goto out; | ||
3200 | |||
3201 | status = nfs_ok; | ||
3202 | out: | ||
3203 | return status; | ||
3204 | } | ||
3205 | |||
3140 | /* | 3206 | /* |
3141 | * Checks for stateid operations | 3207 | * Checks for stateid operations |
3142 | */ | 3208 | */ |
@@ -3216,6 +3282,81 @@ out: | |||
3216 | return status; | 3282 | return status; |
3217 | } | 3283 | } |
3218 | 3284 | ||
3285 | static __be32 | ||
3286 | nfsd4_free_delegation_stateid(stateid_t *stateid) | ||
3287 | { | ||
3288 | struct nfs4_delegation *dp = search_for_delegation(stateid); | ||
3289 | if (dp) | ||
3290 | return nfserr_locks_held; | ||
3291 | return nfserr_bad_stateid; | ||
3292 | } | ||
3293 | |||
3294 | static __be32 | ||
3295 | nfsd4_free_lock_stateid(struct nfs4_stateid *stp) | ||
3296 | { | ||
3297 | if (check_for_locks(stp->st_file, stp->st_stateowner)) | ||
3298 | return nfserr_locks_held; | ||
3299 | release_lock_stateid(stp); | ||
3300 | return nfs_ok; | ||
3301 | } | ||
3302 | |||
3303 | /* | ||
3304 | * Test if the stateid is valid | ||
3305 | */ | ||
3306 | __be32 | ||
3307 | nfsd4_test_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | ||
3308 | struct nfsd4_test_stateid *test_stateid) | ||
3309 | { | ||
3310 | test_stateid->ts_has_session = nfsd4_has_session(cstate); | ||
3311 | return nfs_ok; | ||
3312 | } | ||
3313 | |||
3314 | /* | ||
3315 | * Free a state id | ||
3316 | */ | ||
3317 | __be32 | ||
3318 | nfsd4_free_stateid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | ||
3319 | struct nfsd4_free_stateid *free_stateid) | ||
3320 | { | ||
3321 | stateid_t *stateid = &free_stateid->fr_stateid; | ||
3322 | struct nfs4_stateid *stp; | ||
3323 | __be32 ret; | ||
3324 | |||
3325 | nfs4_lock_state(); | ||
3326 | if (is_delegation_stateid(stateid)) { | ||
3327 | ret = nfsd4_free_delegation_stateid(stateid); | ||
3328 | goto out; | ||
3329 | } | ||
3330 | |||
3331 | stp = search_for_stateid(stateid); | ||
3332 | if (!stp) { | ||
3333 | ret = nfserr_bad_stateid; | ||
3334 | goto out; | ||
3335 | } | ||
3336 | if (stateid->si_generation != 0) { | ||
3337 | if (stateid->si_generation < stp->st_stateid.si_generation) { | ||
3338 | ret = nfserr_old_stateid; | ||
3339 | goto out; | ||
3340 | } | ||
3341 | if (stateid->si_generation > stp->st_stateid.si_generation) { | ||
3342 | ret = nfserr_bad_stateid; | ||
3343 | goto out; | ||
3344 | } | ||
3345 | } | ||
3346 | |||
3347 | if (is_open_stateid(stp)) { | ||
3348 | ret = nfserr_locks_held; | ||
3349 | goto out; | ||
3350 | } else { | ||
3351 | ret = nfsd4_free_lock_stateid(stp); | ||
3352 | goto out; | ||
3353 | } | ||
3354 | |||
3355 | out: | ||
3356 | nfs4_unlock_state(); | ||
3357 | return ret; | ||
3358 | } | ||
3359 | |||
3219 | static inline int | 3360 | static inline int |
3220 | setlkflg (int type) | 3361 | setlkflg (int type) |
3221 | { | 3362 | { |
@@ -3384,18 +3525,15 @@ out: | |||
3384 | return status; | 3525 | return status; |
3385 | } | 3526 | } |
3386 | 3527 | ||
3387 | 3528 | static inline void nfs4_file_downgrade(struct nfs4_stateid *stp, unsigned int to_access) | |
3388 | /* | ||
3389 | * unset all bits in union bitmap (bmap) that | ||
3390 | * do not exist in share (from successful OPEN_DOWNGRADE) | ||
3391 | */ | ||
3392 | static void | ||
3393 | reset_union_bmap_access(unsigned long access, unsigned long *bmap) | ||
3394 | { | 3529 | { |
3395 | int i; | 3530 | int i; |
3531 | |||
3396 | for (i = 1; i < 4; i++) { | 3532 | for (i = 1; i < 4; i++) { |
3397 | if ((i & access) != i) | 3533 | if (test_bit(i, &stp->st_access_bmap) && !(i & to_access)) { |
3398 | __clear_bit(i, bmap); | 3534 | nfs4_file_put_access(stp->st_file, i); |
3535 | __clear_bit(i, &stp->st_access_bmap); | ||
3536 | } | ||
3399 | } | 3537 | } |
3400 | } | 3538 | } |
3401 | 3539 | ||
@@ -3416,7 +3554,6 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp, | |||
3416 | { | 3554 | { |
3417 | __be32 status; | 3555 | __be32 status; |
3418 | struct nfs4_stateid *stp; | 3556 | struct nfs4_stateid *stp; |
3419 | unsigned int share_access; | ||
3420 | 3557 | ||
3421 | dprintk("NFSD: nfsd4_open_downgrade on file %.*s\n", | 3558 | dprintk("NFSD: nfsd4_open_downgrade on file %.*s\n", |
3422 | (int)cstate->current_fh.fh_dentry->d_name.len, | 3559 | (int)cstate->current_fh.fh_dentry->d_name.len, |
@@ -3445,10 +3582,8 @@ nfsd4_open_downgrade(struct svc_rqst *rqstp, | |||
3445 | stp->st_deny_bmap, od->od_share_deny); | 3582 | stp->st_deny_bmap, od->od_share_deny); |
3446 | goto out; | 3583 | goto out; |
3447 | } | 3584 | } |
3448 | set_access(&share_access, stp->st_access_bmap); | 3585 | nfs4_file_downgrade(stp, od->od_share_access); |
3449 | nfs4_file_downgrade(stp->st_file, share_access & ~od->od_share_access); | ||
3450 | 3586 | ||
3451 | reset_union_bmap_access(od->od_share_access, &stp->st_access_bmap); | ||
3452 | reset_union_bmap_deny(od->od_share_deny, &stp->st_deny_bmap); | 3587 | reset_union_bmap_deny(od->od_share_deny, &stp->st_deny_bmap); |
3453 | 3588 | ||
3454 | update_stateid(&stp->st_stateid); | 3589 | update_stateid(&stp->st_stateid); |
@@ -3594,6 +3729,14 @@ static struct list_head lock_ownerid_hashtbl[LOCK_HASH_SIZE]; | |||
3594 | static struct list_head lock_ownerstr_hashtbl[LOCK_HASH_SIZE]; | 3729 | static struct list_head lock_ownerstr_hashtbl[LOCK_HASH_SIZE]; |
3595 | static struct list_head lockstateid_hashtbl[STATEID_HASH_SIZE]; | 3730 | static struct list_head lockstateid_hashtbl[STATEID_HASH_SIZE]; |
3596 | 3731 | ||
3732 | static int | ||
3733 | same_stateid(stateid_t *id_one, stateid_t *id_two) | ||
3734 | { | ||
3735 | if (id_one->si_stateownerid != id_two->si_stateownerid) | ||
3736 | return 0; | ||
3737 | return id_one->si_fileid == id_two->si_fileid; | ||
3738 | } | ||
3739 | |||
3597 | static struct nfs4_stateid * | 3740 | static struct nfs4_stateid * |
3598 | find_stateid(stateid_t *stid, int flags) | 3741 | find_stateid(stateid_t *stid, int flags) |
3599 | { | 3742 | { |
@@ -3623,6 +3766,44 @@ find_stateid(stateid_t *stid, int flags) | |||
3623 | return NULL; | 3766 | return NULL; |
3624 | } | 3767 | } |
3625 | 3768 | ||
3769 | static struct nfs4_stateid * | ||
3770 | search_for_stateid(stateid_t *stid) | ||
3771 | { | ||
3772 | struct nfs4_stateid *local; | ||
3773 | unsigned int hashval = stateid_hashval(stid->si_stateownerid, stid->si_fileid); | ||
3774 | |||
3775 | list_for_each_entry(local, &lockstateid_hashtbl[hashval], st_hash) { | ||
3776 | if (same_stateid(&local->st_stateid, stid)) | ||
3777 | return local; | ||
3778 | } | ||
3779 | |||
3780 | list_for_each_entry(local, &stateid_hashtbl[hashval], st_hash) { | ||
3781 | if (same_stateid(&local->st_stateid, stid)) | ||
3782 | return local; | ||
3783 | } | ||
3784 | return NULL; | ||
3785 | } | ||
3786 | |||
3787 | static struct nfs4_delegation * | ||
3788 | search_for_delegation(stateid_t *stid) | ||
3789 | { | ||
3790 | struct nfs4_file *fp; | ||
3791 | struct nfs4_delegation *dp; | ||
3792 | struct list_head *pos; | ||
3793 | int i; | ||
3794 | |||
3795 | for (i = 0; i < FILE_HASH_SIZE; i++) { | ||
3796 | list_for_each_entry(fp, &file_hashtbl[i], fi_hash) { | ||
3797 | list_for_each(pos, &fp->fi_delegations) { | ||
3798 | dp = list_entry(pos, struct nfs4_delegation, dl_perfile); | ||
3799 | if (same_stateid(&dp->dl_stateid, stid)) | ||
3800 | return dp; | ||
3801 | } | ||
3802 | } | ||
3803 | } | ||
3804 | return NULL; | ||
3805 | } | ||
3806 | |||
3626 | static struct nfs4_delegation * | 3807 | static struct nfs4_delegation * |
3627 | find_delegation_stateid(struct inode *ino, stateid_t *stid) | 3808 | find_delegation_stateid(struct inode *ino, stateid_t *stid) |
3628 | { | 3809 | { |
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 990181103214..c8bf405d19de 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c | |||
@@ -44,13 +44,15 @@ | |||
44 | #include <linux/namei.h> | 44 | #include <linux/namei.h> |
45 | #include <linux/statfs.h> | 45 | #include <linux/statfs.h> |
46 | #include <linux/utsname.h> | 46 | #include <linux/utsname.h> |
47 | #include <linux/pagemap.h> | ||
47 | #include <linux/sunrpc/svcauth_gss.h> | 48 | #include <linux/sunrpc/svcauth_gss.h> |
48 | 49 | ||
49 | #include "idmap.h" | 50 | #include "idmap.h" |
50 | #include "acl.h" | 51 | #include "acl.h" |
51 | #include "xdr4.h" | 52 | #include "xdr4.h" |
52 | #include "vfs.h" | 53 | #include "vfs.h" |
53 | 54 | #include "state.h" | |
55 | #include "cache.h" | ||
54 | 56 | ||
55 | #define NFSDDBG_FACILITY NFSDDBG_XDR | 57 | #define NFSDDBG_FACILITY NFSDDBG_XDR |
56 | 58 | ||
@@ -131,6 +133,22 @@ xdr_error: \ | |||
131 | } \ | 133 | } \ |
132 | } while (0) | 134 | } while (0) |
133 | 135 | ||
136 | static void save_buf(struct nfsd4_compoundargs *argp, struct nfsd4_saved_compoundargs *savep) | ||
137 | { | ||
138 | savep->p = argp->p; | ||
139 | savep->end = argp->end; | ||
140 | savep->pagelen = argp->pagelen; | ||
141 | savep->pagelist = argp->pagelist; | ||
142 | } | ||
143 | |||
144 | static void restore_buf(struct nfsd4_compoundargs *argp, struct nfsd4_saved_compoundargs *savep) | ||
145 | { | ||
146 | argp->p = savep->p; | ||
147 | argp->end = savep->end; | ||
148 | argp->pagelen = savep->pagelen; | ||
149 | argp->pagelist = savep->pagelist; | ||
150 | } | ||
151 | |||
134 | static __be32 *read_buf(struct nfsd4_compoundargs *argp, u32 nbytes) | 152 | static __be32 *read_buf(struct nfsd4_compoundargs *argp, u32 nbytes) |
135 | { | 153 | { |
136 | /* We want more bytes than seem to be available. | 154 | /* We want more bytes than seem to be available. |
@@ -1246,6 +1264,19 @@ nfsd4_decode_destroy_session(struct nfsd4_compoundargs *argp, | |||
1246 | } | 1264 | } |
1247 | 1265 | ||
1248 | static __be32 | 1266 | static __be32 |
1267 | nfsd4_decode_free_stateid(struct nfsd4_compoundargs *argp, | ||
1268 | struct nfsd4_free_stateid *free_stateid) | ||
1269 | { | ||
1270 | DECODE_HEAD; | ||
1271 | |||
1272 | READ_BUF(sizeof(stateid_t)); | ||
1273 | READ32(free_stateid->fr_stateid.si_generation); | ||
1274 | COPYMEM(&free_stateid->fr_stateid.si_opaque, sizeof(stateid_opaque_t)); | ||
1275 | |||
1276 | DECODE_TAIL; | ||
1277 | } | ||
1278 | |||
1279 | static __be32 | ||
1249 | nfsd4_decode_sequence(struct nfsd4_compoundargs *argp, | 1280 | nfsd4_decode_sequence(struct nfsd4_compoundargs *argp, |
1250 | struct nfsd4_sequence *seq) | 1281 | struct nfsd4_sequence *seq) |
1251 | { | 1282 | { |
@@ -1261,6 +1292,40 @@ nfsd4_decode_sequence(struct nfsd4_compoundargs *argp, | |||
1261 | DECODE_TAIL; | 1292 | DECODE_TAIL; |
1262 | } | 1293 | } |
1263 | 1294 | ||
1295 | static __be32 | ||
1296 | nfsd4_decode_test_stateid(struct nfsd4_compoundargs *argp, struct nfsd4_test_stateid *test_stateid) | ||
1297 | { | ||
1298 | unsigned int nbytes; | ||
1299 | stateid_t si; | ||
1300 | int i; | ||
1301 | __be32 *p; | ||
1302 | __be32 status; | ||
1303 | |||
1304 | READ_BUF(4); | ||
1305 | test_stateid->ts_num_ids = ntohl(*p++); | ||
1306 | |||
1307 | nbytes = test_stateid->ts_num_ids * sizeof(stateid_t); | ||
1308 | if (nbytes > (u32)((char *)argp->end - (char *)argp->p)) | ||
1309 | goto xdr_error; | ||
1310 | |||
1311 | test_stateid->ts_saved_args = argp; | ||
1312 | save_buf(argp, &test_stateid->ts_savedp); | ||
1313 | |||
1314 | for (i = 0; i < test_stateid->ts_num_ids; i++) { | ||
1315 | status = nfsd4_decode_stateid(argp, &si); | ||
1316 | if (status) | ||
1317 | return status; | ||
1318 | } | ||
1319 | |||
1320 | status = 0; | ||
1321 | out: | ||
1322 | return status; | ||
1323 | xdr_error: | ||
1324 | dprintk("NFSD: xdr error (%s:%d)\n", __FILE__, __LINE__); | ||
1325 | status = nfserr_bad_xdr; | ||
1326 | goto out; | ||
1327 | } | ||
1328 | |||
1264 | static __be32 nfsd4_decode_reclaim_complete(struct nfsd4_compoundargs *argp, struct nfsd4_reclaim_complete *rc) | 1329 | static __be32 nfsd4_decode_reclaim_complete(struct nfsd4_compoundargs *argp, struct nfsd4_reclaim_complete *rc) |
1265 | { | 1330 | { |
1266 | DECODE_HEAD; | 1331 | DECODE_HEAD; |
@@ -1370,7 +1435,7 @@ static nfsd4_dec nfsd41_dec_ops[] = { | |||
1370 | [OP_EXCHANGE_ID] = (nfsd4_dec)nfsd4_decode_exchange_id, | 1435 | [OP_EXCHANGE_ID] = (nfsd4_dec)nfsd4_decode_exchange_id, |
1371 | [OP_CREATE_SESSION] = (nfsd4_dec)nfsd4_decode_create_session, | 1436 | [OP_CREATE_SESSION] = (nfsd4_dec)nfsd4_decode_create_session, |
1372 | [OP_DESTROY_SESSION] = (nfsd4_dec)nfsd4_decode_destroy_session, | 1437 | [OP_DESTROY_SESSION] = (nfsd4_dec)nfsd4_decode_destroy_session, |
1373 | [OP_FREE_STATEID] = (nfsd4_dec)nfsd4_decode_notsupp, | 1438 | [OP_FREE_STATEID] = (nfsd4_dec)nfsd4_decode_free_stateid, |
1374 | [OP_GET_DIR_DELEGATION] = (nfsd4_dec)nfsd4_decode_notsupp, | 1439 | [OP_GET_DIR_DELEGATION] = (nfsd4_dec)nfsd4_decode_notsupp, |
1375 | [OP_GETDEVICEINFO] = (nfsd4_dec)nfsd4_decode_notsupp, | 1440 | [OP_GETDEVICEINFO] = (nfsd4_dec)nfsd4_decode_notsupp, |
1376 | [OP_GETDEVICELIST] = (nfsd4_dec)nfsd4_decode_notsupp, | 1441 | [OP_GETDEVICELIST] = (nfsd4_dec)nfsd4_decode_notsupp, |
@@ -1380,7 +1445,7 @@ static nfsd4_dec nfsd41_dec_ops[] = { | |||
1380 | [OP_SECINFO_NO_NAME] = (nfsd4_dec)nfsd4_decode_secinfo_no_name, | 1445 | [OP_SECINFO_NO_NAME] = (nfsd4_dec)nfsd4_decode_secinfo_no_name, |
1381 | [OP_SEQUENCE] = (nfsd4_dec)nfsd4_decode_sequence, | 1446 | [OP_SEQUENCE] = (nfsd4_dec)nfsd4_decode_sequence, |
1382 | [OP_SET_SSV] = (nfsd4_dec)nfsd4_decode_notsupp, | 1447 | [OP_SET_SSV] = (nfsd4_dec)nfsd4_decode_notsupp, |
1383 | [OP_TEST_STATEID] = (nfsd4_dec)nfsd4_decode_notsupp, | 1448 | [OP_TEST_STATEID] = (nfsd4_dec)nfsd4_decode_test_stateid, |
1384 | [OP_WANT_DELEGATION] = (nfsd4_dec)nfsd4_decode_notsupp, | 1449 | [OP_WANT_DELEGATION] = (nfsd4_dec)nfsd4_decode_notsupp, |
1385 | [OP_DESTROY_CLIENTID] = (nfsd4_dec)nfsd4_decode_notsupp, | 1450 | [OP_DESTROY_CLIENTID] = (nfsd4_dec)nfsd4_decode_notsupp, |
1386 | [OP_RECLAIM_COMPLETE] = (nfsd4_dec)nfsd4_decode_reclaim_complete, | 1451 | [OP_RECLAIM_COMPLETE] = (nfsd4_dec)nfsd4_decode_reclaim_complete, |
@@ -1402,6 +1467,7 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp) | |||
1402 | DECODE_HEAD; | 1467 | DECODE_HEAD; |
1403 | struct nfsd4_op *op; | 1468 | struct nfsd4_op *op; |
1404 | struct nfsd4_minorversion_ops *ops; | 1469 | struct nfsd4_minorversion_ops *ops; |
1470 | bool cachethis = false; | ||
1405 | int i; | 1471 | int i; |
1406 | 1472 | ||
1407 | /* | 1473 | /* |
@@ -1483,7 +1549,16 @@ nfsd4_decode_compound(struct nfsd4_compoundargs *argp) | |||
1483 | argp->opcnt = i+1; | 1549 | argp->opcnt = i+1; |
1484 | break; | 1550 | break; |
1485 | } | 1551 | } |
1552 | /* | ||
1553 | * We'll try to cache the result in the DRC if any one | ||
1554 | * op in the compound wants to be cached: | ||
1555 | */ | ||
1556 | cachethis |= nfsd4_cache_this_op(op); | ||
1486 | } | 1557 | } |
1558 | /* Sessions make the DRC unnecessary: */ | ||
1559 | if (argp->minorversion) | ||
1560 | cachethis = false; | ||
1561 | argp->rqstp->rq_cachetype = cachethis ? RC_REPLBUFF : RC_NOCACHE; | ||
1487 | 1562 | ||
1488 | DECODE_TAIL; | 1563 | DECODE_TAIL; |
1489 | } | 1564 | } |
@@ -3116,6 +3191,21 @@ nfsd4_encode_destroy_session(struct nfsd4_compoundres *resp, int nfserr, | |||
3116 | } | 3191 | } |
3117 | 3192 | ||
3118 | static __be32 | 3193 | static __be32 |
3194 | nfsd4_encode_free_stateid(struct nfsd4_compoundres *resp, int nfserr, | ||
3195 | struct nfsd4_free_stateid *free_stateid) | ||
3196 | { | ||
3197 | __be32 *p; | ||
3198 | |||
3199 | if (nfserr) | ||
3200 | return nfserr; | ||
3201 | |||
3202 | RESERVE_SPACE(4); | ||
3203 | WRITE32(nfserr); | ||
3204 | ADJUST_ARGS(); | ||
3205 | return nfserr; | ||
3206 | } | ||
3207 | |||
3208 | static __be32 | ||
3119 | nfsd4_encode_sequence(struct nfsd4_compoundres *resp, int nfserr, | 3209 | nfsd4_encode_sequence(struct nfsd4_compoundres *resp, int nfserr, |
3120 | struct nfsd4_sequence *seq) | 3210 | struct nfsd4_sequence *seq) |
3121 | { | 3211 | { |
@@ -3138,6 +3228,36 @@ nfsd4_encode_sequence(struct nfsd4_compoundres *resp, int nfserr, | |||
3138 | return 0; | 3228 | return 0; |
3139 | } | 3229 | } |
3140 | 3230 | ||
3231 | __be32 | ||
3232 | nfsd4_encode_test_stateid(struct nfsd4_compoundres *resp, int nfserr, | ||
3233 | struct nfsd4_test_stateid *test_stateid) | ||
3234 | { | ||
3235 | struct nfsd4_compoundargs *argp; | ||
3236 | stateid_t si; | ||
3237 | __be32 *p; | ||
3238 | int i; | ||
3239 | int valid; | ||
3240 | |||
3241 | restore_buf(test_stateid->ts_saved_args, &test_stateid->ts_savedp); | ||
3242 | argp = test_stateid->ts_saved_args; | ||
3243 | |||
3244 | RESERVE_SPACE(4); | ||
3245 | *p++ = htonl(test_stateid->ts_num_ids); | ||
3246 | resp->p = p; | ||
3247 | |||
3248 | nfs4_lock_state(); | ||
3249 | for (i = 0; i < test_stateid->ts_num_ids; i++) { | ||
3250 | nfsd4_decode_stateid(argp, &si); | ||
3251 | valid = nfs4_validate_stateid(&si, test_stateid->ts_has_session); | ||
3252 | RESERVE_SPACE(4); | ||
3253 | *p++ = htonl(valid); | ||
3254 | resp->p = p; | ||
3255 | } | ||
3256 | nfs4_unlock_state(); | ||
3257 | |||
3258 | return nfserr; | ||
3259 | } | ||
3260 | |||
3141 | static __be32 | 3261 | static __be32 |
3142 | nfsd4_encode_noop(struct nfsd4_compoundres *resp, __be32 nfserr, void *p) | 3262 | nfsd4_encode_noop(struct nfsd4_compoundres *resp, __be32 nfserr, void *p) |
3143 | { | 3263 | { |
@@ -3196,7 +3316,7 @@ static nfsd4_enc nfsd4_enc_ops[] = { | |||
3196 | [OP_EXCHANGE_ID] = (nfsd4_enc)nfsd4_encode_exchange_id, | 3316 | [OP_EXCHANGE_ID] = (nfsd4_enc)nfsd4_encode_exchange_id, |
3197 | [OP_CREATE_SESSION] = (nfsd4_enc)nfsd4_encode_create_session, | 3317 | [OP_CREATE_SESSION] = (nfsd4_enc)nfsd4_encode_create_session, |
3198 | [OP_DESTROY_SESSION] = (nfsd4_enc)nfsd4_encode_destroy_session, | 3318 | [OP_DESTROY_SESSION] = (nfsd4_enc)nfsd4_encode_destroy_session, |
3199 | [OP_FREE_STATEID] = (nfsd4_enc)nfsd4_encode_noop, | 3319 | [OP_FREE_STATEID] = (nfsd4_enc)nfsd4_encode_free_stateid, |
3200 | [OP_GET_DIR_DELEGATION] = (nfsd4_enc)nfsd4_encode_noop, | 3320 | [OP_GET_DIR_DELEGATION] = (nfsd4_enc)nfsd4_encode_noop, |
3201 | [OP_GETDEVICEINFO] = (nfsd4_enc)nfsd4_encode_noop, | 3321 | [OP_GETDEVICEINFO] = (nfsd4_enc)nfsd4_encode_noop, |
3202 | [OP_GETDEVICELIST] = (nfsd4_enc)nfsd4_encode_noop, | 3322 | [OP_GETDEVICELIST] = (nfsd4_enc)nfsd4_encode_noop, |
@@ -3206,7 +3326,7 @@ static nfsd4_enc nfsd4_enc_ops[] = { | |||
3206 | [OP_SECINFO_NO_NAME] = (nfsd4_enc)nfsd4_encode_secinfo_no_name, | 3326 | [OP_SECINFO_NO_NAME] = (nfsd4_enc)nfsd4_encode_secinfo_no_name, |
3207 | [OP_SEQUENCE] = (nfsd4_enc)nfsd4_encode_sequence, | 3327 | [OP_SEQUENCE] = (nfsd4_enc)nfsd4_encode_sequence, |
3208 | [OP_SET_SSV] = (nfsd4_enc)nfsd4_encode_noop, | 3328 | [OP_SET_SSV] = (nfsd4_enc)nfsd4_encode_noop, |
3209 | [OP_TEST_STATEID] = (nfsd4_enc)nfsd4_encode_noop, | 3329 | [OP_TEST_STATEID] = (nfsd4_enc)nfsd4_encode_test_stateid, |
3210 | [OP_WANT_DELEGATION] = (nfsd4_enc)nfsd4_encode_noop, | 3330 | [OP_WANT_DELEGATION] = (nfsd4_enc)nfsd4_encode_noop, |
3211 | [OP_DESTROY_CLIENTID] = (nfsd4_enc)nfsd4_encode_noop, | 3331 | [OP_DESTROY_CLIENTID] = (nfsd4_enc)nfsd4_encode_noop, |
3212 | [OP_RECLAIM_COMPLETE] = (nfsd4_enc)nfsd4_encode_noop, | 3332 | [OP_RECLAIM_COMPLETE] = (nfsd4_enc)nfsd4_encode_noop, |
@@ -3319,8 +3439,11 @@ nfs4svc_encode_voidres(struct svc_rqst *rqstp, __be32 *p, void *dummy) | |||
3319 | return xdr_ressize_check(rqstp, p); | 3439 | return xdr_ressize_check(rqstp, p); |
3320 | } | 3440 | } |
3321 | 3441 | ||
3322 | void nfsd4_release_compoundargs(struct nfsd4_compoundargs *args) | 3442 | int nfsd4_release_compoundargs(void *rq, __be32 *p, void *resp) |
3323 | { | 3443 | { |
3444 | struct svc_rqst *rqstp = rq; | ||
3445 | struct nfsd4_compoundargs *args = rqstp->rq_argp; | ||
3446 | |||
3324 | if (args->ops != args->iops) { | 3447 | if (args->ops != args->iops) { |
3325 | kfree(args->ops); | 3448 | kfree(args->ops); |
3326 | args->ops = args->iops; | 3449 | args->ops = args->iops; |
@@ -3333,13 +3456,12 @@ void nfsd4_release_compoundargs(struct nfsd4_compoundargs *args) | |||
3333 | tb->release(tb->buf); | 3456 | tb->release(tb->buf); |
3334 | kfree(tb); | 3457 | kfree(tb); |
3335 | } | 3458 | } |
3459 | return 1; | ||
3336 | } | 3460 | } |
3337 | 3461 | ||
3338 | int | 3462 | int |
3339 | nfs4svc_decode_compoundargs(struct svc_rqst *rqstp, __be32 *p, struct nfsd4_compoundargs *args) | 3463 | nfs4svc_decode_compoundargs(struct svc_rqst *rqstp, __be32 *p, struct nfsd4_compoundargs *args) |
3340 | { | 3464 | { |
3341 | __be32 status; | ||
3342 | |||
3343 | args->p = p; | 3465 | args->p = p; |
3344 | args->end = rqstp->rq_arg.head[0].iov_base + rqstp->rq_arg.head[0].iov_len; | 3466 | args->end = rqstp->rq_arg.head[0].iov_base + rqstp->rq_arg.head[0].iov_len; |
3345 | args->pagelist = rqstp->rq_arg.pages; | 3467 | args->pagelist = rqstp->rq_arg.pages; |
@@ -3349,11 +3471,7 @@ nfs4svc_decode_compoundargs(struct svc_rqst *rqstp, __be32 *p, struct nfsd4_comp | |||
3349 | args->ops = args->iops; | 3471 | args->ops = args->iops; |
3350 | args->rqstp = rqstp; | 3472 | args->rqstp = rqstp; |
3351 | 3473 | ||
3352 | status = nfsd4_decode_compound(args); | 3474 | return !nfsd4_decode_compound(args); |
3353 | if (status) { | ||
3354 | nfsd4_release_compoundargs(args); | ||
3355 | } | ||
3356 | return !status; | ||
3357 | } | 3475 | } |
3358 | 3476 | ||
3359 | int | 3477 | int |
diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c index 4666a209678a..2cbac34a55da 100644 --- a/fs/nfsd/nfscache.c +++ b/fs/nfsd/nfscache.c | |||
@@ -118,7 +118,7 @@ hash_refile(struct svc_cacherep *rp) | |||
118 | * Note that no operation within the loop may sleep. | 118 | * Note that no operation within the loop may sleep. |
119 | */ | 119 | */ |
120 | int | 120 | int |
121 | nfsd_cache_lookup(struct svc_rqst *rqstp, int type) | 121 | nfsd_cache_lookup(struct svc_rqst *rqstp) |
122 | { | 122 | { |
123 | struct hlist_node *hn; | 123 | struct hlist_node *hn; |
124 | struct hlist_head *rh; | 124 | struct hlist_head *rh; |
@@ -128,6 +128,7 @@ nfsd_cache_lookup(struct svc_rqst *rqstp, int type) | |||
128 | vers = rqstp->rq_vers, | 128 | vers = rqstp->rq_vers, |
129 | proc = rqstp->rq_proc; | 129 | proc = rqstp->rq_proc; |
130 | unsigned long age; | 130 | unsigned long age; |
131 | int type = rqstp->rq_cachetype; | ||
131 | int rtn; | 132 | int rtn; |
132 | 133 | ||
133 | rqstp->rq_cacherep = NULL; | 134 | rqstp->rq_cacherep = NULL; |
diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c index 2b1449dd2f49..c7716143cbd1 100644 --- a/fs/nfsd/nfsctl.c +++ b/fs/nfsd/nfsctl.c | |||
@@ -24,15 +24,6 @@ | |||
24 | */ | 24 | */ |
25 | enum { | 25 | enum { |
26 | NFSD_Root = 1, | 26 | NFSD_Root = 1, |
27 | #ifdef CONFIG_NFSD_DEPRECATED | ||
28 | NFSD_Svc, | ||
29 | NFSD_Add, | ||
30 | NFSD_Del, | ||
31 | NFSD_Export, | ||
32 | NFSD_Unexport, | ||
33 | NFSD_Getfd, | ||
34 | NFSD_Getfs, | ||
35 | #endif | ||
36 | NFSD_List, | 27 | NFSD_List, |
37 | NFSD_Export_features, | 28 | NFSD_Export_features, |
38 | NFSD_Fh, | 29 | NFSD_Fh, |
@@ -59,15 +50,6 @@ enum { | |||
59 | /* | 50 | /* |
60 | * write() for these nodes. | 51 | * write() for these nodes. |
61 | */ | 52 | */ |
62 | #ifdef CONFIG_NFSD_DEPRECATED | ||
63 | static ssize_t write_svc(struct file *file, char *buf, size_t size); | ||
64 | static ssize_t write_add(struct file *file, char *buf, size_t size); | ||
65 | static ssize_t write_del(struct file *file, char *buf, size_t size); | ||
66 | static ssize_t write_export(struct file *file, char *buf, size_t size); | ||
67 | static ssize_t write_unexport(struct file *file, char *buf, size_t size); | ||
68 | static ssize_t write_getfd(struct file *file, char *buf, size_t size); | ||
69 | static ssize_t write_getfs(struct file *file, char *buf, size_t size); | ||
70 | #endif | ||
71 | static ssize_t write_filehandle(struct file *file, char *buf, size_t size); | 53 | static ssize_t write_filehandle(struct file *file, char *buf, size_t size); |
72 | static ssize_t write_unlock_ip(struct file *file, char *buf, size_t size); | 54 | static ssize_t write_unlock_ip(struct file *file, char *buf, size_t size); |
73 | static ssize_t write_unlock_fs(struct file *file, char *buf, size_t size); | 55 | static ssize_t write_unlock_fs(struct file *file, char *buf, size_t size); |
@@ -83,15 +65,6 @@ static ssize_t write_recoverydir(struct file *file, char *buf, size_t size); | |||
83 | #endif | 65 | #endif |
84 | 66 | ||
85 | static ssize_t (*write_op[])(struct file *, char *, size_t) = { | 67 | static ssize_t (*write_op[])(struct file *, char *, size_t) = { |
86 | #ifdef CONFIG_NFSD_DEPRECATED | ||
87 | [NFSD_Svc] = write_svc, | ||
88 | [NFSD_Add] = write_add, | ||
89 | [NFSD_Del] = write_del, | ||
90 | [NFSD_Export] = write_export, | ||
91 | [NFSD_Unexport] = write_unexport, | ||
92 | [NFSD_Getfd] = write_getfd, | ||
93 | [NFSD_Getfs] = write_getfs, | ||
94 | #endif | ||
95 | [NFSD_Fh] = write_filehandle, | 68 | [NFSD_Fh] = write_filehandle, |
96 | [NFSD_FO_UnlockIP] = write_unlock_ip, | 69 | [NFSD_FO_UnlockIP] = write_unlock_ip, |
97 | [NFSD_FO_UnlockFS] = write_unlock_fs, | 70 | [NFSD_FO_UnlockFS] = write_unlock_fs, |
@@ -130,16 +103,6 @@ static ssize_t nfsctl_transaction_write(struct file *file, const char __user *bu | |||
130 | 103 | ||
131 | static ssize_t nfsctl_transaction_read(struct file *file, char __user *buf, size_t size, loff_t *pos) | 104 | static ssize_t nfsctl_transaction_read(struct file *file, char __user *buf, size_t size, loff_t *pos) |
132 | { | 105 | { |
133 | #ifdef CONFIG_NFSD_DEPRECATED | ||
134 | static int warned; | ||
135 | if (file->f_dentry->d_name.name[0] == '.' && !warned) { | ||
136 | printk(KERN_INFO | ||
137 | "Warning: \"%s\" uses deprecated NFSD interface: %s." | ||
138 | " This will be removed in 2.6.40\n", | ||
139 | current->comm, file->f_dentry->d_name.name); | ||
140 | warned = 1; | ||
141 | } | ||
142 | #endif | ||
143 | if (! file->private_data) { | 106 | if (! file->private_data) { |
144 | /* An attempt to read a transaction file without writing | 107 | /* An attempt to read a transaction file without writing |
145 | * causes a 0-byte write so that the file can return | 108 | * causes a 0-byte write so that the file can return |
@@ -226,303 +189,6 @@ static const struct file_operations pool_stats_operations = { | |||
226 | * payload - write methods | 189 | * payload - write methods |
227 | */ | 190 | */ |
228 | 191 | ||
229 | #ifdef CONFIG_NFSD_DEPRECATED | ||
230 | /** | ||
231 | * write_svc - Start kernel's NFSD server | ||
232 | * | ||
233 | * Deprecated. /proc/fs/nfsd/threads is preferred. | ||
234 | * Function remains to support old versions of nfs-utils. | ||
235 | * | ||
236 | * Input: | ||
237 | * buf: struct nfsctl_svc | ||
238 | * svc_port: port number of this | ||
239 | * server's listener | ||
240 | * svc_nthreads: number of threads to start | ||
241 | * size: size in bytes of passed in nfsctl_svc | ||
242 | * Output: | ||
243 | * On success: returns zero | ||
244 | * On error: return code is negative errno value | ||
245 | */ | ||
246 | static ssize_t write_svc(struct file *file, char *buf, size_t size) | ||
247 | { | ||
248 | struct nfsctl_svc *data; | ||
249 | int err; | ||
250 | if (size < sizeof(*data)) | ||
251 | return -EINVAL; | ||
252 | data = (struct nfsctl_svc*) buf; | ||
253 | err = nfsd_svc(data->svc_port, data->svc_nthreads); | ||
254 | if (err < 0) | ||
255 | return err; | ||
256 | return 0; | ||
257 | } | ||
258 | |||
259 | /** | ||
260 | * write_add - Add or modify client entry in auth unix cache | ||
261 | * | ||
262 | * Deprecated. /proc/net/rpc/auth.unix.ip is preferred. | ||
263 | * Function remains to support old versions of nfs-utils. | ||
264 | * | ||
265 | * Input: | ||
266 | * buf: struct nfsctl_client | ||
267 | * cl_ident: '\0'-terminated C string | ||
268 | * containing domain name | ||
269 | * of client | ||
270 | * cl_naddr: no. of items in cl_addrlist | ||
271 | * cl_addrlist: array of client addresses | ||
272 | * cl_fhkeytype: ignored | ||
273 | * cl_fhkeylen: ignored | ||
274 | * cl_fhkey: ignored | ||
275 | * size: size in bytes of passed in nfsctl_client | ||
276 | * Output: | ||
277 | * On success: returns zero | ||
278 | * On error: return code is negative errno value | ||
279 | * | ||
280 | * Note: Only AF_INET client addresses are passed in, since | ||
281 | * nfsctl_client.cl_addrlist contains only in_addr fields for addresses. | ||
282 | */ | ||
283 | static ssize_t write_add(struct file *file, char *buf, size_t size) | ||
284 | { | ||
285 | struct nfsctl_client *data; | ||
286 | if (size < sizeof(*data)) | ||
287 | return -EINVAL; | ||
288 | data = (struct nfsctl_client *)buf; | ||
289 | return exp_addclient(data); | ||
290 | } | ||
291 | |||
292 | /** | ||
293 | * write_del - Remove client from auth unix cache | ||
294 | * | ||
295 | * Deprecated. /proc/net/rpc/auth.unix.ip is preferred. | ||
296 | * Function remains to support old versions of nfs-utils. | ||
297 | * | ||
298 | * Input: | ||
299 | * buf: struct nfsctl_client | ||
300 | * cl_ident: '\0'-terminated C string | ||
301 | * containing domain name | ||
302 | * of client | ||
303 | * cl_naddr: ignored | ||
304 | * cl_addrlist: ignored | ||
305 | * cl_fhkeytype: ignored | ||
306 | * cl_fhkeylen: ignored | ||
307 | * cl_fhkey: ignored | ||
308 | * size: size in bytes of passed in nfsctl_client | ||
309 | * Output: | ||
310 | * On success: returns zero | ||
311 | * On error: return code is negative errno value | ||
312 | * | ||
313 | * Note: Only AF_INET client addresses are passed in, since | ||
314 | * nfsctl_client.cl_addrlist contains only in_addr fields for addresses. | ||
315 | */ | ||
316 | static ssize_t write_del(struct file *file, char *buf, size_t size) | ||
317 | { | ||
318 | struct nfsctl_client *data; | ||
319 | if (size < sizeof(*data)) | ||
320 | return -EINVAL; | ||
321 | data = (struct nfsctl_client *)buf; | ||
322 | return exp_delclient(data); | ||
323 | } | ||
324 | |||
325 | /** | ||
326 | * write_export - Export part or all of a local file system | ||
327 | * | ||
328 | * Deprecated. /proc/net/rpc/{nfsd.export,nfsd.fh} are preferred. | ||
329 | * Function remains to support old versions of nfs-utils. | ||
330 | * | ||
331 | * Input: | ||
332 | * buf: struct nfsctl_export | ||
333 | * ex_client: '\0'-terminated C string | ||
334 | * containing domain name | ||
335 | * of client allowed to access | ||
336 | * this export | ||
337 | * ex_path: '\0'-terminated C string | ||
338 | * containing pathname of | ||
339 | * directory in local file system | ||
340 | * ex_dev: fsid to use for this export | ||
341 | * ex_ino: ignored | ||
342 | * ex_flags: export flags for this export | ||
343 | * ex_anon_uid: UID to use for anonymous | ||
344 | * requests | ||
345 | * ex_anon_gid: GID to use for anonymous | ||
346 | * requests | ||
347 | * size: size in bytes of passed in nfsctl_export | ||
348 | * Output: | ||
349 | * On success: returns zero | ||
350 | * On error: return code is negative errno value | ||
351 | */ | ||
352 | static ssize_t write_export(struct file *file, char *buf, size_t size) | ||
353 | { | ||
354 | struct nfsctl_export *data; | ||
355 | if (size < sizeof(*data)) | ||
356 | return -EINVAL; | ||
357 | data = (struct nfsctl_export*)buf; | ||
358 | return exp_export(data); | ||
359 | } | ||
360 | |||
361 | /** | ||
362 | * write_unexport - Unexport a previously exported file system | ||
363 | * | ||
364 | * Deprecated. /proc/net/rpc/{nfsd.export,nfsd.fh} are preferred. | ||
365 | * Function remains to support old versions of nfs-utils. | ||
366 | * | ||
367 | * Input: | ||
368 | * buf: struct nfsctl_export | ||
369 | * ex_client: '\0'-terminated C string | ||
370 | * containing domain name | ||
371 | * of client no longer allowed | ||
372 | * to access this export | ||
373 | * ex_path: '\0'-terminated C string | ||
374 | * containing pathname of | ||
375 | * directory in local file system | ||
376 | * ex_dev: ignored | ||
377 | * ex_ino: ignored | ||
378 | * ex_flags: ignored | ||
379 | * ex_anon_uid: ignored | ||
380 | * ex_anon_gid: ignored | ||
381 | * size: size in bytes of passed in nfsctl_export | ||
382 | * Output: | ||
383 | * On success: returns zero | ||
384 | * On error: return code is negative errno value | ||
385 | */ | ||
386 | static ssize_t write_unexport(struct file *file, char *buf, size_t size) | ||
387 | { | ||
388 | struct nfsctl_export *data; | ||
389 | |||
390 | if (size < sizeof(*data)) | ||
391 | return -EINVAL; | ||
392 | data = (struct nfsctl_export*)buf; | ||
393 | return exp_unexport(data); | ||
394 | } | ||
395 | |||
396 | /** | ||
397 | * write_getfs - Get a variable-length NFS file handle by path | ||
398 | * | ||
399 | * Deprecated. /proc/fs/nfsd/filehandle is preferred. | ||
400 | * Function remains to support old versions of nfs-utils. | ||
401 | * | ||
402 | * Input: | ||
403 | * buf: struct nfsctl_fsparm | ||
404 | * gd_addr: socket address of client | ||
405 | * gd_path: '\0'-terminated C string | ||
406 | * containing pathname of | ||
407 | * directory in local file system | ||
408 | * gd_maxlen: maximum size of returned file | ||
409 | * handle | ||
410 | * size: size in bytes of passed in nfsctl_fsparm | ||
411 | * Output: | ||
412 | * On success: passed-in buffer filled with a knfsd_fh structure | ||
413 | * (a variable-length raw NFS file handle); | ||
414 | * return code is the size in bytes of the file handle | ||
415 | * On error: return code is negative errno value | ||
416 | * | ||
417 | * Note: Only AF_INET client addresses are passed in, since gd_addr | ||
418 | * is the same size as a struct sockaddr_in. | ||
419 | */ | ||
420 | static ssize_t write_getfs(struct file *file, char *buf, size_t size) | ||
421 | { | ||
422 | struct nfsctl_fsparm *data; | ||
423 | struct sockaddr_in *sin; | ||
424 | struct auth_domain *clp; | ||
425 | int err = 0; | ||
426 | struct knfsd_fh *res; | ||
427 | struct in6_addr in6; | ||
428 | |||
429 | if (size < sizeof(*data)) | ||
430 | return -EINVAL; | ||
431 | data = (struct nfsctl_fsparm*)buf; | ||
432 | err = -EPROTONOSUPPORT; | ||
433 | if (data->gd_addr.sa_family != AF_INET) | ||
434 | goto out; | ||
435 | sin = (struct sockaddr_in *)&data->gd_addr; | ||
436 | if (data->gd_maxlen > NFS3_FHSIZE) | ||
437 | data->gd_maxlen = NFS3_FHSIZE; | ||
438 | |||
439 | res = (struct knfsd_fh*)buf; | ||
440 | |||
441 | exp_readlock(); | ||
442 | |||
443 | ipv6_addr_set_v4mapped(sin->sin_addr.s_addr, &in6); | ||
444 | |||
445 | clp = auth_unix_lookup(&init_net, &in6); | ||
446 | if (!clp) | ||
447 | err = -EPERM; | ||
448 | else { | ||
449 | err = exp_rootfh(clp, data->gd_path, res, data->gd_maxlen); | ||
450 | auth_domain_put(clp); | ||
451 | } | ||
452 | exp_readunlock(); | ||
453 | if (err == 0) | ||
454 | err = res->fh_size + offsetof(struct knfsd_fh, fh_base); | ||
455 | out: | ||
456 | return err; | ||
457 | } | ||
458 | |||
459 | /** | ||
460 | * write_getfd - Get a fixed-length NFS file handle by path (used by mountd) | ||
461 | * | ||
462 | * Deprecated. /proc/fs/nfsd/filehandle is preferred. | ||
463 | * Function remains to support old versions of nfs-utils. | ||
464 | * | ||
465 | * Input: | ||
466 | * buf: struct nfsctl_fdparm | ||
467 | * gd_addr: socket address of client | ||
468 | * gd_path: '\0'-terminated C string | ||
469 | * containing pathname of | ||
470 | * directory in local file system | ||
471 | * gd_version: fdparm structure version | ||
472 | * size: size in bytes of passed in nfsctl_fdparm | ||
473 | * Output: | ||
474 | * On success: passed-in buffer filled with nfsctl_res | ||
475 | * (a fixed-length raw NFS file handle); | ||
476 | * return code is the size in bytes of the file handle | ||
477 | * On error: return code is negative errno value | ||
478 | * | ||
479 | * Note: Only AF_INET client addresses are passed in, since gd_addr | ||
480 | * is the same size as a struct sockaddr_in. | ||
481 | */ | ||
482 | static ssize_t write_getfd(struct file *file, char *buf, size_t size) | ||
483 | { | ||
484 | struct nfsctl_fdparm *data; | ||
485 | struct sockaddr_in *sin; | ||
486 | struct auth_domain *clp; | ||
487 | int err = 0; | ||
488 | struct knfsd_fh fh; | ||
489 | char *res; | ||
490 | struct in6_addr in6; | ||
491 | |||
492 | if (size < sizeof(*data)) | ||
493 | return -EINVAL; | ||
494 | data = (struct nfsctl_fdparm*)buf; | ||
495 | err = -EPROTONOSUPPORT; | ||
496 | if (data->gd_addr.sa_family != AF_INET) | ||
497 | goto out; | ||
498 | err = -EINVAL; | ||
499 | if (data->gd_version < 2 || data->gd_version > NFSSVC_MAXVERS) | ||
500 | goto out; | ||
501 | |||
502 | res = buf; | ||
503 | sin = (struct sockaddr_in *)&data->gd_addr; | ||
504 | exp_readlock(); | ||
505 | |||
506 | ipv6_addr_set_v4mapped(sin->sin_addr.s_addr, &in6); | ||
507 | |||
508 | clp = auth_unix_lookup(&init_net, &in6); | ||
509 | if (!clp) | ||
510 | err = -EPERM; | ||
511 | else { | ||
512 | err = exp_rootfh(clp, data->gd_path, &fh, NFS_FHSIZE); | ||
513 | auth_domain_put(clp); | ||
514 | } | ||
515 | exp_readunlock(); | ||
516 | |||
517 | if (err == 0) { | ||
518 | memset(res,0, NFS_FHSIZE); | ||
519 | memcpy(res, &fh.fh_base, fh.fh_size); | ||
520 | err = NFS_FHSIZE; | ||
521 | } | ||
522 | out: | ||
523 | return err; | ||
524 | } | ||
525 | #endif /* CONFIG_NFSD_DEPRECATED */ | ||
526 | 192 | ||
527 | /** | 193 | /** |
528 | * write_unlock_ip - Release all locks used by a client | 194 | * write_unlock_ip - Release all locks used by a client |
@@ -1397,15 +1063,6 @@ static ssize_t write_recoverydir(struct file *file, char *buf, size_t size) | |||
1397 | static int nfsd_fill_super(struct super_block * sb, void * data, int silent) | 1063 | static int nfsd_fill_super(struct super_block * sb, void * data, int silent) |
1398 | { | 1064 | { |
1399 | static struct tree_descr nfsd_files[] = { | 1065 | static struct tree_descr nfsd_files[] = { |
1400 | #ifdef CONFIG_NFSD_DEPRECATED | ||
1401 | [NFSD_Svc] = {".svc", &transaction_ops, S_IWUSR}, | ||
1402 | [NFSD_Add] = {".add", &transaction_ops, S_IWUSR}, | ||
1403 | [NFSD_Del] = {".del", &transaction_ops, S_IWUSR}, | ||
1404 | [NFSD_Export] = {".export", &transaction_ops, S_IWUSR}, | ||
1405 | [NFSD_Unexport] = {".unexport", &transaction_ops, S_IWUSR}, | ||
1406 | [NFSD_Getfd] = {".getfd", &transaction_ops, S_IWUSR|S_IRUSR}, | ||
1407 | [NFSD_Getfs] = {".getfs", &transaction_ops, S_IWUSR|S_IRUSR}, | ||
1408 | #endif | ||
1409 | [NFSD_List] = {"exports", &exports_operations, S_IRUGO}, | 1066 | [NFSD_List] = {"exports", &exports_operations, S_IRUGO}, |
1410 | [NFSD_Export_features] = {"export_features", | 1067 | [NFSD_Export_features] = {"export_features", |
1411 | &export_features_operations, S_IRUGO}, | 1068 | &export_features_operations, S_IRUGO}, |
diff --git a/fs/nfsd/nfssvc.c b/fs/nfsd/nfssvc.c index 18743c4d8bca..dc5a1bf476b1 100644 --- a/fs/nfsd/nfssvc.c +++ b/fs/nfsd/nfssvc.c | |||
@@ -528,16 +528,9 @@ nfsd(void *vrqstp) | |||
528 | continue; | 528 | continue; |
529 | } | 529 | } |
530 | 530 | ||
531 | |||
532 | /* Lock the export hash tables for reading. */ | ||
533 | exp_readlock(); | ||
534 | |||
535 | validate_process_creds(); | 531 | validate_process_creds(); |
536 | svc_process(rqstp); | 532 | svc_process(rqstp); |
537 | validate_process_creds(); | 533 | validate_process_creds(); |
538 | |||
539 | /* Unlock export hash tables */ | ||
540 | exp_readunlock(); | ||
541 | } | 534 | } |
542 | 535 | ||
543 | /* Clear signals before calling svc_exit_thread() */ | 536 | /* Clear signals before calling svc_exit_thread() */ |
@@ -577,8 +570,22 @@ nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp) | |||
577 | rqstp->rq_vers, rqstp->rq_proc); | 570 | rqstp->rq_vers, rqstp->rq_proc); |
578 | proc = rqstp->rq_procinfo; | 571 | proc = rqstp->rq_procinfo; |
579 | 572 | ||
573 | /* | ||
574 | * Give the xdr decoder a chance to change this if it wants | ||
575 | * (necessary in the NFSv4.0 compound case) | ||
576 | */ | ||
577 | rqstp->rq_cachetype = proc->pc_cachetype; | ||
578 | /* Decode arguments */ | ||
579 | xdr = proc->pc_decode; | ||
580 | if (xdr && !xdr(rqstp, (__be32*)rqstp->rq_arg.head[0].iov_base, | ||
581 | rqstp->rq_argp)) { | ||
582 | dprintk("nfsd: failed to decode arguments!\n"); | ||
583 | *statp = rpc_garbage_args; | ||
584 | return 1; | ||
585 | } | ||
586 | |||
580 | /* Check whether we have this call in the cache. */ | 587 | /* Check whether we have this call in the cache. */ |
581 | switch (nfsd_cache_lookup(rqstp, proc->pc_cachetype)) { | 588 | switch (nfsd_cache_lookup(rqstp)) { |
582 | case RC_INTR: | 589 | case RC_INTR: |
583 | case RC_DROPIT: | 590 | case RC_DROPIT: |
584 | return 0; | 591 | return 0; |
@@ -588,16 +595,6 @@ nfsd_dispatch(struct svc_rqst *rqstp, __be32 *statp) | |||
588 | /* do it */ | 595 | /* do it */ |
589 | } | 596 | } |
590 | 597 | ||
591 | /* Decode arguments */ | ||
592 | xdr = proc->pc_decode; | ||
593 | if (xdr && !xdr(rqstp, (__be32*)rqstp->rq_arg.head[0].iov_base, | ||
594 | rqstp->rq_argp)) { | ||
595 | dprintk("nfsd: failed to decode arguments!\n"); | ||
596 | nfsd_cache_update(rqstp, RC_NOCACHE, NULL); | ||
597 | *statp = rpc_garbage_args; | ||
598 | return 1; | ||
599 | } | ||
600 | |||
601 | /* need to grab the location to store the status, as | 598 | /* need to grab the location to store the status, as |
602 | * nfsv4 does some encoding while processing | 599 | * nfsv4 does some encoding while processing |
603 | */ | 600 | */ |
diff --git a/fs/nfsd/state.h b/fs/nfsd/state.h index 6bd2f3c21f2b..4eefaf1b42e8 100644 --- a/fs/nfsd/state.h +++ b/fs/nfsd/state.h | |||
@@ -482,6 +482,7 @@ extern void nfsd4_recdir_purge_old(void); | |||
482 | extern int nfsd4_create_clid_dir(struct nfs4_client *clp); | 482 | extern int nfsd4_create_clid_dir(struct nfs4_client *clp); |
483 | extern void nfsd4_remove_clid_dir(struct nfs4_client *clp); | 483 | extern void nfsd4_remove_clid_dir(struct nfs4_client *clp); |
484 | extern void release_session_client(struct nfsd4_session *); | 484 | extern void release_session_client(struct nfsd4_session *); |
485 | extern __be32 nfs4_validate_stateid(stateid_t *, int); | ||
485 | 486 | ||
486 | static inline void | 487 | static inline void |
487 | nfs4_put_stateowner(struct nfs4_stateowner *so) | 488 | nfs4_put_stateowner(struct nfs4_stateowner *so) |
diff --git a/fs/nfsd/xdr4.h b/fs/nfsd/xdr4.h index 366401e1a536..d2a8d04428c7 100644 --- a/fs/nfsd/xdr4.h +++ b/fs/nfsd/xdr4.h | |||
@@ -342,6 +342,25 @@ struct nfsd4_setclientid_confirm { | |||
342 | nfs4_verifier sc_confirm; | 342 | nfs4_verifier sc_confirm; |
343 | }; | 343 | }; |
344 | 344 | ||
345 | struct nfsd4_saved_compoundargs { | ||
346 | __be32 *p; | ||
347 | __be32 *end; | ||
348 | int pagelen; | ||
349 | struct page **pagelist; | ||
350 | }; | ||
351 | |||
352 | struct nfsd4_test_stateid { | ||
353 | __be32 ts_num_ids; | ||
354 | __be32 ts_has_session; | ||
355 | struct nfsd4_compoundargs *ts_saved_args; | ||
356 | struct nfsd4_saved_compoundargs ts_savedp; | ||
357 | }; | ||
358 | |||
359 | struct nfsd4_free_stateid { | ||
360 | stateid_t fr_stateid; /* request */ | ||
361 | __be32 fr_status; /* response */ | ||
362 | }; | ||
363 | |||
345 | /* also used for NVERIFY */ | 364 | /* also used for NVERIFY */ |
346 | struct nfsd4_verify { | 365 | struct nfsd4_verify { |
347 | u32 ve_bmval[3]; /* request */ | 366 | u32 ve_bmval[3]; /* request */ |
@@ -432,10 +451,14 @@ struct nfsd4_op { | |||
432 | struct nfsd4_destroy_session destroy_session; | 451 | struct nfsd4_destroy_session destroy_session; |
433 | struct nfsd4_sequence sequence; | 452 | struct nfsd4_sequence sequence; |
434 | struct nfsd4_reclaim_complete reclaim_complete; | 453 | struct nfsd4_reclaim_complete reclaim_complete; |
454 | struct nfsd4_test_stateid test_stateid; | ||
455 | struct nfsd4_free_stateid free_stateid; | ||
435 | } u; | 456 | } u; |
436 | struct nfs4_replay * replay; | 457 | struct nfs4_replay * replay; |
437 | }; | 458 | }; |
438 | 459 | ||
460 | bool nfsd4_cache_this_op(struct nfsd4_op *); | ||
461 | |||
439 | struct nfsd4_compoundargs { | 462 | struct nfsd4_compoundargs { |
440 | /* scratch variables for XDR decode */ | 463 | /* scratch variables for XDR decode */ |
441 | __be32 * p; | 464 | __be32 * p; |
@@ -458,6 +481,7 @@ struct nfsd4_compoundargs { | |||
458 | u32 opcnt; | 481 | u32 opcnt; |
459 | struct nfsd4_op *ops; | 482 | struct nfsd4_op *ops; |
460 | struct nfsd4_op iops[8]; | 483 | struct nfsd4_op iops[8]; |
484 | int cachetype; | ||
461 | }; | 485 | }; |
462 | 486 | ||
463 | struct nfsd4_compoundres { | 487 | struct nfsd4_compoundres { |
@@ -559,11 +583,15 @@ extern __be32 | |||
559 | nfsd4_release_lockowner(struct svc_rqst *rqstp, | 583 | nfsd4_release_lockowner(struct svc_rqst *rqstp, |
560 | struct nfsd4_compound_state *, | 584 | struct nfsd4_compound_state *, |
561 | struct nfsd4_release_lockowner *rlockowner); | 585 | struct nfsd4_release_lockowner *rlockowner); |
562 | extern void nfsd4_release_compoundargs(struct nfsd4_compoundargs *); | 586 | extern int nfsd4_release_compoundargs(void *rq, __be32 *p, void *resp); |
563 | extern __be32 nfsd4_delegreturn(struct svc_rqst *rqstp, | 587 | extern __be32 nfsd4_delegreturn(struct svc_rqst *rqstp, |
564 | struct nfsd4_compound_state *, struct nfsd4_delegreturn *dr); | 588 | struct nfsd4_compound_state *, struct nfsd4_delegreturn *dr); |
565 | extern __be32 nfsd4_renew(struct svc_rqst *rqstp, | 589 | extern __be32 nfsd4_renew(struct svc_rqst *rqstp, |
566 | struct nfsd4_compound_state *, clientid_t *clid); | 590 | struct nfsd4_compound_state *, clientid_t *clid); |
591 | extern __be32 nfsd4_test_stateid(struct svc_rqst *rqstp, | ||
592 | struct nfsd4_compound_state *, struct nfsd4_test_stateid *test_stateid); | ||
593 | extern __be32 nfsd4_free_stateid(struct svc_rqst *rqstp, | ||
594 | struct nfsd4_compound_state *, struct nfsd4_free_stateid *free_stateid); | ||
567 | #endif | 595 | #endif |
568 | 596 | ||
569 | /* | 597 | /* |