Print this page
Add VZONEROOT flag because not all zone roots have VROOT set.

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/zone.c
          +++ new/usr/src/uts/common/os/zone.c
↓ open down ↓ 2932 lines elided ↑ open up ↑
2933 2933           * This zone_t can no longer inhibit creation of another zone_t
2934 2934           * with the same name or debug ID.  Generate a sysevent so that
2935 2935           * userspace tools know it is safe to carry on.
2936 2936           */
2937 2937          mutex_enter(&zone_status_lock);
2938 2938          zone_status_set(zone, ZONE_IS_FREE);
2939 2939          mutex_exit(&zone_status_lock);
2940 2940  
2941 2941          cpu_uarray_free(zone->zone_ustate);
2942 2942  
2943      -        if (zone->zone_rootvp != NULL)
2944      -                VN_RELE(zone->zone_rootvp);
     2943 +        if (zone->zone_rootvp != NULL) {
     2944 +                vnode_t *vp = zone->zone_rootvp;
     2945 +
     2946 +                mutex_enter(&vp->v_lock);
     2947 +                vp->v_flag &= ~VZONEROOT;
     2948 +                mutex_exit(&vp->v_lock);
     2949 +                VN_RELE(vp);
     2950 +                /* No need to worry about NULL-ing out zone_rootvp. */
     2951 +        }
2945 2952          if (zone->zone_rootpath)
2946 2953                  kmem_free(zone->zone_rootpath, zone->zone_rootpathlen);
2947 2954          if (zone->zone_name != NULL)
2948 2955                  kmem_free(zone->zone_name, ZONENAME_MAX);
2949 2956          if (zone->zone_slabel != NULL)
2950 2957                  label_rele(zone->zone_slabel);
2951 2958          if (zone->zone_nodename != NULL)
2952 2959                  kmem_free(zone->zone_nodename, _SYS_NMLN);
2953 2960          if (zone->zone_domain != NULL)
2954 2961                  kmem_free(zone->zone_domain, _SYS_NMLN);
↓ open down ↓ 1101 lines elided ↑ open up ↑
4056 4063                                  /* Success! */
4057 4064                                  break;
4058 4065                          }
4059 4066                          VN_RELE(vp);
4060 4067                  }
4061 4068                  if (error != ESTALE)
4062 4069                          goto out;
4063 4070          }
4064 4071  
4065 4072          ASSERT(error == 0);
     4073 +        mutex_enter(&vp->v_lock);
     4074 +        if (vp->v_flag & VZONEROOT) {
     4075 +                /* Wow, someone's already using this zone root! */
     4076 +                error = EEXIST; /* XXX KEBE ASKS, better errno? */
     4077 +                mutex_exit(&vp->v_lock);
     4078 +                VN_RELE(vp);
     4079 +                goto out;
     4080 +        }
     4081 +        vp->v_flag |= VZONEROOT;
     4082 +        mutex_exit(&vp->v_lock);
4066 4083          zone->zone_rootvp = vp;         /* we hold a reference to vp */
4067 4084          zone->zone_rootpath = path;
4068 4085          zone->zone_rootpathlen = pathlen;
4069 4086          if (pathlen > 5 && strcmp(path + pathlen - 5, "/lu/") == 0)
4070 4087                  zone->zone_flags |= ZF_IS_SCRATCH;
4071 4088          return (0);
4072 4089  
4073 4090  out:
4074 4091          pn_free(&pn);
4075 4092          pn_free(&upn);
↓ open down ↓ 1961 lines elided ↑ open up ↑
6037 6054          if (zone->zone_flags & ZF_HASHED_LABEL)
6038 6055                  (void) mod_hash_destroy(zonehashbylabel,
6039 6056                      (mod_hash_key_t)zone->zone_slabel);
6040 6057          mutex_exit(&zonehash_lock);
6041 6058  
6042 6059          /*
6043 6060           * Release the root vnode; we're not using it anymore.  Nor should any
6044 6061           * other thread that might access it exist.
6045 6062           */
6046 6063          if (zone->zone_rootvp != NULL) {
6047      -                VN_RELE(zone->zone_rootvp);
     6064 +                vnode_t *vp = zone->zone_rootvp;
     6065 +
     6066 +                mutex_enter(&vp->v_lock);
     6067 +                vp->v_flag &= ~VZONEROOT;
     6068 +                mutex_exit(&vp->v_lock);
     6069 +                VN_RELE(vp);
6048 6070                  zone->zone_rootvp = NULL;
6049 6071          }
6050 6072  
6051 6073          /* add to deathrow list */
6052 6074          mutex_enter(&zone_deathrow_lock);
6053 6075          list_insert_tail(&zone_deathrow, zone);
6054 6076          mutex_exit(&zone_deathrow_lock);
6055 6077  
6056 6078          /*
6057 6079           * Drop last reference (which was added by zsched()), this will
↓ open down ↓ 2372 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX