11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * linux/fs/nfs/callback.h 31da177e4SLinus Torvalds * 41da177e4SLinus Torvalds * Copyright (C) 2004 Trond Myklebust 51da177e4SLinus Torvalds * 61da177e4SLinus Torvalds * NFSv4 callback definitions 71da177e4SLinus Torvalds */ 81da177e4SLinus Torvalds #ifndef __LINUX_FS_NFS_CALLBACK_H 91da177e4SLinus Torvalds #define __LINUX_FS_NFS_CALLBACK_H 10778be232SAndy Adamson #include <linux/sunrpc/svc.h> 111da177e4SLinus Torvalds 121da177e4SLinus Torvalds #define NFS4_CALLBACK 0x40000000 131da177e4SLinus Torvalds #define NFS4_CALLBACK_XDRSIZE 2048 141da177e4SLinus Torvalds #define NFS4_CALLBACK_BUFSIZE (1024 + NFS4_CALLBACK_XDRSIZE) 151da177e4SLinus Torvalds 161da177e4SLinus Torvalds enum nfs4_callback_procnum { 171da177e4SLinus Torvalds CB_NULL = 0, 181da177e4SLinus Torvalds CB_COMPOUND = 1, 191da177e4SLinus Torvalds }; 201da177e4SLinus Torvalds 211da177e4SLinus Torvalds enum nfs4_callback_opnum { 221da177e4SLinus Torvalds OP_CB_GETATTR = 3, 231da177e4SLinus Torvalds OP_CB_RECALL = 4, 2445377b94SBenny Halevy /* Callback operations new to NFSv4.1 */ 2545377b94SBenny Halevy OP_CB_LAYOUTRECALL = 5, 2645377b94SBenny Halevy OP_CB_NOTIFY = 6, 2745377b94SBenny Halevy OP_CB_PUSH_DELEG = 7, 2845377b94SBenny Halevy OP_CB_RECALL_ANY = 8, 2945377b94SBenny Halevy OP_CB_RECALLABLE_OBJ_AVAIL = 9, 3045377b94SBenny Halevy OP_CB_RECALL_SLOT = 10, 3145377b94SBenny Halevy OP_CB_SEQUENCE = 11, 3245377b94SBenny Halevy OP_CB_WANTS_CANCELLED = 12, 3345377b94SBenny Halevy OP_CB_NOTIFY_LOCK = 13, 3434bc47c9SBenny Halevy OP_CB_NOTIFY_DEVICEID = 14, 351da177e4SLinus Torvalds OP_CB_ILLEGAL = 10044, 361da177e4SLinus Torvalds }; 371da177e4SLinus Torvalds 38c36fca52SAndy Adamson struct cb_process_state { 39c36fca52SAndy Adamson __be32 drc_status; 40c36fca52SAndy Adamson struct nfs_client *clp; 4145d43c29STrond Myklebust u32 slotid; 42c7add9a9SStanislav Kinsbursky struct net *net; 43c36fca52SAndy Adamson }; 44c36fca52SAndy Adamson 451da177e4SLinus Torvalds struct cb_compound_hdr_arg { 462e42c3e2STrond Myklebust unsigned int taglen; 471da177e4SLinus Torvalds const char *tag; 48b8f2ef84SBenny Halevy unsigned int minorversion; 49c36fca52SAndy Adamson unsigned int cb_ident; /* v4.0 callback identifier */ 501da177e4SLinus Torvalds unsigned nops; 511da177e4SLinus Torvalds }; 521da177e4SLinus Torvalds 531da177e4SLinus Torvalds struct cb_compound_hdr_res { 545704fdebSAl Viro __be32 *status; 552e42c3e2STrond Myklebust unsigned int taglen; 561da177e4SLinus Torvalds const char *tag; 575704fdebSAl Viro __be32 *nops; 581da177e4SLinus Torvalds }; 591da177e4SLinus Torvalds 601da177e4SLinus Torvalds struct cb_getattrargs { 61671beed7SChuck Lever struct sockaddr *addr; 621da177e4SLinus Torvalds struct nfs_fh fh; 631da177e4SLinus Torvalds uint32_t bitmap[2]; 641da177e4SLinus Torvalds }; 651da177e4SLinus Torvalds 661da177e4SLinus Torvalds struct cb_getattrres { 67e6f684f6SAl Viro __be32 status; 681da177e4SLinus Torvalds uint32_t bitmap[2]; 691da177e4SLinus Torvalds uint64_t size; 701da177e4SLinus Torvalds uint64_t change_attr; 711da177e4SLinus Torvalds struct timespec ctime; 721da177e4SLinus Torvalds struct timespec mtime; 731da177e4SLinus Torvalds }; 741da177e4SLinus Torvalds 751da177e4SLinus Torvalds struct cb_recallargs { 76c1d35866SChuck Lever struct sockaddr *addr; 771da177e4SLinus Torvalds struct nfs_fh fh; 781da177e4SLinus Torvalds nfs4_stateid stateid; 791da177e4SLinus Torvalds uint32_t truncate; 801da177e4SLinus Torvalds }; 811da177e4SLinus Torvalds 822d9b9ec3SBenny Halevy #if defined(CONFIG_NFS_V4_1) 832d9b9ec3SBenny Halevy 842d9b9ec3SBenny Halevy struct referring_call { 852d9b9ec3SBenny Halevy uint32_t rc_sequenceid; 862d9b9ec3SBenny Halevy uint32_t rc_slotid; 872d9b9ec3SBenny Halevy }; 882d9b9ec3SBenny Halevy 892d9b9ec3SBenny Halevy struct referring_call_list { 902d9b9ec3SBenny Halevy struct nfs4_sessionid rcl_sessionid; 912d9b9ec3SBenny Halevy uint32_t rcl_nrefcalls; 922d9b9ec3SBenny Halevy struct referring_call *rcl_refcalls; 932d9b9ec3SBenny Halevy }; 942d9b9ec3SBenny Halevy 952d9b9ec3SBenny Halevy struct cb_sequenceargs { 9665fc64e5SRicardo Labiaga struct sockaddr *csa_addr; 972d9b9ec3SBenny Halevy struct nfs4_sessionid csa_sessionid; 982d9b9ec3SBenny Halevy uint32_t csa_sequenceid; 992d9b9ec3SBenny Halevy uint32_t csa_slotid; 1002d9b9ec3SBenny Halevy uint32_t csa_highestslotid; 1012d9b9ec3SBenny Halevy uint32_t csa_cachethis; 1022d9b9ec3SBenny Halevy uint32_t csa_nrclists; 1032d9b9ec3SBenny Halevy struct referring_call_list *csa_rclists; 1042d9b9ec3SBenny Halevy }; 1052d9b9ec3SBenny Halevy 1062d9b9ec3SBenny Halevy struct cb_sequenceres { 10765fc64e5SRicardo Labiaga __be32 csr_status; 1082d9b9ec3SBenny Halevy struct nfs4_sessionid csr_sessionid; 1092d9b9ec3SBenny Halevy uint32_t csr_sequenceid; 1102d9b9ec3SBenny Halevy uint32_t csr_slotid; 1112d9b9ec3SBenny Halevy uint32_t csr_highestslotid; 1122d9b9ec3SBenny Halevy uint32_t csr_target_highestslotid; 1132d9b9ec3SBenny Halevy }; 1142d9b9ec3SBenny Halevy 115c36fca52SAndy Adamson extern __be32 nfs4_callback_sequence(struct cb_sequenceargs *args, 116c36fca52SAndy Adamson struct cb_sequenceres *res, 117c36fca52SAndy Adamson struct cb_process_state *cps); 118d49433e1SBenny Halevy 1192597641dSAlexandros Batsakis extern int nfs41_validate_delegation_stateid(struct nfs_delegation *delegation, 1202597641dSAlexandros Batsakis const nfs4_stateid *stateid); 12131f09607SAlexandros Batsakis 12231f09607SAlexandros Batsakis #define RCA4_TYPE_MASK_RDATA_DLG 0 12331f09607SAlexandros Batsakis #define RCA4_TYPE_MASK_WDATA_DLG 1 12436840370SAlexandros Batsakis #define RCA4_TYPE_MASK_DIR_DLG 2 12536840370SAlexandros Batsakis #define RCA4_TYPE_MASK_FILE_LAYOUT 3 12636840370SAlexandros Batsakis #define RCA4_TYPE_MASK_BLK_LAYOUT 4 12736840370SAlexandros Batsakis #define RCA4_TYPE_MASK_OBJ_LAYOUT_MIN 8 12836840370SAlexandros Batsakis #define RCA4_TYPE_MASK_OBJ_LAYOUT_MAX 9 12936840370SAlexandros Batsakis #define RCA4_TYPE_MASK_OTHER_LAYOUT_MIN 12 13036840370SAlexandros Batsakis #define RCA4_TYPE_MASK_OTHER_LAYOUT_MAX 15 13136840370SAlexandros Batsakis #define RCA4_TYPE_MASK_ALL 0xf31f 13231f09607SAlexandros Batsakis 13331f09607SAlexandros Batsakis struct cb_recallanyargs { 13431f09607SAlexandros Batsakis struct sockaddr *craa_addr; 13531f09607SAlexandros Batsakis uint32_t craa_objs_to_keep; 13631f09607SAlexandros Batsakis uint32_t craa_type_mask; 13731f09607SAlexandros Batsakis }; 13831f09607SAlexandros Batsakis 139c36fca52SAndy Adamson extern __be32 nfs4_callback_recallany(struct cb_recallanyargs *args, 140c36fca52SAndy Adamson void *dummy, 141c36fca52SAndy Adamson struct cb_process_state *cps); 142b9efa1b2SAndy Adamson 143b9efa1b2SAndy Adamson struct cb_recallslotargs { 144b9efa1b2SAndy Adamson struct sockaddr *crsa_addr; 145b9efa1b2SAndy Adamson uint32_t crsa_target_max_slots; 146b9efa1b2SAndy Adamson }; 147c36fca52SAndy Adamson extern __be32 nfs4_callback_recallslot(struct cb_recallslotargs *args, 148c36fca52SAndy Adamson void *dummy, 149c36fca52SAndy Adamson struct cb_process_state *cps); 150b9efa1b2SAndy Adamson 151f2a62561SFred Isaman struct cb_layoutrecallargs { 152f2a62561SFred Isaman struct sockaddr *cbl_addr; 153f2a62561SFred Isaman uint32_t cbl_recall_type; 154f2a62561SFred Isaman uint32_t cbl_layout_type; 155f2a62561SFred Isaman uint32_t cbl_layoutchanged; 156f2a62561SFred Isaman union { 157f2a62561SFred Isaman struct { 158f2a62561SFred Isaman struct nfs_fh cbl_fh; 159f2a62561SFred Isaman struct pnfs_layout_range cbl_range; 160f2a62561SFred Isaman nfs4_stateid cbl_stateid; 161f2a62561SFred Isaman }; 162f2a62561SFred Isaman struct nfs_fsid cbl_fsid; 163f2a62561SFred Isaman }; 164f2a62561SFred Isaman }; 165f2a62561SFred Isaman 1660e0243dcSDan Carpenter extern __be32 nfs4_callback_layoutrecall( 167f2a62561SFred Isaman struct cb_layoutrecallargs *args, 168f2a62561SFred Isaman void *dummy, struct cb_process_state *cps); 169f2a62561SFred Isaman 17042acd021SAndy Adamson extern void nfs4_check_drain_bc_complete(struct nfs4_session *ses); 1711be5683bSMarc Eshel 1721be5683bSMarc Eshel struct cb_devicenotifyitem { 1731be5683bSMarc Eshel uint32_t cbd_notify_type; 1741be5683bSMarc Eshel uint32_t cbd_layout_type; 1751be5683bSMarc Eshel struct nfs4_deviceid cbd_dev_id; 1761be5683bSMarc Eshel uint32_t cbd_immediate; 1771be5683bSMarc Eshel }; 1781be5683bSMarc Eshel 1791be5683bSMarc Eshel struct cb_devicenotifyargs { 1801be5683bSMarc Eshel int ndevs; 1811be5683bSMarc Eshel struct cb_devicenotifyitem *devs; 1821be5683bSMarc Eshel }; 1831be5683bSMarc Eshel 1841be5683bSMarc Eshel extern __be32 nfs4_callback_devicenotify( 1851be5683bSMarc Eshel struct cb_devicenotifyargs *args, 1861be5683bSMarc Eshel void *dummy, struct cb_process_state *cps); 1871be5683bSMarc Eshel 1882d9b9ec3SBenny Halevy #endif /* CONFIG_NFS_V4_1 */ 189778be232SAndy Adamson extern int check_gss_callback_principal(struct nfs_client *, struct svc_rqst *); 190c36fca52SAndy Adamson extern __be32 nfs4_callback_getattr(struct cb_getattrargs *args, 191c36fca52SAndy Adamson struct cb_getattrres *res, 192c36fca52SAndy Adamson struct cb_process_state *cps); 193c36fca52SAndy Adamson extern __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy, 194c36fca52SAndy Adamson struct cb_process_state *cps); 195*89d77c8fSBryan Schumaker #if IS_ENABLED(CONFIG_NFS_V4) 19671468513SBenny Halevy extern int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt); 197e82dc22dSAndy Adamson extern void nfs_callback_down(int minorversion); 1982597641dSAlexandros Batsakis extern int nfs4_validate_delegation_stateid(struct nfs_delegation *delegation, 1992597641dSAlexandros Batsakis const nfs4_stateid *stateid); 2002c2618c6SAndy Adamson extern int nfs4_set_callback_sessionid(struct nfs_client *clp); 201e82dc22dSAndy Adamson #endif /* CONFIG_NFS_V4 */ 202a43cde94SRicardo Labiaga /* 203a43cde94SRicardo Labiaga * nfs41: Callbacks are expected to not cause substantial latency, 204a43cde94SRicardo Labiaga * so we limit their concurrency to 1 by setting up the maximum number 205a43cde94SRicardo Labiaga * of slots for the backchannel. 206a43cde94SRicardo Labiaga */ 207a43cde94SRicardo Labiaga #define NFS41_BC_MIN_CALLBACKS 1 208d49433e1SBenny Halevy #define NFS41_BC_MAX_CALLBACKS 1 209a43cde94SRicardo Labiaga 210a72b4422STrond Myklebust extern unsigned int nfs_callback_set_tcpport; 2111da177e4SLinus Torvalds extern unsigned short nfs_callback_tcpport; 212f738f517SChuck Lever extern unsigned short nfs_callback_tcpport6; 2131da177e4SLinus Torvalds 2141da177e4SLinus Torvalds #endif /* __LINUX_FS_NFS_CALLBACK_H */ 215