Skip to contentSkip to conversation

Replicator

PATCH New Zdenek Kabelac 2 participants 29 messages Mar 17, 2010 – Mar 18, 2010 Library code

lore
Share & tools
lore
#0 lore raw

cover Replicator

Rebased set of replicator patches.
Log creation code is still kept separately as many changes are still on going in this code.

Updated parts:
* Using common typedef between dm and lvm part for operation mode.
* cmd_context now contains only vgs_lvs_retry dm_list - needs to be fixed.
* Minor code reoganization based on review
* Extended validation code.
* Added manpages updates to patches to document API
still this is ongoing task to make all the options working
* Whole new API aroung vg_name_list which is now autonomous entity
* lock_vol now detects missing vgs using new LCK_MISSING_VG bit
* Tunning some API
* Processed vg contains list of opened vgs.

Zdenek Kabelac (25):
Remove const from volume_group* in process_each
Replicator: add libdm support
Replicator: suspend/deactivate replicator
Replicator: add lvm support
Replicator: validate replicator segments
Replicator: extend _lv_each_dependency() rep. deps
Replicator: extend VG with list of opened vgs
Replicator: add sorted vg_name_list
Replicator: add lv_replicator_sites_check_vg
Replicator: add read/release VG for rsites
Replicator: use vg_name_list for _process_one_vg()
Replicator: use str_list for process_each_lv_in_vg
Replicator: lock_vol update replicator LV
Replicator: extend activate with rsite resolving
Replicator: update _create_partial_dtree()
Replicator: vg with missing_vgs does not print
Replicator: add replicator to dtree
Replicator: do not remove of replicators' LVs
Replicator: no crash lvresize if area_count is 0
Replicator: activate change for vgchange
Replicator: add new options for replicator
Replicator: man pages for lvcreate, lvchange
Replicator: update copyright dates
Replicator: update generated lib/misc/configure.h.in
Replicator: update generated configure.in

 configure                        |   33 ++-
 configure.in                     |   17 +
 lib/Makefile.in                  |    9 +
 lib/activate/activate.c          |   22 +-
 lib/activate/dev_manager.c       |  137 +++++++-
 lib/commands/toolcontext.c       |    6 +
 lib/commands/toolcontext.h       |    2 +
 lib/config/defaults.h            |    1 +
 lib/format_text/flags.c          |    2 +
 lib/locking/locking.c            |    3 +
 lib/locking/locking.h            |    7 +-
 lib/metadata/lv_manip.c          |   15 +
 lib/metadata/merge.c             |   14 +
 lib/metadata/metadata-exported.h |  105 +++++-
 lib/metadata/metadata.c          |  162 ++++++++
 lib/metadata/replicator_manip.c  |  576 +++++++++++++++++++++++++++
 lib/metadata/segtype.h           |   10 +-
 lib/misc/configure.h.in          |    3 +
 lib/replicator/.exported_symbols |    1 +
 lib/replicator/Makefile.in       |   29 ++
 lib/replicator/replicator.c      |  794 ++++++++++++++++++++++++++++++++++++++
 libdm/.exported_symbols          |    3 +
 libdm/libdevmapper.h             |   33 ++
 libdm/libdm-deptree.c            |  361 +++++++++++++++++-
 man/lvchange.8.in                |   60 +++-
 man/lvcreate.8.in                |   55 +++
 tools/args.h                     |   13 +
 tools/commands.h                 |   10 +-
 tools/lvcreate.c                 |   58 +++-
 tools/lvmcmdline.c               |    9 +
 tools/toollib.c                  |  119 ++++--
 tools/toollib.h                  |    2 +-
 tools/tools.h                    |    1 +
 tools/vgchange.c                 |    9 +-
 34 files changed, 2624 insertions(+), 57 deletions(-)
 create mode 100644 lib/metadata/replicator_manip.c
 create mode 100644 lib/replicator/.exported_symbols
 create mode 100644 lib/replicator/Makefile.in
 create mode 100644 lib/replicator/replicator.c
#1 lore raw

PATCH 1/25 Remove const from volume_group* in process_each

struct volume_group could change as a result of process_single() so vg is not const.

---
 tools/toollib.c |    2 +-
 tools/toollib.h |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tools/toollib.c +1 -1
index 0d3fe0a..972d077 100644
@@ -83,7 +83,7 @@ char *skip_dev_dir(struct cmd_context *cmd, const char *vg_name,
  * Metadata iteration functions
  */
 int process_each_lv_in_vg(struct cmd_context *cmd,
-			  const struct volume_group *vg,
+			  struct volume_group *vg,
 			  const struct dm_list *arg_lvnames,
 			  const struct dm_list *tags,
 			  void *handle,
tools/toollib.h +1 -1
index 4743fd5..d284de4 100644
@@ -76,7 +76,7 @@ typedef int (*process_single_lv_fn_t) (struct cmd_context *cmd,
 				  void *handle);
 
 int process_each_lv_in_vg(struct cmd_context *cmd,
-			  const struct volume_group *vg,
+			  struct volume_group *vg,
 			  const struct dm_list *arg_lvnames,
 			  const struct dm_list *tags,
 			  void *handle,
Signature · 1 line
1.7.0.1
#3 lore raw

PATCH 2/25 Replicator: add libdm support

In reply to Zdenek Kabelac

Introducing dm_tree_node_add_replicator_target() and dm_tree_node_add_replicator_dev_target(). Define typedef dm_replicator_mode_t

---
 libdm/.exported_symbols |    2 +
 libdm/libdevmapper.h    |   31 +++++
 libdm/libdm-deptree.c   |  297 ++++++++++++++++++++++++++++++++++++++++++++++-
 3 files changed, 325 insertions(+), 5 deletions(-)
libdm/.exported_symbols +2 -0
index fd9d0b9..eaa4579 100644
@@ -80,6 +80,8 @@ dm_tree_node_add_crypt_target
 dm_tree_node_add_mirror_target
 dm_tree_node_add_mirror_target_log
 dm_tree_node_add_target_area
+dm_tree_node_add_replicator_target
+dm_tree_node_add_replicator_dev_target
 dm_tree_node_set_read_ahead
 dm_tree_skip_lockfs
 dm_tree_use_no_flush_suspend
libdm/libdevmapper.h +31 -0
index 1ae930f..3836481 100644
@@ -439,6 +439,37 @@ int dm_tree_node_add_mirror_target_log(struct dm_tree_node *node,
 					  const char *log_uuid,
 					  unsigned area_count,
 					  uint32_t flags);
+
+/* Replicator operation mode */
+typedef enum {
+	DM_REPLICATOR_SYNC,			/* Synchronous replication */
+	DM_REPLICATOR_ASYNC_WARN,		/* Warn if async replicator is slow */
+	DM_REPLICATOR_ASYNC_STALL,		/* Stall replicator if not fast enough */
+	DM_REPLICATOR_ASYNC_DROP,		/* Drop sites out of sync */
+	DM_REPLICATOR_ASYNC_FAIL,		/* Fail replicator if slow */
+	NUM_DM_REPLICATOR_MODES
+} dm_replicator_mode_t;
+
+int dm_tree_node_add_replicator_target(struct dm_tree_node *node,
+				       uint64_t size,
+				       const char *rlog_uuid,
+				       const char *rlog_type,
+				       unsigned rsite_index,
+				       dm_replicator_mode_t mode,
+				       uint32_t async_timeout,
+				       uint64_t fall_behind_data,
+				       uint32_t fall_behind_ios);
+
+int dm_tree_node_add_replicator_dev_target(struct dm_tree_node *node,
+					   uint64_t size,
+					   const char *replicator_uuid,	/* Replicator control device */
+					   uint64_t rdevice_index,
+					   const char *rdev_uuid,	/* Rimage device name/uuid */
+					   unsigned rsite_index,
+					   const char *slog_uuid,
+					   uint32_t slog_flags,		/* Mirror log flags */
+					   uint32_t slog_region_size);
+
 int dm_tree_node_add_target_area(struct dm_tree_node *node,
 				    const char *dev_name,
 				    const char *dlid,
libdm/libdm-deptree.c +292 -5

380 lines not on this page · raw message

Signature · 1 line
1.7.0.1
#4 lore raw

PATCH 3/25 Replicator: suspend/deactivate replicator

In reply to Zdenek Kabelac

Introducing dm_tree_set_suspend_priority() for suspending replicator control target before deactivation of replicator-dev target.

---
 libdm/.exported_symbols |    1 +
 libdm/libdevmapper.h    |    2 +
 libdm/libdm-deptree.c   |   62 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 65 insertions(+), 0 deletions(-)
libdm/.exported_symbols +1 -0
index eaa4579..54e7ccb 100644
@@ -82,6 +82,7 @@ dm_tree_node_add_mirror_target_log
 dm_tree_node_add_target_area
 dm_tree_node_add_replicator_target
 dm_tree_node_add_replicator_dev_target
+dm_tree_set_suspend_priority
 dm_tree_node_set_read_ahead
 dm_tree_skip_lockfs
 dm_tree_use_no_flush_suspend
libdm/libdevmapper.h +2 -0
index 3836481..fac4723 100644
@@ -470,6 +470,8 @@ int dm_tree_node_add_replicator_dev_target(struct dm_tree_node *node,
 					   uint32_t slog_flags,		/* Mirror log flags */
 					   uint32_t slog_region_size);
 
+int dm_tree_set_suspend_priority(struct dm_tree *dtree, const char *uuid, int priority);
+
 int dm_tree_node_add_target_area(struct dm_tree_node *node,
 				    const char *dev_name,
 				    const char *dlid,
libdm/libdm-deptree.c +62 -0

86 lines not on this page · raw message

Signature · 1 line
1.7.0.1
#5 lore raw

PATCH 4/25 Replicator: add lvm support

In reply to Zdenek Kabelac

Adding configure.in support for Replicators. Adding basic lib lvm support for Replicators. Adding flags REPLICATOR and REPLICATOR_LOG. Adding segments SEG_REPLICATOR and SEG_REPLICATOR_DEV. Adding basic methods for handling replicator metadata.

---
 configure.in                     |   17 +
 lib/Makefile.in                  |    9 +
 lib/commands/toolcontext.c       |    5 +
 lib/format_text/flags.c          |    2 +
 lib/metadata/lv_manip.c          |    1 +
 lib/metadata/merge.c             |   14 +
 lib/metadata/metadata-exported.h |   75 ++++-
 lib/metadata/replicator_manip.c  |  340 ++++++++++++++++
 lib/metadata/segtype.h           |    8 +
 lib/replicator/.exported_symbols |    1 +
 lib/replicator/Makefile.in       |   29 ++
 lib/replicator/replicator.c      |  794 ++++++++++++++++++++++++++++++++++++++
 12 files changed, 1294 insertions(+), 1 deletions(-)
 create mode 100644 lib/metadata/replicator_manip.c
 create mode 100644 lib/replicator/.exported_symbols
 create mode 100644 lib/replicator/Makefile.in
 create mode 100644 lib/replicator/replicator.c
configure.in +17 -0
index 3473d95..31a9b3a 100644
@@ -306,6 +306,21 @@ if test x$MIRRORS = xinternal; then
 fi
 
 ################################################################################
+dnl -- asynchronous volume replicator inclusion type
+AC_MSG_CHECKING(whether to include replicators)
+AC_ARG_WITH(replicators, AC_HELP_STRING([--with-replicators=TYPE],
+	[Replicator support: internal/shared/none [TYPE=none] ]),
+	[REPLICATORS=$withval], [REPLICATORS="none"])
+AC_MSG_RESULT($REPLICATORS)
+
+case "$REPLICATORS" in
+  none|shared) ;;
+  internal) AC_DEFINE([REPLICATOR_INTERNAL], 1,
+		[Define to 1 to include built-in support for replicators.]) ;;
+  *) AC_MSG_ERROR([--with-replicators parameter invalid ($REPLICATORS)]) ;;
+esac
+
+################################################################################
 dnl -- Disable readline
 AC_MSG_CHECKING(whether to enable readline)
 AC_ARG_ENABLE([readline],
@@ -1105,6 +1120,7 @@ AC_SUBST(LVM_PATCHLEVEL)
 AC_SUBST(LVM_RELEASE)
 AC_SUBST(LVM_RELEASE_DATE)
 AC_SUBST(MIRRORS)
+AC_SUBST(REPLICATORS)
 AC_SUBST(MSGFMT)
 AC_SUBST(OWNER)
 AC_SUBST(PKGCONFIG)
@@ -1157,6 +1173,7 @@ lib/format1/Makefile
 lib/format_pool/Makefile
 lib/locking/Makefile
 lib/mirror/Makefile
+lib/replicator/Makefile
 lib/misc/lvm-version.h
 lib/snapshot/Makefile
 libdm/Makefile
lib/Makefile.in +9 -0
index a2e66f3..a1bc90b 100644
@@ -33,6 +33,10 @@ ifeq ("@MIRRORS@", "shared")
   SUBDIRS += mirror
 endif
 
+ifeq ("@REPLICATORS@", "shared")
+  SUBDIRS += replicator
+endif
+
 SOURCES =\
 	activate/activate.c \
 	cache/lvmcache.c \
@@ -75,6 +79,7 @@ SOURCES =\
 	metadata/mirror.c \
 	metadata/pv_manip.c \
 	metadata/pv_map.c \
+	metadata/replicator_manip.c \
 	metadata/segtype.c \
 	metadata/snapshot_manip.c \
 	misc/crc.c \
@@ -130,6 +135,10 @@ ifeq ("@MIRRORS@", "internal")
   SOURCES += mirror/mirrored.c
 endif
 
+ifeq ("@REPLICATORS@", "internal")
+  SOURCES += replicator/replicator.c
+endif
+
 ifeq ("@DEVMAPPER@", "yes")
   SOURCES +=\
 	activate/dev_manager.c \
lib/commands/toolcontext.c +5 -0
index 7aac361..118f09c 100644
@@ -917,6 +917,11 @@ static int _init_segtypes(struct cmd_context *cmd)
 	dm_list_add(&cmd->segtypes, &segtype->list);
 #endif
 
+#ifdef REPLICATOR_INTERNAL
+	if (!init_replicator_segtype(&seglib))
+		return 0;
+#endif
+
 #ifdef HAVE_LIBDL
 	/* Load any formats in shared libs unless static */
 	if (!is_static() &&
lib/format_text/flags.c +2 -0
index a41dc1a..994adf2 100644
@@ -67,6 +67,8 @@ static const struct flag _lv_flags[] = {
 	{PARTIAL_LV, NULL, 0},
 	{POSTORDER_FLAG, NULL, 0},
 	{VIRTUAL_ORIGIN, NULL, 0},
+	{REPLICATOR, NULL, 0},
+	{REPLICATOR_LOG, NULL, 0},
 	{0, NULL, 0}
 };
 
lib/metadata/lv_manip.c +1 -0
index 93fd57f..abcbcbf 100644
@@ -1871,6 +1871,7 @@ struct logical_volume *alloc_lv(struct dm_pool *mem)
 	dm_list_init(&lv->segments);
 	dm_list_init(&lv->tags);
 	dm_list_init(&lv->segs_using_this_lv);
+	dm_list_init(&lv->rsites);
 
 	return lv;
 }
lib/metadata/merge.c +14 -0
index 66e9ce0..3233d2b 100644
@@ -66,6 +66,8 @@ int check_lv_segments(struct logical_volume *lv, int complete_vg)
 	int r = 1;
 	uint32_t area_multiplier, s;
 	struct seg_list *sl;
+	struct replicator_site *rsite;
+	struct replicator_device *rdev;
 
 	dm_list_iterate_items(seg, &lv->segments) {
 		seg_count++;
@@ -207,6 +209,18 @@ int check_lv_segments(struct logical_volume *lv, int complete_vg)
 			if (lv == seg_lv(seg, s))
 				seg_found++;
 		}
+		if (seg_is_replicator_dev(seg)) {
+			dm_list_iterate_items(rsite, &seg->replicator->rsites) {
+				dm_list_iterate_items(rdev, &rsite->rdevices) {
+					if (lv == rdev->lv || lv == rdev->slog)
+						seg_found++;
+				}
+			}
+			if (lv == seg->replicator)
+				seg_found++;
+		}
+		if (seg_is_replicator(seg) && lv == seg->rlog_lv)
+				seg_found++;
 		if (seg->log_lv == lv)
 			seg_found++;
 		if (!seg_found) {
lib/metadata/metadata-exported.h +74 -1

111 lines not on this page · raw message

lib/metadata/replicator_manip.c new file +340 -0

340 lines not on this page · raw message

lib/metadata/segtype.h +8 -0
index 7b31c1d..d352928 100644
@@ -35,9 +35,13 @@ struct dev_manager;
 #define SEG_VIRTUAL		0x00000020U
 #define SEG_CANNOT_BE_ZEROED	0x00000040U
 #define SEG_MONITORED		0x00000080U
+#define SEG_REPLICATOR		0x00000100U
+#define SEG_REPLICATOR_DEV	0x00000200U
 #define SEG_UNKNOWN		0x80000000U
 
 #define seg_is_mirrored(seg)	((seg)->segtype->flags & SEG_AREAS_MIRRORED ? 1 : 0)
+#define seg_is_replicator(seg)	((seg)->segtype->flags & SEG_REPLICATOR ? 1 : 0)
+#define seg_is_replicator_dev(seg) ((seg)->segtype->flags & SEG_REPLICATOR_DEV ? 1 : 0)
 #define seg_is_striped(seg)	((seg)->segtype->flags & SEG_AREAS_STRIPED ? 1 : 0)
 #define seg_is_snapshot(seg)	((seg)->segtype->flags & SEG_SNAPSHOT ? 1 : 0)
 #define seg_is_virtual(seg)	((seg)->segtype->flags & SEG_VIRTUAL ? 1 : 0)
@@ -110,6 +114,10 @@ struct segment_type *init_error_segtype(struct cmd_context *cmd);
 struct segment_type *init_free_segtype(struct cmd_context *cmd);
 struct segment_type *init_unknown_segtype(struct cmd_context *cmd, const char *name);
 
+#ifdef REPLICATOR_INTERNAL
+int init_replicator_segtype(struct segtype_library *seglib);
+#endif
+
 #ifdef SNAPSHOT_INTERNAL
 struct segment_type *init_snapshot_segtype(struct cmd_context *cmd);
 #endif
lib/replicator/.exported_symbols new file +1 -0
new file mode 100644
index 0000000..1c92c6a
@@ -0,0 +1 @@
+init_segtype
lib/replicator/Makefile.in new file +29 -0
new file mode 100644
index 0000000..b7c1d5d
@@ -0,0 +1,29 @@
+#
+# Copyright (C) 2009-2010 Red Hat, Inc. All rights reserved.
+#
+# This file is part of LVM2.
+#
+# This copyrighted material is made available to anyone wishing to use,
+# modify, copy, or redistribute it subject to the terms and conditions
+# of the GNU General Public License v.2.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+top_builddir = @top_builddir@
+VPATH = @srcdir@
+
+SOURCES = replicator.c
+
+LIB_SHARED = liblvm2replicator.so
+LIB_VERSION = $(LIB_VERSION_LVM)
+
+include $(top_builddir)/make.tmpl
+
+install: $(LIB_SHARED)
+	$(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) $< \
+		$(libdir)/$(LIB_SHARED).$(LIB_VERSION)
+	$(LN_S) -f $(LIB_SHARED).$(LIB_VERSION) $(libdir)/$(LIB_SHARED)
lib/replicator/replicator.c new file +794 -0

794 lines not on this page · raw message

Signature · 1 line
1.7.0.1
#6 lore raw

PATCH 5/25 Replicator: validate replicator segments

In reply to Zdenek Kabelac

Check for possible problems within replicator structures.

---
 lib/metadata/metadata.c |  158 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 158 insertions(+), 0 deletions(-)
lib/metadata/metadata.c +158 -0
index dcf1aa9..a3c855c 100644
@@ -2138,6 +2138,161 @@ void lv_calculate_readahead(const struct logical_volume *lv, uint32_t *read_ahea
 	}
 }
 
+/*
+ * Validate replicator structures:
+ * Check for:
+ *  non-clustered vg for replicator
+ *  only one segment in replicator LV
+ *  site has correct combination of operation_mode parameters
+ *  site and devices have correct index numbers
+ *  duplicate site names, site indexes, device names, device indexes
+ */
+static int _replicator_validate(const struct logical_volume *lv)
+{
+	struct replicator_site *rsite, *rsiteb;
+	struct replicator_device *rdev, *rdevb;
+	struct lv_segment *rseg;
+	int r = 1;
+
+	if (vg_is_clustered(lv->vg)) {
+		log_error(INTERNAL_ERROR "Volume Group %s of replicator %s is clustered",
+			  lv->vg->name, lv->name);
+		return 0;
+	}
+
+	if (dm_list_size(&lv->segments) != 1) {
+		log_error(INTERNAL_ERROR "Replicator %s segment size %d != 1",
+			  lv->name, dm_list_size(&lv->segments));
+		return 0;
+	}
+
+	rseg = first_seg(lv);
+
+	dm_list_iterate_items(rsite, &lv->rsites) {
+		if (rsite->op_mode == DM_REPLICATOR_SYNC) {
+			if (rsite->fall_behind_timeout) {
+				log_error(INTERNAL_ERROR "Defined fall_behind_timeout="
+					  "%d for sync replicator %s/%s.",
+					  rsite->fall_behind_timeout, lv->name,
+					  rsite->name);
+				r = 0;
+			}
+			if (rsite->fall_behind_ios) {
+				log_error(INTERNAL_ERROR "Defined fall_behind_ios="
+					  "%d for sync replicator %s/%s.",
+					  rsite->fall_behind_ios, lv->name, rsite->name);
+				r = 0;
+			}
+			if (rsite->fall_behind_data) {
+				log_error(INTERNAL_ERROR "Defined fall_behind_data="
+					  "%" PRIu64 " for sync replicator %s/%s.",
+					  rsite->fall_behind_data, lv->name, rsite->name);
+				r = 0;
+			}
+		} else {
+			if (rsite->fall_behind_timeout && rsite->fall_behind_ios) {
+				log_error(INTERNAL_ERROR "Defined fall_behind_timeout and"
+					  " fall_behind_ios for async replicator %s/%s.",
+					  lv->name, rsite->name);
+				r = 0;
+			}
+			if (rsite->fall_behind_timeout && rsite->fall_behind_data) {
+				log_error(INTERNAL_ERROR "Defined fall_behind_timeout and"
+					  " fall_behind_data for async replicator %s/%s.",
+					  lv->name, rsite->name);
+				r = 0;
+			}
+			if (rsite->fall_behind_ios && rsite->fall_behind_data) {
+				log_error(INTERNAL_ERROR "Defined fall_behind_ios and"
+					  " fall_behind_data for async replicator %s/%s.",
+					  lv->name, rsite->name);
+				r = 0;
+			}
+			if (!rsite->fall_behind_ios && !rsite->fall_behind_data &&
+			    !rsite->fall_behind_timeout) {
+				log_error(INTERNAL_ERROR "fall_behind_timeout,"
+					  " fall_behind_ios and fall_behind_data are"
+					  " undefined for async replicator %s/%s.",
+					  lv->name, rsite->name);
+				r = 0;
+			}
+		}
+		dm_list_iterate_items(rsiteb, &lv->rsites) {
+			if (rsite == rsiteb)
+				break;
+			if (strcasecmp(rsite->name, rsiteb->name) == 0) {
+				log_error(INTERNAL_ERROR "Duplicate site name"
+					  " %s detected for replicator %s.",
+					  rsite->name, lv->name);
+				r = 0;
+			}
+			if ((rsite->vg_name && rsiteb->vg_name &&
+			     strcasecmp(rsite->vg_name, rsiteb->vg_name) == 0) ||
+			    (!rsite->vg_name && !rsiteb->vg_name)) {
+				log_error(INTERNAL_ERROR "Duplicate VG name"
+					  " %s detected for replicator %s.",
+					  (rsite->vg_name) ? rsite->vg_name : "<local>",
+					  lv->name);
+				r = 0;
+			}
+			if (rsite->site_index == rsiteb->site_index) {
+				log_error(INTERNAL_ERROR "Duplicate site index"
+					  " %d detected for replicator %s/%s.",
+					  rsite->site_index, lv->name,
+					  rsite->name);
+				r = 0;
+			}
+			if (rsite->site_index > rseg->rsite_index_highest) {
+				log_error(INTERNAL_ERROR "Site index %d > %d"
+					  " (too high) for replicator %s/%s.",
+					  rsite->site_index,
+					  rseg->rsite_index_highest,
+					  lv->name, rsite->name);
+				r = 0;
+			}
+		}
+
+		dm_list_iterate_items(rdev, &rsite->rdevices) {
+			dm_list_iterate_items(rdevb, &rsite->rdevices) {
+				if (rdev == rdevb)
+					break;
+				if (rdev->slog && (rdev->slog == rdevb->slog)) {
+					log_error(INTERNAL_ERROR "Duplicate "
+						  "sync log %s detected for "
+						  "replicator %s.",
+						  rdev->slog->name, lv->name);
+					r = 0;
+				}
+				if (strcasecmp(rdev->name, rdevb->name) == 0) {
+					log_error(INTERNAL_ERROR "Duplicate "
+						  "device name %s detected "
+						  "for replicator %s.",
+						  rdev->name, lv->name);
+					r = 0;
+				}
+				if (rdev->device_index == rdevb->device_index) {
+					log_error(INTERNAL_ERROR "Duplicate "
+						  "device index %" PRId64
+						  " detected for replicator "
+						  "%s/%s.", rdev->device_index,
+						  lv->name, rsite->name);
+					r = 0;
+				}
+				if (rdev->device_index > rseg->rdevice_index_highest) {
+					log_error(INTERNAL_ERROR "Device index %" PRIu64 " > %"
+						  PRIu64 " (too high) for replicator %s/%s.",
+						  rdev->device_index,
+						  rseg->rdevice_index_highest,
+						  lv->name, rsite->name);
+					r = 0;
+				}
+			}
+		}
+	}
+
+	return r;
+}
+
 int vg_validate(struct volume_group *vg)
 {
 	struct pv_list *pvl, *pvl2;
@@ -2238,6 +2393,9 @@ int vg_validate(struct volume_group *vg)
 				r = 0;
 			}
 		}
+
+		if (lv_is_replicator(lvl->lv) && !_replicator_validate(lvl->lv))
+			r = 0;
 	}
 
 	dm_list_iterate_items(lvl, &vg->lvs) {
Signature · 1 line
1.7.0.1
#7 lore raw

PATCH 6/25 Replicator: extend _lv_each_dependency() rep. deps

In reply to Zdenek Kabelac
---
 lib/metadata/metadata.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
lib/metadata/metadata.c +4 -0
index a3c855c..822e6d1 100644
@@ -1977,6 +1977,8 @@ static int _lv_each_dependency(struct logical_volume *lv,
 	struct lv_segment *lvseg;
 
 	struct logical_volume *deps[] = {
+		(lv->rdevice && lv != lv->rdevice->lv) ? lv->rdevice->lv : 0,
+		(lv->rdevice && lv != lv->rdevice->slog) ? lv->rdevice->slog : 0,
 		lv->snapshot ? lv->snapshot->origin : 0,
 		lv->snapshot ? lv->snapshot->cow : 0 };
 	for (i = 0; i < sizeof(deps) / sizeof(*deps); ++i) {
@@ -1987,6 +1989,8 @@ static int _lv_each_dependency(struct logical_volume *lv,
 	dm_list_iterate_items(lvseg, &lv->segments) {
 		if (lvseg->log_lv && !fn(lvseg->log_lv, data))
 			return_0;
+		if (lvseg->rlog_lv && !fn(lvseg->rlog_lv, data))
+			return_0;
 		for (s = 0; s < lvseg->area_count; ++s) {
 			if (seg_type(lvseg, s) == AREA_LV && !fn(seg_lv(lvseg,s), data))
 				return_0;
Signature · 1 line
1.7.0.1
#8 lore raw

PATCH 7/25 Replicator: extend VG with list of opened vgs

In reply to Zdenek Kabelac

Add linked list of opened VGs and counter for missing VGs. Needed for replicator target.

---
 lib/metadata/metadata-exported.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
lib/metadata/metadata-exported.h +4 -0
index cc4221e..ac0681e 100644
@@ -250,6 +250,10 @@ struct volume_group {
 
 	struct dm_list tags;
 
+        /* List of locked and opened VGs */
+	struct dm_list vgs;
+	uint32_t missing_vgs;
+
 	/*
 	 * FIXME: Move the next fields into a different struct?
 	 */
Signature · 1 line
1.7.0.1
#9 lore raw

PATCH 8/25 Replicator: add sorted vg_name_list

In reply to Zdenek Kabelac

Introduce struct vg_name_list to store information about needed volume group name, vgid, flags and the pointer to opened VG.

Keep VG in list in alphabetical order for locking order.

Introduce functions vg_name_list_add(), vg_name_list_lookup(), vg_name_list_splice(). They extend dm_list functionality.

vg_name_list_read() open list of VGs.
vg_name_list_release close VGs in reversed order.

---
 lib/metadata/metadata-exported.h |   21 ++++++
 lib/metadata/replicator_manip.c  |  148 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 169 insertions(+), 0 deletions(-)
lib/metadata/metadata-exported.h +21 -0
index ac0681e..594c0b0 100644
@@ -288,6 +288,15 @@ struct lv_segment_area {
 
 struct segment_type;
 
+/* List with VG names */
+struct vg_name_list {
+	struct dm_list list;
+	const char *vg_name;
+	const char *vgid;
+	uint32_t flags;
+	struct volume_group *vg;
+};
+
 /* ++ replicator datatypes */
 typedef enum {
 	REPLICATOR_STATE_PASSIVE,
@@ -778,6 +787,18 @@ int lv_is_rlog(const struct logical_volume *lv);
 int lv_is_slog(const struct logical_volume *lv);
 struct logical_volume *first_replicator_dev(const struct logical_volume *lv);
 /* --  metadata/replicator_manip.c */
+void vg_name_list_splice(struct dm_list *list, struct dm_list *head);
+struct vg_name_list *vg_name_list_add(struct dm_pool *mem,
+				      struct dm_list *vg_nlist,
+				      const char *vg_name, const char *vgid,
+				      uint32_t flags);
+struct vg_name_list *vg_name_list_lookup(struct dm_list *vg_nlist,
+					 const char *vg_name);
+
+int vg_name_list_read(struct cmd_context *cmd, struct dm_list *vgs_list,
+		      struct vg_name_list *vnl_vg);
+void vg_name_list_release(struct dm_list *vgs_list,
+			  struct vg_name_list *vnl_vg);
 
 struct logical_volume *find_pvmove_lv(struct volume_group *vg,
 				      struct device *dev, uint32_t lv_type);
lib/metadata/replicator_manip.c +148 -0

151 lines not on this page · raw message

Signature · 1 line
1.7.0.1
#10 lore raw

PATCH 9/25 Replicator: add lv_replicator_sites_check_vg

In reply to Zdenek Kabelac

Adding lv_replicator_sites_check_vg() which is called before taking lock_vol().

---
 lib/metadata/metadata-exported.h |    2 ++
 lib/metadata/replicator_manip.c  |   32 ++++++++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 0 deletions(-)
lib/metadata/metadata-exported.h +2 -0
index 594c0b0..3e1da12 100644
@@ -800,6 +800,8 @@ int vg_name_list_read(struct cmd_context *cmd, struct dm_list *vgs_list,
 void vg_name_list_release(struct dm_list *vgs_list,
 			  struct vg_name_list *vnl_vg);
 
+int lv_replicator_sites_check_vg(struct logical_volume *lv);
+
 struct logical_volume *find_pvmove_lv(struct volume_group *vg,
 				      struct device *dev, uint32_t lv_type);
 struct logical_volume *find_pvmove_lv_from_pvname(struct cmd_context *cmd,
lib/metadata/replicator_manip.c +32 -0
index 52a7fcb..d5e3cda 100644
@@ -486,3 +486,35 @@ void vg_name_list_release(struct dm_list *vgs_list,
 		vnl->vg = NULL;
 	}
 }
+
+/**
+ * Check whether all VGs are available for processing given LV
+ * Missing VGs are added to the list
+ */
+int lv_replicator_sites_check_vg(struct logical_volume *lv)
+{
+	struct replicator_site *rsite;
+	int ret = 1;
+
+	if (!lv_is_replicator_dev(lv))
+		return 1;
+
+	dm_list_iterate_items(rsite, &first_seg(lv)->replicator->rsites) {
+		if (!rsite->vg_name ||
+		    vg_name_list_lookup(&lv->vg->vgs, rsite->vg_name))
+			continue;
+		ret = 0;
+		/* Using cmd memory pool for list allocation */
+		if (!vg_name_list_add(lv->vg->cmd->mem, &lv->vg->vgs,
+				      rsite->vg_name, NULL, 0)) {
+			stack;
+			lv->vg->missing_vgs = 0; /* do not retry */
+			break;
+		}
+
+		log_debug("VG: %s added as missing.", rsite->vg_name);
+		lv->vg->missing_vgs++;
+	}
+
+	return ret;
+}
Signature · 1 line
1.7.0.1
#11 lore raw

PATCH 10/25 Replicator: add read/release VG for rsites

In reply to Zdenek Kabelac

Add function to read/release remote VGs from replicator sites in activation context.

---
 lib/metadata/metadata-exported.h |    2 +
 lib/metadata/replicator_manip.c  |   56 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 0 deletions(-)
lib/metadata/metadata-exported.h +2 -0
index 3e1da12..cf73bf8 100644
@@ -801,6 +801,8 @@ void vg_name_list_release(struct dm_list *vgs_list,
 			  struct vg_name_list *vnl_vg);
 
 int lv_replicator_sites_check_vg(struct logical_volume *lv);
+int lv_replicator_sites_read(struct logical_volume *lv);
+void lv_replicator_sites_release(struct logical_volume *lv);
 
 struct logical_volume *find_pvmove_lv(struct volume_group *vg,
 				      struct device *dev, uint32_t lv_type);
lib/metadata/replicator_manip.c +56 -0

59 lines not on this page · raw message

Signature · 1 line
1.7.0.1
#12 lore raw

PATCH 11/25 Replicator: use vg_name_list for _process_one_vg()

In reply to Zdenek Kabelac

Patch modifes behavior of _process_one_vg().

In the first pass the plain vg_read() for the given VG is used. Replicator collects sorted list of additional VGs during lock_vol. If any needed VG is not yet opened the next iteration loop is taken with collected VGs.

Flag vg->missing_vgs detects missing VGs.

---
 tools/toollib.c |   56 ++++++++++++++++++++++++++++++++----------------------
 1 files changed, 33 insertions(+), 23 deletions(-)
tools/toollib.c +33 -23
index 972d077..066fbfd 100644
@@ -424,37 +424,47 @@ static int _process_one_vg(struct cmd_context *cmd, const char *vg_name,
 						  struct volume_group * vg,
 						  void *handle))
 {
-	struct volume_group *vg;
+	struct dm_list vgs_list;
+	struct vg_name_list *vnl_vg;
 	int ret = 0;
 
 	log_verbose("Finding volume group \"%s\"", vg_name);
 
-	vg = vg_read(cmd, vg_name, vgid, flags);
-	/* Allow FAILED_INCONSISTENT through only for vgcfgrestore */
-	if (vg_read_error(vg) &&
-	    !((vg_read_error(vg) == FAILED_INCONSISTENT) &&
-	      (flags & READ_ALLOW_INCONSISTENT))) {
-		ret_max = ECMD_FAILED;
-		goto_out;
-	}
+	dm_list_init(&vgs_list);
+	vnl_vg = vg_name_list_add(cmd->mem, &vgs_list, vg_name, vgid, flags);
+	if (!vnl_vg)
+		return_0;
+
+	while (!sigint_caught()) {
+		if (!vg_name_list_read(cmd, &vgs_list, vnl_vg))
+			/* Allow FAILED_INCONSISTENT through only for vgcfgrestore */
+			if (vg_read_error(vnl_vg->vg) &&
+			    (!((flags & READ_ALLOW_INCONSISTENT) &&
+			       (vg_read_error(vnl_vg->vg) == FAILED_INCONSISTENT)))) {
+				ret = ECMD_FAILED;
+				break;
+			}
+
+		if (!dm_list_empty(tags) &&
+		    /* Only process if a tag matches or it's on arg_vgnames */
+		    !str_list_match_item(arg_vgnames, vg_name) &&
+		    !str_list_match_list(tags, &vnl_vg->vg->tags))
+			break;
 
-	if (!dm_list_empty(tags)) {
-		/* Only process if a tag matches or it's on arg_vgnames */
-		if (!str_list_match_item(arg_vgnames, vg_name) &&
-		    !str_list_match_list(tags, &vg->tags))
-			goto out;
+		ret = process_single(cmd, vg_name, vnl_vg->vg, handle);
+
+		if (vg_read_error(vnl_vg->vg)) /* FAILED_INCONSISTENT */
+			break;
+
+		if (!vnl_vg->vg->missing_vgs)
+			break;
+
+		vg_name_list_release(&vgs_list, vnl_vg);
 	}
 
-	if ((ret = process_single(cmd, vg_name, vg,
-				  handle)) > ret_max)
-		ret_max = ret;
+	vg_name_list_release(&vgs_list, vnl_vg);
 
-out:
-	if (vg_read_error(vg))
-		vg_release(vg);
-	else
-		unlock_and_release_vg(cmd, vg, vg_name);
-	return ret_max;
+	return (ret > ret_max) ? ret : ret_max;
 }
 
 int process_each_vg(struct cmd_context *cmd, int argc, char **argv,
Signature · 1 line
1.7.0.1
#13 lore raw

PATCH 12/25 Replicator: use str_list for process_each_lv_in_vg

In reply to Zdenek Kabelac

As for _process_one_vg() we need similar retry loop for process_each_lv_in_vg(). This patch tries to collect missed LVs and then reopens collected VGs and process only selected LVs again.

Patch does not add any extra repeated invocations if there is not missing VG during LV processing.

cmd_context is extended to avoid API change with vgs_lvs_retry list.
FIXME: modify process_each_lv_in_vg() API to avoid this change

---
 lib/commands/toolcontext.c |    1 +
 lib/commands/toolcontext.h |    2 +
 tools/toollib.c            |   61 ++++++++++++++++++++++++++++++++++++-------
 3 files changed, 54 insertions(+), 10 deletions(-)
lib/commands/toolcontext.c +1 -0
index 118f09c..b61f37a 100644
@@ -1109,6 +1109,7 @@ struct cmd_context *create_toolcontext(unsigned is_long_lived,
 	dm_list_init(&cmd->segtypes);
 	dm_list_init(&cmd->tags);
 	dm_list_init(&cmd->config_files);
+	dm_list_init(&cmd->vgs_lvs_retry);
 
 	/* FIXME Make this configurable? */
 	reset_lvm_errno(1);
lib/commands/toolcontext.h +2 -0
index eac5721..a72d76d 100644
@@ -96,6 +96,8 @@ struct cmd_context {
 	char dev_dir[PATH_MAX];
 	char proc_dir[PATH_MAX];
 	char sysfs_dir[PATH_MAX];
+
+	struct dm_list vgs_lvs_retry;	/* Retry LVs with more VGs */
 };
 
 /*
tools/toollib.c +51 -10

102 lines not on this page · raw message

Signature · 1 line
1.7.0.1
#14 lore raw

PATCH 13/25 Replicator: lock_vol update replicator LV

In reply to Zdenek Kabelac

Add LCK_MISSING_VG flag to sinal missing VG to _lock_vol function. This way we easily detect whether we still need to lock more VGs while having all data available - it would be ackware to resolve it from resource uuid string. In the case missing VG is found, whole whole operation must be retried - this usually requires to release all locks, and take them again in the alphabetic order.

---
 lib/locking/locking.c |    3 +++
 lib/locking/locking.h |    7 ++++++-
 2 files changed, 9 insertions(+), 1 deletions(-)
lib/locking/locking.c +3 -0
index 76dbda5..57b7ba9 100644
@@ -362,6 +362,9 @@ static int _lock_vol(struct cmd_context *cmd, const char *resource,
 {
 	int ret = 0;
 
+	if (flags & LCK_MISSING_VG)
+		return_0;
+
 	_block_signals(flags);
 	_lock_memory(cmd, lv_op);
 
lib/locking/locking.h +6 -1
index e7f25b9..da442ec 100644
@@ -86,6 +86,7 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname);
 #define LCK_LOCAL	0x00000040U	/* Don't propagate to other nodes */
 #define LCK_CLUSTER_VG	0x00000080U	/* VG is clustered */
 #define LCK_CACHE	0x00000100U	/* Operation on cache only using P_ lock */
+#define LCK_MISSING_VG	0x00000200U	/* 'Remote' VG misses lock for this LV */
 
 /*
  * Additional lock bits for cluster communication
@@ -128,8 +129,12 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname);
 #define LCK_LV_CLUSTERED(lv)	\
 	(vg_is_clustered((lv)->vg) ? LCK_CLUSTER_VG : 0)
 
+#define LCK_CHECK_MISSING_VG(lv)	\
+	(lv_replicator_sites_check_vg((lv)) ? 0 : LCK_MISSING_VG)
+
 #define lock_lv_vol(cmd, lv, flags)	\
-	lock_vol(cmd, (lv)->lvid.s, flags | LCK_LV_CLUSTERED(lv))
+	lock_vol(cmd, (lv)->lvid.s, flags | LCK_LV_CLUSTERED(lv) | \
+		 LCK_CHECK_MISSING_VG(lv))
 
 #define unlock_vg(cmd, vol)	lock_vol(cmd, vol, LCK_VG_UNLOCK)
 #define unlock_and_release_vg(cmd, vg, vol) \
Signature · 1 line
1.7.0.1
#16 lore raw

PATCH 14/25 Replicator: extend activate with rsite resolving

In reply to Zdenek Kabelac

Activation code needs to have all remote lv pointers resolved.

---
 lib/activate/activate.c |   22 ++++++++++++++++++----
 1 files changed, 18 insertions(+), 4 deletions(-)
lib/activate/activate.c +18 -4
index eb94ac0..6c28c4f 100644
@@ -854,6 +854,9 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
 		goto out;
 	}
 
+	if (!lv_replicator_sites_read(lv))
+		goto_out;
+
 	lv_calculate_readahead(lv, NULL);
 
 	/* If VG was precommitted, preload devices for the LV */
@@ -883,9 +886,10 @@ static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
 out:
 	if (lv_pre)
 		vg_release(lv_pre->vg);
-	if (lv)
+	if (lv) {
+		lv_replicator_sites_release(lv);
 		vg_release(lv->vg);
-
+	}
 	return r;
 }
 
@@ -1014,6 +1018,9 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s)
 			goto_out;
 	}
 
+	if (!lv_replicator_sites_read(lv))
+		goto_out;
+
 	lv_calculate_readahead(lv, NULL);
 
 	if (!monitor_dev_for_events(cmd, lv, 0))
@@ -1027,8 +1034,10 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s)
 	if (!lv_info(cmd, lv, &info, 1, 0) || info.exists)
 		r = 0;
 out:
-	if (lv)
+	if (lv) {
+		lv_replicator_sites_release(lv);
 		vg_release(lv->vg);
+	}
 
 	return r;
 }
@@ -1107,6 +1116,9 @@ static int _lv_activate(struct cmd_context *cmd, const char *lvid_s,
 		goto out;
 	}
 
+	if (!lv_replicator_sites_read(lv))
+		goto_out;
+
 	lv_calculate_readahead(lv, NULL);
 
 	if (exclusive)
@@ -1122,8 +1134,10 @@ static int _lv_activate(struct cmd_context *cmd, const char *lvid_s,
 		stack;
 
 out:
-	if (lv)
+	if (lv) {
+		lv_replicator_sites_release(lv);
 		vg_release(lv->vg);
+	}
 
 	return r;
 }
Signature · 1 line
1.7.0.1
#17 lore raw

PATCH 15/25 Replicator: update _create_partial_dtree()

In reply to Zdenek Kabelac

Adding function _create_partial_replicator() to create partial tree for Replicator target.

Using dm_tree_set_suspend_priority() for Replicator.

---
 lib/activate/dev_manager.c |   75 ++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 75 insertions(+), 0 deletions(-)
lib/activate/dev_manager.c +75 -0
index 5c5bc44..1adefc8 100644
@@ -867,6 +867,75 @@ static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, struc
 	return 1;
 }
 
+/*
+ * Add devices from replicator
+ * use _add_dev_to_dtree() directly instead of _add_lv_to_dtree()
+ * no need to extend its check with  _slog, _rlog, _rimage
+ */
+static int _create_partial_replicator(struct dev_manager *dm,
+				      struct dm_tree *dtree,
+				      struct lv_segment *seg)
+{
+	struct replicator_device *rdev;
+	struct replicator_site *rsite;
+	const char *replicator_dlid;
+
+	if (!lv_is_active_replicator_dev(seg->lv)) {
+		if (!_add_dev_to_dtree(dm, dtree, seg->lv->rdevice->lv,
+				       NULL))
+			return_0;
+		return 1;
+	}
+
+	/* Add all related devs for replicator */
+	dm_list_iterate_items(rsite, &seg->replicator->rsites) {
+		dm_list_iterate_items(rdev, &rsite->rdevices) {
+			if (rsite->state == REPLICATOR_STATE_ACTIVE) {
+				/* Add _rimage LV */
+				if (rdev->lv &&
+				    !_add_dev_to_dtree(dm, dtree,
+						       rdev->lv, NULL))
+					return_0;
+
+				/* Add replicator-dev LV */
+				if (seg->lv != rdev->replicator_dev->lv &&
+				    !_add_dev_to_dtree(dm, dtree,
+						       rdev->replicator_dev->lv,
+						       NULL))
+					return_0;
+			}
+
+			if (!rdev->rsite->vg_name)
+				continue;
+
+			if (rdev->lv &&
+			    !_add_dev_to_dtree(dm, dtree, rdev->lv, NULL))
+				return_0;
+
+			if (rdev->slog &&
+			    !_add_dev_to_dtree(dm, dtree, rdev->slog, NULL))
+				return_0;
+
+		}
+	}
+
+	/* Add rlog and replicator devices */
+	if (first_seg(seg->replicator)->rlog_lv &&
+	    !_add_dev_to_dtree(dm, dtree,
+			       first_seg(seg->replicator)->rlog_lv, NULL))
+		return_0;
+	if (!_add_dev_to_dtree(dm, dtree, seg->replicator, NULL))
+		return_0;
+
+	/* Set suspend priority for replicator device */
+	if (!(replicator_dlid = build_dlid(dm, seg->replicator->lvid.s, NULL)))
+		return_0;
+	if (!dm_tree_set_suspend_priority(dtree, replicator_dlid, 1))
+		return_0;
+
+	return 1;
+}
+
 static struct dm_tree *_create_partial_dtree(struct dev_manager *dm, struct logical_volume *lv)
 {
 	struct dm_tree *dtree;
@@ -887,6 +956,12 @@ static struct dm_tree *_create_partial_dtree(struct dev_manager *dm, struct logi
 		if (!_add_lv_to_dtree(dm, dtree, dm_list_struct_base(snh, struct lv_segment, origin_list)->cow))
 			goto_bad;
 
+	/* Add any replicator-dev LVs of this LV */
+	dm_list_iterate_items(seg, &lv->segments)
+		if (seg_is_replicator_dev(seg) &&
+		    !_create_partial_replicator(dm, dtree, seg))
+			goto_bad;
+
 	/* Add any LVs used by segments in this LV */
 	dm_list_iterate_items(seg, &lv->segments)
 		for (s = 0; s < seg->area_count; s++)
Signature · 1 line
1.7.0.1
#18 lore raw

PATCH 16/25 Replicator: vg with missing_vgs does not print

In reply to Zdenek Kabelac

If missed VGs do not print message and wait for retry.

---
 tools/vgchange.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
tools/vgchange.c +3 -2
index 6d869f9..4045411 100644
@@ -224,8 +224,9 @@ static int _vgchange_available(struct cmd_context *cmd, struct volume_group *vg)
 
 	ret = _activate_lvs_in_vg(cmd, vg, available);
 
-	log_print("%d logical volume(s) in volume group \"%s\" now active",
-		  lvs_in_vg_activated(vg), vg->name);
+	if (!vg->missing_vgs)
+		log_print("%d logical volume(s) in volume group \"%s\" now active",
+			  lvs_in_vg_activated(vg), vg->name);
 	return ret;
 }
 
Signature · 1 line
1.7.0.1
#19 lore raw

PATCH 17/25 Replicator: add replicator to dtree

In reply to Zdenek Kabelac

Adding all replicator related LVs to dtree.
Start of one replicator_dev initiate start of all other related.

---
 lib/activate/dev_manager.c |   60 +++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 59 insertions(+), 1 deletions(-)
lib/activate/dev_manager.c +59 -1
index 1adefc8..451ba2b 100644
@@ -1173,6 +1173,61 @@ static int _add_target_to_dtree(struct dev_manager *dm,
 static int _add_new_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree,
 				  struct logical_volume *lv, const char *layer);
 
+/* Add all replicators' LVs from active segment */
+static int _add_replicator_dev_target_to_dtree(struct dev_manager *dm,
+					       struct dm_tree *dtree,
+					       struct lv_segment *seg)
+{
+	struct replicator_device *rdev;
+	struct replicator_site *rsite;
+
+	/* Only active replicator */
+	if (!lv_is_active_replicator_dev(seg->lv)) {
+		if (!_add_new_lv_to_dtree(dm, dtree, seg->lv->rdevice->lv, NULL))
+			return_0;
+		return 1;
+	}
+
+	/* Add rlog and replicator nodes */
+	if (!seg->replicator ||
+            !first_seg(seg->replicator)->rlog_lv ||
+	    !_add_new_lv_to_dtree(dm, dtree,
+				  first_seg(seg->replicator)->rlog_lv, NULL) ||
+	    !_add_new_lv_to_dtree(dm, dtree, seg->replicator, NULL))
+	    return_0;
+
+	/* Activation of one replicator_dev node activates all other nodes */
+	dm_list_iterate_items(rsite, &seg->replicator->rsites) {
+		dm_list_iterate_items(rdev, &rsite->rdevices) {
+			if (rdev->lv &&
+			    !_add_new_lv_to_dtree(dm, dtree, rdev->lv, NULL))
+				return_0;
+
+			if (rdev->slog &&
+			    !_add_new_lv_to_dtree(dm, dtree,
+						  rdev->slog, NULL))
+				return_0;
+		}
+	}
+	/* Add remaining replicator-dev nodes in the second loop
+	 * to avoid multiple retries for inserting all elements */
+	dm_list_iterate_items(rsite, &seg->replicator->rsites) {
+		if (rsite->state != REPLICATOR_STATE_ACTIVE)
+			continue;
+		dm_list_iterate_items(rdev, &rsite->rdevices) {
+			if (rdev->replicator_dev->lv == seg->lv)
+				continue;
+			if (!rdev->replicator_dev->lv ||
+			    !_add_new_lv_to_dtree(dm, dtree,
+						  rdev->replicator_dev->lv,
+						  NULL))
+				return_0;
+		}
+	}
+
+	return 1;
+}
+
 static int _add_segment_to_dtree(struct dev_manager *dm,
 				   struct dm_tree *dtree,
 				   struct dm_tree_node *dnode,
@@ -1203,9 +1258,12 @@ static int _add_segment_to_dtree(struct dev_manager *dm,
 	    !_add_new_lv_to_dtree(dm, dtree, seg->log_lv, NULL))
 		return_0;
 
+	if (seg_is_replicator_dev(seg)) {
+		if (!_add_replicator_dev_target_to_dtree(dm, dtree, seg))
+			return_0;
 	/* If this is a snapshot origin, add real LV */
 	/* If this is a snapshot origin + merging snapshot, add cow + real LV */
-	if (lv_is_origin(seg->lv) && !layer) {
+	} else if (lv_is_origin(seg->lv) && !layer) {
 		if (vg_is_clustered(seg->lv->vg)) {
 			log_error("Clustered snapshots are not yet supported");
 			return 0;
Signature · 1 line
1.7.0.1
#20 lore raw

PATCH 18/25 Replicator: do not remove of replicators' LVs

In reply to Zdenek Kabelac
---
 lib/metadata/lv_manip.c |    9 +++++++++
 1 files changed, 9 insertions(+), 0 deletions(-)
lib/metadata/lv_manip.c +9 -0
index abcbcbf..766e6a0 100644
@@ -2080,6 +2080,15 @@ int lv_remove_single(struct cmd_context *cmd, struct logical_volume *lv,
 		return 0;
 	}
 
+	if (lv_is_replicator_dev(lv) ||
+	    lv_is_rimage(lv) ||
+	    lv_is_rlog(lv) ||
+	    lv_is_slog(lv)) {
+		log_error("Can't remove logical volume %s used by a "
+			  "replicator.", lv->name);
+		return 0;
+	}
+
 	if (lv->status & LOCKED) {
 		log_error("Can't remove locked LV %s", lv->name);
 		return 0;
Signature · 1 line
1.7.0.1
#21 lore raw

PATCH 19/25 Replicator: no crash lvresize if area_count is 0

In reply to Zdenek Kabelac

Currently with replicator-dev LV we get area_count=0 for lvresize request. The original reason needs to be exploread, meanwhile avoid crash, but stopping processing if count is 0.

---
 lib/metadata/lv_manip.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
lib/metadata/lv_manip.c +5 -0
index 766e6a0..67cd220 100644
@@ -1380,6 +1380,11 @@ int lv_add_segment(struct alloc_handle *ah,
 		return 0;
 	}
 
+	if (!ah->area_count) {
+		log_error("Allocated areas are empty.");
+		return 0;
+	}
+
 	if (!_setup_alloced_segments(lv, &ah->alloced_areas[first_area],
 				     num_areas, status,
 				     stripe_size, segtype,
Signature · 1 line
1.7.0.1
#23 lore raw

PATCH 20/25 Replicator: activate change for vgchange

In reply to Zdenek Kabelac

Activate only the first replicator-dev LV, that activates all other related LVs from Replicator.

---
 tools/vgchange.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
tools/vgchange.c +4 -0
index 4045411..637ce78 100644
@@ -104,6 +104,10 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd,
 		if ((lv->status & MIRROR_IMAGE) || (lv->status & MIRROR_LOG))
 			continue;
 
+		/* Only request activation of the first replicator-dev LV */
+		if (lv_is_replicator_dev(lv) && (lv != first_replicator_dev(lv)))
+			continue;
+
 		/* Can't deactivate a pvmove LV */
 		/* FIXME There needs to be a controlled way of doing this */
 		if (((activate == CHANGE_AN) || (activate == CHANGE_ALN)) &&
Signature · 1 line
1.7.0.1
#24 lore raw

PATCH 21/25 Replicator: add new options for replicator

In reply to Zdenek Kabelac

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

---
 lib/config/defaults.h            |    1 +
 lib/metadata/metadata-exported.h |    1 +
 tools/args.h                     |   13 ++++++++
 tools/commands.h                 |   10 +++++-
 tools/lvcreate.c                 |   58 +++++++++++++++++++++++++++++++++++++-
 tools/lvmcmdline.c               |    9 ++++++
 tools/tools.h                    |    1 +
 7 files changed, 90 insertions(+), 3 deletions(-)
lib/config/defaults.h +1 -0
index 22a085d..4ef94ff 100644
@@ -108,6 +108,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
lib/metadata/metadata-exported.h +1 -0
index cf73bf8..3c49b7b 100644
@@ -596,6 +596,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 */
tools/args.h +13 -0
index 981f45f..4623ff6 100644
@@ -66,6 +66,19 @@ arg(virtualoriginsize_ARG, '\0', "virtualoriginsize", size_mb_arg, 0)
 arg(virtualsize_ARG, '\0', "virtualsize", size_mb_arg, 0)
 arg(noudevsync_ARG, '\0', "noudevsync", NULL, 0)
 arg(poll_ARG, '\0', "poll", yes_no_arg, 0)
+arg(replicator_ARG, '\0', "replicator", NULL, 0)
+arg(replicatordev_ARG, '\0', "replicatordev", NULL, 0)
+arg(replicatorlog_ARG, '\0', "replicatorlog", NULL, 0)
+arg(replicatorlogtype_ARG, '\0', "replicatorlogtype", NULL, 0)
+arg(addsite_ARG, '\0', "addsite", site_arg, 0)
+arg(delsite_ARG, '\0', "delsite", site_arg, 0)
+arg(fallbehinddata_ARG, '\0', "fallbehinddata", size_mb_arg, 0)
+arg(fallbehindios_ARG, '\0', "fallbehindios", int_arg, 0)
+arg(fallbehindtimeout_ARG, '\0', "fallbehindtimeout", int_arg, 0)
+arg(sitemode_ARG, '\0', "sitemode", string_arg, 0)
+arg(activesite_ARG, '\0', "activesite", string_arg, 0)
+arg(passivesite_ARG, '\0', "passivesite", string_arg, 0)
+arg(remotevolumegroup_ARG, '\0', "remotevolumegroup", string_arg, 0)
 
 /* Allow some variations */
 arg(resizable_ARG, '\0', "resizable", yes_no_arg, 0)
tools/commands.h +8 -2
index ad0b385..44c5a21 100644
@@ -62,10 +62,12 @@ xx(lvchange,
    "lvchange\n"
    "\t[-A|--autobackup y|n]\n"
    "\t[-a|--available [e|l]y|n]\n"
+   "\t[--addsite Site]\n"
    "\t[--addtag Tag]\n"
    "\t[--alloc AllocationPolicy]\n"
    "\t[-C|--contiguous y|n]\n"
    "\t[-d|--debug]\n"
+   "\t[--delsite Site]\n"
    "\t[--deltag Tag]\n"
    "\t[-f|--force]\n"
    "\t[-h|--help]\n"
@@ -90,7 +92,7 @@ xx(lvchange,
    ignorelockingfailure_ARG, ignoremonitoring_ARG, major_ARG, minor_ARG,
    monitor_ARG, noudevsync_ARG, partial_ARG, permission_ARG, persistent_ARG,
    poll_ARG, readahead_ARG, resync_ARG, refresh_ARG, addtag_ARG, deltag_ARG,
-   test_ARG, yes_ARG)
+   test_ARG, addsite_ARG, delsite_ARG, yes_ARG)
 
 xx(lvconvert,
    "Change logical volume layout",
@@ -160,6 +162,9 @@ xx(lvcreate,
    "\t[-p|--permission {r|rw}]\n"
    "\t[-r|--readahead ReadAheadSectors|auto|none]\n"
    "\t[-R|--regionsize MirrorLogRegionSize]\n"
+   "\t[--replicator]\n"
+   "\t[--replicatorlog LogicalVolumeName]\n"
+   "\t[--replicatorlogtype ringbuffer]\n"
    "\t[-t|--test]\n"
    "\t[--type VolumeType]\n"
    "\t[-v|--verbose]\n"
@@ -194,7 +199,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)
 
tools/lvcreate.c +57 -1

88 lines not on this page · raw message

tools/lvmcmdline.c +9 -0
index 69e2c87..41204a4 100644
@@ -488,6 +488,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))) {
tools/tools.h +1 -0
index 75575e7..8dbabbc 100644
@@ -152,6 +152,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 arg_count(const struct cmd_context *cmd, int a);
Signature · 1 line
1.7.0.1
#25 lore raw

PATCH 22/25 Replicator: man pages for lvcreate, lvchange

In reply to Zdenek Kabelac

Update man pages to cover basic usage of lvcreate and lvchange utility to handle basic replicator commands.

Current desriptions shows how to create replicator, add site, add replicated device.

---
 man/lvchange.8.in |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 man/lvcreate.8.in |   55 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 114 insertions(+), 1 deletions(-)
man/lvchange.8.in +59 -1
index 08a83c4..0d091c9 100644
@@ -3,10 +3,18 @@
 lvchange \- change attributes of a logical volume
 .SH SYNOPSIS
 .B lvchange
+[\-\-addsite Site]
 [\-\-addtag Tag]
 [\-A|\-\-autobackup y|n] [\-a|\-\-available y|n|ey|en|ly|ln]
 [\-\-alloc AllocationPolicy]
 [\-C|\-\-contiguous y|n] [\-d|\-\-debug] [\-\-deltag Tag]
+[\-\-delsite Site]
+[[\-\-fallbehinddata Size[bBsSkKmMgGtTpPeE]] |
+[\-\-fallbehindios  IOS] |
+[\-\-fallbehindtimeout sec]]
+[\-\-sitemode [sync|warn|stall|drop|fail]
+[\-\-activesite Site]
+[\-\-passivesite Site]
 [\-\-resync]
 [\-h|\-?|\-\-help]
 [\-\-ignorelockingfailure]
@@ -19,7 +27,9 @@ lvchange \- change attributes of a logical volume
 [\-p|\-\-permission r|rw] [\-r/\-\-readahead ReadAheadSectors|auto|none]
 [\-\-refresh]
 [\-t|\-\-test]
-[\-v|\-\-verbose] LogicalVolumePath [LogicalVolumePath...]
+[\-v|\-\-verbose]
+[\-\-remotevolumegroup VolumeGroupName]
+LogicalVolumePath [LogicalVolumePath...]
 .SH DESCRIPTION
 lvchange allows you to change the attributes of a logical volume
 including making them known to the kernel ready for use.
@@ -102,10 +112,58 @@ If the logical volume is active, reload its metadata.
 This is not necessary in normal operation, but may be useful
 if something has gone wrong or if you're doing clustering 
 manually without a clustered lock manager.
+.TP
+.I \-\-addsite
+Add new site to given replicator LV.
+.TP
+.I \-\-delsite
+Remove given site from replicator LV.
+.TP
+.I \-\-fallbehinddata
+How many data could get replicator behind. Cannot be mixed
+with --fallbehindios or --fallbehindtimeout.
+.TP
+.I \-\-fallbehindios 
+How many io operation could be queued in replicator backing store device.
+Cannot be mixed with --fallbehinddata or --fallbehindtimeout.
+.TP
+.I \-\-fallbehindtimeout
+How many seconds could be replicator behind actual data. Cannot be mixed
+with --fallbehinddata or --fallbehindios.
+.TP
+.I \-\-sitemode
+Select replication mode. Default is Warn.
+Sync is synchronous mode. Warn,Stall,Drop,Fail are asynchronous modes.
+Warn issues warning when remote site is switched to sync log.
+Stall stalls replicator until remote site is back in range.
+Drop drops whole remote site, if it get too behind.
+Fail whole replicator fails is remote sites gets too behind.
+Local site works usually in stall mode. There is no synclog for local
+replicated volumes.
+.TP
+.I \-\-activesite 
+Marks site as active. Note: Only one site from replicator could be 
+marked active with actual implementation and this site must be 
+local site.
+.TP
+.I \-\-passivesite 
+Marks site as passive which is default.
+.TP
+.I \-\-remotevolumegroup 
+Selects remote volume group for remote site that contains logical volumes
+with same names for replication as the local site. Local site inside
+replicator's is assumed if remotevolumegroup is not specified.
+.TP
 .SH Examples
 "lvchange -pr vg00/lvol1" changes the permission on 
 volume lvol1 in volume group vg00 to be read-only.
 
+"lvchange --addsite NewYork vg00/replicator0"
+adds new local site NewYork in replicator vg00/replicator0.
+
+"lvchange --activesite NewYork vg00/replicator0"
+marks site NewYork in replicator vg00/replicator0 as active.
+
 .SH SEE ALSO
 .BR lvm (8), 
 .BR lvcreate (8),
man/lvcreate.8.in +55 -0

83 lines not on this page · raw message

Signature · 1 line
1.7.0.1
#26 lore raw

PATCH 23/25 Replicator: update copyright dates

In reply to Zdenek Kabelac
---
 lib/activate/dev_manager.c |    2 +-
 lib/metadata/segtype.h     |    2 +-
 libdm/libdm-deptree.c      |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
lib/activate/dev_manager.c +1 -1
index 451ba2b..a947e8f 100644
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2002-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.
  *
lib/metadata/segtype.h +1 -1
index d352928..89e2e98 100644
@@ -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.
  *
libdm/libdm-deptree.c +1 -1
index 885a9f9..9cb71a5 100644
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005-2007 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2005-2010 Red Hat, Inc. All rights reserved.
  *
  * This file is part of the device-mapper userspace tools.
  *
Signature · 1 line
1.7.0.1
#27 lore raw

PATCH 24/25 Replicator: update generated lib/misc/configure.h.in

In reply to Zdenek Kabelac
---
 lib/misc/configure.h.in |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
lib/misc/configure.h.in +3 -0
index b0af63f..8e53fa0 100644
@@ -416,6 +416,9 @@
 /* Define to 1 to include the LVM readline shell. */
 #undef READLINE_SUPPORT
 
+/* Define to 1 to include built-in support for replicators. */
+#undef REPLICATOR_INTERNAL
+
 /* Define as the return type of signal handlers (`int' or `void'). */
 #undef RETSIGTYPE
 
Signature · 1 line
1.7.0.1
#28 lore raw

PATCH 25/25 Replicator: update generated configure.in

In reply to Zdenek Kabelac
---
 configure |   33 ++++++++++++++++++++++++++++++++-
 1 files changed, 32 insertions(+), 1 deletions(-)
configure +32 -1
index 2d8d969..7fe7ad0 100755
@@ -658,6 +658,7 @@ PTHREAD_LIBS
 POOL
 PKGCONFIG
 OWNER
+REPLICATORS
 MIRRORS
 LVM_RELEASE_DATE
 LVM_RELEASE
@@ -817,6 +818,7 @@ with_pool
 with_cluster
 with_snapshots
 with_mirrors
+with_replicators
 enable_readline
 enable_realtime
 with_clvmd
@@ -1549,6 +1551,7 @@ Optional Packages:
                           TYPE=internal
   --with-mirrors=TYPE     Mirror support: internal/shared/none
                           TYPE=internal
+  --with-replicators=TYPE Replicator support: internal/shared/none TYPE=none
   --with-clvmd=TYPE       Build cluster LVM Daemon.
                           The following cluster manager combinations are valid:
                            * cman,gulm             (RHEL4 or equivalent)
@@ -9328,6 +9331,32 @@ _ACEOF
 fi
 
 ################################################################################
+{ $as_echo "$as_me:$LINENO: checking whether to include replicators" >&5
+$as_echo_n "checking whether to include replicators... " >&6; }
+
+# Check whether --with-replicators was given.
+if test "${with_replicators+set}" = set; then
+  withval=$with_replicators; REPLICATORS=$withval
+else
+  REPLICATORS="none"
+fi
+
+{ $as_echo "$as_me:$LINENO: result: $REPLICATORS" >&5
+$as_echo "$REPLICATORS" >&6; }
+
+case "$REPLICATORS" in
+  none|shared) ;;
+  internal)
+cat >>confdefs.h <<\_ACEOF
+#define REPLICATOR_INTERNAL 1
+_ACEOF
+ ;;
+  *) { { $as_echo "$as_me:$LINENO: error: --with-replicators parameter invalid ($REPLICATORS)" >&5
+$as_echo "$as_me: error: --with-replicators parameter invalid ($REPLICATORS)" >&2;}
+   { (exit 1); exit 1; }; } ;;
+esac
+
+################################################################################
 { $as_echo "$as_me:$LINENO: checking whether to enable readline" >&5
 $as_echo_n "checking whether to enable readline... " >&6; }
 # Check whether --enable-readline was given.
@@ -15564,8 +15593,9 @@ LVM_LIBAPI=`echo "$VER" | $AWK -F '[()]' '{print $2}'`
 
 
 
+
 ################################################################################
-ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile daemons/cmirrord/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile daemons/dmeventd/plugins/lvm2/Makefile daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile doc/Makefile include/.symlinks include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/misc/lvm-version.h lib/snapshot/Makefile libdm/Makefile libdm/libdevmapper.pc liblvm/Makefile liblvm/liblvm2app.pc man/Makefile po/Makefile scripts/clvmd_init_red_hat scripts/cmirrord_init_red_hat scripts/lvm2_monitoring_init_red_hat scripts/Makefile test/Makefile test/api/Makefile tools/Makefile udev/Makefile"
+ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile daemons/cmirrord/Makefile daemons/dmeventd/Makefile daemons/dmeventd/libdevmapper-event.pc daemons/dmeventd/plugins/Makefile daemons/dmeventd/plugins/lvm2/Makefile daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile doc/Makefile include/.symlinks include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/replicator/Makefile lib/misc/lvm-version.h lib/snapshot/Makefile libdm/Makefile libdm/libdevmapper.pc liblvm/Makefile liblvm/liblvm2app.pc man/Makefile po/Makefile scripts/clvmd_init_red_hat scripts/cmirrord_init_red_hat scripts/lvm2_monitoring_init_red_hat scripts/Makefile test/Makefile test/api/Makefile tools/Makefile udev/Makefile"
 
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -16183,6 +16213,7 @@ do
     "lib/format_pool/Makefile") CONFIG_FILES="$CONFIG_FILES lib/format_pool/Makefile" ;;
     "lib/locking/Makefile") CONFIG_FILES="$CONFIG_FILES lib/locking/Makefile" ;;
     "lib/mirror/Makefile") CONFIG_FILES="$CONFIG_FILES lib/mirror/Makefile" ;;
+    "lib/replicator/Makefile") CONFIG_FILES="$CONFIG_FILES lib/replicator/Makefile" ;;
     "lib/misc/lvm-version.h") CONFIG_FILES="$CONFIG_FILES lib/misc/lvm-version.h" ;;
     "lib/snapshot/Makefile") CONFIG_FILES="$CONFIG_FILES lib/snapshot/Makefile" ;;
     "libdm/Makefile") CONFIG_FILES="$CONFIG_FILES libdm/Makefile" ;;
Signature · 1 line
1.7.0.1
#15 lore raw

PATCH 13/25 Replicator: lock_vol update replicator LV

In reply to Zdenek Kabelac
Quoted 43 lines · Zdenek Kabelac

Add LCK_MISSING_VG flag to sinal missing VG to _lock_vol function. This way we easily detect whether we still need to lock more VGs while having all data available - it would be ackware to resolve it from resource uuid string. In the case missing VG is found, whole whole operation must be retried - this usually requires to release all locks, and take them again in the alphabetic order.

---
 lib/locking/locking.c |    3 +++
 lib/locking/locking.h |    7 ++++++-
 2 files changed, 9 insertions(+), 1 deletions(-)
lib/locking/locking.c +3 -0
index 76dbda5..57b7ba9 100644
@@ -362,6 +362,9 @@ static int _lock_vol(struct cmd_context *cmd, const char *resource,
 {
 	int ret = 0;
 
+	if (flags & LCK_MISSING_VG)
+		return_0;
+
 	_block_signals(flags);
 	_lock_memory(cmd, lv_op);
 
lib/locking/locking.h +1 -0
index e7f25b9..da442ec 100644
@@ -86,6 +86,7 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname);
 #define LCK_LOCAL	0x00000040U	/* Don't propagate to other nodes */
 #define LCK_CLUSTER_VG	0x00000080U	/* VG is clustered */
 #define LCK_CACHE	0x00000100U	/* Operation on cache only using P_ lock */
+#define LCK_MISSING_VG	0x00000200U	/* 'Remote' VG misses lock for this LV */
 
 /*
  * Additional lock bits for cluster communication
@@ -128,8 +129,12 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname);
 #define LCK_LV_CLUSTERED(lv)	\
 	(vg_is_clustered((lv)->vg) ? LCK_CLUSTER_VG : 0)
 

lib/locking/locking.h int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname); · line 140

Quoted 10 lines
lib/locking/locking.h +5 -1
+#define LCK_CHECK_MISSING_VG(lv)	\
+	(lv_replicator_sites_check_vg((lv)) ? 0 : LCK_MISSING_VG)
+
 #define lock_lv_vol(cmd, lv, flags)	\
-	lock_vol(cmd, (lv)->lvid.s, flags | LCK_LV_CLUSTERED(lv))
+	lock_vol(cmd, (lv)->lvid.s, flags | LCK_LV_CLUSTERED(lv) | \
+		 LCK_CHECK_MISSING_VG(lv))
 
 #define unlock_vg(cmd, vol)	lock_vol(cmd, vol, LCK_VG_UNLOCK)
 #define unlock_and_release_vg(cmd, vg, vol) \

Here is simpler version which doesn't change LCK flags - so no changes in clmvd....

Zdenek
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0018-Replicator-lock_vol-update-replicator-LV.patch
Type: text/x-patch
Size: 1041 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/lvm-devel/attachments/20100317/3a4accce/attachment.bin>

#2 lore raw

PATCH 1/25 Remove const from volume_group* in process_each

In reply to Zdenek Kabelac
Quoted 2 lines · Zdenek Kabelac

struct volume_group could change as a result of process_single() so vg is not const.

Ack.

Alasdair

#22 lore raw

PATCH 19/25 Replicator: no crash lvresize if area_count is 0

In reply to Zdenek Kabelac
Quoted 3 lines · Zdenek Kabelac

Currently with replicator-dev LV we get area_count=0 for lvresize request. The original reason needs to be exploread, meanwhile avoid crash, but stopping processing if count is 0.

I think we've discussed this one before?
Implies a logic error in the code: Internal Error please.

Alasdair