aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/libzpool/taskq.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/libzpool/taskq.c b/lib/libzpool/taskq.c
index ae67906fe..456080f7f 100644
--- a/lib/libzpool/taskq.c
+++ b/lib/libzpool/taskq.c
@@ -34,6 +34,8 @@ int taskq_now;
taskq_t *system_taskq;
taskq_t *system_delay_taskq;
+static pthread_key_t taskq_tsd;
+
#define TASKQ_ACTIVE 0x00010000
static taskq_ent_t *
@@ -213,6 +215,8 @@ taskq_thread(void *arg)
taskq_ent_t *t;
boolean_t prealloc;
+ VERIFY0(pthread_setspecific(taskq_tsd, tq));
+
mutex_enter(&tq->tq_lock);
while (tq->tq_flags & TASKQ_ACTIVE) {
if ((t = tq->tq_task.tqent_next) == &tq->tq_task) {
@@ -343,6 +347,12 @@ taskq_member(taskq_t *tq, kthread_t *t)
return (0);
}
+taskq_t *
+taskq_of_curthread(void)
+{
+ return (pthread_getspecific(taskq_tsd));
+}
+
int
taskq_cancel_id(taskq_t *tq, taskqid_t id)
{
@@ -352,6 +362,7 @@ taskq_cancel_id(taskq_t *tq, taskqid_t id)
void
system_taskq_init(void)
{
+ VERIFY0(pthread_key_create(&taskq_tsd, NULL));
system_taskq = taskq_create("system_taskq", 64, maxclsyspri, 4, 512,
TASKQ_DYNAMIC | TASKQ_PREPOPULATE);
system_delay_taskq = taskq_create("delay_taskq", 4, maxclsyspri, 4,
@@ -365,4 +376,5 @@ system_taskq_fini(void)
system_taskq = NULL; /* defensive */
taskq_destroy(system_delay_taskq);
system_delay_taskq = NULL;
+ VERIFY0(pthread_key_delete(taskq_tsd));
}