Bug 710618 - mirrored stripe volume gets corrupted when reduce only alters one leg
Summary: mirrored stripe volume gets corrupted when reduce only alters one leg
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 5
Classification: Red Hat
Component: lvm2
Version: 5.7
Hardware: x86_64
OS: Linux
urgent
urgent
Target Milestone: rc
: ---
Assignee: Milan Broz
QA Contact: Corey Marthaler
URL:
Whiteboard:
Depends On:
Blocks: 723065
TreeView+ depends on / blocked
 
Reported: 2011-06-03 20:51 UTC by Corey Marthaler
Modified: 2013-03-01 04:10 UTC (History)
12 users (show)

Fixed In Version: lvm2-2.02.84-6.el5
Doc Type: Bug Fix
Doc Text:
Clone Of:
: 723065 (view as bug list)
Environment:
Last Closed: 2011-07-21 10:50:30 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2011:1071 0 normal SHIPPED_LIVE lvm2 bug fix and enhancement update 2011-07-21 10:50:01 UTC

Description Corey Marthaler 2011-06-03 20:51:16 UTC
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

Comment 1 Corey Marthaler 2011-06-03 21:55:45 UTC
This issue most likely exists in RHEL6.1 as well.

Comment 2 Alasdair Kergon 2011-06-06 12:16:59 UTC
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.

Comment 3 Alasdair Kergon 2011-06-06 12:28:30 UTC
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.

Comment 4 Alasdair Kergon 2011-06-06 13:10:32 UTC
(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

Comment 5 Milan Broz 2011-06-06 16:47:00 UTC
I'll add at least 1) + 2) to 5.7 so it cannot corrupt VG metadata.

Comment 6 Milan Broz 2011-06-10 17:29:41 UTC
Fixed in
lvm2-2.02.84-5.el5
lvm2-cluster-2.02.84-5.el5

full fix included.

Comment 10 Milan Broz 2011-06-16 15:31:38 UTC
Roundig up logic hopefully fixed in lvm2-2.02.84-6.el5

Comment 12 Corey Marthaler 2011-06-21 20:11:47 UTC
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

Comment 13 errata-xmlrpc 2011-07-21 10:50:30 UTC
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

Comment 14 errata-xmlrpc 2011-07-21 12:29:36 UTC
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


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