diff options
author | Tejun Heo <tj@kernel.org> | 2010-07-20 16:09:01 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2010-07-22 16:58:47 -0400 |
commit | 8af7c12436803291c90295259db23d371a7ad9cc (patch) | |
tree | 5e75360876ac5783a3e64bd35a1715847d90e9ce /fs/fscache/page.c | |
parent | 8b8edefa2fffbff97f9eec8b70e78ae23abad1a0 (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 'fs/fscache/page.c')
-rw-r--r-- | fs/fscache/page.c | 36 |
1 files changed, 8 insertions, 28 deletions
diff --git a/fs/fscache/page.c b/fs/fscache/page.c index 723b889fd219..41c441c2058d 100644 --- a/fs/fscache/page.c +++ b/fs/fscache/page.c | |||
@@ -105,7 +105,7 @@ bool __fscache_maybe_release_page(struct fscache_cookie *cookie, | |||
105 | 105 | ||
106 | page_busy: | 106 | page_busy: |
107 | /* we might want to wait here, but that could deadlock the allocator as | 107 | /* we might want to wait here, but that could deadlock the allocator as |
108 | * the slow-work threads writing to the cache may all end up sleeping | 108 | * the work threads writing to the cache may all end up sleeping |
109 | * on memory allocation */ | 109 | * on memory allocation */ |
110 | fscache_stat(&fscache_n_store_vmscan_busy); | 110 | fscache_stat(&fscache_n_store_vmscan_busy); |
111 | return false; | 111 | return false; |
@@ -188,9 +188,8 @@ int __fscache_attr_changed(struct fscache_cookie *cookie) | |||
188 | return -ENOMEM; | 188 | return -ENOMEM; |
189 | } | 189 | } |
190 | 190 | ||
191 | fscache_operation_init(op, NULL); | 191 | fscache_operation_init(op, fscache_attr_changed_op, NULL); |
192 | fscache_operation_init_slow(op, fscache_attr_changed_op); | 192 | op->flags = FSCACHE_OP_ASYNC | (1 << FSCACHE_OP_EXCLUSIVE); |
193 | op->flags = FSCACHE_OP_SLOW | (1 << FSCACHE_OP_EXCLUSIVE); | ||
194 | fscache_set_op_name(op, "Attr"); | 193 | fscache_set_op_name(op, "Attr"); |
195 | 194 | ||
196 | spin_lock(&cookie->lock); | 195 | spin_lock(&cookie->lock); |
@@ -218,24 +217,6 @@ nobufs: | |||
218 | EXPORT_SYMBOL(__fscache_attr_changed); | 217 | EXPORT_SYMBOL(__fscache_attr_changed); |
219 | 218 | ||
220 | /* | 219 | /* |
221 | * handle secondary execution given to a retrieval op on behalf of the | ||
222 | * cache | ||
223 | */ | ||
224 | static void fscache_retrieval_work(struct work_struct *work) | ||
225 | { | ||
226 | struct fscache_retrieval *op = | ||
227 | container_of(work, struct fscache_retrieval, op.fast_work); | ||
228 | unsigned long start; | ||
229 | |||
230 | _enter("{OP%x}", op->op.debug_id); | ||
231 | |||
232 | start = jiffies; | ||
233 | op->op.processor(&op->op); | ||
234 | fscache_hist(fscache_ops_histogram, start); | ||
235 | fscache_put_operation(&op->op); | ||
236 | } | ||
237 | |||
238 | /* | ||
239 | * release a retrieval op reference | 220 | * release a retrieval op reference |
240 | */ | 221 | */ |
241 | static void fscache_release_retrieval_op(struct fscache_operation *_op) | 222 | static void fscache_release_retrieval_op(struct fscache_operation *_op) |
@@ -269,13 +250,12 @@ static struct fscache_retrieval *fscache_alloc_retrieval( | |||
269 | return NULL; | 250 | return NULL; |
270 | } | 251 | } |
271 | 252 | ||
272 | fscache_operation_init(&op->op, fscache_release_retrieval_op); | 253 | fscache_operation_init(&op->op, NULL, fscache_release_retrieval_op); |
273 | op->op.flags = FSCACHE_OP_MYTHREAD | (1 << FSCACHE_OP_WAITING); | 254 | op->op.flags = FSCACHE_OP_MYTHREAD | (1 << FSCACHE_OP_WAITING); |
274 | op->mapping = mapping; | 255 | op->mapping = mapping; |
275 | op->end_io_func = end_io_func; | 256 | op->end_io_func = end_io_func; |
276 | op->context = context; | 257 | op->context = context; |
277 | op->start_time = jiffies; | 258 | op->start_time = jiffies; |
278 | INIT_WORK(&op->op.fast_work, fscache_retrieval_work); | ||
279 | INIT_LIST_HEAD(&op->to_do); | 259 | INIT_LIST_HEAD(&op->to_do); |
280 | fscache_set_op_name(&op->op, "Retr"); | 260 | fscache_set_op_name(&op->op, "Retr"); |
281 | return op; | 261 | return op; |
@@ -795,9 +775,9 @@ int __fscache_write_page(struct fscache_cookie *cookie, | |||
795 | if (!op) | 775 | if (!op) |
796 | goto nomem; | 776 | goto nomem; |
797 | 777 | ||
798 | fscache_operation_init(&op->op, fscache_release_write_op); | 778 | fscache_operation_init(&op->op, fscache_write_op, |
799 | fscache_operation_init_slow(&op->op, fscache_write_op); | 779 | fscache_release_write_op); |
800 | op->op.flags = FSCACHE_OP_SLOW | (1 << FSCACHE_OP_WAITING); | 780 | op->op.flags = FSCACHE_OP_ASYNC | (1 << FSCACHE_OP_WAITING); |
801 | fscache_set_op_name(&op->op, "Write1"); | 781 | fscache_set_op_name(&op->op, "Write1"); |
802 | 782 | ||
803 | ret = radix_tree_preload(gfp & ~__GFP_HIGHMEM); | 783 | ret = radix_tree_preload(gfp & ~__GFP_HIGHMEM); |
@@ -852,7 +832,7 @@ int __fscache_write_page(struct fscache_cookie *cookie, | |||
852 | fscache_stat(&fscache_n_store_ops); | 832 | fscache_stat(&fscache_n_store_ops); |
853 | fscache_stat(&fscache_n_stores_ok); | 833 | fscache_stat(&fscache_n_stores_ok); |
854 | 834 | ||
855 | /* the slow work queue now carries its own ref on the object */ | 835 | /* the work queue now carries its own ref on the object */ |
856 | fscache_put_operation(&op->op); | 836 | fscache_put_operation(&op->op); |
857 | _leave(" = 0"); | 837 | _leave(" = 0"); |
858 | return 0; | 838 | return 0; |