Red Hat Bugzilla – Bug 1007406
LVM on Raid 1 array gets stuck in read only after reboot when lvmetad+lvm autoactivation is used
Last modified: 2013-11-21 18:28:17 EST
[0] raw/~ # mdadm --create --verbose /dev/md0 --level=mirror --raid-devices=2 /dev/sda /dev/sdb mdadm: /dev/sda appears to be part of a raid array: level=raid1 devices=2 ctime=Thu Aug 22 12:15:05 2013 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: /dev/sdb appears to be part of a raid array: level=raid1 devices=2 ctime=Thu Aug 22 12:15:05 2013 mdadm: size set to 130944K Continue creating array? y mdadm: Defaulting to version 1.2 metadata mdadm: array /dev/md0 started. [0] raw/~ # pvcreate /dev/md0 Physical volume "/dev/md0" successfully created [0] raw/~ # vgcreate vg /dev/md0 Volume group "vg" successfully created [0] raw/~ # lvcreate -l1 vg Logical volume "lvol0" created [0] raw/~ # dmsetup info -c -o name,attr Name Stat fedora_raw-swap L--w fedora_raw-root L--w [0] raw/~ # vgchange -ay vg 1 logical volume(s) in volume group "vg" now active [0] raw/~ # dmsetup info -c -o name,attr Name Stat fedora_raw-swap L--w vg-lvol0 L--w fedora_raw-root L--w [0] raw/~ # vgchange -an vg 0 logical volume(s) in volume group "vg" now active [0] raw/~ # dmsetup info -c -o name,attr Name Stat fedora_raw-swap L--w fedora_raw-root L--w [0] raw/~ # mdadm -S /dev/md0 mdadm: stopped /dev/md0 [0] raw/~ # dmsetup info -c -o name,attr Name Stat fedora_raw-swap L--w vg-lvol0 ---w fedora_raw-root L--w And assosciated log from dmesg after mdadm -S: [ 5046.297812] md: md0 still in use. [ 5046.333193] device-mapper: table: 253:2: linear: dm-linear: Device lookup failed [ 5046.336647] device-mapper: ioctl: error adding target to table [ 5046.500320] md0: detected capacity change from 134086656 to 0 [ 5046.503839] md: md0 stopped. [ 5046.505986] md: unbind<sdb> [ 5046.506862] md: export_rdev(sdb) [ 5046.507715] md: unbind<sda> [ 5046.510534] md: export_rdev(sda) And udev log after mdadm -S: [1] raw/~ # udevadm monitor --kernel monitor will print the received events for: KERNEL - the kernel uevent KERNEL[5046.296878] change /devices/virtual/block/md0 (block) KERNEL[5046.330424] add /devices/virtual/bdi/253:2 (bdi) KERNEL[5046.331208] add /devices/virtual/block/dm-2 (block) KERNEL[5046.511436] change /devices/virtual/block/md0 (block) KERNEL[5046.511777] change /devices/virtual/block/md0 (block) KERNEL[5046.512331] remove /devices/virtual/bdi/9:0 (bdi) KERNEL[5046.512496] remove /devices/virtual/block/md0 (block) So there's a CHANGE event followed by REMOVE event when stopping the MD array. The CHANGE event for md0 causes the autoactivation to trigger. At the time the LVM on MD is autoactivated, the MD itself is removed. That explains why we end up with the vg-lvol0 created, but not loaded - the MD underneath is already gone when trying to load the table: [ 5046.333193] device-mapper: table: 253:2: linear: dm-linear: Device lookup failed So what we need is to filter out that CHANGE even that's just before REMOVE... That's going to be a little bit harde since the CHANGE even before REMOVE is exactly the same as the CHANGE event that notifies about MD array activation (there's no variable we could make a comparison with).is lvmdump I hope) --- Additional comment from Peter Rajnoha on 2013-09-11 13:42:32 CEST --- This patch should fix the issues reported: https://git.fedorahosted.org/cgit/lvm2.git/commit/?id=8d1d83504dcf9c86ad42d34d3bd0b201d7bab8f6
The bug #1002144 is also an incarnation of this bug - incorrect MD handling while trying to scan the PVs to update lvmetad and running autoactivation at improper time.
Could not reproduce this problem with lvm2-2.02.100-5.el6.x86_64 Both with a running system and commands as stated above, and with a reboot. Everything worked, no read-only occurences (with use_lvmetad=1 and lvm2-lvmetad on). Marking this concrete case as VERIFIED.
Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. http://rhn.redhat.com/errata/RHBA-2013-1704.html