Login
[x]
Log in using an account from:
Fedora Account System
Red Hat Associate
Red Hat Customer
Or login using a Red Hat Bugzilla account
Forgot Password
Login:
Hide Forgot
Create an Account
Red Hat Bugzilla – Attachment 200201 Details for
Bug 154691
RHEL4: (LVM2) lvextend should default to the size of the pv + current size of lv
[?]
New
Simple Search
Advanced Search
My Links
Browse
Requests
Reports
Current State
Search
Tabular reports
Graphical reports
Duplicates
Other Reports
User Changes
Plotly Reports
Bug Status
Bug Severity
Non-Defaults
|
Product Dashboard
Help
Page Help!
Bug Writing Guidelines
What's new
Browser Support Policy
5.0.4.rh83 Release notes
FAQ
Guides index
User guide
Web Services
Contact
Legal
This site requires JavaScript to be enabled to function correctly, please enable it.
[patch]
Updated patch implementing %PVS option for lvextend and lvcreate
lvm2-make-extents-optional-when-pvs-on-cmdline.patch (text/plain), 13.94 KB, created by
Dave Wysochanski
on 2007-09-19 22:01:26 UTC
(
hide
)
Description:
Updated patch implementing %PVS option for lvextend and lvcreate
Filename:
MIME Type:
Creator:
Dave Wysochanski
Created:
2007-09-19 22:01:26 UTC
Size:
13.94 KB
patch
obsolete
>Add '%PVS' extent option to lvextend, lvresize and lvcreate. This simplifies >adding new space to an LV for a newly added PV without the user having to do >any extent math. For example, suppose we have vg0, lv0, and we want to >add new space in /dev/loop3. We can now do the following to add all free >space on /dev/loop3: > ># pvcreate /dev/loop3 ># vgextend vg0 /dev/loop3 ># lvextend -l +100%PV vg0/lv0 /dev/loop3 > >Another cleaner cmdline is to forgo '-l' altogether and just assume a >"-l +100%PVS" if there are PVs on the cmdline. Thus, a valid syntax is >also: ># lvextend vg0/lv0 /dev/loop3 > >-- >Index: LVM2/tools/lvresize.c >=================================================================== >--- LVM2.orig/tools/lvresize.c 2007-09-06 18:35:01.000000000 -0400 >+++ LVM2/tools/lvresize.c 2007-09-19 17:38:29.000000000 -0400 >@@ -182,8 +182,21 @@ static int _lvresize_params(struct cmd_c > if (!strcmp(cmd_name, "lvextend")) > lp->resize = LV_EXTEND; > >- if (arg_count(cmd, extents_ARG) + arg_count(cmd, size_ARG) != 1) { >- log_error("Please specify either size or extents (not both)"); >+ /* >+ * Allow omission of extents and size if the user has given us >+ * one or more PVs. Most likely, the intent was just "resize this >+ * LV the best you can with these PVs" >+ */ >+ if ((arg_count(cmd, extents_ARG) + arg_count(cmd, size_ARG) == 0) && >+ (argc >= 2)) { >+ lp->extents = 100; >+ lp->percent = PERCENT_PVS; >+ lp->sign = SIGN_PLUS; >+ } else if ((arg_count(cmd, extents_ARG) + >+ arg_count(cmd, size_ARG) != 1) && >+ (argc < 2)) { >+ log_error("Please specify either size or extents or " >+ "one or more PVs"); > return 0; > } > >@@ -246,6 +259,7 @@ static int _lvresize(struct cmd_context > uint32_t seg_mirrors = 0; > uint32_t extents_used = 0; > uint32_t size_rest; >+ uint32_t pv_extent_count = 0; > alloc_policy_t alloc; > struct logical_volume *lock_lv; > struct lv_list *lvl; >@@ -319,6 +333,12 @@ static int _lvresize(struct cmd_context > lp->extents = lp->size / vg->extent_size; > } > >+ if (!(pvh = lp->argc ? create_pv_list(cmd->mem, vg, lp->argc, >+ lp->argv, 1) : &vg->pvs)) { >+ stack; >+ return ECMD_FAILED; >+ } >+ > switch(lp->percent) { > case PERCENT_VG: > lp->extents = lp->extents * vg->extent_count / 100; >@@ -329,6 +349,10 @@ static int _lvresize(struct cmd_context > case PERCENT_LV: > lp->extents = lp->extents * lv->le_count / 100; > break; >+ case PERCENT_PVS: >+ pv_extent_count = pv_list_extents_free(pvh); >+ lp->extents = lp->extents * pv_extent_count / 100; >+ break; > case PERCENT_NONE: > break; > } >@@ -539,10 +563,6 @@ static int _lvresize(struct cmd_context > if (lp->resize == LV_REDUCE) { > if (lp->argc) > log_warn("Ignoring PVs on command line when reducing"); >- } else if (!(pvh = lp->argc ? create_pv_list(cmd->mem, vg, lp->argc, >- lp->argv, 1) : &vg->pvs)) { >- stack; >- return ECMD_FAILED; > } > > if (lp->resize == LV_REDUCE || lp->resizefs) { >Index: LVM2/tools/lvmcmdline.c >=================================================================== >--- LVM2.orig/tools/lvmcmdline.c 2007-08-21 15:46:36.000000000 -0400 >+++ LVM2/tools/lvmcmdline.c 2007-09-19 15:53:36.000000000 -0400 >@@ -269,6 +269,9 @@ int int_arg_with_sign_and_percent(struct > a->percent = PERCENT_VG; > else if (!strcasecmp(ptr, "L") || !strcasecmp(ptr, "LV")) > a->percent = PERCENT_LV; >+ else if (!strcasecmp(ptr, "P") || !strcasecmp(ptr, "PV") || >+ !strcasecmp(ptr, "PVS")) >+ a->percent = PERCENT_PVS; > else if (!strcasecmp(ptr, "F") || !strcasecmp(ptr, "FR") || > !strcasecmp(ptr, "FREE")) > a->percent = PERCENT_FREE; >Index: LVM2/tools/tools.h >=================================================================== >--- LVM2.orig/tools/tools.h 2007-08-21 15:46:36.000000000 -0400 >+++ LVM2/tools/tools.h 2007-09-19 15:29:52.000000000 -0400 >@@ -83,7 +83,8 @@ typedef enum { > PERCENT_NONE = 0, > PERCENT_VG, > PERCENT_FREE, >- PERCENT_LV >+ PERCENT_LV, >+ PERCENT_PVS > } percent_t; > > enum { >Index: LVM2/man/lvresize.8 >=================================================================== >--- LVM2.orig/man/lvresize.8 2006-11-10 13:24:11.000000000 -0500 >+++ LVM2/man/lvresize.8 2007-09-19 16:09:15.000000000 -0400 >@@ -6,7 +6,7 @@ lvresize \- resize a logical volume > [\-\-alloc AllocationPolicy] > [\-A/\-\-autobackup y/n] [\-d/\-\-debug] [\-h/\-?/\-\-help] > [\-i/\-\-stripes Stripes [\-I/\-\-stripesize StripeSize]] >-{\-l/\-\-extents [+]LogicalExtentsNumber[%{VG|LV|FREE}] | >+{\-l/\-\-extents [+]LogicalExtentsNumber[%{VG|LV|PVS|FREE}] | > \-L/\-\-size [+]LogicalVolumeSize[kKmMgGtT]} > [\-t/\-\-test] > [\-v/\-\-verbose] LogicalVolumePath [PhysicalVolumePath...] >@@ -25,14 +25,16 @@ volume use > .SH OPTIONS > See \fBlvm\fP for common options. > .TP >-.I \-l, \-\-extents [+/-]LogicalExtentsNumber[%{VG|LV|FREE}] >+.I \-l, \-\-extents [+/-]LogicalExtentsNumber[%{VG|LV|PVS|FREE}] > Change or set the logical volume size in units of logical extents. > With the + or - sign the value is added to or subtracted from the actual size > of the logical volume and without it, the value is taken as an absolute one. > The number can also be expressed as a percentage of the total space >-in the Volume Group with the suffix %VG or relative to the existing >-size of the Logical Volume with the suffix %LV or as a percentage of the remaining >-free space in the Volume Group with the suffix %FREE. >+in the Volume Group with the suffix %VG, relative to the existing >+size of the Logical Volume with the suffix %LV, as a percentage of >+the remaining free space of the PhysicalVolumes on the command line with the >+suffix %PVS, or as a percentage of the remaining free space in the >+Volume Group with the suffix %FREE. > .TP > .I \-L, \-\-size [+/-]LogicalVolumeSize[kKmMgGtTpPeE] > Change or set the logical volume size in units of megabytes. >Index: LVM2/tools/lvcreate.c >=================================================================== >--- LVM2.orig/tools/lvcreate.c 2007-09-17 13:18:37.000000000 -0400 >+++ LVM2/tools/lvcreate.c 2007-09-19 15:29:25.000000000 -0400 >@@ -490,6 +490,7 @@ static int _lvcreate(struct cmd_context > char lv_name_buf[128]; > const char *lv_name; > struct lvinfo info; >+ uint32_t pv_extent_count; > > status |= lp->permission | VISIBLE_LV; > >@@ -574,6 +575,15 @@ static int _lvcreate(struct cmd_context > case PERCENT_FREE: > lp->extents = lp->extents * vg->free_count / 100; > break; >+ case PERCENT_PVS: >+ if (!lp->pv_count) { >+ log_error("Please specify physical volume(s) " >+ "with %%PV"); >+ return 0; >+ } >+ pv_extent_count = pv_list_extents_free(pvh); >+ lp->extents = lp->extents * pv_extent_count / 100; >+ break; > case PERCENT_LV: > log_error("Please express size as %%VG or %%FREE."); > return 0; >Index: LVM2/man/lvcreate.8 >=================================================================== >--- LVM2.orig/man/lvcreate.8 2007-08-30 15:34:19.000000000 -0400 >+++ LVM2/man/lvcreate.8 2007-09-19 16:08:51.000000000 -0400 >@@ -8,7 +8,7 @@ lvcreate \- create a logical volume in a > [\-A/\-\-autobackup y/n] [\-C/\-\-contiguous y/n] [\-d/\-\-debug] > [\-h/\-?/\-\-help] > [\-i/\-\-stripes Stripes [\-I/\-\-stripesize StripeSize]] >-{\-l/\-\-extents LogicalExtentsNumber[%{VG|FREE}] | >+{\-l/\-\-extents LogicalExtentsNumber[%{VG|PVS|FREE}] | > \-L/\-\-size LogicalVolumeSize[kKmMgGtT]} > [\-M/\-\-persistent y/n] [\-\-minor minor] > [\-m/\-\-mirrors Mirrors [\-\-nosync] [\-\-mirrorlog {disk|log}] [\-\-corelog] >@@ -63,12 +63,13 @@ StripeSize must be 2^n (n = 2 to 9) for > For metadata in LVM2 format, the stripe size may be a larger > power of 2 but must not exceed the physical extent size. > .TP >-.I \-l, \-\-extents LogicalExtentsNumber[%{VG|FREE}] >+.I \-l, \-\-extents LogicalExtentsNumber[%{VG|PVS|FREE}] > Gives the number of logical extents to allocate for the new > logical volume. > This can also be expressed as a percentage of the total space >-in the Volume Group with the suffix %VG or of the remaining free space >-with the suffix %FREE. >+in the Volume Group with the suffix %VG, of the remaining free >+extents for the specified PhysicalVolume(s) with the suffix %PVS, >+or of the remaining free space with the suffix %FREE. > .TP > .I \-L, \-\-size LogicalVolumeSize[kKmMgGtTpPeE] > Gives the size to allocate for the new logical volume. >Index: LVM2/man/lvextend.8 >=================================================================== >--- LVM2.orig/man/lvextend.8 2007-01-09 16:12:41.000000000 -0500 >+++ LVM2/man/lvextend.8 2007-09-19 17:54:39.000000000 -0400 >@@ -6,7 +6,7 @@ lvextend \- extend the size of a logical > [\-\-alloc AllocationPolicy] > [\-A/\-\-autobackup y/n] [\-d/\-\-debug] [\-h/\-?/\-\-help] > [\-i/\-\-stripes Stripes [\-I/\-\-stripesize StripeSize]] >-{\-l/\-\-extents [+]LogicalExtentsNumber[%{VG|LV|FREE}] | >+{\-l/\-\-extents [+]LogicalExtentsNumber[%{VG|LV|PVS|FREE}] | > \-L/\-\-size [+]LogicalVolumeSize[kKmMgGtT]} > [\-t/\-\-test] > [\-v/\-\-verbose] LogicalVolumePath [PhysicalVolumePath...] >@@ -21,14 +21,16 @@ volume use > .SH OPTIONS > See \fBlvm\fP for common options. > .TP >-.I \-l, \-\-extents [+]LogicalExtentsNumber[%{VG|LV|FREE}] >+.I \-l, \-\-extents [+]LogicalExtentsNumber[%{VG|LV|PVS|FREE}] > Extend or set the logical volume size in units of logical extents. > With the + sign the value is added to the actual size > of the logical volume and without it, the value is taken as an absolute one. > The number can also be expressed as a percentage of the total space >-in the Volume Group with the suffix %VG or relative to the existing >-size of the Logical Volume with the suffix %LV or as a percentage of the remaining >-free space in the Volume Group with the suffix %FREE. >+in the Volume Group with the suffix %VG, relative to the existing >+size of the Logical Volume with the suffix %LV, of the remaining >+free extents for the specified PhysicalVolume(s) with the suffix %PVS, >+or as a percentage of the remaining free space in the Volume Group >+with the suffix %FREE. > .TP > .I \-L, \-\-size [+]LogicalVolumeSize[kKmMgGtTpPeE] > Extend or set the logical volume size in units of megabytes. >@@ -54,6 +56,10 @@ StripeSize must be 2^n (n = 2 to 9) > that logical volume by 54MB on physical volume /dev/sdk3. > This is only possible if /dev/sdk3 is a member of volume group vg01 and > there are enough free physical extents in it. >+ >+"lvextend /dev/vg01/lvol01 /dev/sdk3" tries to extend the size of that >+logical volume by the amount of free space on physical volume /dev/sdk3. >+This is equivalent to specifying "-l +100%PVS" on the command line. > .SH SEE ALSO > .BR lvm (8), > .BR lvcreate (8), >Index: LVM2/tools/commands.h >=================================================================== >--- LVM2.orig/tools/commands.h 2007-08-28 12:14:49.000000000 -0400 >+++ LVM2/tools/commands.h 2007-09-19 17:54:08.000000000 -0400 >@@ -144,7 +144,7 @@ xx(lvcreate, > "\t[-d|--debug]\n" > "\t[-h|-?|--help]\n" > "\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n" >- "\t{-l|--extents LogicalExtentsNumber[%{VG|LV|FREE}] |\n" >+ "\t{-l|--extents LogicalExtentsNumber[%{VG|LV|PVS|FREE}] |\n" > "\t -L|--size LogicalVolumeSize[kKmMgGtTpPeE]}\n" > "\t[-M|--persistent {y|n}] [--major major] [--minor minor]\n" > "\t[-n|--name LogicalVolumeName]\n" >@@ -209,7 +209,7 @@ xx(lvextend, > "\t[-d|--debug]\n" > "\t[-h|--help]\n" > "\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n" >- "\t{-l|--extents [+]LogicalExtentsNumber[%{VG|FREE}] |\n" >+ "\t{-l|--extents [+]LogicalExtentsNumber[%{VG|PVS|FREE}] |\n" > "\t -L|--size [+]LogicalVolumeSize[kKmMgGtTpPeE]}\n" > "\t[-m|--mirrors Mirrors]\n" > "\t[-n|--nofsck]\n" >@@ -323,7 +323,7 @@ xx(lvresize, > "\t[-d|--debug]\n" > "\t[-h|--help]\n" > "\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n" >- "\t{-l|--extents [+|-]LogicalExtentsNumber[%{VG|LV|FREE}] |\n" >+ "\t{-l|--extents [+|-]LogicalExtentsNumber[%{VG|LV|PVS|FREE}] |\n" > "\t -L|--size [+|-]LogicalVolumeSize[kKmMgGtTpPeE]}\n" > "\t[-n|--nofsck]\n" > "\t[-r|--resizefs]\n" >Index: LVM2/tools/toollib.c >=================================================================== >--- LVM2.orig/tools/toollib.c 2007-09-11 16:12:54.000000000 -0400 >+++ LVM2/tools/toollib.c 2007-09-19 15:12:52.000000000 -0400 >@@ -875,6 +875,46 @@ char *default_vgname(struct cmd_context > } > > /* >+ * Calculate the overlap, in extents, between a struct pv_segment and >+ * a struct pe_range. >+ */ >+static uint32_t _overlap_pe(struct pv_segment *pvseg, >+ struct pe_range *per) >+{ >+ uint32_t start; >+ uint32_t end; >+ >+ start = max(pvseg->pe, per->start); >+ end = min(pvseg->pe + pvseg->len, per->start + per->count); >+ if (end < start) >+ return 0; >+ else >+ return end - start; >+} >+ >+/* >+ * Returns: number of free PEs in a struct pv_list >+ */ >+uint32_t pv_list_extents_free(struct list *pvh) >+{ >+ struct pv_list *pvl; >+ struct pe_range *per; >+ uint32_t extents = 0; >+ struct pv_segment *pvseg; >+ >+ list_iterate_items(pvl, pvh) { >+ list_iterate_items(per, pvl->pe_ranges) { >+ list_iterate_items(pvseg, &pvl->pv->segments) { >+ if (!pvseg->lvseg) /* free space */ >+ extents += _overlap_pe(pvseg, per); >+ } >+ } >+ } >+ >+ return extents; >+} >+ >+/* > * Process physical extent range specifiers > */ > static int _add_pe_range(struct dm_pool *mem, const char *pvname, >Index: LVM2/tools/toollib.h >=================================================================== >--- LVM2.orig/tools/toollib.h 2007-08-22 10:38:18.000000000 -0400 >+++ LVM2/tools/toollib.h 2007-09-19 14:41:25.000000000 -0400 >@@ -112,4 +112,6 @@ struct logical_volume *create_mirror_log > int set_lv(struct cmd_context *cmd, struct logical_volume *lv, > uint64_t sectors, int value); > >+uint32_t pv_list_extents_free(struct list *pvh); >+ > #endif >Index: LVM2/lib/misc/util.h >=================================================================== >--- LVM2.orig/lib/misc/util.h 2007-08-20 16:55:27.000000000 -0400 >+++ LVM2/lib/misc/util.h 2007-09-19 16:06:15.000000000 -0400 >@@ -15,6 +15,16 @@ > #ifndef _LVM_UTIL_H > #define _LVM_UTIL_H > >+#define min(a, b) ({ typeof(a) _a = (a); \ >+ typeof(b) _b = (b); \ >+ (void) (&_a == &_b); \ >+ _a < _b ? _a : _b; }) >+ >+#define max(a, b) ({ typeof(a) _a = (a); \ >+ typeof(b) _b = (b); \ >+ (void) (&_a == &_b); \ >+ _a > _b ? _a : _b; }) >+ > char *last_path_component(char const *name); > > #endif
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 154691
:
144160
|
192151
| 200201