Commit 339421de authored by Song Liu's avatar Song Liu Committed by NeilBrown

MD: when RAID journal is missing/faulty, block RESTART_ARRAY_RW

When RAID-4/5/6 array suffers from missing journal device, we put
the array in read only state. We should not allow trasition to
read-write states (clean and active) before replacing journal device.
Signed-off-by: default avatarSong Liu <songliubraving@fb.com>
Signed-off-by: default avatarShaohua Li <shli@fb.com>
Signed-off-by: default avatarNeilBrown <neilb@suse.com>
parent f2076e7d
...@@ -3970,7 +3970,9 @@ array_state_store(struct mddev *mddev, const char *buf, size_t len) ...@@ -3970,7 +3970,9 @@ array_state_store(struct mddev *mddev, const char *buf, size_t len)
break; break;
case clean: case clean:
if (mddev->pers) { if (mddev->pers) {
restart_array(mddev); err = restart_array(mddev);
if (err)
break;
spin_lock(&mddev->lock); spin_lock(&mddev->lock);
if (atomic_read(&mddev->writes_pending) == 0) { if (atomic_read(&mddev->writes_pending) == 0) {
if (mddev->in_sync == 0) { if (mddev->in_sync == 0) {
...@@ -3988,7 +3990,9 @@ array_state_store(struct mddev *mddev, const char *buf, size_t len) ...@@ -3988,7 +3990,9 @@ array_state_store(struct mddev *mddev, const char *buf, size_t len)
break; break;
case active: case active:
if (mddev->pers) { if (mddev->pers) {
restart_array(mddev); err = restart_array(mddev);
if (err)
break;
clear_bit(MD_CHANGE_PENDING, &mddev->flags); clear_bit(MD_CHANGE_PENDING, &mddev->flags);
wake_up(&mddev->sb_wait); wake_up(&mddev->sb_wait);
err = 0; err = 0;
...@@ -5351,6 +5355,25 @@ static int restart_array(struct mddev *mddev) ...@@ -5351,6 +5355,25 @@ static int restart_array(struct mddev *mddev)
return -EINVAL; return -EINVAL;
if (!mddev->ro) if (!mddev->ro)
return -EBUSY; return -EBUSY;
if (test_bit(MD_HAS_JOURNAL, &mddev->flags)) {
struct md_rdev *rdev;
bool has_journal = false;
rcu_read_lock();
rdev_for_each_rcu(rdev, mddev) {
if (test_bit(Journal, &rdev->flags) &&
!test_bit(Faulty, &rdev->flags)) {
has_journal = true;
break;
}
}
rcu_read_unlock();
/* Don't restart rw with journal missing/faulty */
if (!has_journal)
return -EINVAL;
}
mddev->safemode = 0; mddev->safemode = 0;
mddev->ro = 0; mddev->ro = 0;
set_disk_ro(disk, 0); set_disk_ro(disk, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment