Skip to content

Commit

Permalink
spl-taskq: fix task counts for delayed and cancelled tasks
Browse files Browse the repository at this point in the history
Dispatched delayed tasks were not added to tasks_total, and cancelled
tasks were not removed. This notably could make tasks_total go to
UNIT64_MAX, but just generally meant the count could be wrong. So lets
not!

Sponsored-by: Klara, Inc.
Sponsored-by: Syneto
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes openzfs#16473
  • Loading branch information
robn authored and lundman committed Sep 4, 2024
1 parent 2de8e1b commit 9111fa2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions module/os/linux/spl/spl-taskq.c
Original file line number Diff line number Diff line change
Expand Up @@ -620,6 +620,7 @@ taskq_cancel_id(taskq_t *tq, taskqid_t id)
if (t && t != ERR_PTR(-EBUSY)) {
list_del_init(&t->tqent_list);
TQSTAT_DEC_LIST(tq, t);
TQSTAT_DEC(tq, tasks_total);

t->tqent_flags |= TQENT_FLAG_CANCEL;
TQSTAT_INC(tq, tasks_cancelled);
Expand Down Expand Up @@ -760,6 +761,7 @@ taskq_dispatch_delay(taskq_t *tq, task_func_t func, void *arg,
list_add_tail(&t->tqent_list, &tq->tq_delay_list);
TQENT_SET_LIST(t, TQENT_LIST_DELAY);
TQSTAT_INC_LIST(tq, t);
TQSTAT_INC(tq, tasks_total);

t->tqent_id = rc = tq->tq_next_id;
tq->tq_next_id++;
Expand Down

0 comments on commit 9111fa2

Please sign in to comment.