aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/md/raid5.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-06-01 05:37:24 -0400
committerNeilBrown <neilb@suse.de>2010-07-20 23:28:15 -0400
commitc41d4ac40df0d01bf9c383ff28f194d1df2d4fd9 (patch)
tree0e22b3cc5e211a3f7dd4b6dea69d2afc1a173543 /drivers/md/raid5.c
parent00bcb4ac7ee7e557a491b614219142cea0ef16f4 (diff)
md/raid5: factor out code for changing size of stripe cache.
Separate the actual 'change' code from the sysfs interface so that it can eventually be called internally. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md/raid5.c')
-rw-r--r--drivers/md/raid5.c39
1 files changed, 26 insertions, 13 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 6a7a30113161..bd4067a70834 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -4566,23 +4566,15 @@ raid5_show_stripe_cache_size(mddev_t *mddev, char *page)
4566 return 0; 4566 return 0;
4567} 4567}
4568 4568
4569static ssize_t 4569int
4570raid5_store_stripe_cache_size(mddev_t *mddev, const char *page, size_t len) 4570raid5_set_cache_size(mddev_t *mddev, int size)
4571{ 4571{
4572 raid5_conf_t *conf = mddev->private; 4572 raid5_conf_t *conf = mddev->private;
4573 unsigned long new;
4574 int err; 4573 int err;
4575 4574
4576 if (len >= PAGE_SIZE) 4575 if (size <= 16 || size > 32768)
4577 return -EINVAL; 4576 return -EINVAL;
4578 if (!conf) 4577 while (size < conf->max_nr_stripes) {
4579 return -ENODEV;
4580
4581 if (strict_strtoul(page, 10, &new))
4582 return -EINVAL;
4583 if (new <= 16 || new > 32768)
4584 return -EINVAL;
4585 while (new < conf->max_nr_stripes) {
4586 if (drop_one_stripe(conf)) 4578 if (drop_one_stripe(conf))
4587 conf->max_nr_stripes--; 4579 conf->max_nr_stripes--;
4588 else 4580 else
@@ -4591,11 +4583,32 @@ raid5_store_stripe_cache_size(mddev_t *mddev, const char *page, size_t len)
4591 err = md_allow_write(mddev); 4583 err = md_allow_write(mddev);
4592 if (err) 4584 if (err)
4593 return err; 4585 return err;
4594 while (new > conf->max_nr_stripes) { 4586 while (size > conf->max_nr_stripes) {
4595 if (grow_one_stripe(conf)) 4587 if (grow_one_stripe(conf))
4596 conf->max_nr_stripes++; 4588 conf->max_nr_stripes++;
4597 else break; 4589 else break;
4598 } 4590 }
4591 return 0;
4592}
4593EXPORT_SYMBOL(raid5_set_cache_size);
4594
4595static ssize_t
4596raid5_store_stripe_cache_size(mddev_t *mddev, const char *page, size_t len)
4597{
4598 raid5_conf_t *conf = mddev->private;
4599 unsigned long new;
4600 int err;
4601
4602 if (len >= PAGE_SIZE)
4603 return -EINVAL;
4604 if (!conf)
4605 return -ENODEV;
4606
4607 if (strict_strtoul(page, 10, &new))
4608 return -EINVAL;
4609 err = raid5_set_cache_size(mddev, new);
4610 if (err)
4611 return err;
4599 return len; 4612 return len;
4600} 4613}
4601 4614