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>


6832                         default:
6833                                 break;
6834                         }
6835 
6836                         node = safe_malloc(sizeof (unshare_unmount_node_t));
6837                         node->un_zhp = zhp;
6838                         node->un_mountp = safe_strdup(entry.mnt_mountp);
6839 
6840                         uu_avl_node_init(node, &node->un_avlnode, pool);
6841 
6842                         if (uu_avl_find(tree, node, NULL, &idx) == NULL) {
6843                                 uu_avl_insert(tree, node, idx);
6844                         } else {
6845                                 zfs_close(node->un_zhp);
6846                                 free(node->un_mountp);
6847                                 free(node);
6848                         }
6849                 }
6850 
6851                 /*
























6852                  * Walk the AVL tree in reverse, unmounting each filesystem and
6853                  * removing it from the AVL tree in the process.
6854                  */
6855                 if ((walk = uu_avl_walk_start(tree,
6856                     UU_WALK_REVERSE | UU_WALK_ROBUST)) == NULL)
6857                         nomem();
6858 
6859                 while ((node = uu_avl_walk_next(walk)) != NULL) {
6860                         uu_avl_remove(tree, node);
6861 
6862                         switch (op) {
6863                         case OP_SHARE:
6864                                 if (zfs_unshareall_bypath(node->un_zhp,
6865                                     node->un_mountp) != 0)
6866                                         ret = 1;
6867                                 break;
6868 
6869                         case OP_MOUNT:
6870                                 if (zfs_unmount(node->un_zhp,
6871                                     node->un_mountp, flags) != 0)




6832                         default:
6833                                 break;
6834                         }
6835 
6836                         node = safe_malloc(sizeof (unshare_unmount_node_t));
6837                         node->un_zhp = zhp;
6838                         node->un_mountp = safe_strdup(entry.mnt_mountp);
6839 
6840                         uu_avl_node_init(node, &node->un_avlnode, pool);
6841 
6842                         if (uu_avl_find(tree, node, NULL, &idx) == NULL) {
6843                                 uu_avl_insert(tree, node, idx);
6844                         } else {
6845                                 zfs_close(node->un_zhp);
6846                                 free(node->un_mountp);
6847                                 free(node);
6848                         }
6849                 }
6850 
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                 /*
6876                  * Walk the AVL tree in reverse, unmounting each filesystem and
6877                  * removing it from the AVL tree in the process.
6878                  */
6879                 if ((walk = uu_avl_walk_start(tree,
6880                     UU_WALK_REVERSE | UU_WALK_ROBUST)) == NULL)
6881                         nomem();
6882 
6883                 while ((node = uu_avl_walk_next(walk)) != NULL) {
6884                         uu_avl_remove(tree, node);
6885 
6886                         switch (op) {
6887                         case OP_SHARE:
6888                                 if (zfs_unshareall_bypath(node->un_zhp,
6889                                     node->un_mountp) != 0)
6890                                         ret = 1;
6891                                 break;
6892 
6893                         case OP_MOUNT:
6894                                 if (zfs_unmount(node->un_zhp,
6895                                     node->un_mountp, flags) != 0)