FreeBSD: Implement taskq_init_ent()
Previously taskq_init_ent() was an empty macro, while actual init was done by taskq_dispatch_ent(). It could be slightly faster in case taskq never enqueued. But without it taskq_empty_ent() relied on the structure being zeroed by somebody else, that is not good. As a side effect this allows the same task to be queued several times, that is normal on FreeBSD, that may or may not get useful here also one day. Reviewed-by: Brian Atkinson <batkinson@lanl.gov> Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Signed-off-by: Alexander Motin <mav@FreeBSD.org> Sponsored by: iXsystems, Inc. Closes #15455
This commit is contained in:
parent
58398cbd03
commit
020f6fd093
|
@ -82,7 +82,6 @@ typedef struct taskq_ent {
|
||||||
|
|
||||||
#define TASKQID_INVALID ((taskqid_t)0)
|
#define TASKQID_INVALID ((taskqid_t)0)
|
||||||
|
|
||||||
#define taskq_init_ent(x)
|
|
||||||
extern taskq_t *system_taskq;
|
extern taskq_t *system_taskq;
|
||||||
/* Global dynamic task queue for long delay */
|
/* Global dynamic task queue for long delay */
|
||||||
extern taskq_t *system_delay_taskq;
|
extern taskq_t *system_delay_taskq;
|
||||||
|
@ -93,6 +92,7 @@ extern taskqid_t taskq_dispatch_delay(taskq_t *, task_func_t, void *,
|
||||||
extern void taskq_dispatch_ent(taskq_t *, task_func_t, void *, uint_t,
|
extern void taskq_dispatch_ent(taskq_t *, task_func_t, void *, uint_t,
|
||||||
taskq_ent_t *);
|
taskq_ent_t *);
|
||||||
extern int taskq_empty_ent(taskq_ent_t *);
|
extern int taskq_empty_ent(taskq_ent_t *);
|
||||||
|
extern void taskq_init_ent(taskq_ent_t *);
|
||||||
taskq_t *taskq_create(const char *, int, pri_t, int, int, uint_t);
|
taskq_t *taskq_create(const char *, int, pri_t, int, int, uint_t);
|
||||||
taskq_t *taskq_create_synced(const char *, int, pri_t, int, int, uint_t,
|
taskq_t *taskq_create_synced(const char *, int, pri_t, int, int, uint_t,
|
||||||
kthread_t ***);
|
kthread_t ***);
|
||||||
|
|
|
@ -480,21 +480,33 @@ void
|
||||||
taskq_dispatch_ent(taskq_t *tq, task_func_t func, void *arg, uint32_t flags,
|
taskq_dispatch_ent(taskq_t *tq, task_func_t func, void *arg, uint32_t flags,
|
||||||
taskq_ent_t *task)
|
taskq_ent_t *task)
|
||||||
{
|
{
|
||||||
int prio;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If TQ_FRONT is given, we want higher priority for this task, so it
|
* If TQ_FRONT is given, we want higher priority for this task, so it
|
||||||
* can go at the front of the queue.
|
* can go at the front of the queue.
|
||||||
*/
|
*/
|
||||||
prio = !!(flags & TQ_FRONT);
|
task->tqent_task.ta_priority = !!(flags & TQ_FRONT);
|
||||||
task->tqent_id = 0;
|
|
||||||
task->tqent_func = func;
|
task->tqent_func = func;
|
||||||
task->tqent_arg = arg;
|
task->tqent_arg = arg;
|
||||||
|
|
||||||
TASK_INIT(&task->tqent_task, prio, taskq_run_ent, task);
|
|
||||||
taskqueue_enqueue(tq->tq_queue, &task->tqent_task);
|
taskqueue_enqueue(tq->tq_queue, &task->tqent_task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
taskq_init_ent(taskq_ent_t *task)
|
||||||
|
{
|
||||||
|
TASK_INIT(&task->tqent_task, 0, taskq_run_ent, task);
|
||||||
|
task->tqent_func = NULL;
|
||||||
|
task->tqent_arg = NULL;
|
||||||
|
task->tqent_id = 0;
|
||||||
|
task->tqent_type = NORMAL_TASK;
|
||||||
|
task->tqent_rc = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
taskq_empty_ent(taskq_ent_t *task)
|
||||||
|
{
|
||||||
|
return (task->tqent_task.ta_pending == 0);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
taskq_wait(taskq_t *tq)
|
taskq_wait(taskq_t *tq)
|
||||||
{
|
{
|
||||||
|
@ -521,9 +533,3 @@ taskq_wait_outstanding(taskq_t *tq, taskqid_t id __unused)
|
||||||
{
|
{
|
||||||
taskqueue_drain_all(tq->tq_queue);
|
taskqueue_drain_all(tq->tq_queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
taskq_empty_ent(taskq_ent_t *t)
|
|
||||||
{
|
|
||||||
return (t->tqent_task.ta_pending == 0);
|
|
||||||
}
|
|
||||||
|
|
Loading…
Reference in New Issue