]> sourceware.org Git - lvm2.git/commitdiff
Replicator: base lvm2 support
authorZdenek Kabelac <zkabelac@redhat.com>
Fri, 21 May 2010 12:36:30 +0000 (12:36 +0000)
committerZdenek Kabelac <zkabelac@redhat.com>
Fri, 21 May 2010 12:36:30 +0000 (12:36 +0000)
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.

WHATS_NEW
configure
configure.in
lib/Makefile.in
lib/commands/toolcontext.c
lib/format_text/flags.c
lib/metadata/lv_manip.c
lib/metadata/merge.c
lib/metadata/metadata-exported.h
lib/metadata/segtype.h
lib/misc/configure.h.in

index b9550d8a322d4632fead494f35106d8ff024927d..b1104c287a719e9a22a74ecb59c7cbc86a7d8508 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.67 -
 ===============================
+  Initial lvm2 support for Replicator metadata handling.
   Checking open_count in all parents of presuspend_node.
   Added dm_tree_node_set_presuspend_node() to presuspend child in deactivate.
   Initial libdm support for Replicator target (API is not stable yet).
index 9ff2ab89c9696d8fe257feaa9f58d47cb00ecf3e..5383e6f77a07c5ad0ff84d9910cbc47f2bad26b8 100755 (executable)
--- a/configure
+++ b/configure
@@ -660,6 +660,7 @@ READLINE_LIBS
 PTHREAD_LIBS
 POOL
 PKGCONFIG
+REPLICATORS
 MIRRORS
 LVM_RELEASE_DATE
 LVM_RELEASE
@@ -824,6 +825,7 @@ with_pool
 with_cluster
 with_snapshots
 with_mirrors
+with_replicators
 enable_readline
 enable_realtime
 with_clvmd
@@ -1563,6 +1565,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)
@@ -9344,6 +9347,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; }
@@ -15710,10 +15739,11 @@ 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 doc/example.conf 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 doc/example.conf 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
@@ -16332,6 +16362,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" ;;
index a766f18fd44233ca30c1d70cdb642c2db245bf73..bdf5dde576c030d379a97b0b64bf4fcc31a3869f 100644 (file)
@@ -302,6 +302,21 @@ if test x$MIRRORS = xinternal; then
        AC_DEFINE([MIRRORED_INTERNAL], 1, [Define to 1 to include built-in support for mirrors.])
 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)
@@ -1151,6 +1166,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(PKGCONFIG)
 AC_SUBST(POOL)
@@ -1206,6 +1222,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
index 34981417309ac32adafc022127b95735f4894161..ae81040536802cf442a31acb6e6cbc06edcefafe 100644 (file)
@@ -32,6 +32,10 @@ ifeq ("@MIRRORS@", "shared")
   SUBDIRS += mirror
 endif
 
+ifeq ("@REPLICATORS@", "shared")
+  SUBDIRS += replicator
+endif
+
 SOURCES =\
        activate/activate.c \
        cache/lvmcache.c \
@@ -74,6 +78,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 \
@@ -129,6 +134,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 \
@@ -155,6 +164,7 @@ ifeq ($(MAKECMDGOALS),distclean)
        format_pool \
        snapshot \
        mirror \
+       replicator \
        locking
 endif
 
index c780d2673758eac5ca8459cc1cec68ea6f93c149..890da3ec5e0f41a60de26010ed17b244d60085d6 100644 (file)
@@ -936,6 +936,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() &&
index a41dc1a7d939207eaaab1a311b1f5af03f979025..994adf2ec2655ad17a6afd9d39c0fb560e7f5104 100644 (file)
@@ -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}
 };
 
index de973417b78ba2c542ac0b544a633cf02e3c9fe4..5e4a6741bb6f101a059501a9bf8ea50ab8c69ad6 100644 (file)
@@ -2008,6 +2008,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;
 }
index df90743712b54e776e743555095ba302d56cba55..66ff57b5027b537a13bf7ccdf6cf0081264f051f 100644 (file)
@@ -72,6 +72,8 @@ int check_lv_segments(struct logical_volume *lv, int complete_vg)
        uint32_t area_multiplier, s;
        struct seg_list *sl;
        int error_count = 0;
+       struct replicator_site *rsite;
+       struct replicator_device *rdev;
 
        dm_list_iterate_items(seg, &lv->segments) {
                seg_count++;
@@ -213,6 +215,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) {
index 9e1b564aeefe13b3ddea900160b65774364e7744..3c9e1bb7d6cd6a1fac443922faca706d238cac75 100644 (file)
@@ -72,6 +72,9 @@
 
 #define MERGING                        0x10000000U     /* LV SEG */
 
+#define REPLICATOR             0x20000000U     /* LV -internal use only for replicator */
+#define REPLICATOR_LOG         0x40000000U     /* LV -internal use only for replicator-dev */
+
 #define LVM_READ               0x00000100U     /* LV VG */
 #define LVM_WRITE              0x00000200U     /* LV VG */
 #define CLUSTERED              0x00000400U     /* VG */
@@ -292,6 +295,45 @@ struct lv_segment_area {
 };
 
 struct segment_type;
+
+/* ++ Replicator datatypes */
+typedef enum {
+       REPLICATOR_STATE_PASSIVE,
+       REPLICATOR_STATE_ACTIVE,
+       NUM_REPLICATOR_STATE
+} replicator_state_t;
+
+struct replicator_site {
+       struct dm_list list;            /* Chained list of sites */
+       struct dm_list rdevices;        /* Device list */
+
+       struct logical_volume *replicator; /* Reference to replicator */
+
+       const char *name;               /* Site name */
+       const char *vg_name;            /* VG name */
+       struct volume_group *vg;        /* resolved vg  (activate/deactive) */
+       unsigned site_index;
+       replicator_state_t state;       /* Active or pasive state of site */
+       dm_replicator_mode_t op_mode;   /* Operation mode sync or async fail|warn|drop|stall */
+       uint64_t fall_behind_data;      /* Bytes */
+       uint32_t fall_behind_ios;       /* IO operations */
+       uint32_t fall_behind_timeout;   /* Seconds */
+};
+
+struct replicator_device {
+       struct dm_list list;            /* Chained list of devices from same site */
+
+       struct lv_segment *replicator_dev; /* Reference to replicator-dev segment */
+       struct replicator_site *rsite;  /* Reference to site parameters */
+
+       uint64_t device_index;
+       const char *name;               /* Device LV name */
+       struct logical_volume *lv;      /* LV from replicator site's VG */
+       struct logical_volume *slog;    /* Synclog lv from VG  */
+       const char *slog_name;          /* Debug - specify size of core synclog */
+};
+/* -- Replicator datatypes */
+
 struct lv_segment {
        struct dm_list list;
        struct logical_volume *lv;
@@ -310,7 +352,7 @@ struct lv_segment {
        struct logical_volume *origin;
        struct logical_volume *cow;
        struct dm_list origin_list;
-       uint32_t region_size;   /* For mirrors - in sectors */
+       uint32_t region_size;   /* For mirrors, replicators - in sectors */
        uint32_t extents_copied;
        struct logical_volume *log_lv;
        struct lv_segment *pvmove_source_seg;
@@ -319,6 +361,12 @@ struct lv_segment {
        struct dm_list tags;
 
        struct lv_segment_area *areas;
+
+       struct logical_volume *replicator;/* For replicator-devs - link to replicator LV */
+       struct logical_volume *rlog_lv; /* For replicators */
+       const char *rlog_type;          /* For replicators */
+       uint64_t rdevice_index_highest; /* For replicators */
+       unsigned rsite_index_highest;   /* For replicators */
 };
 
 #define seg_type(seg, s)       (seg)->areas[(s)].type
@@ -344,6 +392,9 @@ struct logical_volume {
        struct dm_list snapshot_segs;
        struct lv_segment *snapshot;
 
+       struct replicator_device *rdevice;/* For replicator-devs, rimages, slogs - reference to rdevice */
+       struct dm_list rsites;  /* For replicators - all sites */
+
        struct dm_list segments;
        struct dm_list tags;
        struct dm_list segs_using_this_lv;
@@ -725,6 +776,27 @@ int reconfigure_mirror_images(struct lv_segment *mirrored_seg, uint32_t num_mirr
 int collapse_mirrored_lv(struct logical_volume *lv);
 int shift_mirror_images(struct lv_segment *mirrored_seg, unsigned mimage);
 
+/* ++  metadata/replicator_manip.c */
+int replicator_add_replicator_dev(struct logical_volume *replicator_lv,
+                                 struct lv_segment *rdev_seg);
+struct logical_volume *replicator_remove_replicator_dev(struct lv_segment *rdev_seg);
+int replicator_add_rlog(struct lv_segment *replicator_seg, struct logical_volume *rlog_lv);
+struct logical_volume *replicator_remove_rlog(struct lv_segment *replicator_seg);
+
+int replicator_dev_add_slog(struct replicator_device *rdev, struct logical_volume *slog_lv);
+struct logical_volume *replicator_dev_remove_slog(struct replicator_device *rdev);
+int replicator_dev_add_rimage(struct replicator_device *rdev, struct logical_volume *lv);
+struct logical_volume *replicator_dev_remove_rimage(struct replicator_device *rdev);
+
+int lv_is_active_replicator_dev(const struct logical_volume *lv);
+int lv_is_replicator(const struct logical_volume *lv);
+int lv_is_replicator_dev(const struct logical_volume *lv);
+int lv_is_rimage(const struct logical_volume *lv);
+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 */
+
 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,
index 7b31c1ddbec7c927255b462c9ffa06417fc3ec90..d35292819132e013fc4698e1096761d4bd395aca 100644 (file)
@@ -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
index 125a4edebb8d217e0754bb8a19cf0d8abbf8e61c..6b0d69aefd094e3e18f6efad887593e89ff4a64a 100644 (file)
 /* 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
 
This page took 0.067145 seconds and 5 git commands to generate.