For VIMAGE kernels store vnet in the struct task, and set vnet context

during task processing.

Reported & tested by:	mm
This commit is contained in:
Gleb Smirnoff 2013-10-16 05:02:01 +00:00
parent 994409375b
commit 348298b1a3
3 changed files with 19 additions and 0 deletions

View File

@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$");
#include <sys/taskqueue.h>
#include <sys/unistd.h>
#include <machine/stdarg.h>
#include <net/vnet.h>
static MALLOC_DEFINE(M_TASKQUEUE, "taskqueue", "Task Queues");
static void *taskqueue_giant_ih;
@ -330,7 +331,9 @@ taskqueue_run_locked(struct taskqueue *queue)
tb.tb_running = task;
TQ_UNLOCK(queue);
CURVNET_SET(task->ta_vnet);
task->ta_func(task->ta_context, pending);
CURVNET_RESTORE();
TQ_LOCK(queue);
tb.tb_running = NULL;

View File

@ -49,6 +49,9 @@ struct task {
u_short ta_priority; /* (c) Priority */
task_fn_t *ta_func; /* (c) task handler */
void *ta_context; /* (c) argument for handler */
#ifdef VIMAGE
struct vnet *ta_vnet; /* (c) vnet context */
#endif
};
#endif /* !_SYS__TASK_H_ */

View File

@ -36,6 +36,9 @@
#include <sys/queue.h>
#include <sys/_task.h>
#include <sys/_callout.h>
#ifdef VIMAGE
#include <net/vnet.h>
#endif
struct taskqueue;
struct thread;
@ -105,12 +108,22 @@ void taskqueue_thread_enqueue(void *context);
/*
* Initialise a task structure.
*/
#ifdef VIMAGE
#define TASK_INIT(task, priority, func, context) do { \
(task)->ta_pending = 0; \
(task)->ta_priority = (priority); \
(task)->ta_func = (func); \
(task)->ta_context = (context); \
(task)->ta_vnet = curvnet; \
} while (0)
#else /* !VIMAGE */
#define TASK_INIT(task, priority, func, context) do { \
(task)->ta_pending = 0; \
(task)->ta_priority = (priority); \
(task)->ta_func = (func); \
(task)->ta_context = (context); \
} while (0)
#endif /* !VIMAGE */
void _timeout_task_init(struct taskqueue *queue,
struct timeout_task *timeout_task, int priority, task_fn_t func,