]> granicus.if.org Git - spl/commitdiff
Support TQ_FRONT flag used by taskq_dispatch()
authorBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 11 Jun 2010 21:53:23 +0000 (14:53 -0700)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Fri, 11 Jun 2010 22:57:25 +0000 (15:57 -0700)
Allow taskq_dispatch() to insert work items at the head of the
queue instead of just the tail by passing the TQ_FRONT flag.

include/sys/taskq.h
module/spl/spl-taskq.c

index baa96eaa0ab0a1b5c044c73c098161c4dcb145ad..4e51d98ddee868d91b471c67997132400ca99f8e 100644 (file)
@@ -39,6 +39,7 @@
 #define TASKQ_CPR_SAFE          0x00000002
 #define TASKQ_DYNAMIC           0x00000004
 #define TASKQ_THREADS_CPU_PCT   0x00000008
+#define TASKQ_DC_BATCH          0x00000010
 
 typedef unsigned long taskqid_t;
 typedef void (task_func_t)(void *);
@@ -53,6 +54,7 @@ typedef void (task_func_t)(void *);
 #define TQ_NOQUEUE              0x01000000
 #define TQ_NOALLOC              0x02000000
 #define TQ_NEW                  0x04000000
+#define TQ_FRONT                0x08000000
 #define TQ_ACTIVE               0x80000000
 
 typedef struct taskq {
index 805749a14ed76e3cd80a8bebed9925df274f2655..fba38021fef86da2122fdf6c675ce70d074fbca1 100644 (file)
@@ -274,7 +274,13 @@ __taskq_dispatch(taskq_t *tq, task_func_t func, void *arg, uint_t flags)
                GOTO(out, rc = 0);
 
        spin_lock(&t->t_lock);
-       list_add_tail(&t->t_list, &tq->tq_pend_list);
+
+       /* Queue to the head instead of the tail */
+       if (flags & TQ_FRONT)
+               list_add(&t->t_list, &tq->tq_pend_list);
+       else
+               list_add_tail(&t->t_list, &tq->tq_pend_list);
+
        t->t_id = rc = tq->tq_next_id;
        tq->tq_next_id++;
         t->t_func = func;