Skip to content

Commit b721420

Browse files
Shaohua Lineilbrown
Shaohua Li
authored andcommitted
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 <[email protected]> Signed-off-by: NeilBrown <[email protected]>
1 parent 851c30c commit b721420

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

drivers/md/raid5.c

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5145,10 +5145,70 @@ stripe_cache_active_show(struct mddev *mddev, char *page)
51455145
static struct md_sysfs_entry
51465146
raid5_stripecache_active = __ATTR_RO(stripe_cache_active);
51475147

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+
51485207
static struct attribute *raid5_attrs[] = {
51495208
&raid5_stripecache_size.attr,
51505209
&raid5_stripecache_active.attr,
51515210
&raid5_preread_bypass_threshold.attr,
5211+
&raid5_group_thread_cnt.attr,
51525212
NULL,
51535213
};
51545214
static struct attribute_group raid5_attrs_group = {

0 commit comments

Comments
 (0)