19a74af21SBoaz Harrosh /* 29a74af21SBoaz Harrosh * Server-side types for NFSv4. 39a74af21SBoaz Harrosh * 49a74af21SBoaz Harrosh * Copyright (c) 2002 The Regents of the University of Michigan. 59a74af21SBoaz Harrosh * All rights reserved. 69a74af21SBoaz Harrosh * 79a74af21SBoaz Harrosh * Kendrick Smith <kmsmith@umich.edu> 89a74af21SBoaz Harrosh * Andy Adamson <andros@umich.edu> 99a74af21SBoaz Harrosh * 109a74af21SBoaz Harrosh * Redistribution and use in source and binary forms, with or without 119a74af21SBoaz Harrosh * modification, are permitted provided that the following conditions 129a74af21SBoaz Harrosh * are met: 139a74af21SBoaz Harrosh * 149a74af21SBoaz Harrosh * 1. Redistributions of source code must retain the above copyright 159a74af21SBoaz Harrosh * notice, this list of conditions and the following disclaimer. 169a74af21SBoaz Harrosh * 2. Redistributions in binary form must reproduce the above copyright 179a74af21SBoaz Harrosh * notice, this list of conditions and the following disclaimer in the 189a74af21SBoaz Harrosh * documentation and/or other materials provided with the distribution. 199a74af21SBoaz Harrosh * 3. Neither the name of the University nor the names of its 209a74af21SBoaz Harrosh * contributors may be used to endorse or promote products derived 219a74af21SBoaz Harrosh * from this software without specific prior written permission. 229a74af21SBoaz Harrosh * 239a74af21SBoaz Harrosh * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 249a74af21SBoaz Harrosh * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 259a74af21SBoaz Harrosh * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 269a74af21SBoaz Harrosh * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 279a74af21SBoaz Harrosh * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 289a74af21SBoaz Harrosh * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 299a74af21SBoaz Harrosh * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 309a74af21SBoaz Harrosh * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 319a74af21SBoaz Harrosh * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 329a74af21SBoaz Harrosh * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 339a74af21SBoaz Harrosh * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 349a74af21SBoaz Harrosh * 359a74af21SBoaz Harrosh */ 369a74af21SBoaz Harrosh 379a74af21SBoaz Harrosh #ifndef _LINUX_NFSD_XDR4_H 389a74af21SBoaz Harrosh #define _LINUX_NFSD_XDR4_H 399a74af21SBoaz Harrosh 409a74af21SBoaz Harrosh #include "state.h" 419a74af21SBoaz Harrosh #include "nfsd.h" 429a74af21SBoaz Harrosh 439a74af21SBoaz Harrosh #define NFSD4_MAX_TAGLEN 128 449a74af21SBoaz Harrosh #define XDR_LEN(n) (((n) + 3) & ~3) 459a74af21SBoaz Harrosh 4637c593c5STigran Mkrtchyan #define CURRENT_STATE_ID_FLAG (1<<0) 4737c593c5STigran Mkrtchyan #define SAVED_STATE_ID_FLAG (1<<1) 4837c593c5STigran Mkrtchyan 4951100d2bSOlga Kornievskaia #define SET_CSTATE_FLAG(c, f) ((c)->sid_flags |= (f)) 5051100d2bSOlga Kornievskaia #define HAS_CSTATE_FLAG(c, f) ((c)->sid_flags & (f)) 5151100d2bSOlga Kornievskaia #define CLEAR_CSTATE_FLAG(c, f) ((c)->sid_flags &= ~(f)) 5237c593c5STigran Mkrtchyan 539a74af21SBoaz Harrosh struct nfsd4_compound_state { 549a74af21SBoaz Harrosh struct svc_fh current_fh; 559a74af21SBoaz Harrosh struct svc_fh save_fh; 569a74af21SBoaz Harrosh struct nfs4_stateowner *replay_owner; 574b24ca7dSJeff Layton struct nfs4_client *clp; 589a74af21SBoaz Harrosh /* For sessions DRC */ 599a74af21SBoaz Harrosh struct nfsd4_session *session; 609a74af21SBoaz Harrosh struct nfsd4_slot *slot; 61f5236013SJ. Bruce Fields int data_offset; 62ed941643SAndrew Elble bool spo_must_allowed; 639a74af21SBoaz Harrosh size_t iovlen; 649a74af21SBoaz Harrosh u32 minorversion; 6557b7b43bSJ. Bruce Fields __be32 status; 6637c593c5STigran Mkrtchyan stateid_t current_stateid; 6737c593c5STigran Mkrtchyan stateid_t save_stateid; 6837c593c5STigran Mkrtchyan /* to indicate current and saved state id presents */ 6937c593c5STigran Mkrtchyan u32 sid_flags; 709a74af21SBoaz Harrosh }; 719a74af21SBoaz Harrosh 729a74af21SBoaz Harrosh static inline bool nfsd4_has_session(struct nfsd4_compound_state *cs) 739a74af21SBoaz Harrosh { 749a74af21SBoaz Harrosh return cs->slot != NULL; 759a74af21SBoaz Harrosh } 769a74af21SBoaz Harrosh 779a74af21SBoaz Harrosh struct nfsd4_change_info { 789a74af21SBoaz Harrosh u32 atomic; 799a74af21SBoaz Harrosh u64 before_change; 809a74af21SBoaz Harrosh u64 after_change; 819a74af21SBoaz Harrosh }; 829a74af21SBoaz Harrosh 839a74af21SBoaz Harrosh struct nfsd4_access { 849a74af21SBoaz Harrosh u32 ac_req_access; /* request */ 859a74af21SBoaz Harrosh u32 ac_supported; /* response */ 869a74af21SBoaz Harrosh u32 ac_resp_access; /* response */ 879a74af21SBoaz Harrosh }; 889a74af21SBoaz Harrosh 899a74af21SBoaz Harrosh struct nfsd4_close { 909a74af21SBoaz Harrosh u32 cl_seqid; /* request */ 919a74af21SBoaz Harrosh stateid_t cl_stateid; /* request+response */ 929a74af21SBoaz Harrosh }; 939a74af21SBoaz Harrosh 949a74af21SBoaz Harrosh struct nfsd4_commit { 959a74af21SBoaz Harrosh u64 co_offset; /* request */ 969a74af21SBoaz Harrosh u32 co_count; /* request */ 979a74af21SBoaz Harrosh nfs4_verifier co_verf; /* response */ 989a74af21SBoaz Harrosh }; 999a74af21SBoaz Harrosh 1009a74af21SBoaz Harrosh struct nfsd4_create { 1019a74af21SBoaz Harrosh u32 cr_namelen; /* request */ 1029a74af21SBoaz Harrosh char * cr_name; /* request */ 1039a74af21SBoaz Harrosh u32 cr_type; /* request */ 1049a74af21SBoaz Harrosh union { /* request */ 1059a74af21SBoaz Harrosh struct { 1067fb84306SJ. Bruce Fields u32 datalen; 1077fb84306SJ. Bruce Fields char *data; 10838a70315SChuck Lever struct kvec first; 1099a74af21SBoaz Harrosh } link; /* NF4LNK */ 1109a74af21SBoaz Harrosh struct { 1119a74af21SBoaz Harrosh u32 specdata1; 1129a74af21SBoaz Harrosh u32 specdata2; 1139a74af21SBoaz Harrosh } dev; /* NF4BLK, NF4CHR */ 1149a74af21SBoaz Harrosh } u; 1159a74af21SBoaz Harrosh u32 cr_bmval[3]; /* request */ 1169a74af21SBoaz Harrosh struct iattr cr_iattr; /* request */ 117880a3a53SJ. Bruce Fields int cr_umask; /* request */ 1189a74af21SBoaz Harrosh struct nfsd4_change_info cr_cinfo; /* response */ 1199a74af21SBoaz Harrosh struct nfs4_acl *cr_acl; 12018032ca0SDavid Quigley struct xdr_netobj cr_label; 1219a74af21SBoaz Harrosh }; 1227fb84306SJ. Bruce Fields #define cr_datalen u.link.datalen 1237fb84306SJ. Bruce Fields #define cr_data u.link.data 12438a70315SChuck Lever #define cr_first u.link.first 1259a74af21SBoaz Harrosh #define cr_specdata1 u.dev.specdata1 1269a74af21SBoaz Harrosh #define cr_specdata2 u.dev.specdata2 1279a74af21SBoaz Harrosh 1289a74af21SBoaz Harrosh struct nfsd4_delegreturn { 1299a74af21SBoaz Harrosh stateid_t dr_stateid; 1309a74af21SBoaz Harrosh }; 1319a74af21SBoaz Harrosh 1329a74af21SBoaz Harrosh struct nfsd4_getattr { 1339a74af21SBoaz Harrosh u32 ga_bmval[3]; /* request */ 1349a74af21SBoaz Harrosh struct svc_fh *ga_fhp; /* response */ 1359a74af21SBoaz Harrosh }; 1369a74af21SBoaz Harrosh 1379a74af21SBoaz Harrosh struct nfsd4_link { 1389a74af21SBoaz Harrosh u32 li_namelen; /* request */ 1399a74af21SBoaz Harrosh char * li_name; /* request */ 1409a74af21SBoaz Harrosh struct nfsd4_change_info li_cinfo; /* response */ 1419a74af21SBoaz Harrosh }; 1429a74af21SBoaz Harrosh 1439a74af21SBoaz Harrosh struct nfsd4_lock_denied { 1449a74af21SBoaz Harrosh clientid_t ld_clientid; 1457c13f344SJ. Bruce Fields struct xdr_netobj ld_owner; 1469a74af21SBoaz Harrosh u64 ld_start; 1479a74af21SBoaz Harrosh u64 ld_length; 1489a74af21SBoaz Harrosh u32 ld_type; 1499a74af21SBoaz Harrosh }; 1509a74af21SBoaz Harrosh 1519a74af21SBoaz Harrosh struct nfsd4_lock { 1529a74af21SBoaz Harrosh /* request */ 1539a74af21SBoaz Harrosh u32 lk_type; 1549a74af21SBoaz Harrosh u32 lk_reclaim; /* boolean */ 1559a74af21SBoaz Harrosh u64 lk_offset; 1569a74af21SBoaz Harrosh u64 lk_length; 1579a74af21SBoaz Harrosh u32 lk_is_new; 1589a74af21SBoaz Harrosh union { 1599a74af21SBoaz Harrosh struct { 1609a74af21SBoaz Harrosh u32 open_seqid; 1619a74af21SBoaz Harrosh stateid_t open_stateid; 1629a74af21SBoaz Harrosh u32 lock_seqid; 1639a74af21SBoaz Harrosh clientid_t clientid; 1649a74af21SBoaz Harrosh struct xdr_netobj owner; 1659a74af21SBoaz Harrosh } new; 1669a74af21SBoaz Harrosh struct { 1679a74af21SBoaz Harrosh stateid_t lock_stateid; 1689a74af21SBoaz Harrosh u32 lock_seqid; 1699a74af21SBoaz Harrosh } old; 1709a74af21SBoaz Harrosh } v; 1719a74af21SBoaz Harrosh 1729a74af21SBoaz Harrosh /* response */ 1739a74af21SBoaz Harrosh union { 1749a74af21SBoaz Harrosh struct { 1759a74af21SBoaz Harrosh stateid_t stateid; 1769a74af21SBoaz Harrosh } ok; 1779a74af21SBoaz Harrosh struct nfsd4_lock_denied denied; 1789a74af21SBoaz Harrosh } u; 1799a74af21SBoaz Harrosh }; 1809a74af21SBoaz Harrosh #define lk_new_open_seqid v.new.open_seqid 1819a74af21SBoaz Harrosh #define lk_new_open_stateid v.new.open_stateid 1829a74af21SBoaz Harrosh #define lk_new_lock_seqid v.new.lock_seqid 1839a74af21SBoaz Harrosh #define lk_new_clientid v.new.clientid 1849a74af21SBoaz Harrosh #define lk_new_owner v.new.owner 1859a74af21SBoaz Harrosh #define lk_old_lock_stateid v.old.lock_stateid 1869a74af21SBoaz Harrosh #define lk_old_lock_seqid v.old.lock_seqid 1879a74af21SBoaz Harrosh 1889a74af21SBoaz Harrosh #define lk_resp_stateid u.ok.stateid 1899a74af21SBoaz Harrosh #define lk_denied u.denied 1909a74af21SBoaz Harrosh 1919a74af21SBoaz Harrosh 1929a74af21SBoaz Harrosh struct nfsd4_lockt { 1939a74af21SBoaz Harrosh u32 lt_type; 1949a74af21SBoaz Harrosh clientid_t lt_clientid; 1959a74af21SBoaz Harrosh struct xdr_netobj lt_owner; 1969a74af21SBoaz Harrosh u64 lt_offset; 1979a74af21SBoaz Harrosh u64 lt_length; 1989a74af21SBoaz Harrosh struct nfsd4_lock_denied lt_denied; 1999a74af21SBoaz Harrosh }; 2009a74af21SBoaz Harrosh 2019a74af21SBoaz Harrosh 2029a74af21SBoaz Harrosh struct nfsd4_locku { 2039a74af21SBoaz Harrosh u32 lu_type; 2049a74af21SBoaz Harrosh u32 lu_seqid; 2059a74af21SBoaz Harrosh stateid_t lu_stateid; 2069a74af21SBoaz Harrosh u64 lu_offset; 2079a74af21SBoaz Harrosh u64 lu_length; 2089a74af21SBoaz Harrosh }; 2099a74af21SBoaz Harrosh 2109a74af21SBoaz Harrosh 2119a74af21SBoaz Harrosh struct nfsd4_lookup { 2129a74af21SBoaz Harrosh u32 lo_len; /* request */ 2139a74af21SBoaz Harrosh char * lo_name; /* request */ 2149a74af21SBoaz Harrosh }; 2159a74af21SBoaz Harrosh 2169a74af21SBoaz Harrosh struct nfsd4_putfh { 2179a74af21SBoaz Harrosh u32 pf_fhlen; /* request */ 2189a74af21SBoaz Harrosh char *pf_fhval; /* request */ 219b9e8638eSOlga Kornievskaia bool no_verify; /* represents foreigh fh */ 2209a74af21SBoaz Harrosh }; 2219a74af21SBoaz Harrosh 2226178713bSFrank van der Linden struct nfsd4_getxattr { 2236178713bSFrank van der Linden char *getxa_name; /* request */ 2246178713bSFrank van der Linden u32 getxa_len; /* request */ 2256178713bSFrank van der Linden void *getxa_buf; 2266178713bSFrank van der Linden }; 2276178713bSFrank van der Linden 2286178713bSFrank van der Linden struct nfsd4_setxattr { 2296178713bSFrank van der Linden u32 setxa_flags; /* request */ 2306178713bSFrank van der Linden char *setxa_name; /* request */ 2316178713bSFrank van der Linden char *setxa_buf; /* request */ 2326178713bSFrank van der Linden u32 setxa_len; /* request */ 2336178713bSFrank van der Linden struct nfsd4_change_info setxa_cinfo; /* response */ 2346178713bSFrank van der Linden }; 2356178713bSFrank van der Linden 2366178713bSFrank van der Linden struct nfsd4_removexattr { 2376178713bSFrank van der Linden char *rmxa_name; /* request */ 2386178713bSFrank van der Linden struct nfsd4_change_info rmxa_cinfo; /* response */ 2396178713bSFrank van der Linden }; 2406178713bSFrank van der Linden 2416178713bSFrank van der Linden struct nfsd4_listxattrs { 2426178713bSFrank van der Linden u64 lsxa_cookie; /* request */ 2436178713bSFrank van der Linden u32 lsxa_maxcount; /* request */ 2446178713bSFrank van der Linden char *lsxa_buf; /* unfiltered buffer (reply) */ 2456178713bSFrank van der Linden u32 lsxa_len; /* unfiltered len (reply) */ 2466178713bSFrank van der Linden }; 2476178713bSFrank van der Linden 2489a74af21SBoaz Harrosh struct nfsd4_open { 2499a74af21SBoaz Harrosh u32 op_claim_type; /* request */ 2501708e50bSChuck Lever u32 op_fnamelen; 2511708e50bSChuck Lever char * op_fname; /* request - everything but CLAIM_PREV */ 2529a74af21SBoaz Harrosh u32 op_delegate_type; /* request - CLAIM_PREV only */ 2539a74af21SBoaz Harrosh stateid_t op_delegate_stateid; /* request - response */ 254d24433cdSBenny Halevy u32 op_why_no_deleg; /* response - DELEG_NONE_EXT only */ 2559a74af21SBoaz Harrosh u32 op_create; /* request */ 2569a74af21SBoaz Harrosh u32 op_createmode; /* request */ 257880a3a53SJ. Bruce Fields int op_umask; /* request */ 2589a74af21SBoaz Harrosh u32 op_bmval[3]; /* request */ 2593ff69309SKinglong Mee struct iattr op_iattr; /* UNCHECKED4, GUARDED4, EXCLUSIVE4_1 */ 260ab4684d1SChuck Lever nfs4_verifier op_verf __attribute__((aligned(32))); 261ab4684d1SChuck Lever /* EXCLUSIVE4 */ 2629a74af21SBoaz Harrosh clientid_t op_clientid; /* request */ 2639a74af21SBoaz Harrosh struct xdr_netobj op_owner; /* request */ 2649a74af21SBoaz Harrosh u32 op_seqid; /* request */ 2659a74af21SBoaz Harrosh u32 op_share_access; /* request */ 2669a74af21SBoaz Harrosh u32 op_share_deny; /* request */ 2672c8bd7e0SBenny Halevy u32 op_deleg_want; /* request */ 2689a74af21SBoaz Harrosh stateid_t op_stateid; /* response */ 2699d313b17SJ. Bruce Fields __be32 op_xdr_error; /* see nfsd4_open_omfg() */ 2709a74af21SBoaz Harrosh u32 op_recall; /* recall */ 2719a74af21SBoaz Harrosh struct nfsd4_change_info op_cinfo; /* response */ 2729a74af21SBoaz Harrosh u32 op_rflags; /* response */ 273856121b2SJ. Bruce Fields bool op_truncate; /* used during processing */ 274856121b2SJ. Bruce Fields bool op_created; /* used during processing */ 275fe0750e5SJ. Bruce Fields struct nfs4_openowner *op_openowner; /* used during processing */ 276fb70bf12SChuck Lever struct file *op_filp; /* used during processing */ 27732513b40SJ. Bruce Fields struct nfs4_file *op_file; /* used during processing */ 2784cdc951bSJ. Bruce Fields struct nfs4_ol_stateid *op_stp; /* used during processing */ 2798287f009SSachin Bhamare struct nfs4_clnt_odstate *op_odstate; /* used during processing */ 2809a74af21SBoaz Harrosh struct nfs4_acl *op_acl; 28118032ca0SDavid Quigley struct xdr_netobj op_label; 282876c553cSJeff Layton struct svc_rqst *op_rqstp; 2839a74af21SBoaz Harrosh }; 2849a74af21SBoaz Harrosh 2859a74af21SBoaz Harrosh struct nfsd4_open_confirm { 2869a74af21SBoaz Harrosh stateid_t oc_req_stateid /* request */; 2879a74af21SBoaz Harrosh u32 oc_seqid /* request */; 2889a74af21SBoaz Harrosh stateid_t oc_resp_stateid /* response */; 2899a74af21SBoaz Harrosh }; 2909a74af21SBoaz Harrosh 2919a74af21SBoaz Harrosh struct nfsd4_open_downgrade { 2929a74af21SBoaz Harrosh stateid_t od_stateid; 2939a74af21SBoaz Harrosh u32 od_seqid; 2942c8bd7e0SBenny Halevy u32 od_share_access; /* request */ 2952c8bd7e0SBenny Halevy u32 od_deleg_want; /* request */ 2962c8bd7e0SBenny Halevy u32 od_share_deny; /* request */ 2979a74af21SBoaz Harrosh }; 2989a74af21SBoaz Harrosh 2999a74af21SBoaz Harrosh 3009a74af21SBoaz Harrosh struct nfsd4_read { 3019a74af21SBoaz Harrosh stateid_t rd_stateid; /* request */ 3029a74af21SBoaz Harrosh u64 rd_offset; /* request */ 3039a74af21SBoaz Harrosh u32 rd_length; /* request */ 3049a74af21SBoaz Harrosh int rd_vlen; 3055c4583b2SJeff Layton struct nfsd_file *rd_nf; 3069a74af21SBoaz Harrosh 3079a74af21SBoaz Harrosh struct svc_rqst *rd_rqstp; /* response */ 3089a74af21SBoaz Harrosh struct svc_fh *rd_fhp; /* response */ 30924c7fb85SChuck Lever u32 rd_eof; /* response */ 3109a74af21SBoaz Harrosh }; 3119a74af21SBoaz Harrosh 3129a74af21SBoaz Harrosh struct nfsd4_readdir { 3139a74af21SBoaz Harrosh u64 rd_cookie; /* request */ 3149a74af21SBoaz Harrosh nfs4_verifier rd_verf; /* request */ 3159a74af21SBoaz Harrosh u32 rd_dircount; /* request */ 3169a74af21SBoaz Harrosh u32 rd_maxcount; /* request */ 3179a74af21SBoaz Harrosh u32 rd_bmval[3]; /* request */ 3189a74af21SBoaz Harrosh struct svc_rqst *rd_rqstp; /* response */ 3199a74af21SBoaz Harrosh struct svc_fh * rd_fhp; /* response */ 3209a74af21SBoaz Harrosh 3219a74af21SBoaz Harrosh struct readdir_cd common; 322561f0ed4SJ. Bruce Fields struct xdr_stream *xdr; 323561f0ed4SJ. Bruce Fields int cookie_offset; 3249a74af21SBoaz Harrosh }; 3259a74af21SBoaz Harrosh 3269a74af21SBoaz Harrosh struct nfsd4_release_lockowner { 3279a74af21SBoaz Harrosh clientid_t rl_clientid; 3289a74af21SBoaz Harrosh struct xdr_netobj rl_owner; 3299a74af21SBoaz Harrosh }; 3309a74af21SBoaz Harrosh struct nfsd4_readlink { 3319a74af21SBoaz Harrosh struct svc_rqst *rl_rqstp; /* request */ 3329a74af21SBoaz Harrosh struct svc_fh * rl_fhp; /* request */ 3339a74af21SBoaz Harrosh }; 3349a74af21SBoaz Harrosh 3359a74af21SBoaz Harrosh struct nfsd4_remove { 3369a74af21SBoaz Harrosh u32 rm_namelen; /* request */ 3379a74af21SBoaz Harrosh char * rm_name; /* request */ 3389a74af21SBoaz Harrosh struct nfsd4_change_info rm_cinfo; /* response */ 3399a74af21SBoaz Harrosh }; 3409a74af21SBoaz Harrosh 3419a74af21SBoaz Harrosh struct nfsd4_rename { 3429a74af21SBoaz Harrosh u32 rn_snamelen; /* request */ 3439a74af21SBoaz Harrosh char * rn_sname; /* request */ 3449a74af21SBoaz Harrosh u32 rn_tnamelen; /* request */ 3459a74af21SBoaz Harrosh char * rn_tname; /* request */ 3469a74af21SBoaz Harrosh struct nfsd4_change_info rn_sinfo; /* response */ 3479a74af21SBoaz Harrosh struct nfsd4_change_info rn_tinfo; /* response */ 3489a74af21SBoaz Harrosh }; 3499a74af21SBoaz Harrosh 3509a74af21SBoaz Harrosh struct nfsd4_secinfo { 3519a74af21SBoaz Harrosh u32 si_namelen; /* request */ 3529a74af21SBoaz Harrosh char *si_name; /* request */ 3539a74af21SBoaz Harrosh struct svc_export *si_exp; /* response */ 3549a74af21SBoaz Harrosh }; 3559a74af21SBoaz Harrosh 35604f4ad16SJ. Bruce Fields struct nfsd4_secinfo_no_name { 35704f4ad16SJ. Bruce Fields u32 sin_style; /* request */ 35804f4ad16SJ. Bruce Fields struct svc_export *sin_exp; /* response */ 35904f4ad16SJ. Bruce Fields }; 36004f4ad16SJ. Bruce Fields 3619a74af21SBoaz Harrosh struct nfsd4_setattr { 3629a74af21SBoaz Harrosh stateid_t sa_stateid; /* request */ 3639a74af21SBoaz Harrosh u32 sa_bmval[3]; /* request */ 3649a74af21SBoaz Harrosh struct iattr sa_iattr; /* request */ 3659a74af21SBoaz Harrosh struct nfs4_acl *sa_acl; 36618032ca0SDavid Quigley struct xdr_netobj sa_label; 3679a74af21SBoaz Harrosh }; 3689a74af21SBoaz Harrosh 3699a74af21SBoaz Harrosh struct nfsd4_setclientid { 3709a74af21SBoaz Harrosh nfs4_verifier se_verf; /* request */ 371a084daf5SJ. Bruce Fields struct xdr_netobj se_name; 3729a74af21SBoaz Harrosh u32 se_callback_prog; /* request */ 3739a74af21SBoaz Harrosh u32 se_callback_netid_len; /* request */ 3749a74af21SBoaz Harrosh char * se_callback_netid_val; /* request */ 3759a74af21SBoaz Harrosh u32 se_callback_addr_len; /* request */ 3769a74af21SBoaz Harrosh char * se_callback_addr_val; /* request */ 3779a74af21SBoaz Harrosh u32 se_callback_ident; /* request */ 3789a74af21SBoaz Harrosh clientid_t se_clientid; /* response */ 3799a74af21SBoaz Harrosh nfs4_verifier se_confirm; /* response */ 3809a74af21SBoaz Harrosh }; 3819a74af21SBoaz Harrosh 3829a74af21SBoaz Harrosh struct nfsd4_setclientid_confirm { 3839a74af21SBoaz Harrosh clientid_t sc_clientid; 3849a74af21SBoaz Harrosh nfs4_verifier sc_confirm; 3859a74af21SBoaz Harrosh }; 3869a74af21SBoaz Harrosh 38703cfb420SBryan Schumaker struct nfsd4_test_stateid_id { 38803cfb420SBryan Schumaker __be32 ts_id_status; 38903cfb420SBryan Schumaker stateid_t ts_id_stateid; 39003cfb420SBryan Schumaker struct list_head ts_id_list; 39103cfb420SBryan Schumaker }; 39203cfb420SBryan Schumaker 39317456804SBryan Schumaker struct nfsd4_test_stateid { 39457b7b43bSJ. Bruce Fields u32 ts_num_ids; 39503cfb420SBryan Schumaker struct list_head ts_stateid_list; 39617456804SBryan Schumaker }; 39717456804SBryan Schumaker 398e1ca12dfSBryan Schumaker struct nfsd4_free_stateid { 399e1ca12dfSBryan Schumaker stateid_t fr_stateid; /* request */ 400e1ca12dfSBryan Schumaker }; 401e1ca12dfSBryan Schumaker 4029a74af21SBoaz Harrosh /* also used for NVERIFY */ 4039a74af21SBoaz Harrosh struct nfsd4_verify { 4049a74af21SBoaz Harrosh u32 ve_bmval[3]; /* request */ 4059a74af21SBoaz Harrosh u32 ve_attrlen; /* request */ 4069a74af21SBoaz Harrosh char * ve_attrval; /* request */ 4079a74af21SBoaz Harrosh }; 4089a74af21SBoaz Harrosh 4099a74af21SBoaz Harrosh struct nfsd4_write { 4109a74af21SBoaz Harrosh stateid_t wr_stateid; /* request */ 4119a74af21SBoaz Harrosh u64 wr_offset; /* request */ 4129a74af21SBoaz Harrosh u32 wr_stable_how; /* request */ 4139a74af21SBoaz Harrosh u32 wr_buflen; /* request */ 414c1346a12SChuck Lever struct xdr_buf wr_payload; /* request */ 4159a74af21SBoaz Harrosh 4169a74af21SBoaz Harrosh u32 wr_bytes_written; /* response */ 4179a74af21SBoaz Harrosh u32 wr_how_written; /* response */ 4189a74af21SBoaz Harrosh nfs4_verifier wr_verifier; /* response */ 4199a74af21SBoaz Harrosh }; 4209a74af21SBoaz Harrosh 4219a74af21SBoaz Harrosh struct nfsd4_exchange_id { 4229a74af21SBoaz Harrosh nfs4_verifier verifier; 4239a74af21SBoaz Harrosh struct xdr_netobj clname; 4249a74af21SBoaz Harrosh u32 flags; 4259a74af21SBoaz Harrosh clientid_t clientid; 4269a74af21SBoaz Harrosh u32 seqid; 427523ec6edSChuck Lever u32 spa_how; 428ed941643SAndrew Elble u32 spo_must_enforce[3]; 429ed941643SAndrew Elble u32 spo_must_allow[3]; 43079123444SJ. Bruce Fields struct xdr_netobj nii_domain; 43179123444SJ. Bruce Fields struct xdr_netobj nii_name; 43279123444SJ. Bruce Fields struct timespec64 nii_time; 4339a74af21SBoaz Harrosh }; 4349a74af21SBoaz Harrosh 4359a74af21SBoaz Harrosh struct nfsd4_sequence { 4369a74af21SBoaz Harrosh struct nfs4_sessionid sessionid; /* request/response */ 4379a74af21SBoaz Harrosh u32 seqid; /* request/response */ 4389a74af21SBoaz Harrosh u32 slotid; /* request/response */ 4399a74af21SBoaz Harrosh u32 maxslots; /* request/response */ 4409a74af21SBoaz Harrosh u32 cachethis; /* request */ 4419a74af21SBoaz Harrosh #if 0 4429a74af21SBoaz Harrosh u32 target_maxslots; /* response */ 4439a74af21SBoaz Harrosh #endif /* not yet */ 4440d7bb719SJ. Bruce Fields u32 status_flags; /* response */ 4459a74af21SBoaz Harrosh }; 4469a74af21SBoaz Harrosh 4479a74af21SBoaz Harrosh struct nfsd4_destroy_session { 4489a74af21SBoaz Harrosh struct nfs4_sessionid sessionid; 4499a74af21SBoaz Harrosh }; 4509a74af21SBoaz Harrosh 451345c2842SMi Jinlong struct nfsd4_destroy_clientid { 452345c2842SMi Jinlong clientid_t clientid; 453345c2842SMi Jinlong }; 454345c2842SMi Jinlong 4554dc6ec00SJ. Bruce Fields struct nfsd4_reclaim_complete { 4564dc6ec00SJ. Bruce Fields u32 rca_one_fs; 4574dc6ec00SJ. Bruce Fields }; 4584dc6ec00SJ. Bruce Fields 4599cf514ccSChristoph Hellwig struct nfsd4_deviceid { 4609cf514ccSChristoph Hellwig u64 fsid_idx; 4619cf514ccSChristoph Hellwig u32 generation; 4629cf514ccSChristoph Hellwig u32 pad; 4639cf514ccSChristoph Hellwig }; 4649cf514ccSChristoph Hellwig 4659cf514ccSChristoph Hellwig struct nfsd4_layout_seg { 4669cf514ccSChristoph Hellwig u32 iomode; 4679cf514ccSChristoph Hellwig u64 offset; 4689cf514ccSChristoph Hellwig u64 length; 4699cf514ccSChristoph Hellwig }; 4709cf514ccSChristoph Hellwig 4719cf514ccSChristoph Hellwig struct nfsd4_getdeviceinfo { 4729cf514ccSChristoph Hellwig struct nfsd4_deviceid gd_devid; /* request */ 4739cf514ccSChristoph Hellwig u32 gd_layout_type; /* request */ 4749cf514ccSChristoph Hellwig u32 gd_maxcount; /* request */ 4759cf514ccSChristoph Hellwig u32 gd_notify_types;/* request - response */ 4769cf514ccSChristoph Hellwig void *gd_device; /* response */ 4779cf514ccSChristoph Hellwig }; 4789cf514ccSChristoph Hellwig 4799cf514ccSChristoph Hellwig struct nfsd4_layoutget { 4809cf514ccSChristoph Hellwig u64 lg_minlength; /* request */ 4819cf514ccSChristoph Hellwig u32 lg_signal; /* request */ 4829cf514ccSChristoph Hellwig u32 lg_layout_type; /* request */ 4839cf514ccSChristoph Hellwig u32 lg_maxcount; /* request */ 4849cf514ccSChristoph Hellwig stateid_t lg_sid; /* request/response */ 4859cf514ccSChristoph Hellwig struct nfsd4_layout_seg lg_seg; /* request/response */ 4869cf514ccSChristoph Hellwig void *lg_content; /* response */ 4879cf514ccSChristoph Hellwig }; 4889cf514ccSChristoph Hellwig 4899cf514ccSChristoph Hellwig struct nfsd4_layoutcommit { 4909cf514ccSChristoph Hellwig stateid_t lc_sid; /* request */ 4919cf514ccSChristoph Hellwig struct nfsd4_layout_seg lc_seg; /* request */ 4929cf514ccSChristoph Hellwig u32 lc_reclaim; /* request */ 4939cf514ccSChristoph Hellwig u32 lc_newoffset; /* request */ 4949cf514ccSChristoph Hellwig u64 lc_last_wr; /* request */ 495bdba5368SJ. Bruce Fields struct timespec64 lc_mtime; /* request */ 4969cf514ccSChristoph Hellwig u32 lc_layout_type; /* request */ 4979cf514ccSChristoph Hellwig u32 lc_up_len; /* layout length */ 4989cf514ccSChristoph Hellwig void *lc_up_layout; /* decoded by callback */ 4999cf514ccSChristoph Hellwig u32 lc_size_chg; /* boolean for response */ 5009cf514ccSChristoph Hellwig u64 lc_newsize; /* response */ 5019cf514ccSChristoph Hellwig }; 5029cf514ccSChristoph Hellwig 5039cf514ccSChristoph Hellwig struct nfsd4_layoutreturn { 5049cf514ccSChristoph Hellwig u32 lr_return_type; /* request */ 5059cf514ccSChristoph Hellwig u32 lr_layout_type; /* request */ 5069cf514ccSChristoph Hellwig struct nfsd4_layout_seg lr_seg; /* request */ 5079cf514ccSChristoph Hellwig u32 lr_reclaim; /* request */ 5089cf514ccSChristoph Hellwig u32 lrf_body_len; /* request */ 5099cf514ccSChristoph Hellwig void *lrf_body; /* request */ 5109cf514ccSChristoph Hellwig stateid_t lr_sid; /* request/response */ 5119cf514ccSChristoph Hellwig u32 lrs_present; /* response */ 5129cf514ccSChristoph Hellwig }; 5139cf514ccSChristoph Hellwig 51495d871f0SAnna Schumaker struct nfsd4_fallocate { 51595d871f0SAnna Schumaker /* request */ 51695d871f0SAnna Schumaker stateid_t falloc_stateid; 51795d871f0SAnna Schumaker loff_t falloc_offset; 51895d871f0SAnna Schumaker u64 falloc_length; 51995d871f0SAnna Schumaker }; 52095d871f0SAnna Schumaker 521ffa0160aSChristoph Hellwig struct nfsd4_clone { 522ffa0160aSChristoph Hellwig /* request */ 523ffa0160aSChristoph Hellwig stateid_t cl_src_stateid; 524ffa0160aSChristoph Hellwig stateid_t cl_dst_stateid; 525ffa0160aSChristoph Hellwig u64 cl_src_pos; 526ffa0160aSChristoph Hellwig u64 cl_dst_pos; 527ffa0160aSChristoph Hellwig u64 cl_count; 528ffa0160aSChristoph Hellwig }; 529ffa0160aSChristoph Hellwig 53029ae7f9dSAnna Schumaker struct nfsd42_write_res { 53129ae7f9dSAnna Schumaker u64 wr_bytes_written; 53229ae7f9dSAnna Schumaker u32 wr_stable_how; 53329ae7f9dSAnna Schumaker nfs4_verifier wr_verifier; 5349eb190fcSOlga Kornievskaia stateid_t cb_stateid; 53529ae7f9dSAnna Schumaker }; 53629ae7f9dSAnna Schumaker 537a11ada99SChuck Lever struct nfsd4_cb_offload { 538a11ada99SChuck Lever struct nfsd4_callback co_cb; 539a11ada99SChuck Lever struct nfsd42_write_res co_res; 540a11ada99SChuck Lever __be32 co_nfserr; 541a11ada99SChuck Lever struct knfsd_fh co_fh; 542a11ada99SChuck Lever }; 543a11ada99SChuck Lever 54429ae7f9dSAnna Schumaker struct nfsd4_copy { 54529ae7f9dSAnna Schumaker /* request */ 54629ae7f9dSAnna Schumaker stateid_t cp_src_stateid; 54729ae7f9dSAnna Schumaker stateid_t cp_dst_stateid; 54829ae7f9dSAnna Schumaker u64 cp_src_pos; 54929ae7f9dSAnna Schumaker u64 cp_dst_pos; 55029ae7f9dSAnna Schumaker u64 cp_count; 55187689df6SChuck Lever struct nl4_server *cp_src; 55229ae7f9dSAnna Schumaker 5531913cdf5SChuck Lever unsigned long cp_flags; 5541913cdf5SChuck Lever #define NFSD4_COPY_F_STOPPED (0) 5551913cdf5SChuck Lever #define NFSD4_COPY_F_INTRA (1) 5561913cdf5SChuck Lever #define NFSD4_COPY_F_SYNCHRONOUS (2) 5571913cdf5SChuck Lever #define NFSD4_COPY_F_COMMITTED (3) 55829ae7f9dSAnna Schumaker 55929ae7f9dSAnna Schumaker /* response */ 56029ae7f9dSAnna Schumaker struct nfsd42_write_res cp_res; 5619eb190fcSOlga Kornievskaia struct knfsd_fh fh; 562e0639dc5SOlga Kornievskaia 563e0639dc5SOlga Kornievskaia struct nfs4_client *cp_clp; 564e0639dc5SOlga Kornievskaia 5655c4583b2SJeff Layton struct nfsd_file *nf_src; 5665c4583b2SJeff Layton struct nfsd_file *nf_dst; 567e0639dc5SOlga Kornievskaia 568624322f1SOlga Kornievskaia copy_stateid_t cp_stateid; 569e0639dc5SOlga Kornievskaia 570e0639dc5SOlga Kornievskaia struct list_head copies; 571e0639dc5SOlga Kornievskaia struct task_struct *copy_task; 572e0639dc5SOlga Kornievskaia refcount_t refcount; 573ce0887acSOlga Kornievskaia 574ce0887acSOlga Kornievskaia struct vfsmount *ss_mnt; 575ce0887acSOlga Kornievskaia struct nfs_fh c_fh; 576ce0887acSOlga Kornievskaia nfs4_stateid stateid; 57729ae7f9dSAnna Schumaker }; 57829ae7f9dSAnna Schumaker 5791913cdf5SChuck Lever static inline void nfsd4_copy_set_sync(struct nfsd4_copy *copy, bool sync) 5801913cdf5SChuck Lever { 5811913cdf5SChuck Lever if (sync) 5821913cdf5SChuck Lever set_bit(NFSD4_COPY_F_SYNCHRONOUS, ©->cp_flags); 5831913cdf5SChuck Lever else 5841913cdf5SChuck Lever clear_bit(NFSD4_COPY_F_SYNCHRONOUS, ©->cp_flags); 5851913cdf5SChuck Lever } 5861913cdf5SChuck Lever 5871913cdf5SChuck Lever static inline bool nfsd4_copy_is_sync(const struct nfsd4_copy *copy) 5881913cdf5SChuck Lever { 5891913cdf5SChuck Lever return test_bit(NFSD4_COPY_F_SYNCHRONOUS, ©->cp_flags); 5901913cdf5SChuck Lever } 5911913cdf5SChuck Lever 5921913cdf5SChuck Lever static inline bool nfsd4_copy_is_async(const struct nfsd4_copy *copy) 5931913cdf5SChuck Lever { 5941913cdf5SChuck Lever return !test_bit(NFSD4_COPY_F_SYNCHRONOUS, ©->cp_flags); 5951913cdf5SChuck Lever } 5961913cdf5SChuck Lever 5971913cdf5SChuck Lever static inline bool nfsd4_ssc_is_inter(const struct nfsd4_copy *copy) 5981913cdf5SChuck Lever { 5991913cdf5SChuck Lever return !test_bit(NFSD4_COPY_F_INTRA, ©->cp_flags); 6001913cdf5SChuck Lever } 6011913cdf5SChuck Lever 60224bab491SAnna Schumaker struct nfsd4_seek { 60324bab491SAnna Schumaker /* request */ 60424bab491SAnna Schumaker stateid_t seek_stateid; 60524bab491SAnna Schumaker loff_t seek_offset; 60624bab491SAnna Schumaker u32 seek_whence; 60724bab491SAnna Schumaker 60824bab491SAnna Schumaker /* response */ 60924bab491SAnna Schumaker u32 seek_eof; 61024bab491SAnna Schumaker loff_t seek_pos; 61124bab491SAnna Schumaker }; 61224bab491SAnna Schumaker 6136308bc98SOlga Kornievskaia struct nfsd4_offload_status { 6146308bc98SOlga Kornievskaia /* request */ 6156308bc98SOlga Kornievskaia stateid_t stateid; 6166308bc98SOlga Kornievskaia 6176308bc98SOlga Kornievskaia /* response */ 6186308bc98SOlga Kornievskaia u64 count; 6196308bc98SOlga Kornievskaia u32 status; 6206308bc98SOlga Kornievskaia }; 6216308bc98SOlga Kornievskaia 62251911868SOlga Kornievskaia struct nfsd4_copy_notify { 62351911868SOlga Kornievskaia /* request */ 62451911868SOlga Kornievskaia stateid_t cpn_src_stateid; 62509426ef2SChuck Lever struct nl4_server *cpn_dst; 62651911868SOlga Kornievskaia 62751911868SOlga Kornievskaia /* response */ 62851911868SOlga Kornievskaia stateid_t cpn_cnr_stateid; 62951911868SOlga Kornievskaia u64 cpn_sec; 63051911868SOlga Kornievskaia u32 cpn_nsec; 63109426ef2SChuck Lever struct nl4_server *cpn_src; 63251911868SOlga Kornievskaia }; 63351911868SOlga Kornievskaia 6349a74af21SBoaz Harrosh struct nfsd4_op { 6353a237b4aSChuck Lever u32 opnum; 6369a74af21SBoaz Harrosh __be32 status; 637d3143094SChuck Lever const struct nfsd4_operation *opdesc; 638d3143094SChuck Lever struct nfs4_replay *replay; 639b60e9859SChristoph Hellwig union nfsd4_op_u { 6409a74af21SBoaz Harrosh struct nfsd4_access access; 6419a74af21SBoaz Harrosh struct nfsd4_close close; 6429a74af21SBoaz Harrosh struct nfsd4_commit commit; 6439a74af21SBoaz Harrosh struct nfsd4_create create; 6449a74af21SBoaz Harrosh struct nfsd4_delegreturn delegreturn; 6459a74af21SBoaz Harrosh struct nfsd4_getattr getattr; 6469a74af21SBoaz Harrosh struct svc_fh * getfh; 6479a74af21SBoaz Harrosh struct nfsd4_link link; 6489a74af21SBoaz Harrosh struct nfsd4_lock lock; 6499a74af21SBoaz Harrosh struct nfsd4_lockt lockt; 6509a74af21SBoaz Harrosh struct nfsd4_locku locku; 6519a74af21SBoaz Harrosh struct nfsd4_lookup lookup; 6529a74af21SBoaz Harrosh struct nfsd4_verify nverify; 6539a74af21SBoaz Harrosh struct nfsd4_open open; 6549a74af21SBoaz Harrosh struct nfsd4_open_confirm open_confirm; 6559a74af21SBoaz Harrosh struct nfsd4_open_downgrade open_downgrade; 6569a74af21SBoaz Harrosh struct nfsd4_putfh putfh; 6579a74af21SBoaz Harrosh struct nfsd4_read read; 6589a74af21SBoaz Harrosh struct nfsd4_readdir readdir; 6599a74af21SBoaz Harrosh struct nfsd4_readlink readlink; 6609a74af21SBoaz Harrosh struct nfsd4_remove remove; 6619a74af21SBoaz Harrosh struct nfsd4_rename rename; 6629a74af21SBoaz Harrosh clientid_t renew; 6639a74af21SBoaz Harrosh struct nfsd4_secinfo secinfo; 6649a74af21SBoaz Harrosh struct nfsd4_setattr setattr; 6659a74af21SBoaz Harrosh struct nfsd4_setclientid setclientid; 6669a74af21SBoaz Harrosh struct nfsd4_setclientid_confirm setclientid_confirm; 6679a74af21SBoaz Harrosh struct nfsd4_verify verify; 6689a74af21SBoaz Harrosh struct nfsd4_write write; 6699a74af21SBoaz Harrosh struct nfsd4_release_lockowner release_lockowner; 6709a74af21SBoaz Harrosh 6719a74af21SBoaz Harrosh /* NFSv4.1 */ 6729a74af21SBoaz Harrosh struct nfsd4_exchange_id exchange_id; 673cb73a9f4SJ. Bruce Fields struct nfsd4_backchannel_ctl backchannel_ctl; 6741d1bc8f2SJ. Bruce Fields struct nfsd4_bind_conn_to_session bind_conn_to_session; 6759a74af21SBoaz Harrosh struct nfsd4_create_session create_session; 6769a74af21SBoaz Harrosh struct nfsd4_destroy_session destroy_session; 677eb69853dSChristoph Hellwig struct nfsd4_destroy_clientid destroy_clientid; 6789a74af21SBoaz Harrosh struct nfsd4_sequence sequence; 6794dc6ec00SJ. Bruce Fields struct nfsd4_reclaim_complete reclaim_complete; 68017456804SBryan Schumaker struct nfsd4_test_stateid test_stateid; 681e1ca12dfSBryan Schumaker struct nfsd4_free_stateid free_stateid; 6829cf514ccSChristoph Hellwig struct nfsd4_getdeviceinfo getdeviceinfo; 6839cf514ccSChristoph Hellwig struct nfsd4_layoutget layoutget; 6849cf514ccSChristoph Hellwig struct nfsd4_layoutcommit layoutcommit; 6859cf514ccSChristoph Hellwig struct nfsd4_layoutreturn layoutreturn; 686eb69853dSChristoph Hellwig struct nfsd4_secinfo_no_name secinfo_no_name; 68724bab491SAnna Schumaker 68824bab491SAnna Schumaker /* NFSv4.2 */ 68995d871f0SAnna Schumaker struct nfsd4_fallocate allocate; 690b0cb9085SAnna Schumaker struct nfsd4_fallocate deallocate; 691ffa0160aSChristoph Hellwig struct nfsd4_clone clone; 69229ae7f9dSAnna Schumaker struct nfsd4_copy copy; 6936308bc98SOlga Kornievskaia struct nfsd4_offload_status offload_status; 69451911868SOlga Kornievskaia struct nfsd4_copy_notify copy_notify; 69524bab491SAnna Schumaker struct nfsd4_seek seek; 6966178713bSFrank van der Linden 6976178713bSFrank van der Linden struct nfsd4_getxattr getxattr; 6986178713bSFrank van der Linden struct nfsd4_setxattr setxattr; 6996178713bSFrank van der Linden struct nfsd4_listxattrs listxattrs; 7006178713bSFrank van der Linden struct nfsd4_removexattr removexattr; 7019a74af21SBoaz Harrosh } u; 7029a74af21SBoaz Harrosh }; 7039a74af21SBoaz Harrosh 7041091006cSJ. Bruce Fields bool nfsd4_cache_this_op(struct nfsd4_op *); 7051091006cSJ. Bruce Fields 706d5e23383SJ. Bruce Fields /* 707d5e23383SJ. Bruce Fields * Memory needed just for the duration of processing one compound: 708d5e23383SJ. Bruce Fields */ 709d5e23383SJ. Bruce Fields struct svcxdr_tmpbuf { 710d5e23383SJ. Bruce Fields struct svcxdr_tmpbuf *next; 711d5e23383SJ. Bruce Fields char buf[]; 712d5e23383SJ. Bruce Fields }; 713d5e23383SJ. Bruce Fields 7149a74af21SBoaz Harrosh struct nfsd4_compoundargs { 7159a74af21SBoaz Harrosh /* scratch variables for XDR decode */ 716c1346a12SChuck Lever struct xdr_stream *xdr; 717d5e23383SJ. Bruce Fields struct svcxdr_tmpbuf *to_free; 7189a74af21SBoaz Harrosh struct svc_rqst *rqstp; 7199a74af21SBoaz Harrosh 7209a74af21SBoaz Harrosh char * tag; 7217518a3dcSChuck Lever u32 taglen; 7229a74af21SBoaz Harrosh u32 minorversion; 7237518a3dcSChuck Lever u32 client_opcnt; 7249a74af21SBoaz Harrosh u32 opcnt; 7259a74af21SBoaz Harrosh struct nfsd4_op *ops; 7269a74af21SBoaz Harrosh struct nfsd4_op iops[8]; 7279a74af21SBoaz Harrosh }; 7289a74af21SBoaz Harrosh 7299a74af21SBoaz Harrosh struct nfsd4_compoundres { 7309a74af21SBoaz Harrosh /* scratch variables for XDR encode */ 731bddfdbcdSChuck Lever struct xdr_stream *xdr; 7329a74af21SBoaz Harrosh struct svc_rqst * rqstp; 7339a74af21SBoaz Harrosh 7343b0ebb25SChuck Lever __be32 *statusp; 7359a74af21SBoaz Harrosh char * tag; 736*9f553e61SChuck Lever u32 taglen; 7379a74af21SBoaz Harrosh u32 opcnt; 7383b0ebb25SChuck Lever 7399a74af21SBoaz Harrosh struct nfsd4_compound_state cstate; 7409a74af21SBoaz Harrosh }; 7419a74af21SBoaz Harrosh 7429a74af21SBoaz Harrosh static inline bool nfsd4_is_solo_sequence(struct nfsd4_compoundres *resp) 7439a74af21SBoaz Harrosh { 7449a74af21SBoaz Harrosh struct nfsd4_compoundargs *args = resp->rqstp->rq_argp; 7459a74af21SBoaz Harrosh return resp->opcnt == 1 && args->ops[0].opnum == OP_SEQUENCE; 7469a74af21SBoaz Harrosh } 7479a74af21SBoaz Harrosh 748085def3aSJ. Bruce Fields /* 749085def3aSJ. Bruce Fields * The session reply cache only needs to cache replies that the client 750085def3aSJ. Bruce Fields * actually asked us to. But it's almost free for us to cache compounds 751085def3aSJ. Bruce Fields * consisting of only a SEQUENCE op, so we may as well cache those too. 752085def3aSJ. Bruce Fields * Also, the protocol doesn't give us a convenient response in the case 753085def3aSJ. Bruce Fields * of a replay of a solo SEQUENCE op that wasn't cached 754085def3aSJ. Bruce Fields * (RETRY_UNCACHED_REP can only be returned in the second op of a 755085def3aSJ. Bruce Fields * compound). 756085def3aSJ. Bruce Fields */ 757085def3aSJ. Bruce Fields static inline bool nfsd4_cache_this(struct nfsd4_compoundres *resp) 7589a74af21SBoaz Harrosh { 759085def3aSJ. Bruce Fields return (resp->cstate.slot->sl_flags & NFSD4_SLOT_CACHETHIS) 76073e79482SJ. Bruce Fields || nfsd4_is_solo_sequence(resp); 7619a74af21SBoaz Harrosh } 7629a74af21SBoaz Harrosh 7639b3234b9SJ. Bruce Fields static inline bool nfsd4_last_compound_op(struct svc_rqst *rqstp) 7649b3234b9SJ. Bruce Fields { 7659b3234b9SJ. Bruce Fields struct nfsd4_compoundres *resp = rqstp->rq_resp; 7669b3234b9SJ. Bruce Fields struct nfsd4_compoundargs *argp = rqstp->rq_argp; 7679b3234b9SJ. Bruce Fields 7689b3234b9SJ. Bruce Fields return argp->opcnt == resp->opcnt; 7699b3234b9SJ. Bruce Fields } 7709b3234b9SJ. Bruce Fields 771f4f9ef4aSJ. Bruce Fields const struct nfsd4_operation *OPDESC(struct nfsd4_op *op); 7724f0cefbfSJ. Bruce Fields int nfsd4_max_reply(struct svc_rqst *rqstp, struct nfsd4_op *op); 77307d1f802SJ. Bruce Fields void warn_on_nonidempotent_op(struct nfsd4_op *op); 77407d1f802SJ. Bruce Fields 7759a74af21SBoaz Harrosh #define NFS4_SVC_XDRSIZE sizeof(struct nfsd4_compoundargs) 7769a74af21SBoaz Harrosh 7779a74af21SBoaz Harrosh static inline void 7789a74af21SBoaz Harrosh set_change_info(struct nfsd4_change_info *cinfo, struct svc_fh *fhp) 7799a74af21SBoaz Harrosh { 780c1ac3ffcSNeil Brown BUG_ON(!fhp->fh_pre_saved); 781716a8bc7STrond Myklebust cinfo->atomic = (u32)(fhp->fh_post_saved && !fhp->fh_no_atomic_attr); 782c1ac3ffcSNeil Brown 7839a74af21SBoaz Harrosh cinfo->before_change = fhp->fh_pre_change; 7849a74af21SBoaz Harrosh cinfo->after_change = fhp->fh_post_change; 7859a74af21SBoaz Harrosh } 7869a74af21SBoaz Harrosh 787dedeb13fSAndrew Elble 788dedeb13fSAndrew Elble bool nfsd4_mach_creds_match(struct nfs4_client *cl, struct svc_rqst *rqstp); 789c44b31c2SChuck Lever bool nfs4svc_decode_compoundargs(struct svc_rqst *rqstp, struct xdr_stream *xdr); 790130e2054SChuck Lever bool nfs4svc_encode_compoundres(struct svc_rqst *rqstp, struct xdr_stream *xdr); 79157b7b43bSJ. Bruce Fields __be32 nfsd4_check_resp_size(struct nfsd4_compoundres *, u32); 7929a74af21SBoaz Harrosh void nfsd4_encode_operation(struct nfsd4_compoundres *, struct nfsd4_op *); 793d0a381ddSJ. Bruce Fields void nfsd4_encode_replay(struct xdr_stream *xdr, struct nfsd4_op *op); 794d5184658SJ. Bruce Fields __be32 nfsd4_encode_fattr_to_buf(__be32 **p, int words, 795d5184658SJ. Bruce Fields struct svc_fh *fhp, struct svc_export *exp, 796d5184658SJ. Bruce Fields struct dentry *dentry, 7979a74af21SBoaz Harrosh u32 *bmval, struct svc_rqst *, int ignore_crossmnt); 7989a74af21SBoaz Harrosh extern __be32 nfsd4_setclientid(struct svc_rqst *rqstp, 799eb69853dSChristoph Hellwig struct nfsd4_compound_state *, union nfsd4_op_u *u); 8009a74af21SBoaz Harrosh extern __be32 nfsd4_setclientid_confirm(struct svc_rqst *rqstp, 801eb69853dSChristoph Hellwig struct nfsd4_compound_state *, union nfsd4_op_u *u); 8029a74af21SBoaz Harrosh extern __be32 nfsd4_exchange_id(struct svc_rqst *rqstp, 803eb69853dSChristoph Hellwig struct nfsd4_compound_state *, union nfsd4_op_u *u); 804eb69853dSChristoph Hellwig extern __be32 nfsd4_backchannel_ctl(struct svc_rqst *, 805eb69853dSChristoph Hellwig struct nfsd4_compound_state *, union nfsd4_op_u *u); 806eb69853dSChristoph Hellwig extern __be32 nfsd4_bind_conn_to_session(struct svc_rqst *, 807eb69853dSChristoph Hellwig struct nfsd4_compound_state *, union nfsd4_op_u *u); 8089a74af21SBoaz Harrosh extern __be32 nfsd4_create_session(struct svc_rqst *, 809eb69853dSChristoph Hellwig struct nfsd4_compound_state *, union nfsd4_op_u *u); 8109a74af21SBoaz Harrosh extern __be32 nfsd4_sequence(struct svc_rqst *, 811eb69853dSChristoph Hellwig struct nfsd4_compound_state *, union nfsd4_op_u *u); 812b607664eSTrond Myklebust extern void nfsd4_sequence_done(struct nfsd4_compoundres *resp); 8139a74af21SBoaz Harrosh extern __be32 nfsd4_destroy_session(struct svc_rqst *, 814eb69853dSChristoph Hellwig struct nfsd4_compound_state *, union nfsd4_op_u *u); 815eb69853dSChristoph Hellwig extern __be32 nfsd4_destroy_clientid(struct svc_rqst *, struct nfsd4_compound_state *, 816eb69853dSChristoph Hellwig union nfsd4_op_u *u); 817eb69853dSChristoph Hellwig __be32 nfsd4_reclaim_complete(struct svc_rqst *, struct nfsd4_compound_state *, 818eb69853dSChristoph Hellwig union nfsd4_op_u *u); 8199a74af21SBoaz Harrosh extern __be32 nfsd4_process_open1(struct nfsd4_compound_state *, 8203320fef1SStanislav Kinsbursky struct nfsd4_open *open, struct nfsd_net *nn); 8219a74af21SBoaz Harrosh extern __be32 nfsd4_process_open2(struct svc_rqst *rqstp, 8229a74af21SBoaz Harrosh struct svc_fh *current_fh, struct nfsd4_open *open); 82358fb12e6SJeff Layton extern void nfsd4_cstate_clear_replay(struct nfsd4_compound_state *cstate); 82458fb12e6SJeff Layton extern void nfsd4_cleanup_open_state(struct nfsd4_compound_state *cstate, 82542297899SJeff Layton struct nfsd4_open *open); 8269a74af21SBoaz Harrosh extern __be32 nfsd4_open_confirm(struct svc_rqst *rqstp, 827eb69853dSChristoph Hellwig struct nfsd4_compound_state *, union nfsd4_op_u *u); 828eb69853dSChristoph Hellwig extern __be32 nfsd4_close(struct svc_rqst *rqstp, struct nfsd4_compound_state *, 829eb69853dSChristoph Hellwig union nfsd4_op_u *u); 8309a74af21SBoaz Harrosh extern __be32 nfsd4_open_downgrade(struct svc_rqst *rqstp, 831eb69853dSChristoph Hellwig struct nfsd4_compound_state *, union nfsd4_op_u *u); 8329a74af21SBoaz Harrosh extern __be32 nfsd4_lock(struct svc_rqst *rqstp, struct nfsd4_compound_state *, 833eb69853dSChristoph Hellwig union nfsd4_op_u *u); 834eb69853dSChristoph Hellwig extern __be32 nfsd4_lockt(struct svc_rqst *rqstp, struct nfsd4_compound_state *, 835eb69853dSChristoph Hellwig union nfsd4_op_u *u); 836eb69853dSChristoph Hellwig extern __be32 nfsd4_locku(struct svc_rqst *rqstp, struct nfsd4_compound_state *, 837eb69853dSChristoph Hellwig union nfsd4_op_u *u); 8389a74af21SBoaz Harrosh extern __be32 8399a74af21SBoaz Harrosh nfsd4_release_lockowner(struct svc_rqst *rqstp, 840eb69853dSChristoph Hellwig struct nfsd4_compound_state *, union nfsd4_op_u *u); 8418537488bSChristoph Hellwig extern void nfsd4_release_compoundargs(struct svc_rqst *rqstp); 8429a74af21SBoaz Harrosh extern __be32 nfsd4_delegreturn(struct svc_rqst *rqstp, 843eb69853dSChristoph Hellwig struct nfsd4_compound_state *, union nfsd4_op_u *u); 844eb69853dSChristoph Hellwig extern __be32 nfsd4_renew(struct svc_rqst *rqstp, struct nfsd4_compound_state *, 845eb69853dSChristoph Hellwig union nfsd4_op_u *u); 84617456804SBryan Schumaker extern __be32 nfsd4_test_stateid(struct svc_rqst *rqstp, 847eb69853dSChristoph Hellwig struct nfsd4_compound_state *, union nfsd4_op_u *); 848e1ca12dfSBryan Schumaker extern __be32 nfsd4_free_stateid(struct svc_rqst *rqstp, 849eb69853dSChristoph Hellwig struct nfsd4_compound_state *, union nfsd4_op_u *); 8509411b1d4SJ. Bruce Fields extern void nfsd4_bump_seqid(struct nfsd4_compound_state *, __be32 nfserr); 85158fb12e6SJeff Layton 8520020939fSJ. Bruce Fields enum nfsd4_op_flags { 8530020939fSJ. Bruce Fields ALLOWED_WITHOUT_FH = 1 << 0, /* No current filehandle required */ 8540020939fSJ. Bruce Fields ALLOWED_ON_ABSENT_FS = 1 << 1, /* ops processed on absent fs */ 8550020939fSJ. Bruce Fields ALLOWED_AS_FIRST_OP = 1 << 2, /* ops reqired first in compound */ 8560020939fSJ. Bruce Fields /* For rfc 5661 section 2.6.3.1.1: */ 8570020939fSJ. Bruce Fields OP_HANDLES_WRONGSEC = 1 << 3, 8580020939fSJ. Bruce Fields OP_IS_PUTFH_LIKE = 1 << 4, 8590020939fSJ. Bruce Fields /* 8600020939fSJ. Bruce Fields * These are the ops whose result size we estimate before 8610020939fSJ. Bruce Fields * encoding, to avoid performing an op then not being able to 8620020939fSJ. Bruce Fields * respond or cache a response. This includes writes and setattrs 8630020939fSJ. Bruce Fields * as well as the operations usually called "nonidempotent": 8640020939fSJ. Bruce Fields */ 8650020939fSJ. Bruce Fields OP_MODIFIES_SOMETHING = 1 << 5, 8660020939fSJ. Bruce Fields /* 8670020939fSJ. Bruce Fields * Cache compounds containing these ops in the xid-based drc: 8680020939fSJ. Bruce Fields * We use the DRC for compounds containing non-idempotent 8690020939fSJ. Bruce Fields * operations, *except* those that are 4.1-specific (since 8700020939fSJ. Bruce Fields * sessions provide their own EOS), and except for stateful 8710020939fSJ. Bruce Fields * operations other than setclientid and setclientid_confirm 8720020939fSJ. Bruce Fields * (since sequence numbers provide EOS for open, lock, etc in 8730020939fSJ. Bruce Fields * the v4.0 case). 8740020939fSJ. Bruce Fields */ 8750020939fSJ. Bruce Fields OP_CACHEME = 1 << 6, 8760020939fSJ. Bruce Fields /* 8770020939fSJ. Bruce Fields * These are ops which clear current state id. 8780020939fSJ. Bruce Fields */ 8790020939fSJ. Bruce Fields OP_CLEAR_STATEID = 1 << 7, 880b7571e4cSJ. Bruce Fields /* Most ops return only an error on failure; some may do more: */ 881b7571e4cSJ. Bruce Fields OP_NONTRIVIAL_ERROR_ENCODE = 1 << 8, 8820020939fSJ. Bruce Fields }; 8830020939fSJ. Bruce Fields 8840020939fSJ. Bruce Fields struct nfsd4_operation { 8850020939fSJ. Bruce Fields __be32 (*op_func)(struct svc_rqst *, struct nfsd4_compound_state *, 8860020939fSJ. Bruce Fields union nfsd4_op_u *); 88734b1744cSJ. Bruce Fields void (*op_release)(union nfsd4_op_u *); 8880020939fSJ. Bruce Fields u32 op_flags; 8890020939fSJ. Bruce Fields char *op_name; 8900020939fSJ. Bruce Fields /* Try to get response size before operation */ 8916604148cSChuck Lever u32 (*op_rsize_bop)(const struct svc_rqst *rqstp, 8926604148cSChuck Lever const struct nfsd4_op *op); 8930020939fSJ. Bruce Fields void (*op_get_currentstateid)(struct nfsd4_compound_state *, 8940020939fSJ. Bruce Fields union nfsd4_op_u *); 8950020939fSJ. Bruce Fields void (*op_set_currentstateid)(struct nfsd4_compound_state *, 8960020939fSJ. Bruce Fields union nfsd4_op_u *); 8970020939fSJ. Bruce Fields }; 8980020939fSJ. Bruce Fields 8990020939fSJ. Bruce Fields 9009a74af21SBoaz Harrosh #endif 901