Print this page
Caution with use after exi_rele()
Ooops exi_zoneid isn't a variable again yet
Be far more judicious in the use of curzone-using macros.

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 ↓ 158 lines elided ↑ open up ↑
 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          /* Caller will set exi_zone... */
      169 +        /* XXX KEBE SAYS Uncomment me or fix in the caller */
      170 +        /* exi->exi_zoneid = ne->ne_globals->nfs_zoneid; */
 169  171          exi->exi_volatile_dev = (vfssw[vp->v_vfsp->vfs_fstype].vsw_flag &
 170  172              VSW_VOLATILEDEV) ? 1 : 0;
 171  173          mutex_init(&exi->exi_lock, NULL, MUTEX_DEFAULT, NULL);
 172      -        exi->exi_zoneid = ne->ne_globals->nfs_zoneid;
 173  174  
 174  175          /*
 175  176           * Build up the template fhandle
 176  177           */
 177  178          exi->exi_fh.fh_fsid = fsid;
 178  179          ASSERT(exi->exi_fid.fid_len <= sizeof (exi->exi_fh.fh_xdata));
 179  180          exi->exi_fh.fh_xlen = exi->exi_fid.fid_len;
 180  181          bcopy(exi->exi_fid.fid_data, exi->exi_fh.fh_xdata,
 181  182              exi->exi_fid.fid_len);
 182  183          exi->exi_fh.fh_len = sizeof (exi->exi_fh.fh_data);
↓ open down ↓ 470 lines elided ↑ open up ↑
 653  654          exportdir = 1;
 654  655  
 655  656          for (;;) {
 656  657  
 657  658                  bzero(&fid, sizeof (fid));
 658  659                  fid.fid_len = MAXFIDSZ;
 659  660                  error = vop_fid_pseudo(vp, &fid);
 660  661                  if (error)
 661  662                          break;
 662  663  
      664 +                ASSERT3U(exip->exi_zoneid, ==, curzone->zone_id);
 663  665                  /*
 664  666                   * The root of the file system, or the zone's root for
 665  667                   * in-zone NFS service needs special handling
 666  668                   */
 667  669                  if (vp->v_flag & VROOT || VN_IS_CURZONEROOT(vp)) {
 668  670                          if (!exportdir) {
 669  671                                  struct exportinfo *exi;
 670  672  
 671  673                                  /*
 672  674                                   * Check if this VROOT dir is already exported.
↓ open down ↓ 16 lines elided ↑ open up ↑
 689  691                                  }
 690  692  
 691  693                                  /*
 692  694                                   * Found the root directory of a filesystem
 693  695                                   * that isn't exported.  Need to export
 694  696                                   * this as a pseudo export so that an NFS v4
 695  697                                   * client can do lookups in it.
 696  698                                   */
 697  699                                  new_exi = pseudo_exportfs(ne, vp, &fid,
 698  700                                      vis_head, NULL);
      701 +                                /* XXX KEBE SAYS NUKE ME */
 699  702                                  new_exi->exi_zone = exip->exi_zone;
 700  703                                  vis_head = NULL;
 701  704                          }
 702  705  
 703  706                          if (VN_IS_CURZONEROOT(vp)) {
 704  707                                  /* at system root */
 705  708                                  /*
 706  709                                   * If sharing "/", new_exi is shared exportinfo
 707  710                                   * (exip). Otherwise, new_exi is exportinfo
 708  711                                   * created by pseudo_exportfs() above.
↓ open down ↓ 164 lines elided ↑ open up ↑
 873  876                          break;
 874  877  
 875  878                  /* Release pseudo export if it has no child */
 876  879                  if (TREE_ROOT(tnode) && !TREE_EXPORTED(tnode) &&
 877  880                      tnode->tree_child_first == NULL) {
 878  881                          mutex_enter(&nfs_exi_id_lock);
 879  882                          avl_remove(&exi_id_tree, tnode->tree_exi);
 880  883                          mutex_exit(&nfs_exi_id_lock);
 881  884                          export_unlink(ne, tnode->tree_exi);
 882  885                          exi_rele(tnode->tree_exi);
      886 +                        tnode->tree_exi = NULL;
 883  887                  }
 884  888  
 885  889                  /* Release visible in parent's exportinfo */
 886  890                  if (tnode->tree_vis != NULL)
 887  891                          less_visible(vis2exi(tnode), tnode->tree_vis);
 888  892  
 889  893                  /* Continue with parent */
 890  894                  old_nd = tnode;
 891  895                  tnode = tnode->tree_parent;
 892  896  
↓ open down ↓ 7 lines elided ↑ open up ↑
 900  904  
 901  905          /* Update the change timestamp */
 902  906          if (connect_point != NULL)
 903  907                  tree_update_change(ne, connect_point, NULL);
 904  908  }
 905  909  
 906  910  /*
 907  911   * Traverse backward across mountpoint from the
 908  912   * root vnode of a filesystem to its mounted-on
 909  913   * vnode.
      914 + *
      915 + * Callers to this function have confirmed the use of curzone is safe here.
 910  916   */
 911  917  vnode_t *
 912  918  untraverse(vnode_t *vp)
 913  919  {
 914  920          vnode_t *tvp, *nextvp;
 915  921  
 916  922          tvp = vp;
 917  923          for (;;) {
 918  924                  if (!(tvp->v_flag & VROOT) && !VN_IS_CURZONEROOT(tvp))
 919  925                          break;
↓ open down ↓ 36 lines elided ↑ open up ↑
 956  962   *              |
 957  963   *              c  #share /a/b/c
 958  964   *              |
 959  965   *              d
 960  966   *
 961  967   * where c is in the same filesystem as a.
 962  968   * So, get_root_export(*exportinfo_for_c) returns exportinfo_for_a
 963  969   *
 964  970   * If d is shared, then c will be put into a's visible list.
 965  971   * Note: visible list is per filesystem and is attached to the
 966      - * VROOT exportinfo.
      972 + * VROOT exportinfo.  Returned exi does NOT have a new hold.
 967  973   */
 968  974  struct exportinfo *
 969  975  get_root_export(struct exportinfo *exip)
 970  976  {
 971  977          treenode_t *tnode = exip->exi_tree;
 972  978          exportinfo_t *exi = NULL;
 973  979  
 974  980          while (tnode) {
 975  981                  if (TREE_ROOT(tnode)) {
 976  982                          exi = tnode->tree_exi;
↓ open down ↓ 310 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX