diff options
author | J.Bruce Fields <bfields@fieldses.org> | 2006-12-13 03:35:38 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-13 12:05:54 -0500 |
commit | b591480bbe1a7f0e90533bce8ea86efecc84648e (patch) | |
tree | 43d75e2978ecf85bab894ec6afce8cc06c5480c1 /fs | |
parent | c954e2a5d1c9662991a41282297ddebcadee0578 (diff) |
[PATCH] knfsd: nfsd4: reorganize compound ops
Define an op descriptor struct, use it to simplify nfsd4_proc_compound().
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
Signed-off-by: Neil Brown <neilb@suse.de>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/nfsd/nfs4proc.c | 254 | ||||
-rw-r--r-- | fs/nfsd/nfs4state.c | 14 |
2 files changed, 139 insertions, 129 deletions
diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c index 8fc2cab9d76a..e1c463bad124 100644 --- a/fs/nfsd/nfs4proc.c +++ b/fs/nfsd/nfs4proc.c | |||
@@ -258,7 +258,8 @@ out: | |||
258 | * filehandle-manipulating ops. | 258 | * filehandle-manipulating ops. |
259 | */ | 259 | */ |
260 | static __be32 | 260 | static __be32 |
261 | nfsd4_getfh(struct nfsd4_compound_state *cstate, struct svc_fh **getfh) | 261 | nfsd4_getfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, |
262 | struct svc_fh **getfh) | ||
262 | { | 263 | { |
263 | if (!cstate->current_fh.fh_dentry) | 264 | if (!cstate->current_fh.fh_dentry) |
264 | return nfserr_nofilehandle; | 265 | return nfserr_nofilehandle; |
@@ -279,7 +280,8 @@ nfsd4_putfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
279 | } | 280 | } |
280 | 281 | ||
281 | static __be32 | 282 | static __be32 |
282 | nfsd4_putrootfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate) | 283 | nfsd4_putrootfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, |
284 | void *arg) | ||
283 | { | 285 | { |
284 | __be32 status; | 286 | __be32 status; |
285 | 287 | ||
@@ -290,7 +292,8 @@ nfsd4_putrootfh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate) | |||
290 | } | 292 | } |
291 | 293 | ||
292 | static __be32 | 294 | static __be32 |
293 | nfsd4_restorefh(struct nfsd4_compound_state *cstate) | 295 | nfsd4_restorefh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, |
296 | void *arg) | ||
294 | { | 297 | { |
295 | if (!cstate->save_fh.fh_dentry) | 298 | if (!cstate->save_fh.fh_dentry) |
296 | return nfserr_restorefh; | 299 | return nfserr_restorefh; |
@@ -300,7 +303,8 @@ nfsd4_restorefh(struct nfsd4_compound_state *cstate) | |||
300 | } | 303 | } |
301 | 304 | ||
302 | static __be32 | 305 | static __be32 |
303 | nfsd4_savefh(struct nfsd4_compound_state *cstate) | 306 | nfsd4_savefh(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, |
307 | void *arg) | ||
304 | { | 308 | { |
305 | if (!cstate->current_fh.fh_dentry) | 309 | if (!cstate->current_fh.fh_dentry) |
306 | return nfserr_nofilehandle; | 310 | return nfserr_nofilehandle; |
@@ -463,7 +467,8 @@ nfsd4_link(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, | |||
463 | } | 467 | } |
464 | 468 | ||
465 | static __be32 | 469 | static __be32 |
466 | nfsd4_lookupp(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate) | 470 | nfsd4_lookupp(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, |
471 | void *arg) | ||
467 | { | 472 | { |
468 | struct svc_fh tmp_fh; | 473 | struct svc_fh tmp_fh; |
469 | __be32 ret; | 474 | __be32 ret; |
@@ -791,6 +796,16 @@ static struct nfsd4_compound_state *cstate_alloc(void) | |||
791 | return cstate; | 796 | return cstate; |
792 | } | 797 | } |
793 | 798 | ||
799 | typedef __be32(*nfsd4op_func)(struct svc_rqst *, struct nfsd4_compound_state *, | ||
800 | void *); | ||
801 | |||
802 | struct nfsd4_operation { | ||
803 | nfsd4op_func op_func; | ||
804 | u32 op_flags; | ||
805 | }; | ||
806 | |||
807 | static struct nfsd4_operation nfsd4_ops[]; | ||
808 | |||
794 | /* | 809 | /* |
795 | * COMPOUND call. | 810 | * COMPOUND call. |
796 | */ | 811 | */ |
@@ -800,6 +815,7 @@ nfsd4_proc_compound(struct svc_rqst *rqstp, | |||
800 | struct nfsd4_compoundres *resp) | 815 | struct nfsd4_compoundres *resp) |
801 | { | 816 | { |
802 | struct nfsd4_op *op; | 817 | struct nfsd4_op *op; |
818 | struct nfsd4_operation *opdesc; | ||
803 | struct nfsd4_compound_state *cstate = NULL; | 819 | struct nfsd4_compound_state *cstate = NULL; |
804 | int slack_bytes; | 820 | int slack_bytes; |
805 | __be32 status; | 821 | __be32 status; |
@@ -854,6 +870,8 @@ nfsd4_proc_compound(struct svc_rqst *rqstp, | |||
854 | goto encode_op; | 870 | goto encode_op; |
855 | } | 871 | } |
856 | 872 | ||
873 | opdesc = &nfsd4_ops[op->opnum]; | ||
874 | |||
857 | /* All operations except RENEW, SETCLIENTID, RESTOREFH | 875 | /* All operations except RENEW, SETCLIENTID, RESTOREFH |
858 | * SETCLIENTID_CONFIRM, PUTFH and PUTROOTFH | 876 | * SETCLIENTID_CONFIRM, PUTFH and PUTROOTFH |
859 | * require a valid current filehandle | 877 | * require a valid current filehandle |
@@ -883,127 +901,11 @@ nfsd4_proc_compound(struct svc_rqst *rqstp, | |||
883 | op->status = nfserr_moved; | 901 | op->status = nfserr_moved; |
884 | goto encode_op; | 902 | goto encode_op; |
885 | } | 903 | } |
886 | switch (op->opnum) { | 904 | |
887 | case OP_ACCESS: | 905 | if (opdesc->op_func) |
888 | op->status = nfsd4_access(rqstp, cstate, | 906 | op->status = opdesc->op_func(rqstp, cstate, &op->u); |
889 | &op->u.access); | 907 | else |
890 | break; | ||
891 | case OP_CLOSE: | ||
892 | op->status = nfsd4_close(rqstp, cstate, | ||
893 | &op->u.close); | ||
894 | break; | ||
895 | case OP_COMMIT: | ||
896 | op->status = nfsd4_commit(rqstp, cstate, | ||
897 | &op->u.commit); | ||
898 | break; | ||
899 | case OP_CREATE: | ||
900 | op->status = nfsd4_create(rqstp, cstate, | ||
901 | &op->u.create); | ||
902 | break; | ||
903 | case OP_DELEGRETURN: | ||
904 | op->status = nfsd4_delegreturn(rqstp, cstate, | ||
905 | &op->u.delegreturn); | ||
906 | break; | ||
907 | case OP_GETATTR: | ||
908 | op->status = nfsd4_getattr(rqstp, cstate, | ||
909 | &op->u.getattr); | ||
910 | break; | ||
911 | case OP_GETFH: | ||
912 | op->status = nfsd4_getfh(cstate, &op->u.getfh); | ||
913 | break; | ||
914 | case OP_LINK: | ||
915 | op->status = nfsd4_link(rqstp, cstate, &op->u.link); | ||
916 | break; | ||
917 | case OP_LOCK: | ||
918 | op->status = nfsd4_lock(rqstp, cstate, &op->u.lock); | ||
919 | break; | ||
920 | case OP_LOCKT: | ||
921 | op->status = nfsd4_lockt(rqstp, cstate, &op->u.lockt); | ||
922 | break; | ||
923 | case OP_LOCKU: | ||
924 | op->status = nfsd4_locku(rqstp, cstate, &op->u.locku); | ||
925 | break; | ||
926 | case OP_LOOKUP: | ||
927 | op->status = nfsd4_lookup(rqstp, cstate, | ||
928 | &op->u.lookup); | ||
929 | break; | ||
930 | case OP_LOOKUPP: | ||
931 | op->status = nfsd4_lookupp(rqstp, cstate); | ||
932 | break; | ||
933 | case OP_NVERIFY: | ||
934 | op->status = nfsd4_nverify(rqstp, cstate, | ||
935 | &op->u.nverify); | ||
936 | break; | ||
937 | case OP_OPEN: | ||
938 | op->status = nfsd4_open(rqstp, cstate, | ||
939 | &op->u.open); | ||
940 | break; | ||
941 | case OP_OPEN_CONFIRM: | ||
942 | op->status = nfsd4_open_confirm(rqstp, cstate, | ||
943 | &op->u.open_confirm); | ||
944 | break; | ||
945 | case OP_OPEN_DOWNGRADE: | ||
946 | op->status = nfsd4_open_downgrade(rqstp, cstate, | ||
947 | &op->u.open_downgrade); | ||
948 | break; | ||
949 | case OP_PUTFH: | ||
950 | op->status = nfsd4_putfh(rqstp, cstate, &op->u.putfh); | ||
951 | break; | ||
952 | case OP_PUTROOTFH: | ||
953 | op->status = nfsd4_putrootfh(rqstp, cstate); | ||
954 | break; | ||
955 | case OP_READ: | ||
956 | op->status = nfsd4_read(rqstp, cstate, &op->u.read); | ||
957 | break; | ||
958 | case OP_READDIR: | ||
959 | op->status = nfsd4_readdir(rqstp, cstate, | ||
960 | &op->u.readdir); | ||
961 | break; | ||
962 | case OP_READLINK: | ||
963 | op->status = nfsd4_readlink(rqstp, cstate, | ||
964 | &op->u.readlink); | ||
965 | break; | ||
966 | case OP_REMOVE: | ||
967 | op->status = nfsd4_remove(rqstp, cstate, | ||
968 | &op->u.remove); | ||
969 | break; | ||
970 | case OP_RENAME: | ||
971 | op->status = nfsd4_rename(rqstp, cstate, | ||
972 | &op->u.rename); | ||
973 | break; | ||
974 | case OP_RENEW: | ||
975 | op->status = nfsd4_renew(&op->u.renew); | ||
976 | break; | ||
977 | case OP_RESTOREFH: | ||
978 | op->status = nfsd4_restorefh(cstate); | ||
979 | break; | ||
980 | case OP_SAVEFH: | ||
981 | op->status = nfsd4_savefh(cstate); | ||
982 | break; | ||
983 | case OP_SETATTR: | ||
984 | op->status = nfsd4_setattr(rqstp, cstate, | ||
985 | &op->u.setattr); | ||
986 | break; | ||
987 | case OP_SETCLIENTID: | ||
988 | op->status = nfsd4_setclientid(rqstp, &op->u.setclientid); | ||
989 | break; | ||
990 | case OP_SETCLIENTID_CONFIRM: | ||
991 | op->status = nfsd4_setclientid_confirm(rqstp, &op->u.setclientid_confirm); | ||
992 | break; | ||
993 | case OP_VERIFY: | ||
994 | op->status = nfsd4_verify(rqstp, cstate, | ||
995 | &op->u.verify); | ||
996 | break; | ||
997 | case OP_WRITE: | ||
998 | op->status = nfsd4_write(rqstp, cstate, &op->u.write); | ||
999 | break; | ||
1000 | case OP_RELEASE_LOCKOWNER: | ||
1001 | op->status = nfsd4_release_lockowner(rqstp, &op->u.release_lockowner); | ||
1002 | break; | ||
1003 | default: | ||
1004 | BUG_ON(op->status == nfs_ok); | 908 | BUG_ON(op->status == nfs_ok); |
1005 | break; | ||
1006 | } | ||
1007 | 909 | ||
1008 | encode_op: | 910 | encode_op: |
1009 | if (op->status == nfserr_replay_me) { | 911 | if (op->status == nfserr_replay_me) { |
@@ -1031,6 +933,108 @@ out: | |||
1031 | return status; | 933 | return status; |
1032 | } | 934 | } |
1033 | 935 | ||
936 | static struct nfsd4_operation nfsd4_ops[OP_RELEASE_LOCKOWNER+1] = { | ||
937 | [OP_ACCESS] = { | ||
938 | .op_func = (nfsd4op_func)nfsd4_access, | ||
939 | }, | ||
940 | [OP_CLOSE] = { | ||
941 | .op_func = (nfsd4op_func)nfsd4_close, | ||
942 | }, | ||
943 | [OP_COMMIT] = { | ||
944 | .op_func = (nfsd4op_func)nfsd4_commit, | ||
945 | }, | ||
946 | [OP_CREATE] = { | ||
947 | .op_func = (nfsd4op_func)nfsd4_create, | ||
948 | }, | ||
949 | [OP_DELEGRETURN] = { | ||
950 | .op_func = (nfsd4op_func)nfsd4_delegreturn, | ||
951 | }, | ||
952 | [OP_GETATTR] = { | ||
953 | .op_func = (nfsd4op_func)nfsd4_getattr, | ||
954 | }, | ||
955 | [OP_GETFH] = { | ||
956 | .op_func = (nfsd4op_func)nfsd4_getfh, | ||
957 | }, | ||
958 | [OP_LINK] = { | ||
959 | .op_func = (nfsd4op_func)nfsd4_link, | ||
960 | }, | ||
961 | [OP_LOCK] = { | ||
962 | .op_func = (nfsd4op_func)nfsd4_lock, | ||
963 | }, | ||
964 | [OP_LOCKT] = { | ||
965 | .op_func = (nfsd4op_func)nfsd4_lockt, | ||
966 | }, | ||
967 | [OP_LOCKU] = { | ||
968 | .op_func = (nfsd4op_func)nfsd4_locku, | ||
969 | }, | ||
970 | [OP_LOOKUP] = { | ||
971 | .op_func = (nfsd4op_func)nfsd4_lookup, | ||
972 | }, | ||
973 | [OP_LOOKUPP] = { | ||
974 | .op_func = (nfsd4op_func)nfsd4_lookupp, | ||
975 | }, | ||
976 | [OP_NVERIFY] = { | ||
977 | .op_func = (nfsd4op_func)nfsd4_nverify, | ||
978 | }, | ||
979 | [OP_OPEN] = { | ||
980 | .op_func = (nfsd4op_func)nfsd4_open, | ||
981 | }, | ||
982 | [OP_OPEN_CONFIRM] = { | ||
983 | .op_func = (nfsd4op_func)nfsd4_open_confirm, | ||
984 | }, | ||
985 | [OP_OPEN_DOWNGRADE] = { | ||
986 | .op_func = (nfsd4op_func)nfsd4_open_downgrade, | ||
987 | }, | ||
988 | [OP_PUTFH] = { | ||
989 | .op_func = (nfsd4op_func)nfsd4_putfh, | ||
990 | }, | ||
991 | [OP_PUTROOTFH] = { | ||
992 | .op_func = (nfsd4op_func)nfsd4_putrootfh, | ||
993 | }, | ||
994 | [OP_READ] = { | ||
995 | .op_func = (nfsd4op_func)nfsd4_read, | ||
996 | }, | ||
997 | [OP_READDIR] = { | ||
998 | .op_func = (nfsd4op_func)nfsd4_readdir, | ||
999 | }, | ||
1000 | [OP_READLINK] = { | ||
1001 | .op_func = (nfsd4op_func)nfsd4_readlink, | ||
1002 | }, | ||
1003 | [OP_REMOVE] = { | ||
1004 | .op_func = (nfsd4op_func)nfsd4_remove, | ||
1005 | }, | ||
1006 | [OP_RENAME] = { | ||
1007 | .op_func = (nfsd4op_func)nfsd4_rename, | ||
1008 | }, | ||
1009 | [OP_RENEW] = { | ||
1010 | .op_func = (nfsd4op_func)nfsd4_renew, | ||
1011 | }, | ||
1012 | [OP_RESTOREFH] = { | ||
1013 | .op_func = (nfsd4op_func)nfsd4_restorefh, | ||
1014 | }, | ||
1015 | [OP_SAVEFH] = { | ||
1016 | .op_func = (nfsd4op_func)nfsd4_savefh, | ||
1017 | }, | ||
1018 | [OP_SETATTR] = { | ||
1019 | .op_func = (nfsd4op_func)nfsd4_setattr, | ||
1020 | }, | ||
1021 | [OP_SETCLIENTID] = { | ||
1022 | .op_func = (nfsd4op_func)nfsd4_setclientid, | ||
1023 | }, | ||
1024 | [OP_SETCLIENTID_CONFIRM] = { | ||
1025 | .op_func = (nfsd4op_func)nfsd4_setclientid_confirm, | ||
1026 | }, | ||
1027 | [OP_VERIFY] = { | ||
1028 | .op_func = (nfsd4op_func)nfsd4_verify, | ||
1029 | }, | ||
1030 | [OP_WRITE] = { | ||
1031 | .op_func = (nfsd4op_func)nfsd4_write, | ||
1032 | }, | ||
1033 | [OP_RELEASE_LOCKOWNER] = { | ||
1034 | .op_func = (nfsd4op_func)nfsd4_release_lockowner, | ||
1035 | }, | ||
1036 | }; | ||
1037 | |||
1034 | #define nfs4svc_decode_voidargs NULL | 1038 | #define nfs4svc_decode_voidargs NULL |
1035 | #define nfs4svc_release_void NULL | 1039 | #define nfs4svc_release_void NULL |
1036 | #define nfsd4_voidres nfsd4_voidargs | 1040 | #define nfsd4_voidres nfsd4_voidargs |
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index db701c47a342..9de89df961f4 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
@@ -711,7 +711,8 @@ out_err: | |||
711 | * | 711 | * |
712 | */ | 712 | */ |
713 | __be32 | 713 | __be32 |
714 | nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_setclientid *setclid) | 714 | nfsd4_setclientid(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, |
715 | struct nfsd4_setclientid *setclid) | ||
715 | { | 716 | { |
716 | __be32 ip_addr = rqstp->rq_addr.sin_addr.s_addr; | 717 | __be32 ip_addr = rqstp->rq_addr.sin_addr.s_addr; |
717 | struct xdr_netobj clname = { | 718 | struct xdr_netobj clname = { |
@@ -876,7 +877,9 @@ out: | |||
876 | * NOTE: callback information will be processed here in a future patch | 877 | * NOTE: callback information will be processed here in a future patch |
877 | */ | 878 | */ |
878 | __be32 | 879 | __be32 |
879 | nfsd4_setclientid_confirm(struct svc_rqst *rqstp, struct nfsd4_setclientid_confirm *setclientid_confirm) | 880 | nfsd4_setclientid_confirm(struct svc_rqst *rqstp, |
881 | struct nfsd4_compound_state *cstate, | ||
882 | struct nfsd4_setclientid_confirm *setclientid_confirm) | ||
880 | { | 883 | { |
881 | __be32 ip_addr = rqstp->rq_addr.sin_addr.s_addr; | 884 | __be32 ip_addr = rqstp->rq_addr.sin_addr.s_addr; |
882 | struct nfs4_client *conf, *unconf; | 885 | struct nfs4_client *conf, *unconf; |
@@ -1833,7 +1836,8 @@ static void laundromat_main(struct work_struct *); | |||
1833 | static DECLARE_DELAYED_WORK(laundromat_work, laundromat_main); | 1836 | static DECLARE_DELAYED_WORK(laundromat_work, laundromat_main); |
1834 | 1837 | ||
1835 | __be32 | 1838 | __be32 |
1836 | nfsd4_renew(clientid_t *clid) | 1839 | nfsd4_renew(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, |
1840 | clientid_t *clid) | ||
1837 | { | 1841 | { |
1838 | struct nfs4_client *clp; | 1842 | struct nfs4_client *clp; |
1839 | __be32 status; | 1843 | __be32 status; |
@@ -2979,7 +2983,9 @@ out: | |||
2979 | } | 2983 | } |
2980 | 2984 | ||
2981 | __be32 | 2985 | __be32 |
2982 | nfsd4_release_lockowner(struct svc_rqst *rqstp, struct nfsd4_release_lockowner *rlockowner) | 2986 | nfsd4_release_lockowner(struct svc_rqst *rqstp, |
2987 | struct nfsd4_compound_state *cstate, | ||
2988 | struct nfsd4_release_lockowner *rlockowner) | ||
2983 | { | 2989 | { |
2984 | clientid_t *clid = &rlockowner->rl_clientid; | 2990 | clientid_t *clid = &rlockowner->rl_clientid; |
2985 | struct nfs4_stateowner *sop; | 2991 | struct nfs4_stateowner *sop; |