[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[lvm-devel] LVM2 ./WHATS_NEW man/lvconvert.8 man/lvcreate. ...



CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	jbrassow sourceware org	2007-08-01 21:01:06

Modified files:
	.              : WHATS_NEW 
	man            : lvconvert.8 lvcreate.8 
	tools          : args.h commands.h lvconvert.c lvcreate.c 

Log message:
	This patch changes the arguments that specify the mirror
	log type.  Previously, we had a '--corelog' argument that
	would change the default type from 'disk' to 'core'.  I
	think that creates too much confusion - especially when
	doing conversions on mirrors.
	
	The new argument '--log' takes either "disk" or "core"
	as a parameter.  This could be expanded in the future
	for additional logging types as well.
	
	Examples:
	# Creating a 2-way mirror
	$> lvcreate -m1 ... # implicitly use default disk logging
	$> lvcreate -m1 --log disk ... # explicit disk logging
	$> lvcreate -m1 --log core ... # specify core logging
	$> lvcreate -m1 --corelog ... # old way still works
	
	# Conversion examples
	$> lvconvert --log core ... # convert to core logging
	$> lvconvert --log disk ... # convert to disk logging
	$> lvconvert -mX --corelog ... # old way still works
	$> lvconvert -mX ... # old way of converting to disk logging still works
	
	Changes are reflected in the man pages.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.675&r2=1.676
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvconvert.8.diff?cvsroot=lvm2&r1=1.5&r2=1.6
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvcreate.8.diff?cvsroot=lvm2&r1=1.14&r2=1.15
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/args.h.diff?cvsroot=lvm2&r1=1.50&r2=1.51
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/commands.h.diff?cvsroot=lvm2&r1=1.97&r2=1.98
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.30&r2=1.31
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.138&r2=1.139

--- LVM2/WHATS_NEW	2007/08/01 20:29:07	1.675
+++ LVM2/WHATS_NEW	2007/08/01 21:01:06	1.676
@@ -1,5 +1,6 @@
 Version 2.02.28 -
 ================================
+  Add --log argument to specify log type for mirrors.
   Don't try to monitor devices which we failed to create.
   Don't leak a file descriptor in fcntl_lock_file(), when fcntl fails.
   Remove create_dir function; use now-equivalent dm_create_dir instead
--- LVM2/man/lvconvert.8	2007/01/10 19:56:38	1.5
+++ LVM2/man/lvconvert.8	2007/08/01 21:01:06	1.6
@@ -3,7 +3,7 @@
 lvconvert \- convert a logical volume from linear to mirror or snapshot
 .SH SYNOPSIS
 .B lvconvert
-\-m/\-\-mirrors Mirrors [\-\-corelog] [\-R/\-\-regionsize MirrorLogRegionSize]
+\-m/\-\-mirrors Mirrors [\-\-log {disk|core}] [\-R/\-\-regionsize MirrorLogRegionSize]
 [\-A/\-\-alloc AllocationPolicy]
 [\-h/\-?/\-\-help]
 [\-v/\-\-verbose]
@@ -37,12 +37,10 @@
 volume to a mirror volume with 2-sides; that is, a
 linear volume plus one copy.
 .TP
-.I \-\-corelog
-This optional argument tells lvconvert to switch the
-mirror from using a disk-based (persistent) log to
-an in-memory log.  You may only specify this option
-when the \-\-mirror argument is the same degree of
-the mirror you are changing.
+.I \-\-log disk/core
+This optional argument gives the ability to switch the
+logging type that is used by a mirror.  The logging type
+can be either "disk" (persistent) or "core" (non-persistent).
 .TP
 .I \-R, \-\-regionsize MirrorLogRegionSize
 A mirror is divided into regions of this size (in MB), and the mirror log
@@ -64,14 +62,17 @@
 "lvconvert -m1 vg00/lvol1"
 .br
 converts the linear logical volume "vg00/lvol1" to
-a mirror logical volume.  This command could also
-be used to convert a two-way mirror with an
-in-memory log to a two-way mirror with a disk log.
+a two-legged mirror logical volume.
 
-"lvconvert -m1 --corelog vg00/lvol1"
+"lvconvert --log core vg00/lvol1"
 .br
-converts a two-way mirror with a disk log to a
-two-way mirror with an in-memory log.
+converts a mirror with a disk log to a
+mirror with an in-memory log.
+
+"lvconvert --log disk vg00/lvol1"
+.br
+converts a mirror with an in-memory log
+to a mirror with a disk log.
 
 "lvconvert -m0 vg00/lvol1"
 .br
--- LVM2/man/lvcreate.8	2007/01/10 14:13:46	1.14
+++ LVM2/man/lvcreate.8	2007/08/01 21:01:06	1.15
@@ -11,7 +11,7 @@
 {\-l/\-\-extents LogicalExtentsNumber[%{VG|FREE}] |
  \-L/\-\-size LogicalVolumeSize[kKmMgGtT]}
 [\-M/\-\-persistent y/n] [\-\-minor minor]
-[\-m/\-\-mirrors Mirrors [\-\-nosync] [\-\-corelog]
+[\-m/\-\-mirrors Mirrors [\-\-nosync] [\-\-log {disk|log}]
 [\-R/\-\-regionsize MirrorLogRegionSize]]
 [\-n/\-\-name LogicalVolumeName]
 [\-p/\-\-permission r/rw] [\-r/\-\-readahead ReadAheadSectors]
@@ -95,11 +95,13 @@
 copied.  This is useful for skipping a potentially long and resource
 intensive initial sync.
 
-Specifying the optional argument "--corelog" will create a mirror with
-an in-memory log verses a disk-based (persistent) log.  While this
-removes the need for an extra log device and *may* be slightly faster,
-it requires that the entire mirror be resynchronized upon each
-instantiation (e.g. a reboot).
+The optional argument "--log" gives the ability to specify the type
+of mirror log to be used.  The available types are "disk" and "core",
+where "disk" is the default.  The "disk" log is persistent and requires
+a small amount of storage space - usually on a separate device from the
+mirror legs.  While the "disk" log may cause the mirror to be slightly
+slower during writes, it prevents the need to completely resynchronize
+the mirror upon each instantiation (e.g. a reboot).
 .TP
 .I \-n, \-\-name LogicalVolumeName
 The name for the new logical volume.
@@ -157,6 +159,10 @@
 require 3 devices - two for the mirror devices and one for the disk
 log.
 
+"lvcreate -m1 --log core -L 500M vg00" tries to create a mirror logical volume
+with 2 sides with a useable size of 500 MiB.  This operation would
+require 2 devices - the log is "in-memory".
+
 "lvcreate --size 100m --snapshot --name snap /dev/vg00/lvol1"
 .br
 creates a snapshot logical volume named /dev/vg00/snap which has access to the
--- LVM2/tools/args.h	2007/06/18 14:14:33	1.50
+++ LVM2/tools/args.h	2007/08/01 21:01:06	1.51
@@ -48,6 +48,7 @@
 arg(nosync_ARG, '\0', "nosync", NULL)
 arg(resync_ARG, '\0', "resync", NULL)
 arg(corelog_ARG, '\0', "corelog", NULL)
+arg(log_ARG, '\0', "log", string_arg)
 arg(monitor_ARG, '\0', "monitor", yes_no_arg)
 arg(config_ARG, '\0', "config", string_arg)
 arg(trustcache_ARG, '\0', "trustcache", NULL)
--- LVM2/tools/commands.h	2007/06/18 14:14:33	1.97
+++ LVM2/tools/commands.h	2007/08/01 21:01:06	1.98
@@ -88,7 +88,7 @@
 xx(lvconvert,
    "Change logical volume layout",
    "lvconvert "
-   "[-m|--mirrors Mirrors [--corelog]]\n"
+   "[-m|--mirrors Mirrors [--log {disk|core}]]\n"
    "\t[-R|--regionsize MirrorLogRegionSize]\n"
    "\t[--alloc AllocationPolicy]\n"
    "\t[-d|--debug]\n"
@@ -107,8 +107,8 @@
    "\t[--version]" "\n"
    "\tOriginalLogicalVolume[Path] SnapshotLogicalVolume[Path]\n",
 
-   alloc_ARG, chunksize_ARG, mirrors_ARG, corelog_ARG, regionsize_ARG,
-   snapshot_ARG, test_ARG, zero_ARG)
+   alloc_ARG, chunksize_ARG, mirrors_ARG, corelog_ARG, log_ARG,
+   regionsize_ARG, snapshot_ARG, test_ARG, zero_ARG)
 
 xx(lvcreate,
    "Create a logical volume",
@@ -123,7 +123,7 @@
    "\t{-l|--extents LogicalExtentsNumber |\n"
    "\t -L|--size LogicalVolumeSize[kKmMgGtTpPeE]}\n"
    "\t[-M|--persistent {y|n}] [--major major] [--minor minor]\n"
-   "\t[-m|--mirrors Mirrors [--nosync] [--corelog]]\n"
+   "\t[-m|--mirrors Mirrors [--nosync] [--log {disk|core}]]\n"
    "\t[-n|--name LogicalVolumeName]\n"
    "\t[-p|--permission {r|rw}]\n"
    "\t[-r|--readahead ReadAheadSectors]\n"
@@ -156,7 +156,7 @@
    "\tOriginalLogicalVolume[Path] [PhysicalVolumePath...]\n\n",
 
    addtag_ARG, alloc_ARG, autobackup_ARG, chunksize_ARG, contiguous_ARG,
-   corelog_ARG, extents_ARG, major_ARG, minor_ARG, mirrors_ARG, name_ARG,
+   corelog_ARG, log_ARG, extents_ARG, major_ARG, minor_ARG, mirrors_ARG, name_ARG,
    nosync_ARG, permission_ARG, persistent_ARG, readahead_ARG, regionsize_ARG,
    size_ARG, snapshot_ARG, stripes_ARG, stripesize_ARG, test_ARG, type_ARG,
    zero_ARG)
--- LVM2/tools/lvconvert.c	2007/08/01 20:54:28	1.30
+++ LVM2/tools/lvconvert.c	2007/08/01 21:01:06	1.31
@@ -101,14 +101,31 @@
 static int _read_params(struct lvconvert_params *lp, struct cmd_context *cmd,
 			int argc, char **argv)
 {
+	int count;
 	int region_size;
 	int pagesize = lvm_getpagesize();
 
 	memset(lp, 0, sizeof(*lp));
 
-	if (arg_count(cmd, mirrors_ARG) + arg_count(cmd, snapshot_ARG) != 1) {
-		log_error("Exactly one of --mirrors or --snapshot arguments "
-			  "required.");
+	if (arg_count(cmd, log_ARG) > 1) {
+		log_error("Too many --log arguments supplied.");
+		return 0;
+	}
+	if (arg_count(cmd, mirrors_ARG) > 1) {
+		log_error("Too many --mirrors arguments supplied.");
+		return 0;
+	}
+	if (arg_count(cmd, snapshot_ARG) > 1) {
+		log_error("Too many --snapshot arguments supplied.");
+		return 0;
+	}
+	if (arg_count(cmd, log_ARG) || arg_count(cmd, mirrors_ARG))
+		count = 1;
+	count += arg_count(cmd, snapshot_ARG);
+
+	if (count != 1) {
+		log_error("--snapshots argument cannot be mixed "
+			  "with --mirrors or --log");
 		return 0;
 	}
 
@@ -237,6 +254,8 @@
 	struct list *parallel_areas;
 	struct segment_type *segtype;  /* FIXME: could I just use lp->segtype */
 	float sync_percent;
+	const char *log_arg;
+	int corelog = 0;
 
 	seg = first_seg(lv);
 	existing_mirrors = seg->area_count;
@@ -267,6 +286,31 @@
 		return 0;
 	}
 
+	/*
+	 * Adjust log type
+	 */
+	if (arg_count(cmd, corelog_ARG)) {
+		log_verbose("Setting logging type to \"core\"");
+		corelog = 1;
+	}
+
+	if (arg_count(cmd, log_ARG)) {
+		log_arg = arg_str_value(cmd, log_ARG, "disk");
+		if (!strcmp("disk", log_arg)) {
+			log_verbose("Setting logging type to \"disk\"");
+			corelog = 0;
+		} else if (!strcmp("core", log_arg)) {
+			log_verbose("Setting logging type to \"core\"");
+			corelog = 1;
+		} else {
+			log_error("Unknown logging type, \"%s\"", log_arg);
+			return 0;
+		}
+	}
+
+	/*
+	 * Region size must not change on existing mirrors
+	 */
 	if (arg_count(cmd, regionsize_ARG) && (lv->status & MIRRORED) &&
 	    (lp->region_size != seg->region_size)) {
 		log_error("Mirror log region size cannot be changed on "
@@ -309,7 +353,7 @@
 
 		if (!(ah = allocate_extents(lv->vg, NULL, lp->segtype,
 					    1, lp->mirrors - 1,
-					    arg_count(cmd, corelog_ARG) ? 0 : 1,
+					    corelog ? 0 : 1,
 					    lv->le_count * (lp->mirrors - 1),
 					    NULL, 0, 0, lp->pvh,
 					    lp->alloc,
@@ -321,7 +365,7 @@
 							      lp->region_size);
 
 		log_lv = NULL;
-		if (!arg_count(cmd, corelog_ARG) &&
+		if (!corelog &&
 		    !(log_lv = create_mirror_log(cmd, lv->vg, ah,
 						 lp->alloc,
 						 lv->name, 0, &lv->tags))) {
@@ -348,7 +392,7 @@
 	}
 
 	if (lp->mirrors == existing_mirrors) {
-		if (!seg->log_lv && !arg_count(cmd, corelog_ARG)) {
+		if (!seg->log_lv && !corelog) {
 			/* No disk log present, add one. */
 			if (!(parallel_areas = build_parallel_areas_from_lv(cmd, lv)))
 				return_0;
@@ -383,7 +427,7 @@
 			seg->log_lv = log_lv;
 			log_lv->status |= MIRROR_LOG;
 			first_seg(log_lv)->mirror_seg = seg;
-		} else if (seg->log_lv && arg_count(cmd, corelog_ARG)) {
+		} else if (seg->log_lv && corelog) {
 			/* Had disk log, switch to core. */
 			if (!lv_mirror_percent(cmd, lv, 0, &sync_percent, NULL)) {
 				log_error("Unable to determine mirror sync status.");
@@ -543,7 +587,8 @@
 		return ECMD_FAILED;
 	}
 
-	if (arg_count(cmd, mirrors_ARG)) {
+	if (arg_count(cmd, mirrors_ARG) ||
+	    ((lv->status & MIRRORED) && arg_count(cmd, log_ARG))) {
 		if (!archive(lv->vg))
 			return ECMD_FAILED;
 		if (!lvconvert_mirrors(cmd, lv, lp))
--- LVM2/tools/lvcreate.c	2007/07/17 16:13:12	1.138
+++ LVM2/tools/lvcreate.c	2007/08/01 21:01:06	1.139
@@ -241,6 +241,7 @@
 	int argc = *pargc;
 	int region_size;
 	int pagesize = lvm_getpagesize();
+	const char *log_arg;
 
 	if (argc && (unsigned) argc < lp->mirrors) {
 		log_error("Too few physical volumes on "
@@ -284,7 +285,25 @@
 		return 0;
 	}
 
-	lp->corelog = arg_count(cmd, corelog_ARG) ? 1 : 0;
+	if (arg_count(cmd, corelog_ARG)) {
+		log_verbose("Setting logging type to \"core\"");
+		lp->corelog = 1;
+	}
+
+	if (arg_count(cmd, log_ARG)) {
+		log_arg = arg_str_value(cmd, log_ARG, "disk");
+		if (!strcmp("disk", log_arg)) {
+			log_verbose("Setting logging type to \"disk\"");
+			lp->corelog = 0;
+		} else if (!strcmp("core", log_arg)) {
+			log_verbose("Setting logging type to \"core\"");
+			lp->corelog = 1;
+		} else {
+			log_error("Unknown logging type, \"%s\"", log_arg);
+			return 0;
+		}
+	}
+
 	lp->nosync = arg_count(cmd, nosync_ARG) ? 1 : 0;
 
 	return 1;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]