Print this page
11945 pool import performance regression due to repeated libshare initialization
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Reviewed by: Dan McDonald <danmcd@joyent.com>
Reviewed by: Jason King <jason.brian.king@gmail.com>

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/zfs/zfs_main.c
          +++ new/usr/src/cmd/zfs/zfs_main.c
↓ open down ↓ 6841 lines elided ↑ open up ↑
6842 6842                          if (uu_avl_find(tree, node, NULL, &idx) == NULL) {
6843 6843                                  uu_avl_insert(tree, node, idx);
6844 6844                          } else {
6845 6845                                  zfs_close(node->un_zhp);
6846 6846                                  free(node->un_mountp);
6847 6847                                  free(node);
6848 6848                          }
6849 6849                  }
6850 6850  
6851 6851                  /*
     6852 +                 * Initialize libshare SA_INIT_SHARE_API_SELECTIVE here
     6853 +                 * to avoid unnecessary load/unload of the libshare API
     6854 +                 * per shared dataset downstream.
     6855 +                 */
     6856 +                if (op == OP_SHARE) {
     6857 +                        get_all_cb_t dslist = { 0 };
     6858 +                        get_all_datasets(&dslist, B_FALSE);
     6859 +
     6860 +                        if (dslist.cb_used != 0) {
     6861 +                                sa_init_selective_arg_t sharearg;
     6862 +                                sharearg.zhandle_arr = dslist.cb_handles;
     6863 +                                sharearg.zhandle_len = dslist.cb_used;
     6864 +                                if ((ret = zfs_init_libshare_arg(g_zfs,
     6865 +                                    SA_INIT_SHARE_API_SELECTIVE, &sharearg)) !=
     6866 +                                        SA_OK) {
     6867 +                                        (void) fprintf(stderr, gettext(
     6868 +                                            "Could not initialize libshare, "
     6869 +                                            "%d"), ret);
     6870 +                                        return (1);
     6871 +                                }
     6872 +                        }
     6873 +                }
     6874 +
     6875 +                /*
6852 6876                   * Walk the AVL tree in reverse, unmounting each filesystem and
6853 6877                   * removing it from the AVL tree in the process.
6854 6878                   */
6855 6879                  if ((walk = uu_avl_walk_start(tree,
6856 6880                      UU_WALK_REVERSE | UU_WALK_ROBUST)) == NULL)
6857 6881                          nomem();
6858 6882  
6859 6883                  while ((node = uu_avl_walk_next(walk)) != NULL) {
6860 6884                          uu_avl_remove(tree, node);
6861 6885  
↓ open down ↓ 1237 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX