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