xref: /OK3568_Linux_fs/kernel/fs/nfsd/state.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  *  Copyright (c) 2001 The Regents of the University of Michigan.
3*4882a593Smuzhiyun  *  All rights reserved.
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  *  Kendrick Smith <kmsmith@umich.edu>
6*4882a593Smuzhiyun  *  Andy Adamson <andros@umich.edu>
7*4882a593Smuzhiyun  *
8*4882a593Smuzhiyun  *  Redistribution and use in source and binary forms, with or without
9*4882a593Smuzhiyun  *  modification, are permitted provided that the following conditions
10*4882a593Smuzhiyun  *  are met:
11*4882a593Smuzhiyun  *
12*4882a593Smuzhiyun  *  1. Redistributions of source code must retain the above copyright
13*4882a593Smuzhiyun  *     notice, this list of conditions and the following disclaimer.
14*4882a593Smuzhiyun  *  2. Redistributions in binary form must reproduce the above copyright
15*4882a593Smuzhiyun  *     notice, this list of conditions and the following disclaimer in the
16*4882a593Smuzhiyun  *     documentation and/or other materials provided with the distribution.
17*4882a593Smuzhiyun  *  3. Neither the name of the University nor the names of its
18*4882a593Smuzhiyun  *     contributors may be used to endorse or promote products derived
19*4882a593Smuzhiyun  *     from this software without specific prior written permission.
20*4882a593Smuzhiyun  *
21*4882a593Smuzhiyun  *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
22*4882a593Smuzhiyun  *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23*4882a593Smuzhiyun  *  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24*4882a593Smuzhiyun  *  DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25*4882a593Smuzhiyun  *  FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26*4882a593Smuzhiyun  *  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27*4882a593Smuzhiyun  *  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
28*4882a593Smuzhiyun  *  BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29*4882a593Smuzhiyun  *  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30*4882a593Smuzhiyun  *  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31*4882a593Smuzhiyun  *  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32*4882a593Smuzhiyun  *
33*4882a593Smuzhiyun  */
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun #ifndef _NFSD4_STATE_H
36*4882a593Smuzhiyun #define _NFSD4_STATE_H
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun #include <linux/idr.h>
39*4882a593Smuzhiyun #include <linux/refcount.h>
40*4882a593Smuzhiyun #include <linux/sunrpc/svc_xprt.h>
41*4882a593Smuzhiyun #include "nfsfh.h"
42*4882a593Smuzhiyun #include "nfsd.h"
43*4882a593Smuzhiyun 
44*4882a593Smuzhiyun typedef struct {
45*4882a593Smuzhiyun 	u32             cl_boot;
46*4882a593Smuzhiyun 	u32             cl_id;
47*4882a593Smuzhiyun } clientid_t;
48*4882a593Smuzhiyun 
49*4882a593Smuzhiyun typedef struct {
50*4882a593Smuzhiyun 	clientid_t	so_clid;
51*4882a593Smuzhiyun 	u32		so_id;
52*4882a593Smuzhiyun } stateid_opaque_t;
53*4882a593Smuzhiyun 
54*4882a593Smuzhiyun typedef struct {
55*4882a593Smuzhiyun 	u32                     si_generation;
56*4882a593Smuzhiyun 	stateid_opaque_t        si_opaque;
57*4882a593Smuzhiyun } stateid_t;
58*4882a593Smuzhiyun 
59*4882a593Smuzhiyun typedef struct {
60*4882a593Smuzhiyun 	stateid_t		stid;
61*4882a593Smuzhiyun #define NFS4_COPY_STID 1
62*4882a593Smuzhiyun #define NFS4_COPYNOTIFY_STID 2
63*4882a593Smuzhiyun 	unsigned char		sc_type;
64*4882a593Smuzhiyun 	refcount_t		sc_count;
65*4882a593Smuzhiyun } copy_stateid_t;
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun struct nfsd4_callback {
68*4882a593Smuzhiyun 	struct nfs4_client *cb_clp;
69*4882a593Smuzhiyun 	struct rpc_message cb_msg;
70*4882a593Smuzhiyun 	const struct nfsd4_callback_ops *cb_ops;
71*4882a593Smuzhiyun 	struct work_struct cb_work;
72*4882a593Smuzhiyun 	int cb_seq_status;
73*4882a593Smuzhiyun 	int cb_status;
74*4882a593Smuzhiyun 	bool cb_need_restart;
75*4882a593Smuzhiyun 	bool cb_holds_slot;
76*4882a593Smuzhiyun };
77*4882a593Smuzhiyun 
78*4882a593Smuzhiyun struct nfsd4_callback_ops {
79*4882a593Smuzhiyun 	void (*prepare)(struct nfsd4_callback *);
80*4882a593Smuzhiyun 	int (*done)(struct nfsd4_callback *, struct rpc_task *);
81*4882a593Smuzhiyun 	void (*release)(struct nfsd4_callback *);
82*4882a593Smuzhiyun };
83*4882a593Smuzhiyun 
84*4882a593Smuzhiyun /*
85*4882a593Smuzhiyun  * A core object that represents a "common" stateid. These are generally
86*4882a593Smuzhiyun  * embedded within the different (more specific) stateid objects and contain
87*4882a593Smuzhiyun  * fields that are of general use to any stateid.
88*4882a593Smuzhiyun  */
89*4882a593Smuzhiyun struct nfs4_stid {
90*4882a593Smuzhiyun 	refcount_t		sc_count;
91*4882a593Smuzhiyun #define NFS4_OPEN_STID 1
92*4882a593Smuzhiyun #define NFS4_LOCK_STID 2
93*4882a593Smuzhiyun #define NFS4_DELEG_STID 4
94*4882a593Smuzhiyun /* For an open stateid kept around *only* to process close replays: */
95*4882a593Smuzhiyun #define NFS4_CLOSED_STID 8
96*4882a593Smuzhiyun /* For a deleg stateid kept around only to process free_stateid's: */
97*4882a593Smuzhiyun #define NFS4_REVOKED_DELEG_STID 16
98*4882a593Smuzhiyun #define NFS4_CLOSED_DELEG_STID 32
99*4882a593Smuzhiyun #define NFS4_LAYOUT_STID 64
100*4882a593Smuzhiyun 	struct list_head	sc_cp_list;
101*4882a593Smuzhiyun 	unsigned char		sc_type;
102*4882a593Smuzhiyun 	stateid_t		sc_stateid;
103*4882a593Smuzhiyun 	spinlock_t		sc_lock;
104*4882a593Smuzhiyun 	struct nfs4_client	*sc_client;
105*4882a593Smuzhiyun 	struct nfs4_file	*sc_file;
106*4882a593Smuzhiyun 	void			(*sc_free)(struct nfs4_stid *);
107*4882a593Smuzhiyun };
108*4882a593Smuzhiyun 
109*4882a593Smuzhiyun /* Keep a list of stateids issued by the COPY_NOTIFY, associate it with the
110*4882a593Smuzhiyun  * parent OPEN/LOCK/DELEG stateid.
111*4882a593Smuzhiyun  */
112*4882a593Smuzhiyun struct nfs4_cpntf_state {
113*4882a593Smuzhiyun 	copy_stateid_t		cp_stateid;
114*4882a593Smuzhiyun 	struct list_head	cp_list;	/* per parent nfs4_stid */
115*4882a593Smuzhiyun 	stateid_t		cp_p_stateid;	/* copy of parent's stateid */
116*4882a593Smuzhiyun 	clientid_t		cp_p_clid;	/* copy of parent's clid */
117*4882a593Smuzhiyun 	time64_t		cpntf_time;	/* last time stateid used */
118*4882a593Smuzhiyun };
119*4882a593Smuzhiyun 
120*4882a593Smuzhiyun /*
121*4882a593Smuzhiyun  * Represents a delegation stateid. The nfs4_client holds references to these
122*4882a593Smuzhiyun  * and they are put when it is being destroyed or when the delegation is
123*4882a593Smuzhiyun  * returned by the client:
124*4882a593Smuzhiyun  *
125*4882a593Smuzhiyun  * o 1 reference as long as a delegation is still in force (taken when it's
126*4882a593Smuzhiyun  *   alloc'd, put when it's returned or revoked)
127*4882a593Smuzhiyun  *
128*4882a593Smuzhiyun  * o 1 reference as long as a recall rpc is in progress (taken when the lease
129*4882a593Smuzhiyun  *   is broken, put when the rpc exits)
130*4882a593Smuzhiyun  *
131*4882a593Smuzhiyun  * o 1 more ephemeral reference for each nfsd thread currently doing something
132*4882a593Smuzhiyun  *   with that delegation without holding the cl_lock
133*4882a593Smuzhiyun  *
134*4882a593Smuzhiyun  * If the server attempts to recall a delegation and the client doesn't do so
135*4882a593Smuzhiyun  * before a timeout, the server may also revoke the delegation. In that case,
136*4882a593Smuzhiyun  * the object will either be destroyed (v4.0) or moved to a per-client list of
137*4882a593Smuzhiyun  * revoked delegations (v4.1+).
138*4882a593Smuzhiyun  *
139*4882a593Smuzhiyun  * This object is a superset of the nfs4_stid.
140*4882a593Smuzhiyun  */
141*4882a593Smuzhiyun struct nfs4_delegation {
142*4882a593Smuzhiyun 	struct nfs4_stid	dl_stid; /* must be first field */
143*4882a593Smuzhiyun 	struct list_head	dl_perfile;
144*4882a593Smuzhiyun 	struct list_head	dl_perclnt;
145*4882a593Smuzhiyun 	struct list_head	dl_recall_lru;  /* delegation recalled */
146*4882a593Smuzhiyun 	struct nfs4_clnt_odstate *dl_clnt_odstate;
147*4882a593Smuzhiyun 	u32			dl_type;
148*4882a593Smuzhiyun 	time64_t		dl_time;
149*4882a593Smuzhiyun /* For recall: */
150*4882a593Smuzhiyun 	int			dl_retries;
151*4882a593Smuzhiyun 	struct nfsd4_callback	dl_recall;
152*4882a593Smuzhiyun };
153*4882a593Smuzhiyun 
154*4882a593Smuzhiyun #define cb_to_delegation(cb) \
155*4882a593Smuzhiyun 	container_of(cb, struct nfs4_delegation, dl_recall)
156*4882a593Smuzhiyun 
157*4882a593Smuzhiyun /* client delegation callback info */
158*4882a593Smuzhiyun struct nfs4_cb_conn {
159*4882a593Smuzhiyun 	/* SETCLIENTID info */
160*4882a593Smuzhiyun 	struct sockaddr_storage	cb_addr;
161*4882a593Smuzhiyun 	struct sockaddr_storage	cb_saddr;
162*4882a593Smuzhiyun 	size_t			cb_addrlen;
163*4882a593Smuzhiyun 	u32                     cb_prog; /* used only in 4.0 case;
164*4882a593Smuzhiyun 					    per-session otherwise */
165*4882a593Smuzhiyun 	u32                     cb_ident;	/* minorversion 0 only */
166*4882a593Smuzhiyun 	struct svc_xprt		*cb_xprt;	/* minorversion 1 only */
167*4882a593Smuzhiyun };
168*4882a593Smuzhiyun 
delegstateid(struct nfs4_stid * s)169*4882a593Smuzhiyun static inline struct nfs4_delegation *delegstateid(struct nfs4_stid *s)
170*4882a593Smuzhiyun {
171*4882a593Smuzhiyun 	return container_of(s, struct nfs4_delegation, dl_stid);
172*4882a593Smuzhiyun }
173*4882a593Smuzhiyun 
174*4882a593Smuzhiyun /* Maximum number of slots per session. 160 is useful for long haul TCP */
175*4882a593Smuzhiyun #define NFSD_MAX_SLOTS_PER_SESSION     160
176*4882a593Smuzhiyun /* Maximum number of operations per session compound */
177*4882a593Smuzhiyun #define NFSD_MAX_OPS_PER_COMPOUND	16
178*4882a593Smuzhiyun /* Maximum  session per slot cache size */
179*4882a593Smuzhiyun #define NFSD_SLOT_CACHE_SIZE		2048
180*4882a593Smuzhiyun /* Maximum number of NFSD_SLOT_CACHE_SIZE slots per session */
181*4882a593Smuzhiyun #define NFSD_CACHE_SIZE_SLOTS_PER_SESSION	32
182*4882a593Smuzhiyun #define NFSD_MAX_MEM_PER_SESSION  \
183*4882a593Smuzhiyun 		(NFSD_CACHE_SIZE_SLOTS_PER_SESSION * NFSD_SLOT_CACHE_SIZE)
184*4882a593Smuzhiyun 
185*4882a593Smuzhiyun struct nfsd4_slot {
186*4882a593Smuzhiyun 	u32	sl_seqid;
187*4882a593Smuzhiyun 	__be32	sl_status;
188*4882a593Smuzhiyun 	struct svc_cred sl_cred;
189*4882a593Smuzhiyun 	u32	sl_datalen;
190*4882a593Smuzhiyun 	u16	sl_opcnt;
191*4882a593Smuzhiyun #define NFSD4_SLOT_INUSE	(1 << 0)
192*4882a593Smuzhiyun #define NFSD4_SLOT_CACHETHIS	(1 << 1)
193*4882a593Smuzhiyun #define NFSD4_SLOT_INITIALIZED	(1 << 2)
194*4882a593Smuzhiyun #define NFSD4_SLOT_CACHED	(1 << 3)
195*4882a593Smuzhiyun 	u8	sl_flags;
196*4882a593Smuzhiyun 	char	sl_data[];
197*4882a593Smuzhiyun };
198*4882a593Smuzhiyun 
199*4882a593Smuzhiyun struct nfsd4_channel_attrs {
200*4882a593Smuzhiyun 	u32		headerpadsz;
201*4882a593Smuzhiyun 	u32		maxreq_sz;
202*4882a593Smuzhiyun 	u32		maxresp_sz;
203*4882a593Smuzhiyun 	u32		maxresp_cached;
204*4882a593Smuzhiyun 	u32		maxops;
205*4882a593Smuzhiyun 	u32		maxreqs;
206*4882a593Smuzhiyun 	u32		nr_rdma_attrs;
207*4882a593Smuzhiyun 	u32		rdma_attrs;
208*4882a593Smuzhiyun };
209*4882a593Smuzhiyun 
210*4882a593Smuzhiyun struct nfsd4_cb_sec {
211*4882a593Smuzhiyun 	u32	flavor; /* (u32)(-1) used to mean "no valid flavor" */
212*4882a593Smuzhiyun 	kuid_t	uid;
213*4882a593Smuzhiyun 	kgid_t	gid;
214*4882a593Smuzhiyun };
215*4882a593Smuzhiyun 
216*4882a593Smuzhiyun struct nfsd4_create_session {
217*4882a593Smuzhiyun 	clientid_t			clientid;
218*4882a593Smuzhiyun 	struct nfs4_sessionid		sessionid;
219*4882a593Smuzhiyun 	u32				seqid;
220*4882a593Smuzhiyun 	u32				flags;
221*4882a593Smuzhiyun 	struct nfsd4_channel_attrs	fore_channel;
222*4882a593Smuzhiyun 	struct nfsd4_channel_attrs	back_channel;
223*4882a593Smuzhiyun 	u32				callback_prog;
224*4882a593Smuzhiyun 	struct nfsd4_cb_sec		cb_sec;
225*4882a593Smuzhiyun };
226*4882a593Smuzhiyun 
227*4882a593Smuzhiyun struct nfsd4_backchannel_ctl {
228*4882a593Smuzhiyun 	u32	bc_cb_program;
229*4882a593Smuzhiyun 	struct nfsd4_cb_sec		bc_cb_sec;
230*4882a593Smuzhiyun };
231*4882a593Smuzhiyun 
232*4882a593Smuzhiyun struct nfsd4_bind_conn_to_session {
233*4882a593Smuzhiyun 	struct nfs4_sessionid		sessionid;
234*4882a593Smuzhiyun 	u32				dir;
235*4882a593Smuzhiyun };
236*4882a593Smuzhiyun 
237*4882a593Smuzhiyun /* The single slot clientid cache structure */
238*4882a593Smuzhiyun struct nfsd4_clid_slot {
239*4882a593Smuzhiyun 	u32				sl_seqid;
240*4882a593Smuzhiyun 	__be32				sl_status;
241*4882a593Smuzhiyun 	struct nfsd4_create_session	sl_cr_ses;
242*4882a593Smuzhiyun };
243*4882a593Smuzhiyun 
244*4882a593Smuzhiyun struct nfsd4_conn {
245*4882a593Smuzhiyun 	struct list_head cn_persession;
246*4882a593Smuzhiyun 	struct svc_xprt *cn_xprt;
247*4882a593Smuzhiyun 	struct svc_xpt_user cn_xpt_user;
248*4882a593Smuzhiyun 	struct nfsd4_session *cn_session;
249*4882a593Smuzhiyun /* CDFC4_FORE, CDFC4_BACK: */
250*4882a593Smuzhiyun 	unsigned char cn_flags;
251*4882a593Smuzhiyun };
252*4882a593Smuzhiyun 
253*4882a593Smuzhiyun /*
254*4882a593Smuzhiyun  * Representation of a v4.1+ session. These are refcounted in a similar fashion
255*4882a593Smuzhiyun  * to the nfs4_client. References are only taken when the server is actively
256*4882a593Smuzhiyun  * working on the object (primarily during the processing of compounds).
257*4882a593Smuzhiyun  */
258*4882a593Smuzhiyun struct nfsd4_session {
259*4882a593Smuzhiyun 	atomic_t		se_ref;
260*4882a593Smuzhiyun 	struct list_head	se_hash;	/* hash by sessionid */
261*4882a593Smuzhiyun 	struct list_head	se_perclnt;
262*4882a593Smuzhiyun /* See SESSION4_PERSIST, etc. for standard flags; this is internal-only: */
263*4882a593Smuzhiyun #define NFS4_SESSION_DEAD	0x010
264*4882a593Smuzhiyun 	u32			se_flags;
265*4882a593Smuzhiyun 	struct nfs4_client	*se_client;
266*4882a593Smuzhiyun 	struct nfs4_sessionid	se_sessionid;
267*4882a593Smuzhiyun 	struct nfsd4_channel_attrs se_fchannel;
268*4882a593Smuzhiyun 	struct nfsd4_channel_attrs se_bchannel;
269*4882a593Smuzhiyun 	struct nfsd4_cb_sec	se_cb_sec;
270*4882a593Smuzhiyun 	struct list_head	se_conns;
271*4882a593Smuzhiyun 	u32			se_cb_prog;
272*4882a593Smuzhiyun 	u32			se_cb_seq_nr;
273*4882a593Smuzhiyun 	struct nfsd4_slot	*se_slots[];	/* forward channel slots */
274*4882a593Smuzhiyun };
275*4882a593Smuzhiyun 
276*4882a593Smuzhiyun /* formatted contents of nfs4_sessionid */
277*4882a593Smuzhiyun struct nfsd4_sessionid {
278*4882a593Smuzhiyun 	clientid_t	clientid;
279*4882a593Smuzhiyun 	u32		sequence;
280*4882a593Smuzhiyun 	u32		reserved;
281*4882a593Smuzhiyun };
282*4882a593Smuzhiyun 
283*4882a593Smuzhiyun #define HEXDIR_LEN     33 /* hex version of 16 byte md5 of cl_name plus '\0' */
284*4882a593Smuzhiyun 
285*4882a593Smuzhiyun /*
286*4882a593Smuzhiyun  * struct nfs4_client - one per client.  Clientids live here.
287*4882a593Smuzhiyun  *
288*4882a593Smuzhiyun  * The initial object created by an NFS client using SETCLIENTID (for NFSv4.0)
289*4882a593Smuzhiyun  * or EXCHANGE_ID (for NFSv4.1+). These objects are refcounted and timestamped.
290*4882a593Smuzhiyun  * Each nfsd_net_ns object contains a set of these and they are tracked via
291*4882a593Smuzhiyun  * short and long form clientid. They are hashed and searched for under the
292*4882a593Smuzhiyun  * per-nfsd_net client_lock spinlock.
293*4882a593Smuzhiyun  *
294*4882a593Smuzhiyun  * References to it are only held during the processing of compounds, and in
295*4882a593Smuzhiyun  * certain other operations. In their "resting state" they have a refcount of
296*4882a593Smuzhiyun  * 0. If they are not renewed within a lease period, they become eligible for
297*4882a593Smuzhiyun  * destruction by the laundromat.
298*4882a593Smuzhiyun  *
299*4882a593Smuzhiyun  * These objects can also be destroyed prematurely by the fault injection code,
300*4882a593Smuzhiyun  * or if the client sends certain forms of SETCLIENTID or EXCHANGE_ID updates.
301*4882a593Smuzhiyun  * Care is taken *not* to do this however when the objects have an elevated
302*4882a593Smuzhiyun  * refcount.
303*4882a593Smuzhiyun  *
304*4882a593Smuzhiyun  * o Each nfs4_client is hashed by clientid
305*4882a593Smuzhiyun  *
306*4882a593Smuzhiyun  * o Each nfs4_clients is also hashed by name (the opaque quantity initially
307*4882a593Smuzhiyun  *   sent by the client to identify itself).
308*4882a593Smuzhiyun  *
309*4882a593Smuzhiyun  * o cl_perclient list is used to ensure no dangling stateowner references
310*4882a593Smuzhiyun  *   when we expire the nfs4_client
311*4882a593Smuzhiyun  */
312*4882a593Smuzhiyun struct nfs4_client {
313*4882a593Smuzhiyun 	struct list_head	cl_idhash; 	/* hash by cl_clientid.id */
314*4882a593Smuzhiyun 	struct rb_node		cl_namenode;	/* link into by-name trees */
315*4882a593Smuzhiyun 	struct list_head	*cl_ownerstr_hashtbl;
316*4882a593Smuzhiyun 	struct list_head	cl_openowners;
317*4882a593Smuzhiyun 	struct idr		cl_stateids;	/* stateid lookup */
318*4882a593Smuzhiyun 	struct list_head	cl_delegations;
319*4882a593Smuzhiyun 	struct list_head	cl_revoked;	/* unacknowledged, revoked 4.1 state */
320*4882a593Smuzhiyun 	struct list_head        cl_lru;         /* tail queue */
321*4882a593Smuzhiyun #ifdef CONFIG_NFSD_PNFS
322*4882a593Smuzhiyun 	struct list_head	cl_lo_states;	/* outstanding layout states */
323*4882a593Smuzhiyun #endif
324*4882a593Smuzhiyun 	struct xdr_netobj	cl_name; 	/* id generated by client */
325*4882a593Smuzhiyun 	nfs4_verifier		cl_verifier; 	/* generated by client */
326*4882a593Smuzhiyun 	time64_t		cl_time;	/* time of last lease renewal */
327*4882a593Smuzhiyun 	struct sockaddr_storage	cl_addr; 	/* client ipaddress */
328*4882a593Smuzhiyun 	bool			cl_mach_cred;	/* SP4_MACH_CRED in force */
329*4882a593Smuzhiyun 	struct svc_cred		cl_cred; 	/* setclientid principal */
330*4882a593Smuzhiyun 	clientid_t		cl_clientid;	/* generated by server */
331*4882a593Smuzhiyun 	nfs4_verifier		cl_confirm;	/* generated by server */
332*4882a593Smuzhiyun 	u32			cl_minorversion;
333*4882a593Smuzhiyun 	/* NFSv4.1 client implementation id: */
334*4882a593Smuzhiyun 	struct xdr_netobj	cl_nii_domain;
335*4882a593Smuzhiyun 	struct xdr_netobj	cl_nii_name;
336*4882a593Smuzhiyun 	struct timespec64	cl_nii_time;
337*4882a593Smuzhiyun 
338*4882a593Smuzhiyun 	/* for v4.0 and v4.1 callbacks: */
339*4882a593Smuzhiyun 	struct nfs4_cb_conn	cl_cb_conn;
340*4882a593Smuzhiyun #define NFSD4_CLIENT_CB_UPDATE		(0)
341*4882a593Smuzhiyun #define NFSD4_CLIENT_CB_KILL		(1)
342*4882a593Smuzhiyun #define NFSD4_CLIENT_STABLE		(2)	/* client on stable storage */
343*4882a593Smuzhiyun #define NFSD4_CLIENT_RECLAIM_COMPLETE	(3)	/* reclaim_complete done */
344*4882a593Smuzhiyun #define NFSD4_CLIENT_CONFIRMED		(4)	/* client is confirmed */
345*4882a593Smuzhiyun #define NFSD4_CLIENT_UPCALL_LOCK	(5)	/* upcall serialization */
346*4882a593Smuzhiyun #define NFSD4_CLIENT_CB_FLAG_MASK	(1 << NFSD4_CLIENT_CB_UPDATE | \
347*4882a593Smuzhiyun 					 1 << NFSD4_CLIENT_CB_KILL)
348*4882a593Smuzhiyun 	unsigned long		cl_flags;
349*4882a593Smuzhiyun 	const struct cred	*cl_cb_cred;
350*4882a593Smuzhiyun 	struct rpc_clnt		*cl_cb_client;
351*4882a593Smuzhiyun 	u32			cl_cb_ident;
352*4882a593Smuzhiyun #define NFSD4_CB_UP		0
353*4882a593Smuzhiyun #define NFSD4_CB_UNKNOWN	1
354*4882a593Smuzhiyun #define NFSD4_CB_DOWN		2
355*4882a593Smuzhiyun #define NFSD4_CB_FAULT		3
356*4882a593Smuzhiyun 	int			cl_cb_state;
357*4882a593Smuzhiyun 	struct nfsd4_callback	cl_cb_null;
358*4882a593Smuzhiyun 	struct nfsd4_session	*cl_cb_session;
359*4882a593Smuzhiyun 
360*4882a593Smuzhiyun 	/* for all client information that callback code might need: */
361*4882a593Smuzhiyun 	spinlock_t		cl_lock;
362*4882a593Smuzhiyun 
363*4882a593Smuzhiyun 	/* for nfs41 */
364*4882a593Smuzhiyun 	struct list_head	cl_sessions;
365*4882a593Smuzhiyun 	struct nfsd4_clid_slot	cl_cs_slot;	/* create_session slot */
366*4882a593Smuzhiyun 	u32			cl_exchange_flags;
367*4882a593Smuzhiyun 	/* number of rpc's in progress over an associated session: */
368*4882a593Smuzhiyun 	atomic_t		cl_rpc_users;
369*4882a593Smuzhiyun 	struct nfsdfs_client	cl_nfsdfs;
370*4882a593Smuzhiyun 	struct nfs4_op_map      cl_spo_must_allow;
371*4882a593Smuzhiyun 
372*4882a593Smuzhiyun 	/* debugging info directory under nfsd/clients/ : */
373*4882a593Smuzhiyun 	struct dentry		*cl_nfsd_dentry;
374*4882a593Smuzhiyun 
375*4882a593Smuzhiyun 	/* for nfs41 callbacks */
376*4882a593Smuzhiyun 	/* We currently support a single back channel with a single slot */
377*4882a593Smuzhiyun 	unsigned long		cl_cb_slot_busy;
378*4882a593Smuzhiyun 	struct rpc_wait_queue	cl_cb_waitq;	/* backchannel callers may */
379*4882a593Smuzhiyun 						/* wait here for slots */
380*4882a593Smuzhiyun 	struct net		*net;
381*4882a593Smuzhiyun 	struct list_head	async_copies;	/* list of async copies */
382*4882a593Smuzhiyun 	spinlock_t		async_lock;	/* lock for async copies */
383*4882a593Smuzhiyun 	atomic_t		cl_cb_inflight;	/* Outstanding callbacks */
384*4882a593Smuzhiyun };
385*4882a593Smuzhiyun 
386*4882a593Smuzhiyun /* struct nfs4_client_reset
387*4882a593Smuzhiyun  * one per old client. Populates reset_str_hashtbl. Filled from conf_id_hashtbl
388*4882a593Smuzhiyun  * upon lease reset, or from upcall to state_daemon (to read in state
389*4882a593Smuzhiyun  * from non-volitile storage) upon reboot.
390*4882a593Smuzhiyun  */
391*4882a593Smuzhiyun struct nfs4_client_reclaim {
392*4882a593Smuzhiyun 	struct list_head	cr_strhash;	/* hash by cr_name */
393*4882a593Smuzhiyun 	struct nfs4_client	*cr_clp;	/* pointer to associated clp */
394*4882a593Smuzhiyun 	struct xdr_netobj	cr_name;	/* recovery dir name */
395*4882a593Smuzhiyun 	struct xdr_netobj	cr_princhash;
396*4882a593Smuzhiyun };
397*4882a593Smuzhiyun 
398*4882a593Smuzhiyun /* A reasonable value for REPLAY_ISIZE was estimated as follows:
399*4882a593Smuzhiyun  * The OPEN response, typically the largest, requires
400*4882a593Smuzhiyun  *   4(status) + 8(stateid) + 20(changeinfo) + 4(rflags) +  8(verifier) +
401*4882a593Smuzhiyun  *   4(deleg. type) + 8(deleg. stateid) + 4(deleg. recall flag) +
402*4882a593Smuzhiyun  *   20(deleg. space limit) + ~32(deleg. ace) = 112 bytes
403*4882a593Smuzhiyun  */
404*4882a593Smuzhiyun 
405*4882a593Smuzhiyun #define NFSD4_REPLAY_ISIZE       112
406*4882a593Smuzhiyun 
407*4882a593Smuzhiyun /*
408*4882a593Smuzhiyun  * Replay buffer, where the result of the last seqid-mutating operation
409*4882a593Smuzhiyun  * is cached.
410*4882a593Smuzhiyun  */
411*4882a593Smuzhiyun struct nfs4_replay {
412*4882a593Smuzhiyun 	__be32			rp_status;
413*4882a593Smuzhiyun 	unsigned int		rp_buflen;
414*4882a593Smuzhiyun 	char			*rp_buf;
415*4882a593Smuzhiyun 	struct knfsd_fh		rp_openfh;
416*4882a593Smuzhiyun 	struct mutex		rp_mutex;
417*4882a593Smuzhiyun 	char			rp_ibuf[NFSD4_REPLAY_ISIZE];
418*4882a593Smuzhiyun };
419*4882a593Smuzhiyun 
420*4882a593Smuzhiyun struct nfs4_stateowner;
421*4882a593Smuzhiyun 
422*4882a593Smuzhiyun struct nfs4_stateowner_operations {
423*4882a593Smuzhiyun 	void (*so_unhash)(struct nfs4_stateowner *);
424*4882a593Smuzhiyun 	void (*so_free)(struct nfs4_stateowner *);
425*4882a593Smuzhiyun };
426*4882a593Smuzhiyun 
427*4882a593Smuzhiyun /*
428*4882a593Smuzhiyun  * A core object that represents either an open or lock owner. The object and
429*4882a593Smuzhiyun  * lock owner objects have one of these embedded within them. Refcounts and
430*4882a593Smuzhiyun  * other fields common to both owner types are contained within these
431*4882a593Smuzhiyun  * structures.
432*4882a593Smuzhiyun  */
433*4882a593Smuzhiyun struct nfs4_stateowner {
434*4882a593Smuzhiyun 	struct list_head			so_strhash;
435*4882a593Smuzhiyun 	struct list_head			so_stateids;
436*4882a593Smuzhiyun 	struct nfs4_client			*so_client;
437*4882a593Smuzhiyun 	const struct nfs4_stateowner_operations	*so_ops;
438*4882a593Smuzhiyun 	/* after increment in nfsd4_bump_seqid, represents the next
439*4882a593Smuzhiyun 	 * sequence id expected from the client: */
440*4882a593Smuzhiyun 	atomic_t				so_count;
441*4882a593Smuzhiyun 	u32					so_seqid;
442*4882a593Smuzhiyun 	struct xdr_netobj			so_owner; /* open owner name */
443*4882a593Smuzhiyun 	struct nfs4_replay			so_replay;
444*4882a593Smuzhiyun 	bool					so_is_open_owner;
445*4882a593Smuzhiyun };
446*4882a593Smuzhiyun 
447*4882a593Smuzhiyun /*
448*4882a593Smuzhiyun  * When a file is opened, the client provides an open state owner opaque string
449*4882a593Smuzhiyun  * that indicates the "owner" of that open. These objects are refcounted.
450*4882a593Smuzhiyun  * References to it are held by each open state associated with it. This object
451*4882a593Smuzhiyun  * is a superset of the nfs4_stateowner struct.
452*4882a593Smuzhiyun  */
453*4882a593Smuzhiyun struct nfs4_openowner {
454*4882a593Smuzhiyun 	struct nfs4_stateowner	oo_owner; /* must be first field */
455*4882a593Smuzhiyun 	struct list_head        oo_perclient;
456*4882a593Smuzhiyun 	/*
457*4882a593Smuzhiyun 	 * We keep around openowners a little while after last close,
458*4882a593Smuzhiyun 	 * which saves clients from having to confirm, and allows us to
459*4882a593Smuzhiyun 	 * handle close replays if they come soon enough.  The close_lru
460*4882a593Smuzhiyun 	 * is a list of such openowners, to be reaped by the laundromat
461*4882a593Smuzhiyun 	 * thread eventually if they remain unused:
462*4882a593Smuzhiyun 	 */
463*4882a593Smuzhiyun 	struct list_head	oo_close_lru;
464*4882a593Smuzhiyun 	struct nfs4_ol_stateid *oo_last_closed_stid;
465*4882a593Smuzhiyun 	time64_t		oo_time; /* time of placement on so_close_lru */
466*4882a593Smuzhiyun #define NFS4_OO_CONFIRMED   1
467*4882a593Smuzhiyun 	unsigned char		oo_flags;
468*4882a593Smuzhiyun };
469*4882a593Smuzhiyun 
470*4882a593Smuzhiyun /*
471*4882a593Smuzhiyun  * Represents a generic "lockowner". Similar to an openowner. References to it
472*4882a593Smuzhiyun  * are held by the lock stateids that are created on its behalf. This object is
473*4882a593Smuzhiyun  * a superset of the nfs4_stateowner struct.
474*4882a593Smuzhiyun  */
475*4882a593Smuzhiyun struct nfs4_lockowner {
476*4882a593Smuzhiyun 	struct nfs4_stateowner	lo_owner;	/* must be first element */
477*4882a593Smuzhiyun 	struct list_head	lo_blocked;	/* blocked file_locks */
478*4882a593Smuzhiyun };
479*4882a593Smuzhiyun 
openowner(struct nfs4_stateowner * so)480*4882a593Smuzhiyun static inline struct nfs4_openowner * openowner(struct nfs4_stateowner *so)
481*4882a593Smuzhiyun {
482*4882a593Smuzhiyun 	return container_of(so, struct nfs4_openowner, oo_owner);
483*4882a593Smuzhiyun }
484*4882a593Smuzhiyun 
lockowner(struct nfs4_stateowner * so)485*4882a593Smuzhiyun static inline struct nfs4_lockowner * lockowner(struct nfs4_stateowner *so)
486*4882a593Smuzhiyun {
487*4882a593Smuzhiyun 	return container_of(so, struct nfs4_lockowner, lo_owner);
488*4882a593Smuzhiyun }
489*4882a593Smuzhiyun 
490*4882a593Smuzhiyun /*
491*4882a593Smuzhiyun  * Per-client state indicating no. of opens and outstanding delegations
492*4882a593Smuzhiyun  * on a file from a particular client.'od' stands for 'open & delegation'
493*4882a593Smuzhiyun  */
494*4882a593Smuzhiyun struct nfs4_clnt_odstate {
495*4882a593Smuzhiyun 	struct nfs4_client	*co_client;
496*4882a593Smuzhiyun 	struct nfs4_file	*co_file;
497*4882a593Smuzhiyun 	struct list_head	co_perfile;
498*4882a593Smuzhiyun 	refcount_t		co_odcount;
499*4882a593Smuzhiyun };
500*4882a593Smuzhiyun 
501*4882a593Smuzhiyun /*
502*4882a593Smuzhiyun  * nfs4_file: a file opened by some number of (open) nfs4_stateowners.
503*4882a593Smuzhiyun  *
504*4882a593Smuzhiyun  * These objects are global. nfsd keeps one instance of a nfs4_file per
505*4882a593Smuzhiyun  * filehandle (though it may keep multiple file descriptors for each). Each
506*4882a593Smuzhiyun  * inode can have multiple filehandles associated with it, so there is
507*4882a593Smuzhiyun  * (potentially) a many to one relationship between this struct and struct
508*4882a593Smuzhiyun  * inode.
509*4882a593Smuzhiyun  *
510*4882a593Smuzhiyun  * These are hashed by filehandle in the file_hashtbl, which is protected by
511*4882a593Smuzhiyun  * the global state_lock spinlock.
512*4882a593Smuzhiyun  */
513*4882a593Smuzhiyun struct nfs4_file {
514*4882a593Smuzhiyun 	refcount_t		fi_ref;
515*4882a593Smuzhiyun 	spinlock_t		fi_lock;
516*4882a593Smuzhiyun 	struct hlist_node       fi_hash;	/* hash on fi_fhandle */
517*4882a593Smuzhiyun 	struct list_head        fi_stateids;
518*4882a593Smuzhiyun 	union {
519*4882a593Smuzhiyun 		struct list_head	fi_delegations;
520*4882a593Smuzhiyun 		struct rcu_head		fi_rcu;
521*4882a593Smuzhiyun 	};
522*4882a593Smuzhiyun 	struct list_head	fi_clnt_odstate;
523*4882a593Smuzhiyun 	/* One each for O_RDONLY, O_WRONLY, O_RDWR: */
524*4882a593Smuzhiyun 	struct nfsd_file	*fi_fds[3];
525*4882a593Smuzhiyun 	/*
526*4882a593Smuzhiyun 	 * Each open or lock stateid contributes 0-4 to the counts
527*4882a593Smuzhiyun 	 * below depending on which bits are set in st_access_bitmap:
528*4882a593Smuzhiyun 	 *     1 to fi_access[O_RDONLY] if NFS4_SHARE_ACCES_READ is set
529*4882a593Smuzhiyun 	 *   + 1 to fi_access[O_WRONLY] if NFS4_SHARE_ACCESS_WRITE is set
530*4882a593Smuzhiyun 	 *   + 1 to both of the above if NFS4_SHARE_ACCESS_BOTH is set.
531*4882a593Smuzhiyun 	 */
532*4882a593Smuzhiyun 	atomic_t		fi_access[2];
533*4882a593Smuzhiyun 	u32			fi_share_deny;
534*4882a593Smuzhiyun 	struct nfsd_file	*fi_deleg_file;
535*4882a593Smuzhiyun 	int			fi_delegees;
536*4882a593Smuzhiyun 	struct knfsd_fh		fi_fhandle;
537*4882a593Smuzhiyun 	bool			fi_had_conflict;
538*4882a593Smuzhiyun #ifdef CONFIG_NFSD_PNFS
539*4882a593Smuzhiyun 	struct list_head	fi_lo_states;
540*4882a593Smuzhiyun 	atomic_t		fi_lo_recalls;
541*4882a593Smuzhiyun #endif
542*4882a593Smuzhiyun };
543*4882a593Smuzhiyun 
544*4882a593Smuzhiyun /*
545*4882a593Smuzhiyun  * A generic struct representing either a open or lock stateid. The nfs4_client
546*4882a593Smuzhiyun  * holds a reference to each of these objects, and they in turn hold a
547*4882a593Smuzhiyun  * reference to their respective stateowners. The client's reference is
548*4882a593Smuzhiyun  * released in response to a close or unlock (depending on whether it's an open
549*4882a593Smuzhiyun  * or lock stateid) or when the client is being destroyed.
550*4882a593Smuzhiyun  *
551*4882a593Smuzhiyun  * In the case of v4.0 open stateids, these objects are preserved for a little
552*4882a593Smuzhiyun  * while after close in order to handle CLOSE replays. Those are eventually
553*4882a593Smuzhiyun  * reclaimed via a LRU scheme by the laundromat.
554*4882a593Smuzhiyun  *
555*4882a593Smuzhiyun  * This object is a superset of the nfs4_stid. "ol" stands for "Open or Lock".
556*4882a593Smuzhiyun  * Better suggestions welcome.
557*4882a593Smuzhiyun  */
558*4882a593Smuzhiyun struct nfs4_ol_stateid {
559*4882a593Smuzhiyun 	struct nfs4_stid		st_stid;
560*4882a593Smuzhiyun 	struct list_head		st_perfile;
561*4882a593Smuzhiyun 	struct list_head		st_perstateowner;
562*4882a593Smuzhiyun 	struct list_head		st_locks;
563*4882a593Smuzhiyun 	struct nfs4_stateowner		*st_stateowner;
564*4882a593Smuzhiyun 	struct nfs4_clnt_odstate	*st_clnt_odstate;
565*4882a593Smuzhiyun 	unsigned char			st_access_bmap;
566*4882a593Smuzhiyun 	unsigned char			st_deny_bmap;
567*4882a593Smuzhiyun 	struct nfs4_ol_stateid		*st_openstp;
568*4882a593Smuzhiyun 	struct mutex			st_mutex;
569*4882a593Smuzhiyun };
570*4882a593Smuzhiyun 
openlockstateid(struct nfs4_stid * s)571*4882a593Smuzhiyun static inline struct nfs4_ol_stateid *openlockstateid(struct nfs4_stid *s)
572*4882a593Smuzhiyun {
573*4882a593Smuzhiyun 	return container_of(s, struct nfs4_ol_stateid, st_stid);
574*4882a593Smuzhiyun }
575*4882a593Smuzhiyun 
576*4882a593Smuzhiyun struct nfs4_layout_stateid {
577*4882a593Smuzhiyun 	struct nfs4_stid		ls_stid;
578*4882a593Smuzhiyun 	struct list_head		ls_perclnt;
579*4882a593Smuzhiyun 	struct list_head		ls_perfile;
580*4882a593Smuzhiyun 	spinlock_t			ls_lock;
581*4882a593Smuzhiyun 	struct list_head		ls_layouts;
582*4882a593Smuzhiyun 	u32				ls_layout_type;
583*4882a593Smuzhiyun 	struct nfsd_file		*ls_file;
584*4882a593Smuzhiyun 	struct nfsd4_callback		ls_recall;
585*4882a593Smuzhiyun 	stateid_t			ls_recall_sid;
586*4882a593Smuzhiyun 	bool				ls_recalled;
587*4882a593Smuzhiyun 	struct mutex			ls_mutex;
588*4882a593Smuzhiyun };
589*4882a593Smuzhiyun 
layoutstateid(struct nfs4_stid * s)590*4882a593Smuzhiyun static inline struct nfs4_layout_stateid *layoutstateid(struct nfs4_stid *s)
591*4882a593Smuzhiyun {
592*4882a593Smuzhiyun 	return container_of(s, struct nfs4_layout_stateid, ls_stid);
593*4882a593Smuzhiyun }
594*4882a593Smuzhiyun 
595*4882a593Smuzhiyun /* flags for preprocess_seqid_op() */
596*4882a593Smuzhiyun #define RD_STATE	        0x00000010
597*4882a593Smuzhiyun #define WR_STATE	        0x00000020
598*4882a593Smuzhiyun 
599*4882a593Smuzhiyun enum nfsd4_cb_op {
600*4882a593Smuzhiyun 	NFSPROC4_CLNT_CB_NULL = 0,
601*4882a593Smuzhiyun 	NFSPROC4_CLNT_CB_RECALL,
602*4882a593Smuzhiyun 	NFSPROC4_CLNT_CB_LAYOUT,
603*4882a593Smuzhiyun 	NFSPROC4_CLNT_CB_OFFLOAD,
604*4882a593Smuzhiyun 	NFSPROC4_CLNT_CB_SEQUENCE,
605*4882a593Smuzhiyun 	NFSPROC4_CLNT_CB_NOTIFY_LOCK,
606*4882a593Smuzhiyun };
607*4882a593Smuzhiyun 
608*4882a593Smuzhiyun /* Returns true iff a is later than b: */
nfsd4_stateid_generation_after(stateid_t * a,stateid_t * b)609*4882a593Smuzhiyun static inline bool nfsd4_stateid_generation_after(stateid_t *a, stateid_t *b)
610*4882a593Smuzhiyun {
611*4882a593Smuzhiyun 	return (s32)(a->si_generation - b->si_generation) > 0;
612*4882a593Smuzhiyun }
613*4882a593Smuzhiyun 
614*4882a593Smuzhiyun /*
615*4882a593Smuzhiyun  * When a client tries to get a lock on a file, we set one of these objects
616*4882a593Smuzhiyun  * on the blocking lock. When the lock becomes free, we can then issue a
617*4882a593Smuzhiyun  * CB_NOTIFY_LOCK to the server.
618*4882a593Smuzhiyun  */
619*4882a593Smuzhiyun struct nfsd4_blocked_lock {
620*4882a593Smuzhiyun 	struct list_head	nbl_list;
621*4882a593Smuzhiyun 	struct list_head	nbl_lru;
622*4882a593Smuzhiyun 	time64_t		nbl_time;
623*4882a593Smuzhiyun 	struct file_lock	nbl_lock;
624*4882a593Smuzhiyun 	struct knfsd_fh		nbl_fh;
625*4882a593Smuzhiyun 	struct nfsd4_callback	nbl_cb;
626*4882a593Smuzhiyun };
627*4882a593Smuzhiyun 
628*4882a593Smuzhiyun struct nfsd4_compound_state;
629*4882a593Smuzhiyun struct nfsd_net;
630*4882a593Smuzhiyun struct nfsd4_copy;
631*4882a593Smuzhiyun 
632*4882a593Smuzhiyun extern __be32 nfs4_preprocess_stateid_op(struct svc_rqst *rqstp,
633*4882a593Smuzhiyun 		struct nfsd4_compound_state *cstate, struct svc_fh *fhp,
634*4882a593Smuzhiyun 		stateid_t *stateid, int flags, struct nfsd_file **filp,
635*4882a593Smuzhiyun 		struct nfs4_stid **cstid);
636*4882a593Smuzhiyun __be32 nfsd4_lookup_stateid(struct nfsd4_compound_state *cstate,
637*4882a593Smuzhiyun 		     stateid_t *stateid, unsigned char typemask,
638*4882a593Smuzhiyun 		     struct nfs4_stid **s, struct nfsd_net *nn);
639*4882a593Smuzhiyun struct nfs4_stid *nfs4_alloc_stid(struct nfs4_client *cl, struct kmem_cache *slab,
640*4882a593Smuzhiyun 				  void (*sc_free)(struct nfs4_stid *));
641*4882a593Smuzhiyun int nfs4_init_copy_state(struct nfsd_net *nn, struct nfsd4_copy *copy);
642*4882a593Smuzhiyun void nfs4_free_copy_state(struct nfsd4_copy *copy);
643*4882a593Smuzhiyun struct nfs4_cpntf_state *nfs4_alloc_init_cpntf_state(struct nfsd_net *nn,
644*4882a593Smuzhiyun 			struct nfs4_stid *p_stid);
645*4882a593Smuzhiyun void nfs4_unhash_stid(struct nfs4_stid *s);
646*4882a593Smuzhiyun void nfs4_put_stid(struct nfs4_stid *s);
647*4882a593Smuzhiyun void nfs4_inc_and_copy_stateid(stateid_t *dst, struct nfs4_stid *stid);
648*4882a593Smuzhiyun void nfs4_remove_reclaim_record(struct nfs4_client_reclaim *, struct nfsd_net *);
649*4882a593Smuzhiyun extern void nfs4_release_reclaim(struct nfsd_net *);
650*4882a593Smuzhiyun extern struct nfs4_client_reclaim *nfsd4_find_reclaim_client(struct xdr_netobj name,
651*4882a593Smuzhiyun 							struct nfsd_net *nn);
652*4882a593Smuzhiyun extern __be32 nfs4_check_open_reclaim(clientid_t *clid,
653*4882a593Smuzhiyun 		struct nfsd4_compound_state *cstate, struct nfsd_net *nn);
654*4882a593Smuzhiyun extern void nfsd4_probe_callback(struct nfs4_client *clp);
655*4882a593Smuzhiyun extern void nfsd4_probe_callback_sync(struct nfs4_client *clp);
656*4882a593Smuzhiyun extern void nfsd4_change_callback(struct nfs4_client *clp, struct nfs4_cb_conn *);
657*4882a593Smuzhiyun extern void nfsd4_init_cb(struct nfsd4_callback *cb, struct nfs4_client *clp,
658*4882a593Smuzhiyun 		const struct nfsd4_callback_ops *ops, enum nfsd4_cb_op op);
659*4882a593Smuzhiyun extern void nfsd4_run_cb(struct nfsd4_callback *cb);
660*4882a593Smuzhiyun extern int nfsd4_create_callback_queue(void);
661*4882a593Smuzhiyun extern void nfsd4_destroy_callback_queue(void);
662*4882a593Smuzhiyun extern void nfsd4_shutdown_callback(struct nfs4_client *);
663*4882a593Smuzhiyun extern void nfsd4_shutdown_copy(struct nfs4_client *clp);
664*4882a593Smuzhiyun extern void nfsd4_prepare_cb_recall(struct nfs4_delegation *dp);
665*4882a593Smuzhiyun extern struct nfs4_client_reclaim *nfs4_client_to_reclaim(struct xdr_netobj name,
666*4882a593Smuzhiyun 				struct xdr_netobj princhash, struct nfsd_net *nn);
667*4882a593Smuzhiyun extern bool nfs4_has_reclaimed_state(struct xdr_netobj name, struct nfsd_net *nn);
668*4882a593Smuzhiyun 
669*4882a593Smuzhiyun struct nfs4_file *find_file(struct knfsd_fh *fh);
670*4882a593Smuzhiyun void put_nfs4_file(struct nfs4_file *fi);
671*4882a593Smuzhiyun extern void nfs4_put_copy(struct nfsd4_copy *copy);
672*4882a593Smuzhiyun extern struct nfsd4_copy *
673*4882a593Smuzhiyun find_async_copy(struct nfs4_client *clp, stateid_t *staetid);
674*4882a593Smuzhiyun extern void nfs4_put_cpntf_state(struct nfsd_net *nn,
675*4882a593Smuzhiyun 				 struct nfs4_cpntf_state *cps);
676*4882a593Smuzhiyun extern __be32 manage_cpntf_state(struct nfsd_net *nn, stateid_t *st,
677*4882a593Smuzhiyun 				 struct nfs4_client *clp,
678*4882a593Smuzhiyun 				 struct nfs4_cpntf_state **cps);
get_nfs4_file(struct nfs4_file * fi)679*4882a593Smuzhiyun static inline void get_nfs4_file(struct nfs4_file *fi)
680*4882a593Smuzhiyun {
681*4882a593Smuzhiyun 	refcount_inc(&fi->fi_ref);
682*4882a593Smuzhiyun }
683*4882a593Smuzhiyun struct nfsd_file *find_any_file(struct nfs4_file *f);
684*4882a593Smuzhiyun 
685*4882a593Smuzhiyun /* grace period management */
686*4882a593Smuzhiyun void nfsd4_end_grace(struct nfsd_net *nn);
687*4882a593Smuzhiyun 
688*4882a593Smuzhiyun /* nfs4recover operations */
689*4882a593Smuzhiyun extern int nfsd4_client_tracking_init(struct net *net);
690*4882a593Smuzhiyun extern void nfsd4_client_tracking_exit(struct net *net);
691*4882a593Smuzhiyun extern void nfsd4_client_record_create(struct nfs4_client *clp);
692*4882a593Smuzhiyun extern void nfsd4_client_record_remove(struct nfs4_client *clp);
693*4882a593Smuzhiyun extern int nfsd4_client_record_check(struct nfs4_client *clp);
694*4882a593Smuzhiyun extern void nfsd4_record_grace_done(struct nfsd_net *nn);
695*4882a593Smuzhiyun 
696*4882a593Smuzhiyun #endif   /* NFSD4_STATE_H */
697