FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Redhat > Device-mapper Development

 
 
LinkBack Thread Tools
 
Old 11-02-2009, 01:20 PM
Zdenek Kabelac
 
Default Replicator: add new options for replicator

New options: addsite, delsite, replicator,
replicatorlog, replicatorlogtype.

Signed-off-by: Zdenek Kabelac <zkabelac@redhat.com>
---
lib/config/defaults.h | 1 +
lib/metadata/metadata-exported.h | 1 +
tools/args.h | 5 ++++
tools/commands.h | 10 ++++++-
tools/lvcreate.c | 47 ++++++++++++++++++++++++++++++++++++++
tools/lvmcmdline.c | 9 +++++++
tools/tools.h | 1 +
7 files changed, 72 insertions(+), 2 deletions(-)

diff --git a/lib/config/defaults.h b/lib/config/defaults.h
index 824fec2..e904e58 100644
--- a/lib/config/defaults.h
+++ b/lib/config/defaults.h
@@ -103,6 +103,7 @@

#define DEFAULT_STRIPE_FILLER "error"
#define DEFAULT_MIRROR_REGION_SIZE 512 /* KB */
+#define DEFAULT_REPLICATOR_REGION_SIZE 512 /* KB */
#define DEFAULT_INTERVAL 15

#ifdef READLINE_SUPPORT
diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h
index 257165c..2ca2d81 100644
--- a/lib/metadata/metadata-exported.h
+++ b/lib/metadata/metadata-exported.h
@@ -584,6 +584,7 @@ uint64_t extents_from_size(struct cmd_context *cmd, uint64_t size,
struct lvcreate_params {
/* flags */
int snapshot; /* snap */
+ int replicator; /* replicator */
int zero; /* all */
int major; /* all */
int minor; /* all */
diff --git a/tools/args.h b/tools/args.h
index 1f2427b..40b92b3 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -64,6 +64,11 @@ arg(dataalignmentoffset_ARG, '', "dataalignmentoffset", size_kb_arg, 0)
arg(virtualoriginsize_ARG, '', "virtualoriginsize", size_mb_arg, 0)
arg(virtualsize_ARG, '', "virtualsize", size_mb_arg, 0)
arg(noudevsync_ARG, '', "noudevsync", NULL, 0)
+arg(replicator_ARG, '', "replicator", NULL, 0)
+arg(replicatorlog_ARG, '', "replicatorlog", NULL, 0)
+arg(replicatorlogtype_ARG, '', "replicatorlogtype", NULL, 0)
+arg(addsite_ARG, '', "addsite", site_arg, 0)
+arg(delsite_ARG, '', "delsite", site_arg, 0)

/* Allow some variations */
arg(resizable_ARG, '', "resizable", yes_no_arg, 0)
diff --git a/tools/commands.h b/tools/commands.h
index 85222e4..fc37889 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -62,10 +62,12 @@ xx(lvchange,
"lvchange
"
" [-A|--autobackup y|n]
"
" [-a|--available [e|l]y|n]
"
+ " [--addsite Site]
"
" [--addtag Tag]
"
" [--alloc AllocationPolicy]
"
" [-C|--contiguous y|n]
"
" [-d|--debug]
"
+ " [--delsite Site]
"
" [--deltag Tag]
"
" [-f|--force]
"
" [-h|--help]
"
@@ -89,7 +91,7 @@ xx(lvchange,
ignorelockingfailure_ARG, ignoremonitoring_ARG, major_ARG, minor_ARG,
monitor_ARG, noudevsync_ARG, partial_ARG, permission_ARG, persistent_ARG,
readahead_ARG, resync_ARG, refresh_ARG, addtag_ARG, deltag_ARG, test_ARG,
- yes_ARG)
+ addsite_ARG, delsite_ARG, yes_ARG)

xx(lvconvert,
"Change logical volume layout",
@@ -145,6 +147,9 @@ xx(lvcreate,
" [-p|--permission {r|rw}]
"
" [-r|--readahead ReadAheadSectors|auto|none]
"
" [-R|--regionsize MirrorLogRegionSize]
"
+ " [--replicator]
"
+ " [--replicatorlog LogicalVolumeName]
"
+ " [--replicatorlogtype ringbuffer]
"
" [-t|--test]
"
" [--type VolumeType]
"
" [-v|--verbose]
"
@@ -179,7 +184,8 @@ xx(lvcreate,
addtag_ARG, alloc_ARG, autobackup_ARG, chunksize_ARG, contiguous_ARG,
corelog_ARG, extents_ARG, major_ARG, minor_ARG, mirrorlog_ARG, mirrors_ARG,
name_ARG, nosync_ARG, noudevsync_ARG, permission_ARG, persistent_ARG,
- readahead_ARG, regionsize_ARG, size_ARG, snapshot_ARG, stripes_ARG,
+ readahead_ARG, regionsize_ARG, replicator_ARG, replicatorlog_ARG,
+ replicatorlogtype_ARG, size_ARG, snapshot_ARG, stripes_ARG,
stripesize_ARG, test_ARG, type_ARG, virtualoriginsize_ARG, virtualsize_ARG,
zero_ARG)

diff --git a/tools/lvcreate.c b/tools/lvcreate.c
index be6b5cc..6f71aaf 100644
--- a/tools/lvcreate.c
+++ b/tools/lvcreate.c
@@ -373,6 +373,36 @@ static int _read_mirror_params(struct lvcreate_params *lp,
return 1;
}

+static int _read_replicator_params(struct lvcreate_params *lp,
+ struct cmd_context *cmd)
+{
+ int region_size;
+ 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 = arg_uint_value(cmd, regionsize_ARG, 0);
+ } else {
+ region_size = 2 * find_config_tree_int(cmd,
+ "activation/replicator_region_size",
+ DEFAULT_REPLICATOR_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;
+}
+
static int _lvcreate_params(struct lvcreate_params *lp,
struct lvcreate_cmdline_params *lcp,
struct cmd_context *cmd,
@@ -405,6 +435,9 @@ static int _lvcreate_params(struct lvcreate_params *lp,
if (seg_is_mirrored(lp))
lp->mirrors = 2;

+ if (seg_is_replicator(lp) || arg_count(cmd, replicator_ARG))
+ lp->replicator = 1;
+
if (arg_count(cmd, mirrors_ARG)) {
lp->mirrors = arg_uint_value(cmd, mirrors_ARG, 0) + 1;
if (lp->mirrors == 1)
@@ -469,6 +502,20 @@ static int _lvcreate_params(struct lvcreate_params *lp,
}
}

+ if (lp->replicator) {
+ log_error("--replicator for replicators");
+
+ } else {
+ if (arg_count(cmd, replicatorlog_ARG)) {
+ log_error("--replicatorlog is only available with replicators");
+ return 0;
+ }
+ if (arg_count(cmd, replicatorlogtype_ARG)) {
+ log_error("--replicatorlogtype is only available with replicators");
+ return 0;
+ }
+ }
+
if (activation() && lp->segtype->ops->target_present &&
!lp->segtype->ops->target_present(cmd, NULL, NULL)) {
log_error("%s: Required device-mapper target(s) not "
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 31ebd12..cdfef3f 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -483,6 +483,15 @@ int readahead_arg(struct cmd_context *cmd __attribute((unused)), struct arg *a)
return 1;
}

+int site_arg(struct cmd_context *cmd __attribute((unused)), struct arg *a)
+{
+ char *pos = a->value;
+ if (!validate_name(pos))
+ return 0;
+
+ return 1;
+}
+
static void __alloc(int size)
{
if (!(_cmdline.commands = dm_realloc(_cmdline.commands, sizeof(*_cmdline.commands) * size))) {
diff --git a/tools/tools.h b/tools/tools.h
index 3afa1a1..67b2178 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -151,6 +151,7 @@ int units_arg(struct cmd_context *cmd, struct arg *a);
int segtype_arg(struct cmd_context *cmd, struct arg *a);
int alloc_arg(struct cmd_context *cmd, struct arg *a);
int readahead_arg(struct cmd_context *cmd, struct arg *a);
+int site_arg(struct cmd_context *cmd, struct arg *a);

/* we use the enums to access the switches */
unsigned int arg_count(const struct cmd_context *cmd, int a);
--
1.6.5.1

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel
 

Thread Tools




All times are GMT. The time now is 09:00 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org