Print this page
NEX-19996 exi_id_get_next() calls should be WRITER locked
NEX-20014 NFS v4 state lock mutex exited before entered (on error path)
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>
Reviewed by: Joyce McIntosh <joyce.mcintosh@nexenta.com>
NEX-15279 support NFS server in zone
NEX-15520 online NFS shares cause zoneadm halt to hang in nfs_export_zone_fini
Portions contributed by: Dan Kruchinin dan.kruchinin@nexenta.com
Portions contributed by: Stepan Zastupov stepan.zastupov@gmail.com
Reviewed by: Joyce McIntosh <joyce.mcintosh@nexenta.com>
Reviewed by: Rob Gittins <rob.gittins@nexenta.com>
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
NEX-9275 Got "bad mutex" panic when run IO to nfs share from clients
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Rob Gittins <rob.gittins@nexenta.com>
NEX-6778 NFS kstats leak and cause system to hang
Revert "NEX-4261 Per-client NFS server IOPS, bandwidth, and latency kstats"
This reverts commit 586c3ab1927647487f01c337ddc011c642575a52.
Revert "NEX-5354 Aggregated IOPS, bandwidth, and latency kstats for NFS server"
This reverts commit c91d7614da8618ef48018102b077f60ecbbac8c2.
Revert "NEX-5667 nfssrv_stats_flags does not work for aggregated kstats"
This reverts commit 3dcf42618be7dd5f408c327f429c81e07ca08e74.
Revert "NEX-5750 Time values for aggregated NFS server kstats should be normalized"
This reverts commit 1f4d4f901153b0191027969fa4a8064f9d3b9ee1.
Revert "NEX-5942 Panic in rfs4_minorvers_mismatch() with NFSv4.1 client"
This reverts commit 40766417094a162f5e4cc8786c0fa0a7e5871cd9.
Revert "NEX-5752 NFS server: namespace collision in kstats"
This reverts commit ae81e668db86050da8e483264acb0cce0444a132.
Reviewed by: Rob Gittins <rob.gittins@nexenta.com>
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
NEX-5667 nfssrv_stats_flags does not work for aggregated kstats
NEX-4472 nfsauth_retrieve() flood caused by NFS clients with personal identity problems
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
NEX-4261 Per-client NFS server IOPS, bandwidth, and latency kstats
Reviewed by: Kevin Crowe <kevin.crowe@nexenta.com>
Reviewed by: Roman Strashkin <roman.strashkin@nexenta.com>
NEX-3097 IOPS, bandwidth, and latency kstats for NFS server
Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
NEX-2345 nfsauth_cache_get() could spend a lot of time walking exi_cache
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
NEX-1974 Support for more than 16 groups with AUTH_SYS
Reviewed by: Gordon Ross <gordon.ross@nexenta.com>
Reviewed by: Josef 'Jeff' Sipek <josef.sipek@nexenta.com>
NEX-1128 NFS server: Generic uid and gid remapping for AUTH_SYS
Reviewed by: Jan Kryl <jan.kryl@nexenta.com>
re #3541 rb11254 - nfs nohide - "nfssrv: need ability to go to submounts for v3 and v2 protocols"
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/nfs/export.h
+++ new/usr/src/uts/common/nfs/export.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
|
↓ open down ↓ |
12 lines elided |
↑ open up ↑ |
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 - * Copyright 2016 Nexenta Systems, Inc. All rights reserved.
23 + * Copyright 2018 Nexenta Systems, Inc.
24 24 * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
25 25 * Copyright 2016 Jason King.
26 26 */
27 27
28 28 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
29 29 /* All Rights Reserved */
30 30
31 31 #ifndef _NFS_EXPORT_H
32 32 #define _NFS_EXPORT_H
33 33
34 34 #include <nfs/nfs_sec.h>
35 35 #include <nfs/auth.h>
36 36 #include <sys/vnode.h>
37 37 #include <nfs/nfs4.h>
38 38 #include <sys/kiconv.h>
39 39 #include <sys/avl.h>
40 40
41 +#ifdef _KERNEL
42 +#include <sys/pkp_hash.h> /* for PKP_HASH_SIZE */
43 +#endif /* _KERNEL */
44 +
41 45 #ifdef __cplusplus
42 46 extern "C" {
43 47 #endif
44 48
45 49 /*
46 50 * nfs pseudo flavor number is owned by IANA. Need to make sure the
47 51 * Solaris specific NFS_FLAVOR_NOMAP number will not overlap with any
48 52 * new IANA defined pseudo flavor numbers. The chance for the overlap
49 53 * is very small since the growth of new flavor numbers is expected
50 54 * to be limited.
51 55 */
52 56 #define NFS_FLAVOR_NOMAP 999999 /* no nfs flavor mapping */
53 57
54 58 /*
55 59 * As duplicate flavors can be passed into exportfs in the arguments, we
56 60 * allocate a cleaned up array with non duplicate flavors on the stack.
57 61 * So we need to know how much to allocate.
58 62 */
59 63 #define MAX_FLAVORS 6 /* none, sys, dh, krb5, krb5i krb5p */
60 64
61 65 /*
62 66 * Note: exported_lock is currently used to ensure the integrity of
63 67 * the secinfo fields.
64 68 */
65 69 struct secinfo {
66 70 seconfig_t s_secinfo; /* /etc/nfssec.conf entry */
67 71 unsigned int s_flags; /* flags (see below) */
68 72 int32_t s_refcnt; /* reference count for tracking */
69 73 /* how many children (self included) */
70 74 /* use this flavor. */
71 75 int s_window; /* window */
72 76 uint_t s_rootid; /* UID to use for authorized roots */
73 77 int s_rootcnt; /* count of root names */
74 78 caddr_t *s_rootnames; /* array of root names */
75 79 /* they are strings for AUTH_DES and */
76 80 /* rpc_gss_principal_t for RPCSEC_GSS */
77 81 };
78 82
79 83 #ifdef _SYSCALL32
80 84 struct secinfo32 {
81 85 seconfig32_t s_secinfo; /* /etc/nfssec.conf entry */
82 86 uint32_t s_flags; /* flags (see below) */
83 87 int32_t s_refcnt; /* reference count for tracking */
84 88 /* how many children (self included) */
85 89 /* use this flavor. */
86 90 int32_t s_window; /* window */
87 91 uint32_t s_rootid; /* UID to use for authorized roots */
88 92 int32_t s_rootcnt; /* count of root names */
89 93 caddr32_t s_rootnames; /* array of root names */
90 94 /* they are strings for AUTH_DES and */
91 95 /* rpc_gss_principal_t for RPCSEC_GSS */
92 96 };
93 97 #endif /* _SYSCALL32 */
94 98
95 99 /*
96 100 * security negotiation related
97 101 */
98 102
99 103 #define SEC_QUERY 0x01 /* query sec modes */
100 104
101 105 struct sec_ol {
102 106 int sec_flags; /* security nego flags */
103 107 uint_t sec_index; /* index into sec flavor array */
104 108 };
105 109
106 110 /*
107 111 * Per-mode flags (secinfo.s_flags)
108 112 */
109 113 #define M_RO 0x01 /* exported ro to all */
110 114 #define M_ROL 0x02 /* exported ro to all listed */
111 115 #define M_RW 0x04 /* exported rw to all */
112 116 #define M_RWL 0x08 /* exported ro to all listed */
113 117 #define M_ROOT 0x10 /* root list is defined */
114 118 #define M_4SEC_EXPORTED 0x20 /* this is an explicitly shared flavor */
115 119 #define M_NONE 0x40 /* none list is defined */
116 120 #define M_MAP 0x80 /* uidmap and/or gidmap is defined */
117 121
118 122 /* invalid secinfo reference count */
119 123 #define SEC_REF_INVALID(p) ((p)->s_refcnt < 1)
120 124
121 125 /* last secinfo reference */
122 126 #define SEC_REF_LAST(p) ((p)->s_refcnt == 1)
123 127
124 128 /* sec flavor explicitly shared for the exported node */
125 129 #define SEC_REF_EXPORTED(p) ((p)->s_flags & M_4SEC_EXPORTED)
126 130
127 131 /* the only reference count left is for referring itself */
128 132 #define SEC_REF_SELF(p) (SEC_REF_LAST(p) && SEC_REF_EXPORTED(p))
129 133
130 134 /*
131 135 * The export information passed to exportfs() (Version 2)
132 136 */
133 137 #define EX_CURRENT_VERSION 2 /* current version of exportdata struct */
134 138
135 139 struct exportdata {
136 140 int ex_version; /* structure version */
137 141 char *ex_path; /* exported path */
138 142 size_t ex_pathlen; /* path length */
139 143 int ex_flags; /* flags */
140 144 unsigned int ex_anon; /* uid for unauthenticated requests */
141 145 int ex_seccnt; /* count of security modes */
142 146 struct secinfo *ex_secinfo; /* security mode info */
143 147 char *ex_index; /* index file for public filesystem */
144 148 char *ex_log_buffer; /* path to logging buffer file */
145 149 size_t ex_log_bufferlen; /* buffer file path len */
146 150 char *ex_tag; /* tag used to identify log config */
147 151 size_t ex_taglen; /* tag length */
148 152 };
149 153
150 154 #ifdef _SYSCALL32
151 155 struct exportdata32 {
152 156 int32_t ex_version; /* structure version */
153 157 caddr32_t ex_path; /* exported path */
154 158 int32_t ex_pathlen; /* path length */
155 159 int32_t ex_flags; /* flags */
156 160 uint32_t ex_anon; /* uid for unauthenticated requests */
157 161 int32_t ex_seccnt; /* count of security modes */
158 162 caddr32_t ex_secinfo; /* security mode info */
159 163 caddr32_t ex_index; /* index file for public filesystem */
160 164 caddr32_t ex_log_buffer; /* path to logging buffer file */
161 165 int32_t ex_log_bufferlen; /* buffer file path len */
162 166 caddr32_t ex_tag; /* tag used to identify log config */
163 167 int32_t ex_taglen; /* tag length */
164 168 };
165 169 #endif /* _SYSCALL32 */
166 170
167 171 /*
168 172 * exported vfs flags.
169 173 */
170 174
171 175 #define EX_NOSUID 0x01 /* exported with unsetable set[ug]ids */
172 176 #define EX_ACLOK 0x02 /* exported with maximal access if acl exists */
173 177 #define EX_PUBLIC 0x04 /* exported with public filehandle */
174 178 #define EX_NOSUB 0x08 /* no nfs_getfh or MCL below export point */
175 179 #define EX_INDEX 0x10 /* exported with index file specified */
176 180 #define EX_LOG 0x20 /* logging enabled */
177 181 #define EX_LOG_ALLOPS 0x40 /* logging of all RPC operations enabled */
178 182 /* by default only operations which affect */
179 183 /* transaction logging are enabled */
180 184 #define EX_PSEUDO 0x80 /* pseudo filesystem export */
181 185 #ifdef VOLATILE_FH_TEST
|
↓ open down ↓ |
131 lines elided |
↑ open up ↑ |
182 186 #define EX_VOLFH 0x100 /* XXX nfsv4 fh may expire anytime */
183 187 #define EX_VOLRNM 0x200 /* XXX nfsv4 fh expire at rename */
184 188 #define EX_VOLMIG 0x400 /* XXX nfsv4 fh expire at migration */
185 189 #define EX_NOEXPOPEN 0x800 /* XXX nfsv4 fh no expire with open */
186 190 #endif /* VOLATILE_FH_TEST */
187 191
188 192 #define EX_CHARMAP 0x1000 /* NFS may need a character set conversion */
189 193 #define EX_NOACLFAB 0x2000 /* If set, NFSv2 and v3 servers won't */
190 194 /* fabricate an aclent_t ACL on file systems */
191 195 /* that don't support aclent_t ACLs */
196 +#define EX_NOHIDE 0x4000 /* traversable from exported parent */
192 197
193 198 #ifdef _KERNEL
194 199
195 200 #define RPC_IDEMPOTENT 0x1 /* idempotent or not */
196 201 /*
197 202 * Be very careful about which NFS procedures get the RPC_ALLOWANON bit.
198 203 * Right now, if this bit is on, we ignore the results of per NFS request
199 204 * access control.
200 205 */
201 206 #define RPC_ALLOWANON 0x2 /* allow anonymous access */
202 207 #define RPC_MAPRESP 0x4 /* use mapped response buffer */
203 208 #define RPC_AVOIDWORK 0x8 /* do work avoidance for dups */
204 209 #define RPC_PUBLICFH_OK 0x10 /* allow use of public filehandle */
205 210
206 211 /*
207 212 * RPC_ALL is an or of all above bits to be used with "don't care"
208 213 * nfsv4 ops. The flags of an nfsv4 request is the bit-AND of the
209 214 * per-op flags.
210 215 */
211 216 #define RPC_ALL (RPC_IDEMPOTENT|RPC_ALLOWANON|RPC_AVOIDWORK|RPC_PUBLICFH_OK)
212 217
213 218
214 219 #ifdef VOLATILE_FH_TEST
215 220 struct ex_vol_rename {
216 221 nfs_fh4_fmt_t vrn_fh_fmt;
217 222 struct ex_vol_rename *vrn_next;
218 223 };
219 224 #endif /* VOLATILE_FH_TEST */
220 225
221 226 /*
222 227 * An auth cache client entry. This is the umbrella structure and contains all
223 228 * related auth_cache entries in the authc_tree AVL tree.
224 229 */
225 230 struct auth_cache_clnt {
226 231 avl_node_t authc_link;
227 232 struct netbuf authc_addr; /* address of the client */
228 233 krwlock_t authc_lock; /* protects authc_tree */
229 234 avl_tree_t authc_tree; /* auth_cache entries */
230 235 };
231 236
232 237 /*
233 238 * An auth cache entry can exist in 6 states.
234 239 *
235 240 * A NEW entry was recently allocated and added to the cache. It does not
236 241 * contain the valid auth state yet.
237 242 *
238 243 * A WAITING entry is one which is actively engaging the user land mountd code
239 244 * to authenticate or re-authenticate it. The auth state might not be valid
240 245 * yet. The other threads should wait on auth_cv until the retrieving thread
241 246 * finishes the retrieval and changes the auth cache entry to FRESH, or NEW (in
242 247 * a case this entry had no valid auth state yet).
243 248 *
244 249 * A REFRESHING entry is one which is actively engaging the user land mountd
245 250 * code to re-authenticate the cache entry. There is currently no other thread
246 251 * waiting for the results of the refresh.
247 252 *
248 253 * A FRESH entry is one which is valid (it is either newly retrieved or has
249 254 * been refreshed at least once).
250 255 *
251 256 * A STALE entry is one which has been detected to be too old. The transition
252 257 * from FRESH to STALE prevents multiple threads from submitting refresh
253 258 * requests.
254 259 *
255 260 * An INVALID entry is one which was either STALE or REFRESHING and was deleted
256 261 * out of the encapsulating exi. Since we can't delete it yet, we mark it as
257 262 * INVALID, which lets the refresh thread know not to work on it and free it
258 263 * instead.
259 264 *
260 265 * Note that the auth state of the entry is valid, even if the entry is STALE.
261 266 * Just as you can eat stale bread, you can consume a stale cache entry. The
262 267 * only time the contents change could be during the transition from REFRESHING
263 268 * or WAITING to FRESH.
264 269 *
265 270 * Valid state transitions:
266 271 *
267 272 * alloc
268 273 * |
269 274 * v
270 275 * +-----+
271 276 * +--->| NEW |------>free
272 277 * | +-----+
273 278 * | |
274 279 * | v
275 280 * | +---------+
276 281 * +<-| WAITING |
277 282 * ^ +---------+
278 283 * | |
279 284 * | v
280 285 * | +<--------------------------+<---------------+
281 286 * | | ^ |
282 287 * | v | |
283 288 * | +-------+ +-------+ +------------+ +---------+
284 289 * +---| FRESH |--->| STALE |--->| REFRESHING |--->| WAITING |
285 290 * +-------+ +-------+ +------------+ +---------+
286 291 * | | |
287 292 * | v |
288 293 * v +---------+ |
289 294 * free<-----| INVALID |<--------+
290 295 * +---------+
291 296 */
292 297 typedef enum auth_state {
293 298 NFS_AUTH_FRESH,
294 299 NFS_AUTH_STALE,
295 300 NFS_AUTH_REFRESHING,
296 301 NFS_AUTH_INVALID,
297 302 NFS_AUTH_NEW,
298 303 NFS_AUTH_WAITING
299 304 } auth_state_t;
300 305
301 306 /*
302 307 * An authorization cache entry
303 308 *
304 309 * Either the state in auth_state will protect the
305 310 * contents or auth_lock must be held.
306 311 */
307 312 struct auth_cache {
308 313 avl_node_t auth_link;
309 314 struct auth_cache_clnt *auth_clnt;
310 315 int auth_flavor;
311 316 cred_t *auth_clnt_cred;
312 317 uid_t auth_srv_uid;
313 318 gid_t auth_srv_gid;
314 319 uint_t auth_srv_ngids;
315 320 gid_t *auth_srv_gids;
316 321 int auth_access;
317 322 time_t auth_time;
318 323 time_t auth_freshness;
319 324 auth_state_t auth_state;
320 325 kmutex_t auth_lock;
321 326 kcondvar_t auth_cv;
322 327 };
323 328
324 329 #define AUTH_TABLESIZE 32
325 330
326 331 /*
327 332 * Structure containing log file meta-data.
328 333 */
329 334 struct log_file {
330 335 unsigned int lf_flags; /* flags (see below) */
331 336 int lf_writers; /* outstanding writers */
332 337 int lf_refcnt; /* references to this struct */
333 338 caddr_t lf_path; /* buffer file location */
334 339 vnode_t *lf_vp; /* vnode for the buffer file */
335 340 kmutex_t lf_lock;
336 341 kcondvar_t lf_cv_waiters;
337 342 };
338 343
339 344 /*
340 345 * log_file and log_buffer flags.
341 346 */
342 347 #define L_WAITING 0x01 /* flush of in-core data to stable */
343 348 /* storage in progress */
344 349 #define L_PRINTED 0x02 /* error message printed to console */
345 350 #define L_ERROR 0x04 /* error condition detected */
346 351
347 352 /*
348 353 * The logging buffer information.
349 354 * This structure may be shared by multiple exportinfo structures,
350 355 * if they share the same buffer file.
351 356 * This structure contains the basic information about the buffer, such
352 357 * as it's location in the filesystem.
353 358 *
354 359 * 'lb_lock' protects all the fields in this structure except for 'lb_path',
355 360 * and 'lb_next'.
356 361 * 'lb_path' is a write-once/read-many field which needs no locking, it is
357 362 * set before the structure is linked to any exportinfo structure.
358 363 * 'lb_next' is protected by the log_buffer_list_lock.
359 364 */
360 365 struct log_buffer {
361 366 unsigned int lb_flags; /* L_ONLIST set? */
362 367 int lb_refcnt; /* references to this struct */
363 368 unsigned int lb_rec_id; /* used to generate unique id */
364 369 caddr_t lb_path; /* buffer file pathname */
365 370 struct log_file *lb_logfile; /* points to log_file structure */
366 371 kmutex_t lb_lock;
367 372 struct log_buffer *lb_next;
368 373 kcondvar_t lb_cv_waiters;
369 374 caddr_t lb_records; /* linked list of records to write */
370 375 int lb_num_recs; /* # of records to write */
371 376 ssize_t lb_size_queued; /* number of bytes queued for write */
372 377 };
373 378
374 379 #define LOG_BUFFER_HOLD(lbp) { \
375 380 mutex_enter(&(lbp)->lb_lock); \
376 381 (lbp)->lb_refcnt++; \
377 382 mutex_exit(&(lbp)->lb_lock); \
378 383 }
379 384
380 385 #define LOG_BUFFER_RELE(lbp) { \
381 386 log_buffer_rele(lbp); \
382 387 }
383 388
384 389 /*
385 390 * Structure for character set conversion mapping based on client address.
386 391 */
387 392 struct charset_cache {
388 393 struct charset_cache *next;
389 394 kiconv_t inbound;
390 395 kiconv_t outbound;
391 396 struct sockaddr client_addr;
392 397 };
393 398
394 399 /* Forward declarations */
395 400 struct exportinfo;
396 401 struct exp_visible;
397 402 struct svc_req;
398 403
399 404 /*
400 405 * Treenodes are used to build tree representing every node which is part
401 406 * of nfs server pseudo namespace. They are connected with both exportinfo
402 407 * and exp_visible struct. They were introduced to avoid lookup of ".."
403 408 * in the underlying file system during unshare, which was failing if the
404 409 * file system was forcibly unmounted or if the directory was removed.
405 410 * One exp_visible_t can be shared via several treenode_t, i.e.
406 411 * different tree_vis can point to the same exp_visible_t.
407 412 * This will happen if some directory is on two different shared paths:
408 413 * E.g. after share /tmp/a/b1 and share /tmp/a/b2 there will be two treenodes
409 414 * corresponding to /tmp/a and both will have same value in tree_vis.
410 415 *
411 416 *
412 417 *
413 418 * NEW DATA STRUCT ORIGINAL DATA STRUCT
414 419 *
415 420 * ns_root +---+ +----------+
416 421 * | / | |PSEUDO EXP|-->+---+ +---+ +---+
417 422 * +---+--------- ----+----------+ | a |-->| k |-->| b |
418 423 * /\ +---+ +---+ +---+
419 424 * / \ . . .
420 425 * +---+...\......... ..................... . .
421 426 * *| a | \ +----------+ . .
422 427 * +---+-----\------- ----|REAL EXP a| . .
423 428 * / \ +----------+ . .
424 429 * / +===+... ............................. .
425 430 * / *| k | +----------+ .
426 431 * / +===+--- ----|REAL EXP k| .
427 432 * / +----------+ .
428 433 * +===+................ .....................................
429 434 * *| b | +----------+
430 435 * +===+---------------- ----|REAL EXP b|-->+---+
431 436 * \ +----------+ | d |
432 437 * +===+............. ...................+---+
433 438 * | d | +----------+
434 439 * +===+------------- ----|PSEUDO EXP|-->+---+ +---+
435 440 * / +----------+ | e |-->| g |
436 441 * +---+................. ...................+---+ +---+
437 442 * | e | .
438 443 * +---+ .
439 444 * \ .
440 445 * +---+.............. ............................
441 446 * *| g | +----------+
442 447 * +---+-------------- ----|REAL EXP g|
443 448 * +----------+
444 449 *
445 450 *
446 451 *
447 452 * +===+ +---+ +---+
448 453 * | b |..mountpoint | e |..directory/file *| a |..node is shared
449 454 * +===+ (VROOT) +---+ +---+
450 455 *
451 456 *
452 457 * Bi-directional interconnect:
453 458 * treenode_t::tree_exi --------- exportinfo_t::exi_tree
454 459 * One-way direction connection:
455 460 * treenode_t::tree_vis .........> exp_visible_t
456 461 */
457 462 /* Access to treenode_t is under protection of exported_lock RW_LOCK */
458 463 typedef struct treenode {
459 464 /* support for generic n-ary trees */
460 465 struct treenode *tree_parent;
461 466 struct treenode *tree_child_first;
462 467 struct treenode *tree_sibling; /* next sibling */
463 468 /* private, nfs specific part */
464 469 struct exportinfo *tree_exi;
465 470 struct exp_visible *tree_vis;
466 471 } treenode_t;
467 472
468 473 /*
|
↓ open down ↓ |
267 lines elided |
↑ open up ↑ |
469 474 * TREE_ROOT checks if the node corresponds to a filesystem root
470 475 * TREE_EXPORTED checks if the node is explicitly shared
471 476 */
472 477
473 478 #define TREE_ROOT(t) \
474 479 ((t)->tree_exi && (t)->tree_exi->exi_vp->v_flag & VROOT)
475 480
476 481 #define TREE_EXPORTED(t) \
477 482 ((t)->tree_exi && !PSEUDO((t)->tree_exi))
478 483
479 -/* Root of nfs pseudo namespace */
480 -extern treenode_t *ns_root;
481 -
482 484 #define EXPTABLESIZE 256
483 485
484 486 struct exp_hash {
485 487 struct exportinfo *prev; /* ptr to the previous exportinfo */
486 488 struct exportinfo *next; /* ptr to the next exportinfo */
487 489 struct exportinfo **bckt; /* backpointer to the hash bucket */
488 490 };
489 491
490 492 /*
491 493 * A node associated with an export entry on the
492 494 * list of exported filesystems.
493 495 *
494 496 * exi_count+exi_lock protects an individual exportinfo from being freed
495 497 * when in use.
496 498 *
497 499 * You must have the writer lock on exported_lock to add/delete an exportinfo
498 500 * structure to/from the list.
499 501 *
500 502 * exi_volatile_dev maps to VSW_VOLATILEDEV. It means that the
501 503 * underlying fs devno can change on each mount. When set, the server
502 504 * should not use va_fsid for a GETATTR(FATTR4_FSID) reply. It must
503 505 * use exi_fsid because it is guaranteed to be persistent. This isn't
504 506 * in any way related to NFS4 volatile filehandles.
505 507 *
506 508 * The exi_cache_lock protects the exi_cache AVL trees.
507 509 */
508 510 struct exportinfo {
509 511 struct exportdata exi_export;
510 512 fsid_t exi_fsid;
511 513 struct fid exi_fid;
512 514 struct exp_hash fid_hash;
513 515 struct exp_hash path_hash;
514 516 struct treenode *exi_tree;
515 517 fhandle_t exi_fh;
516 518 krwlock_t exi_cache_lock;
517 519 kmutex_t exi_lock;
518 520 uint_t exi_count;
519 521 vnode_t *exi_vp;
520 522 vnode_t *exi_dvp;
521 523 avl_tree_t *exi_cache[AUTH_TABLESIZE];
|
↓ open down ↓ |
30 lines elided |
↑ open up ↑ |
522 524 struct log_buffer *exi_logbuffer;
523 525 struct exp_visible *exi_visible;
524 526 struct charset_cache *exi_charset;
525 527 unsigned exi_volatile_dev:1;
526 528 unsigned exi_moved:1;
527 529 #ifdef VOLATILE_FH_TEST
528 530 uint32_t exi_volatile_id;
529 531 struct ex_vol_rename *exi_vol_rename;
530 532 kmutex_t exi_vol_rename_lock;
531 533 #endif /* VOLATILE_FH_TEST */
534 + int exi_id;
535 + avl_node_t exi_id_link;
536 + struct exp_kstats *exi_kstats;
537 + zoneid_t exi_zoneid;
532 538 };
533 539
534 540 typedef struct exportinfo exportinfo_t;
535 541 typedef struct exportdata exportdata_t;
536 542 typedef struct secinfo secinfo_t;
537 543
538 544 /*
539 545 * exp_visible is a visible list per filesystem. It is for filesystems
540 546 * that may need a limited view of its contents. A pseudo export and
541 547 * a real export at the mount point (VROOT) which has a subtree shared
542 548 * has a visible list.
543 549 *
544 550 * The exi_visible field is NULL for normal, non-pseudo filesystems
545 551 * which do not have any subtree exported. If the field is non-null,
546 552 * it points to a list of visible entries, identified by vis_fid and/or
547 553 * vis_ino. The presence of a "visible" list means that if this export
548 554 * can only have a limited view, it can only view the entries in the
549 555 * exp_visible list. The directories in the fid list comprise paths that
550 556 * lead to exported directories.
551 557 *
552 558 * The vis_count field records the number of paths in this filesystem
553 559 * that use this directory. The vis_exported field is non-zero if the
554 560 * entry is an exported directory (leaf node).
555 561 *
556 562 * exp_visible itself is not reference counted. Each exp_visible is
557 563 * referenced twice:
558 564 * 1) from treenode::tree_vis
559 565 * 2) linked from exportinfo::exi_visible
560 566 * The 'owner' of exp_visible is the exportinfo structure. exp_visible should
561 567 * be always freed only from exportinfo_t, never from treenode::tree_vis.
562 568 */
563 569
564 570 struct exp_visible {
565 571 vnode_t *vis_vp;
566 572 fid_t vis_fid;
567 573 u_longlong_t vis_ino;
568 574 int vis_count;
569 575 int vis_exported;
570 576 struct exp_visible *vis_next;
571 577 struct secinfo *vis_secinfo;
572 578 int vis_seccnt;
573 579 timespec_t vis_change;
574 580 };
575 581 typedef struct exp_visible exp_visible_t;
576 582
577 583 #define PSEUDO(exi) ((exi)->exi_export.ex_flags & EX_PSEUDO)
578 584 #define EXP_LINKED(exi) ((exi)->fid_hash.bckt != NULL)
579 585
580 586 #define EQFSID(fsidp1, fsidp2) \
581 587 (((fsidp1)->val[0] == (fsidp2)->val[0]) && \
582 588 ((fsidp1)->val[1] == (fsidp2)->val[1]))
583 589
584 590 #define EQFID(fidp1, fidp2) \
585 591 ((fidp1)->fid_len == (fidp2)->fid_len && \
586 592 bcmp((char *)(fidp1)->fid_data, (char *)(fidp2)->fid_data, \
587 593 (uint_t)(fidp1)->fid_len) == 0)
588 594
589 595 #define exportmatch(exi, fsid, fid) \
590 596 (EQFSID(&(exi)->exi_fsid, (fsid)) && EQFID(&(exi)->exi_fid, (fid)))
591 597
592 598 /*
593 599 * Returns true iff exported filesystem is read-only to the given host.
594 600 *
595 601 * Note: this macro should be as fast as possible since it's called
596 602 * on each NFS modification request.
597 603 */
598 604 #define rdonly(ro, vp) ((ro) || vn_is_readonly(vp))
599 605 #define rdonly4(req, cs) \
|
↓ open down ↓ |
58 lines elided |
↑ open up ↑ |
600 606 (vn_is_readonly((cs)->vp) || \
601 607 (nfsauth4_access((cs)->exi, (cs)->vp, (req), (cs)->basecr, NULL, \
602 608 NULL, NULL, NULL) & (NFSAUTH_RO | NFSAUTH_LIMITED)))
603 609
604 610 extern int nfsauth4_access(struct exportinfo *, vnode_t *,
605 611 struct svc_req *, cred_t *, uid_t *, gid_t *, uint_t *, gid_t **);
606 612 extern int nfsauth4_secinfo_access(struct exportinfo *,
607 613 struct svc_req *, int, int, cred_t *);
608 614 extern int nfsauth_cache_clnt_compar(const void *, const void *);
609 615 extern int nfs_fhbcmp(char *, char *, int);
610 -extern int nfs_exportinit(void);
616 +extern void nfs_exportinit(void);
611 617 extern void nfs_exportfini(void);
612 618 extern int chk_clnt_sec(struct exportinfo *, struct svc_req *);
613 619 extern int makefh(fhandle_t *, struct vnode *, struct exportinfo *);
614 620 extern int makefh_ol(fhandle_t *, struct exportinfo *, uint_t);
615 621 extern int makefh3(nfs_fh3 *, struct vnode *, struct exportinfo *);
616 622 extern int makefh3_ol(nfs_fh3 *, struct exportinfo *, uint_t);
617 623 extern vnode_t *nfs_fhtovp(fhandle_t *, struct exportinfo *);
618 624 extern vnode_t *nfs3_fhtovp(nfs_fh3 *, struct exportinfo *);
619 625 extern struct exportinfo *checkexport(fsid_t *, struct fid *);
620 626 extern struct exportinfo *checkexport4(fsid_t *, struct fid *, vnode_t *);
621 627 extern void exi_hold(struct exportinfo *);
622 -extern void exi_rele(struct exportinfo *);
628 +extern void exi_rele(struct exportinfo **);
623 629 extern struct exportinfo *nfs_vptoexi(vnode_t *, vnode_t *, cred_t *, int *,
624 630 int *, bool_t);
625 631 extern int nfs_check_vpexi(vnode_t *, vnode_t *, cred_t *,
626 632 struct exportinfo **);
627 -extern void export_link(struct exportinfo *);
628 -extern void export_unlink(struct exportinfo *);
629 633 extern vnode_t *untraverse(vnode_t *);
630 634 extern int vn_is_nfs_reparse(vnode_t *, cred_t *);
631 635 extern int client_is_downrev(struct svc_req *);
632 636 extern char *build_symlink(vnode_t *, cred_t *, size_t *);
633 637
638 +extern fhandle_t nullfh2; /* for comparing V2 filehandles */
639 +
640 +typedef struct nfs_export {
641 + /* Root of nfs pseudo namespace */
642 + treenode_t *ns_root;
643 +
644 + struct exportinfo *exptable_path_hash[PKP_HASH_SIZE];
645 + struct exportinfo *exptable[EXPTABLESIZE];
646 +
647 + /*
648 + * Read/Write lock that protects the exportinfo list. This lock
649 + * must be held when searching or modifiying the exportinfo list.
650 + */
651 + krwlock_t exported_lock;
652 +
653 + /* "public" and default (root) location for public filehandle */
654 + struct exportinfo *exi_public, *exi_root;
655 + /* For checking default public file handle */
656 + fid_t exi_rootfid;
657 + /* For comparing V2 filehandles */
658 + fhandle_t nullfh2;
659 +
660 + /* The change attribute value of the root of nfs pseudo namespace */
661 + timespec_t ns_root_change;
662 +} nfs_export_t;
663 +
634 664 /*
635 665 * Functions that handle the NFSv4 server namespace
636 666 */
637 667 extern exportinfo_t *vis2exi(treenode_t *);
638 668 extern int treeclimb_export(struct exportinfo *);
639 -extern void treeclimb_unexport(struct exportinfo *);
669 +extern void treeclimb_unexport(nfs_export_t *, struct exportinfo *);
640 670 extern int nfs_visible(struct exportinfo *, vnode_t *, int *);
641 671 extern int nfs_visible_inode(struct exportinfo *, ino64_t,
642 - struct exp_visible **);
672 + struct exp_visible **);
643 673 extern int has_visible(struct exportinfo *, vnode_t *);
644 674 extern void free_visible(struct exp_visible *);
645 675 extern int nfs_exported(struct exportinfo *, vnode_t *);
646 -extern struct exportinfo *pseudo_exportfs(vnode_t *, fid_t *,
647 - struct exp_visible *, struct exportdata *);
676 +extern struct exportinfo *pseudo_exportfs(nfs_export_t *, vnode_t *, fid_t *,
677 + struct exp_visible *, struct exportdata *);
648 678 extern int vop_fid_pseudo(vnode_t *, fid_t *);
649 679 extern int nfs4_vget_pseudo(struct exportinfo *, vnode_t **, fid_t *);
650 680 extern bool_t nfs_visible_change(struct exportinfo *, vnode_t *,
651 - timespec_t *);
652 -extern void tree_update_change(treenode_t *, timespec_t *);
681 + timespec_t *);
682 +extern void tree_update_change(nfs_export_t *, treenode_t *, timespec_t *);
683 +
653 684 /*
654 685 * Functions that handle the NFSv4 server namespace security flavors
655 686 * information.
656 687 */
657 688 extern void srv_secinfo_exp2pseu(struct exportdata *, struct exportdata *);
658 689 extern void srv_secinfo_list_free(struct secinfo *, int);
659 690
691 +extern nfs_export_t *nfs_get_export();
692 +extern void export_link(nfs_export_t *, struct exportinfo *);
693 +extern void export_unlink(nfs_export_t *, struct exportinfo *);
694 +
660 695 /*
661 - * "public" and default (root) location for public filehandle
696 + * exi_id support
662 697 */
663 -extern struct exportinfo *exi_public, *exi_root;
664 -extern fhandle_t nullfh2; /* for comparing V2 filehandles */
665 -extern krwlock_t exported_lock;
666 -extern struct exportinfo *exptable[];
698 +extern kmutex_t nfs_exi_id_lock;
699 +extern avl_tree_t exi_id_tree;
700 +extern int exi_id_get_next(void);
667 701
668 702 /*
669 703 * Two macros for identifying public filehandles.
670 704 * A v2 public filehandle is 32 zero bytes.
671 705 * A v3 public filehandle is zero length.
672 706 */
673 707 #define PUBLIC_FH2(fh) \
674 708 ((fh)->fh_fsid.val[1] == 0 && \
675 709 bcmp((fh), &nullfh2, sizeof (fhandle_t)) == 0)
676 710
677 711 #define PUBLIC_FH3(fh) \
678 712 ((fh)->fh3_length == 0)
679 713
680 714 extern int makefh4(nfs_fh4 *, struct vnode *, struct exportinfo *);
681 715 extern vnode_t *nfs4_fhtovp(nfs_fh4 *, struct exportinfo *, nfsstat4 *);
682 716
683 717 #endif /* _KERNEL */
684 718
685 719 #ifdef __cplusplus
686 720 }
687 721 #endif
688 722
689 723 #endif /* _NFS_EXPORT_H */
|
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX