Skip to content

Commit 0bb0c10

Browse files
liu-song-6shligit
authored andcommitted
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>
1 parent 1ad45a9 commit 0bb0c10

File tree

1 file changed

+36
-10
lines changed

1 file changed

+36
-10
lines changed

drivers/md/raid5.c

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8292,17 +8292,41 @@ static int raid5_change_consistency_policy(struct mddev *mddev, const char *buf)
82928292
}
82938293

82948294
if (strncmp(buf, "ppl", 3) == 0 && !raid5_has_ppl(conf)) {
8295-
mddev_suspend(mddev);
8296-
set_bit(MD_HAS_PPL, &mddev->flags);
8297-
err = log_init(conf, NULL);
8298-
if (!err)
8295+
/* ppl only works with RAID 5 */
8296+
if (conf->level == 5) {
8297+
mddev_suspend(mddev);
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);
82998309
raid5_reset_stripe_cache(mddev);
8300-
mddev_resume(mddev);
8301-
} else if (strncmp(buf, "resync", 6) == 0 && raid5_has_ppl(conf)) {
8302-
mddev_suspend(mddev);
8303-
log_exit(conf);
8304-
raid5_reset_stripe_cache(mddev);
8305-
mddev_resume(mddev);
8310+
mddev_resume(mddev);
8311+
} else if (test_bit(MD_HAS_JOURNAL, &conf->mddev->flags) &&
8312+
r5l_log_disk_error(conf)) {
8313+
bool journal_dev_exists = false;
8314+
struct md_rdev *rdev;
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;
83068330
} else {
83078331
err = -EINVAL;
83088332
}
@@ -8337,6 +8361,7 @@ static struct md_personality raid6_personality =
83378361
.quiesce = raid5_quiesce,
83388362
.takeover = raid6_takeover,
83398363
.congested = raid5_congested,
8364+
.change_consistency_policy = raid5_change_consistency_policy,
83408365
};
83418366
static struct md_personality raid5_personality =
83428367
{
@@ -8385,6 +8410,7 @@ static struct md_personality raid4_personality =
83858410
.quiesce = raid5_quiesce,
83868411
.takeover = raid4_takeover,
83878412
.congested = raid5_congested,
8413+
.change_consistency_policy = raid5_change_consistency_policy,
83888414
};
83898415

83908416
static int __init raid5_init(void)

0 commit comments

Comments
 (0)