]>
git.proxmox.com Git - mirror_zfs.git/blob - modules/spl/linux-taskq.c
1 #include <linux-taskq.h>
6 * The taskq_work_wrapper functions are used to manage the work_structs
7 * which must be submitted to linux. The shim layer allocates a wrapper
8 * structure for all items which contains a pointer to itself as well as
9 * the real work to be performed. When the work item run the generic
10 * handle is called which calls the real work function and then using
11 * the self pointer frees the work_struct.
13 typedef struct taskq_work_wrapper
{
14 struct work_struct tww_work
;
17 } taskq_work_wrapper_t
;
20 taskq_work_handler(void *priv
)
22 taskq_work_wrapper_t
*tww
= priv
;
25 BUG_ON(tww
->tww_func
== NULL
);
27 /* Call the real function and free the wrapper */
28 tww
->tww_func(tww
->tww_priv
);
32 /* XXX - All flags currently ignored */
34 __taskq_dispatch(taskq_t
*tq
, task_func_t func
, void *priv
, uint_t flags
)
36 struct workqueue_struct
*wq
= tq
;
37 taskq_work_wrapper_t
*tww
;
41 BUG_ON(in_interrupt());
45 tww
= (taskq_work_wrapper_t
*)kmalloc(sizeof(*tww
), GFP_KERNEL
);
49 INIT_WORK(&(tww
->tww_work
), taskq_work_handler
, tww
);
53 rc
= queue_work(wq
, &(tww
->tww_work
));
61 EXPORT_SYMBOL(__taskq_dispatch
);
63 /* XXX - Most args ignored until we decide if it's worth the effort
64 * to emulate the solaris notion of dynamic thread pools. For
65 * now we simply serialize everything through one thread which
66 * may come back to bite us as a performance issue.
67 * pri - Ignore priority
68 * min - Ignored until this is a dynamic thread pool
69 * max - Ignored until this is a dynamic thread pool
70 * flags - Ignored until this is a dynamic thread_pool
73 __taskq_create(const char *name
, int nthreads
, pri_t pri
,
74 int minalloc
, int maxalloc
, uint_t flags
)
76 /* NOTE: Linux workqueue names are limited to 10 chars */
78 return create_singlethread_workqueue(name
);
80 EXPORT_SYMBOL(__taskq_create
);