Skip to contentSkip to conversation

LVM2 ./WHATS_NEW lib/config/defaults.h lib/met ...

PATCH [email protected] 1 participant 1 message Aug 21, 2007

lore
Share & tools
lore
#0 lore raw

CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk at sourceware.org 2007-08-21 19:46:36

Modified files:

	.              : WHATS_NEW 
	lib/config     : defaults.h 
	lib/metadata   : lv_manip.c 
	tools          : args.h commands.h lvconvert.c lvcreate.c 

lvmcmdline.c tools.h

Log message:
Clean up mirrorlog argument processing.
Only permit --force, --verbose and --debug arguments to be repeated.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.687&r2=1.688
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/defaults.h.diff?cvsroot=lvm2&r1=1.32&r2=1.33
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.125&r2=1.126
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/args.h.diff?cvsroot=lvm2&r1=1.53&r2=1.54
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/commands.h.diff?cvsroot=lvm2&r1=1.100&r2=1.101
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.34&r2=1.35
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.141&r2=1.142
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.47&r2=1.48
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/tools.h.diff?cvsroot=lvm2&r1=1.56&r2=1.57

WHATS_NEW +3 -2
@@ -1,5 +1,6 @@
 Version 2.02.28 -
 ================================
+  Only permit --force, --verbose and --debug arguments to be repeated.
   Move guts of vgremove into library.
   Fix inconsistent licence notices: executables are GPLv2; libraries LGPLv2.1.
   Move guts of lvremove into library.
@@ -9,10 +10,10 @@
   Add const attributes where possible, first cut.
   Add support for renaming mirrored LVs.
   Factor out core of lvrename() to lv_rename lvm library function.
-  Add --log argument to specify log type for mirrors.
+  Add --mirrorlog 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
+  Replace create_dir with dm_create_dir.
   Detect stream write failure reliably; new fn: lvm_fclose; use dm_fclose
   Fix clvmd if compiled with gulm support. (2.02.26)
   Trivial fix to lvdisplay man page.
lib/config/defaults.h +1 -0
@@ -39,6 +39,7 @@
 #define DEFAULT_FALLBACK_TO_LOCAL_LOCKING 1
 #define DEFAULT_FALLBACK_TO_CLUSTERED_LOCKING 1
 
+#define DEFAULT_MIRRORLOG "disk"
 #define DEFAULT_MIRROR_LOG_FAULT_POLICY "allocate"
 #define DEFAULT_MIRROR_DEV_FAULT_POLICY "remove"
 #define DEFAULT_DMEVENTD_MIRROR_LIB "libdevmapper-event-lvm2mirror.so"
lib/metadata/lv_manip.c +0 -1
@@ -1574,7 +1574,6 @@
 /*
  * Core of LV renaming routine.
  * VG must be locked by caller.
- * Returns 0 on failure, 1 on success.
  */
 int lv_rename(struct cmd_context *cmd, struct logical_volume *lv,
 	      const char *new_name)
tools/args.h +104 -104

224 lines not on this page · raw message

tools/commands.h +7 -7
@@ -88,7 +88,7 @@
 xx(lvconvert,
    "Change logical volume layout",
    "lvconvert "
-   "[-m|--mirrors Mirrors [--log {disk|core}]]\n"
+   "[-m|--mirrors Mirrors [{--mirrorlog {disk|core}|--corelog}]]\n"
    "\t[-R|--regionsize MirrorLogRegionSize]\n"
    "\t[--alloc AllocationPolicy]\n"
    "\t[-d|--debug]\n"
@@ -107,7 +107,7 @@
    "\t[--version]" "\n"
    "\tOriginalLogicalVolume[Path] SnapshotLogicalVolume[Path]\n",
 
-   alloc_ARG, chunksize_ARG, mirrors_ARG, corelog_ARG, mirrorlog_ARG,
+   alloc_ARG, chunksize_ARG, corelog_ARG, mirrorlog_ARG, mirrors_ARG,
    regionsize_ARG, snapshot_ARG, test_ARG, zero_ARG)
 
 xx(lvcreate,
@@ -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] [--log {disk|core}]]\n"
+   "\t[-m|--mirrors Mirrors [--nosync] [{--mirrorlog {disk|core}|--corelog}]]\n"
    "\t[-n|--name LogicalVolumeName]\n"
    "\t[-p|--permission {r|rw}]\n"
    "\t[-r|--readahead ReadAheadSectors]\n"
@@ -156,10 +156,10 @@
    "\tOriginalLogicalVolume[Path] [PhysicalVolumePath...]\n\n",
 
    addtag_ARG, alloc_ARG, autobackup_ARG, chunksize_ARG, contiguous_ARG,
-   corelog_ARG, mirrorlog_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)
+   corelog_ARG, extents_ARG, major_ARG, minor_ARG, mirrorlog_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)
 
 xx(lvdisplay,
    "Display information about a logical volume",
tools/lvconvert.c +18 -33

80 lines not on this page · raw message

tools/lvcreate.c +15 -14
@@ -241,7 +241,7 @@
 	int argc = *pargc;
 	int region_size;
 	int pagesize = lvm_getpagesize();
-	const char *log_arg;
+	const char *mirrorlog;
 
 	if (argc && (unsigned) argc < lp->mirrors) {
 		log_error("Too few physical volumes on "
@@ -285,25 +285,26 @@
 		return 0;
 	}
 
-	if (arg_count(cmd, corelog_ARG)) {
-		log_verbose("Setting logging type to \"core\"");
+	if (arg_count(cmd, corelog_ARG))
 		lp->corelog = 1;
-	}
 
-	if (arg_count(cmd, mirrorlog_ARG)) {
-		log_arg = arg_str_value(cmd, mirrorlog_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);
+	mirrorlog = arg_str_value(cmd, mirrorlog_ARG, DEFAULT_MIRRORLOG);
+	if (!strcmp("disk", mirrorlog)) {
+		if (lp->corelog) {
+			log_error("--mirrorlog disk and --corelog "
+				  "are incompatible");
 			return 0;
 		}
+		lp->corelog = 0;
+	} else if (!strcmp("core", mirrorlog))
+		lp->corelog = 1;
+	else {
+		log_error("Unknown mirrorlog type: %s", mirrorlog);
+		return 0;
 	}
 
+	log_verbose("Setting logging type to %s", mirrorlog);
+
 	lp->nosync = arg_count(cmd, nosync_ARG) ? 1 : 0;
 
 	return 1;
tools/lvmcmdline.c +10 -10
@@ -45,7 +45,7 @@
  * Table of valid switches
  */
 static struct arg _the_args[ARG_COUNT + 1] = {
-#define arg(a, b, c, d) {b, "", "--" c, d, 0, NULL, 0, 0, INT64_C(0), UINT64_C(0), SIGN_NONE, PERCENT_NONE, NULL},
+#define arg(a, b, c, d, e) {b, "", "--" c, d, e, 0, NULL, 0, 0, INT64_C(0), UINT64_C(0), SIGN_NONE, PERCENT_NONE, NULL},
 #include "args.h"
 #undef arg
 };
@@ -568,16 +568,16 @@
 			return 0;
 		}
 
-		if (a->fn) {
-			if (a->count) {
-				log_error("Option%s%c%s%s may not be repeated",
-					  a->short_arg ? " -" : "",
-					  a->short_arg ? : ' ',
-					  (a->short_arg && a->long_arg) ?
-					  "/" : "", a->long_arg ? : "");
-				return 0;
-			}
+		if (a->count && !(a->flags & ARG_REPEATABLE)) {
+			log_error("Option%s%c%s%s may not be repeated",
+				  a->short_arg ? " -" : "",
+				  a->short_arg ? : ' ',
+				  (a->short_arg && a->long_arg) ?
+				  "/" : "", a->long_arg ? : "");
+			return 0;
+		}
 
+		if (a->fn) {
 			if (!optarg) {
 				log_error("Option requires argument.");
 				return 0;
tools/tools.h +4 -1
@@ -68,7 +68,7 @@
 
 /* define the enums for the command line switches */
 enum {
-#define arg(a, b, c, d) a ,
+#define arg(a, b, c, d, e) a ,
 #include "args.h"
 #undef arg
 };
@@ -94,6 +94,8 @@
 	CHANGE_ALN = 4
 };
 
+#define ARG_REPEATABLE 0x00000001
+
 /* a global table of possible arguments */
 struct arg {
 	const char short_arg;
@@ -101,6 +103,7 @@
 	const char *long_arg;
 
 	int (*fn) (struct cmd_context * cmd, struct arg * a);
+	uint32_t flags;
 
 	unsigned count;
 	char *value;