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/main.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/main.c')
-rw-r--r-- | fs/fscache/main.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/fs/fscache/main.c b/fs/fscache/main.c index bb8d4c35c7a2..44d13ddab2cc 100644 --- a/fs/fscache/main.c +++ b/fs/fscache/main.c | |||
@@ -42,11 +42,13 @@ MODULE_PARM_DESC(fscache_debug, | |||
42 | 42 | ||
43 | struct kobject *fscache_root; | 43 | struct kobject *fscache_root; |
44 | struct workqueue_struct *fscache_object_wq; | 44 | struct workqueue_struct *fscache_object_wq; |
45 | struct workqueue_struct *fscache_op_wq; | ||
45 | 46 | ||
46 | DEFINE_PER_CPU(wait_queue_head_t, fscache_object_cong_wait); | 47 | DEFINE_PER_CPU(wait_queue_head_t, fscache_object_cong_wait); |
47 | 48 | ||
48 | /* these values serve as lower bounds, will be adjusted in fscache_init() */ | 49 | /* these values serve as lower bounds, will be adjusted in fscache_init() */ |
49 | static unsigned fscache_object_max_active = 4; | 50 | static unsigned fscache_object_max_active = 4; |
51 | static unsigned fscache_op_max_active = 2; | ||
50 | 52 | ||
51 | #ifdef CONFIG_SYSCTL | 53 | #ifdef CONFIG_SYSCTL |
52 | static struct ctl_table_header *fscache_sysctl_header; | 54 | static struct ctl_table_header *fscache_sysctl_header; |
@@ -74,6 +76,14 @@ ctl_table fscache_sysctls[] = { | |||
74 | .proc_handler = fscache_max_active_sysctl, | 76 | .proc_handler = fscache_max_active_sysctl, |
75 | .extra1 = &fscache_object_wq, | 77 | .extra1 = &fscache_object_wq, |
76 | }, | 78 | }, |
79 | { | ||
80 | .procname = "operation_max_active", | ||
81 | .data = &fscache_op_max_active, | ||
82 | .maxlen = sizeof(unsigned), | ||
83 | .mode = 0644, | ||
84 | .proc_handler = fscache_max_active_sysctl, | ||
85 | .extra1 = &fscache_op_wq, | ||
86 | }, | ||
77 | {} | 87 | {} |
78 | }; | 88 | }; |
79 | 89 | ||
@@ -110,6 +120,16 @@ static int __init fscache_init(void) | |||
110 | if (!fscache_object_wq) | 120 | if (!fscache_object_wq) |
111 | goto error_object_wq; | 121 | goto error_object_wq; |
112 | 122 | ||
123 | fscache_op_max_active = | ||
124 | clamp_val(fscache_object_max_active / 2, | ||
125 | fscache_op_max_active, WQ_UNBOUND_MAX_ACTIVE); | ||
126 | |||
127 | ret = -ENOMEM; | ||
128 | fscache_op_wq = alloc_workqueue("fscache_operation", WQ_UNBOUND, | ||
129 | fscache_op_max_active); | ||
130 | if (!fscache_op_wq) | ||
131 | goto error_op_wq; | ||
132 | |||
113 | for_each_possible_cpu(cpu) | 133 | for_each_possible_cpu(cpu) |
114 | init_waitqueue_head(&per_cpu(fscache_object_cong_wait, cpu)); | 134 | init_waitqueue_head(&per_cpu(fscache_object_cong_wait, cpu)); |
115 | 135 | ||
@@ -152,6 +172,8 @@ error_sysctl: | |||
152 | #endif | 172 | #endif |
153 | fscache_proc_cleanup(); | 173 | fscache_proc_cleanup(); |
154 | error_proc: | 174 | error_proc: |
175 | destroy_workqueue(fscache_op_wq); | ||
176 | error_op_wq: | ||
155 | destroy_workqueue(fscache_object_wq); | 177 | destroy_workqueue(fscache_object_wq); |
156 | error_object_wq: | 178 | error_object_wq: |
157 | slow_work_unregister_user(THIS_MODULE); | 179 | slow_work_unregister_user(THIS_MODULE); |
@@ -172,6 +194,7 @@ static void __exit fscache_exit(void) | |||
172 | kmem_cache_destroy(fscache_cookie_jar); | 194 | kmem_cache_destroy(fscache_cookie_jar); |
173 | unregister_sysctl_table(fscache_sysctl_header); | 195 | unregister_sysctl_table(fscache_sysctl_header); |
174 | fscache_proc_cleanup(); | 196 | fscache_proc_cleanup(); |
197 | destroy_workqueue(fscache_op_wq); | ||
175 | destroy_workqueue(fscache_object_wq); | 198 | destroy_workqueue(fscache_object_wq); |
176 | slow_work_unregister_user(THIS_MODULE); | 199 | slow_work_unregister_user(THIS_MODULE); |
177 | printk(KERN_NOTICE "FS-Cache: Unloaded\n"); | 200 | printk(KERN_NOTICE "FS-Cache: Unloaded\n"); |