diff options
author | Shaohua Li <shli@kernel.org> | 2013-08-27 05:50:42 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2013-08-28 02:56:52 -0400 |
commit | b721420e8719131896b009b11edbbd27d9b85e98 (patch) | |
tree | cb1cfdc9d63150365da8f47d283209401836d0fc /drivers/md/raid5.c | |
parent | 851c30c9badfc6b294c98e887624bff53644ad21 (diff) |
raid5: sysfs entry to control worker thread number
Add a sysfs entry to control running workqueue thread number. If
group_thread_cnt is set to 0, we will disable workqueue offload handling of
stripes.
Signed-off-by: Shaohua Li <shli@fusionio.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/raid5.c')
-rw-r--r-- | drivers/md/raid5.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 32fa1131cafc..d79ecd903269 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
@@ -5145,10 +5145,70 @@ stripe_cache_active_show(struct mddev *mddev, char *page) | |||
5145 | static struct md_sysfs_entry | 5145 | static struct md_sysfs_entry |
5146 | raid5_stripecache_active = __ATTR_RO(stripe_cache_active); | 5146 | raid5_stripecache_active = __ATTR_RO(stripe_cache_active); |
5147 | 5147 | ||
5148 | static ssize_t | ||
5149 | raid5_show_group_thread_cnt(struct mddev *mddev, char *page) | ||
5150 | { | ||
5151 | struct r5conf *conf = mddev->private; | ||
5152 | if (conf) | ||
5153 | return sprintf(page, "%d\n", conf->worker_cnt_per_group); | ||
5154 | else | ||
5155 | return 0; | ||
5156 | } | ||
5157 | |||
5158 | static int alloc_thread_groups(struct r5conf *conf, int cnt); | ||
5159 | static ssize_t | ||
5160 | raid5_store_group_thread_cnt(struct mddev *mddev, const char *page, size_t len) | ||
5161 | { | ||
5162 | struct r5conf *conf = mddev->private; | ||
5163 | unsigned long new; | ||
5164 | int err; | ||
5165 | struct r5worker_group *old_groups; | ||
5166 | int old_group_cnt; | ||
5167 | |||
5168 | if (len >= PAGE_SIZE) | ||
5169 | return -EINVAL; | ||
5170 | if (!conf) | ||
5171 | return -ENODEV; | ||
5172 | |||
5173 | if (kstrtoul(page, 10, &new)) | ||
5174 | return -EINVAL; | ||
5175 | |||
5176 | if (new == conf->worker_cnt_per_group) | ||
5177 | return len; | ||
5178 | |||
5179 | mddev_suspend(mddev); | ||
5180 | |||
5181 | old_groups = conf->worker_groups; | ||
5182 | old_group_cnt = conf->worker_cnt_per_group; | ||
5183 | |||
5184 | conf->worker_groups = NULL; | ||
5185 | err = alloc_thread_groups(conf, new); | ||
5186 | if (err) { | ||
5187 | conf->worker_groups = old_groups; | ||
5188 | conf->worker_cnt_per_group = old_group_cnt; | ||
5189 | } else { | ||
5190 | if (old_groups) | ||
5191 | kfree(old_groups[0].workers); | ||
5192 | kfree(old_groups); | ||
5193 | } | ||
5194 | |||
5195 | mddev_resume(mddev); | ||
5196 | |||
5197 | if (err) | ||
5198 | return err; | ||
5199 | return len; | ||
5200 | } | ||
5201 | |||
5202 | static struct md_sysfs_entry | ||
5203 | raid5_group_thread_cnt = __ATTR(group_thread_cnt, S_IRUGO | S_IWUSR, | ||
5204 | raid5_show_group_thread_cnt, | ||
5205 | raid5_store_group_thread_cnt); | ||
5206 | |||
5148 | static struct attribute *raid5_attrs[] = { | 5207 | static struct attribute *raid5_attrs[] = { |
5149 | &raid5_stripecache_size.attr, | 5208 | &raid5_stripecache_size.attr, |
5150 | &raid5_stripecache_active.attr, | 5209 | &raid5_stripecache_active.attr, |
5151 | &raid5_preread_bypass_threshold.attr, | 5210 | &raid5_preread_bypass_threshold.attr, |
5211 | &raid5_group_thread_cnt.attr, | ||
5152 | NULL, | 5212 | NULL, |
5153 | }; | 5213 | }; |
5154 | static struct attribute_group raid5_attrs_group = { | 5214 | static struct attribute_group raid5_attrs_group = { |