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