[PATCH] Do not assemble a duplicate of a running array

Yury Polyanskiy yp at mit.edu
Mon Jul 11 01:04:11 UTC 2011


Dear mdadm developers,

Consider the following scenario (based on true story):

SETUP:
* a raid1 MD array is configured with the name /dev/md/data (metadata=1.0).
* /dev/md/data is identified in the /etc/mdadm/mdadm.conf by its UUID
* /dev/md/data is assembled from the initramfs with minor /dev/md127

CRASH:
* [GLITCH] at some point one of the disks (/dev/sda) comprising /dev/md/data
experiences a bus-failure and is correctly removed from the array.
* array runs for some time in degraded state, data is being written and read
from the remaining disks (/dev/sdb, sdc etc)
* [REBOOT] after some time, the server is rebooted
* at boot time initramfs script starts /dev/md/data, but kernel correctly
kicks out /dev/sda from the array because the Event Counter is too old
('kicking non-fresh sda from array').
* when udev starts, "mdadm --detail --export /dev/md127" correctly
identifies /dev/md127 and UDEV creates a correct symbolic link:
   /dev/md/data -> /dev/md127

* startup proceeds to execute /etc/init.d/mdadm-raid which runs "mdadm
--assemble --scan".
* mdadm --assemble --scan discovers the description of /dev/md/data in
mdadm.conf and finds a lonely /dev/sda with a matching UUID; /dev/md126 is
created out of a single /dev/sda
* now udev receives an ADD event for /sys/block/md126; again "mdadm --detail
--export /dev/md126" says that this device must be named /dev/md/data. UDEV
then re-creates the symbolic link, which now points to /dev/md126:
   /dev/md/data -> /dev/md126

* startup proceeds and /dev/md/data is mounted as a /home partition.

CONCLUSION:
* data written to /dev/md/data between GLITCH and REBOOT is lost.
* data written to /dev/md/data after REBOOT is stored on a buggy /dev/sda
instead of a sane array (/dev/sdb,/dev/sdc)


PATCH:
* attached is a patch against the master of git://
anonscm.debian.org/pkg-mdadm/mdadm.git


Best wishes,
Yury Polyanskiy

PS. Please CC me, I am not on the list.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/pkg-mdadm-devel/attachments/20110710/6cc65081/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: debian-uuidfix.patch
Type: text/x-patch
Size: 6050 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/pkg-mdadm-devel/attachments/20110710/6cc65081/attachment.bin>


More information about the pkg-mdadm-devel mailing list