/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <sys/zfs_context.h>
int taskq_now;
typedef struct task {
void *task_arg;
} task_t;
struct taskq {
int tq_flags;
int tq_active;
int tq_nthreads;
int tq_nalloc;
int tq_minalloc;
int tq_maxalloc;
int tq_maxalloc_wait;
};
static task_t *
{
task_t *t;
int rv;
} else {
return (NULL);
/*
* We don't want to exceed tq_maxalloc, but we can't
* wait for other tasks to complete (and thus free up
* task structures) without risking deadlock with
* the caller. So, we just delay for one second
* to throttle the allocation rate. If we have tasks
* complete before one second timeout expires then
* taskq_ent_free will signal us and we will
* immediately retry the allocation.
*/
tq->tq_maxalloc_wait++;
tq->tq_maxalloc_wait--;
if (rv > 0)
goto again; /* signaled */
}
if (t != NULL)
}
return (t);
}
static void
{
tq->tq_freelist = t;
} else {
}
if (tq->tq_maxalloc_wait)
}
{
task_t *t;
if (taskq_now) {
return (1);
}
return (0);
}
} else {
}
return (1);
}
void
{
}
static void *
{
task_t *t;
continue;
}
}
tq->tq_nthreads--;
return (NULL);
}
/*ARGSUSED*/
taskq_t *
{
int t;
if (flags & TASKQ_THREADS_CPU_PCT) {
int pct;
} else {
}
if (flags & TASKQ_PREPOPULATE) {
while (minalloc-- > 0)
}
for (t = 0; t < nthreads; t++)
(void) thr_create(0, 0, taskq_thread,
return (tq);
}
void
{
int t;
taskq_wait(tq);
while (tq->tq_nthreads != 0)
tq->tq_minalloc = 0;
}
for (t = 0; t < nthreads; t++)
}
int
{
int i;
if (taskq_now)
return (1);
for (i = 0; i < tq->tq_nthreads; i++)
return (1);
return (0);
}
void
system_taskq_init(void)
{
}
void
system_taskq_fini(void)
{
}