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
↓ 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;
↓ 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));
↓ 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                                   */
↓ 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;
↓ 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);
↓ open down ↓ 274 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX