aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/slow-work.h
diff options
context:
space:
mode:
authorDavid Howells <dhowells@redhat.com>2009-11-19 13:10:53 -0500
committerDavid Howells <dhowells@redhat.com>2009-11-19 13:10:53 -0500
commit31ba99d304494cb28fa8671ccc769c5543e1165d (patch)
treeea2d839fb70798cf6a3b55ccc87f749e14e14f1d /include/linux/slow-work.h
parent8fba10a42d191de612e60e7009c8f0313f90a9b3 (diff)
SLOW_WORK: Allow the owner of a work item to determine if it is queued or not
Add a function (slow_work_is_queued()) to permit the owner of a work item to determine if the item is queued or not. The work item is counted as being queued if it is actually on the queue, not just if it is pending. If it is executing and pending, then it is not on the queue, but will rather be put back on the queue when execution finishes. This permits a caller to quickly work out if it may be able to put another, dependent work item on the queue behind it, or whether it will have to wait till that is finished. This can be used by CacheFiles to work out whether the creation a new object can be immediately deferred when it has to wait for an old object to be deleted, or whether a wait must take place. If a wait is necessary, then the slow-work thread can otherwise get blocked, preventing the deletion from taking place. Signed-off-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'include/linux/slow-work.h')
-rw-r--r--include/linux/slow-work.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/linux/slow-work.h b/include/linux/slow-work.h
index f41485145ed1..bfd3ab4c8898 100644
--- a/include/linux/slow-work.h
+++ b/include/linux/slow-work.h
@@ -120,6 +120,25 @@ static inline void vslow_work_init(struct slow_work *work,
120 INIT_LIST_HEAD(&work->link); 120 INIT_LIST_HEAD(&work->link);
121} 121}
122 122
123/**
124 * slow_work_is_queued - Determine if a slow work item is on the work queue
125 * work: The work item to test
126 *
127 * Determine if the specified slow-work item is on the work queue. This
128 * returns true if it is actually on the queue.
129 *
130 * If the item is executing and has been marked for requeue when execution
131 * finishes, then false will be returned.
132 *
133 * Anyone wishing to wait for completion of execution can wait on the
134 * SLOW_WORK_EXECUTING bit.
135 */
136static inline bool slow_work_is_queued(struct slow_work *work)
137{
138 unsigned long flags = work->flags;
139 return flags & SLOW_WORK_PENDING && !(flags & SLOW_WORK_EXECUTING);
140}
141
123extern int slow_work_enqueue(struct slow_work *work); 142extern int slow_work_enqueue(struct slow_work *work);
124extern void slow_work_cancel(struct slow_work *work); 143extern void slow_work_cancel(struct slow_work *work);
125extern int slow_work_register_user(struct module *owner); 144extern int slow_work_register_user(struct module *owner);