MT#57049 Ensure SW-RAID device is inactive before re-reading partition table

Re-reading of disks fails if the mdadm SW-RAID device is still active:

| root@sp1 ~ # cat /proc/mdstat
| Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
| md0 : active raid1 sdb3[1] sda3[0]
|       468218880 blocks super 1.2 [2/2] [UU]
|       [========>............]  resync = 42.2% (197855168/468218880) finish=22.4min speed=200756K/sec
|       bitmap: 3/4 pages [12KB], 65536KB chunk
|
| unused devices: <none>
| root@sp1 ~ # blockdev --rereadpt /dev/sdb
| blockdev: ioctl error on BLKRRPART: Device or resource busy
| 1 root@sp1 ~ # blockdev --rereadpt /dev/sda
| blockdev: ioctl error on BLKRRPART: Device or resource busy
| 1 root@sp1 ~ #

Only if we stop the mdadm SW-RAID device, then we can re-read the
partition table:

| root@sp1 ~ # mdadm --stop /dev/md0
| mdadm: stopped /dev/md0
| root@sp1 ~ # blockdev --rereadpt /dev/sda
| root@sp1 ~ #

This behavior isn't new and unrelated to Debian/bookworm but was spotted
while debugging an unrelated issue.

FTR: we re-read the partition table (via `blockdev --rereadpt`) to ensure
that /etc/fstab of the live system is up2date and matches the current
system state. While this isn't stricly needed, we preserve existing
behavior and also try to avoid a hard "cut" of a possibly ongoing
SW-RAID sync.

Change-Id: I735b00423e6efa932f74b78a38ed023576e5d306
mr11.4
Michael Prokop 2 years ago
parent 2ad306c465
commit f4da3e094e

@ -2437,6 +2437,9 @@ if [[ "${SWRAID}" = "true" ]] ; then
echo "Cloning EFI partition from ${efidev1} to ${efidev2}"
dd if="${efidev1}" of="${efidev2}" bs=10M
fi
echo "Ensuring ${SWRAID_DEVICE} is stopped"
mdadm --stop "${SWRAID_DEVICE}" || true
fi
if ! blockdev --rereadpt "/dev/${DISK}" ; then

Loading…
Cancel
Save