xref: /openbmc/linux/fs/nfs/callback.h (revision 55fd7e02)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /*
3  * linux/fs/nfs/callback.h
4  *
5  * Copyright (C) 2004 Trond Myklebust
6  *
7  * NFSv4 callback definitions
8  */
9 #ifndef __LINUX_FS_NFS_CALLBACK_H
10 #define __LINUX_FS_NFS_CALLBACK_H
11 #include <linux/sunrpc/svc.h>
12 
13 #define NFS4_CALLBACK 0x40000000
14 #define NFS4_CALLBACK_XDRSIZE 2048
15 #define NFS4_CALLBACK_BUFSIZE (1024 + NFS4_CALLBACK_XDRSIZE)
16 
17 enum nfs4_callback_procnum {
18 	CB_NULL = 0,
19 	CB_COMPOUND = 1,
20 };
21 
22 enum nfs4_callback_opnum {
23 	OP_CB_GETATTR = 3,
24 	OP_CB_RECALL  = 4,
25 /* Callback operations new to NFSv4.1 */
26 	OP_CB_LAYOUTRECALL  = 5,
27 	OP_CB_NOTIFY        = 6,
28 	OP_CB_PUSH_DELEG    = 7,
29 	OP_CB_RECALL_ANY    = 8,
30 	OP_CB_RECALLABLE_OBJ_AVAIL = 9,
31 	OP_CB_RECALL_SLOT   = 10,
32 	OP_CB_SEQUENCE      = 11,
33 	OP_CB_WANTS_CANCELLED = 12,
34 	OP_CB_NOTIFY_LOCK   = 13,
35 	OP_CB_NOTIFY_DEVICEID = 14,
36 /* Callback operations new to NFSv4.2 */
37 	OP_CB_OFFLOAD = 15,
38 	OP_CB_ILLEGAL = 10044,
39 };
40 
41 struct nfs4_slot;
42 struct cb_process_state {
43 	__be32			drc_status;
44 	struct nfs_client	*clp;
45 	struct nfs4_slot	*slot;
46 	u32			minorversion;
47 	struct net		*net;
48 };
49 
50 struct cb_compound_hdr_arg {
51 	unsigned int taglen;
52 	const char *tag;
53 	unsigned int minorversion;
54 	unsigned int cb_ident; /* v4.0 callback identifier */
55 	unsigned nops;
56 };
57 
58 struct cb_compound_hdr_res {
59 	__be32 *status;
60 	unsigned int taglen;
61 	const char *tag;
62 	__be32 *nops;
63 };
64 
65 struct cb_getattrargs {
66 	struct nfs_fh fh;
67 	uint32_t bitmap[2];
68 };
69 
70 struct cb_getattrres {
71 	__be32 status;
72 	uint32_t bitmap[2];
73 	uint64_t size;
74 	uint64_t change_attr;
75 	struct timespec64 ctime;
76 	struct timespec64 mtime;
77 };
78 
79 struct cb_recallargs {
80 	struct nfs_fh fh;
81 	nfs4_stateid stateid;
82 	uint32_t truncate;
83 };
84 
85 #if defined(CONFIG_NFS_V4_1)
86 
87 struct referring_call {
88 	uint32_t			rc_sequenceid;
89 	uint32_t			rc_slotid;
90 };
91 
92 struct referring_call_list {
93 	struct nfs4_sessionid		rcl_sessionid;
94 	uint32_t			rcl_nrefcalls;
95 	struct referring_call 		*rcl_refcalls;
96 };
97 
98 struct cb_sequenceargs {
99 	struct sockaddr			*csa_addr;
100 	struct nfs4_sessionid		csa_sessionid;
101 	uint32_t			csa_sequenceid;
102 	uint32_t			csa_slotid;
103 	uint32_t			csa_highestslotid;
104 	uint32_t			csa_cachethis;
105 	uint32_t			csa_nrclists;
106 	struct referring_call_list	*csa_rclists;
107 };
108 
109 struct cb_sequenceres {
110 	__be32				csr_status;
111 	struct nfs4_sessionid		csr_sessionid;
112 	uint32_t			csr_sequenceid;
113 	uint32_t			csr_slotid;
114 	uint32_t			csr_highestslotid;
115 	uint32_t			csr_target_highestslotid;
116 };
117 
118 extern __be32 nfs4_callback_sequence(void *argp, void *resp,
119 				       struct cb_process_state *cps);
120 
121 #define RCA4_TYPE_MASK_RDATA_DLG	0
122 #define RCA4_TYPE_MASK_WDATA_DLG	1
123 #define RCA4_TYPE_MASK_DIR_DLG         2
124 #define RCA4_TYPE_MASK_FILE_LAYOUT     3
125 #define RCA4_TYPE_MASK_BLK_LAYOUT      4
126 #define RCA4_TYPE_MASK_OBJ_LAYOUT_MIN  8
127 #define RCA4_TYPE_MASK_OBJ_LAYOUT_MAX  9
128 #define RCA4_TYPE_MASK_OTHER_LAYOUT_MIN 12
129 #define RCA4_TYPE_MASK_OTHER_LAYOUT_MAX 15
130 #define PNFS_FF_RCA4_TYPE_MASK_READ 16
131 #define PNFS_FF_RCA4_TYPE_MASK_RW 17
132 #define RCA4_TYPE_MASK_ALL 0x3f31f
133 
134 struct cb_recallanyargs {
135 	uint32_t	craa_objs_to_keep;
136 	uint32_t	craa_type_mask;
137 };
138 
139 extern __be32 nfs4_callback_recallany(void *argp, void *resp,
140 					struct cb_process_state *cps);
141 
142 struct cb_recallslotargs {
143 	uint32_t	crsa_target_highest_slotid;
144 };
145 extern __be32 nfs4_callback_recallslot(void *argp, void *resp,
146 					 struct cb_process_state *cps);
147 
148 struct cb_layoutrecallargs {
149 	uint32_t		cbl_recall_type;
150 	uint32_t		cbl_layout_type;
151 	uint32_t		cbl_layoutchanged;
152 	union {
153 		struct {
154 			struct nfs_fh		cbl_fh;
155 			struct pnfs_layout_range cbl_range;
156 			nfs4_stateid		cbl_stateid;
157 		};
158 		struct nfs_fsid		cbl_fsid;
159 	};
160 };
161 
162 extern __be32 nfs4_callback_layoutrecall(void *argp, void *resp,
163 		struct cb_process_state *cps);
164 
165 struct cb_devicenotifyitem {
166 	uint32_t		cbd_notify_type;
167 	uint32_t		cbd_layout_type;
168 	struct nfs4_deviceid	cbd_dev_id;
169 	uint32_t		cbd_immediate;
170 };
171 
172 struct cb_devicenotifyargs {
173 	int				 ndevs;
174 	struct cb_devicenotifyitem	 *devs;
175 };
176 
177 extern __be32 nfs4_callback_devicenotify(void *argp, void *resp,
178 		struct cb_process_state *cps);
179 
180 struct cb_notify_lock_args {
181 	struct nfs_fh			cbnl_fh;
182 	struct nfs_lowner		cbnl_owner;
183 	bool				cbnl_valid;
184 };
185 
186 extern __be32 nfs4_callback_notify_lock(void *argp, void *resp,
187 					 struct cb_process_state *cps);
188 #endif /* CONFIG_NFS_V4_1 */
189 #ifdef CONFIG_NFS_V4_2
190 struct cb_offloadargs {
191 	struct nfs_fh		coa_fh;
192 	nfs4_stateid		coa_stateid;
193 	uint32_t		error;
194 	uint64_t		wr_count;
195 	struct nfs_writeverf	wr_writeverf;
196 };
197 
198 extern __be32 nfs4_callback_offload(void *args, void *dummy,
199 				    struct cb_process_state *cps);
200 #endif /* CONFIG_NFS_V4_2 */
201 extern int check_gss_callback_principal(struct nfs_client *, struct svc_rqst *);
202 extern __be32 nfs4_callback_getattr(void *argp, void *resp,
203 				    struct cb_process_state *cps);
204 extern __be32 nfs4_callback_recall(void *argp, void *resp,
205 				   struct cb_process_state *cps);
206 #if IS_ENABLED(CONFIG_NFS_V4)
207 extern int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt);
208 extern void nfs_callback_down(int minorversion, struct net *net);
209 #endif /* CONFIG_NFS_V4 */
210 /*
211  * nfs41: Callbacks are expected to not cause substantial latency,
212  * so we limit their concurrency to 1 by setting up the maximum number
213  * of slots for the backchannel.
214  */
215 #define NFS41_BC_MIN_CALLBACKS 1
216 #define NFS41_BC_MAX_CALLBACKS 1
217 
218 #define NFS4_MIN_NR_CALLBACK_THREADS 1
219 
220 extern unsigned int nfs_callback_set_tcpport;
221 extern unsigned short nfs_callback_nr_threads;
222 
223 #endif /* __LINUX_FS_NFS_CALLBACK_H */
224