Bug 1007406 - LVM on Raid 1 array gets stuck in read only after reboot when lvmetad+lvm autoactivation is used
LVM on Raid 1 array gets stuck in read only after reboot when lvmetad+lvm aut...
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: lvm2 (Show other bugs)
6.5
x86_64 Linux
medium Severity high
: rc
: ---
Assigned To: Peter Rajnoha
Cluster QE
:
Depends On: 985638
Blocks:
  Show dependency treegraph
 
Reported: 2013-09-12 08:29 EDT by Peter Rajnoha
Modified: 2013-11-21 18:28 EST (History)
19 users (show)

See Also:
Fixed In Version: lvm2-2.02.100-3.el6
Doc Type: Bug Fix
Doc Text:
When using MD RAID devices as PVs on top of which LVM logical volumes are defined and while lvmetad is enabled at the same time (global/use_lvmetad=1 lvm.conf setting), the accompanying logical volume autoactivation that is used together with lvmetad could cause dangling incomplete device-mapper devices representing logical volumes to be left in the system. This also kept the system in inconsistent state where the logical volumes could not be activated any further without manual cleanup of the dangling device-mapper devices. This was caused by triggering the LVM autoactivation at improper time during MD RAID array setup or deactivation. When the MD RAID array is not yet set up completely or it is being deactivated, the autoactivation of LVM logical volumes on top of it fails. This has been fixed and the LVM logical volume is autoactivated at proper time only when the MD RAID device is ready for use.
Story Points: ---
Clone Of: 985638
Environment:
Last Closed: 2013-11-21 18:28:17 EST
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Peter Rajnoha 2013-09-12 08:29:59 EDT
[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
Comment 1 Peter Rajnoha 2013-09-12 08:31:55 EDT
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.
Comment 3 Nenad Peric 2013-10-15 10:01:09 EDT
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.
Comment 4 errata-xmlrpc 2013-11-21 18:28:17 EST
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

Note You need to log in before you can comment on or make changes to this bug.