diff options
author | NeilBrown <neilb@suse.de> | 2010-06-01 09:37:24 (GMT) |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2010-07-21 03:28:15 (GMT) |
commit | c41d4ac40df0d01bf9c383ff28f194d1df2d4fd9 (patch) | |
tree | 0e22b3cc5e211a3f7dd4b6dea69d2afc1a173543 /drivers/md | |
parent | 00bcb4ac7ee7e557a491b614219142cea0ef16f4 (diff) | |
download | linux-c41d4ac40df0d01bf9c383ff28f194d1df2d4fd9.tar.xz |
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')
-rw-r--r-- | drivers/md/raid5.c | 39 | ||||
-rw-r--r-- | drivers/md/raid5.h | 1 |
2 files changed, 27 insertions, 13 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 6a7a301..bd4067a 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) return 0; } -static ssize_t -raid5_store_stripe_cache_size(mddev_t *mddev, const char *page, size_t len) +int +raid5_set_cache_size(mddev_t *mddev, int size) { raid5_conf_t *conf = mddev->private; - unsigned long new; int err; - if (len >= PAGE_SIZE) + if (size <= 16 || size > 32768) return -EINVAL; - if (!conf) - return -ENODEV; - - if (strict_strtoul(page, 10, &new)) - return -EINVAL; - if (new <= 16 || new > 32768) - return -EINVAL; - while (new < conf->max_nr_stripes) { + while (size < conf->max_nr_stripes) { if (drop_one_stripe(conf)) conf->max_nr_stripes--; else @@ -4591,11 +4583,32 @@ raid5_store_stripe_cache_size(mddev_t *mddev, const char *page, size_t len) err = md_allow_write(mddev); if (err) return err; - while (new > conf->max_nr_stripes) { + while (size > conf->max_nr_stripes) { if (grow_one_stripe(conf)) conf->max_nr_stripes++; else break; } + return 0; +} +EXPORT_SYMBOL(raid5_set_cache_size); + +static ssize_t +raid5_store_stripe_cache_size(mddev_t *mddev, const char *page, size_t len) +{ + raid5_conf_t *conf = mddev->private; + unsigned long new; + int err; + + if (len >= PAGE_SIZE) + return -EINVAL; + if (!conf) + return -ENODEV; + + if (strict_strtoul(page, 10, &new)) + return -EINVAL; + err = raid5_set_cache_size(mddev, new); + if (err) + return err; return len; } diff --git a/drivers/md/raid5.h b/drivers/md/raid5.h index 0f86f5e..cbdbc77 100644 --- a/drivers/md/raid5.h +++ b/drivers/md/raid5.h @@ -497,4 +497,5 @@ static inline int algorithm_is_DDF(int layout) { return layout >= 8 && layout <= 10; } +extern int raid5_set_cache_size(mddev_t *mddev, int size); #endif |