Description of problem: If you attempt to alter a stripe LV converted to a mirror, it's possible that only one of the legs (the non striped one) will get altered, and that will cause corruption. [root@grant-01 ~]# pvcreate /dev/sd[bc][12356] Physical volume "/dev/sdb1" successfully created Physical volume "/dev/sdb2" successfully created Physical volume "/dev/sdb3" successfully created Physical volume "/dev/sdb5" successfully created Physical volume "/dev/sdb6" successfully created Physical volume "/dev/sdc1" successfully created Physical volume "/dev/sdc2" successfully created Physical volume "/dev/sdc3" successfully created Physical volume "/dev/sdc5" successfully created Physical volume "/dev/sdc6" successfully created [root@grant-01 ~]# vgcreate grant /dev/sd[bc][12356] Clustered volume group "grant" successfully created [root@grant-01 ~]# lvcreate -L 1G --stripes 7 --stripesize 512 -n stripe grant Rounding size (256 extents) up to stripe boundary size (259 extents) Logical volume "stripe" created [root@grant-01 ~]# lvs -a -o +devices LV VG Attr LSize Devices stripe grant -wi-a- 1.01G /dev/sdb1(0),/dev/sdb2(0),/dev/sdb3(0),/dev/sdb5(0),/dev/sdb6(0),/dev/sdc1(0),/dev/sdc2(0) [root@grant-01 ~]# lvconvert -m 1 grant/stripe grant/stripe: Converted: 5.8% grant/stripe: Converted: 77.2% grant/stripe: Converted: 100.0% # NOTE THE CONVERTED LEG IS NOT STRIPED (ALREADY A KNOWN ISSUE) [root@grant-01 ~]# lvs -a -o +devices LV VG Attr LSize Log Copy% Devices stripe grant mwi-a- 1.01G stripe_mlog 100.00 stripe_mimage_0(0),stripe_mimage_1(0) [stripe_mimage_0] grant iwi-ao 1.01G /dev/sdb1(0),/dev/sdb2(0),/dev/sdb3(0),/dev/sdb5(0),/dev/sdb6(0),/dev/sdc1(0),/dev/sdc2(0) [stripe_mimage_1] grant iwi-ao 1.01G /dev/sdc3(0) [stripe_mlog] grant lwi-ao 4.00M /dev/sdc6(0) [root@grant-01 ~]# lvdisplay grant/stripe | grep Current Current LE 259 [root@grant-01 ~]# lvreduce -f -l 202 grant/stripe WARNING: Reducing active logical volume to 808.00 MB THIS MAY DESTROY YOUR DATA (filesystem etc.) Reducing logical volume stripe to 808.00 MB Segment extent reduction 57not divisible by #stripes 7 Logical volume stripe successfully resized [root@grant-01 ~]# echo $? 0 [root@grant-01 ~]# lvdisplay grant/stripe | grep Current Current LE 202 [root@grant-01 ~]# lvextend -l 241 grant/stripe Extending 2 mirror images. Using stripesize of last segment 512.00 KB Rounding size (241 extents) down to stripe boundary size for segment (237 extents) Extending logical volume stripe to 948.00 MB Not enough PVs with free space available for parallel allocation. Consider --alloc anywhere if desperate. # NOTE THAT ONLY THE NON STRIPED LEG WAS EVER REDUCED! [root@grant-01 ~]# lvs -a -o +devices LV VG Attr LSize Log Copy% Devices stripe grant mwi-a- 808.00M stripe_mlog 100.00 stripe_mimage_0(0),stripe_mimage_1(0) [stripe_mimage_0] grant iwi-ao 1.01G /dev/sdb1(0),/dev/sdb2(0),/dev/sdb3(0),/dev/sdb5(0),/dev/sdb6(0),/dev/sdc1(0),/dev/sdc2(0) [stripe_mimage_1] grant iwi-ao 808.00M /dev/sdc3(0) [stripe_mlog] grant lwi-ao 4.00M /dev/sdc6(0) [root@grant-01 ~]# vgchange -an grant 0 logical volume(s) in volume group "grant" now active [root@grant-01 ~]# lvremove grant Segment extent reduction 202not divisible by #stripes 7 LV segment stripe:0-4294967295 is incorrectly listed as being used by LV stripe_mimage_0 Internal error: LV segments corrupted in stripe_mimage_0. Version-Release number of selected component (if applicable): 2.6.18-261.el5 lvm2-2.02.84-3.el5 BUILT: Wed Apr 27 03:42:24 CDT 2011 lvm2-cluster-2.02.84-3.el5 BUILT: Wed Apr 27 03:42:43 CDT 2011 device-mapper-1.02.63-3.el5 BUILT: Thu May 19 08:09:22 CDT 2011 device-mapper-event-1.02.63-3.el5 BUILT: Thu May 19 08:09:22 CDT 2011 cmirror-1.1.39-10.el5 BUILT: Wed Sep 8 16:32:05 CDT 2010 kmod-cmirror-0.1.22-3.el5 BUILT: Tue Dec 22 13:39:47 CST 2009 How reproducible: EVERYTIME
This issue most likely exists in RHEL6.1 as well.
First bug is in lvreduce (I've not looked beyond that). Reproduced with upstream code. vg_validate() needs fixing to detect metadata corruption like this as well.
When it hit the error: Segment extent reduction 57not divisible by #stripes 7 it should have either aborted the operation (or rounded the size to something compatible, maybe earlier in the code) instead of carrying on and writing out corrupted metadata.
(1) fix vg_validate to ensure that if a segment is mirrored, the size of every mimage matches (2) fix lvreduce to abort if it gets that error instead of ignoring it (3) fix the rounding logic to check all segments and round the size appropriately (common factor logic) - the only difficult part of this fix Item (1) should be sufficient to avoid the corruption; item (2) gives a clean error; item (3) makes the command work as intended. reproducer: lvcreate -i2; lvconvert -m1; lvreduce -l1 then compare LSize in lvs -a
I'll add at least 1) + 2) to 5.7 so it cannot corrupt VG metadata.
Fixed in lvm2-2.02.84-5.el5 lvm2-cluster-2.02.84-5.el5 full fix included.
Roundig up logic hopefully fixed in lvm2-2.02.84-6.el5
Fix verified in the latest rpms. 2.6.18-266.el5 lvm2-2.02.84-6.el5 BUILT: Thu Jun 16 10:31:15 CDT 2011 lvm2-cluster-2.02.84-6.el5 BUILT: Thu Jun 16 10:32:56 CDT 2011 device-mapper-1.02.63-3.el5 BUILT: Thu May 19 08:09:22 CDT 2011 device-mapper-event-1.02.63-3.el5 BUILT: Thu May 19 08:09:22 CDT 2011 cmirror-1.1.39-10.el5 BUILT: Wed Sep 8 16:32:05 CDT 2010 kmod-cmirror-0.1.22-3.el5 BUILT: Tue Dec 22 13:39:47 CST 2009 [root@taft-01 ~]# pvcreate /dev/sd[bc][12356] Physical volume "/dev/sdb1" successfully created Physical volume "/dev/sdb2" successfully created Physical volume "/dev/sdb3" successfully created Physical volume "/dev/sdb5" successfully created Physical volume "/dev/sdb6" successfully created Physical volume "/dev/sdc1" successfully created Physical volume "/dev/sdc2" successfully created Physical volume "/dev/sdc3" successfully created Physical volume "/dev/sdc5" successfully created Physical volume "/dev/sdc6" successfully created [root@taft-01 ~]# vgcreate grant /dev/sd[bc][12356] Volume group "grant" successfully created [root@taft-01 ~]# lvcreate -L 1G --stripes 7 --stripesize 512 -n stripe grant Rounding size (256 extents) up to stripe boundary size (259 extents) Logical volume "stripe" created [root@taft-01 ~]# lvs -a -o +devices LV VG Attr LSize Devices stripe grant -wi-a- 1.01G /dev/sdb1(0),/dev/sdb2(0),/dev/sdb3(0),/dev/sdb5(0),/dev/sdb6(0),/dev/sdc1(0),/dev/sdc2(0) [root@taft-01 ~]# lvconvert -m 1 grant/stripe grant/stripe: Converted: 0.4% grant/stripe: Converted: 25.1% grant/stripe: Converted: 50.2% grant/stripe: Converted: 75.7% grant/stripe: Converted: 100.0% [root@taft-01 ~]# lvs -a -o +devices LV VG Attr LSize Log Copy% Devices stripe grant mwi-a- 1.01G stripe_mlog 100.00 stripe_mimage_0(0),stripe_mimage_1(0) [stripe_mimage_0] grant iwi-ao 1.01G /dev/sdb1(0),/dev/sdb2(0),/dev/sdb3(0),/dev/sdb5(0),/dev/sdb6(0),/dev/sdc1(0),/dev/sdc2(0) [stripe_mimage_1] grant iwi-ao 1.01G /dev/sdc3(0) [stripe_mlog] grant lwi-ao 4.00M /dev/sdc6(0) [root@taft-01 ~]# lvdisplay grant/stripe | grep Current Current LE 259 [root@taft-01 ~]# lvreduce -f -l 202 grant/stripe Rounding size (202 extents) up to stripe boundary size for segment (203 extents) WARNING: Reducing active logical volume to 812.00 MB THIS MAY DESTROY YOUR DATA (filesystem etc.) Reducing logical volume stripe to 812.00 MB Logical volume stripe successfully resized [root@taft-01 ~]# echo $? 0 [root@taft-01 ~]# lvdisplay grant/stripe | grep Current Current LE 203 [root@taft-01 ~]# lvextend -l 241 grant/stripe Extending 2 mirror images. Using stripesize of last segment 512.00 KB Rounding size (241 extents) down to stripe boundary size for segment (238 extents) Extending logical volume stripe to 952.00 MB Not enough PVs with free space available for parallel allocation. Consider --alloc anywhere if desperate. [root@taft-01 ~]# lvs -a -o +devices LV VG Attr LSize Log Copy% Devices stripe grant mwi-a- 812.00M stripe_mlog 100.00 stripe_mimage_0(0),stripe_mimage_1(0) [stripe_mimage_0] grant iwi-ao 812.00M /dev/sdb1(0),/dev/sdb2(0),/dev/sdb3(0),/dev/sdb5(0),/dev/sdb6(0),/dev/sdc1(0),/dev/sdc2(0) [stripe_mimage_1] grant iwi-ao 812.00M /dev/sdc3(0) [stripe_mlog] grant lwi-ao 4.00M /dev/sdc6(0) [root@taft-01 ~]# vgchange -an grant 0 logical volume(s) in volume group "grant" now active [root@taft-01 ~]# lvremove grant Logical volume "stripe" successfully removed
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on therefore solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2011-1071.html