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