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