summaryrefslogtreecommitdiffstats
path: root/drivers/md/raid5.c
diff options
context:
space:
mode:
authorSong Liu <songliubraving@fb.com>2017-03-27 13:51:33 -0400
committerShaohua Li <shli@fb.com>2017-03-27 15:02:33 -0400
commit0bb0c10500ba634216238c40e1eeddce92b4d488 (patch)
treef7bca55d0d048f27362a6d65a2ef3be6eb70b1e6 /drivers/md/raid5.c
parent1ad45a9bc4e0cd5a6e6fb0e6c5d35d6c87f14c76 (diff)
md/raid5: use consistency_policy to remove journal feature
When journal device of an array fails, the array is forced into read-only mode. To make the array normal without adding another journal device, we need to remove journal _feature_ from the array. This patch allows remove journal _feature_ from an array, For journal existing journal should be either missing or faulty. To remove journal feature, it is necessary to remove the journal device first: mdadm --fail /dev/md0 /dev/sdb mdadm: set /dev/sdb faulty in /dev/md0 mdadm --remove /dev/md0 /dev/sdb mdadm: hot removed /dev/sdb from /dev/md0 Then the journal feature can be removed by echoing into the sysfs file: cat /sys/block/md0/md/consistency_policy journal echo resync > /sys/block/md0/md/consistency_policy cat /sys/block/md0/md/consistency_policy resync Signed-off-by: Song Liu <songliubraving@fb.com> Signed-off-by: Shaohua Li <shli@fb.com>
Diffstat (limited to 'drivers/md/raid5.c')
-rw-r--r--drivers/md/raid5.c46
1 files changed, 36 insertions, 10 deletions
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c
index 266d661dc69b..6036d5e41ddd 100644
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -8292,17 +8292,41 @@ static int raid5_change_consistency_policy(struct mddev *mddev, const char *buf)
8292 } 8292 }
8293 8293
8294 if (strncmp(buf, "ppl", 3) == 0 && !raid5_has_ppl(conf)) { 8294 if (strncmp(buf, "ppl", 3) == 0 && !raid5_has_ppl(conf)) {
8295 mddev_suspend(mddev); 8295 /* ppl only works with RAID 5 */
8296 set_bit(MD_HAS_PPL, &mddev->flags); 8296 if (conf->level == 5) {
8297 err = log_init(conf, NULL); 8297 mddev_suspend(mddev);
8298 if (!err) 8298 set_bit(MD_HAS_PPL, &mddev->flags);
8299 err = log_init(conf, NULL);
8300 if (!err)
8301 raid5_reset_stripe_cache(mddev);
8302 mddev_resume(mddev);
8303 } else
8304 err = -EINVAL;
8305 } else if (strncmp(buf, "resync", 6) == 0) {
8306 if (raid5_has_ppl(conf)) {
8307 mddev_suspend(mddev);
8308 log_exit(conf);
8299 raid5_reset_stripe_cache(mddev); 8309 raid5_reset_stripe_cache(mddev);
8300 mddev_resume(mddev); 8310 mddev_resume(mddev);
8301 } else if (strncmp(buf, "resync", 6) == 0 && raid5_has_ppl(conf)) { 8311 } else if (test_bit(MD_HAS_JOURNAL, &conf->mddev->flags) &&
8302 mddev_suspend(mddev); 8312 r5l_log_disk_error(conf)) {
8303 log_exit(conf); 8313 bool journal_dev_exists = false;
8304 raid5_reset_stripe_cache(mddev); 8314 struct md_rdev *rdev;
8305 mddev_resume(mddev); 8315
8316 rdev_for_each(rdev, mddev)
8317 if (test_bit(Journal, &rdev->flags)) {
8318 journal_dev_exists = true;
8319 break;
8320 }
8321
8322 if (!journal_dev_exists) {
8323 mddev_suspend(mddev);
8324 clear_bit(MD_HAS_JOURNAL, &mddev->flags);
8325 mddev_resume(mddev);
8326 } else /* need remove journal device first */
8327 err = -EBUSY;
8328 } else
8329 err = -EINVAL;
8306 } else { 8330 } else {
8307 err = -EINVAL; 8331 err = -EINVAL;
8308 } 8332 }
@@ -8337,6 +8361,7 @@ static struct md_personality raid6_personality =
8337 .quiesce = raid5_quiesce, 8361 .quiesce = raid5_quiesce,
8338 .takeover = raid6_takeover, 8362 .takeover = raid6_takeover,
8339 .congested = raid5_congested, 8363 .congested = raid5_congested,
8364 .change_consistency_policy = raid5_change_consistency_policy,
8340}; 8365};
8341static struct md_personality raid5_personality = 8366static struct md_personality raid5_personality =
8342{ 8367{
@@ -8385,6 +8410,7 @@ static struct md_personality raid4_personality =
8385 .quiesce = raid5_quiesce, 8410 .quiesce = raid5_quiesce,
8386 .takeover = raid4_takeover, 8411 .takeover = raid4_takeover,
8387 .congested = raid5_congested, 8412 .congested = raid5_congested,
8413 .change_consistency_policy = raid5_change_consistency_policy,
8388}; 8414};
8389 8415
8390static int __init raid5_init(void) 8416static int __init raid5_init(void)