Bug 154691 - RHEL4: (LVM2) lvextend should default to the size of the pv + current size of lv
RHEL4: (LVM2) lvextend should default to the size of the pv + current size of lv
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 4
Classification: Red Hat
Component: lvm2 (Show other bugs)
4.0
All Linux
low Severity medium
: ---
: ---
Assigned To: Dave Wysochanski
acl
: FutureFeature
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2005-04-13 11:39 EDT by Corey Marthaler
Modified: 2008-07-24 16:07 EDT (History)
4 users (show)

See Also:
Fixed In Version: RHBA-2008-0776
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2008-07-24 16:07:04 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


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

  None (edit)
Description Corey Marthaler 2005-04-13 11:39:09 EDT
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 16:14:50 EST
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 Product and Program Management 2006-08-18 13:44:58 EDT
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-05 20:06:13 EST
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 10:46:08 EST
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-20 23:43:20 EST
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-20 23:54:27 EST
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 15:08:57 EST
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 10:04:28 EST
I need to look at this again and try to close this out for 4.6.
Comment 11 RHEL Product and Program Management 2007-03-09 20:16:21 EST
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 18:12:34 EDT
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 18:14:18 EDT
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 18:01:26 EDT
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 17:49:03 EDT
Patch in #14 with slight modifications committed to upstream CVS and should be
pulled into next release.
Comment 19 Corey Marthaler 2008-06-30 12:07:56 EDT
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 16:07:04 EDT
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.