[Test case]
1. Reboot the system with multiple MD RAIDs at least 10 times.
2. Make sure the system can reboot successfully every time.
3. You should not see error messages like below.
[ 205.360738] systemd-shutdown[1]: Stopping MD devices.
[ 205.366384] systemd-shutdown[1]: sd-device-enumerator: Scan all dirs
[ 205.373327] systemd-shutdown[1]: sd-device-enumerator: Scanning /sys/bus
[ 205.380427] systemd-shutdown[1]: sd-device-enumerator: Scanning /sys/class
[ 205.388257] systemd-shutdown[1]: Stopping MD /dev/md127 (9:127).
[ 205.394880] systemd-shutdown[1]: Failed to sync MD block device /dev/md127, ignoring: Input/output error
[ 205.404975] md: md127 stopped.
[ 205.470491] systemd-shutdown[1]: Stopping MD /dev/md126 (9:126).
[ 205.770179] md: md126: resync interrupted.
[ 205.776258] md126: detected capacity change from 1900396544 to 0
[ 205.783349] md: md126 stopped.
[ 205.862258] systemd-shutdown[1]: Stopping MD /dev/md125 (9:125).
[ 205.862435] md: md126 stopped.
[ 205.868376] systemd-shutdown[1]: Failed to sync MD block device /dev/md125, ignoring: Input/output error
[ 205.872845] block device autoloading is deprecated and will be removed.
[ 205.880955] md: md125 stopped.
[ 205.934349] systemd-shutdown[1]: Stopping MD /dev/md124p2 (259:7).
[ 205.947707] systemd-shutdown[1]: Could not stop MD /dev/md124p2: Device or resource busy
[ 205.957004] systemd-shutdown[1]: Stopping MD /dev/md124p1 (259:6).
[ 205.964177] systemd-shutdown[1]: Could not stop MD /dev/md124p1: Device or resource busy
[ 205.973155] systemd-shutdown[1]: Stopping MD /dev/md124 (9:124).
[ 205.979789] systemd-shutdown[1]: Could not stop MD /dev/md124: Device or resource busy
[ 205.988475] systemd-shutdown[1]: Not all MD devices stopped, 4 left.
[Where problems could occur]
It fixes the data race issue, should not introduce any regression.
[Impact]
The system with multiple MD RAIDs sometimes hangs while rebooting, that's because of the systemd can't stop and close the MD disk.
[Fix]
This commit fixes the issue.
https:/ /patchwork. kernel. org<email address hidden>/
[Test case]
1. Reboot the system with multiple MD RAIDs at least 10 times.
2. Make sure the system can reboot successfully every time.
3. You should not see error messages like below.
[ 205.360738] systemd- shutdown[ 1]: Stopping MD devices. shutdown[ 1]: sd-device- enumerator: Scan all dirs shutdown[ 1]: sd-device- enumerator: Scanning /sys/bus shutdown[ 1]: sd-device- enumerator: Scanning /sys/class shutdown[ 1]: Stopping MD /dev/md127 (9:127). shutdown[ 1]: Failed to sync MD block device /dev/md127, ignoring: Input/output error shutdown[ 1]: Stopping MD /dev/md126 (9:126). shutdown[ 1]: Stopping MD /dev/md125 (9:125). shutdown[ 1]: Failed to sync MD block device /dev/md125, ignoring: Input/output error shutdown[ 1]: Stopping MD /dev/md124p2 (259:7). shutdown[ 1]: Could not stop MD /dev/md124p2: Device or resource busy shutdown[ 1]: Stopping MD /dev/md124p1 (259:6). shutdown[ 1]: Could not stop MD /dev/md124p1: Device or resource busy shutdown[ 1]: Stopping MD /dev/md124 (9:124). shutdown[ 1]: Could not stop MD /dev/md124: Device or resource busy shutdown[ 1]: Not all MD devices stopped, 4 left.
[ 205.366384] systemd-
[ 205.373327] systemd-
[ 205.380427] systemd-
[ 205.388257] systemd-
[ 205.394880] systemd-
[ 205.404975] md: md127 stopped.
[ 205.470491] systemd-
[ 205.770179] md: md126: resync interrupted.
[ 205.776258] md126: detected capacity change from 1900396544 to 0
[ 205.783349] md: md126 stopped.
[ 205.862258] systemd-
[ 205.862435] md: md126 stopped.
[ 205.868376] systemd-
[ 205.872845] block device autoloading is deprecated and will be removed.
[ 205.880955] md: md125 stopped.
[ 205.934349] systemd-
[ 205.947707] systemd-
[ 205.957004] systemd-
[ 205.964177] systemd-
[ 205.973155] systemd-
[ 205.979789] systemd-
[ 205.988475] systemd-
[Where problems could occur]
It fixes the data race issue, should not introduce any regression.