2008-02-28 03:52:31 +03:00
|
|
|
#ifndef _SPL_TASKQ_H
|
|
|
|
#define _SPL_TASKQ_H
|
2008-02-26 23:36:04 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2008-02-27 22:09:51 +03:00
|
|
|
#include <linux/module.h>
|
2008-02-26 23:36:04 +03:00
|
|
|
#include <linux/gfp.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/interrupt.h>
|
2008-04-26 02:10:47 +04:00
|
|
|
#include <linux/kthread.h>
|
2008-03-01 03:45:59 +03:00
|
|
|
#include <sys/types.h>
|
2008-04-26 02:10:47 +04:00
|
|
|
#include <sys/kmem.h>
|
2008-02-26 23:36:04 +03:00
|
|
|
|
2008-04-26 02:10:47 +04:00
|
|
|
#define TASKQ_NAMELEN 31
|
2008-02-26 23:36:04 +03:00
|
|
|
|
2008-04-26 02:10:47 +04:00
|
|
|
#define TASKQ_PREPOPULATE 0x00000001
|
|
|
|
#define TASKQ_CPR_SAFE 0x00000002
|
|
|
|
#define TASKQ_DYNAMIC 0x00000004
|
2008-02-26 23:36:04 +03:00
|
|
|
|
|
|
|
typedef unsigned long taskqid_t;
|
2008-04-26 02:10:47 +04:00
|
|
|
typedef void (task_func_t)(void *);
|
2008-02-26 23:36:04 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Flags for taskq_dispatch. TQ_SLEEP/TQ_NOSLEEP should be same as
|
2008-04-26 02:10:47 +04:00
|
|
|
* KM_SLEEP/KM_NOSLEEP. TQ_NOQUEUE/TQ_NOALLOC are set particularly
|
|
|
|
* large so as not to conflict with already used GFP_* defines.
|
2008-02-26 23:36:04 +03:00
|
|
|
*/
|
2008-04-26 02:10:47 +04:00
|
|
|
#define TQ_SLEEP KM_SLEEP
|
|
|
|
#define TQ_NOSLEEP KM_NOSLEEP
|
|
|
|
#define TQ_NOQUEUE 0x01000000
|
|
|
|
#define TQ_NOALLOC 0x02000000
|
|
|
|
#define TQ_NEW 0x04000000
|
|
|
|
#define TQ_ACTIVE 0x80000000
|
|
|
|
|
|
|
|
typedef struct task {
|
|
|
|
spinlock_t t_lock;
|
|
|
|
struct list_head t_list;
|
|
|
|
taskqid_t t_id;
|
|
|
|
task_func_t *t_func;
|
|
|
|
void *t_arg;
|
|
|
|
} task_t;
|
|
|
|
|
|
|
|
typedef struct taskq {
|
|
|
|
spinlock_t tq_lock; /* protects taskq_t */
|
|
|
|
struct task_struct **tq_threads; /* thread pointers */
|
|
|
|
const char *tq_name; /* taskq name */
|
|
|
|
int tq_nactive; /* # of active threads */
|
|
|
|
int tq_nthreads; /* # of total threads */
|
|
|
|
int tq_pri; /* priority */
|
|
|
|
int tq_minalloc; /* min task_t pool size */
|
|
|
|
int tq_maxalloc; /* max task_t pool size */
|
|
|
|
int tq_nalloc; /* cur task_t pool size */
|
|
|
|
uint_t tq_flags; /* flags */
|
|
|
|
taskqid_t tq_next_id; /* next pend/work id */
|
|
|
|
taskqid_t tq_lowest_id; /* lowest pend/work id */
|
|
|
|
struct list_head tq_free_list; /* free task_t's */
|
|
|
|
struct list_head tq_work_list; /* work task_t's */
|
|
|
|
struct list_head tq_pend_list; /* pending task_t's */
|
|
|
|
wait_queue_head_t tq_work_waitq; /* new work waitq */
|
|
|
|
wait_queue_head_t tq_wait_waitq; /* wait waitq */
|
|
|
|
} taskq_t;
|
2008-02-26 23:36:04 +03:00
|
|
|
|
|
|
|
extern taskqid_t __taskq_dispatch(taskq_t *, task_func_t, void *, uint_t);
|
|
|
|
extern taskq_t *__taskq_create(const char *, int, pri_t, int, int, uint_t);
|
2008-03-11 05:08:57 +03:00
|
|
|
extern void __taskq_destroy(taskq_t *);
|
|
|
|
extern void __taskq_wait(taskq_t *);
|
2008-04-26 02:10:47 +04:00
|
|
|
extern int __taskq_member(taskq_t *, void *);
|
|
|
|
|
|
|
|
#define taskq_member(tq, t) __taskq_member(tq, t)
|
|
|
|
#define taskq_wait_id(tq, id) __taskq_wait_id(tq, id)
|
|
|
|
#define taskq_wait(tq) __taskq_wait(tq)
|
|
|
|
#define taskq_dispatch(tq, f, p, fl) __taskq_dispatch(tq, f, p, fl)
|
|
|
|
#define taskq_create(n, th, p, mi, ma, fl) __taskq_create(n, th, p, mi, ma, fl)
|
|
|
|
#define taskq_destroy(tq) __taskq_destroy(tq)
|
2008-02-26 23:36:04 +03:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2008-02-28 03:52:31 +03:00
|
|
|
#endif /* _SPL_TASKQ_H */
|