xref: /openbmc/linux/fs/nfs/callback.h (revision 03ab8e6297acd1bc0eedaa050e2a1635c576fd11)
1b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
21da177e4SLinus Torvalds /*
31da177e4SLinus Torvalds  * linux/fs/nfs/callback.h
41da177e4SLinus Torvalds  *
51da177e4SLinus Torvalds  * Copyright (C) 2004 Trond Myklebust
61da177e4SLinus Torvalds  *
71da177e4SLinus Torvalds  * NFSv4 callback definitions
81da177e4SLinus Torvalds  */
91da177e4SLinus Torvalds #ifndef __LINUX_FS_NFS_CALLBACK_H
101da177e4SLinus Torvalds #define __LINUX_FS_NFS_CALLBACK_H
11778be232SAndy Adamson #include <linux/sunrpc/svc.h>
121da177e4SLinus Torvalds 
131da177e4SLinus Torvalds #define NFS4_CALLBACK 0x40000000
141da177e4SLinus Torvalds #define NFS4_CALLBACK_XDRSIZE 2048
151da177e4SLinus Torvalds #define NFS4_CALLBACK_BUFSIZE (1024 + NFS4_CALLBACK_XDRSIZE)
161da177e4SLinus Torvalds 
171da177e4SLinus Torvalds enum nfs4_callback_procnum {
181da177e4SLinus Torvalds 	CB_NULL = 0,
191da177e4SLinus Torvalds 	CB_COMPOUND = 1,
201da177e4SLinus Torvalds };
211da177e4SLinus Torvalds 
221da177e4SLinus Torvalds enum nfs4_callback_opnum {
231da177e4SLinus Torvalds 	OP_CB_GETATTR = 3,
241da177e4SLinus Torvalds 	OP_CB_RECALL  = 4,
2545377b94SBenny Halevy /* Callback operations new to NFSv4.1 */
2645377b94SBenny Halevy 	OP_CB_LAYOUTRECALL  = 5,
2745377b94SBenny Halevy 	OP_CB_NOTIFY        = 6,
2845377b94SBenny Halevy 	OP_CB_PUSH_DELEG    = 7,
2945377b94SBenny Halevy 	OP_CB_RECALL_ANY    = 8,
3045377b94SBenny Halevy 	OP_CB_RECALLABLE_OBJ_AVAIL = 9,
3145377b94SBenny Halevy 	OP_CB_RECALL_SLOT   = 10,
3245377b94SBenny Halevy 	OP_CB_SEQUENCE      = 11,
3345377b94SBenny Halevy 	OP_CB_WANTS_CANCELLED = 12,
3445377b94SBenny Halevy 	OP_CB_NOTIFY_LOCK   = 13,
3534bc47c9SBenny Halevy 	OP_CB_NOTIFY_DEVICEID = 14,
366b140b85SBryan Schumaker /* Callback operations new to NFSv4.2 */
376b140b85SBryan Schumaker 	OP_CB_OFFLOAD = 15,
381da177e4SLinus Torvalds 	OP_CB_ILLEGAL = 10044,
391da177e4SLinus Torvalds };
401da177e4SLinus Torvalds 
41810d82e6STrond Myklebust struct nfs4_slot;
42c36fca52SAndy Adamson struct cb_process_state {
43c36fca52SAndy Adamson 	__be32			drc_status;
44c36fca52SAndy Adamson 	struct nfs_client	*clp;
45810d82e6STrond Myklebust 	struct nfs4_slot	*slot;
46459de2edSBryan Schumaker 	u32			minorversion;
47c7add9a9SStanislav Kinsbursky 	struct net		*net;
48c36fca52SAndy Adamson };
49c36fca52SAndy Adamson 
501da177e4SLinus Torvalds struct cb_compound_hdr_arg {
512e42c3e2STrond Myklebust 	unsigned int taglen;
521da177e4SLinus Torvalds 	const char *tag;
53b8f2ef84SBenny Halevy 	unsigned int minorversion;
54c36fca52SAndy Adamson 	unsigned int cb_ident; /* v4.0 callback identifier */
551da177e4SLinus Torvalds 	unsigned nops;
561da177e4SLinus Torvalds };
571da177e4SLinus Torvalds 
581da177e4SLinus Torvalds struct cb_compound_hdr_res {
595704fdebSAl Viro 	__be32 *status;
602e42c3e2STrond Myklebust 	unsigned int taglen;
611da177e4SLinus Torvalds 	const char *tag;
625704fdebSAl Viro 	__be32 *nops;
631da177e4SLinus Torvalds };
641da177e4SLinus Torvalds 
651da177e4SLinus Torvalds struct cb_getattrargs {
661da177e4SLinus Torvalds 	struct nfs_fh fh;
671da177e4SLinus Torvalds 	uint32_t bitmap[2];
681da177e4SLinus Torvalds };
691da177e4SLinus Torvalds 
701da177e4SLinus Torvalds struct cb_getattrres {
71e6f684f6SAl Viro 	__be32 status;
721da177e4SLinus Torvalds 	uint32_t bitmap[2];
731da177e4SLinus Torvalds 	uint64_t size;
741da177e4SLinus Torvalds 	uint64_t change_attr;
757d34ff51STrond Myklebust 	struct timespec64 ctime;
767d34ff51STrond Myklebust 	struct timespec64 mtime;
771da177e4SLinus Torvalds };
781da177e4SLinus Torvalds 
791da177e4SLinus Torvalds struct cb_recallargs {
801da177e4SLinus Torvalds 	struct nfs_fh fh;
811da177e4SLinus Torvalds 	nfs4_stateid stateid;
821da177e4SLinus Torvalds 	uint32_t truncate;
831da177e4SLinus Torvalds };
841da177e4SLinus Torvalds 
852d9b9ec3SBenny Halevy #if defined(CONFIG_NFS_V4_1)
862d9b9ec3SBenny Halevy 
872d9b9ec3SBenny Halevy struct referring_call {
882d9b9ec3SBenny Halevy 	uint32_t			rc_sequenceid;
892d9b9ec3SBenny Halevy 	uint32_t			rc_slotid;
902d9b9ec3SBenny Halevy };
912d9b9ec3SBenny Halevy 
922d9b9ec3SBenny Halevy struct referring_call_list {
932d9b9ec3SBenny Halevy 	struct nfs4_sessionid		rcl_sessionid;
942d9b9ec3SBenny Halevy 	uint32_t			rcl_nrefcalls;
952d9b9ec3SBenny Halevy 	struct referring_call 		*rcl_refcalls;
962d9b9ec3SBenny Halevy };
972d9b9ec3SBenny Halevy 
982d9b9ec3SBenny Halevy struct cb_sequenceargs {
9965fc64e5SRicardo Labiaga 	struct sockaddr			*csa_addr;
1002d9b9ec3SBenny Halevy 	struct nfs4_sessionid		csa_sessionid;
1012d9b9ec3SBenny Halevy 	uint32_t			csa_sequenceid;
1022d9b9ec3SBenny Halevy 	uint32_t			csa_slotid;
1032d9b9ec3SBenny Halevy 	uint32_t			csa_highestslotid;
1042d9b9ec3SBenny Halevy 	uint32_t			csa_cachethis;
1052d9b9ec3SBenny Halevy 	uint32_t			csa_nrclists;
1062d9b9ec3SBenny Halevy 	struct referring_call_list	*csa_rclists;
1072d9b9ec3SBenny Halevy };
1082d9b9ec3SBenny Halevy 
1092d9b9ec3SBenny Halevy struct cb_sequenceres {
11065fc64e5SRicardo Labiaga 	__be32				csr_status;
1112d9b9ec3SBenny Halevy 	struct nfs4_sessionid		csr_sessionid;
1122d9b9ec3SBenny Halevy 	uint32_t			csr_sequenceid;
1132d9b9ec3SBenny Halevy 	uint32_t			csr_slotid;
1142d9b9ec3SBenny Halevy 	uint32_t			csr_highestslotid;
1152d9b9ec3SBenny Halevy 	uint32_t			csr_target_highestslotid;
1162d9b9ec3SBenny Halevy };
1172d9b9ec3SBenny Halevy 
118f4dac4adSChristoph Hellwig extern __be32 nfs4_callback_sequence(void *argp, void *resp,
119c36fca52SAndy Adamson 				       struct cb_process_state *cps);
120d49433e1SBenny Halevy 
12131f09607SAlexandros Batsakis #define RCA4_TYPE_MASK_RDATA_DLG	0
12231f09607SAlexandros Batsakis #define RCA4_TYPE_MASK_WDATA_DLG	1
12336840370SAlexandros Batsakis #define RCA4_TYPE_MASK_DIR_DLG         2
12436840370SAlexandros Batsakis #define RCA4_TYPE_MASK_FILE_LAYOUT     3
12536840370SAlexandros Batsakis #define RCA4_TYPE_MASK_BLK_LAYOUT      4
12636840370SAlexandros Batsakis #define RCA4_TYPE_MASK_OBJ_LAYOUT_MIN  8
12736840370SAlexandros Batsakis #define RCA4_TYPE_MASK_OBJ_LAYOUT_MAX  9
12836840370SAlexandros Batsakis #define RCA4_TYPE_MASK_OTHER_LAYOUT_MIN 12
12936840370SAlexandros Batsakis #define RCA4_TYPE_MASK_OTHER_LAYOUT_MAX 15
130b5fdf841STrond Myklebust #define PNFS_FF_RCA4_TYPE_MASK_READ 16
131b5fdf841STrond Myklebust #define PNFS_FF_RCA4_TYPE_MASK_RW 17
132b5fdf841STrond Myklebust #define RCA4_TYPE_MASK_ALL 0x3f31f
13331f09607SAlexandros Batsakis 
13431f09607SAlexandros Batsakis struct cb_recallanyargs {
13531f09607SAlexandros Batsakis 	uint32_t	craa_objs_to_keep;
13631f09607SAlexandros Batsakis 	uint32_t	craa_type_mask;
13731f09607SAlexandros Batsakis };
13831f09607SAlexandros Batsakis 
139f4dac4adSChristoph Hellwig extern __be32 nfs4_callback_recallany(void *argp, void *resp,
140c36fca52SAndy Adamson 					struct cb_process_state *cps);
141b9efa1b2SAndy Adamson 
142b9efa1b2SAndy Adamson struct cb_recallslotargs {
143d5fb4ce3STrond Myklebust 	uint32_t	crsa_target_highest_slotid;
144b9efa1b2SAndy Adamson };
145f4dac4adSChristoph Hellwig extern __be32 nfs4_callback_recallslot(void *argp, void *resp,
146c36fca52SAndy Adamson 					 struct cb_process_state *cps);
147b9efa1b2SAndy Adamson 
148f2a62561SFred Isaman struct cb_layoutrecallargs {
149f2a62561SFred Isaman 	uint32_t		cbl_recall_type;
150f2a62561SFred Isaman 	uint32_t		cbl_layout_type;
151f2a62561SFred Isaman 	uint32_t		cbl_layoutchanged;
152f2a62561SFred Isaman 	union {
153f2a62561SFred Isaman 		struct {
154f2a62561SFred Isaman 			struct nfs_fh		cbl_fh;
155f2a62561SFred Isaman 			struct pnfs_layout_range cbl_range;
156f2a62561SFred Isaman 			nfs4_stateid		cbl_stateid;
157f2a62561SFred Isaman 		};
158f2a62561SFred Isaman 		struct nfs_fsid		cbl_fsid;
159f2a62561SFred Isaman 	};
160f2a62561SFred Isaman };
161f2a62561SFred Isaman 
162f4dac4adSChristoph Hellwig extern __be32 nfs4_callback_layoutrecall(void *argp, void *resp,
163f4dac4adSChristoph Hellwig 		struct cb_process_state *cps);
164f2a62561SFred Isaman 
1651be5683bSMarc Eshel struct cb_devicenotifyitem {
1661be5683bSMarc Eshel 	uint32_t		cbd_notify_type;
1671be5683bSMarc Eshel 	uint32_t		cbd_layout_type;
1681be5683bSMarc Eshel 	struct nfs4_deviceid	cbd_dev_id;
1691be5683bSMarc Eshel 	uint32_t		cbd_immediate;
1701be5683bSMarc Eshel };
1711be5683bSMarc Eshel 
1721be5683bSMarc Eshel struct cb_devicenotifyargs {
173*b05bf5c6STrond Myklebust 	uint32_t			 ndevs;
1741be5683bSMarc Eshel 	struct cb_devicenotifyitem	 *devs;
1751be5683bSMarc Eshel };
1761be5683bSMarc Eshel 
177f4dac4adSChristoph Hellwig extern __be32 nfs4_callback_devicenotify(void *argp, void *resp,
178f4dac4adSChristoph Hellwig 		struct cb_process_state *cps);
1791be5683bSMarc Eshel 
180db783688SJeff Layton struct cb_notify_lock_args {
181db783688SJeff Layton 	struct nfs_fh			cbnl_fh;
182db783688SJeff Layton 	struct nfs_lowner		cbnl_owner;
183db783688SJeff Layton 	bool				cbnl_valid;
184db783688SJeff Layton };
185db783688SJeff Layton 
186f4dac4adSChristoph Hellwig extern __be32 nfs4_callback_notify_lock(void *argp, void *resp,
187db783688SJeff Layton 					 struct cb_process_state *cps);
1882d9b9ec3SBenny Halevy #endif /* CONFIG_NFS_V4_1 */
1895178a125SOlga Kornievskaia #ifdef CONFIG_NFS_V4_2
1905178a125SOlga Kornievskaia struct cb_offloadargs {
1915178a125SOlga Kornievskaia 	struct nfs_fh		coa_fh;
1925178a125SOlga Kornievskaia 	nfs4_stateid		coa_stateid;
1935178a125SOlga Kornievskaia 	uint32_t		error;
1945178a125SOlga Kornievskaia 	uint64_t		wr_count;
1955178a125SOlga Kornievskaia 	struct nfs_writeverf	wr_writeverf;
1965178a125SOlga Kornievskaia };
1975178a125SOlga Kornievskaia 
1985178a125SOlga Kornievskaia extern __be32 nfs4_callback_offload(void *args, void *dummy,
1995178a125SOlga Kornievskaia 				    struct cb_process_state *cps);
2005178a125SOlga Kornievskaia #endif /* CONFIG_NFS_V4_2 */
201778be232SAndy Adamson extern int check_gss_callback_principal(struct nfs_client *, struct svc_rqst *);
202f4dac4adSChristoph Hellwig extern __be32 nfs4_callback_getattr(void *argp, void *resp,
203c36fca52SAndy Adamson 				    struct cb_process_state *cps);
204f4dac4adSChristoph Hellwig extern __be32 nfs4_callback_recall(void *argp, void *resp,
205c36fca52SAndy Adamson 				   struct cb_process_state *cps);
20689d77c8fSBryan Schumaker #if IS_ENABLED(CONFIG_NFS_V4)
20771468513SBenny Halevy extern int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt);
208c8ceb412SStanislav Kinsbursky extern void nfs_callback_down(int minorversion, struct net *net);
209e82dc22dSAndy Adamson #endif /* CONFIG_NFS_V4 */
210a43cde94SRicardo Labiaga /*
211a43cde94SRicardo Labiaga  * nfs41: Callbacks are expected to not cause substantial latency,
212a43cde94SRicardo Labiaga  * so we limit their concurrency to 1 by setting up the maximum number
213a43cde94SRicardo Labiaga  * of slots for the backchannel.
214a43cde94SRicardo Labiaga  */
215a43cde94SRicardo Labiaga #define NFS41_BC_MIN_CALLBACKS 1
216d49433e1SBenny Halevy #define NFS41_BC_MAX_CALLBACKS 1
217a43cde94SRicardo Labiaga 
2185405fc44STrond Myklebust #define NFS4_MIN_NR_CALLBACK_THREADS 1
219bb6aeba7STrond Myklebust 
220a72b4422STrond Myklebust extern unsigned int nfs_callback_set_tcpport;
2215405fc44STrond Myklebust extern unsigned short nfs_callback_nr_threads;
2221da177e4SLinus Torvalds 
2231da177e4SLinus Torvalds #endif /* __LINUX_FS_NFS_CALLBACK_H */
224