nfsrvcache.h revision 1.1.1.1.10.3 1 1.1.1.1.10.2 tls /* $NetBSD: nfsrvcache.h,v 1.1.1.1.10.3 2017/12/03 11:38:42 jdolecek Exp $ */
2 1.1.1.1.10.2 tls /*-
3 1.1.1.1.10.2 tls * Copyright (c) 1989, 1993
4 1.1.1.1.10.2 tls * The Regents of the University of California. All rights reserved.
5 1.1.1.1.10.2 tls *
6 1.1.1.1.10.2 tls * This code is derived from software contributed to Berkeley by
7 1.1.1.1.10.2 tls * Rick Macklem at The University of Guelph.
8 1.1.1.1.10.2 tls *
9 1.1.1.1.10.2 tls * Redistribution and use in source and binary forms, with or without
10 1.1.1.1.10.2 tls * modification, are permitted provided that the following conditions
11 1.1.1.1.10.2 tls * are met:
12 1.1.1.1.10.2 tls * 1. Redistributions of source code must retain the above copyright
13 1.1.1.1.10.2 tls * notice, this list of conditions and the following disclaimer.
14 1.1.1.1.10.2 tls * 2. Redistributions in binary form must reproduce the above copyright
15 1.1.1.1.10.2 tls * notice, this list of conditions and the following disclaimer in the
16 1.1.1.1.10.2 tls * documentation and/or other materials provided with the distribution.
17 1.1.1.1.10.2 tls * 4. Neither the name of the University nor the names of its contributors
18 1.1.1.1.10.2 tls * may be used to endorse or promote products derived from this software
19 1.1.1.1.10.2 tls * without specific prior written permission.
20 1.1.1.1.10.2 tls *
21 1.1.1.1.10.2 tls * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 1.1.1.1.10.2 tls * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 1.1.1.1.10.2 tls * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 1.1.1.1.10.2 tls * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 1.1.1.1.10.2 tls * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 1.1.1.1.10.2 tls * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 1.1.1.1.10.2 tls * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 1.1.1.1.10.2 tls * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 1.1.1.1.10.2 tls * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 1.1.1.1.10.2 tls * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 1.1.1.1.10.2 tls * SUCH DAMAGE.
32 1.1.1.1.10.2 tls *
33 1.1.1.1.10.3 jdolecek * FreeBSD: head/sys/fs/nfs/nfsrvcache.h 269347 2014-07-31 19:24:44Z kib
34 1.1.1.1.10.2 tls * $NetBSD: nfsrvcache.h,v 1.1.1.1.10.3 2017/12/03 11:38:42 jdolecek Exp $
35 1.1.1.1.10.2 tls */
36 1.1.1.1.10.2 tls
37 1.1.1.1.10.2 tls #ifndef _NFS_NFSRVCACHE_H_
38 1.1.1.1.10.2 tls #define _NFS_NFSRVCACHE_H_
39 1.1.1.1.10.2 tls
40 1.1.1.1.10.2 tls /*
41 1.1.1.1.10.2 tls * Definitions for the server recent request cache
42 1.1.1.1.10.2 tls */
43 1.1.1.1.10.2 tls #define NFSRVCACHE_MAX_SIZE 2048
44 1.1.1.1.10.2 tls #define NFSRVCACHE_MIN_SIZE 64
45 1.1.1.1.10.2 tls
46 1.1.1.1.10.2 tls #define NFSRVCACHE_HASHSIZE 500
47 1.1.1.1.10.2 tls
48 1.1.1.1.10.2 tls /* Cache table entry. */
49 1.1.1.1.10.2 tls struct nfsrvcache {
50 1.1.1.1.10.2 tls LIST_ENTRY(nfsrvcache) rc_hash; /* Hash chain */
51 1.1.1.1.10.3 jdolecek LIST_ENTRY(nfsrvcache) rc_ahash; /* ACK hash chain */
52 1.1.1.1.10.2 tls TAILQ_ENTRY(nfsrvcache) rc_lru; /* UDP lru chain */
53 1.1.1.1.10.2 tls u_int32_t rc_xid; /* rpc id number */
54 1.1.1.1.10.2 tls time_t rc_timestamp; /* Time done */
55 1.1.1.1.10.2 tls union {
56 1.1.1.1.10.2 tls mbuf_t repmb; /* Reply mbuf list OR */
57 1.1.1.1.10.2 tls int repstat; /* Reply status */
58 1.1.1.1.10.2 tls } rc_un;
59 1.1.1.1.10.2 tls union {
60 1.1.1.1.10.2 tls struct {
61 1.1.1.1.10.2 tls union nethostaddr haddr; /* Host address */
62 1.1.1.1.10.2 tls } udp;
63 1.1.1.1.10.2 tls struct {
64 1.1.1.1.10.2 tls u_int64_t sockref;
65 1.1.1.1.10.2 tls u_int32_t len;
66 1.1.1.1.10.2 tls u_int32_t tcpseq;
67 1.1.1.1.10.2 tls int16_t refcnt;
68 1.1.1.1.10.2 tls u_int16_t cksum;
69 1.1.1.1.10.2 tls time_t cachetime;
70 1.1.1.1.10.3 jdolecek int acked;
71 1.1.1.1.10.2 tls } ot;
72 1.1.1.1.10.2 tls } rc_un2;
73 1.1.1.1.10.2 tls u_int16_t rc_proc; /* rpc proc number */
74 1.1.1.1.10.2 tls u_int16_t rc_flag; /* Flag bits */
75 1.1.1.1.10.2 tls };
76 1.1.1.1.10.2 tls
77 1.1.1.1.10.2 tls #define rc_reply rc_un.repmb
78 1.1.1.1.10.2 tls #define rc_status rc_un.repstat
79 1.1.1.1.10.2 tls #define rc_inet rc_un2.udp.haddr.had_inet.s_addr
80 1.1.1.1.10.2 tls #define rc_inet6 rc_un2.udp.haddr.had_inet6
81 1.1.1.1.10.2 tls #define rc_haddr rc_un2.udp.haddr
82 1.1.1.1.10.2 tls #define rc_sockref rc_un2.ot.sockref
83 1.1.1.1.10.2 tls #define rc_tcpseq rc_un2.ot.tcpseq
84 1.1.1.1.10.2 tls #define rc_refcnt rc_un2.ot.refcnt
85 1.1.1.1.10.2 tls #define rc_reqlen rc_un2.ot.len
86 1.1.1.1.10.2 tls #define rc_cksum rc_un2.ot.cksum
87 1.1.1.1.10.2 tls #define rc_cachetime rc_un2.ot.cachetime
88 1.1.1.1.10.3 jdolecek #define rc_acked rc_un2.ot.acked
89 1.1.1.1.10.3 jdolecek
90 1.1.1.1.10.3 jdolecek /* TCP ACK values */
91 1.1.1.1.10.3 jdolecek #define RC_NO_SEQ 0
92 1.1.1.1.10.3 jdolecek #define RC_NO_ACK 1
93 1.1.1.1.10.3 jdolecek #define RC_ACK 2
94 1.1.1.1.10.3 jdolecek #define RC_NACK 3
95 1.1.1.1.10.2 tls
96 1.1.1.1.10.2 tls /* Return values */
97 1.1.1.1.10.2 tls #define RC_DROPIT 0
98 1.1.1.1.10.2 tls #define RC_REPLY 1
99 1.1.1.1.10.2 tls #define RC_DOIT 2
100 1.1.1.1.10.2 tls
101 1.1.1.1.10.2 tls /* Flag bits */
102 1.1.1.1.10.2 tls #define RC_LOCKED 0x0001
103 1.1.1.1.10.2 tls #define RC_WANTED 0x0002
104 1.1.1.1.10.2 tls #define RC_REPSTATUS 0x0004
105 1.1.1.1.10.2 tls #define RC_REPMBUF 0x0008
106 1.1.1.1.10.2 tls #define RC_UDP 0x0010
107 1.1.1.1.10.2 tls #define RC_INETIPV6 0x0020
108 1.1.1.1.10.2 tls #define RC_INPROG 0x0040
109 1.1.1.1.10.2 tls #define RC_NFSV2 0x0100
110 1.1.1.1.10.2 tls #define RC_NFSV3 0x0200
111 1.1.1.1.10.2 tls #define RC_NFSV4 0x0400
112 1.1.1.1.10.2 tls #define RC_NFSVERS (RC_NFSV2 | RC_NFSV3 | RC_NFSV4)
113 1.1.1.1.10.2 tls #define RC_REFCNT 0x0800
114 1.1.1.1.10.2 tls #define RC_SAMETCPCONN 0x1000
115 1.1.1.1.10.2 tls
116 1.1.1.1.10.2 tls LIST_HEAD(nfsrvhashhead, nfsrvcache);
117 1.1.1.1.10.2 tls
118 1.1.1.1.10.2 tls /* The fine-grained locked cache hash table for TCP. */
119 1.1.1.1.10.2 tls struct nfsrchash_bucket {
120 1.1.1.1.10.3 jdolecek struct kmutex mtx;
121 1.1.1.1.10.2 tls struct nfsrvhashhead tbl;
122 1.1.1.1.10.2 tls };
123 1.1.1.1.10.2 tls
124 1.1.1.1.10.2 tls #endif /* _NFS_NFSRVCACHE_H_ */
125