Skip to content

Commit 7b74857

Browse files
mgmlmepeluse
authored andcommitted
md/raid1,raid10: Fix: Operation continuing on 0 devices.
Since commit 9a56784 ("md: allow last device to be forcibly removed from RAID1/RAID10."), RAID1/10 arrays can now lose all rdevs. Before that commit, losing the array last rdev or reaching the end of the function without early return in raid{1,10}_error never occurred. However, both situations can occur in the current implementation. As a result, when mddev->fail_last_dev is set, a spurious pr_crit message can be printed. This patch prevents "Operation continuing" printed if the array is not operational. root@fedora:~# mdadm --create --verbose /dev/md0 --level=1 \ --raid-devices=2 /dev/loop0 /dev/loop1 mdadm: Note: this array has metadata at the start and may not be suitable as a boot device. If you plan to store '/boot' on this device please ensure that your boot-loader understands md/v1.x metadata, or use --metadata=0.90 mdadm: size set to 1046528K Continue creating array? y mdadm: Defaulting to version 1.2 metadata mdadm: array /dev/md0 started. root@fedora:~# echo 1 > /sys/block/md0/md/fail_last_dev root@fedora:~# mdadm --fail /dev/md0 loop0 mdadm: set loop0 faulty in /dev/md0 root@fedora:~# mdadm --fail /dev/md0 loop1 mdadm: set device faulty failed for loop1: Device or resource busy root@fedora:~# dmesg | tail -n 4 [ 1314.359674] md/raid1:md0: Disk failure on loop0, disabling device. md/raid1:md0: Operation continuing on 1 devices. [ 1315.506633] md/raid1:md0: Disk failure on loop1, disabling device. md/raid1:md0: Operation continuing on 0 devices. root@fedora:~# Fixes: 9a56784 ("md: allow last device to be forcibly removed from RAID1/RAID10.") Signed-off-by: Kenta Akagi <[email protected]>
1 parent 2240d1e commit 7b74857

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

drivers/md/raid1.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,17 +1785,18 @@ static void raid1_error(struct mddev *mddev, struct md_rdev *rdev)
17851785
if (test_and_clear_bit(In_sync, &rdev->flags))
17861786
mddev->degraded++;
17871787
set_bit(Faulty, &rdev->flags);
1788+
if ((conf->raid_disks - mddev->degraded) > 0)
1789+
pr_crit("md/raid1:%s: Disk failure on %pg, disabling device.\n"
1790+
"md/raid1:%s: Operation continuing on %d devices.\n",
1791+
mdname(mddev), rdev->bdev,
1792+
mdname(mddev), conf->raid_disks - mddev->degraded);
17881793
spin_unlock_irqrestore(&conf->device_lock, flags);
17891794
/*
17901795
* if recovery is running, make sure it aborts.
17911796
*/
17921797
set_bit(MD_RECOVERY_INTR, &mddev->recovery);
17931798
set_mask_bits(&mddev->sb_flags, 0,
17941799
BIT(MD_SB_CHANGE_DEVS) | BIT(MD_SB_CHANGE_PENDING));
1795-
pr_crit("md/raid1:%s: Disk failure on %pg, disabling device.\n"
1796-
"md/raid1:%s: Operation continuing on %d devices.\n",
1797-
mdname(mddev), rdev->bdev,
1798-
mdname(mddev), conf->raid_disks - mddev->degraded);
17991800
}
18001801

18011802
static void print_conf(struct r1conf *conf)

drivers/md/raid10.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,11 +2034,12 @@ static void raid10_error(struct mddev *mddev, struct md_rdev *rdev)
20342034
set_bit(Faulty, &rdev->flags);
20352035
set_mask_bits(&mddev->sb_flags, 0,
20362036
BIT(MD_SB_CHANGE_DEVS) | BIT(MD_SB_CHANGE_PENDING));
2037+
if (enough(conf, -1))
2038+
pr_crit("md/raid10:%s: Disk failure on %pg, disabling device.\n"
2039+
"md/raid10:%s: Operation continuing on %d devices.\n",
2040+
mdname(mddev), rdev->bdev,
2041+
mdname(mddev), conf->geo.raid_disks - mddev->degraded);
20372042
spin_unlock_irqrestore(&conf->device_lock, flags);
2038-
pr_crit("md/raid10:%s: Disk failure on %pg, disabling device.\n"
2039-
"md/raid10:%s: Operation continuing on %d devices.\n",
2040-
mdname(mddev), rdev->bdev,
2041-
mdname(mddev), conf->geo.raid_disks - mddev->degraded);
20422043
}
20432044

20442045
static void print_conf(struct r10conf *conf)

0 commit comments

Comments
 (0)