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

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 ↓ 2562 lines elided ↑ open up ↑
2563 2563  }
2564 2564  
2565 2565  /*
2566 2566   * Called right before NFS export is going to
2567 2567   * dissapear. The function finds all vnodes
2568 2568   * belonging to the given export and cleans
2569 2569   * all remote locks and share reservations
2570 2570   * on them.
2571 2571   */
2572 2572  void
2573      -nlm_unexport(struct exportinfo *exi)
     2573 +nlm_zone_unexport(struct nlm_globals *g, struct exportinfo *exi)
2574 2574  {
2575      -        struct nlm_globals *g;
2576 2575          struct nlm_host *hostp;
2577 2576  
2578      -        /* This may be called on behalf of global-zone doing shutdown. */
2579      -        ASSERT(exi->exi_zone == curzone || curzone == global_zone);
2580      -        g = zone_getspecific(nlm_zone_key, exi->exi_zone);
2581      -        if (g == NULL) {
2582      -                /* Did zone cleanup get here already? */
     2577 +        mutex_enter(&g->lock);
     2578 +        if (g->run_status != NLM_ST_UP) {
     2579 +                /* nothing to do */
     2580 +                mutex_exit(&g->lock);
2583 2581                  return;
2584 2582          }
2585 2583  
2586      -        mutex_enter(&g->lock);
2587 2584          hostp = avl_first(&g->nlm_hosts_tree);
2588 2585          while (hostp != NULL) {
2589 2586                  struct nlm_vhold *nvp;
2590 2587  
2591 2588                  if (hostp->nh_flags & NLM_NH_INIDLE) {
2592 2589                          TAILQ_REMOVE(&g->nlm_idle_hosts, hostp, nh_link);
2593 2590                          hostp->nh_flags &= ~NLM_NH_INIDLE;
2594 2591                  }
2595 2592                  hostp->nh_refs++;
2596 2593  
↓ open down ↓ 27 lines elided ↑ open up ↑
2624 2621  
2625 2622                  mutex_enter(&g->lock);
2626 2623                  nlm_host_release_locked(g, hostp);
2627 2624  
2628 2625                  hostp = AVL_NEXT(&g->nlm_hosts_tree, hostp);
2629 2626          }
2630 2627  
2631 2628          mutex_exit(&g->lock);
2632 2629  }
2633 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 +
2634 2653  /*
2635 2654   * Allocate new unique sysid.
2636 2655   * In case of failure (no available sysids)
2637 2656   * return LM_NOSYSID.
2638 2657   */
2639 2658  sysid_t
2640 2659  nlm_sysid_alloc(void)
2641 2660  {
2642 2661          sysid_t ret_sysid = LM_NOSYSID;
2643 2662  
↓ open down ↓ 193 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX