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

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/klm/nlm_impl.c
          +++ new/usr/src/uts/common/klm/nlm_impl.c
↓ open down ↓ 835 lines elided ↑ open up ↑
 836  836                      int, retries);
 837  837                  error = ENOENT;
 838  838                  goto error;
 839  839          }
 840  840  
 841  841          /*
 842  842           * Create an RPC handle that'll be used for communication with local
 843  843           * statd using the status monitor protocol.
 844  844           */
 845  845          error = clnt_tli_kcreate(&nsm->ns_knc, &nsm->ns_addr, SM_PROG, SM_VERS,
 846      -            0, NLM_RPC_RETRIES, kcred, &nsm->ns_handle);
      846 +            0, NLM_RPC_RETRIES, zone_kcred(), &nsm->ns_handle);
 847  847          if (error != 0)
 848  848                  goto error;
 849  849  
 850  850          /*
 851  851           * Create an RPC handle that'll be used for communication with the
 852  852           * local statd using the address registration protocol.
 853  853           */
 854  854          error = clnt_tli_kcreate(&nsm->ns_knc, &nsm->ns_addr, NSM_ADDR_PROGRAM,
 855      -            NSM_ADDR_V1, 0, NLM_RPC_RETRIES, kcred, &nsm->ns_addr_handle);
      855 +            NSM_ADDR_V1, 0, NLM_RPC_RETRIES, zone_kcred(),
      856 +            &nsm->ns_addr_handle);
 856  857          if (error != 0)
 857  858                  goto error;
 858  859  
 859  860          sema_init(&nsm->ns_sem, 1, NULL, SEMA_DEFAULT, NULL);
 860  861          return (0);
 861  862  
 862  863  error:
 863  864          kmem_free(nsm->ns_addr.buf, nsm->ns_addr.maxlen);
 864      -        if (nsm->ns_handle)
      865 +        if (nsm->ns_handle) {
      866 +                ASSERT(nsm->ns_handle->cl_auth != NULL);
      867 +                auth_destroy(nsm->ns_handle->cl_auth);
 865  868                  CLNT_DESTROY(nsm->ns_handle);
      869 +        }
 866  870  
 867  871          return (error);
 868  872  }
 869  873  
 870  874  static void
 871  875  nlm_nsm_fini(struct nlm_nsm *nsm)
 872  876  {
 873  877          kmem_free(nsm->ns_addr.buf, nsm->ns_addr.maxlen);
      878 +        if (nsm->ns_addr_handle->cl_auth != NULL)
      879 +                auth_destroy(nsm->ns_addr_handle->cl_auth);
 874  880          CLNT_DESTROY(nsm->ns_addr_handle);
 875  881          nsm->ns_addr_handle = NULL;
      882 +        if (nsm->ns_handle->cl_auth != NULL)
      883 +                auth_destroy(nsm->ns_handle->cl_auth);
 876  884          CLNT_DESTROY(nsm->ns_handle);
 877  885          nsm->ns_handle = NULL;
 878  886          sema_destroy(&nsm->ns_sem);
 879  887  }
 880  888  
 881  889  static enum clnt_stat
 882  890  nlm_nsm_simu_crash(struct nlm_nsm *nsm)
 883  891  {
 884  892          enum clnt_stat stat;
 885  893  
↓ open down ↓ 1669 lines elided ↑ open up ↑
2555 2563  }
2556 2564  
2557 2565  /*
2558 2566   * Called right before NFS export is going to
2559 2567   * dissapear. The function finds all vnodes
2560 2568   * belonging to the given export and cleans
2561 2569   * all remote locks and share reservations
2562 2570   * on them.
2563 2571   */
2564 2572  void
2565      -nlm_unexport(struct exportinfo *exi)
     2573 +nlm_zone_unexport(struct nlm_globals *g, struct exportinfo *exi)
2566 2574  {
2567      -        struct nlm_globals *g;
2568 2575          struct nlm_host *hostp;
2569 2576  
2570      -        g = zone_getspecific(nlm_zone_key, curzone);
2571      -
2572 2577          mutex_enter(&g->lock);
     2578 +        if (g->run_status != NLM_ST_UP) {
     2579 +                /* nothing to do */
     2580 +                mutex_exit(&g->lock);
     2581 +                return;
     2582 +        }
     2583 +
2573 2584          hostp = avl_first(&g->nlm_hosts_tree);
2574 2585          while (hostp != NULL) {
2575 2586                  struct nlm_vhold *nvp;
2576 2587  
2577 2588                  if (hostp->nh_flags & NLM_NH_INIDLE) {
2578 2589                          TAILQ_REMOVE(&g->nlm_idle_hosts, hostp, nh_link);
2579 2590                          hostp->nh_flags &= ~NLM_NH_INIDLE;
2580 2591                  }
2581 2592                  hostp->nh_refs++;
2582 2593  
↓ open down ↓ 27 lines elided ↑ open up ↑
2610 2621  
2611 2622                  mutex_enter(&g->lock);
2612 2623                  nlm_host_release_locked(g, hostp);
2613 2624  
2614 2625                  hostp = AVL_NEXT(&g->nlm_hosts_tree, hostp);
2615 2626          }
2616 2627  
2617 2628          mutex_exit(&g->lock);
2618 2629  }
2619 2630  
     2631 +void
     2632 +nlm_unexport(struct exportinfo *exi)
     2633 +{
     2634 +        struct nlm_globals *g;
     2635 +
     2636 +        rw_enter(&lm_lck, RW_READER);
     2637 +        TAILQ_FOREACH(g, &nlm_zones_list, nlm_link) {
     2638 +                if (g->nlm_zoneid == exi->exi_zoneid) {
     2639 +                        /*
     2640 +                         * NOTE: If we want to drop lm_lock before
     2641 +                         * calling nlm_zone_unexport(), we should break,
     2642 +                         * and have a post-rw_exit() snippit like:
     2643 +                         *      if (g != NULL)
     2644 +                         *              nlm_zone_unexport(g, exi);
     2645 +                         */
     2646 +                        nlm_zone_unexport(g, exi);
     2647 +                        break; /* Only going to match once! */
     2648 +                }
     2649 +        }
     2650 +        rw_exit(&lm_lck);
     2651 +}
     2652 +
2620 2653  /*
2621 2654   * Allocate new unique sysid.
2622 2655   * In case of failure (no available sysids)
2623 2656   * return LM_NOSYSID.
2624 2657   */
2625 2658  sysid_t
2626 2659  nlm_sysid_alloc(void)
2627 2660  {
2628 2661          sysid_t ret_sysid = LM_NOSYSID;
2629 2662  
↓ open down ↓ 148 lines elided ↑ open up ↑
2778 2811          TAILQ_FOREACH(g, &nlm_zones_list, nlm_link)
2779 2812                  nlm_resume_zone(g);
2780 2813  
2781 2814          rw_exit(&lm_lck);
2782 2815  }
2783 2816  
2784 2817  static void
2785 2818  nlm_nsm_clnt_init(CLIENT *clnt, struct nlm_nsm *nsm)
2786 2819  {
2787 2820          (void) clnt_tli_kinit(clnt, &nsm->ns_knc, &nsm->ns_addr, 0,
2788      -            NLM_RPC_RETRIES, kcred);
     2821 +            NLM_RPC_RETRIES, zone_kcred());
2789 2822  }
2790 2823  
2791 2824  static void
2792 2825  nlm_netbuf_to_netobj(struct netbuf *addr, int *family, netobj *obj)
2793 2826  {
2794 2827          /* LINTED pointer alignment */
2795 2828          struct sockaddr *sa = (struct sockaddr *)addr->buf;
2796 2829  
2797 2830          *family = sa->sa_family;
2798 2831  
↓ open down ↓ 24 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX