mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-30 11:56:43 +07:00
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>
This commit is contained in:
parent
00bcb4ac7e
commit
c41d4ac40d
@ -4566,6 +4566,32 @@ raid5_show_stripe_cache_size(mddev_t *mddev, char *page)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
raid5_set_cache_size(mddev_t *mddev, int size)
|
||||
{
|
||||
raid5_conf_t *conf = mddev->private;
|
||||
int err;
|
||||
|
||||
if (size <= 16 || size > 32768)
|
||||
return -EINVAL;
|
||||
while (size < conf->max_nr_stripes) {
|
||||
if (drop_one_stripe(conf))
|
||||
conf->max_nr_stripes--;
|
||||
else
|
||||
break;
|
||||
}
|
||||
err = md_allow_write(mddev);
|
||||
if (err)
|
||||
return err;
|
||||
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)
|
||||
{
|
||||
@ -4580,22 +4606,9 @@ raid5_store_stripe_cache_size(mddev_t *mddev, const char *page, size_t len)
|
||||
|
||||
if (strict_strtoul(page, 10, &new))
|
||||
return -EINVAL;
|
||||
if (new <= 16 || new > 32768)
|
||||
return -EINVAL;
|
||||
while (new < conf->max_nr_stripes) {
|
||||
if (drop_one_stripe(conf))
|
||||
conf->max_nr_stripes--;
|
||||
else
|
||||
break;
|
||||
}
|
||||
err = md_allow_write(mddev);
|
||||
err = raid5_set_cache_size(mddev, new);
|
||||
if (err)
|
||||
return err;
|
||||
while (new > conf->max_nr_stripes) {
|
||||
if (grow_one_stripe(conf))
|
||||
conf->max_nr_stripes++;
|
||||
else break;
|
||||
}
|
||||
return len;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user