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


  75 
  76         g = kmem_zalloc(sizeof (*g), KM_SLEEP);
  77 
  78         avl_create(&g->nlm_hosts_tree, nlm_host_cmp,
  79             sizeof (struct nlm_host),
  80             offsetof(struct nlm_host, nh_by_addr));
  81 
  82         g->nlm_hosts_hash = mod_hash_create_idhash("nlm_host_by_sysid",
  83             64, mod_hash_null_valdtor);
  84 
  85         TAILQ_INIT(&g->nlm_idle_hosts);
  86         TAILQ_INIT(&g->nlm_slocks);
  87 
  88         mutex_init(&g->lock, NULL, MUTEX_DEFAULT, NULL);
  89         cv_init(&g->nlm_gc_sched_cv, NULL, CV_DEFAULT, NULL);
  90         cv_init(&g->nlm_gc_finish_cv, NULL, CV_DEFAULT, NULL);
  91         mutex_init(&g->clean_lock, NULL, MUTEX_DEFAULT, NULL);
  92 
  93         g->lockd_pid = 0;
  94         g->run_status = NLM_ST_DOWN;

  95 
  96         nlm_globals_register(g);
  97         return (g);
  98 }
  99 
 100 /* ARGSUSED */
 101 void
 102 lm_zone_fini(zoneid_t zoneid, void *data)
 103 {
 104         struct nlm_globals *g = data;
 105 


 106         ASSERT(avl_is_empty(&g->nlm_hosts_tree));
 107         avl_destroy(&g->nlm_hosts_tree);
 108         mod_hash_destroy_idhash(g->nlm_hosts_hash);
 109 
 110         ASSERT(g->nlm_gc_thread == NULL);
 111         mutex_destroy(&g->lock);
 112         cv_destroy(&g->nlm_gc_sched_cv);
 113         cv_destroy(&g->nlm_gc_finish_cv);
 114         mutex_destroy(&g->clean_lock);
 115 
 116         nlm_globals_unregister(g);
 117         kmem_free(g, sizeof (*g));
 118 }
 119 
 120 
 121 
 122 /*
 123  * ****************************************************************
 124  * module init, fini, info
 125  */
 126 int
 127 _init()
 128 {
 129         int retval;
 130 
 131         rw_init(&lm_lck, NULL, RW_DEFAULT, NULL);
 132         nlm_init();
 133 
 134         zone_key_create(&nlm_zone_key, lm_zone_init, NULL, lm_zone_fini);
 135         /* Per-zone lockmgr data.  See: os/flock.c */
 136         zone_key_create(&flock_zone_key, flk_zone_init, NULL, flk_zone_fini);




  75 
  76         g = kmem_zalloc(sizeof (*g), KM_SLEEP);
  77 
  78         avl_create(&g->nlm_hosts_tree, nlm_host_cmp,
  79             sizeof (struct nlm_host),
  80             offsetof(struct nlm_host, nh_by_addr));
  81 
  82         g->nlm_hosts_hash = mod_hash_create_idhash("nlm_host_by_sysid",
  83             64, mod_hash_null_valdtor);
  84 
  85         TAILQ_INIT(&g->nlm_idle_hosts);
  86         TAILQ_INIT(&g->nlm_slocks);
  87 
  88         mutex_init(&g->lock, NULL, MUTEX_DEFAULT, NULL);
  89         cv_init(&g->nlm_gc_sched_cv, NULL, CV_DEFAULT, NULL);
  90         cv_init(&g->nlm_gc_finish_cv, NULL, CV_DEFAULT, NULL);
  91         mutex_init(&g->clean_lock, NULL, MUTEX_DEFAULT, NULL);
  92 
  93         g->lockd_pid = 0;
  94         g->run_status = NLM_ST_DOWN;
  95         g->nlm_zoneid = zoneid;
  96 
  97         nlm_globals_register(g);
  98         return (g);
  99 }
 100 
 101 /* ARGSUSED */
 102 void
 103 lm_zone_fini(zoneid_t zoneid, void *data)
 104 {
 105         struct nlm_globals *g = data;
 106 
 107         nlm_globals_unregister(g);
 108 
 109         ASSERT(avl_is_empty(&g->nlm_hosts_tree));
 110         avl_destroy(&g->nlm_hosts_tree);
 111         mod_hash_destroy_idhash(g->nlm_hosts_hash);
 112 
 113         ASSERT(g->nlm_gc_thread == NULL);
 114         mutex_destroy(&g->lock);
 115         cv_destroy(&g->nlm_gc_sched_cv);
 116         cv_destroy(&g->nlm_gc_finish_cv);
 117         mutex_destroy(&g->clean_lock);
 118 

 119         kmem_free(g, sizeof (*g));
 120 }
 121 
 122 
 123 
 124 /*
 125  * ****************************************************************
 126  * module init, fini, info
 127  */
 128 int
 129 _init()
 130 {
 131         int retval;
 132 
 133         rw_init(&lm_lck, NULL, RW_DEFAULT, NULL);
 134         nlm_init();
 135 
 136         zone_key_create(&nlm_zone_key, lm_zone_init, NULL, lm_zone_fini);
 137         /* Per-zone lockmgr data.  See: os/flock.c */
 138         zone_key_create(&flock_zone_key, flk_zone_init, NULL, flk_zone_fini);