From 020f6fd093b628af5a34eb1cea9a3d800aa17ffb Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Tue, 7 Nov 2023 14:37:18 -0500 Subject: 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 Reviewed-by: Brian Behlendorf Signed-off-by: Alexander Motin Sponsored by: iXsystems, Inc. Closes #15455 --- module/os/freebsd/spl/spl_taskq.c | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) (limited to 'module/os/freebsd/spl/spl_taskq.c') 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,21 +480,33 @@ 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) { @@ -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); -} -- cgit v1.2.3