Print this page
11083 support NFS server in zone
Portions contributed by: Dan Kruchinin <dan.kruchinin@nexenta.com>
Portions contributed by: Stepan Zastupov <stepan.zastupov@gmail.com>
Portions contributed by: Joyce McIntosh <joyce.mcintosh@nexenta.com>
Portions contributed by: Mike Zeller <mike@mikezeller.net>
Portions contributed by: Dan McDonald <danmcd@joyent.com>
Portions contributed by: Gordon Ross <gordon.w.ross@gmail.com>
Portions contributed by: Vitaliy Gusev <gusev.vitaliy@gmail.com>
Reviewed by: Rick McNeal <rick.mcneal@nexenta.com>
Reviewed by: Rob Gittins <rob.gittins@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Jason King <jbk@joyent.com>
Reviewed by: C Fraire <cfraire@me.com>
Change-Id: I22f289d357503f9b48a0bc2482cc4328a6d43d16

@@ -841,40 +841,48 @@
         /*
          * Create an RPC handle that'll be used for communication with local
          * statd using the status monitor protocol.
          */
         error = clnt_tli_kcreate(&nsm->ns_knc, &nsm->ns_addr, SM_PROG, SM_VERS,
-            0, NLM_RPC_RETRIES, kcred, &nsm->ns_handle);
+            0, NLM_RPC_RETRIES, zone_kcred(), &nsm->ns_handle);
         if (error != 0)
                 goto error;
 
         /*
          * Create an RPC handle that'll be used for communication with the
          * local statd using the address registration protocol.
          */
         error = clnt_tli_kcreate(&nsm->ns_knc, &nsm->ns_addr, NSM_ADDR_PROGRAM,
-            NSM_ADDR_V1, 0, NLM_RPC_RETRIES, kcred, &nsm->ns_addr_handle);
+            NSM_ADDR_V1, 0, NLM_RPC_RETRIES, zone_kcred(),
+            &nsm->ns_addr_handle);
         if (error != 0)
                 goto error;
 
         sema_init(&nsm->ns_sem, 1, NULL, SEMA_DEFAULT, NULL);
         return (0);
 
 error:
         kmem_free(nsm->ns_addr.buf, nsm->ns_addr.maxlen);
-        if (nsm->ns_handle)
+        if (nsm->ns_handle) {
+                ASSERT(nsm->ns_handle->cl_auth != NULL);
+                auth_destroy(nsm->ns_handle->cl_auth);
                 CLNT_DESTROY(nsm->ns_handle);
+        }
 
         return (error);
 }
 
 static void
 nlm_nsm_fini(struct nlm_nsm *nsm)
 {
         kmem_free(nsm->ns_addr.buf, nsm->ns_addr.maxlen);
+        if (nsm->ns_addr_handle->cl_auth != NULL)
+                auth_destroy(nsm->ns_addr_handle->cl_auth);
         CLNT_DESTROY(nsm->ns_addr_handle);
         nsm->ns_addr_handle = NULL;
+        if (nsm->ns_handle->cl_auth != NULL)
+                auth_destroy(nsm->ns_handle->cl_auth);
         CLNT_DESTROY(nsm->ns_handle);
         nsm->ns_handle = NULL;
         sema_destroy(&nsm->ns_sem);
 }
 

@@ -2560,18 +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;
 
-        g = zone_getspecific(nlm_zone_key, curzone);
-
         mutex_enter(&g->lock);
+        if (g->run_status != NLM_ST_UP) {
+                /* nothing to do */
+                mutex_exit(&g->lock);
+                return;
+        }
+
         hostp = avl_first(&g->nlm_hosts_tree);
         while (hostp != NULL) {
                 struct nlm_vhold *nvp;
 
                 if (hostp->nh_flags & NLM_NH_INIDLE) {

@@ -2615,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.
  */

@@ -2783,11 +2816,11 @@
 
 static void
 nlm_nsm_clnt_init(CLIENT *clnt, struct nlm_nsm *nsm)
 {
         (void) clnt_tli_kinit(clnt, &nsm->ns_knc, &nsm->ns_addr, 0,
-            NLM_RPC_RETRIES, kcred);
+            NLM_RPC_RETRIES, zone_kcred());
 }
 
 static void
 nlm_netbuf_to_netobj(struct netbuf *addr, int *family, netobj *obj)
 {