aboutsummaryrefslogtreecommitdiffstats
path: root/module/os/freebsd/spl/spl_taskq.c
diff options
context:
space:
mode:
authorAlexander Motin <[email protected]>2023-11-07 14:37:18 -0500
committerGitHub <[email protected]>2023-11-07 11:37:18 -0800
commit020f6fd093b628af5a34eb1cea9a3d800aa17ffb (patch)
tree9ee4403246b472e985708f36b141fe85b0cd6730 /module/os/freebsd/spl/spl_taskq.c
parent58398cbd035116ba1d5756bae338664573e60d21 (diff)
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 <[email protected]> Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Alexander Motin <[email protected]> Sponsored by: iXsystems, Inc. Closes #15455
Diffstat (limited to 'module/os/freebsd/spl/spl_taskq.c')
-rw-r--r--module/os/freebsd/spl/spl_taskq.c30
1 files changed, 18 insertions, 12 deletions
diff --git a/module/os/freebsd/spl/spl_taskq.c b/module/os/freebsd/spl/spl_taskq.c
index 6912b220a..cc276e568 100644
--- a/module/os/freebsd/spl/spl_taskq.c
+++ b/module/os/freebsd/spl/spl_taskq.c
@@ -480,22 +480,34 @@ void
taskq_dispatch_ent(taskq_t *tq, task_func_t func, void *arg, uint32_t flags,
taskq_ent_t *task)
{
- int prio;
-
/*
* If TQ_FRONT is given, we want higher priority for this task, so it
* can go at the front of the queue.
*/
- prio = !!(flags & TQ_FRONT);
- task->tqent_id = 0;
+ task->tqent_task.ta_priority = !!(flags & TQ_FRONT);
task->tqent_func = func;
task->tqent_arg = arg;
-
- TASK_INIT(&task->tqent_task, prio, taskq_run_ent, 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
taskq_wait(taskq_t *tq)
{
taskqueue_quiesce(tq->tq_queue);
@@ -521,9 +533,3 @@ taskq_wait_outstanding(taskq_t *tq, taskqid_t id __unused)
{
taskqueue_drain_all(tq->tq_queue);
}
-
-int
-taskq_empty_ent(taskq_ent_t *t)
-{
- return (t->tqent_task.ta_pending == 0);
-}