]> granicus.if.org Git - zfs/commit
splat taskq:cancel: Add test case
authorBrian Behlendorf <behlendorf1@llnl.gov>
Thu, 6 Dec 2012 23:42:32 +0000 (15:42 -0800)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 12 Dec 2012 17:56:49 +0000 (09:56 -0800)
commit3238e717631c68f6f44907b46733f4ae70452d3b
tree5c0e9781f78af22e7584fa75304f86393da8d6bf
parent2f357826208085bacce9e0a29972c2e5728d5420
splat taskq:cancel: Add test case

Add a test case for taskq_cancel_id() to verify it is working
properly.  Just like taskq:delay we start by dispatching 100
tasks.  However this time 1/3 of the tasks use taskq_dispatch()
and will be run immediately, and 2/3 use taskq_dispatch_delay().
The idea is to create a busy taskq with both active, pending,
and delayed tasks.

After all the items have been successfully dispatched the test
begins randomly canceling known task ids.  It will do this for
5 seconds randomly canceling a task id and then sleeping for a
few milliseconds.   The task being canceled may have already run,
still be on the pending list, or may be currently being executed
by a worker thread.  The idea is to ensure we catch any subtle
race conditions.

Once all the non-canceled tasks have completed we cross check
the number of tasks which ran with the number of tasks which
were successfully canceled.  Additionally, we verify that the
taskq_cancel_id() function never blocks longer than needed.
This time is bounded by the longest run time of the task which
was dispatched.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
module/splat/splat-taskq.c