Bug 733320

Summary: lvresize: When resizing striped LV it should align the size up instead of down
Product: Red Hat Enterprise Linux 6 Reporter: Lukáš Czerner <lczerner>
Component: lvm2Assignee: Petr Rockai <prockai>
Status: CLOSED ERRATA QA Contact: Corey Marthaler <cmarthal>
Severity: medium Docs Contact:
Priority: high    
Version: 6.2CC: agk, coughlan, dwysocha, heinzm, jbrassow, mbroz, prajnoha, prockai, thornber, zkabelac
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: lvm2-2.02.87-3.el6 Doc Type: Bug Fix
Doc Text:
When striped logical volume was resized with the lvresize command, the size was aligned to the stripe boundary down. This could pose a problem when shrinking the volume with file system on it, because even if we computed the new size so that the file system did fit entirely onto the volume and resized it, the alignment done by the lvresize might have cut off a part of the file system and hence it might have corrupted it. To fix this, the rounding has been corrected for striped volumes so the volume never reduces more than requested.
Story Points: ---
Clone Of: Environment:
Last Closed: 2011-12-06 17:02:42 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 743047    

Description Lukáš Czerner 2011-08-25 13:16:30 UTC
Description of problem:

When resizing striped logical volume with lvresize current implementation aligns the size to the stripe boundary down. However it represent a problem when shrinking the volume with file system on it, because even if we compute the new size so the file system will fit entirely onto the volume and resize it, the alignment done by the lvresize might cut off a part of the file system, hence corrupts it.

lvresize should round the size up, instead of down, to avoid such problems.



Version-Release number of selected component (if applicable):
  LVM version:     2.02.87(2)-RHEL6 (2011-08-12)
  Library version: 1.02.68-cvs (2011-08-19)
  Driver version:  4.21.6



How reproducible:

 # lvcreate -v --name lvol003 -L 2G -i 3 -I 32 vg001
 # lvresize -v -L1077936128b /dev/vg001/lvol003
...
  Rounding size (257 extents) down to stripe boundary size for segment (255 extents)

Note that this works if you use lvreduce instead, but those two commands should do exactly the same thing!

 #  lvreduce -v -L1077936128b /dev/vg001/lvol003
...
  Rounding size (257 extents) up to stripe boundary size for segment (258 extents)



Actual results:

  Rounding size (257 extents) down to stripe boundary size for segment (255 extents)

rounding the new size down.


Expected results:

  Rounding size (257 extents) up to stripe boundary size for segment (258 extents)

rounding the new size up.

Comment 2 Alasdair Kergon 2011-08-25 13:35:16 UTC
When reducing, the logic for lvresize should indeed be identical to lvreduce.
Rounding should always be done in the 'safe' direction.

There was a recent fix:
    Fix extent rounding for striped volumes never to reduce more than requested

- perhaps this case was missed?

Comment 3 Lukáš Czerner 2011-08-25 13:38:41 UTC
BTW, the problem is upstream as well.

Thanks!
-Lukas

Comment 4 Milan Broz 2011-08-25 14:10:57 UTC
yes, the case is missed. rounding logic is there but the condition which trigger it seems to be incomplete.

Comment 5 Peter Rajnoha 2011-09-21 15:41:28 UTC
This should work now:

[root@node-a ~]# lvcreate --name test -L 2G -i 3 -I 32 vg
  Rounding size (512 extents) up to stripe boundary size (513 extents)
  Logical volume "test" created

[root@node-a ~]# lvresize -L 1077936128b /dev/vg/test 
  Rounding size (257 extents) up to stripe boundary size for segment (258 extents)
  Reducing logical volume test to 1.01 GiB
  Logical volume test successfully resized

is now the same as lvreduce:

[root@node-a ~]# lvreduce -L 1077936128b /dev/vg/test 
  Rounding size (257 extents) up to stripe boundary size for segment (258 extents)
  Reducing logical volume test to 1.01 GiB
  Logical volume test successfully resized

Comment 6 Corey Marthaler 2011-09-21 15:43:46 UTC
Adding QA ack for this 6.2 blocker.

Devel test results in comment #5.

Comment 8 Corey Marthaler 2011-09-28 22:34:22 UTC
Fix verified in the latest rpms.

2.6.32-201.el6.x86_64

lvm2-2.02.87-3.el6    BUILT: Wed Sep 21 09:54:55 CDT 2011
lvm2-libs-2.02.87-3.el6    BUILT: Wed Sep 21 09:54:55 CDT 2011
lvm2-cluster-2.02.87-3.el6    BUILT: Wed Sep 21 09:54:55 CDT 2011
udev-147-2.40.el6    BUILT: Fri Sep 23 07:51:13 CDT 2011
device-mapper-1.02.66-3.el6    BUILT: Wed Sep 21 09:54:55 CDT 2011
device-mapper-libs-1.02.66-3.el6    BUILT: Wed Sep 21 09:54:55 CDT 2011
device-mapper-event-1.02.66-3.el6    BUILT: Wed Sep 21 09:54:55 CDT 2011
device-mapper-event-libs-1.02.66-3.el6    BUILT: Wed Sep 21 09:54:55 CDT 2011
cmirror-2.02.87-3.el6    BUILT: Wed Sep 21 09:54:55 CDT 2011



[root@hayes-01 ~]# lvcreate -v -n stripe -L 2G -i 3 -I 32 hayes
    Setting logging type to disk
    Finding volume group "hayes"
  Rounding size (512 extents) up to stripe boundary size (513 extents)
  [...]
  Logical volume "stripe" created
[root@hayes-01 ~]# lvs -a -o +devices
  LV      VG         Attr   LSize  Origin Snap%  Move Log Copy%  Convert Devices                                                          
  stripe  hayes      -wi-a-  2.00g                                       /dev/etherd/e1.1p1(0),/dev/etherd/e1.1p2(0),/dev/etherd/e1.1p3(0)

[root@hayes-01 ~]# lvresize -v -L1077936128b /dev/hayes/stripe 
    Finding volume group hayes
  Rounding size (257 extents) up to stripe boundary size for segment (258 extents)
  [...]
  Logical volume stripe successfully resized

[root@hayes-01 ~]# lvreduce -L 1077936128b /dev/hayes/stripe 
  Rounding size (257 extents) up to stripe boundary size for segment (258 extents)
  [...]
Do you really want to reduce stripe? [y/n]: y
  Reducing logical volume stripe to 1.01 GiB
  Logical volume stripe successfully resized

Comment 9 Peter Rajnoha 2011-10-27 08:13:32 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
When striped logical volume was resized with the lvresize command, the size was aligned to the stripe boundary down. This could pose a problem when shrinking the volume with file system on it, because even if we computed the new size so that the file system did fit entirely onto the volume and resized it, the alignment done by the lvresize might have cut off a part of the file system and hence it might have corrupted it. To fix this, the rounding has been corrected for striped volumes so the volume never reduces more than requested.

Comment 10 errata-xmlrpc 2011-12-06 17:02:42 UTC
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-2011-1522.html