All of lore.kernel.org
 help / color / mirror / Atom feed
From: wysochanski@sourceware.org <wysochanski@sourceware.org>
To: lvm-devel@redhat.com
Subject: LVM2/tools lvcreate.c
Date: 24 Sep 2007 13:29:49 -0000	[thread overview]
Message-ID: <20070924132949.14829.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/lvm2
Module name:	LVM2
Changes by:	wysochanski at 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;
 }
 



             reply	other threads:[~2007-09-24 13:29 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-24 13:29 wysochanski [this message]
  -- strict thread matches above, loose matches on Subject: below --
2012-03-02 20:18 LVM2/tools lvcreate.c 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: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
2006-10-16 16:47 agk

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20070924132949.14829.qmail@sourceware.org \
    --to=wysochanski@sourceware.org \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.