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>

@@ -6847,10 +6847,34 @@
                                 free(node);
                         }
                 }
 
                 /*
+                 * Initialize libshare SA_INIT_SHARE_API_SELECTIVE here
+                 * to avoid unnecessary load/unload of the libshare API
+                 * per shared dataset downstream.
+                 */
+                if (op == OP_SHARE) {
+                        get_all_cb_t dslist = { 0 };
+                        get_all_datasets(&dslist, B_FALSE);
+
+                        if (dslist.cb_used != 0) {
+                                sa_init_selective_arg_t sharearg;
+                                sharearg.zhandle_arr = dslist.cb_handles;
+                                sharearg.zhandle_len = dslist.cb_used;
+                                if ((ret = zfs_init_libshare_arg(g_zfs,
+                                    SA_INIT_SHARE_API_SELECTIVE, &sharearg)) !=
+                                        SA_OK) {
+                                        (void) fprintf(stderr, gettext(
+                                            "Could not initialize libshare, "
+                                            "%d"), ret);
+                                        return (1);
+                                }
+                        }
+                }
+
+                /*
                  * Walk the AVL tree in reverse, unmounting each filesystem and
                  * removing it from the AVL tree in the process.
                  */
                 if ((walk = uu_avl_walk_start(tree,
                     UU_WALK_REVERSE | UU_WALK_ROBUST)) == NULL)