[lvm-devel] [PATCH 22/22] Replicator: lvremove implementation

Zdenek Kabelac zkabelac at redhat.com
Wed Jul 7 12:34:56 UTC 2010


Signed-off-by: Zdenek Kabelac <zkabelac at redhat.com>
---
 tools/commands.h |    3 ++-
 tools/lvremove.c |   19 ++++++++++++++++++-
 2 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/tools/commands.h b/tools/commands.h
index 9e27ad9..73bede8 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -365,12 +365,13 @@ xx(lvremove,
    "\t[-f|--force]\n"
    "\t[-h|--help]\n"
    "\t[--noudevsync]\n"
+   "\t[--site SiteName]\n"
    "\t[-t|--test]\n"
    "\t[-v|--verbose]\n"
    "\t[--version]" "\n"
    "\tLogicalVolume[Path] [LogicalVolume[Path]...]\n",
 
-   autobackup_ARG, force_ARG, noudevsync_ARG, test_ARG)
+   autobackup_ARG, force_ARG, noudevsync_ARG, site_ARG, test_ARG)
 
 xx(lvrename,
    "Rename a logical volume",
diff --git a/tools/lvremove.c b/tools/lvremove.c
index dbf2f1d..15005c3 100644
--- a/tools/lvremove.c
+++ b/tools/lvremove.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved.
  *
  * This file is part of LVM2.
  *
@@ -19,6 +19,8 @@ static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
 			   void *handle __attribute((unused)))
 {
 	struct logical_volume *origin;
+	struct logical_volume *replicator;
+	const char *site_name;
 
 	/*
 	 * If this is a sparse device, remove its origin too.
@@ -26,6 +28,21 @@ static int lvremove_single(struct cmd_context *cmd, struct logical_volume *lv,
         if (lv_is_cow(lv) && lv_is_virtual_origin(origin = origin_from_cow(lv)))
                 lv = origin;
 
+	if ((lv_is_replicator_dev(lv) || lv_is_replicator(lv)) &&
+	    arg_count(cmd, site_ARG)) {
+		replicator = lv_is_replicator(lv) ? lv : first_seg(lv)->replicator;
+		site_name = arg_str_value(cmd, site_ARG,
+					  DEFAULT_REPLICATOR_LOCAL_SITE_NAME);
+
+		log_error("REMOVE SITE  %s   of %s", site_name, replicator->name);
+		if (!lv_remove_replicator_site(replicator, site_name)) {
+			stack;
+			return ECMD_FAILED;
+		}
+
+		return ECMD_PROCESSED;
+	}
+
 	if (!lv_remove_with_dependencies(cmd, lv, arg_count(cmd, force_ARG), 0)) {
 		stack;
 		return ECMD_FAILED;
-- 
1.7.1.1




More information about the lvm-devel mailing list