The issue:
- raid1 will be in degraded state if one of its components is logical volume (LV)
- raid0 will be inoperable at all (inacessible from within appliance) if one of its
component is LV
- raidN: you can expect the same issue for any raid level depends on how many components
are inaccessible at the time mdadm is running and raid redundency.
It happens because mdadm is launched prior to lvm AND it is instructed to run found arrays
immediately (--run flag) regardless of completeness of their components.
Later (when lvm activates found LVs) md signature on LV might be recognized BUT newly
found raid components could't be inserted into already running (in degraded state)
or marked as inoperable raid arrays.
The patch fixes the issue in the following way:
1. Found arrays won't be run immediately unless ALL expected drives (components) are
present. Here '--no-degraded' flag comes into a play. See mdadm(8).
2. Second mdadm call (after LVM is scanned) will scan UNUSED yet devices and make an
attempt to run all found arrays (even they will be in degraded state).
There is no performance penalty because second pass scans UNUSED yet devices. Here is
'boot-benchmark' before and after patch:
: libvirt backend : direct backend
------------------------------------------------
master : 835.2ms ±1.1ms : 670.4ms ±0.3ms
master+patch : 837.7ms ±2.4ms : 671.8ms ±0.2ms
---
appliance/init | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/appliance/init b/appliance/init
index c04ee45..6a61a8d 100755
--- a/appliance/init
+++ b/appliance/init
@@ -130,14 +130,16 @@ if test "$guestfs_network" = 1; then
fi
fi
-# Scan for MDs.
-mdadm -As --auto=yes --run
+# Scan for MDs but don't run arrays unless all expected drives are present
+mdadm -As --auto=yes --no-degraded
# Scan for LVM.
modprobe dm_mod ||:
-
lvm vgchange -aay --sysinit
+# Scan for MDs and run all found arrays even they are in degraded state
+mdadm -As --auto=yes --run
+
# Scan for Windows dynamic disks.
ldmtool create all
@@ -146,6 +148,7 @@ if test "$guestfs_verbose" = 1 && test
"$guestfs_boot_analysis" != 1; then
uname -a
ls -lR /dev
cat /proc/mounts
+ cat /proc/mdstat
lvm pvs
lvm vgs
lvm lvs
--
2.9.5