public inbox for lvm2-cvs@sourceware.org
help / color / mirror / Atom feed
* LVM2/tools lvcreate.c
@ 2009-07-26  2:31 wysochanski
  0 siblings, 0 replies; 27+ messages in thread
From: wysochanski @ 2009-07-26  2:31 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-26 02:31:42

Modified files:
	tools          : lvcreate.c 

Log message:
	Move percent_t from struct lvcreate_params to struct lvcreate_cmdline_params.
	
	Create a new structure, lvcreate_cmdline_params, to store parameters only
	relevant for the cmdline, not the library call to lvcreate.
	Should be no functional change.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.201&r2=1.202

--- LVM2/tools/lvcreate.c	2009/07/26 02:31:18	1.201
+++ LVM2/tools/lvcreate.c	2009/07/26 02:31:41	1.202
@@ -18,6 +18,10 @@
 
 #include <fcntl.h>
 
+struct lvcreate_cmdline_params {
+	percent_t percent;
+};
+
 /* FIXME: refactor and reduce the size of this struct! */
 struct lvcreate_params {
 	/* flags */
@@ -46,7 +50,6 @@
 	uint64_t size;
 	uint32_t voriginextents;
 	uint64_t voriginsize;
-	percent_t percent;
 	struct dm_list *pvh;
 
 	uint32_t permission;
@@ -163,7 +166,8 @@
  * need the vg.
  */
 static int _update_extents_params(struct volume_group *vg,
-			       struct lvcreate_params *lp)
+				  struct lvcreate_params *lp,
+				  struct lvcreate_cmdline_params *lcp)
 {
 	uint32_t pv_extent_count;
 
@@ -178,7 +182,7 @@
 		return_0;
 
 	/*
-	 * Create the pv list before we parse lp->percent - might be
+	 * Create the pv list before we parse lcp->percent - might be
 	 * PERCENT_PVSs
 	 */
 	if (lp->pv_count) {
@@ -188,7 +192,7 @@
 	} else
 		lp->pvh = &vg->pvs;
 
-	switch(lp->percent) {
+	switch(lcp->percent) {
 		case PERCENT_VG:
 			lp->extents = lp->extents * vg->extent_count / 100;
 			break;
@@ -215,6 +219,7 @@
 }
 
 static int _read_size_params(struct lvcreate_params *lp,
+			     struct lvcreate_cmdline_params *lcp,
 			     struct cmd_context *cmd)
 {
 	if (arg_count(cmd, extents_ARG) + arg_count(cmd, size_ARG) != 1) {
@@ -228,7 +233,7 @@
 			return 0;
 		}
 		lp->extents = arg_uint_value(cmd, extents_ARG, 0);
-		lp->percent = arg_percent_value(cmd, extents_ARG, PERCENT_NONE);
+		lcp->percent = arg_percent_value(cmd, extents_ARG, PERCENT_NONE);
 	}
 
 	/* Size returned in kilobyte units; held in sectors */
@@ -238,7 +243,7 @@
 			return 0;
 		}
 		lp->size = arg_uint64_value(cmd, size_ARG, UINT64_C(0));
-		lp->percent = PERCENT_NONE;
+		lcp->percent = PERCENT_NONE;
 	}
 
 	/* Size returned in kilobyte units; held in sectors */
@@ -407,13 +412,16 @@
 	return 1;
 }
 
-static int _lvcreate_params(struct lvcreate_params *lp, struct cmd_context *cmd,
+static int _lvcreate_params(struct lvcreate_params *lp,
+			    struct lvcreate_cmdline_params *lcp,
+			    struct cmd_context *cmd,
 			    int argc, char **argv)
 {
 	int contiguous;
 	unsigned pagesize;
 
 	memset(lp, 0, sizeof(*lp));
+	memset(lcp, 0, sizeof(*lcp));
 
 	/*
 	 * Check selected options are compatible and determine segtype
@@ -508,7 +516,7 @@
 	}
 
 	if (!_lvcreate_name_params(lp, cmd, &argc, &argv) ||
-	    !_read_size_params(lp, cmd) ||
+	    !_read_size_params(lp, lcp, cmd) ||
 	    !_read_stripe_params(lp, cmd) ||
 	    !_read_mirror_params(lp, cmd))
 		return_0;
@@ -1006,11 +1014,12 @@
 {
 	int r = ECMD_PROCESSED;
 	struct lvcreate_params lp;
+	struct lvcreate_cmdline_params lcp;
 	struct volume_group *vg;
 
 	memset(&lp, 0, sizeof(lp));
 
-	if (!_lvcreate_params(&lp, cmd, argc, argv))
+	if (!_lvcreate_params(&lp, &lcp, cmd, argc, argv))
 		return EINVALID_CMD_LINE;
 
 	log_verbose("Finding volume group \"%s\"", lp.vg_name);
@@ -1020,7 +1029,7 @@
 		return ECMD_FAILED;
 	}
 
-	if (!_update_extents_params(vg, &lp))
+	if (!_update_extents_params(vg, &lp, &lcp))
 		return ECMD_FAILED;
 
 	if (!_lvcreate(vg, &lp))


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2012-03-02 20:18 zkabelac
  0 siblings, 0 replies; 27+ messages in thread
From: zkabelac @ 2012-03-02 20:18 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2012-03-02 20:18:25

Modified files:
	tools          : lvcreate.c 

Log message:
	Merge metadata size checking
	
	Move the code for poolmetadatasize operation into one place.
	Report override for minimum and maximum size.
	Drop _read_thin_params function its error reporting is handled elsewhere.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.259&r2=1.260

--- LVM2/tools/lvcreate.c	2012/03/02 17:25:21	1.259
+++ LVM2/tools/lvcreate.c	2012/03/02 20:18:25	1.260
@@ -293,15 +293,29 @@
 			break;
 	}
 
-	if (lp->create_thin_pool && !arg_count(vg->cmd, poolmetadatasize_ARG))
-		/* Defaults to nr_pool_blocks * 64b */
-		lp->poolmetadatasize =  (uint64_t) lp->extents * vg->extent_size /
-			(uint64_t) (lp->chunk_size * (SECTOR_SIZE / UINT64_C(64)));
-
-	if (lp->poolmetadatasize &&
-	    !(lp->poolmetadataextents = extents_from_size(vg->cmd, lp->poolmetadatasize,
-							  vg->extent_size)))
-		return_0;
+	if (lp->create_thin_pool) {
+		if (!arg_count(vg->cmd, poolmetadatasize_ARG))
+			/* Defaults to nr_pool_blocks * 64b */
+			lp->poolmetadatasize =  (uint64_t) lp->extents * vg->extent_size /
+				(uint64_t) (lp->chunk_size * (SECTOR_SIZE / UINT64_C(64)));
+
+		if (lp->poolmetadatasize > (2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE)) {
+			if (arg_count(vg->cmd, poolmetadatasize_ARG))
+				log_warn("WARNING: Maximum supported pool metadata size is 16GB.");
+			lp->poolmetadatasize = 2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE;
+		} else if (lp->poolmetadatasize < (2 * DEFAULT_THIN_POOL_MIN_METADATA_SIZE)) {
+			if (arg_count(vg->cmd, poolmetadatasize_ARG))
+				log_warn("WARNING: Minimum supported pool metadata size is 2M.");
+			lp->poolmetadatasize = 2 * DEFAULT_THIN_POOL_MIN_METADATA_SIZE;
+		}
+
+		log_verbose("Setting pool metadata size to %" PRIu64 " sectors.",
+			    lp->poolmetadatasize);
+
+		if (!(lp->poolmetadataextents =
+		      extents_from_size(vg->cmd, lp->poolmetadatasize, vg->extent_size)))
+			return_0;
+	}
 
 	return 1;
 }
@@ -511,33 +525,6 @@
 	return 1;
 }
 
-static int _read_thin_params(struct lvcreate_params *lp,
-			     struct cmd_context *cmd)
-{
-	if (!seg_is_thin(lp)) {
-		if (lp->poolmetadatasize) {
-			log_error("Pool metadata size option is only for pool creation.");
-			return 0;
-		}
-		return 1;
-	}
-
-	if (lp->create_thin_pool) {
-		if (lp->poolmetadatasize > (2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE)) {
-			log_warn("WARNING: Maximum supported pool metadata size is 16GB.");
-			lp->poolmetadatasize = 2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE;
-		} else if (lp->poolmetadatasize < (2 * DEFAULT_THIN_POOL_MIN_METADATA_SIZE))
-			lp->poolmetadatasize = 2 * DEFAULT_THIN_POOL_MIN_METADATA_SIZE;
-		log_verbose("Setting pool metadata size to %" PRIu64 " sectors.",
-			    lp->poolmetadatasize);
-	} else if (lp->poolmetadatasize) {
-		log_error("Pool metadata size options is only for pool creation.");
-		return 0;
-	}
-
-	return 1;
-}
-
 static int _read_activation_params(struct lvcreate_params *lp, struct cmd_context *cmd)
 {
 	unsigned pagesize;
@@ -737,8 +724,7 @@
 	    !_read_size_params(lp, lcp, cmd) ||
 	    !get_stripe_params(cmd, &lp->stripes, &lp->stripe_size) ||
 	    !_read_mirror_params(lp, cmd) ||
-	    !_read_raid_params(lp, cmd) ||
-	    !_read_thin_params(lp, cmd))
+	    !_read_raid_params(lp, cmd))
 		return_0;
 
 	if (lp->snapshot && lp->thin && arg_count(cmd, chunksize_ARG))


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2012-02-01  1:54 agk
  0 siblings, 0 replies; 27+ messages in thread
From: agk @ 2012-02-01  1:54 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2012-02-01 01:54:20

Modified files:
	tools          : lvcreate.c 

Log message:
	lp.pool may be (null) too

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.252&r2=1.253

--- LVM2/tools/lvcreate.c	2012/01/05 15:38:19	1.252
+++ LVM2/tools/lvcreate.c	2012/02/01 01:54:20	1.253
@@ -1017,7 +1017,8 @@
 	if (lp.thin)
 		log_verbose("Making thin LV %s in pool %s in VG %s%s%s using segtype %s",
 			    lp.lv_name ? : "with generated name",
-			    lp.pool, lp.vg_name, lp.snapshot ? " as snapshot of " : "",
+			    lp.pool ? : "with generated name", lp.vg_name,
+			    lp.snapshot ? " as snapshot of " : "",
 			    lp.snapshot ? lp.origin : "", lp.segtype->name);
 
 	if (!lv_create_single(vg, &lp)) {


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2011-11-10 12:40 zkabelac
  0 siblings, 0 replies; 27+ messages in thread
From: zkabelac @ 2011-11-10 12:40 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-11-10 12:40:29

Modified files:
	tools          : lvcreate.c 

Log message:
	Thin move _read_activation_params check
	
	Since we finaly recognize thin creation only after
	_determine_snapshot_type() - move _read_activation_params()
	after it - so we can support  lvcreate -an thin snapshot.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.248&r2=1.249

--- LVM2/tools/lvcreate.c	2011/11/10 12:39:46	1.248
+++ LVM2/tools/lvcreate.c	2011/11/10 12:40:29	1.249
@@ -789,9 +789,6 @@
 		return 0;
 	}
 
-	if (!_read_activation_params(lp, cmd))
-		return_0;
-
 	/*
 	 * Allocation parameters
 	 */
@@ -993,6 +990,15 @@
 		goto_out;
 	}
 
+	/*
+	 * Check activation parameters to support inactive thin snapshot creation
+	 * FIXME: anything else needs to be moved past _determine_snapshot_type()?
+	 */
+	if (!_read_activation_params(&lp, cmd)) {
+		r = ECMD_FAILED;
+		goto_out;
+	}
+
 	if (!_update_extents_params(vg, &lp, &lcp)) {
 		r = ECMD_FAILED;
 		goto_out;


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2011-11-10 12:39 zkabelac
  0 siblings, 0 replies; 27+ messages in thread
From: zkabelac @ 2011-11-10 12:39 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-11-10 12:39:46

Modified files:
	tools          : lvcreate.c 

Log message:
	Thin create normal (old) snapshot when size is specified

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.247&r2=1.248

--- LVM2/tools/lvcreate.c	2011/11/07 11:03:48	1.247
+++ LVM2/tools/lvcreate.c	2011/11/10 12:39:46	1.248
@@ -204,7 +204,12 @@
 		return 0;
 	}
 
-	if (lv_is_thin_volume(lvl->lv)) {
+	if (!arg_count(vg->cmd, extents_ARG) && !arg_count(vg->cmd, size_ARG)) {
+		if (!lv_is_thin_volume(lvl->lv)) {
+			log_error("Please specify either size or extents with snapshots.");
+			return 0;
+		}
+
 		lp->thin = 1;
 		if (!(lp->segtype = get_segtype_from_string(vg->cmd, "thin")))
 			return_0;
@@ -212,11 +217,6 @@
 		lp->pool = first_seg(lvl->lv)->pool_lv->name;
 	}
 
-	if (!lp->thin && !arg_count(vg->cmd, extents_ARG) && !arg_count(vg->cmd, size_ARG)) {
-		log_error("Please specify either size or extents with snapshots.");
-		return 0;
-	}
-
 	return 1;
 }
 


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2011-09-27 12:37 agk
  0 siblings, 0 replies; 27+ messages in thread
From: agk @ 2011-09-27 12:37 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2011-09-27 12:37:07

Modified files:
	tools          : lvcreate.c 

Log message:
	better -m0 error message, but there's an internal logic error to fix instead

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.242&r2=1.243

--- LVM2/tools/lvcreate.c	2011/09/22 15:36:21	1.242
+++ LVM2/tools/lvcreate.c	2011/09/27 12:37:07	1.243
@@ -575,11 +575,14 @@
 	/*
 	 * Check selected options are compatible and determine segtype
 	 */
+// FIXME -m0 implies *striped*
 	if (arg_count(cmd, thin_ARG) && arg_count(cmd,mirrors_ARG)) {
 		log_error("--thin and --mirrors are incompatible.");
 		return 0;
 	}
 
+// FIXME -m0 implies *striped*
+
 	/* Set default segtype */
 	if (arg_count(cmd, mirrors_ARG))
 		segtype_str = find_config_tree_str(cmd, "global/mirror_segtype_default", DEFAULT_MIRROR_SEGTYPE);
@@ -620,7 +623,7 @@
 		lp->mirrors = arg_uint_value(cmd, mirrors_ARG, 0) + 1;
 		if (lp->mirrors == 1) {
 			if (segtype_is_mirrored(lp->segtype)) {
-				log_error("Image count for segtype \"%s\" cannot be 0.", lp->segtype->name);
+				log_error("--mirrors must be at least 1 with segment type %s.", lp->segtype->name);
 				return 0;
 			}
 			log_print("Redundant mirrors argument: default is 0");


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2011-09-07  9:25 zkabelac
  0 siblings, 0 replies; 27+ messages in thread
From: zkabelac @ 2011-09-07  9:25 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2011-09-07 09:25:51

Modified files:
	tools          : lvcreate.c 

Log message:
	Check if lp.origin exists
	
	Currently needed for _determine_snapshot_type().

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.238&r2=1.239

--- LVM2/tools/lvcreate.c	2011/09/06 22:43:58	1.238
+++ LVM2/tools/lvcreate.c	2011/09/07 09:25:51	1.239
@@ -896,7 +896,7 @@
 		return ECMD_FAILED;
 	}
 
-	if (lp.snapshot && !_determine_snapshot_type(vg, &lp)) {
+	if (lp.snapshot && lp.origin && !_determine_snapshot_type(vg, &lp)) {
 		r = ECMD_FAILED;
 		goto_out;
 	}


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2011-09-06 15:35 agk
  0 siblings, 0 replies; 27+ messages in thread
From: agk @ 2011-09-06 15:35 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2011-09-06 15:35:11

Modified files:
	tools          : lvcreate.c 

Log message:
	only thin volumes need converting

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.235&r2=1.236

--- LVM2/tools/lvcreate.c	2011/09/06 00:26:43	1.235
+++ LVM2/tools/lvcreate.c	2011/09/06 15:35:11	1.236
@@ -343,7 +343,7 @@
 		}
 	} else {
 		/* No virtual size given, so no thin LV to create. */
-		if (!seg_is_thin_pool(lp) && !(lp->segtype = get_segtype_from_string(cmd, "thin_pool")))
+		if (seg_is_thin_volume(lp) && !(lp->segtype = get_segtype_from_string(cmd, "thin_pool")))
 			return_0;
 
 		lp->thin = 0;


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2011-03-25 21:56 jbrassow
  0 siblings, 0 replies; 27+ messages in thread
From: jbrassow @ 2011-03-25 21:56 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2011-03-25 21:56:28

Modified files:
	tools          : lvcreate.c 

Log message:
	cosmetic change - swapping one macro for another
	
	When I see 'seg_is_mirrored', I expect the argument to be an lv_segment.
	In this case, it is lvcreate_params.  Both structures, have a 'segtype'
	entry which the macro dereferences.  However, it just seems easier to
	understand if we do 'segtype_is_mirrored' instead.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.229&r2=1.230

--- LVM2/tools/lvcreate.c	2011/02/18 14:47:31	1.229
+++ LVM2/tools/lvcreate.c	2011/03/25 21:56:28	1.230
@@ -346,7 +346,7 @@
 	lp->mirrors = 1;
 
 	/* Default to 2 mirrored areas if --type mirror */
-	if (seg_is_mirrored(lp))
+	if (segtype_is_mirrored(lp->segtype))
 		lp->mirrors = 2;
 
 	if (arg_count(cmd, mirrors_ARG)) {


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2010-10-25 12:05 zkabelac
  0 siblings, 0 replies; 27+ messages in thread
From: zkabelac @ 2010-10-25 12:05 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	zkabelac@sourceware.org	2010-10-25 12:05:46

Modified files:
	tools          : lvcreate.c 

Log message:
	Ensure we always have origin defined
	
	Reported by clang as: Logic error Dereference of null pointer
	Make sure the code path could not use NULL origin because of some internal
	code error.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.223&r2=1.224

--- LVM2/tools/lvcreate.c	2010/07/09 15:34:48	1.223
+++ LVM2/tools/lvcreate.c	2010/10/25 12:05:46	1.224
@@ -179,6 +179,10 @@
 					  lp->origin);
 				return 0;
 			}
+			if (!origin) {
+				log_error(INTERNAL_ERROR "Couldn't find origin volume.");
+				return 0;
+			}
 			lp->extents = lp->extents * origin->le_count / 100;
 			break;
 		case PERCENT_NONE:


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2010-05-11 21:40 jbrassow
  0 siblings, 0 replies; 27+ messages in thread
From: jbrassow @ 2010-05-11 21:40 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow@sourceware.org	2010-05-11 21:40:12

Modified files:
	tools          : lvcreate.c 

Log message:
	If we are checking if '--nosync' was called with the mirror argument,
	then let's also check if '--mirrorlog' was called with the mirror
	argument.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.221&r2=1.222

--- LVM2/tools/lvcreate.c	2010/04/29 01:38:14	1.221
+++ LVM2/tools/lvcreate.c	2010/05/11 21:40:11	1.222
@@ -394,6 +394,11 @@
 			return 0;
 		}
 
+		if (arg_count(cmd, mirrorlog_ARG)) {
+			log_error("--mirrorlog is only available with mirrors");
+			return 0;
+		}
+
 		if (arg_count(cmd, nosync_ARG)) {
 			log_error("--nosync is only available with mirrors");
 			return 0;


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2009-07-26  2:32 wysochanski
  0 siblings, 0 replies; 27+ messages in thread
From: wysochanski @ 2009-07-26  2:32 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-26 02:32:00

Modified files:
	tools          : lvcreate.c 

Log message:
	Move 'size' from lvcreate_params into lvcreate_cmdline_params.
	
	The main _lvcreate function should deal with extents - the 'size' parameter
	is just an intermediate step.
	Should be no functional change.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.202&r2=1.203

--- LVM2/tools/lvcreate.c	2009/07/26 02:31:41	1.202
+++ LVM2/tools/lvcreate.c	2009/07/26 02:32:00	1.203
@@ -20,6 +20,7 @@
 
 struct lvcreate_cmdline_params {
 	percent_t percent;
+	uint64_t size;
 };
 
 /* FIXME: refactor and reduce the size of this struct! */
@@ -47,7 +48,6 @@
 
 	/* size */
 	uint32_t extents;
-	uint64_t size;
 	uint32_t voriginextents;
 	uint64_t voriginsize;
 	struct dm_list *pvh;
@@ -171,8 +171,8 @@
 {
 	uint32_t pv_extent_count;
 
-	if (lp->size &&
-	    !(lp->extents = _extents_from_size(vg->cmd, lp->size,
+	if (lcp->size &&
+	    !(lp->extents = _extents_from_size(vg->cmd, lcp->size,
 					       vg->extent_size)))
 		return_0;
 
@@ -242,7 +242,7 @@
 			log_error("Negative size is invalid");
 			return 0;
 		}
-		lp->size = arg_uint64_value(cmd, size_ARG, UINT64_C(0));
+		lcp->size = arg_uint64_value(cmd, size_ARG, UINT64_C(0));
 		lcp->percent = PERCENT_NONE;
 	}
 


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2009-07-26  2:32 wysochanski
  0 siblings, 0 replies; 27+ messages in thread
From: wysochanski @ 2009-07-26  2:32 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-26 02:32:27

Modified files:
	tools          : lvcreate.c 

Log message:
	Comment lvcreate_params struct.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.203&r2=1.204

--- LVM2/tools/lvcreate.c	2009/07/26 02:32:00	1.203
+++ LVM2/tools/lvcreate.c	2009/07/26 02:32:26	1.204
@@ -26,39 +26,39 @@
 /* FIXME: refactor and reduce the size of this struct! */
 struct lvcreate_params {
 	/* flags */
-	int snapshot;
-	int zero;
-	int major;
-	int minor;
-	int corelog;
-	int nosync;
+	int snapshot; /* snap */
+	int zero; /* all */
+	int major; /* all */
+	int minor; /* all */
+	int corelog; /* mirror */
+	int nosync; /* mirror */
+
+	char *origin; /* snap */
+	const char *vg_name; /* all */
+	const char *lv_name; /* all */
+
+	uint32_t stripes; /* striped */
+	uint32_t stripe_size; /* striped */
+	uint32_t chunk_size; /* snapshot */
+	uint32_t region_size; /* mirror */
 
-	char *origin;
-	const char *vg_name;
-	const char *lv_name;
-
-	uint32_t stripes;
-	uint32_t stripe_size;
-	uint32_t chunk_size;
-	uint32_t region_size;
+	uint32_t mirrors; /* mirror */
 
-	uint32_t mirrors;
-
-	const struct segment_type *segtype;
+	const struct segment_type *segtype; /* all */
 
 	/* size */
-	uint32_t extents;
-	uint32_t voriginextents;
-	uint64_t voriginsize;
-	struct dm_list *pvh;
-
-	uint32_t permission;
-	uint32_t read_ahead;
-	alloc_policy_t alloc;
-
-	int pv_count;
-	char **pvs;
-	const char *tag;
+	uint32_t extents; /* all */
+	uint32_t voriginextents; /* snapshot */
+	uint64_t voriginsize; /* snapshot */
+	struct dm_list *pvh; /* all */
+
+	uint32_t permission; /* all */
+	uint32_t read_ahead; /* all */
+	alloc_policy_t alloc; /* all */
+
+	int pv_count; /* all; redundant? */
+	char **pvs; /* all; redundant? */
+	const char *tag; /* all */
 };
 
 static uint64_t _extents_from_size(struct cmd_context *cmd, uint64_t size,


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2009-07-26  2:32 wysochanski
  0 siblings, 0 replies; 27+ messages in thread
From: wysochanski @ 2009-07-26  2:32 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-26 02:32:50

Modified files:
	tools          : lvcreate.c 

Log message:
	Move pvs and pv_count fields from lvcreate_params to lvcreate_cmdline_params.
	
	No functional change.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.204&r2=1.205

--- LVM2/tools/lvcreate.c	2009/07/26 02:32:26	1.204
+++ LVM2/tools/lvcreate.c	2009/07/26 02:32:50	1.205
@@ -21,6 +21,8 @@
 struct lvcreate_cmdline_params {
 	percent_t percent;
 	uint64_t size;
+	char **pvs;
+	int pv_count;
 };
 
 /* FIXME: refactor and reduce the size of this struct! */
@@ -56,8 +58,6 @@
 	uint32_t read_ahead; /* all */
 	alloc_policy_t alloc; /* all */
 
-	int pv_count; /* all; redundant? */
-	char **pvs; /* all; redundant? */
 	const char *tag; /* all */
 };
 
@@ -185,9 +185,9 @@
 	 * Create the pv list before we parse lcp->percent - might be
 	 * PERCENT_PVSs
 	 */
-	if (lp->pv_count) {
+	if (lcp->pv_count) {
 		if (!(lp->pvh = create_pv_list(vg->cmd->mem, vg,
-					   lp->pv_count, lp->pvs, 1)))
+					   lcp->pv_count, lcp->pvs, 1)))
 			return_0;
 	} else
 		lp->pvh = &vg->pvs;
@@ -200,7 +200,7 @@
 			lp->extents = lp->extents * vg->free_count / 100;
 			break;
 		case PERCENT_PVS:
-			if (!lp->pv_count) {
+			if (!lcp->pv_count) {
 				log_error("Please specify physical volume(s) "
 					  "with %%PVS");
 				return 0;
@@ -603,8 +603,8 @@
 		return 0;
 	}
 
-	lp->pv_count = argc;
-	lp->pvs = argv;
+	lcp->pv_count = argc;
+	lcp->pvs = argv;
 
 	return 1;
 }


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2009-07-26  2:31 wysochanski
  0 siblings, 0 replies; 27+ messages in thread
From: wysochanski @ 2009-07-26  2:31 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-26 02:31:18

Modified files:
	tools          : lvcreate.c 

Log message:
	Refactor extents calculations / updates in _lvcreate.
	
	Move extents calculation adjustments into their own local functions
	right after we read the vg.  This calculation really is not part of
	the LV create function but is rather an adjustment to the parameters
	based on what is given on the cmdline.  So we move it outside the main
	_lvcreate.
	
	Should be no functional change.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.200&r2=1.201

--- LVM2/tools/lvcreate.c	2009/07/26 02:30:57	1.200
+++ LVM2/tools/lvcreate.c	2009/07/26 02:31:18	1.201
@@ -18,6 +18,7 @@
 
 #include <fcntl.h>
 
+/* FIXME: refactor and reduce the size of this struct! */
 struct lvcreate_params {
 	/* flags */
 	int snapshot;
@@ -46,6 +47,7 @@
 	uint32_t voriginextents;
 	uint64_t voriginsize;
 	percent_t percent;
+	struct dm_list *pvh;
 
 	uint32_t permission;
 	uint32_t read_ahead;
@@ -56,6 +58,9 @@
 	const char *tag;
 };
 
+static uint64_t _extents_from_size(struct cmd_context *cmd, uint64_t size,
+				   uint32_t extent_size);
+
 static int _lvcreate_name_params(struct lvcreate_params *lp,
 				 struct cmd_context *cmd,
 				 int *pargc, char ***pargv)
@@ -151,6 +156,64 @@
 	return 1;
 }
 
+/*
+ * Update extents parameters based on other parameters which affect the size
+ * calcuation.
+ * NOTE: We must do this here because of the percent_t typedef and because we
+ * need the vg.
+ */
+static int _update_extents_params(struct volume_group *vg,
+			       struct lvcreate_params *lp)
+{
+	uint32_t pv_extent_count;
+
+	if (lp->size &&
+	    !(lp->extents = _extents_from_size(vg->cmd, lp->size,
+					       vg->extent_size)))
+		return_0;
+
+	if (lp->voriginsize &&
+	    !(lp->voriginextents = _extents_from_size(vg->cmd, lp->voriginsize,
+						      vg->extent_size)))
+		return_0;
+
+	/*
+	 * Create the pv list before we parse lp->percent - might be
+	 * PERCENT_PVSs
+	 */
+	if (lp->pv_count) {
+		if (!(lp->pvh = create_pv_list(vg->cmd->mem, vg,
+					   lp->pv_count, lp->pvs, 1)))
+			return_0;
+	} else
+		lp->pvh = &vg->pvs;
+
+	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_PVS:
+			if (!lp->pv_count) {
+				log_error("Please specify physical volume(s) "
+					  "with %%PVS");
+				return 0;
+			}
+			pv_extent_count = pv_list_extents_free(lp->pvh);
+			lp->extents = lp->extents * pv_extent_count / 100;
+			break;
+		case PERCENT_LV:
+			log_error("Please express size as %%VG, %%PVS, or "
+				  "%%FREE.");
+			return 0;
+		case PERCENT_NONE:
+			break;
+	}
+	return 1;
+}
+
 static int _read_size_params(struct lvcreate_params *lp,
 			     struct cmd_context *cmd)
 {
@@ -607,12 +670,10 @@
 	uint32_t size_rest;
 	uint32_t status = 0;
 	struct logical_volume *lv, *org = NULL;
-	struct dm_list *pvh;
 	int origin_active = 0;
 	char lv_name_buf[128];
 	const char *lv_name;
 	struct lvinfo info;
-	uint32_t pv_extent_count;
 
 	if (lp->lv_name && find_lv_in_vg(vg, lp->lv_name)) {
 		log_error("Logical volume \"%s\" already exists in "
@@ -656,49 +717,6 @@
 		return 0;
 	}
 
-	if (lp->size &&
-	    !(lp->extents = _extents_from_size(cmd, lp->size, vg->extent_size)))
-		return_0;
-
-	if (lp->voriginsize &&
-	    !(lp->voriginextents = _extents_from_size(cmd, lp->voriginsize,
-						      vg->extent_size)))
-		return_0;
-
-	/*
-	 * Create the pv list.
-	 */
-	if (lp->pv_count) {
-		if (!(pvh = create_pv_list(cmd->mem, vg,
-					   lp->pv_count, lp->pvs, 1)))
-			return_0;
-	} else
-		pvh = &vg->pvs;
-
-	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_PVS:
-			if (!lp->pv_count) {
-				log_error("Please specify physical volume(s) "
-					  "with %%PVS");
-				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, %%PVS, 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,
@@ -782,10 +800,10 @@
 		return 0;
 	}
 
-	if (lp->stripes > dm_list_size(pvh) && lp->alloc != ALLOC_ANYWHERE) {
+	if (lp->stripes > dm_list_size(lp->pvh) && lp->alloc != ALLOC_ANYWHERE) {
 		log_error("Number of stripes (%u) must not exceed "
 			  "number of physical volumes (%d)", lp->stripes,
-			  dm_list_size(pvh));
+			  dm_list_size(lp->pvh));
 		return 0;
 	}
 
@@ -855,7 +873,7 @@
 	}
 
 	if (!lv_extend(lv, lp->segtype, lp->stripes, lp->stripe_size,
-		       1, lp->extents, NULL, 0u, 0u, pvh, lp->alloc))
+		       1, lp->extents, NULL, 0u, 0u, lp->pvh, lp->alloc))
 		return_0;
 
 	if (lp->mirrors > 1) {
@@ -864,7 +882,7 @@
 						vg->extent_size,
 						lv->le_count,
 						lp->region_size),
-				    lp->corelog ? 0U : 1U, pvh, lp->alloc,
+				    lp->corelog ? 0U : 1U, lp->pvh, lp->alloc,
 				    MIRROR_BY_LV |
 				    (lp->nosync ? MIRROR_SKIP_INIT_SYNC : 0))) {
 			stack;
@@ -1002,6 +1020,9 @@
 		return ECMD_FAILED;
 	}
 
+	if (!_update_extents_params(vg, &lp))
+		return ECMD_FAILED;
+
 	if (!_lvcreate(vg, &lp))
 		r = ECMD_FAILED;
 


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2009-07-26  2:30 wysochanski
  0 siblings, 0 replies; 27+ messages in thread
From: wysochanski @ 2009-07-26  2:30 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2009-07-26 02:30:57

Modified files:
	tools          : lvcreate.c 

Log message:
	Refactor _lvcreate - move *_ARG into _lvcreate_params and get 'cmd' from 'vg'.
	
	A couple simple refactorings of _lvcreate - should be no functional change.
	Move tags_ARG parsing into _lvcreate_params.  Also use lp->voriginsize
	instread of arg_count().  These refactorings make it easier to move the
	bulk of _lvcreate into the library.
	
	Author: Dave Wysochanski <dwysocha@redhat.com>

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.199&r2=1.200

--- LVM2/tools/lvcreate.c	2009/07/15 20:02:48	1.199
+++ LVM2/tools/lvcreate.c	2009/07/26 02:30:57	1.200
@@ -53,6 +53,7 @@
 
 	int pv_count;
 	char **pvs;
+	const char *tag;
 };
 
 static int _lvcreate_name_params(struct lvcreate_params *lp,
@@ -525,6 +526,12 @@
 		return 0;
 	}
 
+	if (arg_count(cmd, addtag_ARG) &&
+	    !(lp->tag = arg_str_value(cmd, addtag_ARG, NULL))) {
+		log_error("Failed to get tag");
+		return 0;
+	}
+
 	lp->pv_count = argc;
 	lp->pvs = argv;
 
@@ -593,14 +600,14 @@
 	return lv;
 }
 
-static int _lvcreate(struct cmd_context *cmd, struct volume_group *vg,
+static int _lvcreate(struct volume_group *vg,
 		     struct lvcreate_params *lp)
 {
+	struct cmd_context *cmd = vg->cmd;
 	uint32_t size_rest;
 	uint32_t status = 0;
 	struct logical_volume *lv, *org = NULL;
 	struct dm_list *pvh;
-	const char *tag = NULL;
 	int origin_active = 0;
 	char lv_name_buf[128];
 	const char *lv_name;
@@ -722,7 +729,7 @@
 		/* Must zero cow */
 		status |= LVM_WRITE;
 
-		if (arg_count(cmd, virtualsize_ARG))
+		if (lp->voriginsize)
 			origin_active = 1;
 		else {
 
@@ -806,12 +813,7 @@
 		lv_name = &lv_name_buf[0];
 	}
 
-	if (arg_count(cmd, addtag_ARG)) {
-		if (!(tag = arg_str_value(cmd, addtag_ARG, NULL))) {
-			log_error("Failed to get tag");
-			return 0;
-		}
-
+	if (lp->tag) {
 		if (!(vg->fid->fmt->features & FMT_TAGS)) {
 			log_error("Volume group %s does not support tags",
 				  vg->name);
@@ -846,9 +848,9 @@
 			    lv->minor);
 	}
 
-	if (tag && !str_list_add(cmd->mem, &lv->tags, tag)) {
+	if (lp->tag && !str_list_add(cmd->mem, &lv->tags, lp->tag)) {
 		log_error("Failed to add tag %s to %s/%s",
-			  tag, lv->vg->name, lv->name);
+			  lp->tag, lv->vg->name, lv->name);
 		return 0;
 	}
 
@@ -1000,7 +1002,7 @@
 		return ECMD_FAILED;
 	}
 
-	if (!_lvcreate(cmd, vg, &lp))
+	if (!_lvcreate(vg, &lp))
 		r = ECMD_FAILED;
 
 	unlock_and_release_vg(cmd, vg, lp.vg_name);


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2009-06-06 22:06 mbroz
  0 siblings, 0 replies; 27+ messages in thread
From: mbroz @ 2009-06-06 22:06 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	mbroz@sourceware.org	2009-06-06 22:06:54

Modified files:
	tools          : lvcreate.c 

Log message:
	Fix the same readahead rounding in lvcreate.
	
	(fixes previous commit)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.192&r2=1.193

--- LVM2/tools/lvcreate.c	2009/05/27 18:19:21	1.192
+++ LVM2/tools/lvcreate.c	2009/06/06 22:06:54	1.193
@@ -477,9 +477,12 @@
 	if (lp->read_ahead != DM_READ_AHEAD_AUTO &&
 	    lp->read_ahead != DM_READ_AHEAD_NONE &&
 	    lp->read_ahead % pagesize) {
-		lp->read_ahead = (lp->read_ahead / pagesize) * pagesize;
-		log_verbose("Rounding down readahead to %u sectors, a multiple "
-			    "of page size %u.", lp->read_ahead, pagesize);
+		if (lp->read_ahead < pagesize)
+			lp->read_ahead = pagesize;
+		else
+			lp->read_ahead = (lp->read_ahead / pagesize) * pagesize;
+		log_warn("WARNING: Overriding readahead to %u sectors, a multiple "
+			    "of %uK page size.", lp->read_ahead, pagesize >> 1);
 	}
 
 	/*


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2009-05-27 13:07 agk
  0 siblings, 0 replies; 27+ messages in thread
From: agk @ 2009-05-27 13:07 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2009-05-27 13:07:37

Modified files:
	tools          : lvcreate.c 

Log message:
	0->NULL (mbroz)

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.189&r2=1.190

--- LVM2/tools/lvcreate.c	2009/05/21 03:04:53	1.189
+++ LVM2/tools/lvcreate.c	2009/05/27 13:07:37	1.190
@@ -566,27 +566,27 @@
 
 	if (!(segtype = get_segtype_from_string(cmd, "zero"))) {
 		log_error("Zero segment type for virtual origin not found");
-		return 0;
+		return NULL;
 	}
 
 	len = strlen(lv_name) + 32;
 	if (!(vorigin_name = alloca(len)) ||
 	    dm_snprintf(vorigin_name, len, "%s_vorigin", lv_name) < 0) {
 		log_error("Virtual origin name allocation failed.");
-		return 0;
+		return NULL;
 	}
 
 	if (!(lv = lv_create_empty(vorigin_name, NULL, permission,
 				   ALLOC_INHERIT, vg)))
-		return_0;
+		return_NULL;
 
 	if (!lv_extend(lv, segtype, 1, 0, 1, voriginextents, NULL, 0u, 0u,
 		       NULL, ALLOC_INHERIT))
-		return_0;
+		return_NULL;
 
 	/* store vg on disk(s) */
 	if (!vg_write(vg) || !vg_commit(vg))
-		return_0;
+		return_NULL;
 
 	backup(vg);
 


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2009-04-26  8:12 prajnoha
  0 siblings, 0 replies; 27+ messages in thread
From: prajnoha @ 2009-04-26  8:12 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	prajnoha@sourceware.org	2009-04-26 08:12:12

Modified files:
	tools          : lvcreate.c 

Log message:
	Fix wrong arg in lv_is_virtual_origin call while creating snapshots.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.183&r2=1.184

--- LVM2/tools/lvcreate.c	2009/04/25 01:18:00	1.183
+++ LVM2/tools/lvcreate.c	2009/04/26 08:12:12	1.184
@@ -725,7 +725,7 @@
 					  lp->origin);
 				return 0;
 			}
-			if (lv_is_virtual_origin(lv)) {
+			if (lv_is_virtual_origin(org)) {
 				log_error("Can't share virtual origins. "
 					  "Use --virtualoriginsize.");
 				return 0;


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2008-07-17 15:19 wysochanski
  0 siblings, 0 replies; 27+ messages in thread
From: wysochanski @ 2008-07-17 15:19 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2008-07-17 15:19:42

Modified files:
	tools          : lvcreate.c 

Log message:
	Refactor _lvcreate() - no functional change.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.175&r2=1.176

--- LVM2/tools/lvcreate.c	2008/06/05 13:38:30	1.175
+++ LVM2/tools/lvcreate.c	2008/07/17 15:19:42	1.176
@@ -523,8 +523,6 @@
 	struct lvinfo info;
 	uint32_t pv_extent_count;
 
-	status |= lp->permission | VISIBLE_LV;
-
 	if (lp->lv_name && find_lv_in_vg(vg, lp->lv_name)) {
 		log_error("Logical volume \"%s\" already exists in "
 			  "volume group \"%s\"", lp->lv_name, lp->vg_name);
@@ -544,16 +542,6 @@
 		return 0;
 	}
 
-	/*
-	 * Create the pv list.
-	 */
-	if (lp->pv_count) {
-		if (!(pvh = create_pv_list(cmd->mem, vg,
-					   lp->pv_count, lp->pvs, 1)))
-			return_0;
-	} else
-		pvh = &vg->pvs;
-
 	if (lp->stripe_size > vg->extent_size) {
 		log_error("Reducing requested stripe size %s to maximum, "
 			  "physical extent size %s",
@@ -594,6 +582,16 @@
 		lp->extents = (uint64_t) tmp_size / vg->extent_size;
 	}
 
+	/*
+	 * Create the pv list.
+	 */
+	if (lp->pv_count) {
+		if (!(pvh = create_pv_list(cmd->mem, vg,
+					   lp->pv_count, lp->pvs, 1)))
+			return_0;
+	} else
+		pvh = &vg->pvs;
+
 	switch(lp->percent) {
 		case PERCENT_VG:
 			lp->extents = lp->extents * vg->extent_count / 100;
@@ -631,6 +629,8 @@
 		return 0;
 	}
 
+	status |= lp->permission | VISIBLE_LV;
+
 	if (lp->snapshot) {
 		if (!activation()) {
 			log_error("Can't create snapshot without using "


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2008-01-16 15:26 agk
  0 siblings, 0 replies; 27+ messages in thread
From: agk @ 2008-01-16 15:26 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2008-01-16 15:26:40

Modified files:
	tools          : lvcreate.c 

Log message:
	revert temp change

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.166&r2=1.167

--- LVM2/tools/lvcreate.c	2008/01/16 15:25:10	1.166
+++ LVM2/tools/lvcreate.c	2008/01/16 15:26:40	1.167
@@ -705,11 +705,11 @@
 		return 0;
 	}
 
-//	if (lp->mirrors > 1 && !activation()) {
-		//log_error("Can't create mirror without using "
-			  //"device-mapper kernel driver.");
-		//return 0;
-	//}
+	if (lp->mirrors > 1 && !activation()) {
+		log_error("Can't create mirror without using "
+			  "device-mapper kernel driver.");
+		return 0;
+	}
 
 	/* The snapshot segment gets created later */
 	if (lp->snapshot &&


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2007-10-01 15:01 wysochanski
  0 siblings, 0 replies; 27+ messages in thread
From: wysochanski @ 2007-10-01 15:01 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2007-10-01 15:01:26

Modified files:
	tools          : lvcreate.c 

Log message:
	Remove unused pargc parameter

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.149&r2=1.150

--- LVM2/tools/lvcreate.c	2007/09/24 21:30:00	1.149
+++ LVM2/tools/lvcreate.c	2007/10/01 15:01:26	1.150
@@ -216,8 +216,7 @@
  * power of 2, we must divide UINT_MAX by four and add 1 (to round it
  * up to the power of 2) */
 static int _read_stripe_params(struct lvcreate_params *lp,
-			       struct cmd_context *cmd,
-			       int *pargc __attribute((unused)))
+			       struct cmd_context *cmd)
 {
 	if (arg_count(cmd, stripesize_ARG)) {
 		if (arg_sign_value(cmd, stripesize_ARG, 0) == SIGN_MINUS) {
@@ -271,8 +270,7 @@
 }
 
 static int _read_mirror_params(struct lvcreate_params *lp,
-			       struct cmd_context *cmd,
-			       int *pargc __attribute((unused)))
+			       struct cmd_context *cmd)
 {
 	int region_size;
 	const char *mirrorlog;
@@ -429,8 +427,8 @@
 
 	if (!_lvcreate_name_params(lp, cmd, &argc, &argv) ||
 	    !_read_size_params(lp, cmd) ||
-	    !_read_stripe_params(lp, cmd, &argc) ||
-	    !_read_mirror_params(lp, cmd, &argc)) {
+	    !_read_stripe_params(lp, cmd) ||
+	    !_read_mirror_params(lp, cmd)) {
 		stack;
 		return 0;
 	}


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2007-09-24 13:29 wysochanski
  0 siblings, 0 replies; 27+ messages in thread
From: wysochanski @ 2007-09-24 13:29 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski@sourceware.org	2007-09-24 13:29:49

Modified files:
	tools          : lvcreate.c 

Log message:
	Refactor lvcreate mirror parameter validation.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.147&r2=1.148

--- LVM2/tools/lvcreate.c	2007/09/24 13:25:31	1.147
+++ LVM2/tools/lvcreate.c	2007/09/24 13:29:49	1.148
@@ -240,31 +240,14 @@
 	return 1;
 }
 
-static int _read_mirror_params(struct lvcreate_params *lp,
-			       struct cmd_context *cmd,
-			       int *pargc __attribute((unused)))
+/*
+ * Generic mirror parameter checks.
+ * FIXME: Should eventually be moved into lvm library.
+ */
+static int _validate_mirror_params(struct cmd_context *cmd,
+				   struct lvcreate_params *lp)
 {
-	int region_size;
 	int pagesize = lvm_getpagesize();
-	const char *mirrorlog;
-
-	if (arg_count(cmd, regionsize_ARG)) {
-		if (arg_sign_value(cmd, regionsize_ARG, 0) == SIGN_MINUS) {
-			log_error("Negative regionsize is invalid");
-			return 0;
-		}
-		lp->region_size = 2 * arg_uint_value(cmd, regionsize_ARG, 0);
-	} else {
-		region_size = 2 * find_config_tree_int(cmd,
-					"activation/mirror_region_size",
-					DEFAULT_MIRROR_REGION_SIZE);
-		if (region_size < 0) {
-			log_error("Negative regionsize in configuration file "
-				  "is invalid");
-			return 0;
-		}
-		lp->region_size = region_size;
-	}
 
 	if (lp->region_size & (lp->region_size - 1)) {
 		log_error("Region size (%" PRIu32 ") must be a power of 2",
@@ -284,6 +267,16 @@
 		return 0;
 	}
 
+	return 1;
+}
+
+static int _read_mirror_params(struct lvcreate_params *lp,
+			       struct cmd_context *cmd,
+			       int *pargc __attribute((unused)))
+{
+	int region_size;
+	const char *mirrorlog;
+
 	if (arg_count(cmd, corelog_ARG))
 		lp->corelog = 1;
 
@@ -308,6 +301,27 @@
 
 	lp->nosync = arg_count(cmd, nosync_ARG) ? 1 : 0;
 
+	if (arg_count(cmd, regionsize_ARG)) {
+		if (arg_sign_value(cmd, regionsize_ARG, 0) == SIGN_MINUS) {
+			log_error("Negative regionsize is invalid");
+			return 0;
+		}
+		lp->region_size = 2 * arg_uint_value(cmd, regionsize_ARG, 0);
+	} else {
+		region_size = 2 * find_config_tree_int(cmd,
+					"activation/mirror_region_size",
+					DEFAULT_MIRROR_REGION_SIZE);
+		if (region_size < 0) {
+			log_error("Negative regionsize in configuration file "
+				  "is invalid");
+			return 0;
+		}
+		lp->region_size = region_size;
+	}
+
+	if (!_validate_mirror_params(cmd, lp))
+		return 0;
+
 	return 1;
 }
 


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2006-10-16 16:47 agk
  0 siblings, 0 replies; 27+ messages in thread
From: agk @ 2006-10-16 16:47 UTC (permalink / raw)
  To: lvm-devel, lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2006-10-16 16:47:56

Modified files:
	tools          : lvcreate.c 

Log message:
	revert

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.126&r2=1.127

--- LVM2/tools/lvcreate.c	2006/10/16 16:44:28	1.126
+++ LVM2/tools/lvcreate.c	2006/10/16 16:47:56	1.127
@@ -637,11 +637,11 @@
 		return 0;
 	}
 
-	////if (lp->mirrors > 1 && !activation()) {
-		//log_error("Can't create mirror without using "
-			  //"device-mapper kernel driver.");
-		//return 0;
-	//}
+	if (lp->mirrors > 1 && !activation()) {
+		log_error("Can't create mirror without using "
+			  "device-mapper kernel driver.");
+		return 0;
+	}
 
 	/* The snapshot segment gets created later */
 	if (lp->snapshot &&


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2005-11-12 22:00 agk
  0 siblings, 0 replies; 27+ messages in thread
From: agk @ 2005-11-12 22:00 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2005-11-12 22:00:50

Modified files:
	tools          : lvcreate.c 

Log message:
	A missing vg_revert in an error path.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.106&r2=1.107


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2005-10-28 14:38 agk
  0 siblings, 0 replies; 27+ messages in thread
From: agk @ 2005-10-28 14:38 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2005-10-28 14:38:20

Modified files:
	tools          : lvcreate.c 

Log message:
	reorder commit

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.104&r2=1.105


^ permalink raw reply	[flat|nested] 27+ messages in thread

* LVM2/tools lvcreate.c
@ 2005-09-30 22:20 agk
  0 siblings, 0 replies; 27+ messages in thread
From: agk @ 2005-09-30 22:20 UTC (permalink / raw)
  To: lvm2-cvs

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	agk@sourceware.org	2005-09-30 22:20:15

Modified files:
	tools          : lvcreate.c 

Log message:
	Impose chunk size limitation.

Patches:
http://sources.redhat.com/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.103&r2=1.104


^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2012-03-02 20:18 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-26  2:31 LVM2/tools lvcreate.c wysochanski
  -- strict thread matches above, loose matches on Subject: below --
2012-03-02 20:18 zkabelac
2012-02-01  1:54 agk
2011-11-10 12:40 zkabelac
2011-11-10 12:39 zkabelac
2011-09-27 12:37 agk
2011-09-07  9:25 zkabelac
2011-09-06 15:35 agk
2011-03-25 21:56 jbrassow
2010-10-25 12:05 zkabelac
2010-05-11 21:40 jbrassow
2009-07-26  2:32 wysochanski
2009-07-26  2:32 wysochanski
2009-07-26  2:32 wysochanski
2009-07-26  2:31 wysochanski
2009-07-26  2:30 wysochanski
2009-06-06 22:06 mbroz
2009-05-27 13:07 agk
2009-04-26  8:12 prajnoha
2008-07-17 15:19 wysochanski
2008-01-16 15:26 agk
2007-10-01 15:01 wysochanski
2007-09-24 13:29 wysochanski
2006-10-16 16:47 agk
2005-11-12 22:00 agk
2005-10-28 14:38 agk
2005-09-30 22:20 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).