nfsclstate.h revision 1.1.1.1.4.2 1 1.1.1.1.4.2 rmind /* $NetBSD: nfsclstate.h,v 1.1.1.1.4.2 2014/05/18 17:46:05 rmind Exp $ */
2 1.1.1.1.4.2 rmind /*-
3 1.1.1.1.4.2 rmind * Copyright (c) 2009 Rick Macklem, University of Guelph
4 1.1.1.1.4.2 rmind * All rights reserved.
5 1.1.1.1.4.2 rmind *
6 1.1.1.1.4.2 rmind * Redistribution and use in source and binary forms, with or without
7 1.1.1.1.4.2 rmind * modification, are permitted provided that the following conditions
8 1.1.1.1.4.2 rmind * are met:
9 1.1.1.1.4.2 rmind * 1. Redistributions of source code must retain the above copyright
10 1.1.1.1.4.2 rmind * notice, this list of conditions and the following disclaimer.
11 1.1.1.1.4.2 rmind * 2. Redistributions in binary form must reproduce the above copyright
12 1.1.1.1.4.2 rmind * notice, this list of conditions and the following disclaimer in the
13 1.1.1.1.4.2 rmind * documentation and/or other materials provided with the distribution.
14 1.1.1.1.4.2 rmind *
15 1.1.1.1.4.2 rmind * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 1.1.1.1.4.2 rmind * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 1.1.1.1.4.2 rmind * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 1.1.1.1.4.2 rmind * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 1.1.1.1.4.2 rmind * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 1.1.1.1.4.2 rmind * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 1.1.1.1.4.2 rmind * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 1.1.1.1.4.2 rmind * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 1.1.1.1.4.2 rmind * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 1.1.1.1.4.2 rmind * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 1.1.1.1.4.2 rmind * SUCH DAMAGE.
26 1.1.1.1.4.2 rmind *
27 1.1.1.1.4.2 rmind * FreeBSD: head/sys/fs/nfs/nfsclstate.h 244042 2012-12-08 22:52:39Z rmacklem
28 1.1.1.1.4.2 rmind * $NetBSD: nfsclstate.h,v 1.1.1.1.4.2 2014/05/18 17:46:05 rmind Exp $
29 1.1.1.1.4.2 rmind */
30 1.1.1.1.4.2 rmind
31 1.1.1.1.4.2 rmind #ifndef _NFS_NFSCLSTATE_H_
32 1.1.1.1.4.2 rmind #define _NFS_NFSCLSTATE_H_
33 1.1.1.1.4.2 rmind
34 1.1.1.1.4.2 rmind /*
35 1.1.1.1.4.2 rmind * Definitions for NFS V4 client state handling.
36 1.1.1.1.4.2 rmind */
37 1.1.1.1.4.2 rmind LIST_HEAD(nfsclopenhead, nfsclopen);
38 1.1.1.1.4.2 rmind LIST_HEAD(nfscllockownerhead, nfscllockowner);
39 1.1.1.1.4.2 rmind SLIST_HEAD(nfscllockownerfhhead, nfscllockownerfh);
40 1.1.1.1.4.2 rmind LIST_HEAD(nfscllockhead, nfscllock);
41 1.1.1.1.4.2 rmind LIST_HEAD(nfsclhead, nfsclclient);
42 1.1.1.1.4.2 rmind LIST_HEAD(nfsclownerhead, nfsclowner);
43 1.1.1.1.4.2 rmind TAILQ_HEAD(nfscldeleghead, nfscldeleg);
44 1.1.1.1.4.2 rmind LIST_HEAD(nfscldeleghash, nfscldeleg);
45 1.1.1.1.4.2 rmind TAILQ_HEAD(nfscllayouthead, nfscllayout);
46 1.1.1.1.4.2 rmind LIST_HEAD(nfscllayouthash, nfscllayout);
47 1.1.1.1.4.2 rmind LIST_HEAD(nfsclflayouthead, nfsclflayout);
48 1.1.1.1.4.2 rmind LIST_HEAD(nfscldevinfohead, nfscldevinfo);
49 1.1.1.1.4.2 rmind LIST_HEAD(nfsclrecalllayouthead, nfsclrecalllayout);
50 1.1.1.1.4.2 rmind #define NFSCLDELEGHASHSIZE 256
51 1.1.1.1.4.2 rmind #define NFSCLDELEGHASH(c, f, l) \
52 1.1.1.1.4.2 rmind (&((c)->nfsc_deleghash[ncl_hash((f), (l)) % NFSCLDELEGHASHSIZE]))
53 1.1.1.1.4.2 rmind #define NFSCLLAYOUTHASHSIZE 256
54 1.1.1.1.4.2 rmind #define NFSCLLAYOUTHASH(c, f, l) \
55 1.1.1.1.4.2 rmind (&((c)->nfsc_layouthash[ncl_hash((f), (l)) % NFSCLLAYOUTHASHSIZE]))
56 1.1.1.1.4.2 rmind
57 1.1.1.1.4.2 rmind /* Structure for NFSv4.1 session stuff. */
58 1.1.1.1.4.2 rmind struct nfsclsession {
59 1.1.1.1.4.2 rmind struct mtx nfsess_mtx;
60 1.1.1.1.4.2 rmind struct nfsslot nfsess_cbslots[NFSV4_CBSLOTS];
61 1.1.1.1.4.2 rmind nfsquad_t nfsess_clientid;
62 1.1.1.1.4.2 rmind uint32_t nfsess_slotseq[64]; /* Max for 64bit nm_slots */
63 1.1.1.1.4.2 rmind uint64_t nfsess_slots;
64 1.1.1.1.4.2 rmind uint32_t nfsess_sequenceid;
65 1.1.1.1.4.2 rmind uint32_t nfsess_maxcache; /* Max size for cached reply. */
66 1.1.1.1.4.2 rmind uint16_t nfsess_foreslots;
67 1.1.1.1.4.2 rmind uint16_t nfsess_backslots;
68 1.1.1.1.4.2 rmind uint8_t nfsess_sessionid[NFSX_V4SESSIONID];
69 1.1.1.1.4.2 rmind };
70 1.1.1.1.4.2 rmind
71 1.1.1.1.4.2 rmind /*
72 1.1.1.1.4.2 rmind * This structure holds the session, clientid and related information
73 1.1.1.1.4.2 rmind * needed for an NFSv4.1 Meta Data Server (MDS) or Data Server (DS).
74 1.1.1.1.4.2 rmind * It is malloc'd to the correct length.
75 1.1.1.1.4.2 rmind */
76 1.1.1.1.4.2 rmind struct nfsclds {
77 1.1.1.1.4.2 rmind TAILQ_ENTRY(nfsclds) nfsclds_list;
78 1.1.1.1.4.2 rmind struct nfsclsession nfsclds_sess;
79 1.1.1.1.4.2 rmind struct mtx nfsclds_mtx;
80 1.1.1.1.4.2 rmind struct nfssockreq *nfsclds_sockp;
81 1.1.1.1.4.2 rmind time_t nfsclds_expire;
82 1.1.1.1.4.2 rmind uint16_t nfsclds_flags;
83 1.1.1.1.4.2 rmind uint16_t nfsclds_servownlen;
84 1.1.1.1.4.2 rmind uint8_t nfsclds_verf[NFSX_VERF];
85 1.1.1.1.4.2 rmind uint8_t nfsclds_serverown[0];
86 1.1.1.1.4.2 rmind };
87 1.1.1.1.4.2 rmind
88 1.1.1.1.4.2 rmind /*
89 1.1.1.1.4.2 rmind * Flags for nfsclds_flags.
90 1.1.1.1.4.2 rmind */
91 1.1.1.1.4.2 rmind #define NFSCLDS_HASWRITEVERF 0x0001
92 1.1.1.1.4.2 rmind #define NFSCLDS_MDS 0x0002
93 1.1.1.1.4.2 rmind #define NFSCLDS_DS 0x0004
94 1.1.1.1.4.2 rmind
95 1.1.1.1.4.2 rmind struct nfsclclient {
96 1.1.1.1.4.2 rmind LIST_ENTRY(nfsclclient) nfsc_list;
97 1.1.1.1.4.2 rmind struct nfsclownerhead nfsc_owner;
98 1.1.1.1.4.2 rmind struct nfscldeleghead nfsc_deleg;
99 1.1.1.1.4.2 rmind struct nfscldeleghash nfsc_deleghash[NFSCLDELEGHASHSIZE];
100 1.1.1.1.4.2 rmind struct nfscllayouthead nfsc_layout;
101 1.1.1.1.4.2 rmind struct nfscllayouthash nfsc_layouthash[NFSCLLAYOUTHASHSIZE];
102 1.1.1.1.4.2 rmind struct nfscldevinfohead nfsc_devinfo;
103 1.1.1.1.4.2 rmind struct nfsv4lock nfsc_lock;
104 1.1.1.1.4.2 rmind struct proc *nfsc_renewthread;
105 1.1.1.1.4.2 rmind struct nfsmount *nfsc_nmp;
106 1.1.1.1.4.2 rmind time_t nfsc_expire;
107 1.1.1.1.4.2 rmind u_int32_t nfsc_clientidrev;
108 1.1.1.1.4.2 rmind u_int32_t nfsc_rev;
109 1.1.1.1.4.2 rmind u_int32_t nfsc_renew;
110 1.1.1.1.4.2 rmind u_int32_t nfsc_cbident;
111 1.1.1.1.4.2 rmind u_int16_t nfsc_flags;
112 1.1.1.1.4.2 rmind u_int16_t nfsc_idlen;
113 1.1.1.1.4.2 rmind u_int8_t nfsc_id[1]; /* Malloc'd to correct length */
114 1.1.1.1.4.2 rmind };
115 1.1.1.1.4.2 rmind
116 1.1.1.1.4.2 rmind /*
117 1.1.1.1.4.2 rmind * Bits for nfsc_flags.
118 1.1.1.1.4.2 rmind */
119 1.1.1.1.4.2 rmind #define NFSCLFLAGS_INITED 0x0001
120 1.1.1.1.4.2 rmind #define NFSCLFLAGS_HASCLIENTID 0x0002
121 1.1.1.1.4.2 rmind #define NFSCLFLAGS_RECOVER 0x0004
122 1.1.1.1.4.2 rmind #define NFSCLFLAGS_UMOUNT 0x0008
123 1.1.1.1.4.2 rmind #define NFSCLFLAGS_HASTHREAD 0x0010
124 1.1.1.1.4.2 rmind #define NFSCLFLAGS_AFINET6 0x0020
125 1.1.1.1.4.2 rmind #define NFSCLFLAGS_EXPIREIT 0x0040
126 1.1.1.1.4.2 rmind #define NFSCLFLAGS_FIRSTDELEG 0x0080
127 1.1.1.1.4.2 rmind #define NFSCLFLAGS_GOTDELEG 0x0100
128 1.1.1.1.4.2 rmind #define NFSCLFLAGS_RECVRINPROG 0x0200
129 1.1.1.1.4.2 rmind
130 1.1.1.1.4.2 rmind struct nfsclowner {
131 1.1.1.1.4.2 rmind LIST_ENTRY(nfsclowner) nfsow_list;
132 1.1.1.1.4.2 rmind struct nfsclopenhead nfsow_open;
133 1.1.1.1.4.2 rmind struct nfsclclient *nfsow_clp;
134 1.1.1.1.4.2 rmind u_int32_t nfsow_seqid;
135 1.1.1.1.4.2 rmind u_int32_t nfsow_defunct;
136 1.1.1.1.4.2 rmind struct nfsv4lock nfsow_rwlock;
137 1.1.1.1.4.2 rmind u_int8_t nfsow_owner[NFSV4CL_LOCKNAMELEN];
138 1.1.1.1.4.2 rmind };
139 1.1.1.1.4.2 rmind
140 1.1.1.1.4.2 rmind /*
141 1.1.1.1.4.2 rmind * MALLOC'd to the correct length to accommodate the file handle.
142 1.1.1.1.4.2 rmind */
143 1.1.1.1.4.2 rmind struct nfscldeleg {
144 1.1.1.1.4.2 rmind TAILQ_ENTRY(nfscldeleg) nfsdl_list;
145 1.1.1.1.4.2 rmind LIST_ENTRY(nfscldeleg) nfsdl_hash;
146 1.1.1.1.4.2 rmind struct nfsclownerhead nfsdl_owner; /* locally issued state */
147 1.1.1.1.4.2 rmind struct nfscllockownerhead nfsdl_lock;
148 1.1.1.1.4.2 rmind nfsv4stateid_t nfsdl_stateid;
149 1.1.1.1.4.2 rmind struct acl_entry nfsdl_ace; /* Delegation ace */
150 1.1.1.1.4.2 rmind struct nfsclclient *nfsdl_clp;
151 1.1.1.1.4.2 rmind struct nfsv4lock nfsdl_rwlock; /* for active I/O ops */
152 1.1.1.1.4.2 rmind struct nfscred nfsdl_cred; /* Cred. used for Open */
153 1.1.1.1.4.2 rmind time_t nfsdl_timestamp; /* used for stale cleanup */
154 1.1.1.1.4.2 rmind u_int64_t nfsdl_sizelimit; /* Limit for file growth */
155 1.1.1.1.4.2 rmind u_int64_t nfsdl_size; /* saved copy of file size */
156 1.1.1.1.4.2 rmind u_int64_t nfsdl_change; /* and change attribute */
157 1.1.1.1.4.2 rmind struct timespec nfsdl_modtime; /* local modify time */
158 1.1.1.1.4.2 rmind u_int16_t nfsdl_fhlen;
159 1.1.1.1.4.2 rmind u_int8_t nfsdl_flags;
160 1.1.1.1.4.2 rmind u_int8_t nfsdl_fh[1]; /* must be last */
161 1.1.1.1.4.2 rmind };
162 1.1.1.1.4.2 rmind
163 1.1.1.1.4.2 rmind /*
164 1.1.1.1.4.2 rmind * nfsdl_flags bits.
165 1.1.1.1.4.2 rmind */
166 1.1.1.1.4.2 rmind #define NFSCLDL_READ 0x01
167 1.1.1.1.4.2 rmind #define NFSCLDL_WRITE 0x02
168 1.1.1.1.4.2 rmind #define NFSCLDL_RECALL 0x04
169 1.1.1.1.4.2 rmind #define NFSCLDL_NEEDRECLAIM 0x08
170 1.1.1.1.4.2 rmind #define NFSCLDL_ZAPPED 0x10
171 1.1.1.1.4.2 rmind #define NFSCLDL_MODTIMESET 0x20
172 1.1.1.1.4.2 rmind #define NFSCLDL_DELEGRET 0x40
173 1.1.1.1.4.2 rmind
174 1.1.1.1.4.2 rmind /*
175 1.1.1.1.4.2 rmind * MALLOC'd to the correct length to accommodate the file handle.
176 1.1.1.1.4.2 rmind */
177 1.1.1.1.4.2 rmind struct nfsclopen {
178 1.1.1.1.4.2 rmind LIST_ENTRY(nfsclopen) nfso_list;
179 1.1.1.1.4.2 rmind struct nfscllockownerhead nfso_lock;
180 1.1.1.1.4.2 rmind nfsv4stateid_t nfso_stateid;
181 1.1.1.1.4.2 rmind struct nfsclowner *nfso_own;
182 1.1.1.1.4.2 rmind struct nfscred nfso_cred; /* Cred. used for Open */
183 1.1.1.1.4.2 rmind u_int32_t nfso_mode;
184 1.1.1.1.4.2 rmind u_int32_t nfso_opencnt;
185 1.1.1.1.4.2 rmind u_int16_t nfso_fhlen;
186 1.1.1.1.4.2 rmind u_int8_t nfso_posixlock; /* 1 for POSIX type locking */
187 1.1.1.1.4.2 rmind u_int8_t nfso_fh[1]; /* must be last */
188 1.1.1.1.4.2 rmind };
189 1.1.1.1.4.2 rmind
190 1.1.1.1.4.2 rmind /*
191 1.1.1.1.4.2 rmind * Return values for nfscl_open(). NFSCLOPEN_OK must == 0.
192 1.1.1.1.4.2 rmind */
193 1.1.1.1.4.2 rmind #define NFSCLOPEN_OK 0
194 1.1.1.1.4.2 rmind #define NFSCLOPEN_DOOPEN 1
195 1.1.1.1.4.2 rmind #define NFSCLOPEN_DOOPENDOWNGRADE 2
196 1.1.1.1.4.2 rmind #define NFSCLOPEN_SETCRED 3
197 1.1.1.1.4.2 rmind
198 1.1.1.1.4.2 rmind struct nfscllockowner {
199 1.1.1.1.4.2 rmind LIST_ENTRY(nfscllockowner) nfsl_list;
200 1.1.1.1.4.2 rmind struct nfscllockhead nfsl_lock;
201 1.1.1.1.4.2 rmind struct nfsclopen *nfsl_open;
202 1.1.1.1.4.2 rmind NFSPROC_T *nfsl_inprog;
203 1.1.1.1.4.2 rmind nfsv4stateid_t nfsl_stateid;
204 1.1.1.1.4.2 rmind int nfsl_lockflags;
205 1.1.1.1.4.2 rmind u_int32_t nfsl_seqid;
206 1.1.1.1.4.2 rmind struct nfsv4lock nfsl_rwlock;
207 1.1.1.1.4.2 rmind u_int8_t nfsl_owner[NFSV4CL_LOCKNAMELEN];
208 1.1.1.1.4.2 rmind u_int8_t nfsl_openowner[NFSV4CL_LOCKNAMELEN];
209 1.1.1.1.4.2 rmind };
210 1.1.1.1.4.2 rmind
211 1.1.1.1.4.2 rmind /*
212 1.1.1.1.4.2 rmind * Byte range entry for the above lock owner.
213 1.1.1.1.4.2 rmind */
214 1.1.1.1.4.2 rmind struct nfscllock {
215 1.1.1.1.4.2 rmind LIST_ENTRY(nfscllock) nfslo_list;
216 1.1.1.1.4.2 rmind u_int64_t nfslo_first;
217 1.1.1.1.4.2 rmind u_int64_t nfslo_end;
218 1.1.1.1.4.2 rmind short nfslo_type;
219 1.1.1.1.4.2 rmind };
220 1.1.1.1.4.2 rmind
221 1.1.1.1.4.2 rmind /* This structure is used to collect a list of lockowners to free up. */
222 1.1.1.1.4.2 rmind struct nfscllockownerfh {
223 1.1.1.1.4.2 rmind SLIST_ENTRY(nfscllockownerfh) nfslfh_list;
224 1.1.1.1.4.2 rmind struct nfscllockownerhead nfslfh_lock;
225 1.1.1.1.4.2 rmind int nfslfh_len;
226 1.1.1.1.4.2 rmind uint8_t nfslfh_fh[NFSX_V4FHMAX];
227 1.1.1.1.4.2 rmind };
228 1.1.1.1.4.2 rmind
229 1.1.1.1.4.2 rmind /*
230 1.1.1.1.4.2 rmind * MALLOC'd to the correct length to accommodate the file handle.
231 1.1.1.1.4.2 rmind */
232 1.1.1.1.4.2 rmind struct nfscllayout {
233 1.1.1.1.4.2 rmind TAILQ_ENTRY(nfscllayout) nfsly_list;
234 1.1.1.1.4.2 rmind LIST_ENTRY(nfscllayout) nfsly_hash;
235 1.1.1.1.4.2 rmind nfsv4stateid_t nfsly_stateid;
236 1.1.1.1.4.2 rmind struct nfsv4lock nfsly_lock;
237 1.1.1.1.4.2 rmind uint64_t nfsly_filesid[2];
238 1.1.1.1.4.2 rmind uint64_t nfsly_lastbyte;
239 1.1.1.1.4.2 rmind struct nfsclflayouthead nfsly_flayread;
240 1.1.1.1.4.2 rmind struct nfsclflayouthead nfsly_flayrw;
241 1.1.1.1.4.2 rmind struct nfsclrecalllayouthead nfsly_recall;
242 1.1.1.1.4.2 rmind time_t nfsly_timestamp;
243 1.1.1.1.4.2 rmind struct nfsclclient *nfsly_clp;
244 1.1.1.1.4.2 rmind uint16_t nfsly_flags;
245 1.1.1.1.4.2 rmind uint16_t nfsly_fhlen;
246 1.1.1.1.4.2 rmind uint8_t nfsly_fh[1];
247 1.1.1.1.4.2 rmind };
248 1.1.1.1.4.2 rmind
249 1.1.1.1.4.2 rmind /*
250 1.1.1.1.4.2 rmind * Flags for nfsly_flags.
251 1.1.1.1.4.2 rmind */
252 1.1.1.1.4.2 rmind #define NFSLY_FILES 0x0001
253 1.1.1.1.4.2 rmind #define NFSLY_BLOCK 0x0002
254 1.1.1.1.4.2 rmind #define NFSLY_OBJECT 0x0004
255 1.1.1.1.4.2 rmind #define NFSLY_RECALL 0x0008
256 1.1.1.1.4.2 rmind #define NFSLY_RECALLFILE 0x0010
257 1.1.1.1.4.2 rmind #define NFSLY_RECALLFSID 0x0020
258 1.1.1.1.4.2 rmind #define NFSLY_RECALLALL 0x0040
259 1.1.1.1.4.2 rmind #define NFSLY_RETONCLOSE 0x0080
260 1.1.1.1.4.2 rmind #define NFSLY_WRITTEN 0x0100 /* Has been used to write to a DS. */
261 1.1.1.1.4.2 rmind
262 1.1.1.1.4.2 rmind /*
263 1.1.1.1.4.2 rmind * MALLOC'd to the correct length to accommodate the file handle list.
264 1.1.1.1.4.2 rmind * These hang off of nfsly_flayread and nfsly_flayrw, sorted in increasing
265 1.1.1.1.4.2 rmind * offset order.
266 1.1.1.1.4.2 rmind * The nfsly_flayread list holds the ones with iomode == NFSLAYOUTIOMODE_READ,
267 1.1.1.1.4.2 rmind * whereas the nfsly_flayrw holds the ones with iomode == NFSLAYOUTIOMODE_RW.
268 1.1.1.1.4.2 rmind */
269 1.1.1.1.4.2 rmind struct nfsclflayout {
270 1.1.1.1.4.2 rmind LIST_ENTRY(nfsclflayout) nfsfl_list;
271 1.1.1.1.4.2 rmind uint8_t nfsfl_dev[NFSX_V4DEVICEID];
272 1.1.1.1.4.2 rmind uint64_t nfsfl_off;
273 1.1.1.1.4.2 rmind uint64_t nfsfl_end;
274 1.1.1.1.4.2 rmind uint64_t nfsfl_patoff;
275 1.1.1.1.4.2 rmind struct nfscldevinfo *nfsfl_devp;
276 1.1.1.1.4.2 rmind uint32_t nfsfl_iomode;
277 1.1.1.1.4.2 rmind uint32_t nfsfl_util;
278 1.1.1.1.4.2 rmind uint32_t nfsfl_stripe1;
279 1.1.1.1.4.2 rmind uint16_t nfsfl_flags;
280 1.1.1.1.4.2 rmind uint16_t nfsfl_fhcnt;
281 1.1.1.1.4.2 rmind struct nfsfh *nfsfl_fh[1]; /* FH list for DS */
282 1.1.1.1.4.2 rmind };
283 1.1.1.1.4.2 rmind
284 1.1.1.1.4.2 rmind /*
285 1.1.1.1.4.2 rmind * Flags for nfsfl_flags.
286 1.1.1.1.4.2 rmind */
287 1.1.1.1.4.2 rmind #define NFSFL_RECALL 0x0001 /* File layout has been recalled */
288 1.1.1.1.4.2 rmind
289 1.1.1.1.4.2 rmind /*
290 1.1.1.1.4.2 rmind * Structure that is used to store a LAYOUTRECALL.
291 1.1.1.1.4.2 rmind */
292 1.1.1.1.4.2 rmind struct nfsclrecalllayout {
293 1.1.1.1.4.2 rmind LIST_ENTRY(nfsclrecalllayout) nfsrecly_list;
294 1.1.1.1.4.2 rmind uint64_t nfsrecly_off;
295 1.1.1.1.4.2 rmind uint64_t nfsrecly_len;
296 1.1.1.1.4.2 rmind int nfsrecly_recalltype;
297 1.1.1.1.4.2 rmind uint32_t nfsrecly_iomode;
298 1.1.1.1.4.2 rmind uint32_t nfsrecly_stateseqid;
299 1.1.1.1.4.2 rmind };
300 1.1.1.1.4.2 rmind
301 1.1.1.1.4.2 rmind /*
302 1.1.1.1.4.2 rmind * Stores the NFSv4.1 Device Info. Malloc'd to the correct length to
303 1.1.1.1.4.2 rmind * store the list of network connections and list of indices.
304 1.1.1.1.4.2 rmind * nfsdi_data[] is allocated the following way:
305 1.1.1.1.4.2 rmind * - nfsdi_addrcnt * struct nfsclds
306 1.1.1.1.4.2 rmind * - stripe indices, each stored as one byte, since there can be many
307 1.1.1.1.4.2 rmind * of them. (This implies a limit of 256 on nfsdi_addrcnt, since the
308 1.1.1.1.4.2 rmind * indices select which address.)
309 1.1.1.1.4.2 rmind */
310 1.1.1.1.4.2 rmind struct nfscldevinfo {
311 1.1.1.1.4.2 rmind LIST_ENTRY(nfscldevinfo) nfsdi_list;
312 1.1.1.1.4.2 rmind uint8_t nfsdi_deviceid[NFSX_V4DEVICEID];
313 1.1.1.1.4.2 rmind struct nfsclclient *nfsdi_clp;
314 1.1.1.1.4.2 rmind uint32_t nfsdi_refcnt;
315 1.1.1.1.4.2 rmind uint32_t nfsdi_layoutrefs;
316 1.1.1.1.4.2 rmind uint16_t nfsdi_stripecnt;
317 1.1.1.1.4.2 rmind uint16_t nfsdi_addrcnt;
318 1.1.1.1.4.2 rmind struct nfsclds *nfsdi_data[0];
319 1.1.1.1.4.2 rmind };
320 1.1.1.1.4.2 rmind
321 1.1.1.1.4.2 rmind /* These inline functions return values from nfsdi_data[]. */
322 1.1.1.1.4.2 rmind /*
323 1.1.1.1.4.2 rmind * Return a pointer to the address at "pos".
324 1.1.1.1.4.2 rmind */
325 1.1.1.1.4.2 rmind static __inline struct nfsclds **
326 1.1.1.1.4.2 rmind nfsfldi_addr(struct nfscldevinfo *ndi, int pos)
327 1.1.1.1.4.2 rmind {
328 1.1.1.1.4.2 rmind
329 1.1.1.1.4.2 rmind if (pos >= ndi->nfsdi_addrcnt)
330 1.1.1.1.4.2 rmind return (NULL);
331 1.1.1.1.4.2 rmind return (&ndi->nfsdi_data[pos]);
332 1.1.1.1.4.2 rmind }
333 1.1.1.1.4.2 rmind
334 1.1.1.1.4.2 rmind /*
335 1.1.1.1.4.2 rmind * Return the Nth ("pos") stripe index.
336 1.1.1.1.4.2 rmind */
337 1.1.1.1.4.2 rmind static __inline int
338 1.1.1.1.4.2 rmind nfsfldi_stripeindex(struct nfscldevinfo *ndi, int pos)
339 1.1.1.1.4.2 rmind {
340 1.1.1.1.4.2 rmind uint8_t *valp;
341 1.1.1.1.4.2 rmind
342 1.1.1.1.4.2 rmind if (pos >= ndi->nfsdi_stripecnt)
343 1.1.1.1.4.2 rmind return (-1);
344 1.1.1.1.4.2 rmind valp = (uint8_t *)&ndi->nfsdi_data[ndi->nfsdi_addrcnt];
345 1.1.1.1.4.2 rmind valp += pos;
346 1.1.1.1.4.2 rmind return ((int)*valp);
347 1.1.1.1.4.2 rmind }
348 1.1.1.1.4.2 rmind
349 1.1.1.1.4.2 rmind /*
350 1.1.1.1.4.2 rmind * Set the Nth ("pos") stripe index to "val".
351 1.1.1.1.4.2 rmind */
352 1.1.1.1.4.2 rmind static __inline void
353 1.1.1.1.4.2 rmind nfsfldi_setstripeindex(struct nfscldevinfo *ndi, int pos, uint8_t val)
354 1.1.1.1.4.2 rmind {
355 1.1.1.1.4.2 rmind uint8_t *valp;
356 1.1.1.1.4.2 rmind
357 1.1.1.1.4.2 rmind if (pos >= ndi->nfsdi_stripecnt)
358 1.1.1.1.4.2 rmind return;
359 1.1.1.1.4.2 rmind valp = (uint8_t *)&ndi->nfsdi_data[ndi->nfsdi_addrcnt];
360 1.1.1.1.4.2 rmind valp += pos;
361 1.1.1.1.4.2 rmind *valp = val;
362 1.1.1.1.4.2 rmind }
363 1.1.1.1.4.2 rmind
364 1.1.1.1.4.2 rmind /*
365 1.1.1.1.4.2 rmind * Macro for incrementing the seqid#.
366 1.1.1.1.4.2 rmind */
367 1.1.1.1.4.2 rmind #define NFSCL_INCRSEQID(s, n) do { \
368 1.1.1.1.4.2 rmind if (((n)->nd_flag & ND_INCRSEQID)) \
369 1.1.1.1.4.2 rmind (s)++; \
370 1.1.1.1.4.2 rmind } while (0)
371 1.1.1.1.4.2 rmind
372 1.1.1.1.4.2 rmind #endif /* _NFS_NFSCLSTATE_H_ */
373