summaryrefslogtreecommitdiffstats
path: root/drivers/md/raid5.c
diff options
context:
space:
mode:
authorArtur Paszkiewicz <artur.paszkiewicz@intel.com>2017-03-09 04:00:03 -0500
committerShaohua Li <shli@fb.com>2017-03-16 19:55:56 -0400
commitba903a3ea465bd2f2bb9316054b295e79a7a518e (patch)
tree9eae9199e526deaa23791d7477bffcd910dbe463 /drivers/md/raid5.c
parent6358c239d88c751a9f14152a8d4ad2b69f5be48f (diff)
raid5-ppl: runtime PPL enabling or disabling
Allow writing to 'consistency_policy' attribute when the array is active. Add a new function 'change_consistency_policy' to the md_personality operations structure to handle the change in the personality code. Values "ppl" and "resync" are accepted and turn PPL on and off respectively. When enabling PPL its location and size should first be set using 'ppl_sector' and 'ppl_size' attributes and a valid PPL header should be written at this location on each member device. Enabling or disabling PPL is performed under a suspended array. The raid5_reset_stripe_cache function frees the stripe cache and allocates it again in order to allocate or free the ppl_pages for the stripes in the stripe cache. Signed-off-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com> Signed-off-by: Shaohua Li <shli@fb.com>
Diffstat (limited to 'drivers/md/raid5.c')
-rw-r--r--drivers/md/raid5.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 6760af251864..88cc8981bd49 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -8334,6 +8334,58 @@ static void *raid6_takeover(struct mddev *mddev)
8334 return setup_conf(mddev); 8334 return setup_conf(mddev);
8335} 8335}
8336 8336
8337static void raid5_reset_stripe_cache(struct mddev *mddev)
8338{
8339 struct r5conf *conf = mddev->private;
8340
8341 mutex_lock(&conf->cache_size_mutex);
8342 while (conf->max_nr_stripes &&
8343 drop_one_stripe(conf))
8344 ;
8345 while (conf->min_nr_stripes > conf->max_nr_stripes &&
8346 grow_one_stripe(conf, GFP_KERNEL))
8347 ;
8348 mutex_unlock(&conf->cache_size_mutex);
8349}
8350
8351static int raid5_change_consistency_policy(struct mddev *mddev, const char *buf)
8352{
8353 struct r5conf *conf;
8354 int err;
8355
8356 err = mddev_lock(mddev);
8357 if (err)
8358 return err;
8359 conf = mddev->private;
8360 if (!conf) {
8361 mddev_unlock(mddev);
8362 return -ENODEV;
8363 }
8364
8365 if (strncmp(buf, "ppl", 3) == 0 && !raid5_has_ppl(conf)) {
8366 mddev_suspend(mddev);
8367 set_bit(MD_HAS_PPL, &mddev->flags);
8368 err = log_init(conf, NULL);
8369 if (!err)
8370 raid5_reset_stripe_cache(mddev);
8371 mddev_resume(mddev);
8372 } else if (strncmp(buf, "resync", 6) == 0 && raid5_has_ppl(conf)) {
8373 mddev_suspend(mddev);
8374 log_exit(conf);
8375 raid5_reset_stripe_cache(mddev);
8376 mddev_resume(mddev);
8377 } else {
8378 err = -EINVAL;
8379 }
8380
8381 if (!err)
8382 md_update_sb(mddev, 1);
8383
8384 mddev_unlock(mddev);
8385
8386 return err;
8387}
8388
8337static struct md_personality raid6_personality = 8389static struct md_personality raid6_personality =
8338{ 8390{
8339 .name = "raid6", 8391 .name = "raid6",
@@ -8379,6 +8431,7 @@ static struct md_personality raid5_personality =
8379 .quiesce = raid5_quiesce, 8431 .quiesce = raid5_quiesce,
8380 .takeover = raid5_takeover, 8432 .takeover = raid5_takeover,
8381 .congested = raid5_congested, 8433 .congested = raid5_congested,
8434 .change_consistency_policy = raid5_change_consistency_policy,
8382}; 8435};
8383 8436
8384static struct md_personality raid4_personality = 8437static struct md_personality raid4_personality =