From 21c40e6d9e8427679cba05f35db21c85f2723592 Mon Sep 17 00:00:00 2001 From: Alexander Motin Date: Tue, 24 Sep 2024 19:29:18 -0400 Subject: [PATCH] FreeBSD: Sync taskq_cancel_id() returns with Linux Couple places in the code depend on 0 returned only if the task was actually cancelled. Doing otherwise could lead to extra references being dropped. The race could be small, but I believe CI hit it from time to time. Reviewed-by: Brian Behlendorf Signed-off-by: Alexander Motin Sponsored by: iXsystems, Inc. Closes #16565 --- module/os/freebsd/spl/spl_taskq.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/os/freebsd/spl/spl_taskq.c b/module/os/freebsd/spl/spl_taskq.c index 842b80ade..266fe9a9a 100644 --- a/module/os/freebsd/spl/spl_taskq.c +++ b/module/os/freebsd/spl/spl_taskq.c @@ -283,7 +283,7 @@ taskq_cancel_id(taskq_t *tq, taskqid_t tid) taskq_ent_t *ent; if ((ent = taskq_lookup(tid)) == NULL) - return (0); + return (ENOENT); if (ent->tqent_type == NORMAL_TASK) { rc = taskqueue_cancel(tq->tq_queue, &ent->tqent_task, &pend); @@ -306,7 +306,7 @@ taskq_cancel_id(taskq_t *tq, taskqid_t tid) } /* Free the extra reference we added with taskq_lookup. */ taskq_free(ent); - return (rc); + return (pend ? 0 : ENOENT); } static void