aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorJens Axboe <jens.axboe@oracle.com>2009-11-19 13:10:47 -0500
committerDavid Howells <dhowells@redhat.com>2009-11-19 13:10:47 -0500
commit6b8268b17a1ffc942bc72d7d00274e433d6b6719 (patch)
treebd293facd4b805fc05588fcaf024e964a0bb1cca /include/linux
parent0160950297c08f8233c89b9f9e7dd59cfb080809 (diff)
SLOW_WORK: Add delayed_slow_work support
This adds support for starting slow work with a delay, similar to the functionality we have for workqueues. Signed-off-by: Jens Axboe <jens.axboe@oracle.com> Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/slow-work.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/include/linux/slow-work.h b/include/linux/slow-work.h
index eef20182d5b4..b245b9a9cc0b 100644
--- a/include/linux/slow-work.h
+++ b/include/linux/slow-work.h
@@ -17,6 +17,7 @@
17#ifdef CONFIG_SLOW_WORK 17#ifdef CONFIG_SLOW_WORK
18 18
19#include <linux/sysctl.h> 19#include <linux/sysctl.h>
20#include <linux/timer.h>
20 21
21struct slow_work; 22struct slow_work;
22 23
@@ -52,10 +53,16 @@ struct slow_work {
52#define SLOW_WORK_ENQ_DEFERRED 2 /* item enqueue deferred */ 53#define SLOW_WORK_ENQ_DEFERRED 2 /* item enqueue deferred */
53#define SLOW_WORK_VERY_SLOW 3 /* item is very slow */ 54#define SLOW_WORK_VERY_SLOW 3 /* item is very slow */
54#define SLOW_WORK_CANCELLING 4 /* item is being cancelled, don't enqueue */ 55#define SLOW_WORK_CANCELLING 4 /* item is being cancelled, don't enqueue */
56#define SLOW_WORK_DELAYED 5 /* item is struct delayed_slow_work with active timer */
55 const struct slow_work_ops *ops; /* operations table for this item */ 57 const struct slow_work_ops *ops; /* operations table for this item */
56 struct list_head link; /* link in queue */ 58 struct list_head link; /* link in queue */
57}; 59};
58 60
61struct delayed_slow_work {
62 struct slow_work work;
63 struct timer_list timer;
64};
65
59/** 66/**
60 * slow_work_init - Initialise a slow work item 67 * slow_work_init - Initialise a slow work item
61 * @work: The work item to initialise 68 * @work: The work item to initialise
@@ -72,6 +79,20 @@ static inline void slow_work_init(struct slow_work *work,
72} 79}
73 80
74/** 81/**
82 * slow_work_init - Initialise a delayed slow work item
83 * @work: The work item to initialise
84 * @ops: The operations to use to handle the slow work item
85 *
86 * Initialise a delayed slow work item.
87 */
88static inline void delayed_slow_work_init(struct delayed_slow_work *dwork,
89 const struct slow_work_ops *ops)
90{
91 init_timer(&dwork->timer);
92 slow_work_init(&dwork->work, ops);
93}
94
95/**
75 * vslow_work_init - Initialise a very slow work item 96 * vslow_work_init - Initialise a very slow work item
76 * @work: The work item to initialise 97 * @work: The work item to initialise
77 * @ops: The operations to use to handle the slow work item 98 * @ops: The operations to use to handle the slow work item
@@ -93,6 +114,14 @@ extern void slow_work_cancel(struct slow_work *work);
93extern int slow_work_register_user(struct module *owner); 114extern int slow_work_register_user(struct module *owner);
94extern void slow_work_unregister_user(struct module *owner); 115extern void slow_work_unregister_user(struct module *owner);
95 116
117extern int delayed_slow_work_enqueue(struct delayed_slow_work *dwork,
118 unsigned long delay);
119
120static inline void delayed_slow_work_cancel(struct delayed_slow_work *dwork)
121{
122 slow_work_cancel(&dwork->work);
123}
124
96#ifdef CONFIG_SYSCTL 125#ifdef CONFIG_SYSCTL
97extern ctl_table slow_work_sysctls[]; 126extern ctl_table slow_work_sysctls[];
98#endif 127#endif