summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorYufen Yu <yuyufen@huawei.com>2019-09-03 21:12:41 +0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-10-05 12:48:00 +0200
commit440c3706f1d1835d24ba5b4bbe6515e0a97e886c (patch)
treee30981ecc84d36123657ac30ac63941078136962 /drivers
parenta48898d8259d081cfcbd6f2a8feab21fb17ce652 (diff)
downloadlinux-stable-440c3706f1d1835d24ba5b4bbe6515e0a97e886c.tar.gz
linux-stable-440c3706f1d1835d24ba5b4bbe6515e0a97e886c.tar.bz2
linux-stable-440c3706f1d1835d24ba5b4bbe6515e0a97e886c.zip
md/raid1: fail run raid1 array when active disk less than one
[ Upstream commit 07f1a6850c5d5a65c917c3165692b5179ac4cb6b ] When run test case: mdadm -CR /dev/md1 -l 1 -n 4 /dev/sd[a-d] --assume-clean --bitmap=internal mdadm -S /dev/md1 mdadm -A /dev/md1 /dev/sd[b-c] --run --force mdadm --zero /dev/sda mdadm /dev/md1 -a /dev/sda echo offline > /sys/block/sdc/device/state echo offline > /sys/block/sdb/device/state sleep 5 mdadm -S /dev/md1 echo running > /sys/block/sdb/device/state echo running > /sys/block/sdc/device/state mdadm -A /dev/md1 /dev/sd[a-c] --run --force mdadm run fail with kernel message as follow: [ 172.986064] md: kicking non-fresh sdb from array! [ 173.004210] md: kicking non-fresh sdc from array! [ 173.022383] md/raid1:md1: active with 0 out of 4 mirrors [ 173.022406] md1: failed to create bitmap (-5) In fact, when active disk in raid1 array less than one, we need to return fail in raid1_run(). Reviewed-by: NeilBrown <neilb@suse.de> Signed-off-by: Yufen Yu <yuyufen@huawei.com> Signed-off-by: Song Liu <songliubraving@fb.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/md/raid1.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c
index 762d21c84774..f46ac9db9edb 100644
--- a/drivers/md/raid1.c
+++ b/drivers/md/raid1.c
@@ -3099,6 +3099,13 @@ static int raid1_run(struct mddev *mddev)
!test_bit(In_sync, &conf->mirrors[i].rdev->flags) ||
test_bit(Faulty, &conf->mirrors[i].rdev->flags))
mddev->degraded++;
+ /*
+ * RAID1 needs at least one disk in active
+ */
+ if (conf->raid_disks - mddev->degraded < 1) {
+ ret = -EINVAL;
+ goto abort;
+ }
if (conf->raid_disks - mddev->degraded == 1)
mddev->recovery_cp = MaxSector;
@@ -3132,8 +3139,12 @@ static int raid1_run(struct mddev *mddev)
ret = md_integrity_register(mddev);
if (ret) {
md_unregister_thread(&mddev->thread);
- raid1_free(mddev, conf);
+ goto abort;
}
+ return 0;
+
+abort:
+ raid1_free(mddev, conf);
return ret;
}