Print this page
Hyperaggressive asserts pt 2/N
Be far more judicious in the use of curzone-using macros.
(Merge and extra asserts by danmcd.)
dss_paths[] entries need cleanup too
Try to remove assumption that zone's root vnode is marked VROOT
        
*** 816,827 ****
          sip->dss_npaths = dss_npaths;
          sip->dss_paths = kmem_alloc(dss_npaths *
              sizeof (rfs4_dss_path_t *), KM_SLEEP);
  
          for (i = 0; i < dss_npaths; i++) {
!                 /* CSTYLED */
!                 sip->dss_paths[i] = rfs4_dss_newpath(nsrv4, sip, dss_paths[i], i);
          }
  
          mutex_enter(&nsrv4->servinst_lock);
          if (nsrv4->nfs4_cur_servinst != NULL) {
                  /* add to linked list */
--- 816,827 ----
          sip->dss_npaths = dss_npaths;
          sip->dss_paths = kmem_alloc(dss_npaths *
              sizeof (rfs4_dss_path_t *), KM_SLEEP);
  
          for (i = 0; i < dss_npaths; i++) {
!                 sip->dss_paths[i] =
!                     rfs4_dss_newpath(nsrv4, sip, dss_paths[i], i);
          }
  
          mutex_enter(&nsrv4->servinst_lock);
          if (nsrv4->nfs4_cur_servinst != NULL) {
                  /* add to linked list */
*** 855,867 ****
          for (sip = current; sip != NULL; sip = prev) {
                  prev = sip->prev;
                  rw_destroy(&sip->rwlock);
                  if (sip->oldstate)
                          kmem_free(sip->oldstate, sizeof (rfs4_oldstate_t));
!                 if (sip->dss_paths)
                          kmem_free(sip->dss_paths,
                              sip->dss_npaths * sizeof (rfs4_dss_path_t *));
                  kmem_free(sip, sizeof (rfs4_servinst_t));
  #ifdef DEBUG
                  n++;
  #endif
          }
--- 855,883 ----
          for (sip = current; sip != NULL; sip = prev) {
                  prev = sip->prev;
                  rw_destroy(&sip->rwlock);
                  if (sip->oldstate)
                          kmem_free(sip->oldstate, sizeof (rfs4_oldstate_t));
!                 if (sip->dss_paths) {
!                         int i = sip->dss_npaths;
! 
!                         while (i > 0) {
!                                 i--;
!                                 if (sip->dss_paths[i] != NULL) {
!                                         char *path = sip->dss_paths[i]->path;
! 
!                                         if (path != NULL) {
!                                                 kmem_free(path,
!                                                     strlen(path) + 1);
!                                         }
!                                         kmem_free(sip->dss_paths[i],
!                                             sizeof (rfs4_dss_path_t));
!                                 }
!                         }
                          kmem_free(sip->dss_paths,
                              sip->dss_npaths * sizeof (rfs4_dss_path_t *));
+                 }
                  kmem_free(sip, sizeof (rfs4_servinst_t));
  #ifdef DEBUG
                  n++;
  #endif
          }
*** 935,945 ****
  static nfsstat4
  do_rfs4_op_secinfo(struct compound_state *cs, char *nm, SECINFO4res *resp)
  {
          int error, different_export = 0;
          vnode_t *dvp, *vp;
!         struct exportinfo *exi = NULL;
          fid_t fid;
          uint_t count, i;
          secinfo4 *resok_val;
          struct secinfo *secp;
          seconfig_t *si;
--- 951,961 ----
  static nfsstat4
  do_rfs4_op_secinfo(struct compound_state *cs, char *nm, SECINFO4res *resp)
  {
          int error, different_export = 0;
          vnode_t *dvp, *vp;
!         struct exportinfo *exi;
          fid_t fid;
          uint_t count, i;
          secinfo4 *resok_val;
          struct secinfo *secp;
          seconfig_t *si;
*** 946,969 ****
          bool_t did_traverse = FALSE;
          int dotdot, walk;
          nfs_export_t *ne = nfs_get_export();
  
          dvp = cs->vp;
          dotdot = (nm[0] == '.' && nm[1] == '.' && nm[2] == '\0');
  
          /*
           * If dotdotting, then need to check whether it's above the
           * root of a filesystem, or above an export point.
           */
          if (dotdot) {
! 
                  /*
                   * If dotdotting at the root of a filesystem, then
                   * need to traverse back to the mounted-on filesystem
                   * and do the dotdot lookup there.
                   */
!                 if (cs->vp->v_flag & VROOT) {
  
                          /*
                           * If at the system root, then can
                           * go up no further.
                           */
--- 962,987 ----
          bool_t did_traverse = FALSE;
          int dotdot, walk;
          nfs_export_t *ne = nfs_get_export();
  
          dvp = cs->vp;
+         exi = cs->exi;
+         ASSERT(exi != NULL);
          dotdot = (nm[0] == '.' && nm[1] == '.' && nm[2] == '\0');
  
          /*
           * If dotdotting, then need to check whether it's above the
           * root of a filesystem, or above an export point.
           */
          if (dotdot) {
!                 ASSERT3U(exi->exi_zoneid, ==, curzone->zone_id);
                  /*
                   * If dotdotting at the root of a filesystem, then
                   * need to traverse back to the mounted-on filesystem
                   * and do the dotdot lookup there.
                   */
!                 if ((dvp->v_flag & VROOT) || VN_IS_CURZONEROOT(dvp)) {
  
                          /*
                           * If at the system root, then can
                           * go up no further.
                           */
*** 971,981 ****
                                  return (puterrno4(ENOENT));
  
                          /*
                           * Traverse back to the mounted-on filesystem
                           */
!                         dvp = untraverse(cs->vp);
  
                          /*
                           * Set the different_export flag so we remember
                           * to pick up a new exportinfo entry for
                           * this new filesystem.
--- 989,999 ----
                                  return (puterrno4(ENOENT));
  
                          /*
                           * Traverse back to the mounted-on filesystem
                           */
!                         dvp = untraverse(dvp);
  
                          /*
                           * Set the different_export flag so we remember
                           * to pick up a new exportinfo entry for
                           * this new filesystem.
*** 985,995 ****
  
                          /*
                           * If dotdotting above an export point then set
                           * the different_export to get new export info.
                           */
!                         different_export = nfs_exported(cs->exi, cs->vp);
                  }
          }
  
          /*
           * Get the vnode for the component "nm".
--- 1003,1013 ----
  
                          /*
                           * If dotdotting above an export point then set
                           * the different_export to get new export info.
                           */
!                         different_export = nfs_exported(exi, dvp);
                  }
          }
  
          /*
           * Get the vnode for the component "nm".
*** 1004,1016 ****
           * used in the request is valid but not an explicitly shared flavor,
           * or the access bit indicates that this is a limited access,
           * check whether this vnode is visible.
           */
          if (!different_export &&
!             (PSEUDO(cs->exi) || ! is_exported_sec(cs->nfsflavor, cs->exi) ||
              cs->access & CS_ACCESS_LIMITED)) {
!                 if (! nfs_visible(cs->exi, vp, &different_export)) {
                          VN_RELE(vp);
                          return (puterrno4(ENOENT));
                  }
          }
  
--- 1022,1034 ----
           * used in the request is valid but not an explicitly shared flavor,
           * or the access bit indicates that this is a limited access,
           * check whether this vnode is visible.
           */
          if (!different_export &&
!             (PSEUDO(exi) || !is_exported_sec(cs->nfsflavor, exi) ||
              cs->access & CS_ACCESS_LIMITED)) {
!                 if (! nfs_visible(exi, vp, &different_export)) {
                          VN_RELE(vp);
                          return (puterrno4(ENOENT));
                  }
          }
  
*** 1048,1057 ****
--- 1066,1076 ----
                  if (error) {
                          VN_RELE(vp);
                          return (puterrno4(error));
                  }
  
+                 /* We'll need to reassign "exi". */
                  if (dotdot)
                          exi = nfs_vptoexi(NULL, vp, cs->cr, &walk, NULL, TRUE);
                  else
                          exi = checkexport4(&vp->v_vfsp->vfs_fsid, &fid, vp);
  
*** 1068,1079 ****
                          } else {
                                  VN_RELE(vp);
                                  return (puterrno4(EACCES));
                          }
                  }
-         } else {
-                 exi = cs->exi;
          }
          ASSERT(exi != NULL);
  
  
          /*
--- 1087,1096 ----
*** 2700,2716 ****
           * If dotdotting, then need to check whether it's
           * above the root of a filesystem, or above an
           * export point.
           */
          if (dotdot) {
! 
                  /*
                   * If dotdotting at the root of a filesystem, then
                   * need to traverse back to the mounted-on filesystem
                   * and do the dotdot lookup there.
                   */
!                 if (cs->vp->v_flag & VROOT) {
  
                          /*
                           * If at the system root, then can
                           * go up no further.
                           */
--- 2717,2734 ----
           * If dotdotting, then need to check whether it's
           * above the root of a filesystem, or above an
           * export point.
           */
          if (dotdot) {
!                 ASSERT(cs->exi != NULL);
!                 ASSERT3U(cs->exi->exi_zoneid, ==, curzone->zone_id);
                  /*
                   * If dotdotting at the root of a filesystem, then
                   * need to traverse back to the mounted-on filesystem
                   * and do the dotdot lookup there.
                   */
!                 if ((cs->vp->v_flag & VROOT) || VN_IS_CURZONEROOT(cs->vp)) {
  
                          /*
                           * If at the system root, then can
                           * go up no further.
                           */