xref: /illumos-gate/usr/src/uts/common/nfs/nfs4_drc.h (revision 0dfe541e)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 
22 /*
23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * Copyright 2018 Nexenta Systems, Inc.
29  */
30 
31 #ifndef _NFS4_DRC_H
32 #define	_NFS4_DRC_H
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 /*
39  * NFSv4 Duplicate Request cache.
40  */
41 typedef struct rfs4_drc {
42 	kmutex_t	lock;
43 	uint32_t	dr_hash;
44 	uint32_t	max_size;
45 	uint32_t	in_use;
46 	list_t		dr_cache;
47 	list_t		*dr_buckets;
48 } rfs4_drc_t;
49 
50 /*
51  * NFSv4 Duplicate request cache entry.
52  */
53 typedef struct rfs4_dupreq {
54 	list_node_t	dr_bkt_next;
55 	list_node_t	dr_next;
56 	list_t		*dr_bkt;
57 	rfs4_drc_t	*drc;
58 	int		dr_state;
59 	uint32_t	dr_xid;
60 	struct netbuf	dr_addr;
61 	COMPOUND4res	dr_res;
62 } rfs4_dupreq_t;
63 
64 /*
65  *  State of rfs4_dupreq.
66  */
67 #define	NFS4_DUP_ERROR		-1
68 #define	NFS4_NOT_DUP		0
69 #define	NFS4_DUP_NEW		1
70 #define	NFS4_DUP_PENDING	2
71 #define	NFS4_DUP_FREE		3
72 
73 #define	NFS4_DUP_REPLAY		4
74 #define	NFS4_DUP_INUSE		5
75 
76 extern uint32_t nfs4_drc_max;
77 extern uint32_t nfs4_drc_hash;
78 
79 rfs4_drc_t *rfs4_init_drc(uint32_t, uint32_t);
80 void rfs4_fini_drc(void);
81 void rfs4_dr_chstate(rfs4_dupreq_t *, int);
82 rfs4_dupreq_t *rfs4_alloc_dr(rfs4_drc_t *);
83 int rfs4_find_dr(struct svc_req *, rfs4_drc_t *, rfs4_dupreq_t **);
84 
85 #ifdef	__cplusplus
86 }
87 #endif
88 
89 #endif /* _NFS4_DRC_H */
90