public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2 ./WHATS_NEW man/lvcreate.8 man/lvextend.8 ...
@ 2006-09-26  9:35 agk
  0 siblings, 0 replies; only message in thread
From: agk @ 2006-09-26  9:35 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-09-26 09:35:43

Modified files:
	.              : WHATS_NEW 
	man            : lvcreate.8 lvextend.8 lvreduce.8 lvresize.8 
	tools          : args.h commands.h lvcreate.c lvmcmdline.c 
	                 lvresize.c toollib.c tools.h 

Log message:
	Add %VG, %LV and %FREE suffices to lvcreate/lvresize --extents arg.
	e.g. lvcreate -l 100%FREE to create an LV using all available space.
	lvextend -l 50%LV to increase an LV by 50% of its existing size.
	lvcreate -l 20%VG to create an LV using 20% of the total VG size.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.444&r2=1.445
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvcreate.8.diff?cvsroot=lvm2&r1=1.10&r2=1.11
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvextend.8.diff?cvsroot=lvm2&r1=1.6&r2=1.7
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvreduce.8.diff?cvsroot=lvm2&r1=1.9&r2=1.10
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvresize.8.diff?cvsroot=lvm2&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/args.h.diff?cvsroot=lvm2&r1=1.46&r2=1.47
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/commands.h.diff?cvsroot=lvm2&r1=1.86&r2=1.87
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.124&r2=1.125
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.34&r2=1.35
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.75&r2=1.76
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.88&r2=1.89
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/tools.h.diff?cvsroot=lvm2&r1=1.51&r2=1.52

--- LVM2/WHATS_NEW	2006/09/21 20:25:54	1.444
+++ LVM2/WHATS_NEW	2006/09/26 09:35:42	1.445
@@ -1,5 +1,6 @@
 Version 2.02.11 - 
 =====================================
+  Add %VG, %LV and %FREE suffices to lvcreate/lvresize --extents arg.
   Fix two potential NULL pointer derefs in error cases in vg_read().
   Separate --enable-cluster from locking lib options in lvmconf.sh.
   Add a missing comma in lvcreate man page.
--- LVM2/man/lvcreate.8	2006/09/19 20:20:40	1.10
+++ LVM2/man/lvcreate.8	2006/09/26 09:35:42	1.11
@@ -8,7 +8,7 @@
 [\-A/\-\-autobackup y/n] [\-C/\-\-contiguous y/n] [\-d/\-\-debug]
 [\-h/\-?/\-\-help]
 [\-i/\-\-stripes Stripes [\-I/\-\-stripesize StripeSize]]
-{\-l/\-\-extents LogicalExtentsNumber |
+{\-l/\-\-extents LogicalExtentsNumber[%{VG|FREE}] |
  \-L/\-\-size LogicalVolumeSize[kKmMgGtT]}
 [\-M/\-\-persistent y/n] [\-\-minor minor]
 [\-m/\-\-mirrors Mirrors [\-\-nosync] [\-\-corelog]]
@@ -22,7 +22,7 @@
 
 .br
 .B lvcreate
-{\-l/\-\-extents LogicalExtentsNumber |
+{\-l/\-\-extents LogicalExtentsNumber[%{VG|FREE}] |
  \-L/\-\-size LogicalVolumeSize[kKmMgGtT]}
 [\-c/\-\-chunksize ChunkSize]
 \-s/\-\-snapshot \-n/\-\-name SnapshotLogicalVolumeName OriginalLogicalVolumePath
@@ -63,9 +63,12 @@
 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
+.I \-l, \-\-extents LogicalExtentsNumber[%{VG|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.
 .TP
 .I \-L, \-\-size LogicalVolumeSize[kKmMgGtT]
 Gives the size to allocate for the new logical volume.
--- LVM2/man/lvextend.8	2006/08/18 22:27:01	1.6
+++ LVM2/man/lvextend.8	2006/09/26 09:35:42	1.7
@@ -6,7 +6,7 @@
 [\-\-alloc AllocationPolicy]
 [\-A/\-\-autobackup y/n] [\-d/\-\-debug] [\-h/\-?/\-\-help]
 [\-i/\-\-stripes Stripes [\-I/\-\-stripesize StripeSize]]
-{\-l/\-\-extents [+]LogicalExtentsNumber |
+{\-l/\-\-extents [+]LogicalExtentsNumber[%{VG|LV|FREE}] |
 \-L/\-\-size [+]LogicalVolumeSize[kKmMgGtT]}
 [\-t/\-\-test]
 [\-v/\-\-verbose] LogicalVolumePath [PhysicalVolumePath...]
@@ -21,10 +21,14 @@
 .SH OPTIONS
 See \fBlvm\fP for common options.
 .TP
-.I \-l, \-\-extents [+]LogicalExtentsNumber
+.I \-l, \-\-extents [+]LogicalExtentsNumber[%{VG|LV|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.
 .TP
 .I \-L, \-\-size [+]LogicalVolumeSize[kKmMgGtT]
 Extend or set the logical volume size in units in units of megabytes.
--- LVM2/man/lvreduce.8	2006/08/18 22:27:01	1.9
+++ LVM2/man/lvreduce.8	2006/09/26 09:35:42	1.10
@@ -4,7 +4,8 @@
 .SH SYNOPSIS
 .B lvreduce
 [\-A/\-\-autobackup y/n] [\-d/\-\-debug] [\-f/\-\-force]
-[\-h/\-?/\-\-help] {\-l/\-\-extents [\-]LogicalExtentsNumber |
+[\-h/\-?/\-\-help]
+{\-l/\-\-extents [\-]LogicalExtentsNumber[%{VG|LV|FREE}] |
 \-L/\-\-size [\-]LogicalVolumeSize[kKmMgGtT]}
 [\-t/\-\-test]
 [\-v/\-\-verbose] LogicalVolume[Path]
@@ -35,11 +36,15 @@
 .I \-f, \-\-force
 Force size reduction without any question.
 .TP
-.I \-l, \-\-extents [\-]LogicalExtentsNumber
+.I \-l, \-\-extents [\-]LogicalExtentsNumber[%{VG|LV|FREE}]
 Reduce or set the logical volume size in units of logical extents.
 With the - sign the value will be subtracted from
 the logical volume's actual size and without it the will be taken as
 an absolute size.
+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.
 .TP
 .I \-L, \-\-size [\-]LogicalVolumeSize[kKmMgGtT]
 Reduce or set the logical volume size in units of megabyte by default.
--- LVM2/man/lvresize.8	2006/08/18 22:27:01	1.3
+++ LVM2/man/lvresize.8	2006/09/26 09:35:42	1.4
@@ -6,7 +6,7 @@
 [\-\-alloc AllocationPolicy]
 [\-A/\-\-autobackup y/n] [\-d/\-\-debug] [\-h/\-?/\-\-help]
 [\-i/\-\-stripes Stripes [\-I/\-\-stripesize StripeSize]]
-{\-l/\-\-extents [+]LogicalExtentsNumber |
+{\-l/\-\-extents [+]LogicalExtentsNumber[%{VG|LV|FREE}] |
 \-L/\-\-size [+]LogicalVolumeSize[kKmMgGtT]}
 [\-t/\-\-test]
 [\-v/\-\-verbose] LogicalVolumePath [PhysicalVolumePath...]
@@ -25,10 +25,14 @@
 .SH OPTIONS
 See \fBlvm\fP for common options.
 .TP
-.I \-l, \-\-extents [+/-]LogicalExtentsNumber
+.I \-l, \-\-extents [+/-]LogicalExtentsNumber[%{VG|LV|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.
 .TP
 .I \-L, \-\-size [+/-]LogicalVolumeSize[kKmMgGtT]
 Change or set the logical volume size in units of megabytes.
--- LVM2/tools/args.h	2006/08/01 14:56:33	1.46
+++ LVM2/tools/args.h	2006/09/26 09:35:43	1.47
@@ -84,7 +84,7 @@
 arg(iop_version_ARG, 'i', "iop_version", NULL)
 arg(logicalvolume_ARG, 'l', "logicalvolume", int_arg)
 arg(maxlogicalvolumes_ARG, 'l', "maxlogicalvolumes", int_arg)
-arg(extents_ARG, 'l', "extents", int_arg_with_sign)
+arg(extents_ARG, 'l', "extents", int_arg_with_sign_and_percent)
 arg(lvmpartition_ARG, 'l', "lvmpartition", NULL)
 arg(list_ARG, 'l', "list", NULL)
 arg(size_ARG, 'L', "size", size_mb_arg)
--- LVM2/tools/commands.h	2006/08/16 14:41:42	1.86
+++ LVM2/tools/commands.h	2006/09/26 09:35:43	1.87
@@ -137,7 +137,7 @@
    "\t[-d|--debug]\n"
    "\t[-h|-?|--help]\n"
    "\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
-   "\t{-l|--extents LogicalExtentsNumber |\n"
+   "\t{-l|--extents LogicalExtentsNumber[%{VG|LV|FREE}] |\n"
    "\t -L|--size LogicalVolumeSize[kKmMgGtT]}\n"
    "\t[-M|--persistent {y|n}] [--major major] [--minor minor]\n"
    "\t[-n|--name LogicalVolumeName]\n"
@@ -202,7 +202,7 @@
    "\t[-d|--debug]\n"
    "\t[-h|--help]\n"
    "\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
-   "\t{-l|--extents [+]LogicalExtentsNumber |\n"
+   "\t{-l|--extents [+]LogicalExtentsNumber[%{VG|FREE}] |\n"
    "\t -L|--size [+]LogicalVolumeSize[kKmMgGtT]}\n"
    "\t[-m|--mirrors Mirrors]\n"
    "\t[-n|--nofsck]\n"
@@ -267,7 +267,7 @@
    "\t[-d|--debug]\n"
    "\t[-f|--force]\n"
    "\t[-h|--help]\n"
-   "\t{-l|--extents [-]LogicalExtentsNumber |\n"
+   "\t{-l|--extents [-]LogicalExtentsNumber[%{VG|LV|FREE}] |\n"
    "\t -L|--size [-]LogicalVolumeSize[kKmMgGtT]}\n"
    "\t[-n|--nofsck]\n"
    "\t[-r|--resizefs]\n"
@@ -315,7 +315,7 @@
    "\t[-d|--debug]\n"
    "\t[-h|--help]\n"
    "\t[-i|--stripes Stripes [-I|--stripesize StripeSize]]\n"
-   "\t{-l|--extents [+|-]LogicalExtentsNumber |\n"
+   "\t{-l|--extents [+|-]LogicalExtentsNumber[%{VG|LV|FREE}] |\n"
    "\t -L|--size [+|-]LogicalVolumeSize[kKmMgGtT]}\n"
    "\t[-n|--nofsck]\n"
    "\t[-r|--resizefs]\n"
--- LVM2/tools/lvcreate.c	2006/09/02 01:18:17	1.124
+++ LVM2/tools/lvcreate.c	2006/09/26 09:35:43	1.125
@@ -43,6 +43,7 @@
 	/* size */
 	uint32_t extents;
 	uint64_t size;
+	percent_t percent;
 
 	uint32_t permission;
 	uint32_t read_ahead;
@@ -157,6 +158,7 @@
 			return 0;
 		}
 		lp->extents = arg_uint_value(cmd, extents_ARG, 0);
+		lp->percent = arg_percent_value(cmd, extents_ARG, PERCENT_NONE);
 	}
 
 	/* Size returned in kilobyte units; held in sectors */
@@ -166,6 +168,7 @@
 			return 0;
 		}
 		lp->size = arg_uint64_value(cmd, size_ARG, UINT64_C(0)) * 2;
+		lp->percent = PERCENT_NONE;
 	}
 
 	return 1;
@@ -556,6 +559,20 @@
 		lp->extents = tmp_size / vg->extent_size;
 	}
 
+	switch(lp->percent) {
+		case PERCENT_VG:
+			lp->extents = lp->extents * vg->extent_count / 100;
+			break;
+		case PERCENT_FREE:
+			lp->extents = lp->extents * vg->free_count / 100;
+			break;
+		case PERCENT_LV:
+			log_error("Please express size as %%VG or %%FREE.");
+			return 0;
+		case PERCENT_NONE:
+			break;
+	}
+
 	if ((size_rest = lp->extents % lp->stripes)) {
 		log_print("Rounding size (%d extents) up to stripe boundary "
 			  "size (%d extents)", lp->extents,
--- LVM2/tools/lvmcmdline.c	2006/08/21 12:54:53	1.34
+++ LVM2/tools/lvmcmdline.c	2006/09/26 09:35:43	1.35
@@ -69,6 +69,7 @@
 int yes_no_arg(struct cmd_context *cmd __attribute((unused)), struct arg *a)
 {
 	a->sign = SIGN_NONE;
+	a->percent = PERCENT_NONE;
 
 	if (!strcmp(a->value, "y")) {
 		a->i_value = 1;
@@ -90,6 +91,7 @@
 		    struct arg *a)
 {
 	a->sign = SIGN_NONE;
+	a->percent = PERCENT_NONE;
 
 	if (!strcmp(a->value, "e") || !strcmp(a->value, "ey") ||
 	    !strcmp(a->value, "ye")) {
@@ -148,6 +150,8 @@
 	char *val;
 	long v;
 
+	a->percent = PERCENT_NONE;
+
 	val = a->value;
 	switch (*val) {
 	case '+':
@@ -186,6 +190,8 @@
 	char *val;
 	double v;
 
+	a->percent = PERCENT_NONE;
+
 	val = a->value;
 	switch (*val) {
 	case '+':
@@ -259,6 +265,33 @@
 	return 1;
 }
 
+int int_arg_with_sign_and_percent(struct cmd_context *cmd __attribute((unused)),
+				  struct arg *a)
+{
+	char *ptr;
+
+	if (!_get_int_arg(a, &ptr))
+		return 0;
+
+	if (!*ptr)
+		return 1;
+
+	if (*ptr++ != '%')
+		return 0;
+
+	if (!strcasecmp(ptr, "V") || !strcasecmp(ptr, "VG"))
+		a->percent = PERCENT_VG;
+	else if (!strcasecmp(ptr, "L") || !strcasecmp(ptr, "LV"))
+		a->percent = PERCENT_LV;
+	else if (!strcasecmp(ptr, "F") || !strcasecmp(ptr, "FR") ||
+		 !strcasecmp(ptr, "FREE"))
+		a->percent = PERCENT_FREE;
+	else
+		return 0;
+
+	return 1;
+}
+
 int minor_arg(struct cmd_context *cmd __attribute((unused)), struct arg *a)
 {
 	char *ptr;
--- LVM2/tools/lvresize.c	2006/09/02 01:18:17	1.75
+++ LVM2/tools/lvresize.c	2006/09/26 09:35:43	1.76
@@ -31,6 +31,7 @@
 	uint32_t extents;
 	uint64_t size;
 	sign_t sign;
+	percent_t percent;
 
 	enum {
 		LV_ANY = 0,
@@ -68,12 +69,14 @@
 	if (arg_count(cmd, extents_ARG)) {
 		lp->extents = arg_uint_value(cmd, extents_ARG, 0);
 		lp->sign = arg_sign_value(cmd, extents_ARG, SIGN_NONE);
+		lp->percent = arg_percent_value(cmd, extents_ARG, PERCENT_NONE);
 	}
 
 	/* Size returned in kilobyte units; held in sectors */
 	if (arg_count(cmd, size_ARG)) {
 		lp->size = arg_uint64_value(cmd, size_ARG, UINT64_C(0)) * 2;
 		lp->sign = arg_sign_value(cmd, size_ARG, SIGN_NONE);
+		lp->percent = PERCENT_NONE;
 	}
 
 	if (lp->resize == LV_EXTEND && lp->sign == SIGN_MINUS) {
@@ -238,6 +241,20 @@
 		lp->extents = lp->size / vg->extent_size;
 	}
 
+	switch(lp->percent) {
+		case PERCENT_VG:
+			lp->extents = lp->extents * vg->extent_count / 100;
+			break;
+		case PERCENT_FREE:
+			lp->extents = lp->extents * vg->free_count / 100;
+			break;
+		case PERCENT_LV:
+			lp->extents = lp->extents * lv->le_count / 100;
+			break;
+		case PERCENT_NONE:
+			break;
+	}
+
 	if (lp->sign == SIGN_PLUS)
 		lp->extents += lv->le_count;
 
--- LVM2/tools/toollib.c	2006/09/11 14:24:58	1.88
+++ LVM2/tools/toollib.c	2006/09/26 09:35:43	1.89
@@ -70,6 +70,11 @@
 	return arg_count(cmd, a) ? cmd->args[a].sign : def;
 }
 
+sign_t arg_percent_value(struct cmd_context *cmd, int a, const percent_t def)
+{
+	return arg_count(cmd, a) ? cmd->args[a].percent : def;
+}
+
 int arg_count_increment(struct cmd_context *cmd, int a)
 {
 	return cmd->args[a].count++;
--- LVM2/tools/tools.h	2006/05/09 21:23:51	1.51
+++ LVM2/tools/tools.h	2006/09/26 09:35:43	1.52
@@ -80,6 +80,13 @@
 	SIGN_MINUS = 2
 } sign_t;
 
+typedef enum {
+	PERCENT_NONE = 0,
+	PERCENT_VG,
+	PERCENT_FREE,
+	PERCENT_LV
+} percent_t;
+
 enum {
 	CHANGE_AY = 0,
 	CHANGE_AN = 1,
@@ -103,6 +110,7 @@
 	int64_t i64_value;
 	uint64_t ui64_value;
 	sign_t sign;
+	percent_t percent;
 	void *ptr;
 };
 
@@ -126,6 +134,7 @@
 int size_mb_arg(struct cmd_context *cmd, struct arg *a);
 int int_arg(struct cmd_context *cmd, struct arg *a);
 int int_arg_with_sign(struct cmd_context *cmd, struct arg *a);
+int int_arg_with_sign_and_percent(struct cmd_context *cmd, struct arg *a);
 int major_arg(struct cmd_context *cmd, struct arg *a);
 int minor_arg(struct cmd_context *cmd, struct arg *a);
 int string_arg(struct cmd_context *cmd, struct arg *a);
@@ -148,6 +157,7 @@
 uint64_t arg_uint64_value(struct cmd_context *cmd, int a, const uint64_t def);
 const void *arg_ptr_value(struct cmd_context *cmd, int a, const void *def);
 sign_t arg_sign_value(struct cmd_context *cmd, int a, const sign_t def);
+percent_t arg_percent_value(struct cmd_context *cmd, int a, const percent_t def);
 int arg_count_increment(struct cmd_context *cmd, int a);
 
 const char *command_name(struct cmd_context *cmd);


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2006-09-26  9:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-09-26  9:35 LVM2 ./WHATS_NEW man/lvcreate.8 man/lvextend.8 agk

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).