Bug 154691 - RHEL4: (LVM2) lvextend should default to the size of the pv + current size of lv
Summary: RHEL4: (LVM2) lvextend should default to the size of the pv + current size of lv
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: lvm2
Version: 4.0
Hardware: All
OS: Linux
low
medium
Target Milestone: ---
: ---
Assignee: Dave Wysochanski
QA Contact:
URL:
Whiteboard: acl
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2005-04-13 15:39 UTC by Corey Marthaler
Modified: 2008-07-24 20:07 UTC (History)
4 users (show)

Fixed In Version: RHBA-2008-0776
Doc Type: Enhancement
Doc Text:
Clone Of:
Environment:
Last Closed: 2008-07-24 20:07:04 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Patch to make extents optional for lvextend when pvs are on cmdline (2.09 KB, patch)
2006-12-21 04:54 UTC, Dave Wysochanski
no flags Details | Diff
Updated patch against upstream LVM2 to add "%PV" option (12.72 KB, patch)
2007-09-10 22:12 UTC, Dave Wysochanski
no flags Details | Diff
Updated patch implementing %PVS option for lvextend and lvcreate (13.94 KB, patch)
2007-09-19 22:01 UTC, Dave Wysochanski
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2008:0776 0 normal SHIPPED_LIVE lvm2 bug fix and enhancement update 2008-07-23 17:19:45 UTC

Description Corey Marthaler 2005-04-13 15:39:09 UTC
Description of problem:
With computers now days, one shouldn't have to do any math in their head. :)
Since I can add a PV to a VG without any size option, I should be able to do the
 same when adding a PV to a LV, or better yet, if I already added the PV to the
VG, the lv should be able to extend out to the full size of the VG by default.
 

Version-Release number of selected component (if applicable):
[root@tank-03 ~]# rpm -qa | grep lvm2
lvm2-2.01.08-1.0.RHEL4
lvm2-cluster-2.01.09-1.1.RHEL4


The following should "just work":
[root@tank-03 ~]# lvextend /dev/grow/grow /dev/sda3 
  Please specify either size or extents (not both)
  lvextend: Add space to a logical volume

lvextend
        [-A|--autobackup y|n]
        [--alloc AllocationPolicy]
        [-d|--debug]
        [-h|--help]
        [-i|--stripes Stripes [-I|--stripesize StripeSize]]
        {-l|--extents [+]LogicalExtentsNumber |
         -L|--size [+]LogicalVolumeSize[kKmMgGtT]}
        [-n|--nofsck]
        [-r|--resizefs]
        [-t|--test]
        [--type VolumeType]
        [-v|--verbose]
        [--version]
        LogicalVolume[Path] [ PhysicalVolumePath... ]

but instead I have to do math and figure out the size to extend out too:
[root@tank-03 ~]# lvextend -L 274.06G /dev/grow/grow /dev/sda3
  Rounding up size to full physical extent 274.06 GB
  Extending logical volume grow to 274.06 GB
  Logical volume grow successfully resized

Comment 1 Alasdair Kergon 2006-03-08 21:14:50 UTC
Probably not default to maximum size, but there needs to be a simple way to
request it - either a new cmdline flag or a special size value.

Comment 3 RHEL Program Management 2006-08-18 17:44:58 UTC
This request was evaluated by Red Hat Product Management for inclusion in a Red
Hat Enterprise Linux maintenance release.  Product Management has requested
further review of this request by Red Hat Engineering, for potential
inclusion in a Red Hat Enterprise Linux Update release for currently deployed
products.  This request is not yet committed for inclusion in an Update
release.

Comment 5 Dave Wysochanski 2006-12-06 01:06:13 UTC
Does the %FREE option you added to lvextend address this one?

If so it looks like it needs a backport right?

Comment 6 Dave Wysochanski 2006-12-14 15:46:08 UTC
It looks to me like agk's %FREE fix does the trick (for the most part) upstream.
 But it does not cover the exact case corey described in this bug.  The downside
I found was that if you use the % option, it assumes the %age is against the vg,
and ignores any physicalvolumes on the cmdline.  Was there a reason the %FREE
behaves this way or is it a bug?  Also, I checked and the %FREE code is not in
RHEL4 nightly.

With no PhysicalVolumePath args, we assume all the PVs in the VG, so it works fine:

# tools/lvm lvs
File descriptor 4 left open
  WARNING: Ignoring duplicate config node: filter (seeking filter)
  LV   VG   Attr   LSize  Origin Snap%  Move Log Copy%
  lv0  vg0  -wi-a- 96.00M
# tools/lvm pvs
File descriptor 4 left open
  WARNING: Ignoring duplicate config node: filter (seeking filter)
  PV         VG   Fmt  Attr PSize   PFree
  /dev/loop1 vg0  lvm2 a-   252.00M 156.00M
  /dev/loop2      lvm2 --   256.00M 256.00M
# tools/lvm vgs
File descriptor 4 left open
  WARNING: Ignoring duplicate config node: filter (seeking filter)
  VG   #PV #LV #SN Attr   VSize   VFree
  vg0    1   1   0 wz--n- 252.00M 156.00M
# tools/lvm lvextend -l +100%FREE vg0/lv0
File descriptor 4 left open
  WARNING: Ignoring duplicate config node: filter (seeking filter)
  Extending logical volume lv0 to 252.00 MB
  Logical volume lv0 successfully resized
# tools/lvm lvs
File descriptor 4 left open
  WARNING: Ignoring duplicate config node: filter (seeking filter)
  LV   VG   Attr   LSize   Origin Snap%  Move Log Copy%
  lv0  vg0  -wi-a- 252.00M
# tools/lvm version
File descriptor 4 left open
  WARNING: Ignoring duplicate config node: filter (seeking filter)
  LVM version:     2.02.17-cvs (2006-12-01)
  Library version: 1.02.10-cvs (2006-08-15)
  Driver version:  4.5.0


With PV args though - fails b/c there is > 1 PV in the VG, and 100% check is
against the VG.  You'd either have to do %age math here or extend math:

# tools/lvm vgs
File descriptor 4 left open
  WARNING: Ignoring duplicate config node: filter (seeking filter)
  VG   #PV #LV #SN Attr   VSize   VFree
  vg0    2   1   0 wz--n- 504.00M 408.00M
# tools/lvm lvs
File descriptor 4 left open
  WARNING: Ignoring duplicate config node: filter (seeking filter)
  LV   VG   Attr   LSize  Origin Snap%  Move Log Copy%
  lv0  vg0  -wi-a- 96.00M
# tools/lvm pvs
File descriptor 4 left open
  WARNING: Ignoring duplicate config node: filter (seeking filter)
  PV         VG   Fmt  Attr PSize   PFree
  /dev/loop1 vg0  lvm2 a-   252.00M 156.00M
  /dev/loop2 vg0  lvm2 a-   252.00M 252.00M
# tools/lvm lvextend -l +100%FREE vg0/lv0 /dev/loop2
File descriptor 4 left open
  WARNING: Ignoring duplicate config node: filter (seeking filter)
  Extending logical volume lv0 to 504.00 MB
  Insufficient free space: 102 extents needed, but only 63 available
# tools/lvm lvextend -l +63 vg0/lv0 /dev/loop2
File descriptor 4 left open
  WARNING: Ignoring duplicate config node: filter (seeking filter)
  Extending logical volume lv0 to 348.00 MB
  Logical volume lv0 successfully resized


Comment 7 Dave Wysochanski 2006-12-21 04:43:20 UTC
I am pretty sure this is an easy one - and I don't even have to use the %FREE
thing.  I have a patch I'm testing that is simple and seems to work ok.  Will
talk with agk to confirm.

Comment 8 Dave Wysochanski 2006-12-21 04:54:27 UTC
Created attachment 144160 [details]
Patch to make extents optional for lvextend when pvs are on cmdline

Preliminary patch against upstream CVS to allow someone to skip extents arg and
just specify PVS.  Needs cleanup and did not fix man page or cmdline yet but
seems to work ok for basic tests.

Comment 9 Dave Wysochanski 2006-12-27 20:08:57 UTC
Alasdair has pointed out that this is more complicated than it looks, because of
possible pe ranges on the cmdline, and the fact that you don't know if you can
use the extents in the ranges until allocate time.  So I've been reading more
details of the code now and working on improving the previous patch.

Comment 10 Dave Wysochanski 2007-02-22 15:04:28 UTC
I need to look at this again and try to close this out for 4.6.

Comment 11 RHEL Program Management 2007-03-10 01:16:21 UTC
This bugzilla had previously been approved for engineering
consideration but Red Hat Product Management is currently reevaluating
this issue for inclusion in RHEL4.6.

Comment 13 Dave Wysochanski 2007-09-10 22:12:34 UTC
Created attachment 192151 [details]
Updated patch against upstream LVM2 to add "%PV" option

Patch header explains most of it.  Add %PV so you can do "lvextend -l +100%PV
vg0/lv0 /dev/foobar".  This will extend the LV by 100% of the free extents in
/dev/foobar.  Code even handles PE ranges, etc.

Comment 14 Dave Wysochanski 2007-09-10 22:14:18 UTC
Fairly confident something like the above patch is feasible for 4.7.  Probably
needs some discussion with Alasdair when he gets back to confirm this approach.

Comment 15 Dave Wysochanski 2007-09-19 22:01:26 UTC
Created attachment 200201 [details]
Updated patch implementing %PVS option for lvextend and lvcreate

Updated patch based on phone conversation today with agk.  I think this
addresses most, if not all of the comments.  The simpler syntax of omitting the
-l and -L option if you specify a PV on the cmdline is now accepted.  I added
an example in the lvextend man page but did not change the man page syntax.

Patch probably needs a bit more unit testing - only brief unit testing on
lvextend with some simple command lines.

Comment 16 Dave Wysochanski 2007-09-20 21:49:03 UTC
Patch in #14 with slight modifications committed to upstream CVS and should be
pulled into next release.

Comment 19 Corey Marthaler 2008-06-30 16:07:56 UTC
Fix verified in lvm2-2.02.37-3.el4.

[root@taft-03 dev]# lvextend /dev/taft/grow /dev/sdd1
  Extending logical volume grow to 406.96 GB
  Logical volume grow successfully resized


Comment 21 errata-xmlrpc 2008-07-24 20:07:04 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-2008-0776.html


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