2 * Copyright (c) 2001 The Regents of the University of Michigan.
5 * Kendrick Smith <kmsmith@umich.edu>
6 * Andy Adamson <andros@umich.edu>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. Neither the name of the University nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
22 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
23 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
28 * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
29 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
30 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #ifndef _NFSD4_STATE_H
36 #define _NFSD4_STATE_H
38 #include <linux/idr.h>
39 #include <linux/refcount.h>
40 #include <linux/sunrpc/svc_xprt.h>
56 stateid_opaque_t si_opaque;
61 #define NFS4_COPY_STID 1
62 #define NFS4_COPYNOTIFY_STID 2
63 unsigned char cs_type;
67 struct nfsd4_callback {
68 struct nfs4_client *cb_clp;
69 struct rpc_message cb_msg;
70 const struct nfsd4_callback_ops *cb_ops;
71 struct work_struct cb_work;
78 struct nfsd4_callback_ops {
79 void (*prepare)(struct nfsd4_callback *);
80 int (*done)(struct nfsd4_callback *, struct rpc_task *);
81 void (*release)(struct nfsd4_callback *);
85 * A core object that represents a "common" stateid. These are generally
86 * embedded within the different (more specific) stateid objects and contain
87 * fields that are of general use to any stateid.
91 #define NFS4_OPEN_STID 1
92 #define NFS4_LOCK_STID 2
93 #define NFS4_DELEG_STID 4
94 /* For an open stateid kept around *only* to process close replays: */
95 #define NFS4_CLOSED_STID 8
96 /* For a deleg stateid kept around only to process free_stateid's: */
97 #define NFS4_REVOKED_DELEG_STID 16
98 #define NFS4_CLOSED_DELEG_STID 32
99 #define NFS4_LAYOUT_STID 64
100 struct list_head sc_cp_list;
101 unsigned char sc_type;
102 stateid_t sc_stateid;
104 struct nfs4_client *sc_client;
105 struct nfs4_file *sc_file;
106 void (*sc_free)(struct nfs4_stid *);
109 /* Keep a list of stateids issued by the COPY_NOTIFY, associate it with the
110 * parent OPEN/LOCK/DELEG stateid.
112 struct nfs4_cpntf_state {
113 copy_stateid_t cp_stateid;
114 struct list_head cp_list; /* per parent nfs4_stid */
115 stateid_t cp_p_stateid; /* copy of parent's stateid */
116 clientid_t cp_p_clid; /* copy of parent's clid */
117 time64_t cpntf_time; /* last time stateid used */
120 struct nfs4_cb_fattr {
121 struct nfsd4_callback ncf_getattr;
125 /* from CB_GETATTR reply */
131 * Represents a delegation stateid. The nfs4_client holds references to these
132 * and they are put when it is being destroyed or when the delegation is
133 * returned by the client:
135 * o 1 reference as long as a delegation is still in force (taken when it's
136 * alloc'd, put when it's returned or revoked)
138 * o 1 reference as long as a recall rpc is in progress (taken when the lease
139 * is broken, put when the rpc exits)
141 * o 1 more ephemeral reference for each nfsd thread currently doing something
142 * with that delegation without holding the cl_lock
144 * If the server attempts to recall a delegation and the client doesn't do so
145 * before a timeout, the server may also revoke the delegation. In that case,
146 * the object will either be destroyed (v4.0) or moved to a per-client list of
147 * revoked delegations (v4.1+).
149 * This object is a superset of the nfs4_stid.
151 struct nfs4_delegation {
152 struct nfs4_stid dl_stid; /* must be first field */
153 struct list_head dl_perfile;
154 struct list_head dl_perclnt;
155 struct list_head dl_recall_lru; /* delegation recalled */
156 struct nfs4_clnt_odstate *dl_clnt_odstate;
161 struct nfsd4_callback dl_recall;
165 struct nfs4_cb_fattr dl_cb_fattr;
168 #define cb_to_delegation(cb) \
169 container_of(cb, struct nfs4_delegation, dl_recall)
171 /* client delegation callback info */
172 struct nfs4_cb_conn {
173 /* SETCLIENTID info */
174 struct sockaddr_storage cb_addr;
175 struct sockaddr_storage cb_saddr;
177 u32 cb_prog; /* used only in 4.0 case;
178 per-session otherwise */
179 u32 cb_ident; /* minorversion 0 only */
180 struct svc_xprt *cb_xprt; /* minorversion 1 only */
183 static inline struct nfs4_delegation *delegstateid(struct nfs4_stid *s)
185 return container_of(s, struct nfs4_delegation, dl_stid);
188 /* Maximum number of slots per session. 160 is useful for long haul TCP */
189 #define NFSD_MAX_SLOTS_PER_SESSION 160
190 /* Maximum session per slot cache size */
191 #define NFSD_SLOT_CACHE_SIZE 2048
192 /* Maximum number of NFSD_SLOT_CACHE_SIZE slots per session */
193 #define NFSD_CACHE_SIZE_SLOTS_PER_SESSION 32
194 #define NFSD_MAX_MEM_PER_SESSION \
195 (NFSD_CACHE_SIZE_SLOTS_PER_SESSION * NFSD_SLOT_CACHE_SIZE)
200 struct svc_cred sl_cred;
203 #define NFSD4_SLOT_INUSE (1 << 0)
204 #define NFSD4_SLOT_CACHETHIS (1 << 1)
205 #define NFSD4_SLOT_INITIALIZED (1 << 2)
206 #define NFSD4_SLOT_CACHED (1 << 3)
211 struct nfsd4_channel_attrs {
222 struct nfsd4_cb_sec {
223 u32 flavor; /* (u32)(-1) used to mean "no valid flavor" */
228 struct nfsd4_create_session {
230 struct nfs4_sessionid sessionid;
233 struct nfsd4_channel_attrs fore_channel;
234 struct nfsd4_channel_attrs back_channel;
236 struct nfsd4_cb_sec cb_sec;
239 struct nfsd4_backchannel_ctl {
241 struct nfsd4_cb_sec bc_cb_sec;
244 struct nfsd4_bind_conn_to_session {
245 struct nfs4_sessionid sessionid;
249 /* The single slot clientid cache structure */
250 struct nfsd4_clid_slot {
253 struct nfsd4_create_session sl_cr_ses;
257 struct list_head cn_persession;
258 struct svc_xprt *cn_xprt;
259 struct svc_xpt_user cn_xpt_user;
260 struct nfsd4_session *cn_session;
261 /* CDFC4_FORE, CDFC4_BACK: */
262 unsigned char cn_flags;
266 * Representation of a v4.1+ session. These are refcounted in a similar fashion
267 * to the nfs4_client. References are only taken when the server is actively
268 * working on the object (primarily during the processing of compounds).
270 struct nfsd4_session {
272 struct list_head se_hash; /* hash by sessionid */
273 struct list_head se_perclnt;
274 /* See SESSION4_PERSIST, etc. for standard flags; this is internal-only: */
275 #define NFS4_SESSION_DEAD 0x010
277 struct nfs4_client *se_client;
278 struct nfs4_sessionid se_sessionid;
279 struct nfsd4_channel_attrs se_fchannel;
280 struct nfsd4_channel_attrs se_bchannel;
281 struct nfsd4_cb_sec se_cb_sec;
282 struct list_head se_conns;
285 struct nfsd4_slot *se_slots[]; /* forward channel slots */
288 /* formatted contents of nfs4_sessionid */
289 struct nfsd4_sessionid {
295 #define HEXDIR_LEN 33 /* hex version of 16 byte md5 of cl_name plus '\0' */
298 * State Meaning Where set
299 * --------------------------------------------------------------------------
300 * | NFSD4_ACTIVE | Confirmed, active | Default |
301 * |------------------- ----------------------------------------------------|
302 * | NFSD4_COURTESY | Courtesy state. | nfs4_get_client_reaplist |
303 * | | Lease/lock/share | |
304 * | | reservation conflict | |
305 * | | can cause Courtesy | |
306 * | | client to be expired | |
307 * |------------------------------------------------------------------------|
308 * | NFSD4_EXPIRABLE | Courtesy client to be| nfs4_laundromat |
309 * | | expired by Laundromat| try_to_expire_client |
310 * | | due to conflict | |
311 * |------------------------------------------------------------------------|
320 * struct nfs4_client - one per client. Clientids live here.
322 * The initial object created by an NFS client using SETCLIENTID (for NFSv4.0)
323 * or EXCHANGE_ID (for NFSv4.1+). These objects are refcounted and timestamped.
324 * Each nfsd_net_ns object contains a set of these and they are tracked via
325 * short and long form clientid. They are hashed and searched for under the
326 * per-nfsd_net client_lock spinlock.
328 * References to it are only held during the processing of compounds, and in
329 * certain other operations. In their "resting state" they have a refcount of
330 * 0. If they are not renewed within a lease period, they become eligible for
331 * destruction by the laundromat.
333 * These objects can also be destroyed prematurely by the fault injection code,
334 * or if the client sends certain forms of SETCLIENTID or EXCHANGE_ID updates.
335 * Care is taken *not* to do this however when the objects have an elevated
338 * o Each nfs4_client is hashed by clientid
340 * o Each nfs4_clients is also hashed by name (the opaque quantity initially
341 * sent by the client to identify itself).
343 * o cl_perclient list is used to ensure no dangling stateowner references
344 * when we expire the nfs4_client
347 struct list_head cl_idhash; /* hash by cl_clientid.id */
348 struct rb_node cl_namenode; /* link into by-name trees */
349 struct list_head *cl_ownerstr_hashtbl;
350 struct list_head cl_openowners;
351 struct idr cl_stateids; /* stateid lookup */
352 struct list_head cl_delegations;
353 struct list_head cl_revoked; /* unacknowledged, revoked 4.1 state */
354 struct list_head cl_lru; /* tail queue */
355 #ifdef CONFIG_NFSD_PNFS
356 struct list_head cl_lo_states; /* outstanding layout states */
358 struct xdr_netobj cl_name; /* id generated by client */
359 nfs4_verifier cl_verifier; /* generated by client */
360 time64_t cl_time; /* time of last lease renewal */
361 struct sockaddr_storage cl_addr; /* client ipaddress */
362 bool cl_mach_cred; /* SP4_MACH_CRED in force */
363 struct svc_cred cl_cred; /* setclientid principal */
364 clientid_t cl_clientid; /* generated by server */
365 nfs4_verifier cl_confirm; /* generated by server */
367 /* NFSv4.1 client implementation id: */
368 struct xdr_netobj cl_nii_domain;
369 struct xdr_netobj cl_nii_name;
370 struct timespec64 cl_nii_time;
372 /* for v4.0 and v4.1 callbacks: */
373 struct nfs4_cb_conn cl_cb_conn;
374 #define NFSD4_CLIENT_CB_UPDATE (0)
375 #define NFSD4_CLIENT_CB_KILL (1)
376 #define NFSD4_CLIENT_STABLE (2) /* client on stable storage */
377 #define NFSD4_CLIENT_RECLAIM_COMPLETE (3) /* reclaim_complete done */
378 #define NFSD4_CLIENT_CONFIRMED (4) /* client is confirmed */
379 #define NFSD4_CLIENT_UPCALL_LOCK (5) /* upcall serialization */
380 #define NFSD4_CLIENT_CB_FLAG_MASK (1 << NFSD4_CLIENT_CB_UPDATE | \
381 1 << NFSD4_CLIENT_CB_KILL)
382 #define NFSD4_CLIENT_CB_RECALL_ANY (6)
383 unsigned long cl_flags;
384 const struct cred *cl_cb_cred;
385 struct rpc_clnt *cl_cb_client;
387 #define NFSD4_CB_UP 0
388 #define NFSD4_CB_UNKNOWN 1
389 #define NFSD4_CB_DOWN 2
390 #define NFSD4_CB_FAULT 3
392 struct nfsd4_callback cl_cb_null;
393 struct nfsd4_session *cl_cb_session;
395 /* for all client information that callback code might need: */
399 struct list_head cl_sessions;
400 struct nfsd4_clid_slot cl_cs_slot; /* create_session slot */
401 u32 cl_exchange_flags;
402 /* number of rpc's in progress over an associated session: */
403 atomic_t cl_rpc_users;
404 struct nfsdfs_client cl_nfsdfs;
405 struct nfs4_op_map cl_spo_must_allow;
407 /* debugging info directory under nfsd/clients/ : */
408 struct dentry *cl_nfsd_dentry;
409 /* 'info' file within that directory. Ref is not counted,
410 * but will remain valid iff cl_nfsd_dentry != NULL
412 struct dentry *cl_nfsd_info_dentry;
414 /* for nfs41 callbacks */
415 /* We currently support a single back channel with a single slot */
416 unsigned long cl_cb_slot_busy;
417 struct rpc_wait_queue cl_cb_waitq; /* backchannel callers may */
418 /* wait here for slots */
420 struct list_head async_copies; /* list of async copies */
421 spinlock_t async_lock; /* lock for async copies */
422 atomic_t cl_cb_inflight; /* Outstanding callbacks */
424 unsigned int cl_state;
425 atomic_t cl_delegs_in_recall;
427 struct nfsd4_cb_recall_any *cl_ra;
429 struct list_head cl_ra_cblist;
432 /* struct nfs4_client_reset
433 * one per old client. Populates reset_str_hashtbl. Filled from conf_id_hashtbl
434 * upon lease reset, or from upcall to state_daemon (to read in state
435 * from non-volitile storage) upon reboot.
437 struct nfs4_client_reclaim {
438 struct list_head cr_strhash; /* hash by cr_name */
439 struct nfs4_client *cr_clp; /* pointer to associated clp */
440 struct xdr_netobj cr_name; /* recovery dir name */
441 struct xdr_netobj cr_princhash;
444 /* A reasonable value for REPLAY_ISIZE was estimated as follows:
445 * The OPEN response, typically the largest, requires
446 * 4(status) + 8(stateid) + 20(changeinfo) + 4(rflags) + 8(verifier) +
447 * 4(deleg. type) + 8(deleg. stateid) + 4(deleg. recall flag) +
448 * 20(deleg. space limit) + ~32(deleg. ace) = 112 bytes
451 #define NFSD4_REPLAY_ISIZE 112
454 * Replay buffer, where the result of the last seqid-mutating operation
459 unsigned int rp_buflen;
461 struct knfsd_fh rp_openfh;
462 struct mutex rp_mutex;
463 char rp_ibuf[NFSD4_REPLAY_ISIZE];
466 struct nfs4_stateowner;
468 struct nfs4_stateowner_operations {
469 void (*so_unhash)(struct nfs4_stateowner *);
470 void (*so_free)(struct nfs4_stateowner *);
474 * A core object that represents either an open or lock owner. The object and
475 * lock owner objects have one of these embedded within them. Refcounts and
476 * other fields common to both owner types are contained within these
479 struct nfs4_stateowner {
480 struct list_head so_strhash;
481 struct list_head so_stateids;
482 struct nfs4_client *so_client;
483 const struct nfs4_stateowner_operations *so_ops;
484 /* after increment in nfsd4_bump_seqid, represents the next
485 * sequence id expected from the client: */
488 struct xdr_netobj so_owner; /* open owner name */
489 struct nfs4_replay so_replay;
490 bool so_is_open_owner;
494 * When a file is opened, the client provides an open state owner opaque string
495 * that indicates the "owner" of that open. These objects are refcounted.
496 * References to it are held by each open state associated with it. This object
497 * is a superset of the nfs4_stateowner struct.
499 struct nfs4_openowner {
500 struct nfs4_stateowner oo_owner; /* must be first field */
501 struct list_head oo_perclient;
503 * We keep around openowners a little while after last close,
504 * which saves clients from having to confirm, and allows us to
505 * handle close replays if they come soon enough. The close_lru
506 * is a list of such openowners, to be reaped by the laundromat
507 * thread eventually if they remain unused:
509 struct list_head oo_close_lru;
510 struct nfs4_ol_stateid *oo_last_closed_stid;
511 time64_t oo_time; /* time of placement on so_close_lru */
512 #define NFS4_OO_CONFIRMED 1
513 unsigned char oo_flags;
517 * Represents a generic "lockowner". Similar to an openowner. References to it
518 * are held by the lock stateids that are created on its behalf. This object is
519 * a superset of the nfs4_stateowner struct.
521 struct nfs4_lockowner {
522 struct nfs4_stateowner lo_owner; /* must be first element */
523 struct list_head lo_blocked; /* blocked file_locks */
526 static inline struct nfs4_openowner * openowner(struct nfs4_stateowner *so)
528 return container_of(so, struct nfs4_openowner, oo_owner);
531 static inline struct nfs4_lockowner * lockowner(struct nfs4_stateowner *so)
533 return container_of(so, struct nfs4_lockowner, lo_owner);
537 * Per-client state indicating no. of opens and outstanding delegations
538 * on a file from a particular client.'od' stands for 'open & delegation'
540 struct nfs4_clnt_odstate {
541 struct nfs4_client *co_client;
542 struct nfs4_file *co_file;
543 struct list_head co_perfile;
544 refcount_t co_odcount;
548 * nfs4_file: a file opened by some number of (open) nfs4_stateowners.
550 * These objects are global. nfsd keeps one instance of a nfs4_file per
551 * filehandle (though it may keep multiple file descriptors for each). Each
552 * inode can have multiple filehandles associated with it, so there is
553 * (potentially) a many to one relationship between this struct and struct
558 struct inode * fi_inode;
561 struct rhlist_head fi_rlist;
562 struct list_head fi_stateids;
564 struct list_head fi_delegations;
565 struct rcu_head fi_rcu;
567 struct list_head fi_clnt_odstate;
568 /* One each for O_RDONLY, O_WRONLY, O_RDWR: */
569 struct nfsd_file *fi_fds[3];
571 * Each open or lock stateid contributes 0-4 to the counts
572 * below depending on which bits are set in st_access_bitmap:
573 * 1 to fi_access[O_RDONLY] if NFS4_SHARE_ACCES_READ is set
574 * + 1 to fi_access[O_WRONLY] if NFS4_SHARE_ACCESS_WRITE is set
575 * + 1 to both of the above if NFS4_SHARE_ACCESS_BOTH is set.
577 atomic_t fi_access[2];
579 struct nfsd_file *fi_deleg_file;
581 struct knfsd_fh fi_fhandle;
582 bool fi_had_conflict;
583 #ifdef CONFIG_NFSD_PNFS
584 struct list_head fi_lo_states;
585 atomic_t fi_lo_recalls;
590 * A generic struct representing either a open or lock stateid. The nfs4_client
591 * holds a reference to each of these objects, and they in turn hold a
592 * reference to their respective stateowners. The client's reference is
593 * released in response to a close or unlock (depending on whether it's an open
594 * or lock stateid) or when the client is being destroyed.
596 * In the case of v4.0 open stateids, these objects are preserved for a little
597 * while after close in order to handle CLOSE replays. Those are eventually
598 * reclaimed via a LRU scheme by the laundromat.
600 * This object is a superset of the nfs4_stid. "ol" stands for "Open or Lock".
601 * Better suggestions welcome.
603 struct nfs4_ol_stateid {
604 struct nfs4_stid st_stid;
605 struct list_head st_perfile;
606 struct list_head st_perstateowner;
607 struct list_head st_locks;
608 struct nfs4_stateowner *st_stateowner;
609 struct nfs4_clnt_odstate *st_clnt_odstate;
611 * These bitmasks use 3 separate bits for READ, ALLOW, and BOTH; see the
612 * comment above bmap_to_share_mode() for explanation:
614 unsigned char st_access_bmap;
615 unsigned char st_deny_bmap;
616 struct nfs4_ol_stateid *st_openstp;
617 struct mutex st_mutex;
620 static inline struct nfs4_ol_stateid *openlockstateid(struct nfs4_stid *s)
622 return container_of(s, struct nfs4_ol_stateid, st_stid);
625 struct nfs4_layout_stateid {
626 struct nfs4_stid ls_stid;
627 struct list_head ls_perclnt;
628 struct list_head ls_perfile;
630 struct list_head ls_layouts;
632 struct nfsd_file *ls_file;
633 struct nfsd4_callback ls_recall;
634 stateid_t ls_recall_sid;
636 struct mutex ls_mutex;
639 static inline struct nfs4_layout_stateid *layoutstateid(struct nfs4_stid *s)
641 return container_of(s, struct nfs4_layout_stateid, ls_stid);
644 /* flags for preprocess_seqid_op() */
645 #define RD_STATE 0x00000010
646 #define WR_STATE 0x00000020
649 NFSPROC4_CLNT_CB_NULL = 0,
650 NFSPROC4_CLNT_CB_RECALL,
651 NFSPROC4_CLNT_CB_LAYOUT,
652 NFSPROC4_CLNT_CB_OFFLOAD,
653 NFSPROC4_CLNT_CB_SEQUENCE,
654 NFSPROC4_CLNT_CB_NOTIFY_LOCK,
655 NFSPROC4_CLNT_CB_RECALL_ANY,
656 NFSPROC4_CLNT_CB_GETATTR,
659 /* Returns true iff a is later than b: */
660 static inline bool nfsd4_stateid_generation_after(stateid_t *a, stateid_t *b)
662 return (s32)(a->si_generation - b->si_generation) > 0;
666 * When a client tries to get a lock on a file, we set one of these objects
667 * on the blocking lock. When the lock becomes free, we can then issue a
668 * CB_NOTIFY_LOCK to the server.
670 struct nfsd4_blocked_lock {
671 struct list_head nbl_list;
672 struct list_head nbl_lru;
674 struct file_lock nbl_lock;
675 struct knfsd_fh nbl_fh;
676 struct nfsd4_callback nbl_cb;
677 struct kref nbl_kref;
680 struct nfsd4_compound_state;
684 extern __be32 nfs4_preprocess_stateid_op(struct svc_rqst *rqstp,
685 struct nfsd4_compound_state *cstate, struct svc_fh *fhp,
686 stateid_t *stateid, int flags, struct nfsd_file **filp,
687 struct nfs4_stid **cstid);
688 __be32 nfsd4_lookup_stateid(struct nfsd4_compound_state *cstate,
689 stateid_t *stateid, unsigned char typemask,
690 struct nfs4_stid **s, struct nfsd_net *nn);
691 struct nfs4_stid *nfs4_alloc_stid(struct nfs4_client *cl, struct kmem_cache *slab,
692 void (*sc_free)(struct nfs4_stid *));
693 int nfs4_init_copy_state(struct nfsd_net *nn, struct nfsd4_copy *copy);
694 void nfs4_free_copy_state(struct nfsd4_copy *copy);
695 struct nfs4_cpntf_state *nfs4_alloc_init_cpntf_state(struct nfsd_net *nn,
696 struct nfs4_stid *p_stid);
697 void nfs4_unhash_stid(struct nfs4_stid *s);
698 void nfs4_put_stid(struct nfs4_stid *s);
699 void nfs4_inc_and_copy_stateid(stateid_t *dst, struct nfs4_stid *stid);
700 void nfs4_remove_reclaim_record(struct nfs4_client_reclaim *, struct nfsd_net *);
701 extern void nfs4_release_reclaim(struct nfsd_net *);
702 extern struct nfs4_client_reclaim *nfsd4_find_reclaim_client(struct xdr_netobj name,
703 struct nfsd_net *nn);
704 extern __be32 nfs4_check_open_reclaim(struct nfs4_client *);
705 extern void nfsd4_probe_callback(struct nfs4_client *clp);
706 extern void nfsd4_probe_callback_sync(struct nfs4_client *clp);
707 extern void nfsd4_change_callback(struct nfs4_client *clp, struct nfs4_cb_conn *);
708 extern void nfsd4_init_cb(struct nfsd4_callback *cb, struct nfs4_client *clp,
709 const struct nfsd4_callback_ops *ops, enum nfsd4_cb_op op);
710 extern bool nfsd4_run_cb(struct nfsd4_callback *cb);
711 extern int nfsd4_create_callback_queue(void);
712 extern void nfsd4_destroy_callback_queue(void);
713 extern void nfsd4_shutdown_callback(struct nfs4_client *);
714 extern void nfsd4_shutdown_copy(struct nfs4_client *clp);
715 extern struct nfs4_client_reclaim *nfs4_client_to_reclaim(struct xdr_netobj name,
716 struct xdr_netobj princhash, struct nfsd_net *nn);
717 extern bool nfs4_has_reclaimed_state(struct xdr_netobj name, struct nfsd_net *nn);
719 void put_nfs4_file(struct nfs4_file *fi);
720 extern void nfs4_put_cpntf_state(struct nfsd_net *nn,
721 struct nfs4_cpntf_state *cps);
722 extern __be32 manage_cpntf_state(struct nfsd_net *nn, stateid_t *st,
723 struct nfs4_client *clp,
724 struct nfs4_cpntf_state **cps);
725 static inline void get_nfs4_file(struct nfs4_file *fi)
727 refcount_inc(&fi->fi_ref);
729 struct nfsd_file *find_any_file(struct nfs4_file *f);
731 /* grace period management */
732 void nfsd4_end_grace(struct nfsd_net *nn);
734 /* nfs4recover operations */
735 extern int nfsd4_client_tracking_init(struct net *net);
736 extern void nfsd4_client_tracking_exit(struct net *net);
737 extern void nfsd4_client_record_create(struct nfs4_client *clp);
738 extern void nfsd4_client_record_remove(struct nfs4_client *clp);
739 extern int nfsd4_client_record_check(struct nfs4_client *clp);
740 extern void nfsd4_record_grace_done(struct nfsd_net *nn);
742 static inline bool try_to_expire_client(struct nfs4_client *clp)
744 cmpxchg(&clp->cl_state, NFSD4_COURTESY, NFSD4_EXPIRABLE);
745 return clp->cl_state == NFSD4_EXPIRABLE;
748 extern __be32 nfsd4_deleg_getattr_conflict(struct svc_rqst *rqstp,
749 struct inode *inode);
750 #endif /* NFSD4_STATE_H */