Print this page
Zone ID only matches once, don't loop after a match
Fix nlm_unexport

@@ -2568,24 +2568,21 @@
  * belonging to the given export and cleans
  * all remote locks and share reservations
  * on them.
  */
 void
-nlm_unexport(struct exportinfo *exi)
+nlm_zone_unexport(struct nlm_globals *g, struct exportinfo *exi)
 {
-        struct nlm_globals *g;
         struct nlm_host *hostp;
 
-        /* This may be called on behalf of global-zone doing shutdown. */
-        ASSERT(exi->exi_zone == curzone || curzone == global_zone);
-        g = zone_getspecific(nlm_zone_key, exi->exi_zone);
-        if (g == NULL) {
-                /* Did zone cleanup get here already? */
+        mutex_enter(&g->lock);
+        if (g->run_status != NLM_ST_UP) {
+                /* nothing to do */
+                mutex_exit(&g->lock);
                 return;
         }
 
-        mutex_enter(&g->lock);
         hostp = avl_first(&g->nlm_hosts_tree);
         while (hostp != NULL) {
                 struct nlm_vhold *nvp;
 
                 if (hostp->nh_flags & NLM_NH_INIDLE) {

@@ -2629,10 +2626,32 @@
         }
 
         mutex_exit(&g->lock);
 }
 
+void
+nlm_unexport(struct exportinfo *exi)
+{
+        struct nlm_globals *g;
+
+        rw_enter(&lm_lck, RW_READER);
+        TAILQ_FOREACH(g, &nlm_zones_list, nlm_link) {
+                if (g->nlm_zoneid == exi->exi_zoneid) {
+                        /*
+                         * NOTE: If we want to drop lm_lock before
+                         * calling nlm_zone_unexport(), we should break,
+                         * and have a post-rw_exit() snippit like:
+                         *      if (g != NULL)
+                         *              nlm_zone_unexport(g, exi);
+                         */
+                        nlm_zone_unexport(g, exi);
+                        break; /* Only going to match once! */
+                }
+        }
+        rw_exit(&lm_lck);
+}
+
 /*
  * Allocate new unique sysid.
  * In case of failure (no available sysids)
  * return LM_NOSYSID.
  */