Skip to contentSkip to conversation

master - toollib: persistent major minor

PATCH Zdenek Kabelac 1 participant 1 message Oct 24, 2014

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c7484a139a3b24d05459d8593309b518b4104172
Commit:        c7484a139a3b24d05459d8593309b518b4104172
Parent:        d13239b0547e09def4b58b0f49bd0252f459d431
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Thu Oct 23 14:26:16 2014 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Fri Oct 24 16:39:32 2014 +0200

toollib: persistent major minor

Deduce -M from presence of --minor, --major option if not specified on command line.

---
 WHATS_NEW        |    1 +
 tools/lvcreate.c |   37 +++++++++++--------------------
 tools/toollib.c  |   64 ++++++++++++++++++++++++++++++++---------------------
 3 files changed, 53 insertions(+), 49 deletions(-)
WHATS_NEW +1 -0
index 320bca3..c3d56de 100644
@@ -1,5 +1,6 @@
 Version 2.02.112 - 
 =====================================
+  Better support for persistent major and minor options with lvcreate.
   Refactor lvcreate towards more complete validation of all supported options.
   Support lvcreate --type linear.
   Improve _should_wipe_lv() to warn with message.
tools/lvcreate.c +13 -24
index a789fb2..2744b09 100644
@@ -623,20 +623,9 @@ static int _read_activation_params(struct cmd_context *cmd,
 		lp->wipe_signatures = 0;
 	}
 
-	/* Persistent minor (and major) */
-	if (arg_is_set(cmd, persistent_ARG)) {
-		if (lp->create_pool && !seg_is_thin_volume(lp)) {
-			log_error("--persistent is not permitted when creating a thin pool device.");
-			return 0;
-		}
-
-		if (!get_and_validate_major_minor(cmd, vg->fid->fmt,
-						  &lp->major, &lp->minor))
-			return_0;
-	} else if (arg_is_set(cmd, major_ARG) || arg_is_set(cmd, minor_ARG)) {
-		log_error("--major and --minor require -My.");
-		return 0;
-	}
+	/* Persistent minor (and major), default 'n' */
+	if (!get_and_validate_major_minor(cmd, vg->fid->fmt, &lp->major, &lp->minor))
+		return_0;
 
 	if (arg_is_set(cmd, setactivationskip_ARG)) {
 		lp->activation_skip |= ACTIVATION_SKIP_SET;
@@ -1316,10 +1305,14 @@ static int _check_pool_parameters(struct cmd_context *cmd,
 				return 0;
 			}
 		}
-		/* When creating just pool the pool_name needs to be in lv_name */
-		if (seg_is_pool(lp))
+		if (seg_is_pool(lp)) {
+			if (lp->major != -1 || lp->minor != -1) {
+				log_error("Persistent major and minor numbers are unsupported with pools.");
+				return 0;
+			}
+			/* When creating just pool the pool_name needs to be in lv_name */
 			lp->lv_name = lp->pool_name;
-
+		}
 		return 1;
 	}
 	/* Not creating new pool, but existing pool is needed */
@@ -1416,6 +1409,9 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
 		return_ECMD_FAILED;
 	}
 
+	if (!_read_activation_params(cmd, vg, &lp))
+		goto_out;
+
 	/* Resolve segment types with opened VG */
 	if (lp.snapshot && lp.origin_name && !_determine_snapshot_type(vg, &lp, &lcp))
 		goto_out;
@@ -1433,13 +1429,6 @@ int lvcreate(struct cmd_context *cmd, int argc, char **argv)
 	if (!_check_pool_parameters(cmd, vg, &lp, &lcp))
 		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(cmd, vg, &lp))
-		goto_out;
-
 	if (!_update_extents_params(vg, &lp, &lcp))
 		goto_out;
 
tools/toollib.c +39 -25

94 lines not on this page · raw message