aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/fscache-cache.h
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2010-07-20 16:09:01 -0400
committerTejun Heo <tj@kernel.org>2010-07-22 16:58:47 -0400
commit8af7c12436803291c90295259db23d371a7ad9cc (patch)
tree5e75360876ac5783a3e64bd35a1715847d90e9ce /include/linux/fscache-cache.h
parent8b8edefa2fffbff97f9eec8b70e78ae23abad1a0 (diff)
fscache: convert operation to use workqueue instead of slow-work
Make fscache operation to use only workqueue instead of combination of workqueue and slow-work. FSCACHE_OP_SLOW is dropped and FSCACHE_OP_FAST is renamed to FSCACHE_OP_ASYNC and uses newly added fscache_op_wq workqueue to execute op->processor(). fscache_operation_init_slow() is dropped and fscache_operation_init() now takes @processor argument directly. * Unbound workqueue is used. * fscache_retrieval_work() is no longer necessary as OP_ASYNC now does the equivalent thing. * sysctl fscache.operation_max_active added to control concurrency. The default value is nr_cpus clamped between 2 and WQ_UNBOUND_MAX_ACTIVE. * debugfs support is dropped for now. Tracing API based debug facility is planned to be added. Signed-off-by: Tejun Heo <tj@kernel.org> Acked-by: David Howells <dhowells@redhat.com>
Diffstat (limited to 'include/linux/fscache-cache.h')
-rw-r--r--include/linux/fscache-cache.h37
1 files changed, 11 insertions, 26 deletions
diff --git a/include/linux/fscache-cache.h b/include/linux/fscache-cache.h
index 27c8df503152..17ed9c1dbfbe 100644
--- a/include/linux/fscache-cache.h
+++ b/include/linux/fscache-cache.h
@@ -77,18 +77,14 @@ typedef void (*fscache_operation_release_t)(struct fscache_operation *op);
77typedef void (*fscache_operation_processor_t)(struct fscache_operation *op); 77typedef void (*fscache_operation_processor_t)(struct fscache_operation *op);
78 78
79struct fscache_operation { 79struct fscache_operation {
80 union { 80 struct work_struct work; /* record for async ops */
81 struct work_struct fast_work; /* record for fast ops */
82 struct slow_work slow_work; /* record for (very) slow ops */
83 };
84 struct list_head pend_link; /* link in object->pending_ops */ 81 struct list_head pend_link; /* link in object->pending_ops */
85 struct fscache_object *object; /* object to be operated upon */ 82 struct fscache_object *object; /* object to be operated upon */
86 83
87 unsigned long flags; 84 unsigned long flags;
88#define FSCACHE_OP_TYPE 0x000f /* operation type */ 85#define FSCACHE_OP_TYPE 0x000f /* operation type */
89#define FSCACHE_OP_FAST 0x0001 /* - fast op, processor may not sleep for disk */ 86#define FSCACHE_OP_ASYNC 0x0001 /* - async op, processor may sleep for disk */
90#define FSCACHE_OP_SLOW 0x0002 /* - (very) slow op, processor may sleep for disk */ 87#define FSCACHE_OP_MYTHREAD 0x0002 /* - processing is done be issuing thread, not pool */
91#define FSCACHE_OP_MYTHREAD 0x0003 /* - processing is done be issuing thread, not pool */
92#define FSCACHE_OP_WAITING 4 /* cleared when op is woken */ 88#define FSCACHE_OP_WAITING 4 /* cleared when op is woken */
93#define FSCACHE_OP_EXCLUSIVE 5 /* exclusive op, other ops must wait */ 89#define FSCACHE_OP_EXCLUSIVE 5 /* exclusive op, other ops must wait */
94#define FSCACHE_OP_DEAD 6 /* op is now dead */ 90#define FSCACHE_OP_DEAD 6 /* op is now dead */
@@ -106,7 +102,8 @@ struct fscache_operation {
106 /* operation releaser */ 102 /* operation releaser */
107 fscache_operation_release_t release; 103 fscache_operation_release_t release;
108 104
109#ifdef CONFIG_SLOW_WORK_DEBUG 105#ifdef CONFIG_WORKQUEUE_DEBUGFS
106 struct work_struct put_work; /* work to delay operation put */
110 const char *name; /* operation name */ 107 const char *name; /* operation name */
111 const char *state; /* operation state */ 108 const char *state; /* operation state */
112#define fscache_set_op_name(OP, N) do { (OP)->name = (N); } while(0) 109#define fscache_set_op_name(OP, N) do { (OP)->name = (N); } while(0)
@@ -118,7 +115,7 @@ struct fscache_operation {
118}; 115};
119 116
120extern atomic_t fscache_op_debug_id; 117extern atomic_t fscache_op_debug_id;
121extern const struct slow_work_ops fscache_op_slow_work_ops; 118extern void fscache_op_work_func(struct work_struct *work);
122 119
123extern void fscache_enqueue_operation(struct fscache_operation *); 120extern void fscache_enqueue_operation(struct fscache_operation *);
124extern void fscache_put_operation(struct fscache_operation *); 121extern void fscache_put_operation(struct fscache_operation *);
@@ -129,33 +126,21 @@ extern void fscache_put_operation(struct fscache_operation *);
129 * @release: The release function to assign 126 * @release: The release function to assign
130 * 127 *
131 * Do basic initialisation of an operation. The caller must still set flags, 128 * Do basic initialisation of an operation. The caller must still set flags,
132 * object, either fast_work or slow_work if necessary, and processor if needed. 129 * object and processor if needed.
133 */ 130 */
134static inline void fscache_operation_init(struct fscache_operation *op, 131static inline void fscache_operation_init(struct fscache_operation *op,
135 fscache_operation_release_t release) 132 fscache_operation_processor_t processor,
133 fscache_operation_release_t release)
136{ 134{
135 INIT_WORK(&op->work, fscache_op_work_func);
137 atomic_set(&op->usage, 1); 136 atomic_set(&op->usage, 1);
138 op->debug_id = atomic_inc_return(&fscache_op_debug_id); 137 op->debug_id = atomic_inc_return(&fscache_op_debug_id);
138 op->processor = processor;
139 op->release = release; 139 op->release = release;
140 INIT_LIST_HEAD(&op->pend_link); 140 INIT_LIST_HEAD(&op->pend_link);
141 fscache_set_op_state(op, "Init"); 141 fscache_set_op_state(op, "Init");
142} 142}
143 143
144/**
145 * fscache_operation_init_slow - Do additional initialisation of a slow op
146 * @op: The operation to initialise
147 * @processor: The processor function to assign
148 *
149 * Do additional initialisation of an operation as required for slow work.
150 */
151static inline
152void fscache_operation_init_slow(struct fscache_operation *op,
153 fscache_operation_processor_t processor)
154{
155 op->processor = processor;
156 slow_work_init(&op->slow_work, &fscache_op_slow_work_ops);
157}
158
159/* 144/*
160 * data read operation 145 * data read operation
161 */ 146 */