Print this page
Fix NFS design problems re. multiple zone keys
Make NFS server zone-specific data all have the same lifetime
Fix rfs4_clean_state_exi
Fix exi_cache_reclaim
Fix mistakes in zone keys work
More fixes re. exi_zoneid and exi_tree
(danmcd -> Keep some ASSERT()s around for readability.)
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/fs/nfs/nfs4_srv_ns.c
+++ new/usr/src/uts/common/fs/nfs/nfs4_srv_ns.c
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 *
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 23 * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
24 24 */
25 25
26 26 /*
27 27 * Copyright 2018 Nexenta Systems, Inc.
28 28 * Copyright (c) 2015, Joyent, Inc.
29 29 */
30 30
31 31 #include <sys/systm.h>
32 32
33 33 #include <nfs/nfs.h>
34 34 #include <nfs/export.h>
35 35 #include <sys/cmn_err.h>
36 36 #include <sys/avl.h>
37 37
38 38 #define PSEUDOFS_SUFFIX " (pseudo)"
39 39
40 40 /*
41 41 * A version of VOP_FID that deals with a remote VOP_FID for nfs.
42 42 * If vp is an nfs node, nfs4_fid() returns EREMOTE, nfs3_fid() and nfs_fid()
43 43 * returns the filehandle of vp as its fid. When nfs uses fid to set the
44 44 * exportinfo filehandle template, a remote nfs filehandle would be too big for
45 45 * the fid of the exported directory. This routine remaps the value of the
46 46 * attribute va_nodeid of vp to be the fid of vp, so that the fid can fit.
47 47 *
48 48 * We need this fid mainly for setting up NFSv4 server namespace where an
49 49 * nfs filesystem is also part of it. Thus, need to be able to setup a pseudo
50 50 * exportinfo for an nfs node.
51 51 *
52 52 * e.g. mount a filesystem on top of a nfs dir, and then share the new mount
53 53 * (like exporting a local disk from a "diskless" client)
54 54 */
55 55 int
56 56 vop_fid_pseudo(vnode_t *vp, fid_t *fidp)
57 57 {
58 58 struct vattr va;
59 59 int error;
60 60
61 61 error = VOP_FID(vp, fidp, NULL);
62 62
63 63 /*
64 64 * XXX nfs4_fid() does nothing and returns EREMOTE.
65 65 * XXX nfs3_fid()/nfs_fid() returns nfs filehandle as its fid
66 66 * which has a bigger length than local fid.
67 67 * NFS_FH4MAXDATA is the size of
68 68 * fhandle4_t.fh_xdata[NFS_FH4MAXDATA].
69 69 *
70 70 * Note: nfs[2,3,4]_fid() only gets called for diskless clients.
71 71 */
72 72 if (error == EREMOTE ||
73 73 (error == 0 && fidp->fid_len > NFS_FH4MAXDATA)) {
74 74
75 75 va.va_mask = AT_NODEID;
76 76 error = VOP_GETATTR(vp, &va, 0, CRED(), NULL);
77 77 if (error)
78 78 return (error);
79 79
80 80 fidp->fid_len = sizeof (va.va_nodeid);
81 81 bcopy(&va.va_nodeid, fidp->fid_data, fidp->fid_len);
82 82 return (0);
83 83 }
84 84
85 85 return (error);
86 86 }
87 87
88 88 /*
89 89 * Get an nfsv4 vnode of the given fid from the visible list of an
90 90 * nfs filesystem or get the exi_vp if it is the root node.
91 91 */
92 92 int
93 93 nfs4_vget_pseudo(struct exportinfo *exi, vnode_t **vpp, fid_t *fidp)
94 94 {
95 95 fid_t exp_fid;
96 96 struct exp_visible *visp;
97 97 int error;
98 98
99 99 /* check if the given fid is in the visible list */
100 100
101 101 for (visp = exi->exi_visible; visp; visp = visp->vis_next) {
102 102 if (EQFID(fidp, &visp->vis_fid)) {
103 103 VN_HOLD(visp->vis_vp);
104 104 *vpp = visp->vis_vp;
105 105 return (0);
106 106 }
107 107 }
108 108
109 109 /* check if the given fid is the same as the exported node */
110 110
111 111 bzero(&exp_fid, sizeof (exp_fid));
112 112 exp_fid.fid_len = MAXFIDSZ;
113 113 error = vop_fid_pseudo(exi->exi_vp, &exp_fid);
114 114 if (error)
115 115 return (error);
116 116
117 117 if (EQFID(fidp, &exp_fid)) {
118 118 VN_HOLD(exi->exi_vp);
119 119 *vpp = exi->exi_vp;
120 120 return (0);
121 121 }
122 122
123 123 return (ENOENT);
124 124 }
125 125
126 126 /*
127 127 * Create a pseudo export entry
128 128 *
129 129 * This is an export entry that's created as the
130 130 * side-effect of a "real" export. As a part of
131 131 * a real export, the pathname to the export is
132 132 * checked to see if all the directory components
133 133 * are accessible via an NFSv4 client, i.e. are
134 134 * exported. If treeclimb_export() finds an unexported
135 135 * mountpoint along the path, then it calls this
136 136 * function to export it.
137 137 *
138 138 * This pseudo export differs from a real export in that
139 139 * it only allows read-only access. A "visible" list of
140 140 * directories is added to filter lookup and readdir results
141 141 * to only contain dirnames which lead to descendant shares.
142 142 *
143 143 * A visible list has a per-file-system scope. Any exportinfo
144 144 * struct (real or pseudo) can have a visible list as long as
145 145 * a) its export root is VROOT, or is the zone's root for in-zone NFS service
146 146 * b) a descendant of the export root is shared
147 147 */
148 148 struct exportinfo *
149 149 pseudo_exportfs(nfs_export_t *ne, vnode_t *vp, fid_t *fid,
150 150 struct exp_visible *vis_head, struct exportdata *exdata)
151 151 {
152 152 struct exportinfo *exi;
153 153 struct exportdata *kex;
154 154 fsid_t fsid;
155 155 int vpathlen;
156 156 int i;
157 157
158 158 ASSERT(RW_WRITE_HELD(&ne->exported_lock));
159 159
160 160 fsid = vp->v_vfsp->vfs_fsid;
161 161 exi = kmem_zalloc(sizeof (*exi), KM_SLEEP);
|
↓ open down ↓ |
161 lines elided |
↑ open up ↑ |
162 162 exi->exi_fsid = fsid;
163 163 exi->exi_fid = *fid;
164 164 exi->exi_vp = vp;
165 165 VN_HOLD(exi->exi_vp);
166 166 exi->exi_visible = vis_head;
167 167 exi->exi_count = 1;
168 168 /* Caller will set exi_zone... */
169 169 exi->exi_volatile_dev = (vfssw[vp->v_vfsp->vfs_fstype].vsw_flag &
170 170 VSW_VOLATILEDEV) ? 1 : 0;
171 171 mutex_init(&exi->exi_lock, NULL, MUTEX_DEFAULT, NULL);
172 + exi->exi_zoneid = ne->ne_globals->nfs_zoneid;
172 173
173 174 /*
174 175 * Build up the template fhandle
175 176 */
176 177 exi->exi_fh.fh_fsid = fsid;
177 178 ASSERT(exi->exi_fid.fid_len <= sizeof (exi->exi_fh.fh_xdata));
178 179 exi->exi_fh.fh_xlen = exi->exi_fid.fid_len;
179 180 bcopy(exi->exi_fid.fid_data, exi->exi_fh.fh_xdata,
180 181 exi->exi_fid.fid_len);
181 182 exi->exi_fh.fh_len = sizeof (exi->exi_fh.fh_data);
182 183
183 184 kex = &exi->exi_export;
184 185 kex->ex_flags = EX_PSEUDO;
185 186
186 187 vpathlen = strlen(vp->v_path);
187 188 kex->ex_pathlen = vpathlen + strlen(PSEUDOFS_SUFFIX);
188 189 kex->ex_path = kmem_alloc(kex->ex_pathlen + 1, KM_SLEEP);
189 190
190 191 if (vpathlen)
191 192 (void) strncpy(kex->ex_path, vp->v_path, vpathlen);
192 193 (void) strcpy(kex->ex_path + vpathlen, PSEUDOFS_SUFFIX);
193 194
194 195 /* Transfer the secinfo data from exdata to this new pseudo node */
195 196 if (exdata)
196 197 srv_secinfo_exp2pseu(&exi->exi_export, exdata);
197 198
198 199 /*
199 200 * Initialize auth cache and auth cache lock
200 201 */
201 202 for (i = 0; i < AUTH_TABLESIZE; i++) {
202 203 exi->exi_cache[i] = kmem_alloc(sizeof (avl_tree_t), KM_SLEEP);
203 204 avl_create(exi->exi_cache[i], nfsauth_cache_clnt_compar,
204 205 sizeof (struct auth_cache_clnt),
205 206 offsetof(struct auth_cache_clnt, authc_link));
206 207 }
207 208 rw_init(&exi->exi_cache_lock, NULL, RW_DEFAULT, NULL);
208 209
209 210 /*
210 211 * Insert the new entry at the front of the export list
211 212 */
212 213 export_link(ne, exi);
213 214
214 215 /*
215 216 * Initialize exi_id and exi_kstats
216 217 */
217 218 mutex_enter(&nfs_exi_id_lock);
218 219 exi->exi_id = exi_id_get_next();
219 220 avl_add(&exi_id_tree, exi);
220 221 mutex_exit(&nfs_exi_id_lock);
221 222
222 223 return (exi);
223 224 }
224 225
225 226 /*
226 227 * Free a list of visible directories
227 228 */
228 229 void
229 230 free_visible(struct exp_visible *head)
230 231 {
231 232 struct exp_visible *visp, *next;
232 233
233 234 for (visp = head; visp; visp = next) {
234 235 if (visp->vis_vp != NULL)
235 236 VN_RELE(visp->vis_vp);
236 237
237 238 next = visp->vis_next;
238 239 srv_secinfo_list_free(visp->vis_secinfo, visp->vis_seccnt);
239 240 kmem_free(visp, sizeof (*visp));
240 241 }
241 242 }
242 243
243 244 /*
244 245 * Connects newchild (or subtree with newchild in head)
245 246 * to the parent node. We always add it to the beginning
246 247 * of sibling list.
247 248 */
248 249 static void
249 250 tree_add_child(treenode_t *parent, treenode_t *newchild)
250 251 {
251 252 newchild->tree_parent = parent;
252 253 newchild->tree_sibling = parent->tree_child_first;
253 254 parent->tree_child_first = newchild;
254 255 }
255 256
256 257 /* Look up among direct children a node with the exact tree_vis pointer */
257 258 static treenode_t *
258 259 tree_find_child_by_vis(treenode_t *t, exp_visible_t *vis)
259 260 {
260 261 for (t = t->tree_child_first; t; t = t->tree_sibling)
261 262 if (t->tree_vis == vis)
262 263 return (t);
263 264 return (NULL);
264 265 }
265 266
266 267 /*
267 268 * Add new node to the head of subtree pointed by 'n'. n can be NULL.
268 269 * Interconnects the new treenode with exp_visible and exportinfo
269 270 * if needed.
270 271 */
271 272 static treenode_t *
272 273 tree_prepend_node(treenode_t *n, exp_visible_t *v, exportinfo_t *e)
273 274 {
274 275 treenode_t *tnode = kmem_zalloc(sizeof (*tnode), KM_SLEEP);
275 276
276 277 if (n) {
277 278 tnode->tree_child_first = n;
278 279 n->tree_parent = tnode;
279 280 }
280 281 if (v) {
281 282 tnode->tree_vis = v;
282 283 }
283 284 if (e) {
284 285 tnode->tree_exi = e;
285 286 e->exi_tree = tnode;
286 287 }
287 288 return (tnode);
288 289 }
289 290
290 291 /*
291 292 * Removes node from the tree and frees the treenode struct.
292 293 * Does not free structures pointed by tree_exi and tree_vis,
293 294 * they should be already freed.
294 295 */
295 296 static void
296 297 tree_remove_node(nfs_export_t *ne, treenode_t *node)
297 298 {
298 299 treenode_t *parent = node->tree_parent;
299 300 treenode_t *s; /* s for sibling */
300 301
301 302 if (parent == NULL) {
302 303 kmem_free(node, sizeof (*node));
303 304 ne->ns_root = NULL;
304 305 return;
305 306 }
306 307 /* This node is first child */
307 308 if (parent->tree_child_first == node) {
308 309 parent->tree_child_first = node->tree_sibling;
309 310 /* This node is not first child */
310 311 } else {
311 312 s = parent->tree_child_first;
312 313 while (s->tree_sibling != node)
313 314 s = s->tree_sibling;
314 315 s->tree_sibling = s->tree_sibling->tree_sibling;
315 316 }
316 317 kmem_free(node, sizeof (*node));
317 318 }
318 319
319 320 /*
320 321 * When we export a new directory we need to add a new
321 322 * path segment through the pseudofs to reach the new
322 323 * directory. This new path is reflected in a list of
323 324 * directories added to the "visible" list.
324 325 *
325 326 * Here there are two lists of visible fids: one hanging off the
326 327 * pseudo exportinfo, and the one we want to add. It's possible
327 328 * that the two lists share a common path segment
328 329 * and have some common directories. We need to combine
329 330 * the lists so there's no duplicate entries. Where a common
330 331 * path component is found, the vis_count field is bumped.
331 332 *
332 333 * This example shows that the treenode chain (tree_head) and
333 334 * exp_visible chain (vis_head) can differ in length. The latter
334 335 * can be shorter. The outer loop must loop over the vis_head chain.
335 336 *
336 337 * share /x/a
337 338 * mount -F ufs /dev/dsk/... /x/y
338 339 * mkdir -p /x/y/a/b
339 340 * share /x/y/a/b
340 341 *
341 342 * When more_visible() is called during the second share,
342 343 * the existing namespace is following:
343 344 * exp_visible_t
344 345 * treenode_t exportinfo_t v0 v1
345 346 * ns_root+---+ +------------+ +---+ +---+
346 347 * t0| / |........| E0 pseudo |->| x |->| a |
347 348 * +---+ +------------+ +---+ +---+
348 349 * | / /
349 350 * +---+ / /
350 351 * t1| x |------------------------ /
351 352 * +---+ /
352 353 * | /
353 354 * +---+ /
354 355 * t2| a |-------------------------
355 356 * +---+........+------------+
356 357 * | E1 real |
357 358 * +------------+
358 359 *
359 360 * This is being added:
360 361 *
361 362 * tree_head vis_head
362 363 * +---+ +---+
363 364 * t3| x |->| x |v2
364 365 * +---+ +---+
365 366 * | |
366 367 * +---+ +---+ v4 v5
367 368 * t4| y |->| y |v3 +------------+ +---+ +---+
368 369 * +---+\ +---+ | E2 pseudo |->| a |->| b |
369 370 * | \....... >+------------+ +---+ +---+
370 371 * +---+ / /
371 372 * t5| a |--------------------------- /
372 373 * +---+ /
373 374 * | /
374 375 * +---+-------------------------------
375 376 * t6| b | +------------+
376 377 * +---+..........>| E3 real |
377 378 * +------------+
378 379 *
379 380 * more_visible() will:
380 381 * - kmem_free() t3 and v2
381 382 * - add t4, t5, t6 as a child of t1 (t4 will become sibling of t2)
382 383 * - add v3 to the end of E0->exi_visible
383 384 *
384 385 * Note that v4 and v5 were already processed in pseudo_exportfs() and
385 386 * added to E2. The outer loop of more_visible() will loop only over v2
386 387 * and v3. The inner loop of more_visible() always loops over v0 and v1.
387 388 *
388 389 * Illustration for this scenario:
389 390 *
390 391 * mkdir -p /v/a/b/c
391 392 * share /v/a/b/c
392 393 * mkdir /v/a/b/c1
393 394 * mkdir -p /v/a1
394 395 * mv /v/a/b /v/a1
395 396 * share /v/a1/b/c1
396 397 *
397 398 * EXISTING
398 399 * treenode
399 400 * namespace: +-----------+ visibles
400 401 * |exportinfo |-->v->a->b->c
401 402 * connect_point->+---+--->+-----------+
402 403 * | / |T0
403 404 * +---+
404 405 * | NEW treenode chain:
405 406 * child->+---+
406 407 * | v |T1 +---+<-curr
407 408 * +---+ N1| v |
408 409 * | +---+
409 410 * +---+ |
410 411 * | a |T2 +---+<-tree_head
411 412 * +---+ N2| a1|
412 413 * | +---+
413 414 * +---+ |
414 415 * | b |T3 +---+
415 416 * +---+ N3| b |
416 417 * | +---+
417 418 * +---+ |
418 419 * | c |T4 +---+
419 420 * +---+ N4| c1|
420 421 * +---+
421 422 *
422 423 * The picture above illustrates the position of following pointers after line
423 424 * 'child = tree_find_child_by_vis(connect_point, curr->tree_vis);'
424 425 * was executed for the first time in the outer 'for' loop:
425 426 *
426 427 * connect_point..parent treenode in the EXISTING namespace to which the 'curr'
427 428 * should be connected. If 'connect_point' already has a child
428 429 * with the same value of tree_vis as the curr->tree_vis is,
429 430 * the 'curr' will not be added, but kmem_free()d.
430 431 * child..........the result of tree_find_child_by_vis()
431 432 * curr...........currently processed treenode from the NEW treenode chain
432 433 * tree_head......current head of the NEW treenode chain, in this case it was
433 434 * already moved down to its child - preparation for another loop
434 435 *
435 436 * What will happen to NEW treenodes N1, N2, N3, N4 in more_visible() later:
436 437 *
437 438 * N1: is merged - i.e. N1 is kmem_free()d. T0 has a child T1 with the same
438 439 * tree_vis as N1
439 440 * N2: is added as a new child of T1
440 441 * Note: not just N2, but the whole chain N2->N3->N4 is added
441 442 * N3: not processed separately (it was added together with N2)
442 443 * Even that N3 and T3 have same tree_vis, they are NOT merged, but will
443 444 * become duplicates.
444 445 * N4: not processed separately
445 446 */
446 447 static void
447 448 more_visible(struct exportinfo *exi, treenode_t *tree_head)
448 449 {
449 450 struct exp_visible *vp1, *vp2, *vis_head, *tail, *next;
450 451 int found;
451 452 treenode_t *child, *curr, *connect_point;
452 453 nfs_export_t *ne = nfs_get_export();
453 454
454 455 vis_head = tree_head->tree_vis;
455 456 connect_point = exi->exi_tree;
456 457
457 458 /*
458 459 * If exportinfo doesn't already have a visible
459 460 * list just assign the entire supplied list.
460 461 */
461 462 if (exi->exi_visible == NULL) {
462 463 tree_add_child(connect_point, tree_head);
463 464 exi->exi_visible = vis_head;
464 465
465 466 /* Update the change timestamp */
466 467 tree_update_change(ne, connect_point, &vis_head->vis_change);
467 468
468 469 return;
469 470 }
470 471
471 472 /* The outer loop traverses the supplied list. */
472 473 for (vp1 = vis_head; vp1; vp1 = next) {
473 474 found = 0;
474 475 next = vp1->vis_next;
475 476
476 477 /* The inner loop searches the exportinfo visible list. */
477 478 for (vp2 = exi->exi_visible; vp2; vp2 = vp2->vis_next) {
478 479 tail = vp2;
479 480 if (EQFID(&vp1->vis_fid, &vp2->vis_fid)) {
480 481 found = 1;
481 482 vp2->vis_count++;
482 483 VN_RELE(vp1->vis_vp);
483 484 /* Transfer vis_exported from vp1 to vp2. */
484 485 if (vp1->vis_exported && !vp2->vis_exported)
485 486 vp2->vis_exported = 1;
486 487 kmem_free(vp1, sizeof (*vp1));
487 488 tree_head->tree_vis = vp2;
488 489 break;
489 490 }
490 491 }
491 492
492 493 /* If not found - add to the end of the list */
493 494 if (! found) {
494 495 tail->vis_next = vp1;
495 496 vp1->vis_next = NULL;
496 497 }
497 498
498 499 curr = tree_head;
499 500 tree_head = tree_head->tree_child_first;
500 501
501 502 if (! connect_point) /* No longer merging */
502 503 continue;
503 504 /*
504 505 * The inner loop could set curr->tree_vis to the EXISTING
505 506 * exp_visible vp2, so we can search among the children of
506 507 * connect_point for the curr->tree_vis. No need for EQFID.
507 508 */
508 509 child = tree_find_child_by_vis(connect_point, curr->tree_vis);
509 510
510 511 /*
511 512 * Merging cannot be done if a valid child->tree_exi would
512 513 * be overwritten by a new curr->tree_exi.
513 514 */
514 515 if (child &&
515 516 (child->tree_exi == NULL || curr->tree_exi == NULL)) {
516 517 if (curr->tree_exi) { /* Transfer the exportinfo */
517 518 child->tree_exi = curr->tree_exi;
518 519 child->tree_exi->exi_tree = child;
519 520 }
520 521 kmem_free(curr, sizeof (treenode_t));
521 522 connect_point = child;
522 523 } else { /* Branching */
523 524 tree_add_child(connect_point, curr);
524 525
525 526 /* Update the change timestamp */
526 527 tree_update_change(ne, connect_point,
527 528 &curr->tree_vis->vis_change);
528 529
529 530 connect_point = NULL;
530 531 }
531 532 }
532 533 }
533 534
534 535 /*
535 536 * Remove one visible entry from the pseudo exportfs.
536 537 *
537 538 * When we unexport a directory, we have to remove path
538 539 * components from the visible list in the pseudo exportfs
539 540 * entry. The supplied visible contains one fid of one path
540 541 * component. The visible list of the export
541 542 * is checked against provided visible, matching fid has its
542 543 * reference count decremented. If a reference count drops to
543 544 * zero, then it means no paths now use this directory, so its
544 545 * fid can be removed from the visible list.
545 546 *
546 547 * When the last path is removed, the visible list will be null.
547 548 */
548 549 static void
549 550 less_visible(struct exportinfo *exi, struct exp_visible *vp1)
550 551 {
551 552 struct exp_visible *vp2;
552 553 struct exp_visible *prev, *next;
553 554
554 555 for (vp2 = exi->exi_visible, prev = NULL; vp2; vp2 = next) {
555 556
556 557 next = vp2->vis_next;
557 558
558 559 if (vp1 == vp2) {
559 560 /*
560 561 * Decrement the ref count.
561 562 * Remove the entry if it's zero.
562 563 */
563 564 if (--vp2->vis_count <= 0) {
564 565 if (prev == NULL)
565 566 exi->exi_visible = next;
566 567 else
567 568 prev->vis_next = next;
568 569 VN_RELE(vp2->vis_vp);
569 570 srv_secinfo_list_free(vp2->vis_secinfo,
570 571 vp2->vis_seccnt);
571 572 kmem_free(vp2, sizeof (*vp1));
572 573 }
573 574 break;
574 575 }
575 576 prev = vp2;
576 577 }
577 578 }
578 579
579 580 /*
580 581 * This function checks the path to a new export to
581 582 * check whether all the pathname components are
582 583 * exported. It works by climbing the file tree one
583 584 * component at a time via "..", crossing mountpoints
584 585 * if necessary until an export entry is found, or the
585 586 * system root is reached.
586 587 *
587 588 * If an unexported mountpoint is found, then
588 589 * a new pseudo export is added and the pathname from
589 590 * the mountpoint down to the export is added to the
590 591 * visible list for the new pseudo export. If an existing
591 592 * pseudo export is found, then the pathname is added
592 593 * to its visible list.
593 594 *
594 595 * Note that there's some tests for exportdir.
595 596 * The exportinfo entry that's passed as a parameter
596 597 * is that of the real export and exportdir is set
597 598 * for this case.
598 599 *
599 600 * Here is an example of a possible setup:
600 601 *
601 602 * () - a new fs; fs mount point
602 603 * EXPORT - a real exported node
603 604 * PSEUDO - a pseudo node
604 605 * vis - visible list
605 606 * f# - security flavor#
606 607 * (f#) - security flavor# propagated from its descendents
607 608 * "" - covered vnode
608 609 *
609 610 *
610 611 * /
611 612 * |
612 613 * (a) PSEUDO (f1,f2)
613 614 * | vis: b,b,"c","n"
614 615 * |
615 616 * b
616 617 * ---------|------------------
617 618 * | |
618 619 * (c) EXPORT,f1(f2) (n) PSEUDO (f1,f2)
619 620 * | vis: "e","d" | vis: m,m,,p,q,"o"
620 621 * | |
621 622 * ------------------ -------------------
622 623 * | | | | |
623 624 * (d) (e) f m EXPORT,f1(f2) p
624 625 * EXPORT EXPORT | |
625 626 * f1 f2 | |
626 627 * | | |
627 628 * j (o) EXPORT,f2 q EXPORT f2
628 629 *
629 630 */
630 631 int
631 632 treeclimb_export(struct exportinfo *exip)
632 633 {
633 634 vnode_t *dvp, *vp;
634 635 fid_t fid;
635 636 int error;
636 637 int exportdir;
637 638 struct exportinfo *new_exi = exip;
638 639 struct exp_visible *visp;
639 640 struct exp_visible *vis_head = NULL;
640 641 struct vattr va;
641 642 treenode_t *tree_head = NULL;
642 643 timespec_t now;
643 644 nfs_export_t *ne = nfs_get_export();
644 645
645 646 ASSERT(RW_WRITE_HELD(&ne->exported_lock));
646 647 ASSERT3P(curzone, ==, exip->exi_zone);
647 648
648 649 gethrestime(&now);
649 650
650 651 vp = exip->exi_vp;
651 652 VN_HOLD(vp);
652 653 exportdir = 1;
653 654
654 655 for (;;) {
655 656
656 657 bzero(&fid, sizeof (fid));
657 658 fid.fid_len = MAXFIDSZ;
658 659 error = vop_fid_pseudo(vp, &fid);
659 660 if (error)
660 661 break;
661 662
662 663 /*
663 664 * The root of the file system, or the zone's root for
664 665 * in-zone NFS service needs special handling
665 666 */
666 667 if (vp->v_flag & VROOT || VN_IS_CURZONEROOT(vp)) {
667 668 if (!exportdir) {
668 669 struct exportinfo *exi;
669 670
670 671 /*
671 672 * Check if this VROOT dir is already exported.
672 673 * If so, then attach the pseudonodes. If not,
673 674 * then continue .. traversal until we hit a
674 675 * VROOT export (pseudo or real).
675 676 */
676 677 exi = checkexport4(&vp->v_vfsp->vfs_fsid, &fid,
677 678 vp);
678 679 if (exi != NULL) {
679 680 /*
680 681 * Found an export info
681 682 *
682 683 * Extend the list of visible
683 684 * directories whether it's a pseudo
684 685 * or a real export.
685 686 */
686 687 more_visible(exi, tree_head);
687 688 break; /* and climb no further */
688 689 }
689 690
690 691 /*
691 692 * Found the root directory of a filesystem
692 693 * that isn't exported. Need to export
693 694 * this as a pseudo export so that an NFS v4
694 695 * client can do lookups in it.
695 696 */
696 697 new_exi = pseudo_exportfs(ne, vp, &fid,
697 698 vis_head, NULL);
698 699 new_exi->exi_zone = exip->exi_zone;
699 700 vis_head = NULL;
700 701 }
701 702
702 703 if (VN_IS_CURZONEROOT(vp)) {
703 704 /* at system root */
704 705 /*
705 706 * If sharing "/", new_exi is shared exportinfo
706 707 * (exip). Otherwise, new_exi is exportinfo
707 708 * created by pseudo_exportfs() above.
708 709 */
709 710 ne->ns_root = tree_prepend_node(tree_head, NULL,
710 711 new_exi);
711 712
712 713 /* Update the change timestamp */
713 714 tree_update_change(ne, ne->ns_root, &now);
714 715
715 716 break;
716 717 }
717 718
718 719 /*
719 720 * Traverse across the mountpoint and continue the
720 721 * climb on the mounted-on filesystem.
721 722 */
722 723 vp = untraverse(vp);
723 724 exportdir = 0;
724 725 continue;
725 726 }
726 727
727 728 /*
728 729 * Do a getattr to obtain the nodeid (inode num)
729 730 * for this vnode.
730 731 */
731 732 va.va_mask = AT_NODEID;
732 733 error = VOP_GETATTR(vp, &va, 0, CRED(), NULL);
733 734 if (error)
734 735 break;
735 736
736 737 /*
737 738 * Add this directory fid to visible list
738 739 */
739 740 visp = kmem_alloc(sizeof (*visp), KM_SLEEP);
740 741 VN_HOLD(vp);
741 742 visp->vis_vp = vp;
742 743 visp->vis_fid = fid; /* structure copy */
743 744 visp->vis_ino = va.va_nodeid;
744 745 visp->vis_count = 1;
745 746 visp->vis_exported = exportdir;
746 747 visp->vis_secinfo = NULL;
747 748 visp->vis_seccnt = 0;
748 749 visp->vis_change = now; /* structure copy */
749 750 visp->vis_next = vis_head;
750 751 vis_head = visp;
751 752
752 753 /*
753 754 * Will set treenode's pointer to exportinfo to
754 755 * 1. shared exportinfo (exip) - if first visit here
755 756 * 2. freshly allocated pseudo export (if any)
756 757 * 3. null otherwise
757 758 */
758 759 tree_head = tree_prepend_node(tree_head, visp, new_exi);
759 760 new_exi = NULL;
760 761
761 762 /*
762 763 * Now, do a ".." to find parent dir of vp.
763 764 */
764 765 error = VOP_LOOKUP(vp, "..", &dvp, NULL, 0, NULL, CRED(),
765 766 NULL, NULL, NULL);
766 767
767 768 if (error == ENOTDIR && exportdir) {
768 769 dvp = exip->exi_dvp;
769 770 ASSERT(dvp != NULL);
770 771 VN_HOLD(dvp);
771 772 error = 0;
772 773 }
773 774
774 775 if (error)
775 776 break;
776 777
777 778 exportdir = 0;
778 779 VN_RELE(vp);
779 780 vp = dvp;
780 781 }
781 782
782 783 VN_RELE(vp);
783 784
784 785 /*
785 786 * We can have set error due to error in:
786 787 * 1. vop_fid_pseudo()
787 788 * 2. VOP_GETATTR()
788 789 * 3. VOP_LOOKUP()
789 790 * We must free pseudo exportinfos, visibles and treenodes.
790 791 * Visibles are referenced from treenode_t::tree_vis and
791 792 * exportinfo_t::exi_visible. To avoid double freeing, only
792 793 * exi_visible pointer is used, via exi_rele(), for the clean-up.
793 794 */
794 795 if (error) {
795 796 /* Free unconnected visibles, if there are any. */
796 797 if (vis_head)
797 798 free_visible(vis_head);
798 799
799 800 /* Connect unconnected exportinfo, if there is any. */
800 801 if (new_exi && new_exi != exip)
801 802 tree_head = tree_prepend_node(tree_head, NULL, new_exi);
802 803
803 804 while (tree_head) {
804 805 treenode_t *t2 = tree_head;
805 806 exportinfo_t *e = tree_head->tree_exi;
806 807 /* exip will be freed in exportfs() */
807 808 if (e && e != exip) {
808 809 mutex_enter(&nfs_exi_id_lock);
809 810 avl_remove(&exi_id_tree, e);
810 811 mutex_exit(&nfs_exi_id_lock);
811 812 export_unlink(ne, e);
812 813 exi_rele(e);
813 814 }
814 815 tree_head = tree_head->tree_child_first;
815 816 kmem_free(t2, sizeof (*t2));
816 817 }
817 818 }
818 819
819 820 return (error);
820 821 }
821 822
822 823 /*
823 824 * Walk up the tree and:
824 825 * 1. release pseudo exportinfo if it has no child
825 826 * 2. release visible in parent's exportinfo
826 827 * 3. delete non-exported leaf nodes from tree
827 828 *
828 829 * Deleting of nodes will start only if the unshared
829 830 * node was a leaf node.
830 831 * Deleting of nodes will finish when we reach a node which
831 832 * has children or is a real export, then we might still need
832 833 * to continue releasing visibles, until we reach VROOT or zone's root node.
|
↓ open down ↓ |
651 lines elided |
↑ open up ↑ |
833 834 */
834 835 void
835 836 treeclimb_unexport(nfs_export_t *ne, struct exportinfo *exip)
836 837 {
837 838 treenode_t *tnode, *old_nd;
838 839 treenode_t *connect_point = NULL;
839 840
840 841 ASSERT(RW_WRITE_HELD(&ne->exported_lock));
841 842 ASSERT(curzone == exip->exi_zone || curzone == global_zone);
842 843
844 + /*
845 + * exi_tree can be null for the zone root
846 + * which means we're already at the "top"
847 + * and there's nothing more to "climb".
848 + */
843 849 tnode = exip->exi_tree;
850 + if (tnode == NULL) {
851 + /* Should only happen for... */
852 + ASSERT(exip == ne->exi_root);
853 + return;
854 + }
855 +
844 856 /*
845 857 * The unshared exportinfo was unlinked in unexport().
846 858 * Zeroing tree_exi ensures that we will skip it.
847 859 */
848 860 tnode->tree_exi = NULL;
849 861
850 862 if (tnode->tree_vis != NULL) /* system root has tree_vis == NULL */
851 863 tnode->tree_vis->vis_exported = 0;
852 864
853 865 while (tnode != NULL) {
854 866
855 867 /*
856 868 * Stop at VROOT (or zone root) node which is exported or has
857 869 * child.
858 870 */
859 871 if (TREE_ROOT(tnode) &&
860 872 (TREE_EXPORTED(tnode) || tnode->tree_child_first != NULL))
861 873 break;
862 874
863 875 /* Release pseudo export if it has no child */
864 876 if (TREE_ROOT(tnode) && !TREE_EXPORTED(tnode) &&
865 877 tnode->tree_child_first == NULL) {
866 878 mutex_enter(&nfs_exi_id_lock);
867 879 avl_remove(&exi_id_tree, tnode->tree_exi);
868 880 mutex_exit(&nfs_exi_id_lock);
869 881 export_unlink(ne, tnode->tree_exi);
870 882 exi_rele(tnode->tree_exi);
871 883 }
872 884
873 885 /* Release visible in parent's exportinfo */
874 886 if (tnode->tree_vis != NULL)
875 887 less_visible(vis2exi(tnode), tnode->tree_vis);
876 888
877 889 /* Continue with parent */
878 890 old_nd = tnode;
879 891 tnode = tnode->tree_parent;
880 892
881 893 /* Remove itself, if this is a leaf and non-exported node */
882 894 if (old_nd->tree_child_first == NULL &&
883 895 !TREE_EXPORTED(old_nd)) {
884 896 tree_remove_node(ne, old_nd);
885 897 connect_point = tnode;
886 898 }
887 899 }
888 900
889 901 /* Update the change timestamp */
890 902 if (connect_point != NULL)
891 903 tree_update_change(ne, connect_point, NULL);
892 904 }
893 905
894 906 /*
895 907 * Traverse backward across mountpoint from the
896 908 * root vnode of a filesystem to its mounted-on
897 909 * vnode.
898 910 */
899 911 vnode_t *
900 912 untraverse(vnode_t *vp)
901 913 {
902 914 vnode_t *tvp, *nextvp;
903 915
904 916 tvp = vp;
905 917 for (;;) {
906 918 if (!(tvp->v_flag & VROOT) && !VN_IS_CURZONEROOT(tvp))
907 919 break;
908 920
909 921 /* lock vfs to prevent unmount of this vfs */
910 922 vfs_lock_wait(tvp->v_vfsp);
911 923
912 924 if ((nextvp = tvp->v_vfsp->vfs_vnodecovered) == NULL) {
913 925 vfs_unlock(tvp->v_vfsp);
914 926 break;
915 927 }
916 928
917 929 /*
918 930 * Hold nextvp to prevent unmount. After unlock vfs and
919 931 * rele tvp, any number of overlays could be unmounted.
920 932 * Putting a hold on vfs_vnodecovered will only allow
921 933 * tvp's vfs to be unmounted. Of course if caller placed
922 934 * extra hold on vp before calling untraverse, the following
923 935 * hold would not be needed. Since prev actions of caller
924 936 * are unknown, we need to hold here just to be safe.
925 937 */
926 938 VN_HOLD(nextvp);
927 939 vfs_unlock(tvp->v_vfsp);
928 940 VN_RELE(tvp);
929 941 tvp = nextvp;
930 942 }
931 943
932 944 return (tvp);
933 945 }
934 946
935 947 /*
936 948 * Given an exportinfo, climb up to find the exportinfo for the VROOT
937 949 * (or zone root) of the filesystem.
938 950 *
939 951 * e.g. /
940 952 * |
941 953 * a (VROOT) pseudo-exportinfo
942 954 * |
943 955 * b
944 956 * |
945 957 * c #share /a/b/c
946 958 * |
947 959 * d
948 960 *
949 961 * where c is in the same filesystem as a.
950 962 * So, get_root_export(*exportinfo_for_c) returns exportinfo_for_a
951 963 *
952 964 * If d is shared, then c will be put into a's visible list.
953 965 * Note: visible list is per filesystem and is attached to the
954 966 * VROOT exportinfo.
955 967 */
956 968 struct exportinfo *
957 969 get_root_export(struct exportinfo *exip)
958 970 {
959 971 treenode_t *tnode = exip->exi_tree;
960 972 exportinfo_t *exi = NULL;
961 973
962 974 while (tnode) {
963 975 if (TREE_ROOT(tnode)) {
964 976 exi = tnode->tree_exi;
965 977 break;
966 978 }
967 979 tnode = tnode->tree_parent;
968 980 }
969 981 ASSERT(exi);
970 982 return (exi);
971 983 }
972 984
973 985 /*
974 986 * Return true if the supplied vnode has a sub-directory exported.
975 987 */
976 988 int
977 989 has_visible(struct exportinfo *exi, vnode_t *vp)
978 990 {
979 991 struct exp_visible *visp;
980 992 fid_t fid;
981 993 bool_t vp_is_exported;
982 994
983 995 vp_is_exported = VN_CMP(vp, exi->exi_vp);
984 996
985 997 /*
986 998 * An exported root vnode has a sub-dir shared if it has a visible
987 999 * list. i.e. if it does not have a visible list, then there is no
988 1000 * node in this filesystem leads to any other shared node.
989 1001 */
990 1002 ASSERT3P(curzone, ==, exi->exi_zone);
991 1003 if (vp_is_exported &&
992 1004 ((vp->v_flag & VROOT) || VN_IS_CURZONEROOT(vp))) {
993 1005 return (exi->exi_visible ? 1 : 0);
994 1006 }
995 1007
996 1008 /*
997 1009 * Only the exportinfo of a fs root node may have a visible list.
998 1010 * Either it is a pseudo root node, or a real exported root node.
999 1011 */
1000 1012 exi = get_root_export(exi);
1001 1013
1002 1014 if (!exi->exi_visible)
1003 1015 return (0);
1004 1016
1005 1017 /* Get the fid of the vnode */
1006 1018 bzero(&fid, sizeof (fid));
1007 1019 fid.fid_len = MAXFIDSZ;
1008 1020 if (vop_fid_pseudo(vp, &fid) != 0) {
1009 1021 return (0);
1010 1022 }
1011 1023
1012 1024 /*
1013 1025 * See if vp is in the visible list of the root node exportinfo.
1014 1026 */
1015 1027 for (visp = exi->exi_visible; visp; visp = visp->vis_next) {
1016 1028 if (EQFID(&fid, &visp->vis_fid)) {
1017 1029 /*
1018 1030 * If vp is an exported non-root node with only 1 path
1019 1031 * count (for itself), it indicates no sub-dir shared
1020 1032 * using this vp as a path.
1021 1033 */
1022 1034 if (vp_is_exported && visp->vis_count < 2)
1023 1035 break;
1024 1036
1025 1037 return (1);
1026 1038 }
1027 1039 }
1028 1040
1029 1041 return (0);
1030 1042 }
1031 1043
1032 1044 /*
1033 1045 * Returns true if the supplied vnode is visible
1034 1046 * in this export. If vnode is visible, return
1035 1047 * vis_exported in expseudo.
1036 1048 */
1037 1049 int
1038 1050 nfs_visible(struct exportinfo *exi, vnode_t *vp, int *expseudo)
1039 1051 {
1040 1052 struct exp_visible *visp;
1041 1053 fid_t fid;
1042 1054
1043 1055 /*
1044 1056 * First check to see if vp is export root.
1045 1057 *
1046 1058 * A pseudo export root can never be exported
1047 1059 * (it would be a real export then); however,
1048 1060 * it is always visible. If a pseudo root object
1049 1061 * was exported by server admin, then the entire
1050 1062 * pseudo exportinfo (and all visible entries) would
1051 1063 * be destroyed. A pseudo exportinfo only exists
1052 1064 * to provide access to real (descendant) export(s).
1053 1065 *
1054 1066 * Previously, rootdir was special cased here; however,
1055 1067 * the export root special case handles the rootdir
1056 1068 * case also.
1057 1069 */
1058 1070 if (VN_CMP(vp, exi->exi_vp)) {
1059 1071 *expseudo = 0;
1060 1072 return (1);
1061 1073 }
1062 1074
1063 1075 /*
1064 1076 * Only a PSEUDO node has a visible list or an exported VROOT
1065 1077 * node may have a visible list.
1066 1078 */
1067 1079 if (!PSEUDO(exi))
1068 1080 exi = get_root_export(exi);
1069 1081
1070 1082 /* Get the fid of the vnode */
1071 1083
1072 1084 bzero(&fid, sizeof (fid));
1073 1085 fid.fid_len = MAXFIDSZ;
1074 1086 if (vop_fid_pseudo(vp, &fid) != 0) {
1075 1087 *expseudo = 0;
1076 1088 return (0);
1077 1089 }
1078 1090
1079 1091 /*
1080 1092 * We can't trust VN_CMP() above because of LOFS.
1081 1093 * Even though VOP_CMP will do the right thing for LOFS
1082 1094 * objects, VN_CMP will short circuit out early when the
1083 1095 * vnode ops ptrs are different. Just in case we're dealing
1084 1096 * with LOFS, compare exi_fid/fsid here.
1085 1097 *
1086 1098 * expseudo is not set because this is not an export
1087 1099 */
1088 1100 if (EQFID(&exi->exi_fid, &fid) &&
1089 1101 EQFSID(&exi->exi_fsid, &vp->v_vfsp->vfs_fsid)) {
1090 1102 *expseudo = 0;
1091 1103 return (1);
1092 1104 }
1093 1105
1094 1106
1095 1107 /* See if it matches any fid in the visible list */
1096 1108
1097 1109 for (visp = exi->exi_visible; visp; visp = visp->vis_next) {
1098 1110 if (EQFID(&fid, &visp->vis_fid)) {
1099 1111 *expseudo = visp->vis_exported;
1100 1112 return (1);
1101 1113 }
1102 1114 }
1103 1115
1104 1116 *expseudo = 0;
1105 1117
1106 1118 return (0);
1107 1119 }
1108 1120
1109 1121 /*
1110 1122 * Returns true if the supplied vnode is the
1111 1123 * directory of an export point.
1112 1124 */
1113 1125 int
1114 1126 nfs_exported(struct exportinfo *exi, vnode_t *vp)
1115 1127 {
1116 1128 struct exp_visible *visp;
1117 1129 fid_t fid;
1118 1130
1119 1131 /*
1120 1132 * First check to see if vp is the export root
1121 1133 * This check required for the case of lookup ..
1122 1134 * where .. is a V_ROOT vnode and a pseudo exportroot.
1123 1135 * Pseudo export root objects do not have an entry
1124 1136 * in the visible list even though every V_ROOT
1125 1137 * pseudonode is visible. It is safe to compare
1126 1138 * vp here because pseudo_exportfs put a hold on
1127 1139 * it when exi_vp was initialized.
1128 1140 *
1129 1141 * Note: VN_CMP() won't match for LOFS shares, but they're
1130 1142 * handled below w/EQFID/EQFSID.
1131 1143 */
1132 1144 if (VN_CMP(vp, exi->exi_vp))
1133 1145 return (1);
1134 1146
1135 1147 /* Get the fid of the vnode */
1136 1148
1137 1149 bzero(&fid, sizeof (fid));
1138 1150 fid.fid_len = MAXFIDSZ;
1139 1151 if (vop_fid_pseudo(vp, &fid) != 0)
1140 1152 return (0);
1141 1153
1142 1154 if (EQFID(&fid, &exi->exi_fid) &&
1143 1155 EQFSID(&vp->v_vfsp->vfs_fsid, &exi->exi_fsid)) {
1144 1156 return (1);
1145 1157 }
1146 1158
1147 1159 /* See if it matches any fid in the visible list */
1148 1160
1149 1161 for (visp = exi->exi_visible; visp; visp = visp->vis_next) {
1150 1162 if (EQFID(&fid, &visp->vis_fid))
1151 1163 return (visp->vis_exported);
1152 1164 }
1153 1165
1154 1166 return (0);
1155 1167 }
1156 1168
1157 1169 /*
1158 1170 * Returns true if the supplied inode is visible
1159 1171 * in this export. This function is used by
1160 1172 * readdir which uses inode numbers from the
1161 1173 * directory.
1162 1174 *
1163 1175 * NOTE: this code does not match inode number for ".",
1164 1176 * but it isn't required because NFS4 server rddir
1165 1177 * skips . and .. entries.
1166 1178 */
1167 1179 int
1168 1180 nfs_visible_inode(struct exportinfo *exi, ino64_t ino,
1169 1181 struct exp_visible **visp)
1170 1182 {
1171 1183 /*
1172 1184 * Only a PSEUDO node has a visible list or an exported VROOT
1173 1185 * node may have a visible list.
1174 1186 */
1175 1187 if (!PSEUDO(exi))
1176 1188 exi = get_root_export(exi);
1177 1189
1178 1190 for (*visp = exi->exi_visible; *visp != NULL; *visp = (*visp)->vis_next)
1179 1191 if ((u_longlong_t)ino == (*visp)->vis_ino) {
1180 1192 return (1);
1181 1193 }
1182 1194
1183 1195 return (0);
1184 1196 }
1185 1197
1186 1198 /*
1187 1199 * Get the change attribute from visible and returns TRUE.
1188 1200 * If the change value is not available returns FALSE.
1189 1201 */
1190 1202 bool_t
1191 1203 nfs_visible_change(struct exportinfo *exi, vnode_t *vp, timespec_t *change)
1192 1204 {
1193 1205 struct exp_visible *visp;
1194 1206 fid_t fid;
1195 1207 treenode_t *node;
1196 1208 nfs_export_t *ne = nfs_get_export();
1197 1209
1198 1210 /*
1199 1211 * First check to see if vp is export root.
1200 1212 */
1201 1213 if (VN_CMP(vp, exi->exi_vp))
1202 1214 goto exproot;
1203 1215
1204 1216 /*
1205 1217 * Only a PSEUDO node has a visible list or an exported VROOT
1206 1218 * node may have a visible list.
1207 1219 */
1208 1220 if (!PSEUDO(exi))
1209 1221 exi = get_root_export(exi);
1210 1222
1211 1223 /* Get the fid of the vnode */
1212 1224 bzero(&fid, sizeof (fid));
1213 1225 fid.fid_len = MAXFIDSZ;
1214 1226 if (vop_fid_pseudo(vp, &fid) != 0)
1215 1227 return (FALSE);
1216 1228
1217 1229 /*
1218 1230 * We can't trust VN_CMP() above because of LOFS.
1219 1231 * Even though VOP_CMP will do the right thing for LOFS
1220 1232 * objects, VN_CMP will short circuit out early when the
1221 1233 * vnode ops ptrs are different. Just in case we're dealing
1222 1234 * with LOFS, compare exi_fid/fsid here.
1223 1235 */
1224 1236 if (EQFID(&exi->exi_fid, &fid) &&
1225 1237 EQFSID(&exi->exi_fsid, &vp->v_vfsp->vfs_fsid))
1226 1238 goto exproot;
1227 1239
1228 1240 /* See if it matches any fid in the visible list */
1229 1241 for (visp = exi->exi_visible; visp; visp = visp->vis_next) {
1230 1242 if (EQFID(&fid, &visp->vis_fid)) {
1231 1243 *change = visp->vis_change;
1232 1244 return (TRUE);
1233 1245 }
1234 1246 }
1235 1247
1236 1248 return (FALSE);
1237 1249
1238 1250 exproot:
1239 1251 /* The VROOT export have its visible available through treenode */
1240 1252 node = exi->exi_tree;
1241 1253 if (node != ne->ns_root) {
1242 1254 ASSERT(node->tree_vis != NULL);
1243 1255 *change = node->tree_vis->vis_change;
1244 1256 } else {
1245 1257 ASSERT(node->tree_vis == NULL);
1246 1258 *change = ne->ns_root_change;
1247 1259 }
1248 1260 return (TRUE);
1249 1261 }
1250 1262
1251 1263 /*
1252 1264 * Update the change attribute value for a particular treenode. The change
1253 1265 * attribute value is stored in the visible attached to the treenode, or in the
1254 1266 * ns_root_change.
1255 1267 *
1256 1268 * If the change value is not supplied, the current time is used.
1257 1269 */
1258 1270 void
1259 1271 tree_update_change(nfs_export_t *ne, treenode_t *tnode, timespec_t *change)
1260 1272 {
1261 1273 timespec_t *vis_change;
1262 1274
1263 1275 ASSERT(tnode != NULL);
1264 1276 ASSERT((tnode != ne->ns_root && tnode->tree_vis != NULL) ||
1265 1277 (tnode == ne->ns_root && tnode->tree_vis == NULL));
1266 1278
1267 1279 vis_change = tnode == ne->ns_root ? &ne->ns_root_change
1268 1280 : &tnode->tree_vis->vis_change;
1269 1281
1270 1282 if (change != NULL)
1271 1283 *vis_change = *change;
1272 1284 else
1273 1285 gethrestime(vis_change);
1274 1286 }
|
↓ open down ↓ |
421 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX