diff --git a/WHATS_NEW b/WHATS_NEW index b9550d8a3..b1104c287 100644 --- 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). diff --git a/configure b/configure index 9ff2ab89c..5383e6f77 100755 --- 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" ;; diff --git a/configure.in b/configure.in index a766f18fd..bdf5dde57 100644 --- a/configure.in +++ b/configure.in @@ -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 diff --git a/lib/Makefile.in b/lib/Makefile.in index 349814173..ae8104053 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -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 diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c index c780d2673..890da3ec5 100644 --- a/lib/commands/toolcontext.c +++ b/lib/commands/toolcontext.c @@ -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() && diff --git a/lib/format_text/flags.c b/lib/format_text/flags.c index a41dc1a7d..994adf2ec 100644 --- a/lib/format_text/flags.c +++ b/lib/format_text/flags.c @@ -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} }; diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c index de973417b..5e4a6741b 100644 --- a/lib/metadata/lv_manip.c +++ b/lib/metadata/lv_manip.c @@ -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; } diff --git a/lib/metadata/merge.c b/lib/metadata/merge.c index df9074371..66ff57b50 100644 --- a/lib/metadata/merge.c +++ b/lib/metadata/merge.c @@ -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) { diff --git a/lib/metadata/metadata-exported.h b/lib/metadata/metadata-exported.h index 9e1b564ae..3c9e1bb7d 100644 --- a/lib/metadata/metadata-exported.h +++ b/lib/metadata/metadata-exported.h @@ -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, diff --git a/lib/metadata/segtype.h b/lib/metadata/segtype.h index 7b31c1ddb..d35292819 100644 --- a/lib/metadata/segtype.h +++ b/lib/metadata/segtype.h @@ -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 diff --git a/lib/misc/configure.h.in b/lib/misc/configure.h.in index 125a4edeb..6b0d69aef 100644 --- a/lib/misc/configure.h.in +++ b/lib/misc/configure.h.in @@ -427,6 +427,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