5252#include <stdlib.h>
5353#include <string.h>
5454#include <termios.h>
55- #include <thread_pool.h>
5655#include <time.h>
5756#include <unistd.h>
5857#include <pwd.h>
@@ -2389,7 +2388,7 @@ zpool_do_destroy(int argc, char **argv)
23892388}
23902389
23912390typedef struct export_cbdata {
2392- tpool_t * tpool ;
2391+ taskq_t * taskq ;
23932392 pthread_mutex_t mnttab_lock ;
23942393 boolean_t force ;
23952394 boolean_t hardforce ;
@@ -2414,12 +2413,12 @@ zpool_export_one(zpool_handle_t *zhp, void *data)
24142413 * zpool_disable_datasets() is not thread-safe for mnttab access.
24152414 * So we serialize access here for 'zpool export -a' parallel case.
24162415 */
2417- if (cb -> tpool != NULL )
2416+ if (cb -> taskq != NULL )
24182417 (void ) pthread_mutex_lock (& cb -> mnttab_lock );
24192418
24202419 int retval = zpool_disable_datasets (zhp , cb -> force );
24212420
2422- if (cb -> tpool != NULL )
2421+ if (cb -> taskq != NULL )
24232422 (void ) pthread_mutex_unlock (& cb -> mnttab_lock );
24242423
24252424 if (retval )
@@ -2463,15 +2462,16 @@ zpool_export_task(void *arg)
24632462static int
24642463zpool_export_one_async (zpool_handle_t * zhp , void * data )
24652464{
2466- tpool_t * tpool = ((export_cbdata_t * )data )-> tpool ;
2465+ taskq_t * tq = ((export_cbdata_t * )data )-> taskq ;
24672466 async_export_args_t * aea = safe_malloc (sizeof (async_export_args_t ));
24682467
24692468 /* save pool name since zhp will go out of scope */
24702469 aea -> aea_poolname = strdup (zpool_get_name (zhp ));
24712470 aea -> aea_cbdata = data ;
24722471
24732472 /* ship off actual export to another thread */
2474- if (tpool_dispatch (tpool , zpool_export_task , (void * )aea ) != 0 )
2473+ if (taskq_dispatch (tq , zpool_export_task , (void * )aea ,
2474+ TQ_SLEEP ) == TASKQID_INVALID )
24752475 return (errno ); /* unlikely */
24762476 else
24772477 return (0 );
@@ -2517,7 +2517,7 @@ zpool_do_export(int argc, char **argv)
25172517
25182518 cb .force = force ;
25192519 cb .hardforce = hardforce ;
2520- cb .tpool = NULL ;
2520+ cb .taskq = NULL ;
25212521 cb .retval = 0 ;
25222522 argc -= optind ;
25232523 argv += optind ;
@@ -2531,16 +2531,17 @@ zpool_do_export(int argc, char **argv)
25312531 usage (B_FALSE );
25322532 }
25332533
2534- cb .tpool = tpool_create (1 , 5 * sysconf (_SC_NPROCESSORS_ONLN ),
2535- 0 , NULL );
2534+ cb .taskq = taskq_create ("zpool_export" ,
2535+ 5 * sysconf (_SC_NPROCESSORS_ONLN ), minclsyspri , 1 , INT_MAX ,
2536+ TASKQ_DYNAMIC );
25362537 (void ) pthread_mutex_init (& cb .mnttab_lock , NULL );
25372538
25382539 /* Asynchronously call zpool_export_one using thread pool */
25392540 ret = for_each_pool (argc , argv , B_TRUE , NULL , ZFS_TYPE_POOL ,
25402541 B_FALSE , zpool_export_one_async , & cb );
25412542
2542- tpool_wait (cb .tpool );
2543- tpool_destroy (cb .tpool );
2543+ taskq_wait (cb .taskq );
2544+ taskq_destroy (cb .taskq );
25442545 (void ) pthread_mutex_destroy (& cb .mnttab_lock );
25452546
25462547 return (ret | cb .retval );
@@ -3945,10 +3946,11 @@ import_pools(nvlist_t *pools, nvlist_t *props, char *mntopts, int flags,
39453946 uint_t npools = 0 ;
39463947
39473948
3948- tpool_t * tp = NULL ;
3949+ taskq_t * tq = NULL ;
39493950 if (import -> do_all ) {
3950- tp = tpool_create (1 , 5 * sysconf (_SC_NPROCESSORS_ONLN ),
3951- 0 , NULL );
3951+ tq = taskq_create ("zpool_import_all" ,
3952+ 5 * sysconf (_SC_NPROCESSORS_ONLN ), minclsyspri , 1 , INT_MAX ,
3953+ TASKQ_DYNAMIC );
39523954 }
39533955
39543956 /*
@@ -3997,8 +3999,8 @@ import_pools(nvlist_t *pools, nvlist_t *props, char *mntopts, int flags,
39973999 ip -> ip_mntthreads = mount_tp_nthr / npools ;
39984000 ip -> ip_err = & err ;
39994001
4000- (void ) tpool_dispatch ( tp , do_import_task ,
4001- (void * )ip );
4002+ (void ) taskq_dispatch ( tq , do_import_task ,
4003+ (void * )ip , TQ_SLEEP );
40024004 } else {
40034005 /*
40044006 * If we're importing from cachefile, then
@@ -4047,8 +4049,8 @@ import_pools(nvlist_t *pools, nvlist_t *props, char *mntopts, int flags,
40474049 }
40484050 }
40494051 if (import -> do_all ) {
4050- tpool_wait ( tp );
4051- tpool_destroy ( tp );
4052+ taskq_wait ( tq );
4053+ taskq_destroy ( tq );
40524054 }
40534055
40544056 /*
0 commit comments