From prajnoha@sourceware.org Mon May 3 21:06:00 2010 From: prajnoha@sourceware.org (prajnoha@sourceware.org) Date: Mon, 03 May 2010 21:06:00 -0000 Subject: LVM2/libdm libdm-common.c ioctl/libdm-iface.c Message-ID: <20100503210653.28324.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2010-05-03 21:06:53 Modified files: libdm : libdm-common.c libdm/ioctl : libdm-iface.c Log message: Synchronize "remove" dm task while reverting unsuccessful "create" dm task (with table provided). This remove ioctl generates udev events like any other hence it needs to be synchronized properly as well. Also, add dm task type in debug log when setting a cookie (for better debugging). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.94&r2=1.95 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.71&r2=1.72 --- LVM2/libdm/libdm-common.c 2010/03/23 14:43:18 1.94 +++ LVM2/libdm/libdm-common.c 2010/05/03 21:06:53 1.95 @@ -1192,7 +1192,7 @@ dmt->cookie_set = 1; log_debug("Udev cookie 0x%" PRIx32 " (semid %d) assigned to dm_task " - "with flags 0x%" PRIx16, *cookie, semid, flags); + "type %d with flags 0x%" PRIx16, *cookie, semid, dmt->type, flags); return 1; --- LVM2/libdm/ioctl/libdm-iface.c 2010/04/28 13:37:37 1.71 +++ LVM2/libdm/ioctl/libdm-iface.c 2010/05/03 21:06:53 1.72 @@ -1546,6 +1546,7 @@ { struct dm_task *task; int r; + uint32_t cookie; /* Use new task struct to create the device */ if (!(task = dm_task_create(DM_DEVICE_CREATE))) { @@ -1625,7 +1626,18 @@ dmt->type = DM_DEVICE_REMOVE; dm_free(dmt->uuid); dmt->uuid = NULL; - dmt->cookie_set = 0; + + /* + * Also udev-synchronize "remove" dm task that is a part of this revert! + * But only if the original dm task was supposed to be synchronized. + */ + if (dmt->cookie_set) { + cookie = (dmt->event_nr & ~DM_UDEV_FLAGS_MASK) | + (DM_COOKIE_MAGIC << DM_UDEV_FLAGS_SHIFT); + dm_task_set_cookie(dmt, &cookie, + (dmt->event_nr & DM_UDEV_FLAGS_MASK) >> + DM_UDEV_FLAGS_SHIFT); + } if (!dm_task_run(dmt)) log_error("Failed to revert device creation."); From prajnoha@sourceware.org Mon May 3 22:08:00 2010 From: prajnoha@sourceware.org (prajnoha@sourceware.org) Date: Mon, 03 May 2010 22:08:00 -0000 Subject: LVM2/libdm/ioctl libdm-iface.c Message-ID: <20100503220839.5670.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2010-05-03 22:08:39 Modified files: libdm/ioctl : libdm-iface.c Log message: Specify exactly which ioctl doesn't have a cookie set (for better debugging). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.72&r2=1.73 --- LVM2/libdm/ioctl/libdm-iface.c 2010/05/03 21:06:53 1.72 +++ LVM2/libdm/ioctl/libdm-iface.c 2010/05/03 22:08:38 1.73 @@ -1770,11 +1770,13 @@ * libdevmapper's node and symlink creation code. */ if (!dmt->cookie_set && dm_udev_get_sync_support()) { - log_debug("Cookie value is not set while trying to call " - "DM_DEVICE_RESUME, DM_DEVICE_REMOVE or DM_DEVICE_RENAME " + log_debug("Cookie value is not set while trying to call %s " "ioctl. Please, consider using libdevmapper's udev " "synchronisation interface or disable it explicitly " - "by calling dm_udev_set_sync_support(0)."); + "by calling dm_udev_set_sync_support(0).", + dmt->type == DM_DEVICE_RESUME ? "DM_DEVICE_RESUME" : + dmt->type == DM_DEVICE_REMOVE ? "DM_DEVICE_REMOVE" : + "DM_DEVICE_RENAME"); log_debug("Switching off device-mapper and all subsystem related " "udev rules. Falling back to libdevmapper node creation."); /* From mornfall@sourceware.org Wed May 5 22:38:00 2010 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Wed, 05 May 2010 22:38:00 -0000 Subject: LVM2 WHATS_NEW Message-ID: <20100505223833.23504.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2010-05-05 22:38:31 Modified files: . : WHATS_NEW Log message: What's new. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1546&r2=1.1547 --- LVM2/WHATS_NEW 2010/04/30 15:48:39 1.1546 +++ LVM2/WHATS_NEW 2010/05/05 22:38:31 1.1547 @@ -1,5 +1,6 @@ Version 2.02.65 - ================================= + Suppress duplicate error messages about read failures and missing devices. Version 2.02.64 - 30th April 2010 ================================= From mornfall@sourceware.org Wed May 5 22:38:00 2010 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Wed, 05 May 2010 22:38:00 -0000 Subject: LVM2 lib/commands/toolcontext.c lib/device/dev ... Message-ID: <20100505223759.23255.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2010-05-05 22:37:53 Modified files: lib/commands : toolcontext.c lib/device : dev-io.c lib/format_text: import_vsn1.c lib/log : log.c log.h lvm-logging.h tools : lvmcmdline.c Log message: Suppress duplicate error messages about read failures and missing devices. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.95&r2=1.96 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-io.c.diff?cvsroot=lvm2&r1=1.67&r2=1.68 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import_vsn1.c.diff?cvsroot=lvm2&r1=1.74&r2=1.75 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.c.diff?cvsroot=lvm2&r1=1.58&r2=1.59 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.h.diff?cvsroot=lvm2&r1=1.48&r2=1.49 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/lvm-logging.h.diff?cvsroot=lvm2&r1=1.8&r2=1.9 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.120&r2=1.121 --- LVM2/lib/commands/toolcontext.c 2010/04/30 12:37:05 1.95 +++ LVM2/lib/commands/toolcontext.c 2010/05/05 22:37:52 1.96 @@ -194,6 +194,7 @@ #ifdef DEVMAPPER_SUPPORT dm_log_with_errno_init(print_log); #endif + reset_log_duplicated(); } static int _process_config(struct cmd_context *cmd) @@ -1361,6 +1362,7 @@ release_log_memory(); activation_exit(); + reset_log_duplicated(); fin_log(); fin_syslog(); reset_lvm_errno(0); --- LVM2/lib/device/dev-io.c 2010/04/01 14:30:51 1.67 +++ LVM2/lib/device/dev-io.c 2010/05/05 22:37:53 1.68 @@ -95,12 +95,12 @@ while ((n < 0) && ((errno == EINTR) || (errno == EAGAIN))); if (n < 0) - log_error("%s: %s failed after %" PRIu64 " of %" PRIu64 - " at %" PRIu64 ": %s", dev_name(where->dev), - should_write ? "write" : "read", - (uint64_t) total, - (uint64_t) where->size, - (uint64_t) where->start, strerror(errno)); + log_error_once("%s: %s failed after %" PRIu64 " of %" PRIu64 + " at %" PRIu64 ": %s", dev_name(where->dev), + should_write ? "write" : "read", + (uint64_t) total, + (uint64_t) where->size, + (uint64_t) where->start, strerror(errno)); if (n <= 0) break; --- LVM2/lib/format_text/import_vsn1.c 2010/04/08 00:28:58 1.74 +++ LVM2/lib/format_text/import_vsn1.c 2010/05/05 22:37:53 1.75 @@ -198,7 +198,7 @@ if (!id_write_format(&pv->id, buffer, sizeof(buffer))) buffer[0] = '\0'; if (report_missing_devices) - log_error("Couldn't find device with uuid %s.", buffer); + log_error_once("Couldn't find device with uuid %s.", buffer); else log_very_verbose("Couldn't find device with uuid %s.", buffer); } --- LVM2/lib/log/log.c 2010/03/23 18:18:49 1.58 +++ LVM2/lib/log/log.c 2010/05/05 22:37:53 1.59 @@ -169,6 +169,14 @@ return _lvm_errmsg ? : ""; } +static struct dm_hash_table *_duplicated = NULL; + +void reset_log_duplicated(void) { + if (_duplicated) + dm_hash_destroy(_duplicated); + _duplicated = NULL; +} + void print_log(int level, const char *file, int line, int dm_errno, const char *format, ...) { @@ -179,9 +187,10 @@ const char *trformat; /* Translated format string */ char *newbuf; int use_stderr = level & _LOG_STDERR; + int log_once = level & _LOG_ONCE; int fatal_internal_error = 0; - level &= ~_LOG_STDERR; + level &= ~(_LOG_STDERR|_LOG_ONCE); if (_abort_on_internal_errors && !strncmp(format, INTERNAL_ERROR, @@ -203,7 +212,9 @@ if (dm_errno && !_lvm_errno) _lvm_errno = dm_errno; - if (_lvm2_log_fn || (_store_errmsg && (level <= _LOG_ERR))) { + if (_lvm2_log_fn || + (_store_errmsg && (level <= _LOG_ERR)) || + log_once) { va_start(ap, format); n = vsnprintf(buf2, sizeof(buf2) - 1, trformat, ap); va_end(ap); @@ -229,6 +240,16 @@ } } + if (log_once) { + if (!_duplicated) + _duplicated = dm_hash_create(128); + if (_duplicated) { + if (dm_hash_lookup(_duplicated, message)) + level = _LOG_NOTICE; + dm_hash_insert(_duplicated, message, (void*)1); + } + } + if (_lvm2_log_fn) { _lvm2_log_fn(level, file, line, 0, message); if (fatal_internal_error) --- LVM2/lib/log/log.h 2010/02/15 16:46:56 1.48 +++ LVM2/lib/log/log.h 2010/05/05 22:37:53 1.49 @@ -47,6 +47,7 @@ #define _LOG_STDERR 128 /* force things to go to stderr, even if loglevel would make them go to stdout */ +#define _LOG_ONCE 256 /* downgrade to NOTICE if this has been already logged */ #define _LOG_DEBUG 7 #define _LOG_INFO 6 #define _LOG_NOTICE 5 @@ -62,6 +63,7 @@ #define log_warn_suppress(s, x...) LOG_LINE(s ? _LOG_NOTICE : _LOG_WARN | _LOG_STDERR, x) #define log_err(x...) LOG_LINE_WITH_ERRNO(_LOG_ERR, EUNCLASSIFIED, x) #define log_err_suppress(s, x...) LOG_LINE_WITH_ERRNO(s ? _LOG_NOTICE : _LOG_ERR, EUNCLASSIFIED, x) +#define log_err_once(x...) LOG_LINE_WITH_ERRNO(_LOG_ERR | _LOG_ONCE, EUNCLASSIFIED, x) #define log_fatal(x...) LOG_LINE_WITH_ERRNO(_LOG_FATAL, EUNCLASSIFIED, x) #define stack log_debug("") /* Backtrace on error */ @@ -70,6 +72,7 @@ #define log_print(args...) LOG_LINE(_LOG_WARN, args) #define log_error(args...) log_err(args) #define log_error_suppress(s, args...) log_err_suppress(s, args) +#define log_error_once(args...) log_err_once(args) #define log_errno(args...) LOG_LINE_WITH_ERRNO(_LOG_ERR, args) /* System call equivalents */ --- LVM2/lib/log/lvm-logging.h 2009/11/30 17:17:12 1.8 +++ LVM2/lib/log/lvm-logging.h 2010/05/05 22:37:53 1.9 @@ -43,6 +43,7 @@ void fin_log(void); void release_log_memory(void); +void reset_log_duplicated(void); void init_syslog(int facility); void fin_syslog(void); --- LVM2/tools/lvmcmdline.c 2010/04/30 13:47:11 1.120 +++ LVM2/tools/lvmcmdline.c 2010/05/05 22:37:53 1.121 @@ -1087,6 +1087,7 @@ dm_pool_empty(cmd->mem); reset_lvm_errno(1); + reset_log_duplicated(); return ret; } From zkabelac@sourceware.org Thu May 6 10:07:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Thu, 06 May 2010 10:07:00 -0000 Subject: LVM2 ./make.tmpl.in daemons/dmeventd/plugins/m ... Message-ID: <20100506100748.19199.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-06 10:07:47 Modified files: . : make.tmpl.in daemons/dmeventd/plugins/mirror: Makefile.in daemons/dmeventd/plugins/snapshot: Makefile.in lib/format1 : Makefile.in lib/format_pool: Makefile.in lib/locking : Makefile.in lib/mirror : Makefile.in lib/snapshot : Makefile.in Log message: Install plugins to subdirs Target install_dm_plugin installs files to libdir/device-mapper. Target install_lvm2_plugin installs files to libdir/lvm2. Both targets creates relative links to libdir to keep the code compatible with current dlopen handling. Once we will be able to read plugins from subdir, links could be removed. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/make.tmpl.in.diff?cvsroot=lvm2&r1=1.93&r2=1.94 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/plugins/mirror/Makefile.in.diff?cvsroot=lvm2&r1=1.19&r2=1.20 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/plugins/snapshot/Makefile.in.diff?cvsroot=lvm2&r1=1.14&r2=1.15 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/Makefile.in.diff?cvsroot=lvm2&r1=1.14&r2=1.15 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/Makefile.in.diff?cvsroot=lvm2&r1=1.10&r2=1.11 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/Makefile.in.diff?cvsroot=lvm2&r1=1.8&r2=1.9 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/Makefile.in.diff?cvsroot=lvm2&r1=1.9&r2=1.10 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/snapshot/Makefile.in.diff?cvsroot=lvm2&r1=1.9&r2=1.10 --- LVM2/make.tmpl.in 2010/04/30 13:58:10 1.93 +++ LVM2/make.tmpl.in 2010/05/06 10:07:46 1.94 @@ -163,7 +163,7 @@ .PHONY: all pofile distclean clean cleandir cflow device-mapper .PHONY: install install_cluster install_device-mapper install_lvm2 -.PHONY: install_lib_shared install_lib_shared_plugin +.PHONY: install_lib_shared install_dm_plugin install_lvm2_plugin .PHONY: $(SUBDIRS) $(SUBDIRS.install) $(SUBDIRS.clean) $(SUBDIRS.distclean) .PHONY: $(SUBDIRS.pofile) $(SUBDIRS.install_cluster) $(SUBDIRS.cflow) .PHONY: $(SUBDIRS.device-mapper) $(SUBDIRS.install-device-mapper) @@ -306,9 +306,18 @@ $(INSTALL) -d $(usrlibdir) $(LN_S) -f $(USRLIB_RELPATH)$( CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-06 10:10:16 Modified files: . : WHATS_NEW libdm : .exported_symbols libdevmapper.h libdm/datastruct: list.c Log message: Add dm_list_splice() to join two lists. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1547&r2=1.1548 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/.exported_symbols.diff?cvsroot=lvm2&r1=1.51&r2=1.52 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.112&r2=1.113 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/datastruct/list.c.diff?cvsroot=lvm2&r1=1.6&r2=1.7 --- LVM2/WHATS_NEW 2010/05/05 22:38:31 1.1547 +++ LVM2/WHATS_NEW 2010/05/06 10:10:15 1.1548 @@ -1,6 +1,8 @@ Version 2.02.65 - ================================= Suppress duplicate error messages about read failures and missing devices. + Install plugins to $(libdir)/device-mapper and $(libdir)/lvm2. + Add dm_list_splice() function to join two lists together. Version 2.02.64 - 30th April 2010 ================================= --- LVM2/libdm/.exported_symbols 2010/04/20 13:58:22 1.51 +++ LVM2/libdm/.exported_symbols 2010/05/06 10:10:16 1.52 @@ -155,6 +155,7 @@ dm_list_add_h dm_list_del dm_list_move +dm_list_splice dm_list_empty dm_list_start dm_list_end --- LVM2/libdm/libdevmapper.h 2010/04/28 13:37:36 1.112 +++ LVM2/libdm/libdevmapper.h 2010/05/06 10:10:16 1.113 @@ -718,6 +718,11 @@ void dm_list_move(struct dm_list *head, struct dm_list *elem); /* + * Join 'head1' to the of 'head'. + */ +void dm_list_splice(struct dm_list *head, struct dm_list *head1); + +/* * Is the list empty? */ int dm_list_empty(const struct dm_list *head); --- LVM2/libdm/datastruct/list.c 2008/11/04 15:07:45 1.6 +++ LVM2/libdm/datastruct/list.c 2010/05/06 10:10:16 1.7 @@ -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. * @@ -144,3 +144,25 @@ return s; } + +/* + * Join two lists together. + * This moves all the elements of the list 'head1' to the end of the list + * 'head', leaving 'head1' empty. + */ +void dm_list_splice(struct dm_list *head, struct dm_list *head1) +{ + assert(head->n); + assert(head1->n); + + if (dm_list_empty(head1)) + return; + + head1->p->n = head; + head1->n->p = head->p; + + head->p->n = head1->n; + head->p = head1->p; + + dm_list_init(head1); +} From prajnoha@sourceware.org Thu May 6 11:15:00 2010 From: prajnoha@sourceware.org (prajnoha@sourceware.org) Date: Thu, 06 May 2010 11:15:00 -0000 Subject: LVM2 ./WHATS_NEW lib/locking/locking.c lib/loc ... Message-ID: <20100506111558.1469.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2010-05-06 11:15:56 Modified files: . : WHATS_NEW lib/locking : locking.c locking.h liblvm : lvm_base.c man : lvchange.8.in vgchange.8.in tools : args.h commands.h lvchange.c lvmcmdline.c toollib.c vgchange.c Log message: Add new --sysinit option for vgchange and lvchange. A shortcut for --ignorelockingfailure, --ignoremonitoring, --poll n options and LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES environment variable used all at once in initialisation scripts (e.g. rc.sysinit or initrd). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1548&r2=1.1549 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.79&r2=1.80 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.53&r2=1.54 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_base.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvchange.8.in.diff?cvsroot=lvm2&r1=1.7&r2=1.8 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/vgchange.8.in.diff?cvsroot=lvm2&r1=1.8&r2=1.9 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/args.h.diff?cvsroot=lvm2&r1=1.73&r2=1.74 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/commands.h.diff?cvsroot=lvm2&r1=1.145&r2=1.146 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvchange.c.diff?cvsroot=lvm2&r1=1.119&r2=1.120 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.121&r2=1.122 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.196&r2=1.197 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.101&r2=1.102 --- LVM2/WHATS_NEW 2010/05/06 10:10:15 1.1548 +++ LVM2/WHATS_NEW 2010/05/06 11:15:55 1.1549 @@ -1,5 +1,6 @@ Version 2.02.65 - ================================= + Add new --sysinit option for vgchange and lvchange. Suppress duplicate error messages about read failures and missing devices. Install plugins to $(libdir)/device-mapper and $(libdir)/lvm2. Add dm_list_splice() function to join two lists together. --- LVM2/lib/locking/locking.c 2010/04/13 01:54:33 1.79 +++ LVM2/lib/locking/locking.c 2010/05/06 11:15:55 1.80 @@ -217,10 +217,8 @@ * Select a locking type * type: locking type; if < 0, then read config tree value */ -int init_locking(int type, struct cmd_context *cmd) +int init_locking(int type, struct cmd_context *cmd, int suppress_messages) { - int suppress_messages = 0; - if (ignorelockingfailure() && getenv("LVM_SUPPRESS_LOCKING_FAILURE_MESSAGES")) suppress_messages = 1; --- LVM2/lib/locking/locking.h 2010/01/05 16:09:34 1.53 +++ LVM2/lib/locking/locking.h 2010/05/06 11:15:55 1.54 @@ -19,7 +19,7 @@ #include "uuid.h" #include "config.h" -int init_locking(int type, struct cmd_context *cmd); +int init_locking(int type, struct cmd_context *cmd, int suppress_messages); void fin_locking(void); void reset_locking(void); int vg_write_lock_held(void); --- LVM2/liblvm/lvm_base.c 2010/03/17 14:45:28 1.15 +++ LVM2/liblvm/lvm_base.c 2010/05/06 11:15:55 1.16 @@ -50,7 +50,7 @@ /* FIXME: locking_type config option needed? */ /* initialize locking */ - if (!init_locking(-1, cmd)) { + if (!init_locking(-1, cmd, 0)) { /* FIXME: use EAGAIN as error code here */ lvm_quit((lvm_t) cmd); return NULL; --- LVM2/man/lvchange.8.in 2010/03/23 22:30:20 1.7 +++ LVM2/man/lvchange.8.in 2010/05/06 11:15:55 1.8 @@ -13,6 +13,7 @@ [\-\-ignoremonitoring] [\-\-monitor {y|n}] [\-\-poll {y|n}] +[\-\-sysinit] [\-\-noudevsync] [\-M|\-\-persistent y|n] [\-\-minor minor] [\-P|\-\-partial] @@ -71,6 +72,15 @@ immediately poll a logical volume when it is activated, use \fB--poll n\fP to defer and then \fB--poll y\fP to restart the process. .TP +.I \-\-sysinit +Indicates that lvchange(8) is being invoked from early system initialisation +scripts (e.g. rc.sysinit or an initrd), before writeable filesystems are +available. As such, some functionality needs to be disabled and this option +acts as a shortcut which selects an appropriate set of options. Currently +this is equivalent to using \fB--ignorelockingfailure\fP, \fB--ignoremonitoring\fP, +\fB--poll n\fP and setting \fBLVM_SUPPRESS_LOCKING_FAILURE_MESSAGES\fP +environment variable. +.TP .I \-\-noudevsync Disable udev synchronisation. The process will not wait for notification from udev. --- LVM2/man/vgchange.8.in 2010/03/23 22:30:20 1.8 +++ LVM2/man/vgchange.8.in 2010/05/06 11:15:55 1.9 @@ -19,6 +19,7 @@ .RB [ \-h | \-\-help] .RB [ \-\-ignorelockingfailure] .RB [ \-\-ignoremonitoring] +.RB [ \-\-sysinit] .RB [ \-\-noudevsync ] .RB [ \-l | \-\-logicalvolume .IR MaxLogicalVolumes ] @@ -96,6 +97,15 @@ immediately poll a logical volume when it is activated, use \fB--poll n\fP to defer and then \fB--poll y\fP to restart the process. .TP +.BR \-\-sysinit +Indicates that vgchange(8) is being invoked from early system initialisation +scripts (e.g. rc.sysinit or an initrd), before writeable filesystems are +available. As such, some functionality needs to be disabled and this option +acts as a shortcut which selects an appropriate set of options. Currently +this is equivalent to using \fB--ignorelockingfailure\fP, \fB--ignoremonitoring\fP, +\fB--poll n\fP and setting \fBLVM_SUPPRESS_LOCKING_FAILURE_MESSAGES\fP +environment variable. +.TP .BR \-\-noudevsync Disable udev synchronisation. The process will not wait for notification from udev. --- LVM2/tools/args.h 2010/04/13 01:54:33 1.73 +++ LVM2/tools/args.h 2010/05/06 11:15:55 1.74 @@ -66,6 +66,7 @@ arg(noudevsync_ARG, '\0', "noudevsync", NULL, 0) arg(poll_ARG, '\0', "poll", yes_no_arg, 0) arg(stripes_long_ARG, '\0', "stripes", int_arg, 0) +arg(sysinit_ARG, '\0', "sysinit", NULL, 0) /* Allow some variations */ arg(resizable_ARG, '\0', "resizable", yes_no_arg, 0) --- LVM2/tools/commands.h 2010/04/20 18:17:56 1.145 +++ LVM2/tools/commands.h 2010/05/06 11:15:55 1.146 @@ -80,6 +80,7 @@ "\t[-r|--readahead ReadAheadSectors|auto|none]\n" "\t[--refresh]\n" "\t[--resync]\n" + "\t[--sysinit]\n" "\t[-t|--test]\n" "\t[-v|--verbose]\n" "\t[-y|--yes]\n" @@ -90,7 +91,7 @@ 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) + sysinit_ARG, test_ARG, yes_ARG) xx(lvconvert, "Change logical volume layout", @@ -711,6 +712,7 @@ "\t[--poll {y|n}]\n" "\t[--noudevsync]\n" "\t[--refresh]\n" + "\t[--sysinit]\n" "\t[-t|--test]" "\n" "\t[-u|--uuid] " "\n" "\t[-v|--verbose] " "\n" @@ -729,7 +731,7 @@ clustered_ARG, deltag_ARG, ignorelockingfailure_ARG, ignoremonitoring_ARG, logicalvolume_ARG, maxphysicalvolumes_ARG, monitor_ARG, noudevsync_ARG, partial_ARG, physicalextentsize_ARG, poll_ARG, refresh_ARG, resizeable_ARG, - resizable_ARG, test_ARG, uuid_ARG) + resizable_ARG, sysinit_ARG, test_ARG, uuid_ARG) xx(vgck, "Check the consistency of volume group(s)", --- LVM2/tools/lvchange.c 2010/03/29 16:09:41 1.119 +++ LVM2/tools/lvchange.c 2010/05/06 11:15:56 1.120 @@ -586,9 +586,12 @@ * should only be started if the LV is not already active. So: * 1) change the activation code to say if the LV was actually activated * 2) make polling of an LV tightly coupled with LV activation + * + * Do not initiate any polling if --sysinit option is used. */ - init_background_polling(arg_int_value(cmd, poll_ARG, - DEFAULT_BACKGROUND_POLLING)); + init_background_polling(arg_count(cmd, sysinit_ARG) ? 0 : + arg_int_value(cmd, poll_ARG, + DEFAULT_BACKGROUND_POLLING)); /* access permission change */ if (arg_count(cmd, permission_ARG)) { @@ -730,8 +733,9 @@ arg_count(cmd, addtag_ARG) || arg_count(cmd, deltag_ARG) || arg_count(cmd, resync_ARG) || arg_count(cmd, alloc_ARG)); - if (arg_count(cmd, ignorelockingfailure_ARG) && !avail_only) { - log_error("Only -a permitted with --ignorelockingfailure"); + if ((arg_count(cmd, ignorelockingfailure_ARG) || + arg_count(cmd, sysinit_ARG)) && !avail_only) { + log_error("Only -a permitted with --ignorelockingfailure and --sysinit"); return EINVALID_CMD_LINE; } @@ -759,6 +763,11 @@ return EINVALID_CMD_LINE; } + if (arg_count(cmd, poll_ARG) && arg_count(cmd, sysinit_ARG)) { + log_error("Only one of --poll and --sysinit permitted"); + return EINVALID_CMD_LINE; + } + return process_each_lv(cmd, argc, argv, avail_only ? 0 : READ_FOR_UPDATE, NULL, &lvchange_single); --- LVM2/tools/lvmcmdline.c 2010/05/05 22:37:53 1.121 +++ LVM2/tools/lvmcmdline.c 2010/05/06 11:15:56 1.122 @@ -793,7 +793,7 @@ "be activated read-only."); } - if (arg_count(cmd, ignorelockingfailure_ARG)) + if (arg_count(cmd, ignorelockingfailure_ARG) || arg_count(cmd, sysinit_ARG)) init_ignorelockingfailure(1); else init_ignorelockingfailure(0); @@ -1049,7 +1049,7 @@ else locking_type = -1; - if (!init_locking(locking_type, cmd)) { + if (!init_locking(locking_type, cmd, arg_count(cmd, sysinit_ARG))) { ret = ECMD_FAILED; goto out; } --- LVM2/tools/toollib.c 2010/04/28 12:23:11 1.196 +++ LVM2/tools/toollib.c 2010/05/06 11:15:56 1.197 @@ -1372,8 +1372,9 @@ *monitoring_mode = DEFAULT_DMEVENTD_MONITOR; if (arg_count(cmd, monitor_ARG) && - arg_count(cmd, ignoremonitoring_ARG)) { - log_error("Conflicting monitor and ignoremonitoring options"); + (arg_count(cmd, ignoremonitoring_ARG) || + arg_count(cmd, sysinit_ARG))) { + log_error("--ignoremonitoring or --sysinit option not allowed with --monitor option"); return 0; } @@ -1381,6 +1382,7 @@ *monitoring_mode = arg_int_value(cmd, monitor_ARG, DEFAULT_DMEVENTD_MONITOR); else if (is_static() || arg_count(cmd, ignoremonitoring_ARG) || + arg_count(cmd, sysinit_ARG) || !find_config_tree_bool(cmd, "activation/monitoring", DEFAULT_DMEVENTD_MONITOR)) *monitoring_mode = DMEVENTD_MONITOR_IGNORE; --- LVM2/tools/vgchange.c 2010/03/29 16:09:41 1.101 +++ LVM2/tools/vgchange.c 2010/05/06 11:15:56 1.102 @@ -540,9 +540,12 @@ * should only be started if the LV is not already active. So: * 1) change the activation code to say if the LV was actually activated * 2) make polling of an LV tightly coupled with LV activation + * + * Do not initiate any polling if --sysinit option is used. */ - init_background_polling(arg_int_value(cmd, poll_ARG, - DEFAULT_BACKGROUND_POLLING)); + init_background_polling(arg_count(cmd, sysinit_ARG) ? 0 : + arg_int_value(cmd, poll_ARG, + DEFAULT_BACKGROUND_POLLING)); if (arg_count(cmd, available_ARG)) r = _vgchange_available(cmd, vg); @@ -615,9 +618,14 @@ return EINVALID_CMD_LINE; } - if (arg_count(cmd, ignorelockingfailure_ARG) && - !arg_count(cmd, available_ARG)) { - log_error("--ignorelockingfailure only available with -a"); + if ((arg_count(cmd, ignorelockingfailure_ARG) || + arg_count(cmd, sysinit_ARG)) && !arg_count(cmd, available_ARG)) { + log_error("Only -a premitted with --ignorelockingfailure and --sysinit"); + return EINVALID_CMD_LINE; + } + + if (arg_count(cmd, poll_ARG) && arg_count(cmd, sysinit_ARG)) { + log_error("Only one of --poll and --sysinit permitted."); return EINVALID_CMD_LINE; } From mornfall@sourceware.org Thu May 6 18:54:00 2010 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Thu, 06 May 2010 18:54:00 -0000 Subject: LVM2/test Makefile.in test-utils.sh Message-ID: <20100506185453.2064.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2010-05-06 18:54:52 Modified files: test : Makefile.in test-utils.sh Log message: Add some basic provisions for automated testing of dmeventd. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/Makefile.in.diff?cvsroot=lvm2&r1=1.39&r2=1.40 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/test-utils.sh.diff?cvsroot=lvm2&r1=1.38&r2=1.39 --- LVM2/test/Makefile.in 2010/04/30 14:33:39 1.39 +++ LVM2/test/Makefile.in 2010/05/06 18:54:51 1.40 @@ -78,7 +78,11 @@ echo 'abs_top_srcdir=$(abs_top_builddir)' >> $@-t echo 'PATH=$$abs_top_builddir/test/bin:$$PATH' >> $@-t LDLPATH="\$$abs_top_builddir/libdm"; \ + LDLPATH="$$LDLPATH:\$$abs_top_builddir/tools"; \ LDLPATH="$$LDLPATH:\$$abs_top_builddir/daemons/dmeventd"; \ + LDLPATH="$$LDLPATH:\$$abs_top_builddir/daemons/dmeventd/plugins/lvm2"; \ + LDLPATH="$$LDLPATH:\$$abs_top_builddir/daemons/dmeventd/plugins/mirror"; \ + LDLPATH="$$LDLPATH:\$$abs_top_builddir/daemons/dmeventd/plugins/snapshot"; \ echo "export LD_LIBRARY_PATH=\"$$LDLPATH\"" >> $@-t echo 'abs_srcdir=$(abs_srcdir)' >> $@-t echo 'abs_builddir=$(abs_builddir)' >> $@-t @@ -99,6 +103,7 @@ done ln -s "$(abs_top_builddir)/tools/dmsetup" bin/dmsetup ln -s "$(abs_top_builddir)/daemons/clvmd/clvmd" bin/clvmd + ln -s "$(abs_top_builddir)/daemons/dmeventd/dmeventd" bin/dmeventd touch $@ lvm-wrapper: Makefile --- LVM2/test/test-utils.sh 2010/04/20 18:18:59 1.38 +++ LVM2/test/test-utils.sh 2010/05/06 18:54:52 1.39 @@ -72,6 +72,22 @@ LOCAL_CLVMD="$!" } +prepare_dmeventd() { + if pgrep dmeventd ; then + echo "Cannot test dmeventd with real dmeventd ($(pgrep clvmd)) running." + exit 200 + fi + + # skip if we don't have our own dmeventd... + (which dmeventd | grep $abs_builddir) || exit 200 + + trap_teardown + + dmeventd -d & + LOCAL_DMEVENTD="$!" + strace -p $LOCAL_DMEVENTD & +} + prepare_testroot() { OLDPWD="`pwd`" PREFIX="LVMTEST$$" @@ -127,6 +143,8 @@ kill -9 "$LOCAL_CLVMD" || true } + test -n "$LOCAL_DMEVENTD" && kill -9 "$LOCAL_DMEVENTD" + teardown_devs test -n "$TESTDIR" && { From mornfall@sourceware.org Thu May 6 19:01:00 2010 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Thu, 06 May 2010 19:01:00 -0000 Subject: LVM2/test check.sh t-lvconvert-repair-dmeventd.sh Message-ID: <20100506190128.15824.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2010-05-06 19:01:27 Modified files: test : check.sh Added files: test : t-lvconvert-repair-dmeventd.sh Log message: Add a basic test for dmeventd triggering lvconvert --repair. Needs improvement. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvconvert-repair-dmeventd.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/check.sh.diff?cvsroot=lvm2&r1=1.2&r2=1.3 /cvs/lvm2/LVM2/test/t-lvconvert-repair-dmeventd.sh,v --> standard output revision 1.1 --- LVM2/test/t-lvconvert-repair-dmeventd.sh +++ - 2010-05-06 19:01:27.406774000 +0000 @@ -0,0 +1,26 @@ +#!/bin/bash +# Copyright (C) 2008 Red Hat, Inc. All rights reserved. +# +# 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 + +. ./test-utils.sh + +prepare_vg 5 +prepare_dmeventd + +which mkfs.ext2 || exit 200 + +lvcreate -m 3 --ig -L 1 -n 4way $vg +lvchange --monitor y $vg/4way +disable_dev $dev2 $dev4 +mkfs.ext2 $DM_DEV_DIR/$vg/4way +sleep 3 # FIXME : - ( +enable_dev $dev2 $dev4 +check mirror $vg 4way +check mirror_legs $vg 4way 2 --- LVM2/test/check.sh 2010/04/12 19:33:58 1.2 +++ LVM2/test/check.sh 2010/05/06 19:01:26 1.3 @@ -98,6 +98,14 @@ if test -n "$3"; then mirror_log_on "$lv" "$3"; fi } +mirror_legs() { + lv="$1/$2" + expect="$3" + lvdevices "$lv" + real=`lvdevices "$lv" | wc -w` + test "$expect" = "$real" +} + linear() { lv="$1/$2" lvs -ostripes "$lv" | grep -q "1" || { From agk@sourceware.org Fri May 7 15:24:00 2010 From: agk@sourceware.org (agk@sourceware.org) Date: Fri, 07 May 2010 15:24:00 -0000 Subject: LVM2 ./WHATS_NEW tools/pvscan.c Message-ID: <20100507152419.4673.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-05-07 15:24:18 Modified files: . : WHATS_NEW tools : pvscan.c Log message: Fix truncated total size displayed by pvscan. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1549&r2=1.1550 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvscan.c.diff?cvsroot=lvm2&r1=1.50&r2=1.51 --- LVM2/WHATS_NEW 2010/05/06 11:15:55 1.1549 +++ LVM2/WHATS_NEW 2010/05/07 15:24:17 1.1550 @@ -1,5 +1,6 @@ Version 2.02.65 - ================================= + Fix truncated total size displayed by pvscan. Add new --sysinit option for vgchange and lvchange. Suppress duplicate error messages about read failures and missing devices. Install plugins to $(libdir)/device-mapper and $(libdir)/lvm2. --- LVM2/tools/pvscan.c 2010/04/01 10:34:11 1.50 +++ LVM2/tools/pvscan.c 2010/05/07 15:24:18 1.51 @@ -166,7 +166,7 @@ size_new += pv_size(pv); size_total += pv_size(pv); } else - size_total += pv_pe_count(pv) * pv_pe_size(pv); + size_total += (uint64_t) pv_pe_count(pv) * pv_pe_size(pv); } /* find maximum pv name length */ From zkabelac@sourceware.org Tue May 11 08:32:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Tue, 11 May 2010 08:32:00 -0000 Subject: LVM2/daemons/dmeventd/plugins mirror/dmeventd_ ... Message-ID: <20100511083223.32427.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-11 08:32:23 Modified files: daemons/dmeventd/plugins/mirror: dmeventd_mirror.c daemons/dmeventd/plugins/snapshot: dmeventd_snapshot.c Log message: Headerfile is no longer needed here Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c.diff?cvsroot=lvm2&r1=1.33&r2=1.34 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c.diff?cvsroot=lvm2&r1=1.8&r2=1.9 --- LVM2/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c 2010/03/30 14:39:55 1.33 +++ LVM2/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c 2010/05/11 08:32:22 1.34 @@ -19,8 +19,6 @@ #include "libdevmapper-event.h" #include "dmeventd_lvm.h" -#include - #include /* FIXME Replace syslog with multilog */ /* FIXME Missing openlog? */ /* FIXME Replace most syslogs with log_error() style messages and add complete context. */ --- LVM2/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c 2010/02/15 12:55:20 1.8 +++ LVM2/daemons/dmeventd/plugins/snapshot/dmeventd_snapshot.c 2010/05/11 08:32:22 1.9 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2007-2008 Red Hat, Inc. All rights reserved. + * Copyright (C) 2007-2010 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -21,7 +21,6 @@ #include "lvm-string.h" -#include #include /* FIXME Replace syslog with multilog */ /* FIXME Missing openlog? */ From zkabelac@sourceware.org Tue May 11 08:34:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Tue, 11 May 2010 08:34:00 -0000 Subject: LVM2 ./WHATS_NEW ./make.tmpl.in tools/Makefile.in Message-ID: <20100511083441.1146.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-11 08:34:39 Modified files: . : WHATS_NEW make.tmpl.in tools : Makefile.in Log message: Link liblvm2cmd.so with devmapper-event and devmapper libs. and remove generic %.so: %.a target. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1550&r2=1.1551 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/make.tmpl.in.diff?cvsroot=lvm2&r1=1.94&r2=1.95 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/Makefile.in.diff?cvsroot=lvm2&r1=1.117&r2=1.118 --- LVM2/WHATS_NEW 2010/05/07 15:24:17 1.1550 +++ LVM2/WHATS_NEW 2010/05/11 08:34:38 1.1551 @@ -1,5 +1,6 @@ Version 2.02.65 - ================================= + Link liblvm2cmd.so with devmapper-event and devmapper libs. Fix truncated total size displayed by pvscan. Add new --sysinit option for vgchange and lvchange. Suppress duplicate error messages about read failures and missing devices. --- LVM2/make.tmpl.in 2010/05/06 10:07:46 1.94 +++ LVM2/make.tmpl.in 2010/05/11 08:34:38 1.95 @@ -320,11 +320,6 @@ $(LN_S) -f $( CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-11 08:38:11 Modified files: . : WHATS_NEW daemons/dmeventd: Makefile.in Log message: Link libdevmapper-event.so with libdevmapper.so. For now using $(LIBS) for a list of linked libraries to $(LIB_SHARED) library. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1551&r2=1.1552 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/Makefile.in.diff?cvsroot=lvm2&r1=1.41&r2=1.42 --- LVM2/WHATS_NEW 2010/05/11 08:34:38 1.1551 +++ LVM2/WHATS_NEW 2010/05/11 08:38:10 1.1552 @@ -1,5 +1,6 @@ Version 2.02.65 - ================================= + Add devmapper library to linked libdevmapper-event.so. Link liblvm2cmd.so with devmapper-event and devmapper libs. Fix truncated total size displayed by pvscan. Add new --sysinit option for vgchange and lvchange. --- LVM2/daemons/dmeventd/Makefile.in 2010/04/09 21:42:48 1.41 +++ LVM2/daemons/dmeventd/Makefile.in 2010/05/11 08:38:10 1.42 @@ -53,7 +53,8 @@ all: device-mapper device-mapper: $(TARGETS) -LVMLIBS += -ldevmapper-event -ldevmapper $(PTHREAD_LIBS) +LIBS += -ldevmapper +LVMLIBS += -ldevmapper-event $(PTHREAD_LIBS) dmeventd: $(LIB_SHARED) dmeventd.o $(CC) $(CFLAGS) $(LDFLAGS) -L. -o $@ dmeventd.o \ From zkabelac@sourceware.org Tue May 11 08:42:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Tue, 11 May 2010 08:42:00 -0000 Subject: LVM2/daemons/dmeventd/plugins mirror/Makefile. ... Message-ID: <20100511084200.4848.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-11 08:42:00 Modified files: daemons/dmeventd/plugins/mirror: Makefile.in daemons/dmeventd/plugins/snapshot: Makefile.in Log message: Plugins do not use pthread or lvm2cmd directly. Plugins are using pthread and lvm2cmd libraries indirectly through devmapper-event-lvm2, so link only with libraries used by them. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/plugins/mirror/Makefile.in.diff?cvsroot=lvm2&r1=1.20&r2=1.21 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/plugins/snapshot/Makefile.in.diff?cvsroot=lvm2&r1=1.15&r2=1.16 --- LVM2/daemons/dmeventd/plugins/mirror/Makefile.in 2010/05/06 10:07:47 1.20 +++ LVM2/daemons/dmeventd/plugins/mirror/Makefile.in 2010/05/11 08:41:58 1.21 @@ -30,7 +30,7 @@ include $(top_builddir)/make.tmpl -LIBS += @LVM2CMD_LIB@ -ldevmapper-event-lvm2 -ldevmapper $(PTHREAD_LIBS) +LIBS += -ldevmapper-event-lvm2 -ldevmapper install_lvm2: install_dm_plugin --- LVM2/daemons/dmeventd/plugins/snapshot/Makefile.in 2010/05/06 10:07:47 1.15 +++ LVM2/daemons/dmeventd/plugins/snapshot/Makefile.in 2010/05/11 08:41:59 1.16 @@ -26,7 +26,7 @@ include $(top_builddir)/make.tmpl -LIBS += @LVM2CMD_LIB@ -ldevmapper-event-lvm2 -ldevmapper $(PTHREAD_LIBS) +LIBS += -ldevmapper-event-lvm2 -ldevmapper install_lvm2: install_dm_plugin From zkabelac@sourceware.org Tue May 11 08:43:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Tue, 11 May 2010 08:43:00 -0000 Subject: LVM2 make.tmpl.in Message-ID: <20100511084319.5529.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-11 08:43:18 Modified files: . : make.tmpl.in Log message: Skip unneeded 'cat' command execution. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/make.tmpl.in.diff?cvsroot=lvm2&r1=1.95&r2=1.96 --- LVM2/make.tmpl.in 2010/05/11 08:34:38 1.95 +++ LVM2/make.tmpl.in 2010/05/11 08:43:18 1.96 @@ -142,14 +142,11 @@ LVM_VERSION := $(shell cat $(top_srcdir)/VERSION) -LIB_VERSION_LVM := $(shell cat $(top_srcdir)/VERSION | \ - $(AWK) -F '.' '{printf "%s.%s",$$1,$$2}') +LIB_VERSION_LVM := $(shell $(AWK) -F '.' '{printf "%s.%s",$$1,$$2}' $(top_srcdir)/VERSION) -LIB_VERSION_DM := $(shell cat $(top_srcdir)/VERSION_DM | \ - $(AWK) -F '.' '{printf "%s.%s",$$1,$$2}') +LIB_VERSION_DM := $(shell $(AWK) -F '.' '{printf "%s.%s",$$1,$$2}' $(top_srcdir)/VERSION_DM) -LIB_VERSION_APP := $(shell cat $(top_srcdir)/VERSION | \ - $(AWK) -F '[(). ]' '{printf "%s.%s",$$1,$$4}') +LIB_VERSION_APP := $(shell $(AWK) -F '[(). ]' '{printf "%s.%s",$$1,$$4}' $(top_srcdir)/VERSION) INCLUDES += -I. -I$(top_builddir)/include From zkabelac@sourceware.org Tue May 11 08:47:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Tue, 11 May 2010 08:47:00 -0000 Subject: LVM2 ./WHATS_NEW daemons/dmeventd/libdevmapper ... Message-ID: <20100511084705.7923.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-11 08:47:03 Modified files: . : WHATS_NEW daemons/dmeventd: libdevmapper-event.pc.in Log message: Use Require.private: field for devmapper-event.pc Move devmapper to Require.private: field and remove unneeded libs from Libs.private: as they are dependencies of devmapper library. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1552&r2=1.1553 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/libdevmapper-event.pc.in.diff?cvsroot=lvm2&r1=1.2&r2=1.3 --- LVM2/WHATS_NEW 2010/05/11 08:38:10 1.1552 +++ LVM2/WHATS_NEW 2010/05/11 08:47:02 1.1553 @@ -1,5 +1,6 @@ Version 2.02.65 - ================================= + Use field Requires.private: for devmapper-event.pc. Add devmapper library to linked libdevmapper-event.so. Link liblvm2cmd.so with devmapper-event and devmapper libs. Fix truncated total size displayed by pvscan. --- LVM2/daemons/dmeventd/libdevmapper-event.pc.in 2010/03/19 18:33:55 1.2 +++ LVM2/daemons/dmeventd/libdevmapper-event.pc.in 2010/05/11 08:47:03 1.3 @@ -6,7 +6,6 @@ Name: devmapper-event Description: device-mapper event library Version: @DM_LIB_PATCHLEVEL@ -Requires: devmapper Cflags: -I${includedir} Libs: -L${libdir} -ldevmapper-event -Libs.private: -lpthread -ldl +Requires.private: devmapper From zkabelac@sourceware.org Tue May 11 08:48:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Tue, 11 May 2010 08:48:00 -0000 Subject: LVM2 configure configure.in Message-ID: <20100511084844.9157.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-11 08:48:43 Modified files: . : configure configure.in Log message: Add UDEV_PC and SELINUX_PC substituted variables Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.diff?cvsroot=lvm2&r1=1.126&r2=1.127 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.in.diff?cvsroot=lvm2&r1=1.136&r2=1.137 --- LVM2/configure 2010/04/30 14:49:43 1.126 +++ LVM2/configure 2010/05/11 08:48:43 1.127 @@ -649,10 +649,12 @@ WRITE_INSTALL UDEV_SYNC UDEV_RULES +UDEV_PC UDEV_LIBS STATIC_LINK STATICDIR SNAPSHOTS +SELINUX_PC SELINUX_LIBS READLINE_LIBS PTHREAD_LIBS @@ -12327,7 +12329,7 @@ { $as_echo "$as_me:$LINENO: result: $ac_cv_lib_udev_udev_queue_get_udev_is_active" >&5 $as_echo "$ac_cv_lib_udev_udev_queue_get_udev_is_active" >&6; } if test "x$ac_cv_lib_udev_udev_queue_get_udev_is_active" = x""yes; then - UDEV_LIBS="-ludev" + UDEV_PC="libudev"; UDEV_LIBS="-ludev" else { { $as_echo "$as_me:$LINENO: error: bailing out... libudev library is required" >&5 $as_echo "$as_me: error: bailing out... libudev library is required" >&2;} @@ -13141,12 +13143,14 @@ _ACEOF SELINUX_LIBS="-lselinux $SELINUX_LIBS" + SELINUX_PC="libselinux" HAVE_SELINUX=yes else { $as_echo "$as_me:$LINENO: WARNING: Disabling selinux" >&5 $as_echo "$as_me: WARNING: Disabling selinux" >&2;} SELINUX_LIBS= + SELINUX_PC= HAVE_SELINUX=no fi @@ -15610,6 +15614,8 @@ + + ################################################################################ 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" --- LVM2/configure.in 2010/04/30 13:58:10 1.136 +++ LVM2/configure.in 2010/05/11 08:48:43 1.137 @@ -659,7 +659,9 @@ AC_MSG_RESULT($UDEV_SYNC) if test x$UDEV_SYNC = xyes; then - AC_CHECK_LIB(udev, udev_queue_get_udev_is_active, UDEV_LIBS="-ludev", AC_MSG_ERROR(bailing out... libudev library is required)) + AC_CHECK_LIB(udev, udev_queue_get_udev_is_active, + [UDEV_PC="libudev"; UDEV_LIBS="-ludev"], + [AC_MSG_ERROR([bailing out... libudev library is required])]) AC_DEFINE([UDEV_SYNC_SUPPORT], 1, [Define to 1 to enable synchronisation with udev processing.]) fi @@ -831,9 +833,11 @@ AC_CHECK_HEADERS([selinux/selinux.h],, hard_bailout) AC_DEFINE([HAVE_SELINUX], 1, [Define to 1 to include support for selinux.]) SELINUX_LIBS="-lselinux $SELINUX_LIBS" + SELINUX_PC="libselinux" HAVE_SELINUX=yes ], [ AC_MSG_WARN(Disabling selinux) SELINUX_LIBS= + SELINUX_PC= HAVE_SELINUX=no ]) fi @@ -1117,10 +1121,12 @@ AC_SUBST(SALCK_CFLAGS) AC_SUBST(SALCK_LIBS) AC_SUBST(SELINUX_LIBS) +AC_SUBST(SELINUX_PC) AC_SUBST(SNAPSHOTS) AC_SUBST(STATICDIR) AC_SUBST(STATIC_LINK) AC_SUBST(UDEV_LIBS) +AC_SUBST(UDEV_PC) AC_SUBST(UDEV_RULES) AC_SUBST(UDEV_SYNC) AC_SUBST(WRITE_INSTALL) From zkabelac@sourceware.org Tue May 11 08:54:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Tue, 11 May 2010 08:54:00 -0000 Subject: LVM2 ./WHATS_NEW libdm/libdevmapper.pc.in libl ... Message-ID: <20100511085412.12206.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-11 08:54:11 Modified files: . : WHATS_NEW libdm : libdevmapper.pc.in liblvm : liblvm2app.pc.in Log message: Switch to use Requires.private for devmapper.pc and lvm2app.pc Use Requires.private: instead of Libs.private: Use UDEV_PC and SELINUX_PC for Require.private: It looks like usage of Requires.private is prefered from Libs.private. However pkg-config documentation is really poor here. But here is short outcome: There is a difference in Libs.private: and Requires.private: where we specify libselinux instead of -lselinux -lsepol. We leave resolving of query like 'pkg-config --libs --static devmapper' on taking proper selinux and udev libs to their .pc files instead of hardcoding them into our .pc file which is might give incorrect answer. - i.e. dependency of libselinux package might change and we may return wrong list of linked libraries. http://bugs.freedesktop.org/show_bug.cgi?id=4738 http://err.no/personal/blog/tech/2008-03-25-18-07_pkg-config,_sonames_and_Requires.private Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1553&r2=1.1554 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.pc.in.diff?cvsroot=lvm2&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/liblvm2app.pc.in.diff?cvsroot=lvm2&r1=1.1&r2=1.2 --- LVM2/WHATS_NEW 2010/05/11 08:47:02 1.1553 +++ LVM2/WHATS_NEW 2010/05/11 08:54:11 1.1554 @@ -1,5 +1,6 @@ Version 2.02.65 - ================================= + Switch usage of Libs.private: to Requires.private: in devmapper.pc, lvm2app.pc. Use field Requires.private: for devmapper-event.pc. Add devmapper library to linked libdevmapper-event.so. Link liblvm2cmd.so with devmapper-event and devmapper libs. --- LVM2/libdm/libdevmapper.pc.in 2010/04/26 09:05:51 1.4 +++ LVM2/libdm/libdevmapper.pc.in 2010/05/11 08:54:11 1.5 @@ -8,4 +8,4 @@ Version: @DM_LIB_PATCHLEVEL@ Cflags: -I${includedir} Libs: -L${libdir} -ldevmapper -Libs.private: @SELINUX_LIBS@ @UDEV_LIBS@ +Requires.private: @SELINUX_PC@ @UDEV_PC@ --- LVM2/liblvm/liblvm2app.pc.in 2009/07/23 01:41:53 1.1 +++ LVM2/liblvm/liblvm2app.pc.in 2010/05/11 08:54:11 1.2 @@ -8,4 +8,4 @@ Version: @LVM_MAJOR@.@LVM_LIBAPI@ Cflags: -I${includedir} Libs: -L${libdir} -llvm2app -Libs.private: -ldevmapper +Requires.private: devmapper From zkabelac@sourceware.org Tue May 11 08:57:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Tue, 11 May 2010 08:57:00 -0000 Subject: LVM2 ./WHATS_NEW ./make.tmpl.in daemons/dmeven ... Message-ID: <20100511085708.13103.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-11 08:57:04 Modified files: . : WHATS_NEW make.tmpl.in daemons/dmeventd: Makefile.in libdm : Makefile.in liblvm : Makefile.in Log message: Add pkgconfigdir for placement of .pc files Use easily overideable make install pkgconfigdir variable. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1554&r2=1.1555 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/make.tmpl.in.diff?cvsroot=lvm2&r1=1.96&r2=1.97 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/Makefile.in.diff?cvsroot=lvm2&r1=1.42&r2=1.43 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/Makefile.in.diff?cvsroot=lvm2&r1=1.54&r2=1.55 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/Makefile.in.diff?cvsroot=lvm2&r1=1.22&r2=1.23 --- LVM2/WHATS_NEW 2010/05/11 08:54:11 1.1554 +++ LVM2/WHATS_NEW 2010/05/11 08:57:02 1.1555 @@ -1,5 +1,6 @@ Version 2.02.65 - ================================= + Add pkgconfigdir Makefile variable for make install override. Switch usage of Libs.private: to Requires.private: in devmapper.pc, lvm2app.pc. Use field Requires.private: for devmapper-event.pc. Add devmapper library to linked libdevmapper-event.so. --- LVM2/make.tmpl.in 2010/05/11 08:43:18 1.96 +++ LVM2/make.tmpl.in 2010/05/11 08:57:02 1.97 @@ -63,6 +63,7 @@ localedir = $(DESTDIR)@LOCALEDIR@ staticdir = $(DESTDIR)@STATICDIR@ udevdir = $(DESTDIR)@udevdir@ +pkgconfigdir = $(usrlibdir)/pkgconfig USRLIB_RELPATH = $(shell echo $(abspath $(usrlibdir) $(libdir)) | \ $(AWK) -f $(top_srcdir)/scripts/relpath.awk) --- LVM2/daemons/dmeventd/Makefile.in 2010/05/11 08:38:10 1.42 +++ LVM2/daemons/dmeventd/Makefile.in 2010/05/11 08:57:02 1.43 @@ -81,7 +81,7 @@ $(INSTALL_DATA) -D $< $(includedir)/$( CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2010-05-12 05:55:08 Modified files: test : check.sh Log message: Improve the "check" testing utility: slightly refactor and provide active/inactive checks. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/check.sh.diff?cvsroot=lvm2&r1=1.3&r2=1.4 --- LVM2/test/check.sh 2010/05/06 19:01:26 1.3 +++ LVM2/test/check.sh 2010/05/12 05:55:08 1.4 @@ -2,8 +2,12 @@ set -e -o pipefail +lvl() { + lvs -a --noheadings "$@" +} + lvdevices() { - lvs -a -odevices --noheadings "$@" | sed 's/([^)]*)//g; s/,/ /g' + lvl -odevices "$@" | sed 's/([^)]*)//g; s/,/ /g' } mirror_images_redundant() @@ -57,9 +61,9 @@ lv_is_contiguous() { - test `lvs -a --segments --noheadings $1 | wc -l` -eq 1 || { + test `lvl --segments $1 | wc -l` -eq 1 || { echo "LV $1 expected to be contiguous, but is not:" - lvs -a --segments --noheadings $1 + lvl --segments $1 exit 1 } } @@ -89,9 +93,9 @@ mirror() { lv="$1/$2" - lvs -oattr "$lv" | grep "m" || { + lvl -oattr "$lv" | grep "m" || { echo "$lv expected a mirror, but is not:" - lvs -a $lv + lvl -a $lv exit 1 } mirror_images_redundant "$1" "$2" @@ -108,9 +112,37 @@ linear() { lv="$1/$2" - lvs -ostripes "$lv" | grep -q "1" || { + lvl -ostripes "$lv" | grep -q "1" || { echo "$lv expected linear, but is not:" - lvs -a "$lv" -o+devices + lvl "$lv" -o+devices + exit 1 + } +} + +active() { + lv="$1/$2" + lvl -oattr "$lv" 2> /dev/null | grep -q "^ *....a.$" || { + echo "$lv expected active, but lvs says it's not:" + lvl "$lv" -o+devices 2>/dev/null + exit 1 + } + dmsetup table | egrep -q "$1-$2: *[^ ]+" || { + echo "$lv expected active, lvs thinks it is but there are no mappings!" + dmsetup table | grep $1-$2: + exit 1 + } +} + +inactive() { + lv="$1/$2" + lvl -oattr "$lv" 2> /dev/null | grep -q '^ *....[-isd].$' || { + echo "$lv expected inactive, but lvs says it's not:" + lvl "$lv" -o+devices 2>/dev/null + exit 1 + } + dmsetup table | not egrep -q "$1-$2: *[^ ]+" || { + echo "$lv expected inactive, lvs thinks it is but there are mappings!" + dmsetup table | grep $1-$2: exit 1 } } From mornfall@sourceware.org Wed May 12 05:55:00 2010 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Wed, 12 May 2010 05:55:00 -0000 Subject: LVM2/test not.c Message-ID: <20100512055544.5426.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2010-05-12 05:55:42 Modified files: test : not.c Log message: The "should" testing utility should actually only give a warning when the command fails. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/not.c.diff?cvsroot=lvm2&r1=1.3&r2=1.4 --- LVM2/test/not.c 2010/04/30 14:33:39 1.3 +++ LVM2/test/not.c 2010/05/12 05:55:42 1.4 @@ -8,7 +8,8 @@ if (!strcmp(cmd, "not")) return !status; if (!strcmp(cmd, "should")) { - fprintf(stderr, "TEST WARNING: Ignoring command failure.\n"); + if (status) + fprintf(stderr, "TEST WARNING: Ignoring command failure.\n"); return 0; } return 6; From mornfall@sourceware.org Wed May 12 05:59:00 2010 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Wed, 12 May 2010 05:59:00 -0000 Subject: LVM2/test t-activate-partial.sh t-partial-acti ... Message-ID: <20100512055925.6115.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2010-05-12 05:59:25 Added files: test : t-activate-partial.sh Removed files: test : t-partial-activate.sh Log message: Rename t-partial-activate to t-activate-partial (more activation tests coming). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-activate-partial.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-partial-activate.sh.diff?cvsroot=lvm2&r1=1.3&r2=NONE /cvs/lvm2/LVM2/test/t-activate-partial.sh,v --> standard output revision 1.1 --- LVM2/test/t-activate-partial.sh +++ - 2010-05-12 05:59:25.208708000 +0000 @@ -0,0 +1,15 @@ +. ./test-utils.sh + +aux prepare_vg 3 + +lvcreate -m 1 -l 1 -n mirror $vg +lvchange -a n $vg/mirror +disable_dev $dev1 + +not vgreduce --removemissing $vg +not lvchange -v -a y $vg/mirror +lvchange -v --partial -a y $vg/mirror + +# also check that vgchange works +vgchange -a n --partial $vg +vgchange -a y --partial $vg From mornfall@sourceware.org Wed May 12 06:02:00 2010 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Wed, 12 May 2010 06:02:00 -0000 Subject: LVM2/test t-activate-missing.sh Message-ID: <20100512060228.22474.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2010-05-12 06:02:28 Added files: test : t-activate-missing.sh Log message: Add a test for activation in presence of missing devices. This partially covers the robustness requirements for system startup that we have. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-activate-missing.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1 /cvs/lvm2/LVM2/test/t-activate-missing.sh,v --> standard output revision 1.1 --- LVM2/test/t-activate-missing.sh +++ - 2010-05-12 06:02:28.606758000 +0000 @@ -0,0 +1,73 @@ +#!/bin/bash + +# Test activation behaviour with devices missing. +# - snapshots and their origins are only activated together; if one fails, both +# fail +# - partial mirrors are not activated (but maybe they should? maybe we should +# instead lvconvert --repair them?) +# - linear LVs with bits missing are not activated + +. ./test-utils.sh + +prepare_vg 4 + +lvcreate -l1 -n linear1 $vg $dev1 +lvcreate -l1 -n linear2 $vg $dev2 +lvcreate -l2 -n linear12 $vg $dev1:4 $dev2:4 + +lvcreate -l1 -n origin1 $vg $dev1 +lvcreate -s $vg/origin1 -l1 -n s_napshot2 $dev2 + +lvcreate -l1 -m1 -n mirror12 --mirrorlog core $vg $dev1 $dev2 +lvcreate -l1 -m1 -n mirror123 $vg $dev1 $dev2 $dev3 + +vgchange -a n $vg +disable_dev $dev1 +not vgchange -a y $vg + +check inactive $vg linear1 +check active $vg linear2 +check inactive $vg origin1 +check inactive $vg s_napshot2 +check inactive $vg linear12 +check inactive $vg mirror12 +check inactive $vg mirror123 + +vgchange -a n $vg +enable_dev $dev1 +disable_dev $dev2 +not vgchange -a y $vg + +check active $vg linear1 +check inactive $vg linear2 +check inactive $vg linear12 +check inactive $vg origin1 +check inactive $vg s_napshot2 +check inactive $vg mirror12 +check inactive $vg mirror123 + +vgchange -a n $vg +enable_dev $dev2 +disable_dev $dev3 +not vgchange -a y $vg + +check active $vg origin1 +check active $vg s_napshot2 +check active $vg linear1 +check active $vg linear2 +check active $vg linear12 +check inactive $vg mirror123 +check active $vg mirror12 + +vgchange -a n $vg +enable_dev $dev3 +disable_dev $dev4 +vgchange -a y $vg + +check active $vg origin1 +check active $vg s_napshot2 +check active $vg linear1 +check active $vg linear2 +check active $vg linear12 +check active $vg mirror12 +check active $vg mirror123 From mornfall@sourceware.org Wed May 12 06:09:00 2010 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Wed, 12 May 2010 06:09:00 -0000 Subject: LVM2/test t-lvconvert-mirror.sh Message-ID: <20100512060926.17958.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2010-05-12 06:09:25 Modified files: test : t-lvconvert-mirror.sh Log message: Revert the huge device creation in t-lvconvert-mirror and downgrade the race-induced failure to a warning, until we have a better fix for this. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvconvert-mirror.sh.diff?cvsroot=lvm2&r1=1.4&r2=1.5 --- LVM2/test/t-lvconvert-mirror.sh 2010/04/22 15:39:40 1.4 +++ LVM2/test/t-lvconvert-mirror.sh 2010/05/12 06:09:22 1.5 @@ -10,7 +10,7 @@ # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA . ./test-utils.sh -aux prepare_vg 5 200 +aux prepare_vg 5 # convert from linear to 2-way mirror lvcreate -l2 -n $lv1 $vg $dev1 @@ -65,14 +65,16 @@ # Test pulling primary image before mirror in-sync (should fail) # Test pulling primary image after mirror in-sync (should work) # Test that the correct devices remain in the mirror -lvcreate -l20 -m2 -n $lv1 $vg $dev1 $dev2 $dev4 $dev3:0 +lvcreate -l2 -m2 -n $lv1 $vg $dev1 $dev2 $dev4 $dev3:0 # FIXME: # This is somewhat timing dependent - sync /could/ finish before # we get a chance to have this command fail -not lvconvert -m-1 $vg/$lv1 $dev1 +should not lvconvert -m-1 $vg/$lv1 $dev1 while [ `lvs --noheadings -o copy_percent $vg/$lv1` != "100.00" ]; do sleep 1 done +lvconvert -m2 $vg/$lv1 $dev1 $dev2 $dev4 $dev3:0 + lvconvert -m-1 $vg/$lv1 $dev1 check mirror_images_on $lv1 $dev2 $dev4 lvconvert -m-1 $vg/$lv1 $dev2 From mornfall@sourceware.org Wed May 12 10:08:00 2010 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Wed, 12 May 2010 10:08:00 -0000 Subject: LVM2/test check.sh t-lvconvert-mirror.sh t-lvc ... Message-ID: <20100512100837.3410.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2010-05-12 10:08:36 Modified files: test : check.sh t-lvconvert-mirror.sh t-lvcreate-mirror.sh t-vgcreate-usage.sh test-utils.sh Added files: test : t-lvconvert-mirror-basic.sh Removed files: test : t-mirror-lvconvert.sh Log message: A fairly extensive refactor of the mirror testing code. The exhaustive lvconvert testing is now in its own test, t-lvconvert-mirror-basic ... it doesn't do anything fancy but it does run lvconvert through a lot of combinations. I have also merged the remaining t-mirror-lvconvert tests into t-lvconvert-mirror and abolished the former. The latter will be split again later into more thematic divisions. (The previous split was rather arbitrary, may I even say random...) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvconvert-mirror-basic.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/check.sh.diff?cvsroot=lvm2&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvconvert-mirror.sh.diff?cvsroot=lvm2&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvcreate-mirror.sh.diff?cvsroot=lvm2&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-vgcreate-usage.sh.diff?cvsroot=lvm2&r1=1.14&r2=1.15 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/test-utils.sh.diff?cvsroot=lvm2&r1=1.39&r2=1.40 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-mirror-lvconvert.sh.diff?cvsroot=lvm2&r1=1.27&r2=NONE /cvs/lvm2/LVM2/test/t-lvconvert-mirror-basic.sh,v --> standard output revision 1.1 --- LVM2/test/t-lvconvert-mirror-basic.sh +++ - 2010-05-12 10:08:36.393046000 +0000 @@ -0,0 +1,139 @@ +. ./test-utils.sh + +log_name_to_count() +{ + if [ $1 == "mirrored" ]; then + echo 2 + elif [ $1 == "disk" ]; then + echo 1 + else + echo 0 + fi +} + +# FIXME: For test_[up|down]convert, I'd still like to be able +# to specifiy devices - especially if I can do partial PV +# specification for down-converts. It may even be wise to +# do one round through these tests without specifying the PVs +# to use and one round where we do. + +# test_lvconvert +# start_mirror_count: The '-m' argument to create with +# start_log_type: core|disk|mirrored +# final_mirror_count: The '-m' argument to convert to +# final_log_type: core|disk|mirrored +# active: Whether the LV should be active when the convert happens +# +# Exmaple: Convert 3-way disk-log mirror to +# 2-way disk-log mirror while not active +# -> test_lvconvert 2 disk 3 disk 0 + +test_lvconvert() +{ + local start_count=$1 + local start_count_p1=$(($start_count + 1)) + local start_log_type=$2 + local finish_count=$3 + local finish_count_p1=$(($finish_count + 1)) + local finish_log_type=$4 + local dev_array=($dev1 $dev2 $dev3 $dev4 $dev5) + local start_log_count + local finish_log_count + local max_log_count + local alloc="" + local active=true + local i + + if [ $start_log_type == "disk" ] && + [ $finish_log_type == "mirrored" ]; then + echo "FIXME: disk -> mirrored log conversion not yet supported by LVM" + return 0 + fi + + test "$5" = "active" && active=false + #test $finish_count -gt $start_count && up=true + + # Do we have enough devices for the mirror images? + if [ $start_count_p1 -gt ${#dev_array[@]} ]; then + echo "Action requires too many devices" + return 1 + fi + + # Do we have enough devices for the mirror images? + if [ $finish_count_p1 -gt ${#dev_array[@]} ]; then + echo "Action requires too many devices" + return 1 + fi + + start_log_count=`log_name_to_count $start_log_type` + finish_log_count=`log_name_to_count $finish_log_type` + if [ $finish_log_count -gt $start_log_count ]; then + max_log_count=$finish_log_count + else + max_log_count=$start_log_count + fi + + prepare_vg 5 + + if [ $start_count -gt 0 ]; then + # Are there extra devices for the log or do we overlap + if [ $(($start_count_p1 + $start_log_count)) -gt ${#dev_array[@]} ]; then + alloc="--alloc anywhere" + fi + + lvcreate -l2 -m $start_count --mirrorlog $start_log_type \ + -n $lv1 $vg $alloc + check mirror_legs $vg $lv1 $start_count_p1 + # FIXME: check mirror log + else + lvcreate -l2 -n $lv1 $vg + fi + + lvs -a -o name,copy_percent,devices $vg + if ! $active; then + lvchange -an $vg/$lv1 + fi + + # Are there extra devices for the log or do we overlap + if [ $(($finish_count_p1 + $finish_log_count)) -gt ${#dev_array[@]} ]; then + alloc="--alloc anywhere" + fi + + echo y | lvconvert -m $finish_count --mirrorlog $finish_log_type \ + $vg/$lv1 $alloc + + if ! $active; then + lvchange -ay $vg/$lv1 + fi + + check mirror_no_temporaries $vg $lv1 + if [ "$finish_count_p1" -eq 1 ]; then + check linear $vg $lv1 + else + if test -n "$alloc"; then + check mirror_nonredundant $vg $lv1 + else + check mirror $vg $lv1 + fi + check mirror_legs $vg $lv1 $finish_count_p1 + fi +} + +aux prepare_vg 5 + +# Test conversion combinations from linear <-> 4-way mirrors +for i in $(seq 0 4); do + for j in $(seq 0 4); do + for k in core disk mirrored; do + for l in core disk mirrored; do + if test "$i" -eq "$j" && test "$k" = "$l"; then continue; fi + : ---------------------------------------------------- + : "Testing mirror conversion -m$i/$k -> -m$j/$l" + : ---------------------------------------------------- + test_lvconvert $i $k $j $l 0 + test_lvconvert $i $k $j $l 1 + done + done + done +done + --- LVM2/test/check.sh 2010/05/12 05:55:08 1.4 +++ LVM2/test/check.sh 2010/05/12 10:08:35 1.5 @@ -1,5 +1,18 @@ #!/bin/bash +# check.sh: assert various things about volumes + +# USAGE +# check linear VG LV +# check lv_on VG LV PV + +# check mirror VG LV [LOGDEV|core] +# check mirror_nonredundant VG LV +# check mirror_legs VG LV N +# check mirror_images_on VG LV DEV [DEV...] + +# ... + set -e -o pipefail lvl() { @@ -15,7 +28,7 @@ vg=$1 lv=$vg/$2 - lvs -a $vg + lvs -a $vg -o+devices for i in `lvdevices $lv`; do echo "# $i:" lvdevices $vg/$i | sort | uniq @@ -31,23 +44,26 @@ } mirror_images_on() { - lv=$1 + vg=$1 + lv=$2 + + shift 2 for i in `lvdevices $lv`; do + lv_on $vg $lv $1 shift - lv_on $lv $1 done } lv_on() { - lv="$1" - lvdevices $lv | grep -F "$2" || { - echo "LV $lv expected on $2 but is not:" >&2 + lv="$1/$2" + lvdevices $lv | grep -F "$3" || { + echo "LV $lv expected on $3 but is not:" >&2 lvdevices $lv >&2 exit 1 } - test `lvdevices $lv | grep -vF "$2" | wc -l` -eq 0 || { + test `lvdevices $lv | grep -vF "$3" | wc -l` -eq 0 || { echo "LV $lv contains unexpected devices:" >&2 lvdevices $lv >&2 exit 1 @@ -56,7 +72,14 @@ mirror_log_on() { - lv_on "${1}_mlog" "$2" + vg="$1" + lv="$2" + where="$3" + if test "$where" = "core"; then + lvl -omirror_log "$vg/$lv" | not grep mlog + else + lv_on $vg "${lv}_mlog" "$where" + fi } lv_is_contiguous() @@ -92,14 +115,18 @@ } mirror() { + mirror_nonredundant "$@" + mirror_images_redundant "$1" "$2" +} + +mirror_nonredundant() { lv="$1/$2" - lvl -oattr "$lv" | grep "m" || { + lvs -oattr "$lv" | grep -q "^ *m.....$" || { echo "$lv expected a mirror, but is not:" - lvl -a $lv + lvs -a $lv exit 1 } - mirror_images_redundant "$1" "$2" - if test -n "$3"; then mirror_log_on "$lv" "$3"; fi + if test -n "$3"; then mirror_log_on "$1" "$2" "$3"; fi } mirror_legs() { @@ -110,6 +137,17 @@ test "$expect" = "$real" } +mirror_no_temporaries() +{ + vg=$1 + lv=$2 + lvl -oname $vg | grep $lv | not grep "tmp" || { + echo "$lv has temporary mirror images unexpectedly:" + lvl $vg | grep $lv + exit 1 + } +} + linear() { lv="$1/$2" lvl -ostripes "$lv" | grep -q "1" || { --- LVM2/test/t-lvconvert-mirror.sh 2010/05/12 06:09:22 1.5 +++ LVM2/test/t-lvconvert-mirror.sh 2010/05/12 10:08:35 1.6 @@ -10,15 +10,15 @@ # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA . ./test-utils.sh -aux prepare_vg 5 # convert from linear to 2-way mirror +aux prepare_vg 5 lvcreate -l2 -n $lv1 $vg $dev1 lvconvert -i1 -m+1 $vg/$lv1 $dev2 $dev3:0-1 check mirror $vg $lv1 $dev3 -lvremove -ff $vg # convert from 2-way mirror to linear +aux prepare_vg 5 lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0-1 lvconvert -m-1 $vg/$lv1 check linear $vg $lv1 @@ -26,16 +26,18 @@ # and now try removing a specific leg (bz453643) lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0-1 lvconvert -m0 $vg/$lv1 $dev2 -check lv_on $vg/$lv1 $dev1 +check lv_on $vg $lv1 $dev1 lvremove -ff $vg # convert from disklog to corelog, active +aux prepare_vg 5 lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0-1 lvconvert -f --mirrorlog core $vg/$lv1 -check mirror $vg $lv1 "" +check mirror $vg $lv1 core lvremove -ff $vg # convert from corelog to disklog, active +aux prepare_vg 5 lvcreate -l2 -m1 --mirrorlog core -n $lv1 $vg $dev1 $dev2 lvconvert --mirrorlog disk $vg/$lv1 $dev3:0-1 check mirror $vg $lv1 $dev3 @@ -43,13 +45,15 @@ # bz192865: lvconvert log of an inactive mirror lv # convert from disklog to corelog, inactive +aux prepare_vg 5 lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0-1 lvchange -an $vg/$lv1 echo y | lvconvert -f --mirrorlog core $vg/$lv1 -check mirror $vg $lv1 "" +check mirror $vg $lv1 core lvremove -ff $vg # convert from corelog to disklog, inactive +aux prepare_vg 5 lvcreate -l2 -m1 --mirrorlog core -n $lv1 $vg $dev1 $dev2 lvchange -an $vg/$lv1 lvconvert --mirrorlog disk $vg/$lv1 $dev3:0-1 @@ -57,6 +61,7 @@ lvremove -ff $vg # convert linear to 2-way mirror with 1 PV +aux prepare_vg 5 lvcreate -l2 -n $lv1 $vg $dev1 not lvconvert -m+1 --mirrorlog core $vg/$lv1 $dev1 lvremove -ff $vg @@ -70,13 +75,166 @@ # This is somewhat timing dependent - sync /could/ finish before # we get a chance to have this command fail should not lvconvert -m-1 $vg/$lv1 $dev1 -while [ `lvs --noheadings -o copy_percent $vg/$lv1` != "100.00" ]; do - sleep 1 -done -lvconvert -m2 $vg/$lv1 $dev1 $dev2 $dev4 $dev3:0 + +lvconvert $vg/$lv1 # wait +lvconvert -m2 $vg/$lv1 $dev1 $dev2 $dev4 $dev3:0 # If the above "should" failed... lvconvert -m-1 $vg/$lv1 $dev1 check mirror_images_on $lv1 $dev2 $dev4 lvconvert -m-1 $vg/$lv1 $dev2 check linear $vg $lv1 -check lv_on $vg/$lv1 $dev4 +check lv_on $vg $lv1 $dev4 + +# No parallel lvconverts on a single LV please + +aux prepare_vg 5 +lvcreate -l5 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0 +check mirror $vg $lv1 +check mirror_legs $vg $lv1 2 +lvconvert -m+1 -b $vg/$lv1 $dev4 + +# Next convert should fail b/c we can't have 2 at once +should not lvconvert -m+1 $vg/$lv1 $dev5 +lvconvert $vg/$lv1 # wait +lvconvert -m2 $vg/$lv1 # In case the above "should" actually failed + +check mirror $vg $lv1 $dev3 +check mirror_no_temporaries $vg $lv1 +check mirror_legs $vg $lv1 3 + +# add 1 mirror to core log mirror, but +# implicitly keep log as 'core' +aux prepare_vg 5 +lvcreate -l2 -m1 --mirrorlog core -n $lv1 $vg $dev1 $dev2 +lvconvert -m +1 -i1 $vg/$lv1 + +check mirror $vg $lv1 core +check mirror_no_temporaries $vg $lv1 +check mirror_legs $vg $lv1 3 + +# remove 1 mirror from corelog'ed mirror; should retain 'core' log type +aux prepare_vg 5 +lvcreate -l2 -m2 --corelog -n $lv1 $vg +lvconvert -m -1 -i1 $vg/$lv1 + +check mirror $vg $lv1 core +check mirror_no_temporaries $vg $lv1 +check mirror_legs $vg $lv1 2 + +# add 1 mirror then add 1 more mirror during conversion +# FIXME this has been explicitly forbidden? +#aux prepare_vg 5 +#lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0 +#lvconvert -m+1 -b $vg/$lv1 $dev4 +#lvconvert -m+1 $vg/$lv1 $dev5 +# +#check mirror $vg $lv1 $dev3 +#check mirror_no_temporaries $vg $lv1 +#check mirror_legs $vg $lv1 4 + +# Linear to mirror with mirrored log using --alloc anywhere +aux prepare_vg 5 +lvcreate -l2 -n $lv1 $vg $dev1 +lvconvert -m +1 --mirrorlog mirrored $vg/$lv1 $dev1 $dev2 --alloc anywhere +should check mirror $vg $lv1 + +# convert inactive mirror and start polling +aux prepare_vg 5 +lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0 +lvchange -an $vg/$lv1 +lvconvert -m+1 $vg/$lv1 $dev4 +lvchange -ay $vg/$lv1 +lvconvert $vg/$lv1 # wait +check mirror $vg $lv1 $dev3 +check mirror_no_temporaries $vg $lv1 + +# --------------------------------------------------------------------- +# removal during conversion + +# "remove newly added mirror" +aux prepare_vg 5 +lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0 +lvconvert -m+1 -b $vg/$lv1 $dev4 +lvconvert -m-1 $vg/$lv1 $dev4 +lvconvert $vg/$lv1 # wait + +check mirror $vg $lv1 $dev3 +check mirror_no_temporaries $vg $lv1 +check mirror_legs $vg $lv1 2 + +# "remove one of newly added mirrors" +aux prepare_vg 5 +lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0 +lvconvert -m+2 -b $vg/$lv1 $dev4 $dev5 +lvconvert -m-1 $vg/$lv1 $dev4 +lvconvert $vg/$lv1 # wait + +check mirror $vg $lv1 $dev3 +check mirror_no_temporaries $vg $lv1 +check mirror_legs $vg $lv1 3 + +# "remove from original mirror (the original is still mirror)" +aux prepare_vg 5 +lvcreate -l2 -m2 -n $lv1 $vg $dev1 $dev2 $dev5 $dev3:0 +lvconvert -m+1 -b $vg/$lv1 $dev4 +lvconvert -m-1 $vg/$lv1 $dev2 +lvconvert $vg/$lv1 + +check mirror $vg $lv1 $dev3 +check mirror_no_temporaries $vg $lv1 +check mirror_legs $vg $lv1 3 + +# "remove from original mirror (the original becomes linear)" +aux prepare_vg 5 +lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0 +lvconvert -m+1 -b $vg/$lv1 $dev4 +lvconvert -m-1 $vg/$lv1 $dev2 +lvconvert $vg/$lv1 + +check mirror $vg $lv1 $dev3 +check mirror_no_temporaries $vg $lv1 +check mirror_legs $vg $lv1 2 + +# --------------------------------------------------------------------- + +# "rhbz440405: lvconvert -m0 incorrectly fails if all PEs allocated" +aux prepare_vg 5 +lvcreate -l`pvs --noheadings -ope_count $dev1` -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0 +while [ `lvs --noheadings -o copy_percent $vg/$lv1` != "100.00" ]; do sleep 1; done +lvconvert -m0 $vg/$lv1 $dev1 +check linear $vg $lv1 + +# "rhbz264241: lvm mirror doesn't lose it's "M" --nosync attribute after being down and the up converted" +aux prepare_vg 5 +lvcreate -l2 -m1 -n$lv1 --nosync $vg +lvconvert -m0 $vg/$lv1 +lvconvert -m1 $vg/$lv1 +lvs --noheadings -o attr $vg/$lv1 | grep '^ *m' + +# lvconvert from linear (on multiple PVs) to mirror +aux prepare_vg 5 +lvcreate -l 8 -n $lv1 $vg $dev1:0-3 $dev2:0-3 +lvconvert -m1 $vg/$lv1 + +should check mirror $vg $lv1 +check mirror_legs $vg $lv1 2 + +# BZ 463272: disk log mirror convert option is lost if downconvert option is also given +aux prepare_vg 5 +lvcreate -l1 -m2 --corelog -n $lv1 $vg $dev1 $dev2 $dev3 +lvconvert -m1 --mirrorlog disk $vg/$lv1 $dev1 +check mirror $vg $lv1 $dev1 + +# --- +# add mirror and disk log + +# "add 1 mirror and disk log" +aux prepare_vg 5 +lvcreate -l2 -m1 --mirrorlog core -n $lv1 $vg $dev1 $dev2 + +# FIXME on next line, specifying $dev3:0 $dev4 (i.e log device first) fails (!) +lvconvert -m+1 --mirrorlog disk -i1 $vg/$lv1 $dev4 $dev3:0 + +check mirror $vg $lv1 $dev3 +check mirror_no_temporaries $vg $lv1 +check mirror_legs $vg $lv1 3 --- LVM2/test/t-lvcreate-mirror.sh 2010/04/12 19:16:24 1.1 +++ LVM2/test/t-lvcreate-mirror.sh 2010/05/12 10:08:36 1.2 @@ -20,13 +20,13 @@ # 2-way mirror with disklog, 3 PVs lvcreate -l2 -m1 -n $lv1 $vg $dev1 $dev2 $dev3:0-1 check mirror_images_redundant $vg $lv1 -check mirror_log_on $vg/$lv1 $dev3 +check mirror_log_on $vg $lv1 $dev3 lvremove -ff $vg # 3-way mirror with disklog, 4 PVs lvcreate -l2 -m2 --mirrorlog disk -n $lv1 $vg $dev1 $dev2 $dev4 $dev3:0-1 check mirror_images_redundant $vg $lv1 -check mirror_log_on $vg/$lv1 $dev3 +check mirror_log_on $vg $lv1 $dev3 lvremove -ff $vg # lvcreate --nosync is in 100% sync after creation (bz429342) --- LVM2/test/t-vgcreate-usage.sh 2009/12/28 18:33:04 1.14 +++ LVM2/test/t-vgcreate-usage.sh 2010/05/12 10:08:36 1.15 @@ -17,6 +17,8 @@ pvcreate $dev1 $dev2 pvcreate --metadatacopies 0 $dev3 +vg=${PREFIX}vg + #COMM 'vgcreate accepts 8.00m physicalextentsize for VG' vgcreate -c n $vg --physicalextentsize 8.00m $dev1 $dev2 check_vg_field_ $vg vg_extent_size 8.00m --- LVM2/test/test-utils.sh 2010/05/06 18:54:52 1.39 +++ LVM2/test/test-utils.sh 2010/05/12 10:08:36 1.40 @@ -94,7 +94,7 @@ trap_teardown TESTDIR=$($abs_srcdir/mkdtemp ${LVM_TEST_DIR-$(pwd)} $PREFIX.XXXXXXXXXX) \ - || { echo "failed to create temporary directory in $test_dir_"; exit 1; } + || { echo "failed to create temporary directory in ${LVM_TEST_DIR-$(pwd)}"; exit 1; } export LVM_SYSTEM_DIR=$TESTDIR/etc export DM_DEV_DIR=$TESTDIR/dev @@ -131,6 +131,7 @@ test -n "$LOOPFILE" && rm -f $LOOPFILE fi unset devs # devs is set in prepare_devs() + unset LOOP } teardown() { @@ -178,7 +179,7 @@ trap_teardown for i in 0 1 2 3 4 5 6 7; do - mknod $DM_DEV_DIR/loop$i b 7 $i + test -e $DM_DEV_DIR/loop$i || mknod $DM_DEV_DIR/loop$i b 7 $i done LOOPFILE="$PWD/test.img" @@ -291,16 +292,6 @@ local name="${PREFIX}$pvname$i" dmsetup table $name done - - # set up some default names - vg=${PREFIX}vg - vg1=${PREFIX}vg1 - vg2=${PREFIX}vg2 - lv=LV - lv1=LV1 - lv2=LV2 - lv3=LV3 - lv4=LV4 } disable_dev() { @@ -346,10 +337,13 @@ prepare_pvs() { prepare_devs "$@" - pvcreate $devs + pvcreate -ff $devs } prepare_vg() { + vgremove -ff $vg || true + teardown_devs + prepare_pvs "$@" vgcreate -c n $vg $devs pvs -v @@ -400,6 +394,16 @@ prepare_testroot prepare_lvmconf prepare_clvmd + + # set up some default names + vg=${PREFIX}vg + vg1=${PREFIX}vg1 + vg2=${PREFIX}vg2 + lv=LV + lv1=LV1 + lv2=LV2 + lv3=LV3 + lv4=LV4 } LANG=C From mornfall@sourceware.org Wed May 12 11:23:00 2010 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Wed, 12 May 2010 11:23:00 -0000 Subject: LVM2/test Makefile.in harness.c t-lvconvert-re ... Message-ID: <20100512112316.18651.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2010-05-12 11:23:16 Modified files: test : Makefile.in harness.c t-lvconvert-repair-dmeventd.sh test-utils.sh Log message: Revert the "repeat failed tests with -vvvv" feature. Instead, dump debug logs to a file using log/file, with log/overwrite set and dump this file in STACKTRACE. The overall effect is that only the command that ran last before the failure has been triggered will get its debug output logged. This is similar to how we treat coredumps. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/Makefile.in.diff?cvsroot=lvm2&r1=1.40&r2=1.41 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/harness.c.diff?cvsroot=lvm2&r1=1.11&r2=1.12 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvconvert-repair-dmeventd.sh.diff?cvsroot=lvm2&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/test-utils.sh.diff?cvsroot=lvm2&r1=1.40&r2=1.41 --- LVM2/test/Makefile.in 2010/05/06 18:54:51 1.40 +++ LVM2/test/Makefile.in 2010/05/12 11:23:16 1.41 @@ -84,6 +84,7 @@ LDLPATH="$$LDLPATH:\$$abs_top_builddir/daemons/dmeventd/plugins/mirror"; \ LDLPATH="$$LDLPATH:\$$abs_top_builddir/daemons/dmeventd/plugins/snapshot"; \ echo "export LD_LIBRARY_PATH=\"$$LDLPATH\"" >> $@-t + echo 'top_srcdir=$(top_srcdir)' >> $@-t echo 'abs_srcdir=$(abs_srcdir)' >> $@-t echo 'abs_builddir=$(abs_builddir)' >> $@-t echo 'export PATH' >> $@-t --- LVM2/test/harness.c 2010/04/30 14:33:39 1.11 +++ LVM2/test/harness.c 2010/05/12 11:23:16 1.12 @@ -20,7 +20,6 @@ }; struct stats s; -struct stats backup; char *readbuf = NULL; int readbuf_sz = 0, readbuf_used = 0; @@ -142,7 +141,6 @@ int main(int argc, char **argv) { int i; - int repeat = getenv("LVM_TEST_NOVERBOSE") ? 0 : 1; if (argc >= MAX) { fprintf(stderr, "Sorry, my head exploded. Please increase MAX.\n"); @@ -178,13 +176,6 @@ run(i, argv[i]); if (die) break; - if ( repeat && s.status[i] == FAILED ) { - backup = s; - setenv("LVM_TEST_CONFIG", config_debug, 1); - run(i, argv[i]); - setenv("LVM_TEST_CONFIG", config, 1); - s = backup; - } } printf("\n## %d tests: %d OK, %d warnings, %d failures; %d skipped\n", --- LVM2/test/t-lvconvert-repair-dmeventd.sh 2010/05/06 19:01:26 1.1 +++ LVM2/test/t-lvconvert-repair-dmeventd.sh 2010/05/12 11:23:16 1.2 @@ -20,7 +20,7 @@ lvchange --monitor y $vg/4way disable_dev $dev2 $dev4 mkfs.ext2 $DM_DEV_DIR/$vg/4way -sleep 3 # FIXME : - ( +sleep 3 # FIXME: need a "poll" utility, akin to "check" enable_dev $dev2 $dev4 check mirror $vg 4way check mirror_legs $vg 4way 2 --- LVM2/test/test-utils.sh 2010/05/12 10:08:36 1.40 +++ LVM2/test/test-utils.sh 2010/05/12 11:23:16 1.41 @@ -17,23 +17,27 @@ STACKTRACE() { trap - ERR; i=0; + while FUNC=${FUNCNAME[$i]}; test "$FUNC" != "main"; do echo "$i ${FUNC}() called from ${BASH_SOURCE[$i]}:${BASH_LINENO[$i]}" i=$(($i + 1)); done # Get backtraces from coredumps - TEST_LVM_BINARY=$(dirname $(which lvm))/../../tools/lvm if which gdb >& /dev/null; then echo bt full > gdb_commands.txt echo l >> gdb_commands.txt echo quit >> gdb_commands.txt - for core in core*; do + for core in `ls core* 2>/dev/null`; do bin=$(gdb -batch -c $core 2>&1 | grep "generated by" | \ sed -e "s,.*generated by \`\([^ ']*\).*,\1,") gdb -batch -c $core -x gdb_commands.txt `which $bin` done fi + + test -f debug.log && { + sed -e "s,^,## DEBUG: ,;s,$top_srcdir/\?,," < debug.log + } } init_udev_transaction() { @@ -367,6 +371,9 @@ log { syslog = 0 indent = 1 + level = 4 + file = "$TESTDIR/debug.log" + overwrite = 1 } backup { backup = 0 From mornfall@sourceware.org Wed May 12 11:58:00 2010 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Wed, 12 May 2010 11:58:00 -0000 Subject: LVM2/test test-utils.sh Message-ID: <20100512115858.4203.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2010-05-12 11:58:54 Modified files: test : test-utils.sh Log message: Bump the debug.log level from 4 to 9 (the numbering is different from verbose). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/test-utils.sh.diff?cvsroot=lvm2&r1=1.41&r2=1.42 --- LVM2/test/test-utils.sh 2010/05/12 11:23:16 1.41 +++ LVM2/test/test-utils.sh 2010/05/12 11:58:51 1.42 @@ -371,7 +371,7 @@ log { syslog = 0 indent = 1 - level = 4 + level = 9 file = "$TESTDIR/debug.log" overwrite = 1 } From mornfall@sourceware.org Wed May 12 11:59:00 2010 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Wed, 12 May 2010 11:59:00 -0000 Subject: LVM2/test Makefile.in Message-ID: <20100512115949.6205.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2010-05-12 11:59:46 Modified files: test : Makefile.in Log message: Run tests in alphabetical (and thus stable across machines) order. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/Makefile.in.diff?cvsroot=lvm2&r1=1.41&r2=1.42 --- LVM2/test/Makefile.in 2010/05/12 11:23:16 1.41 +++ LVM2/test/Makefile.in 2010/05/12 11:59:46 1.42 @@ -26,7 +26,7 @@ abs_top_srcdir = @abs_top_srcdir@ T ?= . -RUN = $(shell find -regextype posix-egrep -name t-\*.sh -and -regex ".*($(T)).*") +RUN = $(shell find -regextype posix-egrep -name t-\*.sh -and -regex ".*($(T)).*" | sort) # Shell quote; SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) From mornfall@sourceware.org Wed May 12 13:15:00 2010 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Wed, 12 May 2010 13:15:00 -0000 Subject: LVM2/test t-lvconvert-mirror-basic.sh t-lvconv ... Message-ID: <20100512131539.28715.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2010-05-12 13:15:38 Modified files: test : t-lvconvert-mirror-basic.sh Added files: test : t-lvconvert-mirror-basic-0.sh t-lvconvert-mirror-basic-1.sh t-lvconvert-mirror-basic-2.sh t-lvconvert-mirror-basic-3.sh Log message: Chop up the big t-lvconvert-mirror-basic loop across 4 separate test scripts (and use sourcing to avoid code duplication). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvconvert-mirror-basic-0.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvconvert-mirror-basic-1.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvconvert-mirror-basic-2.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvconvert-mirror-basic-3.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvconvert-mirror-basic.sh.diff?cvsroot=lvm2&r1=1.1&r2=1.2 /cvs/lvm2/LVM2/test/t-lvconvert-mirror-basic-0.sh,v --> standard output revision 1.1 --- LVM2/test/t-lvconvert-mirror-basic-0.sh +++ - 2010-05-12 13:15:39.141989000 +0000 @@ -0,0 +1,2 @@ +. ./t-lvconvert-mirror-basic.sh +test_many 0 /cvs/lvm2/LVM2/test/t-lvconvert-mirror-basic-1.sh,v --> standard output revision 1.1 --- LVM2/test/t-lvconvert-mirror-basic-1.sh +++ - 2010-05-12 13:15:39.225899000 +0000 @@ -0,0 +1,2 @@ +. ./t-lvconvert-mirror-basic.sh +test_many 1 /cvs/lvm2/LVM2/test/t-lvconvert-mirror-basic-2.sh,v --> standard output revision 1.1 --- LVM2/test/t-lvconvert-mirror-basic-2.sh +++ - 2010-05-12 13:15:39.310482000 +0000 @@ -0,0 +1,2 @@ +. ./t-lvconvert-mirror-basic.sh +test_many 2 /cvs/lvm2/LVM2/test/t-lvconvert-mirror-basic-3.sh,v --> standard output revision 1.1 --- LVM2/test/t-lvconvert-mirror-basic-3.sh +++ - 2010-05-12 13:15:39.395233000 +0000 @@ -0,0 +1,2 @@ +. ./t-lvconvert-mirror-basic.sh +test_many 3 --- LVM2/test/t-lvconvert-mirror-basic.sh 2010/05/12 10:08:35 1.1 +++ LVM2/test/t-lvconvert-mirror-basic.sh 2010/05/12 13:15:38 1.2 @@ -121,9 +121,9 @@ aux prepare_vg 5 -# Test conversion combinations from linear <-> 4-way mirrors -for i in $(seq 0 4); do - for j in $(seq 0 4); do +test_many() { + i=$1 + for j in $(seq 0 3); do for k in core disk mirrored; do for l in core disk mirrored; do if test "$i" -eq "$j" && test "$k" = "$l"; then continue; fi @@ -135,5 +135,4 @@ done done done -done - +} From mbroz@sourceware.org Thu May 13 13:04:00 2010 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Thu, 13 May 2010 13:04:00 -0000 Subject: LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/comm ... Message-ID: <20100513130406.11244.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2010-05-13 13:04:06 Modified files: . : WHATS_NEW lib/cache : lvmcache.c lib/commands : toolcontext.c lib/filters : filter-persistent.c filter-persistent.h Log message: Currently if clvmd is running and user issues vgscan, the device cache file is dumped both in vgscan and clvmd process. Unfortunately, clvmd calls lvmcache_label_scan, it properly destroys persistent filter, but during persistent_filter_dump it merges old cache content back! This causes that change in filters is not properly propagated into device cache after vgscan on cluster. (Only new devices are added.) https://bugzilla.redhat.com/show_bug.cgi?id=591861 Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1555&r2=1.1556 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.85&r2=1.86 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.96&r2=1.97 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter-persistent.c.diff?cvsroot=lvm2&r1=1.40&r2=1.41 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter-persistent.h.diff?cvsroot=lvm2&r1=1.6&r2=1.7 --- LVM2/WHATS_NEW 2010/05/11 08:57:02 1.1555 +++ LVM2/WHATS_NEW 2010/05/13 13:04:03 1.1556 @@ -1,5 +1,6 @@ Version 2.02.65 - ================================= + Do not merge old device cache after we run full scan. (2.02.56) Add pkgconfigdir Makefile variable for make install override. Switch usage of Libs.private: to Requires.private: in devmapper.pc, lvm2app.pc. Use field Requires.private: for devmapper-event.pc. --- LVM2/lib/cache/lvmcache.c 2010/04/30 12:54:31 1.85 +++ LVM2/lib/cache/lvmcache.c 2010/05/13 13:04:05 1.86 @@ -567,7 +567,7 @@ * device cache for the benefit of short-lived processes. */ if (full_scan == 2 && cmd->is_long_lived && cmd->dump_filter) - persistent_filter_dump(cmd->filter); + persistent_filter_dump(cmd->filter, 0); r = 1; --- LVM2/lib/commands/toolcontext.c 2010/05/05 22:37:52 1.96 +++ LVM2/lib/commands/toolcontext.c 2010/05/13 13:04:05 1.97 @@ -1341,7 +1341,7 @@ void destroy_toolcontext(struct cmd_context *cmd) { if (cmd->dump_filter) - persistent_filter_dump(cmd->filter); + persistent_filter_dump(cmd->filter, 1); archive_exit(cmd); backup_exit(cmd); --- LVM2/lib/filters/filter-persistent.c 2010/01/06 13:25:36 1.40 +++ LVM2/lib/filters/filter-persistent.c 2010/05/13 13:04:05 1.41 @@ -168,7 +168,7 @@ fprintf(fp, "\n\t]\n"); } -int persistent_filter_dump(struct dev_filter *f) +int persistent_filter_dump(struct dev_filter *f, int merge_existing) { struct pfilter *pf; char *tmp_file; @@ -220,7 +220,7 @@ /* * If file contents changed since we loaded it, merge new contents */ - if (info.st_ctime != pf->ctime) + if (merge_existing && info.st_ctime != pf->ctime) /* Keep cft open to avoid losing lock */ persistent_filter_load(f, &cft); --- LVM2/lib/filters/filter-persistent.h 2007/08/20 20:55:25 1.6 +++ LVM2/lib/filters/filter-persistent.h 2010/05/13 13:04:05 1.7 @@ -23,6 +23,6 @@ int persistent_filter_wipe(struct dev_filter *f); int persistent_filter_load(struct dev_filter *f, struct config_tree **cft_out); -int persistent_filter_dump(struct dev_filter *f); +int persistent_filter_dump(struct dev_filter *f, int merge_existing); #endif From mbroz@sourceware.org Thu May 13 13:31:00 2010 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Thu, 13 May 2010 13:31:00 -0000 Subject: LVM2 ./WHATS_NEW_DM libdm/ioctl/libdm-iface.c Message-ID: <20100513133131.19610.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2010-05-13 13:31:30 Modified files: . : WHATS_NEW_DM libdm/ioctl : libdm-iface.c Log message: Do not print encryption key in message debug output. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.367&r2=1.368 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/ioctl/libdm-iface.c.diff?cvsroot=lvm2&r1=1.73&r2=1.74 --- LVM2/WHATS_NEW_DM 2010/04/30 15:48:39 1.367 +++ LVM2/WHATS_NEW_DM 2010/05/13 13:31:30 1.368 @@ -1,5 +1,6 @@ Version 1.02.48 - ================================= + Do not print encryption key in message debug output (cryptsetup luksResume). Version 1.02.47 - 30th April 2010 ================================= --- LVM2/libdm/ioctl/libdm-iface.c 2010/05/03 22:08:38 1.73 +++ LVM2/libdm/ioctl/libdm-iface.c 2010/05/13 13:31:30 1.74 @@ -1102,7 +1102,7 @@ int dm_task_set_message(struct dm_task *dmt, const char *message) { if (!(dmt->message = dm_strdup(message))) { - log_error("dm_task_set_message: strdup(%s) failed", message); + log_error("dm_task_set_message: strdup failed"); return 0; } @@ -1724,6 +1724,18 @@ return r; } +static const char *_sanitise_message(char *message) +{ + const char *sanitised_message = message ?: ""; + + /* FIXME: Check for whitespace variations. */ + /* This traps what cryptsetup sends us. */ + if (message && !strncasecmp(message, "key set", 7)) + sanitised_message = "key set"; + + return sanitised_message; +} + static struct dm_ioctl *_do_dm_ioctl(struct dm_task *dmt, unsigned command, unsigned repeat_count) { @@ -1805,7 +1817,7 @@ dmt->no_flush ? 'N' : 'F', dmt->skip_lockfs ? "S " : "", dmt->query_inactive_table ? "I " : "", - dmt->sector, dmt->message ? dmt->message : "", + dmt->sector, _sanitise_message(dmt->message), dmi->data_size); #ifdef DM_IOCTLS if (ioctl(_control_fd, command, dmi) < 0) { From mbroz@sourceware.org Thu May 13 18:38:00 2010 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Thu, 13 May 2010 18:38:00 -0000 Subject: LVM2 ./WHATS_NEW lib/activate/activate.h lib/a ... Message-ID: <20100513183841.1542.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2010-05-13 18:38:40 Modified files: . : WHATS_NEW lib/activate : activate.h dev_manager.c lib/filters : filter.c Log message: Skip also special lvm devices in scan (if ignore suspended is used). This should avoid various races between dmeventd on multiple nodes in cluster where one node already repairing device and another run full scan and locks the device. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1556&r2=1.1557 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.66&r2=1.67 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.187&r2=1.188 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter.c.diff?cvsroot=lvm2&r1=1.51&r2=1.52 --- LVM2/WHATS_NEW 2010/05/13 13:04:03 1.1556 +++ LVM2/WHATS_NEW 2010/05/13 18:38:38 1.1557 @@ -1,5 +1,6 @@ Version 2.02.65 - ================================= + Skip internal lvm devices in scan if ignore suspended devices is requested. Do not merge old device cache after we run full scan. (2.02.56) Add pkgconfigdir Makefile variable for make install override. Switch usage of Libs.private: to Requires.private: in devmapper.pc, lvm2app.pc. --- LVM2/lib/activate/activate.h 2010/04/23 02:57:41 1.66 +++ LVM2/lib/activate/activate.h 2010/05/13 18:38:38 1.67 @@ -110,6 +110,6 @@ /* * Returns 1 if mapped device is not suspended. */ -int device_is_usable(dev_t dev); +int device_is_usable(struct device *dev); #endif --- LVM2/lib/activate/dev_manager.c 2010/04/23 14:16:33 1.187 +++ LVM2/lib/activate/dev_manager.c 2010/05/13 18:38:38 1.188 @@ -126,11 +126,11 @@ return r; } -int device_is_usable(dev_t dev) +int device_is_usable(struct device *dev) { struct dm_task *dmt; struct dm_info info; - const char *name; + const char *name, *uuid; uint64_t start, length; char *target_type = NULL; char *params; @@ -142,7 +142,7 @@ return 0; } - if (!dm_task_set_major_minor(dmt, MAJOR(dev), MINOR(dev), 1)) + if (!dm_task_set_major_minor(dmt, MAJOR(dev->dev), MINOR(dev->dev), 1)) goto_out; if (!dm_task_run(dmt)) { @@ -157,6 +157,7 @@ goto out; name = dm_task_get_name(dmt); + uuid = dm_task_get_uuid(dmt); /* FIXME Also check for mirror block_on_error and mpath no paths */ /* For now, we exclude all mirrors */ @@ -165,12 +166,21 @@ next = dm_get_next_target(dmt, next, &start, &length, &target_type, ¶ms); /* Skip if target type doesn't match */ - if (target_type && !strcmp(target_type, "mirror")) + if (target_type && !strcmp(target_type, "mirror")) { + log_debug("%s: Mirror device not usable.", dev_name(dev)); goto out; + } } while (next); /* FIXME Also check dependencies? */ + /* Check internal lvm devices */ + if (is_reserved_lvname(name) && uuid && + !strncmp(uuid, UUID_PREFIX, sizeof(UUID_PREFIX) - 1)) { + log_debug("%s: Reserved internal LVM device not usable.", dev_name(dev)); + goto out; + } + r = 1; out: --- LVM2/lib/filters/filter.c 2009/12/11 13:16:38 1.51 +++ LVM2/lib/filters/filter.c 2010/05/13 18:38:40 1.52 @@ -132,8 +132,8 @@ /* Skip suspended devices */ if (MAJOR(dev->dev) == _device_mapper_major && - ignore_suspended_devices() && !device_is_usable(dev->dev)) { - log_debug("%s: Skipping: Suspended dm device", name); + ignore_suspended_devices() && !device_is_usable(dev)) { + log_debug("%s: Skipping: Suspended or internal dm device", name); return 0; } From zkabelac@sourceware.org Fri May 14 11:33:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 14 May 2010 11:33:00 -0000 Subject: LVM2 ./WHATS_NEW scripts/clvmd_fix_conf.sh scr ... Message-ID: <20100514113330.6342.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-14 11:33:21 Modified files: . : WHATS_NEW scripts : clvmd_fix_conf.sh fsadm.sh last_cvs_update.sh lvmconf.sh lvmconf_lockingtype2.sh vgimportclone.sh Log message: Use /bin/bash for scripts with bashisms Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1557&r2=1.1558 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/clvmd_fix_conf.sh.diff?cvsroot=lvm2&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/fsadm.sh.diff?cvsroot=lvm2&r1=1.11&r2=1.12 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/last_cvs_update.sh.diff?cvsroot=lvm2&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/lvmconf.sh.diff?cvsroot=lvm2&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/lvmconf_lockingtype2.sh.diff?cvsroot=lvm2&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/vgimportclone.sh.diff?cvsroot=lvm2&r1=1.2&r2=1.3 --- LVM2/WHATS_NEW 2010/05/13 18:38:38 1.1557 +++ LVM2/WHATS_NEW 2010/05/14 11:33:20 1.1558 @@ -1,5 +1,6 @@ Version 2.02.65 - ================================= + Use /bin/bash for scripts with bashisms. Skip internal lvm devices in scan if ignore suspended devices is requested. Do not merge old device cache after we run full scan. (2.02.56) Add pkgconfigdir Makefile variable for make install override. --- LVM2/scripts/clvmd_fix_conf.sh 2004/12/01 14:47:31 1.2 +++ LVM2/scripts/clvmd_fix_conf.sh 2010/05/14 11:33:21 1.3 @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Edit an lvm.conf file to enable cluster locking. # --- LVM2/scripts/fsadm.sh 2009/06/09 15:31:36 1.11 +++ LVM2/scripts/fsadm.sh 2010/05/14 11:33:21 1.12 @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Copyright (C) 2007-2009 Red Hat, Inc. All rights reserved. # --- LVM2/scripts/last_cvs_update.sh 2001/08/15 16:20:45 1.1 +++ LVM2/scripts/last_cvs_update.sh 2010/05/14 11:33:21 1.2 @@ -1,5 +1,5 @@ -#!/bin/sh -#$Header: /cvs/lvm2/LVM2/scripts/last_cvs_update.sh,v 1.1 2001/08/15 16:20:45 lewis Exp $ +#!/bin/bash +#$Header: /cvs/lvm2/LVM2/scripts/last_cvs_update.sh,v 1.2 2010/05/14 11:33:21 zkabelac Exp $ ################################################################################ ## ## Copyright 2001 Sistina Software, Inc. --- LVM2/scripts/lvmconf.sh 2009/11/27 14:32:16 1.5 +++ LVM2/scripts/lvmconf.sh 2010/05/14 11:33:21 1.6 @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. # --- LVM2/scripts/lvmconf_lockingtype2.sh 2009/11/27 14:32:16 1.1 +++ LVM2/scripts/lvmconf_lockingtype2.sh 2010/05/14 11:33:21 1.2 @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. # --- LVM2/scripts/vgimportclone.sh 2009/06/17 15:47:01 1.2 +++ LVM2/scripts/vgimportclone.sh 2010/05/14 11:33:21 1.3 @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Copyright (C) 2009 Chris Procter All rights reserved. # Copyright (C) 2009 Red Hat, Inc. All rights reserved. From mbroz@sourceware.org Fri May 14 12:03:00 2010 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Fri, 14 May 2010 12:03:00 -0000 Subject: LVM2/lib/activate dev_manager.c Message-ID: <20100514120333.1313.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2010-05-14 12:03:32 Modified files: lib/activate : dev_manager.c Log message: Fix device_is_usable to properly detect only internal LV names. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.188&r2=1.189 --- LVM2/lib/activate/dev_manager.c 2010/05/13 18:38:38 1.188 +++ LVM2/lib/activate/dev_manager.c 2010/05/14 12:03:32 1.189 @@ -133,7 +133,7 @@ const char *name, *uuid; uint64_t start, length; char *target_type = NULL; - char *params; + char *params, *vgname = NULL, *lvname, *layer; void *next = NULL; int r = 0; @@ -175,15 +175,23 @@ /* FIXME Also check dependencies? */ /* Check internal lvm devices */ - if (is_reserved_lvname(name) && uuid && - !strncmp(uuid, UUID_PREFIX, sizeof(UUID_PREFIX) - 1)) { - log_debug("%s: Reserved internal LVM device not usable.", dev_name(dev)); - goto out; + if (uuid && !strncmp(uuid, UUID_PREFIX, sizeof(UUID_PREFIX) - 1)) { + if (!(vgname = dm_strdup(name)) || + !dm_split_lvm_name(NULL, NULL, &vgname, &lvname, &layer)) + goto_out; + + if (lvname && (is_reserved_lvname(lvname) || layer)) { + log_debug("%s: Reserved internal LV device %s/%s%s%s not usable.", + dev_name(dev), vgname, lvname, layer ? "-" : "", + layer ?: ""); + goto out; + } } r = 1; out: + dm_free(vgname); dm_task_destroy(dmt); return r; } From mbroz@sourceware.org Fri May 14 12:30:00 2010 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Fri, 14 May 2010 12:30:00 -0000 Subject: LVM2/lib/activate dev_manager.c Message-ID: <20100514123045.31048.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2010-05-14 12:30:45 Modified files: lib/activate : dev_manager.c Log message: Fix empty layer detection is scan devices. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.189&r2=1.190 --- LVM2/lib/activate/dev_manager.c 2010/05/14 12:03:32 1.189 +++ LVM2/lib/activate/dev_manager.c 2010/05/14 12:30:43 1.190 @@ -180,7 +180,7 @@ !dm_split_lvm_name(NULL, NULL, &vgname, &lvname, &layer)) goto_out; - if (lvname && (is_reserved_lvname(lvname) || layer)) { + if (lvname && (is_reserved_lvname(lvname) || (layer && *layer))) { log_debug("%s: Reserved internal LV device %s/%s%s%s not usable.", dev_name(dev), vgname, lvname, layer ? "-" : "", layer ?: ""); From mbroz@sourceware.org Fri May 14 12:39:00 2010 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Fri, 14 May 2010 12:39:00 -0000 Subject: LVM2/lib/activate dev_manager.c Message-ID: <20100514123953.1912.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2010-05-14 12:39:52 Modified files: lib/activate : dev_manager.c Log message: Another one internal device layer fix... Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.190&r2=1.191 --- LVM2/lib/activate/dev_manager.c 2010/05/14 12:30:43 1.190 +++ LVM2/lib/activate/dev_manager.c 2010/05/14 12:39:52 1.191 @@ -180,10 +180,9 @@ !dm_split_lvm_name(NULL, NULL, &vgname, &lvname, &layer)) goto_out; - if (lvname && (is_reserved_lvname(lvname) || (layer && *layer))) { + if (lvname && (is_reserved_lvname(lvname) || *layer)) { log_debug("%s: Reserved internal LV device %s/%s%s%s not usable.", - dev_name(dev), vgname, lvname, layer ? "-" : "", - layer ?: ""); + dev_name(dev), vgname, lvname, *layer ? "-" : "", layer); goto out; } } From zkabelac@sourceware.org Fri May 14 13:32:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 14 May 2010 13:32:00 -0000 Subject: LVM2 make.tmpl.in Message-ID: <20100514133236.1235.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-14 13:32:36 Modified files: . : make.tmpl.in Log message: For lcov target there is no need to include source file dependencies Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/make.tmpl.in.diff?cvsroot=lvm2&r1=1.97&r2=1.98 --- LVM2/make.tmpl.in 2010/05/11 08:57:02 1.97 +++ LVM2/make.tmpl.in 2010/05/14 13:32:36 1.98 @@ -350,7 +350,7 @@ sed "s/^/ /;s/$$/;/" < $<; \ echo " local:"; echo " *;"; echo "};") > $@ -ifeq (,$(findstring $(MAKECMDGOALS),cscope.out cflow clean distclean)) +ifeq (,$(findstring $(MAKECMDGOALS),cscope.out cflow clean distclean lcov)) ifdef SOURCES -include $(SOURCES:.c=.d) endif From agk@sourceware.org Fri May 14 13:36:00 2010 From: agk@sourceware.org (agk@sourceware.org) Date: Fri, 14 May 2010 13:36:00 -0000 Subject: LVM2/daemons/dmeventd Makefile.in Message-ID: <20100514133656.5924.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-05-14 13:36:56 Modified files: daemons/dmeventd: Makefile.in Log message: Fix static build. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/Makefile.in.diff?cvsroot=lvm2&r1=1.43&r2=1.44 --- LVM2/daemons/dmeventd/Makefile.in 2010/05/11 08:57:02 1.43 +++ LVM2/daemons/dmeventd/Makefile.in 2010/05/14 13:36:56 1.44 @@ -62,7 +62,7 @@ dmeventd.static: $(LIB_STATIC) dmeventd.o $(interfacebuilddir)/libdevmapper.a $(CC) $(CFLAGS) $(LDFLAGS) -static -L. -L$(interfacebuilddir) -o $@ \ - dmeventd.o $(DL_LIBS) $(LVMLIBS) $(STATIC_LIBS) $(LIBS) + dmeventd.o $(DL_LIBS) $(LVMLIBS) $(LIBS) $(STATIC_LIBS) ifeq ("@PKGCONFIG@", "yes") INSTALL_LIB_TARGETS += install_pkgconfig From agk@sourceware.org Fri May 14 14:56:00 2010 From: agk@sourceware.org (agk@sourceware.org) Date: Fri, 14 May 2010 14:56:00 -0000 Subject: LVM2 ./WHATS_NEW_DM daemons/dmeventd/dmeventd. ... Message-ID: <20100514145640.17416.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-05-14 14:56:40 Modified files: . : WHATS_NEW_DM daemons/dmeventd: dmeventd.c daemons/dmeventd/plugins/lvm2: dmeventd_lvm.c daemons/dmeventd/plugins/mirror: dmeventd_mirror.c test : test-utils.sh Log message: Use -d to control level of messages sent to syslog by dmeventd. Change -d to -f to run dmeventd in foreground. (mornfall) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.368&r2=1.369 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/dmeventd.c.diff?cvsroot=lvm2&r1=1.61&r2=1.62 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c.diff?cvsroot=lvm2&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c.diff?cvsroot=lvm2&r1=1.34&r2=1.35 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/test-utils.sh.diff?cvsroot=lvm2&r1=1.42&r2=1.43 --- LVM2/WHATS_NEW_DM 2010/05/13 13:31:30 1.368 +++ LVM2/WHATS_NEW_DM 2010/05/14 14:56:39 1.369 @@ -1,5 +1,7 @@ Version 1.02.48 - ================================= + Use -d to control level of messages sent to syslog by dmeventd. + Change -d to -f to run dmeventd in foreground. Do not print encryption key in message debug output (cryptsetup luksResume). Version 1.02.47 - 30th April 2010 --- LVM2/daemons/dmeventd/dmeventd.c 2010/04/14 18:54:37 1.61 +++ LVM2/daemons/dmeventd/dmeventd.c 2010/05/14 14:56:39 1.62 @@ -54,7 +54,6 @@ static volatile sig_atomic_t _exit_now = 0; /* set to '1' when signal is given to exit */ static volatile sig_atomic_t _thread_registries_empty = 1; /* registries are empty initially */ -static int _debug = 0; /* List (un)link macros. */ #define LINK(x, head) dm_list_add(head, &(x)->list) @@ -98,6 +97,9 @@ #define DEBUGLOG(fmt, args...) _debuglog(fmt, ## args) +int dmeventd_debug = 0; +static int _foreground = 0; + /* Data kept about a DSO. */ struct dso_data { struct dm_list list; @@ -204,7 +206,7 @@ time_t P; va_list ap; - if (!_debug) + if (!_foreground) return; va_start(ap,fmt); @@ -1662,11 +1664,12 @@ static void usage(char *prog, FILE *file) { fprintf(file, "Usage:\n"); - fprintf(file, "%s [Vhd]\n", prog); + fprintf(file, "%s [-V] [-h] [-d] [-d] [-d] [-f]\n", prog); fprintf(file, "\n"); fprintf(file, " -V Show version of dmeventd\n"); fprintf(file, " -h Show this help information\n"); - fprintf(file, " -d Don't fork, run in the foreground\n"); + fprintf(file, " -d Log debug messages to syslog (-d, -dd, -ddd)\n"); + fprintf(file, " -f Don't fork, run in the foreground\n"); fprintf(file, "\n"); } @@ -1680,7 +1683,7 @@ opterr = 0; optind = 0; - while ((opt = getopt(argc, argv, "?hVd")) != EOF) { + while ((opt = getopt(argc, argv, "?fhVd")) != EOF) { switch (opt) { case 'h': usage(argv[0], stdout); @@ -1688,8 +1691,11 @@ case '?': usage(argv[0], stderr); exit(0); + case 'f': + _foreground++; + break; case 'd': - _debug++; + dmeventd_debug++; break; case 'V': printf("dmeventd version: %s\n", DM_LIB_VERSION); @@ -1706,7 +1712,7 @@ if (setenv("LANG", "C", 1)) perror("Cannot set LANG to C"); - if (!_debug) + if (!_foreground) _daemonize(); openlog("dmeventd", LOG_PID, LOG_DAEMON); @@ -1738,7 +1744,7 @@ exit(EXIT_FIFO_FAILURE); /* Signal parent, letting them know we are ready to go. */ - if (!_debug) + if (!_foreground) kill(getppid(), SIGTERM); syslog(LOG_NOTICE, "dmeventd ready for processing."); --- LVM2/daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c 2010/03/30 14:38:56 1.2 +++ LVM2/daemons/dmeventd/plugins/lvm2/dmeventd_lvm.c 2010/05/14 14:56:39 1.3 @@ -13,6 +13,7 @@ */ #include "lib.h" +#include "log.h" #include "lvm2cmd.h" #include "errors.h" @@ -22,6 +23,8 @@ #include #include +extern int dmeventd_debug; + /* * register_device() is called first and performs initialisation. * Only one device may be registered or unregistered at a time. @@ -40,19 +43,41 @@ */ static pthread_mutex_t _event_mutex = PTHREAD_MUTEX_INITIALIZER; -/* FIXME Remove this: Pass messages back to dmeventd core for processing. */ +/* + * FIXME Do not pass things directly to syslog, rather use the existing logging + * facilities to sort logging ... however that mechanism needs to be somehow + * configurable and we don't have that option yet + */ static void _temporary_log_fn(int level, const char *file __attribute((unused)), int line __attribute((unused)), int dm_errno __attribute((unused)), - const char *format) + const char *message) { - level &= ~_LOG_STDERR; + level &= ~(_LOG_STDERR | _LOG_ONCE); - if (!strncmp(format, "WARNING: ", 9) && (level < 5)) - syslog(LOG_CRIT, "%s", format); - else - syslog(LOG_DEBUG, "%s", format); + switch (level) { + case _LOG_DEBUG: + if (dmeventd_debug >= 3) + syslog(LOG_DEBUG, "%s", message); + break; + case _LOG_INFO: + if (dmeventd_debug >= 2) + syslog(LOG_INFO, "%s", message); + break; + case _LOG_NOTICE: + if (dmeventd_debug >= 1) + syslog(LOG_NOTICE, "%s", message); + break; + case _LOG_WARN: + syslog(LOG_WARNING, "%s", message); + break; + case _LOG_ERR: + syslog(LOG_ERR, "%s", message); + break; + default: + syslog(LOG_CRIT, "%s", message); + } } void dmeventd_lvm2_lock(void) --- LVM2/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c 2010/05/11 08:32:22 1.34 +++ LVM2/daemons/dmeventd/plugins/mirror/dmeventd_mirror.c 2010/05/14 14:56:39 1.35 @@ -160,7 +160,8 @@ r = dmeventd_lvm2_run(cmd_str); - syslog(LOG_INFO, "Repair of mirrored LV %s/%s %s.", vg, lv, (r == ECMD_PROCESSED) ? "finished successfully" : "failed"); + syslog(LOG_INFO, "Repair of mirrored LV %s/%s %s.", vg, lv, + (r == ECMD_PROCESSED) ? "finished successfully" : "failed"); return (r == ECMD_PROCESSED) ? 0 : -1; } --- LVM2/test/test-utils.sh 2010/05/12 11:58:51 1.42 +++ LVM2/test/test-utils.sh 2010/05/14 14:56:40 1.43 @@ -87,9 +87,8 @@ trap_teardown - dmeventd -d & + dmeventd -f & LOCAL_DMEVENTD="$!" - strace -p $LOCAL_DMEVENTD & } prepare_testroot() { From jbrassow@sourceware.org Fri May 14 15:19:00 2010 From: jbrassow@sourceware.org (jbrassow@sourceware.org) Date: Fri, 14 May 2010 15:19:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/metadata-exporte ... Message-ID: <20100514151945.10315.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: jbrassow@sourceware.org 2010-05-14 15:19:43 Modified files: . : WHATS_NEW lib/metadata : metadata-exported.h metadata.c mirror.c Log message: Disallow toggling the cluster attribute of a volume group if there are active mirrors or snapshots. We don't have the mechanisms in place to change the device-mapper tables for those targets that have behavioral differences between cluster and single machine instances. Allowing users to change the attribute but not changing the target's behavior can lead to data corruption. The following bugs are fixed/avoided by this patch: 235123 - vgchange -c [ny] do not change target types when necessary 289331 - RFE: switching from cluster domain to local domain needs to deactivate volume somehow 289541 - when changing from local to cluster, volumes can not appear to be deactivated Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1558&r2=1.1559 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.143&r2=1.144 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.338&r2=1.339 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.116&r2=1.117 --- LVM2/WHATS_NEW 2010/05/14 11:33:20 1.1558 +++ LVM2/WHATS_NEW 2010/05/14 15:19:42 1.1559 @@ -1,5 +1,6 @@ Version 2.02.65 - ================================= + Disallow cluster attr toggling if there are active mirrors or snapshots. Use /bin/bash for scripts with bashisms. Skip internal lvm devices in scan if ignore suspended devices is requested. Do not merge old device cache after we run full scan. (2.02.56) --- LVM2/lib/metadata/metadata-exported.h 2010/04/23 19:27:10 1.143 +++ LVM2/lib/metadata/metadata-exported.h 2010/05/14 15:19:43 1.144 @@ -691,6 +691,7 @@ int is_temporary_mirror_layer(const struct logical_volume *lv); struct logical_volume * find_temporary_mirror(const struct logical_volume *lv); +int lv_is_mirrored(const struct logical_volume *lv); uint32_t lv_mirror_count(const struct logical_volume *lv); uint32_t adjusted_mirror_region_size(uint32_t extent_size, uint32_t extents, uint32_t region_size); --- LVM2/lib/metadata/metadata.c 2010/04/23 19:27:10 1.338 +++ LVM2/lib/metadata/metadata.c 2010/05/14 15:19:43 1.339 @@ -1208,8 +1208,19 @@ int vg_set_clustered(struct volume_group *vg, int clustered) { struct lv_list *lvl; - if (clustered) { - dm_list_iterate_items(lvl, &vg->lvs) { + + /* + * We do not currently support switching the cluster attribute + * on active mirrors or snapshots. + */ + dm_list_iterate_items(lvl, &vg->lvs) { + if (lv_is_mirrored(lvl->lv) && lv_is_active(lvl->lv)) { + log_error("Mirror logical volumes must be inactive " + "when changing the cluster attribute."); + return 0; + } + + if (clustered) { if (lv_is_origin(lvl->lv) || lv_is_cow(lvl->lv)) { log_error("Volume group %s contains snapshots " "that are not yet supported.", @@ -1217,6 +1228,13 @@ return 0; } } + + if ((lv_is_origin(lvl->lv) || lv_is_cow(lvl->lv)) && + lv_is_active(lvl->lv)) { + log_error("Snapshot logical volumes must be inactive " + "when changing the cluster attribute."); + return 0; + } } if (clustered) --- LVM2/lib/metadata/mirror.c 2010/04/27 15:26:59 1.116 +++ LVM2/lib/metadata/mirror.c 2010/05/14 15:19:43 1.117 @@ -72,6 +72,14 @@ return NULL; } +int lv_is_mirrored(const struct logical_volume *lv) +{ + if (lv->status & MIRRORED) + return 1; + + return 0; +} + /* * Returns the number of mirrors of the LV */ From fabbione@sourceware.org Mon May 17 03:18:00 2010 From: fabbione@sourceware.org (fabbione@sourceware.org) Date: Mon, 17 May 2010 03:18:00 -0000 Subject: LVM2 ./WHATS_NEW scripts/clvmd_init_red_hat.in Message-ID: <20100517031828.8171.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: fabbione@sourceware.org 2010-05-17 03:18:28 Modified files: . : WHATS_NEW scripts : clvmd_init_red_hat.in Log message: Fix clvmd init script stop function to not deactive non-clustered volume groups. https://bugzilla.redhat.com/show_bug.cgi?id=592362 Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1559&r2=1.1560 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/clvmd_init_red_hat.in.diff?cvsroot=lvm2&r1=1.6&r2=1.7 --- LVM2/WHATS_NEW 2010/05/14 15:19:42 1.1559 +++ LVM2/WHATS_NEW 2010/05/17 03:18:27 1.1560 @@ -1,5 +1,6 @@ Version 2.02.65 - ================================= + Fix clvmd init script to not deactive non-clustered volume groups. Disallow cluster attr toggling if there are active mirrors or snapshots. Use /bin/bash for scripts with bashisms. Skip internal lvm devices in scan if ignore suspended devices is requested. --- LVM2/scripts/clvmd_init_red_hat.in 2010/04/20 14:07:38 1.6 +++ LVM2/scripts/clvmd_init_red_hat.in 2010/05/17 03:18:28 1.7 @@ -109,7 +109,10 @@ { rh_status_q || return 0 - action "Deactivating clusterd VG(s):" ${lvm_vgchange} -anl ${LVM_VGS:-$(clustered_vgs)} || return $? + [ -z "$LVM_VGS" ] && LVM_VGS="$(clustered_vgs)" + if [ -n "$LVM_VGS" ]; then + action "Deactivating clustered VG(s):" ${lvm_vgchange} -anl $LVM_VGS || return $? + fi action "Signaling $DAEMON to exit" kill -TERM $(pidofproc $DAEMON) || return $? From agk@sourceware.org Mon May 17 18:39:00 2010 From: agk@sourceware.org (agk@sourceware.org) Date: Mon, 17 May 2010 18:39:00 -0000 Subject: LVM2 ./VERSION ./VERSION_DM ./WHATS_NEW ./WHAT ... Message-ID: <20100517183904.32003.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-05-17 18:39:03 Modified files: . : VERSION VERSION_DM WHATS_NEW WHATS_NEW_DM lib/filters : filter.c Log message: pre-release Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/VERSION.diff?cvsroot=lvm2&r1=1.234&r2=1.235 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/VERSION_DM.diff?cvsroot=lvm2&r1=1.45&r2=1.46 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1560&r2=1.1561 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.369&r2=1.370 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter.c.diff?cvsroot=lvm2&r1=1.52&r2=1.53 --- LVM2/VERSION 2010/04/30 15:48:38 1.234 +++ LVM2/VERSION 2010/05/17 18:39:01 1.235 @@ -1 +1 @@ -2.02.65(2)-cvs (2010-04-30) +2.02.65(2)-cvs (2010-05-17) --- LVM2/VERSION_DM 2010/04/30 15:48:39 1.45 +++ LVM2/VERSION_DM 2010/05/17 18:39:01 1.46 @@ -1 +1 @@ -1.02.48-cvs (2010-04-30) +1.02.48-cvs (2010-05-17) --- LVM2/WHATS_NEW 2010/05/17 03:18:27 1.1560 +++ LVM2/WHATS_NEW 2010/05/17 18:39:01 1.1561 @@ -1,19 +1,22 @@ -Version 2.02.65 - -================================= - Fix clvmd init script to not deactive non-clustered volume groups. - Disallow cluster attr toggling if there are active mirrors or snapshots. +Version 2.02.65 - 17th May 2010 +=============================== + Fix clvmd init script never to deactivate non-clustered volume groups. + Disallow vgchange --clustered if there are active mirrors or snapshots. + Introduce lv_is_mirrored. Use /bin/bash for scripts with bashisms. - Skip internal lvm devices in scan if ignore suspended devices is requested. + Skip internal lvm devices in scan if ignore_suspended_devices is set. Do not merge old device cache after we run full scan. (2.02.56) Add pkgconfigdir Makefile variable for make install override. - Switch usage of Libs.private: to Requires.private: in devmapper.pc, lvm2app.pc. - Use field Requires.private: for devmapper-event.pc. - Add devmapper library to linked libdevmapper-event.so. - Link liblvm2cmd.so with devmapper-event and devmapper libs. + Configure pkgconfig udev and selinux dependencies. + Switch Libs.private to Requires.private in devmapper.pc and lvm2app.pc. + Use pkgconfig Requires.private for devmapper-event.pc. + Add libdevmapper to linked libdevmapper-event.so. + Link liblvm2cmd.so with libdevmapper-event and libdevmapper. Fix truncated total size displayed by pvscan. - Add new --sysinit option for vgchange and lvchange. - Suppress duplicate error messages about read failures and missing devices. - Install plugins to $(libdir)/device-mapper and $(libdir)/lvm2. + Add new --sysinit compound option to vgchange and lvchange. + Drop duplicate errors for read failures and missing devices to verbose level. + Use $(libdir)/lvm2 with make install_lvm2_plugin. + Use $(libdir)/device-mapper with make install_dm_plugin. Add dm_list_splice() function to join two lists together. Version 2.02.64 - 30th April 2010 --- LVM2/WHATS_NEW_DM 2010/05/14 14:56:39 1.369 +++ LVM2/WHATS_NEW_DM 2010/05/17 18:39:01 1.370 @@ -1,8 +1,10 @@ -Version 1.02.48 - -================================= +Version 1.02.48 - 17th May 2010 +================================ Use -d to control level of messages sent to syslog by dmeventd. Change -d to -f to run dmeventd in foreground. Do not print encryption key in message debug output (cryptsetup luksResume). + Fix dmeventd static build library dependencies. + Fix udev flags on remove in create_and_load error path. Version 1.02.47 - 30th April 2010 ================================= --- LVM2/lib/filters/filter.c 2010/05/13 18:38:40 1.52 +++ LVM2/lib/filters/filter.c 2010/05/17 18:39:03 1.53 @@ -130,6 +130,7 @@ return 0; } + /* FIXME Always check 'layer' regardless of ignore_suspended_devices */ /* Skip suspended devices */ if (MAJOR(dev->dev) == _device_mapper_major && ignore_suspended_devices() && !device_is_usable(dev)) { From agk@sourceware.org Mon May 17 20:18:00 2010 From: agk@sourceware.org (agk@sourceware.org) Date: Mon, 17 May 2010 20:18:00 -0000 Subject: LVM2 VERSION VERSION_DM WHATS_NEW WHATS_NEW_DM Message-ID: <20100517201816.1404.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-05-17 20:18:15 Modified files: . : VERSION VERSION_DM WHATS_NEW WHATS_NEW_DM Log message: post-release Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/VERSION.diff?cvsroot=lvm2&r1=1.235&r2=1.236 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/VERSION_DM.diff?cvsroot=lvm2&r1=1.46&r2=1.47 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1561&r2=1.1562 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.370&r2=1.371 --- LVM2/VERSION 2010/05/17 18:39:01 1.235 +++ LVM2/VERSION 2010/05/17 20:18:13 1.236 @@ -1 +1 @@ -2.02.65(2)-cvs (2010-05-17) +2.02.66(2)-cvs (2010-05-17) --- LVM2/VERSION_DM 2010/05/17 18:39:01 1.46 +++ LVM2/VERSION_DM 2010/05/17 20:18:13 1.47 @@ -1 +1 @@ -1.02.48-cvs (2010-05-17) +1.02.49-cvs (2010-05-17) --- LVM2/WHATS_NEW 2010/05/17 18:39:01 1.1561 +++ LVM2/WHATS_NEW 2010/05/17 20:18:13 1.1562 @@ -1,3 +1,6 @@ +Version 2.02.66 - +=============================== + Version 2.02.65 - 17th May 2010 =============================== Fix clvmd init script never to deactivate non-clustered volume groups. --- LVM2/WHATS_NEW_DM 2010/05/17 18:39:01 1.370 +++ LVM2/WHATS_NEW_DM 2010/05/17 20:18:13 1.371 @@ -1,3 +1,6 @@ +Version 1.02.49 - +================================ + Version 1.02.48 - 17th May 2010 ================================ Use -d to control level of messages sent to syslog by dmeventd. From agk@sourceware.org Wed May 19 00:52:00 2010 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 19 May 2010 00:52:00 -0000 Subject: LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/lock ... Message-ID: <20100519005258.25946.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-05-19 00:52:56 Modified files: . : WHATS_NEW lib/cache : lvmcache.c lib/locking : cluster_locking.c file_locking.c locking.c Log message: Use is_orphan_vg in place of hard-coded prefix tests. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1562&r2=1.1563 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.86&r2=1.87 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/cluster_locking.c.diff?cvsroot=lvm2&r1=1.42&r2=1.43 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/file_locking.c.diff?cvsroot=lvm2&r1=1.44&r2=1.45 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.80&r2=1.81 --- LVM2/WHATS_NEW 2010/05/17 20:18:13 1.1562 +++ LVM2/WHATS_NEW 2010/05/19 00:52:55 1.1563 @@ -1,5 +1,6 @@ Version 2.02.66 - =============================== + Use is_orphan_vg in place of hard-coded prefix tests. Version 2.02.65 - 17th May 2010 =============================== --- LVM2/lib/cache/lvmcache.c 2010/05/13 13:04:05 1.86 +++ LVM2/lib/cache/lvmcache.c 2010/05/19 00:52:55 1.87 @@ -224,11 +224,11 @@ /* * Ensure vgname2 comes after vgname1 alphabetically. - * Special VG names beginning with '#' don't count. + * Orphans don't count. */ static int _vgname_order_correct(const char *vgname1, const char *vgname2) { - if ((*vgname1 == '#') || (*vgname2 == '#')) + if (is_orphan_vg(vgname1) || is_orphan_vg(vgname2)) return 1; if (strcmp(vgname1, vgname2) < 0) --- LVM2/lib/locking/cluster_locking.c 2010/04/13 14:36:25 1.42 +++ LVM2/lib/locking/cluster_locking.c 2010/05/19 00:52:55 1.43 @@ -406,7 +406,7 @@ } /* If the VG name is empty then lock the unused PVs */ - if (*resource == '#' || (flags & LCK_CACHE)) + if (is_orphan_vg(resource) || (flags & LCK_CACHE)) dm_snprintf(lockname, sizeof(lockname), "P_%s", resource); else --- LVM2/lib/locking/file_locking.c 2010/01/05 16:06:43 1.44 +++ LVM2/lib/locking/file_locking.c 2010/05/19 00:52:55 1.45 @@ -265,7 +265,7 @@ if (flags & LCK_CACHE) break; - if (*resource == '#') + if (is_orphan_vg(resource)) dm_snprintf(lockfile, sizeof(lockfile), "%s/P_%s", _lock_dir, resource + 1); else --- LVM2/lib/locking/locking.c 2010/05/06 11:15:55 1.80 +++ LVM2/lib/locking/locking.c 2010/05/19 00:52:55 1.81 @@ -369,7 +369,7 @@ return 0; } - if (*resource == '#' && (flags & LCK_CACHE)) { + if (is_orphan_vg(resource) && (flags & LCK_CACHE)) { log_error(INTERNAL_ERROR "P_%s referenced", resource); return 0; } @@ -423,7 +423,7 @@ if (!_blocking_supported) flags |= LCK_NONBLOCK; - if (vol[0] != '#' && + if (!is_orphan_vg(vol) && ((flags & LCK_TYPE_MASK) != LCK_UNLOCK) && (!(flags & LCK_CACHE)) && !lvmcache_verify_lock_order(vol)) From agk@sourceware.org Wed May 19 01:16:00 2010 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 19 May 2010 01:16:00 -0000 Subject: LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/lock ... Message-ID: <20100519011650.9241.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-05-19 01:16:41 Modified files: . : WHATS_NEW lib/cache : lvmcache.c lib/locking : locking.c lib/metadata : metadata.c tools : pvresize.c Log message: Accept orphan VG names as parameters to lock_vol() and related functions. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1563&r2=1.1564 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.87&r2=1.88 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.81&r2=1.82 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.339&r2=1.340 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvresize.c.diff?cvsroot=lvm2&r1=1.34&r2=1.35 --- LVM2/WHATS_NEW 2010/05/19 00:52:55 1.1563 +++ LVM2/WHATS_NEW 2010/05/19 01:16:40 1.1564 @@ -1,5 +1,6 @@ Version 2.02.66 - =============================== + Accept orphan VG names as parameters to lock_vol() and related functions. Use is_orphan_vg in place of hard-coded prefix tests. Version 2.02.65 - 17th May 2010 --- LVM2/lib/cache/lvmcache.c 2010/05/19 00:52:55 1.87 +++ LVM2/lib/cache/lvmcache.c 2010/05/19 01:16:40 1.88 @@ -290,7 +290,7 @@ if (!_lock_hash) return 0; - return dm_hash_lookup(_lock_hash, vgname) ? 1 : 0; + return dm_hash_lookup(_lock_hash, is_orphan_vg(vgname) ? VG_ORPHANS : vgname) ? 1 : 0; } void lvmcache_unlock_vgname(const char *vgname) --- LVM2/lib/locking/locking.c 2010/05/19 00:52:55 1.81 +++ LVM2/lib/locking/locking.c 2010/05/19 01:16:41 1.82 @@ -417,16 +417,16 @@ switch (flags & LCK_SCOPE_MASK) { case LCK_VG: - /* - * VG locks alphabetical, ORPHAN lock last - */ if (!_blocking_supported) flags |= LCK_NONBLOCK; - if (!is_orphan_vg(vol) && - ((flags & LCK_TYPE_MASK) != LCK_UNLOCK) && - (!(flags & LCK_CACHE)) && - !lvmcache_verify_lock_order(vol)) + /* Global VG_ORPHANS lock covers all orphan formats. */ + if (is_orphan_vg(vol)) + vol = VG_ORPHANS; + /* VG locks alphabetical, ORPHAN lock last */ + else if (((flags & LCK_TYPE_MASK) != LCK_UNLOCK) && + !(flags & LCK_CACHE) && + !lvmcache_verify_lock_order(vol)) return 0; /* Lock VG to change on-disk metadata. */ --- LVM2/lib/metadata/metadata.c 2010/05/14 15:19:43 1.339 +++ LVM2/lib/metadata/metadata.c 2010/05/19 01:16:41 1.340 @@ -3459,7 +3459,7 @@ return !_vg_bad_status_bits(vg, status); } -static struct volume_group *_recover_vg(struct cmd_context *cmd, const char *lock_name, +static struct volume_group *_recover_vg(struct cmd_context *cmd, const char *vg_name, const char *vgid, uint32_t lock_flags) { @@ -3469,11 +3469,11 @@ lock_flags &= ~LCK_TYPE_MASK; lock_flags |= LCK_WRITE; - unlock_vg(cmd, lock_name); + unlock_vg(cmd, vg_name); dev_close_all(); - if (!lock_vol(cmd, lock_name, lock_flags)) + if (!lock_vol(cmd, vg_name, lock_flags)) return_NULL; if (!(vg = vg_read_internal(cmd, vg_name, vgid, &consistent))) @@ -3503,7 +3503,6 @@ uint64_t status_flags, uint32_t misc_flags) { struct volume_group *vg = NULL; - const char *lock_name; int consistent = 1; int consistent_in; uint32_t failure = 0; @@ -3518,11 +3517,10 @@ return NULL; } - lock_name = is_orphan_vg(vg_name) ? VG_ORPHANS : vg_name; - already_locked = vgname_is_locked(lock_name); + already_locked = vgname_is_locked(vg_name); if (!already_locked && !(misc_flags & READ_WITHOUT_LOCK) && - !lock_vol(cmd, lock_name, lock_flags)) { + !lock_vol(cmd, vg_name, lock_flags)) { log_error("Can't get lock for %s", vg_name); return _vg_make_handle(cmd, vg, FAILED_LOCKING); } @@ -3555,7 +3553,7 @@ /* consistent == 0 when VG is not found, but failed == FAILED_NOTFOUND */ if (!consistent && !failure) { vg_release(vg); - if (!(vg = _recover_vg(cmd, lock_name, vg_name, vgid, lock_flags))) { + if (!(vg = _recover_vg(cmd, vg_name, vgid, lock_flags))) { log_error("Recovery of volume group \"%s\" failed.", vg_name); failure |= FAILED_INCONSISTENT; @@ -3592,7 +3590,7 @@ bad: if (!already_locked && !(misc_flags & READ_WITHOUT_LOCK)) - unlock_vg(cmd, lock_name); + unlock_vg(cmd, vg_name); return _vg_make_handle(cmd, vg, failure); } --- LVM2/tools/pvresize.c 2009/12/11 13:11:56 1.34 +++ LVM2/tools/pvresize.c 2010/05/19 01:16:41 1.35 @@ -34,15 +34,14 @@ int r = 0; struct dm_list mdas; const char *pv_name = pv_dev_name(pv); - const char *vg_name; + const char *vg_name = pv_vg_name(pv); struct lvmcache_info *info; int mda_count = 0; struct volume_group *old_vg = vg; dm_list_init(&mdas); - if (is_orphan_vg(pv_vg_name(pv))) { - vg_name = VG_ORPHANS; + if (is_orphan_vg(vg_name)) { if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) { log_error("Can't get lock for orphans"); return 0; @@ -56,8 +55,6 @@ mda_count = dm_list_size(&mdas); } else { - vg_name = pv_vg_name(pv); - vg = vg_read_for_update(cmd, vg_name, NULL, 0); if (vg_read_error(vg)) { @@ -70,7 +67,7 @@ if (!(pvl = find_pv_in_vg(vg, pv_name))) { log_error("Unable to find \"%s\" in volume group \"%s\"", pv_name, vg->name); - goto bad; + goto out; } pv = pvl->pv; @@ -78,31 +75,31 @@ if (!(info = info_from_pvid(pv->dev->pvid, 0))) { log_error("Can't get info for PV %s in volume group %s", pv_name, vg->name); - goto bad; + goto out; } mda_count = dm_list_size(&info->mdas); if (!archive(vg)) - goto bad; + goto out; } /* FIXME Create function to test compatibility properly */ if (mda_count > 1) { log_error("%s: too many metadata areas for pvresize", pv_name); - goto bad; + goto out; } if (!(pv->fmt->features & FMT_RESIZE_PV)) { log_error("Physical volume %s format does not support resizing.", pv_name); - goto bad; + goto out; } /* Get new size */ if (!dev_get_size(pv_dev(pv), &size)) { log_error("%s: Couldn't get size.", pv_name); - goto bad; + goto out; } if (new_size) { @@ -117,13 +114,13 @@ if (size < PV_MIN_SIZE) { log_error("%s: Size must exceed minimum of %ld sectors.", pv_name, PV_MIN_SIZE); - goto bad; + goto out; } if (size < pv_pe_start(pv)) { log_error("%s: Size must exceed physical extent start of " "%" PRIu64 " sectors.", pv_name, pv_pe_start(pv)); - goto bad; + goto out; } pv->size = size; @@ -137,34 +134,34 @@ "least one physical extent of " "%" PRIu32 " sectors.", pv_name, pv_pe_size(pv)); - goto bad; + goto out; } if (!pv_resize(pv, vg, new_pe_count)) - goto_bad; + goto_out; } log_verbose("Resizing volume \"%s\" to %" PRIu64 " sectors.", pv_name, pv_size(pv)); log_verbose("Updating physical volume \"%s\"", pv_name); - if (!is_orphan_vg(pv_vg_name(pv))) { + if (!is_orphan_vg(vg_name)) { if (!vg_write(vg) || !vg_commit(vg)) { log_error("Failed to store physical volume \"%s\" in " "volume group \"%s\"", pv_name, vg->name); - goto bad; + goto out; } backup(vg); } else if (!(pv_write(cmd, pv, NULL, INT64_C(-1)))) { log_error("Failed to store physical volume \"%s\"", pv_name); - goto bad;; + goto out; } log_print("Physical volume \"%s\" changed", pv_name); r = 1; -bad: +out: unlock_vg(cmd, vg_name); if (!old_vg) vg_release(vg); From agk@sourceware.org Wed May 19 01:49:00 2010 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 19 May 2010 01:49:00 -0000 Subject: LVM2/lib/locking locking.h Message-ID: <20100519014912.30632.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-05-19 01:49:09 Modified files: lib/locking : locking.h Log message: Note that orphan lock is always obtained last Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.54&r2=1.55 --- LVM2/lib/locking/locking.h 2010/05/06 11:15:55 1.54 +++ LVM2/lib/locking/locking.h 2010/05/19 01:49:08 1.55 @@ -36,7 +36,8 @@ * Set LCK_CACHE flag when manipulating 'vol' metadata in the internal cache. * (Like commit, revert or invalidate metadata.) * If more than one lock needs to be held simultaneously, they must be - * acquired in alphabetical order of 'vol' (to avoid deadlocks). + * acquired in alphabetical order of 'vol' (to avoid deadlocks), with + * VG_ORPHANS last. * * LCK_LV: * Lock/unlock an individual logical volume From agk@sourceware.org Wed May 19 02:08:00 2010 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 19 May 2010 02:08:00 -0000 Subject: LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/lock ... Message-ID: <20100519020852.9836.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-05-19 02:08:51 Modified files: . : WHATS_NEW lib/cache : lvmcache.c lib/locking : locking.c lib/metadata : metadata-exported.h metadata.c Log message: Validate orphan and VG_GLOBAL lock order too. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1564&r2=1.1565 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.88&r2=1.89 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.82&r2=1.83 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.144&r2=1.145 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.340&r2=1.341 --- LVM2/WHATS_NEW 2010/05/19 01:16:40 1.1564 +++ LVM2/WHATS_NEW 2010/05/19 02:08:50 1.1565 @@ -1,5 +1,6 @@ Version 2.02.66 - =============================== + Validate orphan and VG_GLOBAL lock order too. Accept orphan VG names as parameters to lock_vol() and related functions. Use is_orphan_vg in place of hard-coded prefix tests. --- LVM2/lib/cache/lvmcache.c 2010/05/19 01:16:40 1.88 +++ LVM2/lib/cache/lvmcache.c 2010/05/19 02:08:50 1.89 @@ -224,11 +224,21 @@ /* * Ensure vgname2 comes after vgname1 alphabetically. - * Orphans don't count. + * Orphan locks come last. + * VG_GLOBAL comes first. */ static int _vgname_order_correct(const char *vgname1, const char *vgname2) { - if (is_orphan_vg(vgname1) || is_orphan_vg(vgname2)) + if (is_global_vg(vgname1)) + return 1; + + if (is_global_vg(vgname2)) + return 0; + + if (is_orphan_vg(vgname1)) + return 0; + + if (is_orphan_vg(vgname2)) return 1; if (strcmp(vgname1, vgname2) < 0) --- LVM2/lib/locking/locking.c 2010/05/19 01:16:41 1.82 +++ LVM2/lib/locking/locking.c 2010/05/19 02:08:51 1.83 @@ -424,7 +424,7 @@ if (is_orphan_vg(vol)) vol = VG_ORPHANS; /* VG locks alphabetical, ORPHAN lock last */ - else if (((flags & LCK_TYPE_MASK) != LCK_UNLOCK) && + if (((flags & LCK_TYPE_MASK) != LCK_UNLOCK) && !(flags & LCK_CACHE) && !lvmcache_verify_lock_order(vol)) return 0; --- LVM2/lib/metadata/metadata-exported.h 2010/05/14 15:19:43 1.144 +++ LVM2/lib/metadata/metadata-exported.h 2010/05/19 02:08:51 1.145 @@ -423,6 +423,7 @@ int move_pvs_used_by_lv(struct volume_group *vg_from, struct volume_group *vg_to, const char *lv_name); +int is_global_vg(const char *vg_name); int is_orphan_vg(const char *vg_name); int is_orphan(const struct physical_volume *pv); int is_missing_pv(const struct physical_volume *pv); --- LVM2/lib/metadata/metadata.c 2010/05/19 01:16:41 1.340 +++ LVM2/lib/metadata/metadata.c 2010/05/19 02:08:51 1.341 @@ -3326,6 +3326,11 @@ return 1; } +int is_global_vg(const char *vg_name) +{ + return (vg_name && !strcmp(vg_name, VG_GLOBAL)) ? 1 : 0; +} + /** * is_orphan_vg - Determine whether a vg_name is an orphan * @vg_name: pointer to the vg_name From agk@sourceware.org Wed May 19 02:36:00 2010 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 19 May 2010 02:36:00 -0000 Subject: LVM2 ./WHATS_NEW lib/cache/lvmcache.h lib/lock ... Message-ID: <20100519023634.21918.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-05-19 02:36:33 Modified files: . : WHATS_NEW lib/cache : lvmcache.h lib/locking : cluster_locking.c file_locking.c locking.c lib/metadata : metadata.c Log message: Add is_global_vg and split out from is_orphan_vg. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1565&r2=1.1566 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.30&r2=1.31 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/cluster_locking.c.diff?cvsroot=lvm2&r1=1.43&r2=1.44 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/file_locking.c.diff?cvsroot=lvm2&r1=1.45&r2=1.46 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.83&r2=1.84 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.341&r2=1.342 --- LVM2/WHATS_NEW 2010/05/19 02:08:50 1.1565 +++ LVM2/WHATS_NEW 2010/05/19 02:36:33 1.1566 @@ -2,7 +2,7 @@ =============================== Validate orphan and VG_GLOBAL lock order too. Accept orphan VG names as parameters to lock_vol() and related functions. - Use is_orphan_vg in place of hard-coded prefix tests. + Use is_orphan_vg in place of hard-coded prefix tests and add is_global_vg. Version 2.02.65 - 17th May 2010 =============================== --- LVM2/lib/cache/lvmcache.h 2010/03/17 02:11:18 1.30 +++ LVM2/lib/cache/lvmcache.h 2010/05/19 02:36:33 1.31 @@ -19,9 +19,10 @@ #include "dev-cache.h" #include "uuid.h" #include "label.h" +#include "locking.h" -#define ORPHAN_PREFIX "#" -#define ORPHAN_VG_NAME(fmt) ORPHAN_PREFIX "orphans_" fmt +#define ORPHAN_PREFIX VG_ORPHANS +#define ORPHAN_VG_NAME(fmt) ORPHAN_PREFIX "_" fmt #define CACHE_INVALID 0x00000001 #define CACHE_LOCKED 0x00000002 --- LVM2/lib/locking/cluster_locking.c 2010/05/19 00:52:55 1.43 +++ LVM2/lib/locking/cluster_locking.c 2010/05/19 02:36:33 1.44 @@ -406,7 +406,7 @@ } /* If the VG name is empty then lock the unused PVs */ - if (is_orphan_vg(resource) || (flags & LCK_CACHE)) + if (is_orphan_vg(resource) || is_global_vg(resource) || (flags & LCK_CACHE)) dm_snprintf(lockname, sizeof(lockname), "P_%s", resource); else --- LVM2/lib/locking/file_locking.c 2010/05/19 00:52:55 1.45 +++ LVM2/lib/locking/file_locking.c 2010/05/19 02:36:33 1.46 @@ -265,7 +265,7 @@ if (flags & LCK_CACHE) break; - if (is_orphan_vg(resource)) + if (is_orphan_vg(resource) || is_global_vg(resource)) dm_snprintf(lockfile, sizeof(lockfile), "%s/P_%s", _lock_dir, resource + 1); else --- LVM2/lib/locking/locking.c 2010/05/19 02:08:51 1.83 +++ LVM2/lib/locking/locking.c 2010/05/19 02:36:33 1.84 @@ -325,7 +325,7 @@ char path[PATH_MAX]; /* We'll allow operations on orphans */ - if (is_orphan_vg(vgname)) + if (is_orphan_vg(vgname) || is_global_vg(vgname)) return 1; /* LVM1 is only present in 2.4 kernels. */ @@ -369,7 +369,7 @@ return 0; } - if (is_orphan_vg(resource) && (flags & LCK_CACHE)) { + if ((is_orphan_vg(resource) || is_global_vg(resource)) && (flags & LCK_CACHE)) { log_error(INTERNAL_ERROR "P_%s referenced", resource); return 0; } --- LVM2/lib/metadata/metadata.c 2010/05/19 02:08:51 1.341 +++ LVM2/lib/metadata/metadata.c 2010/05/19 02:36:33 1.342 @@ -3337,7 +3337,7 @@ */ int is_orphan_vg(const char *vg_name) { - return (vg_name && vg_name[0] == ORPHAN_PREFIX[0]) ? 1 : 0; + return (vg_name && !strncmp(vg_name, ORPHAN_PREFIX, sizeof(ORPHAN_PREFIX) - 1)) ? 1 : 0; } /** From wysochanski@sourceware.org Wed May 19 11:52:00 2010 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Wed, 19 May 2010 11:52:00 -0000 Subject: LVM2/lib/cache lvmcache.c lvmcache.h Message-ID: <20100519115221.24898.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2010-05-19 11:52:21 Modified files: lib/cache : lvmcache.c lvmcache.h Log message: Add lvmcache_vgname_from_pvid(). Add lvmcache function to lookup a vgname from a pvid. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.90&r2=1.91 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.32&r2=1.33 --- LVM2/lib/cache/lvmcache.c 2010/05/19 11:52:07 1.90 +++ LVM2/lib/cache/lvmcache.c 2010/05/19 11:52:21 1.91 @@ -509,6 +509,27 @@ return info; } +char *lvmcache_vgname_from_pvid(struct cmd_context *cmd, const char *pvid) +{ + struct lvmcache_info *info; + char *vgname; + + if (!device_from_pvid(cmd, (struct id *)pvid, NULL)) { + log_error("Couldn't find device with uuid %s.", pvid); + return NULL; + } + + info = info_from_pvid(pvid, 0); + if (!info) + return_NULL; + + if (!(vgname = dm_pool_strdup(cmd->mem, info->vginfo->vgname))) { + log_errno(ENOMEM, "vgname allocation failed"); + return NULL; + } + return vgname; +} + static void _rescan_entry(struct lvmcache_info *info) { struct label *label; --- LVM2/lib/cache/lvmcache.h 2010/05/19 11:52:07 1.32 +++ LVM2/lib/cache/lvmcache.h 2010/05/19 11:52:21 1.33 @@ -98,6 +98,7 @@ unsigned *scan_done_once); const char *pvid_from_devname(struct cmd_context *cmd, const char *dev_name); +char *lvmcache_vgname_from_pvid(struct cmd_context *cmd, const char *pvid); int vgs_locked(void); int vgname_is_locked(const char *vgname); From wysochanski@sourceware.org Wed May 19 11:52:00 2010 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Wed, 19 May 2010 11:52:00 -0000 Subject: LVM2/lib/cache lvmcache.c lvmcache.h Message-ID: <20100519115208.24733.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2010-05-19 11:52:08 Modified files: lib/cache : lvmcache.c lvmcache.h Log message: Add pvid_from_devname() lvmcache function. Add supporting function for mappings from devname -> pvid -> vgname. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.89&r2=1.90 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.31&r2=1.32 --- LVM2/lib/cache/lvmcache.c 2010/05/19 02:08:50 1.89 +++ LVM2/lib/cache/lvmcache.c 2010/05/19 11:52:07 1.90 @@ -757,6 +757,25 @@ return NULL; } +const char *pvid_from_devname(struct cmd_context *cmd, + const char *devname) +{ + struct device *dev; + struct label *label; + + if (!(dev = dev_cache_get(devname, cmd->filter))) { + log_error("%s: Couldn't find device. Check your filters?", + devname); + return NULL; + } + + if (!(label_read(dev, &label, UINT64_C(0)))) + return NULL; + + return dev->pvid; +} + + static int _free_vginfo(struct lvmcache_vginfo *vginfo) { struct lvmcache_vginfo *primary_vginfo, *vginfo2; --- LVM2/lib/cache/lvmcache.h 2010/05/19 02:36:33 1.31 +++ LVM2/lib/cache/lvmcache.h 2010/05/19 11:52:07 1.32 @@ -96,6 +96,8 @@ const char *vgname_from_vgid(struct dm_pool *mem, const char *vgid); struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid, unsigned *scan_done_once); +const char *pvid_from_devname(struct cmd_context *cmd, + const char *dev_name); int vgs_locked(void); int vgname_is_locked(const char *vgname); From wysochanski@sourceware.org Wed May 19 11:52:00 2010 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Wed, 19 May 2010 11:52:00 -0000 Subject: LVM2/lib/metadata metadata-exported.h metadata.c Message-ID: <20100519115238.25069.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2010-05-19 11:52:38 Modified files: lib/metadata : metadata-exported.h metadata.c Log message: Add find_vgname_from_{pvname|pvid} functions. Some commands start with a pvname, but we'd like to force users to start with a vg handle to obtain a pv handle. Our best option seems to be providing a way to look up the vgname from the pvname, and then require them to use vg_read/vg_open. In addition to the pvname lookup function, this patch also provides a lookup by pvid. The lookup by pvid can be used in conjunction with lvmcache_get_pvids to process all pvs in the system. The pvid find function first calls lvmcache_vgname_from_pvid, which may cause the label to be read if it is not in the cache. If the vgname is returned is an orphan, we then check to see if there are metadata areas, and if not, we scan every PV on the system by calling scan_vgs_for_pvs(). In most cases we should not need to do this, and by using the info->mdas count, we avoid calling pv_read() as prior code did. So this patch is a bit cleaner and should allow us to refactor more of the pv code. Signed-off-by: Dave Wysochanski Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.145&r2=1.146 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.342&r2=1.343 --- LVM2/lib/metadata/metadata-exported.h 2010/05/19 02:08:51 1.145 +++ LVM2/lib/metadata/metadata-exported.h 2010/05/19 11:52:37 1.146 @@ -625,6 +625,10 @@ struct physical_volume *find_pv_by_name(struct cmd_context *cmd, const char *pv_name); +const char *find_vgname_from_pvname(struct cmd_context *cmd, + const char *pvname); +const char *find_vgname_from_pvid(struct cmd_context *cmd, + const char *pvid); /* Find LV segment containing given LE */ struct lv_segment *first_seg(const struct logical_volume *lv); --- LVM2/lib/metadata/metadata.c 2010/05/19 02:36:33 1.342 +++ LVM2/lib/metadata/metadata.c 2010/05/19 11:52:37 1.343 @@ -3110,6 +3110,52 @@ return NULL; } + +const char *find_vgname_from_pvid(struct cmd_context *cmd, + const char *pvid) +{ + char *vgname; + struct lvmcache_info *info; + + vgname = lvmcache_vgname_from_pvid(cmd, pvid); + + if (is_orphan_vg(vgname)) { + if (!(info = info_from_pvid(pvid, 0))) { + return_NULL; + } + /* + * If an orphan PV has no MDAs it may appear to be an + * orphan until the metadata is read off another PV in + * the same VG. Detecting this means checking every VG + * by scanning every PV on the system. + */ + if (!dm_list_size(&info->mdas)) { + if (!scan_vgs_for_pvs(cmd)) { + log_error("Rescan for PVs without " + "metadata areas failed."); + return NULL; + } + } + /* Ask lvmcache again - we may have a non-orphan name now */ + vgname = lvmcache_vgname_from_pvid(cmd, pvid); + } + return vgname; +} + + +const char *find_vgname_from_pvname(struct cmd_context *cmd, + const char *pvname) +{ + const char *pvid; + + pvid = pvid_from_devname(cmd, pvname); + if (!pvid) + /* Not a PV */ + return NULL; + + return find_vgname_from_pvid(cmd, pvid); +} + /** * pv_read - read and return a handle to a physical volume * @cmd: LVM command initiating the pv_read From wysochanski@sourceware.org Wed May 19 11:53:00 2010 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Wed, 19 May 2010 11:53:00 -0000 Subject: LVM2/test/api test.c Message-ID: <20100519115331.25591.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2010-05-19 11:53:30 Modified files: test/api : test.c Log message: Test lvm_vgname_from_{pvid|device}. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/api/test.c.diff?cvsroot=lvm2&r1=1.29&r2=1.30 --- LVM2/test/api/test.c 2010/02/24 18:16:35 1.29 +++ LVM2/test/api/test.c 2010/05/19 11:53:30 1.30 @@ -97,6 +97,10 @@ "Add/remove a tag from a VG\n"); printf("'lv_{add|remove}_tag vgname lvname tag': " "Add/remove a tag from a LV\n"); + printf("'vgname_from_devname device': " + "Lookup a vgname from a device name\n"); + printf("'vgname_from_pvid pvid': " + "Lookup a vgname from a pvid\n"); printf("'quit': exit the program\n"); } @@ -576,6 +580,38 @@ printf("%s tag %s to LV %s\n", add ? "adding":"removing", argv[3], argv[2]); } +static void _vgname_from_pvid(char **argv, int argc, lvm_t libh) +{ + const char *vgname; + + if (argc < 1) { + printf("Please enter pvid\n"); + return; + } + if (!(vgname = lvm_vgname_from_pvid(libh, argv[1]))) { + printf("Error "); + } else { + printf("Success "); + } + printf("looking up vgname=%s from PVID=%s\n", + vgname, argv[1]); +} +static void _vgname_from_devname(char **argv, int argc, lvm_t libh) +{ + const char *vgname; + + if (argc < 1) { + printf("Please enter device\n"); + return; + } + if (!(vgname = lvm_vgname_from_device(libh, argv[1]))) { + printf("Error "); + } else { + printf("Success "); + } + printf("looking up vgname=%s from device name=%s\n", + vgname, argv[1]); +} static void _lvs_in_vg(char **argv, int argc) { struct dm_list *lvs; @@ -766,6 +802,10 @@ _lv_tag(argv, argc, 0); } else if (!strcmp(argv[0], "lv_get_tags")) { _lv_get_tags(argv, argc); + } else if (!strcmp(argv[0], "vgname_from_devname")) { + _vgname_from_devname(argv, argc, libh); + } else if (!strcmp(argv[0], "vgname_from_pvid")) { + _vgname_from_pvid(argv, argc, libh); } else { printf ("Unrecognized command %s\n", argv[0]); } From wysochanski@sourceware.org Wed May 19 11:53:00 2010 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Wed, 19 May 2010 11:53:00 -0000 Subject: LVM2/liblvm .exported_symbols lvm2app.h lvm_base.c Message-ID: <20100519115317.25417.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2010-05-19 11:53:12 Modified files: liblvm : .exported_symbols lvm2app.h lvm_base.c Log message: Add lvm2app interfaces to lookup a vgname from a pvid and pvname. lvm2app forces applications to start with a volume group name, open the volume group, then operate on individual pvs. In some cases the application may want to start with a device name rather than the volume group name. Today, if an application wants to do this, it must iterate through all the volume groups to find the volume group that the specific device is attached to. These new interfaces allow the application to avoid such overhead. Bump the lvm2app version number to 3. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/.exported_symbols.diff?cvsroot=lvm2&r1=1.25&r2=1.26 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm2app.h.diff?cvsroot=lvm2&r1=1.15&r2=1.16 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_base.c.diff?cvsroot=lvm2&r1=1.16&r2=1.17 --- LVM2/liblvm/.exported_symbols 2010/02/24 18:16:26 1.25 +++ LVM2/liblvm/.exported_symbols 2010/05/19 11:53:12 1.26 @@ -48,3 +48,5 @@ lvm_list_vg_uuids lvm_vg_create_lv_linear lvm_vg_remove_lv +lvm_vgname_from_pvid +lvm_vgname_from_device --- LVM2/liblvm/lvm2app.h 2010/04/19 15:22:24 1.15 +++ LVM2/liblvm/lvm2app.h 2010/05/19 11:53:12 1.16 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2008,2009 Red Hat, Inc. All rights reserved. + * Copyright (C) 2008,2009,2010 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -344,6 +344,45 @@ struct dm_list *lvm_list_vg_uuids(lvm_t libh); /** + * Return the volume group name given a PV UUID + * + * \memberof lvm_t + * + * The memory allocated for the name is tied to the lvm_t handle and will be + * released when lvm_quit is called. + * + * NOTE: This function may scan devices in the system for LVM metadata. + * + * \param libh + * Handle obtained from lvm_init(). + * + * \return + * The volume group name for the given PV UUID. + * NULL is returned if the PV UUID is not associated with a volume group. + */ +const char *lvm_vgname_from_pvid(lvm_t libh, const char *pvid); + +/** + * Return the volume group name given a device name + * + * \memberof lvm_t + * + * The memory allocated for the name is tied to the lvm_t handle and will be + * released when lvm_quit is called. + * + * NOTE: This function may scan devices in the system for LVM metadata. + * + * \param libh + * Handle obtained from lvm_init(). + * + * \return + * The volume group name for the given device name. + * NULL is returned if the device is not an LVM device. + * + */ +const char *lvm_vgname_from_device(lvm_t libh, const char *device); + +/** * Open an existing VG. * * Open a VG for reading or writing. --- LVM2/liblvm/lvm_base.c 2010/05/06 11:15:55 1.16 +++ LVM2/liblvm/lvm_base.c 2010/05/19 11:53:12 1.17 @@ -17,6 +17,7 @@ #include "toolcontext.h" #include "locking.h" #include "lvm-version.h" +#include "metadata-exported.h" const char *lvm_library_get_version(void) { @@ -98,3 +99,21 @@ { return stored_errmsg(); } + +const char *lvm_vgname_from_pvid(lvm_t libh, const char *pvid) +{ + struct cmd_context *cmd = (struct cmd_context *)libh; + char uuid[64] __attribute((aligned(8))); + + if (!id_read_format(uuid, pvid)) { + log_error(INTERNAL_ERROR "Unable to convert uuid"); + return NULL; + } + return find_vgname_from_pvid(cmd, uuid); +} + +const char *lvm_vgname_from_device(lvm_t libh, const char *device) +{ + struct cmd_context *cmd = (struct cmd_context *)libh; + return find_vgname_from_pvname(cmd, device); +} From wysochanski@sourceware.org Wed May 19 11:53:00 2010 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Wed, 19 May 2010 11:53:00 -0000 Subject: LVM2/tools pvchange.c Message-ID: <20100519115300.25238.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2010-05-19 11:53:00 Modified files: tools : pvchange.c Log message: Update pvchange to always obtain a vg handle for each pv to process. Earlier patches added some infrastructure to lookup a vgname from a pvname. We now can cleanup some of the pvchange and other code by requiring callers that want to modify some pv property: 1) lookup the vgname by the pvname 2) use the vgname to obtain a vg handle 3) get the pv handle from the vg handle This should work going forward and be a much cleaner interface, as we move away from pvs as standalone objects. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvchange.c.diff?cvsroot=lvm2&r1=1.73&r2=1.74 --- LVM2/tools/pvchange.c 2009/09/14 22:47:49 1.73 +++ LVM2/tools/pvchange.c 2010/05/19 11:53:00 1.74 @@ -17,13 +17,10 @@ /* FIXME Locking. PVs in VG. */ -static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv, +static int _pvchange_single(struct cmd_context *cmd, struct volume_group *vg, + struct physical_volume *pv, void *handle __attribute((unused))) { - struct volume_group *vg = NULL; - const char *vg_name = NULL; - struct pv_list *pvl; - uint64_t sector; uint32_t orig_pe_alloc_count; /* FIXME Next three only required for format1. */ uint32_t orig_pe_count, orig_pe_size; @@ -53,21 +50,6 @@ /* If in a VG, must change using volume group. */ if (!is_orphan(pv)) { - vg_name = pv_vg_name(pv); - - log_verbose("Finding volume group %s of physical volume %s", - vg_name, pv_name); - vg = vg_read_for_update(cmd, vg_name, NULL, 0); - if (vg_read_error(vg)) { - vg_release(vg); - return_0; - } - - if (!(pvl = find_pv_in_vg(vg, pv_name))) { - log_error("Unable to find \"%s\" in volume group \"%s\"", - pv_name, vg->name); - goto out; - } if (tagarg && !(vg->fid->fmt->features & FMT_TAGS)) { log_error("Volume group containing %s does not " "support tags", pv_name); @@ -78,7 +60,6 @@ "logical volumes", pv_name); goto out; } - pv = pvl->pv; if (!archive(vg)) goto out; } else { @@ -87,19 +68,6 @@ "in volume group", pv_name); return 0; } - - vg_name = VG_ORPHANS; - - if (!lock_vol(cmd, vg_name, LCK_VG_WRITE)) { - log_error("Can't get lock for orphans"); - return 0; - } - - if (!(pv = pv_read(cmd, pv_name, NULL, §or, 1, 0))) { - unlock_vg(cmd, vg_name); - log_error("Unable to read PV \"%s\"", pv_name); - return 0; - } } if (arg_count(cmd, allocatable_ARG)) { @@ -201,7 +169,6 @@ log_print("Physical volume \"%s\" changed", pv_name); r = 1; out: - unlock_and_release_vg(cmd, vg, vg_name); return r; } @@ -212,12 +179,12 @@ int done = 0; int total = 0; - struct physical_volume *pv; - char *pv_name; + struct volume_group *vg; + const char *pv_name, *vg_name; struct pv_list *pvl; - struct dm_list *pvslist; - struct dm_list mdas; + struct dm_list *vgnames; + struct str_list *sll; if (arg_count(cmd, allocatable_ARG) + arg_count(cmd, addtag_ARG) + arg_count(cmd, deltag_ARG) + arg_count(cmd, uuid_ARG) != 1) { @@ -240,50 +207,71 @@ log_verbose("Using physical volume(s) on command line"); for (; opt < argc; opt++) { pv_name = argv[opt]; - dm_list_init(&mdas); - if (!(pv = pv_read(cmd, pv_name, &mdas, NULL, 1, 0))) { + vg_name = find_vgname_from_pvname(cmd, pv_name); + if (!vg_name) { log_error("Failed to read physical volume %s", pv_name); continue; } - /* - * If a PV has no MDAs it may appear to be an - * orphan until the metadata is read off - * another PV in the same VG. Detecting this - * means checking every VG by scanning every - * PV on the system. - */ - if (is_orphan(pv) && !dm_list_size(&mdas)) { - if (!scan_vgs_for_pvs(cmd)) { - log_error("Rescan for PVs without " - "metadata areas failed."); - continue; - } - if (!(pv = pv_read(cmd, pv_name, - NULL, NULL, 1, 0))) { - log_error("Failed to read " - "physical volume %s", - pv_name); - continue; - } + vg = vg_read_for_update(cmd, vg_name, NULL, 0); + if (vg_read_error(vg)) { + vg_release(vg); + stack; + continue; + } + pvl = find_pv_in_vg(vg, pv_name); + if (!pvl || !pvl->pv) { + log_error("Unable to find %s in %s", + pv_name, vg_name); + continue; } total++; - done += _pvchange_single(cmd, pv, NULL); + done += _pvchange_single(cmd, vg, + pvl->pv, NULL); + /* FIXME: we should be using #orphans_lvm2 everwhere */ + if (is_orphan_vg(vg->name)) + vg_name = VG_ORPHANS; + unlock_and_release_vg(cmd, vg, vg_name); } } else { log_verbose("Scanning for physical volume names"); - if (!(pvslist = get_pvs(cmd))) { - stack; + /* FIXME: share code with toollib */ + /* + * Take the global lock here so the lvmcache remains + * consistent across orphan/non-orphan vg locks. If we don't + * take the lock here, pvs with 0 mdas in a non-orphan VG will + * be processed twice. + */ + if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_WRITE)) { + log_error("Unable to obtain global lock."); return ECMD_FAILED; } - dm_list_iterate_items(pvl, pvslist) { - total++; - done += _pvchange_single(cmd, pvl->pv, NULL); + if ((vgnames = get_vgnames(cmd, 1)) && + !dm_list_empty(vgnames)) { + dm_list_iterate_items(sll, vgnames) { + vg = vg_read_for_update(cmd, sll->str, NULL, 0); + if (vg_read_error(vg)) { + vg_release(vg); + stack; + continue; + } + dm_list_iterate_items(pvl, &vg->pvs) { + total++; + done += _pvchange_single(cmd, vg, + pvl->pv, + NULL); + } + /* FIXME: we should be using #orphans_lvm2 everwhere */ + if (is_orphan_vg(vg->name)) + sll->str = VG_ORPHANS; + unlock_and_release_vg(cmd, vg, sll->str); + } } } + unlock_vg(cmd, VG_GLOBAL); log_print("%d physical volume%s changed / %d physical volume%s " "not changed", done, done == 1 ? "" : "s", From wysochanski@sourceware.org Wed May 19 11:57:00 2010 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Wed, 19 May 2010 11:57:00 -0000 Subject: LVM2 WHATS_NEW Message-ID: <20100519115706.26344.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2010-05-19 11:57:05 Modified files: . : WHATS_NEW Log message: Update WHATS_NEW Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1566&r2=1.1567 --- LVM2/WHATS_NEW 2010/05/19 02:36:33 1.1566 +++ LVM2/WHATS_NEW 2010/05/19 11:57:05 1.1567 @@ -1,5 +1,10 @@ Version 2.02.66 - =============================== + Add tests for lvm_vgname_from_{pvid|device}. + Add lvm2app interfaces to lookup a vgname from a pvid and pvname. + Update pvchange to always obtain a vg handle for each pv to process. + Add Add find_vgname_from_{pvname|pvid} functions. + Add pvid_from_devname and lvmcache_vgname_from_pvid lvmcache functions. Validate orphan and VG_GLOBAL lock order too. Accept orphan VG names as parameters to lock_vol() and related functions. Use is_orphan_vg in place of hard-coded prefix tests and add is_global_vg. From wysochanski@sourceware.org Wed May 19 12:12:00 2010 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Wed, 19 May 2010 12:12:00 -0000 Subject: LVM2/liblvm lvm_base.c Message-ID: <20100519121249.18039.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2010-05-19 12:12:48 Modified files: liblvm : lvm_base.c Log message: Fix warnings with conversion of uuid. More cleanup of uuid casting / structures is needed but for now just cast like the rest of the code. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/liblvm/lvm_base.c.diff?cvsroot=lvm2&r1=1.17&r2=1.18 --- LVM2/liblvm/lvm_base.c 2010/05/19 11:53:12 1.17 +++ LVM2/liblvm/lvm_base.c 2010/05/19 12:12:47 1.18 @@ -103,13 +103,13 @@ const char *lvm_vgname_from_pvid(lvm_t libh, const char *pvid) { struct cmd_context *cmd = (struct cmd_context *)libh; - char uuid[64] __attribute((aligned(8))); + struct id id; - if (!id_read_format(uuid, pvid)) { + if (!id_read_format(&id, pvid)) { log_error(INTERNAL_ERROR "Unable to convert uuid"); return NULL; } - return find_vgname_from_pvid(cmd, uuid); + return find_vgname_from_pvid(cmd, (char *)id.uuid); } const char *lvm_vgname_from_device(lvm_t libh, const char *device) From wysochanski@sourceware.org Wed May 19 13:21:00 2010 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Wed, 19 May 2010 13:21:00 -0000 Subject: LVM2/tools pvchange.c Message-ID: <20100519132113.5655.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2010-05-19 13:21:11 Modified files: tools : pvchange.c Log message: Remove hack in pvchange to unlock orphan VG. With agk's recent changes, the lock/unlock APIs can properly handle orphan VG names. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvchange.c.diff?cvsroot=lvm2&r1=1.74&r2=1.75 --- LVM2/tools/pvchange.c 2010/05/19 11:53:00 1.74 +++ LVM2/tools/pvchange.c 2010/05/19 13:21:09 1.75 @@ -263,9 +263,6 @@ pvl->pv, NULL); } - /* FIXME: we should be using #orphans_lvm2 everwhere */ - if (is_orphan_vg(vg->name)) - sll->str = VG_ORPHANS; unlock_and_release_vg(cmd, vg, sll->str); } } From wysochanski@sourceware.org Wed May 19 15:34:00 2010 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Wed, 19 May 2010 15:34:00 -0000 Subject: LVM2/tools pvchange.c Message-ID: <20100519153411.4823.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2010-05-19 15:34:10 Modified files: tools : pvchange.c Log message: Remove another pvchange hack involving orphan VG names. Unnecessary as a result of recent changes. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvchange.c.diff?cvsroot=lvm2&r1=1.75&r2=1.76 --- LVM2/tools/pvchange.c 2010/05/19 13:21:09 1.75 +++ LVM2/tools/pvchange.c 2010/05/19 15:34:10 1.76 @@ -229,9 +229,6 @@ total++; done += _pvchange_single(cmd, vg, pvl->pv, NULL); - /* FIXME: we should be using #orphans_lvm2 everwhere */ - if (is_orphan_vg(vg->name)) - vg_name = VG_ORPHANS; unlock_and_release_vg(cmd, vg, vg_name); } } else { From agk@sourceware.org Thu May 20 11:20:00 2010 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 20 May 2010 11:20:00 -0000 Subject: LVM2 ./WHATS_NEW ./make.tmpl.in scripts/Makefi ... Message-ID: <20100520112043.17465.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-05-20 11:20:38 Modified files: . : WHATS_NEW make.tmpl.in scripts : Makefile.in lvmconf.sh Log message: Install lvmconf script by default. Remove unnecessary versioned dmeventd plugin symlinks. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1567&r2=1.1568 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/make.tmpl.in.diff?cvsroot=lvm2&r1=1.98&r2=1.99 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/Makefile.in.diff?cvsroot=lvm2&r1=1.16&r2=1.17 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/lvmconf.sh.diff?cvsroot=lvm2&r1=1.6&r2=1.7 --- LVM2/WHATS_NEW 2010/05/19 11:57:05 1.1567 +++ LVM2/WHATS_NEW 2010/05/20 11:20:35 1.1568 @@ -1,5 +1,7 @@ Version 2.02.66 - =============================== + Install lvmconf script by default. + Remove unnecessary versioned dmeventd plugin symlinks. Add tests for lvm_vgname_from_{pvid|device}. Add lvm2app interfaces to lookup a vgname from a pvid and pvname. Update pvchange to always obtain a vg handle for each pv to process. --- LVM2/make.tmpl.in 2010/05/14 13:32:36 1.98 +++ LVM2/make.tmpl.in 2010/05/20 11:20:35 1.99 @@ -310,7 +310,6 @@ install_dm_plugin: $(LIB_SHARED) $(INSTALL_PROGRAM) -D $< $(libdir)/device-mapper/$( CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-05-20 11:45:58 Modified files: . : WHATS_NEW configure configure.in doc : Makefile.in Added files: doc : example.conf.in Removed files: doc : example.conf Log message: Generate example.conf so default lvm.conf contents can be configured. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1568&r2=1.1569 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.diff?cvsroot=lvm2&r1=1.127&r2=1.128 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.in.diff?cvsroot=lvm2&r1=1.137&r2=1.138 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.in.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/Makefile.in.diff?cvsroot=lvm2&r1=1.9&r2=1.10 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.diff?cvsroot=lvm2&r1=1.57&r2=NONE --- LVM2/WHATS_NEW 2010/05/20 11:20:35 1.1568 +++ LVM2/WHATS_NEW 2010/05/20 11:45:56 1.1569 @@ -1,5 +1,6 @@ Version 2.02.66 - =============================== + Generate example.conf so default lvm.conf contents can be configured. Install lvmconf script by default. Remove unnecessary versioned dmeventd plugin symlinks. Add tests for lvm_vgname_from_{pvid|device}. --- LVM2/configure 2010/05/11 08:48:43 1.127 +++ LVM2/configure 2010/05/20 11:45:56 1.128 @@ -15617,7 +15617,7 @@ ################################################################################ -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 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" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -16228,6 +16228,7 @@ "daemons/dmeventd/plugins/mirror/Makefile") CONFIG_FILES="$CONFIG_FILES daemons/dmeventd/plugins/mirror/Makefile" ;; "daemons/dmeventd/plugins/snapshot/Makefile") CONFIG_FILES="$CONFIG_FILES daemons/dmeventd/plugins/snapshot/Makefile" ;; "doc/Makefile") CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;; + "doc/example.conf") CONFIG_FILES="$CONFIG_FILES doc/example.conf" ;; "include/.symlinks") CONFIG_FILES="$CONFIG_FILES include/.symlinks" ;; "include/Makefile") CONFIG_FILES="$CONFIG_FILES include/Makefile" ;; "lib/Makefile") CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;; --- LVM2/configure.in 2010/05/11 08:48:43 1.137 +++ LVM2/configure.in 2010/05/20 11:45:57 1.138 @@ -1156,6 +1156,7 @@ daemons/dmeventd/plugins/mirror/Makefile daemons/dmeventd/plugins/snapshot/Makefile doc/Makefile +doc/example.conf include/.symlinks include/Makefile lib/Makefile /cvs/lvm2/LVM2/doc/example.conf.in,v --> standard output revision 1.1 --- LVM2/doc/example.conf.in +++ - 2010-05-20 11:46:02.382454000 +0000 @@ -0,0 +1,501 @@ +# This is an example configuration file for the LVM2 system. +# It contains the default settings that would be used if there was no +# /etc/lvm/lvm.conf file. +# +# Refer to 'man lvm.conf' for further information including the file layout. +# +# To put this file in a different directory and override /etc/lvm set +# the environment variable LVM_SYSTEM_DIR before running the tools. + + +# This section allows you to configure which block devices should +# be used by the LVM system. +devices { + + # Where do you want your volume groups to appear ? + dir = "/dev" + + # An array of directories that contain the device nodes you wish + # to use with LVM2. + scan = [ "/dev" ] + + # If several entries in the scanned directories correspond to the + # same block device and the tools need to display a name for device, + # all the pathnames are matched against each item in the following + # list of regular expressions in turn and the first match is used. + preferred_names = [ ] + + # Try to avoid using undescriptive /dev/dm-N names, if present. + # preferred_names = [ "^/dev/mpath/", "^/dev/mapper/mpath", "^/dev/[hs]d" ] + + # A filter that tells LVM2 to only use a restricted set of devices. + # The filter consists of an array of regular expressions. These + # expressions can be delimited by a character of your choice, and + # prefixed with either an 'a' (for accept) or 'r' (for reject). + # The first expression found to match a device name determines if + # the device will be accepted or rejected (ignored). Devices that + # don't match any patterns are accepted. + + # Be careful if there there are symbolic links or multiple filesystem + # entries for the same device as each name is checked separately against + # the list of patterns. The effect is that if any name matches any 'a' + # pattern, the device is accepted; otherwise if any name matches any 'r' + # pattern it is rejected; otherwise it is accepted. + + # Don't have more than one filter line active at once: only one gets used. + + # Run vgscan after you change this parameter to ensure that + # the cache file gets regenerated (see below). + # If it doesn't do what you expect, check the output of 'vgscan -vvvv'. + + + # By default we accept every block device: + filter = [ "a/.*/" ] + + # Exclude the cdrom drive + # filter = [ "r|/dev/cdrom|" ] + + # When testing I like to work with just loopback devices: + # filter = [ "a/loop/", "r/.*/" ] + + # Or maybe all loops and ide drives except hdc: + # filter =[ "a|loop|", "r|/dev/hdc|", "a|/dev/ide|", "r|.*|" ] + + # Use anchors if you want to be really specific + # filter = [ "a|^/dev/hda8$|", "r/.*/" ] + + # The results of the filtering are cached on disk to avoid + # rescanning dud devices (which can take a very long time). + # By default this cache is stored in the /etc/lvm/cache directory + # in a file called '.cache'. + # It is safe to delete the contents: the tools regenerate it. + # (The old setting 'cache' is still respected if neither of + # these new ones is present.) + cache_dir = "/etc/lvm/cache" + cache_file_prefix = "" + + # You can turn off writing this cache file by setting this to 0. + write_cache_state = 1 + + # Advanced settings. + + # List of pairs of additional acceptable block device types found + # in /proc/devices with maximum (non-zero) number of partitions. + # types = [ "fd", 16 ] + + # If sysfs is mounted (2.6 kernels) restrict device scanning to + # the block devices it believes are valid. + # 1 enables; 0 disables. + sysfs_scan = 1 + + # By default, LVM2 will ignore devices used as components of + # software RAID (md) devices by looking for md superblocks. + # 1 enables; 0 disables. + md_component_detection = 1 + + # By default, if a PV is placed directly upon an md device, LVM2 + # will align its data blocks with the md device's stripe-width. + # 1 enables; 0 disables. + md_chunk_alignment = 1 + + # By default, the start of a PV's data area will be a multiple of + # the 'minimum_io_size' or 'optimal_io_size' exposed in sysfs. + # - minimum_io_size - the smallest request the device can perform + # w/o incurring a read-modify-write penalty (e.g. MD's chunk size) + # - optimal_io_size - the device's preferred unit of receiving I/O + # (e.g. MD's stripe width) + # minimum_io_size is used if optimal_io_size is undefined (0). + # If md_chunk_alignment is enabled, that detects the optimal_io_size. + # This setting takes precedence over md_chunk_alignment. + # 1 enables; 0 disables. + data_alignment_detection = 1 + + # Alignment (in KB) of start of data area when creating a new PV. + # If a PV is placed directly upon an md device and md_chunk_alignment or + # data_alignment_detection is enabled this parameter is ignored. + # Set to 0 for the default alignment of 64KB or page size, if larger. + data_alignment = 0 + + # By default, the start of the PV's aligned data area will be shifted by + # the 'alignment_offset' exposed in sysfs. This offset is often 0 but + # may be non-zero; e.g.: certain 4KB sector drives that compensate for + # windows partitioning will have an alignment_offset of 3584 bytes + # (sector 7 is the lowest aligned logical block, the 4KB sectors start + # at LBA -1, and consequently sector 63 is aligned on a 4KB boundary). + # 1 enables; 0 disables. + data_alignment_offset_detection = 1 + + # If, while scanning the system for PVs, LVM2 encounters a device-mapper + # device that has its I/O suspended, it waits for it to become accessible. + # Set this to 1 to skip such devices. This should only be needed + # in recovery situations. + ignore_suspended_devices = 0 +} + +# This section that allows you to configure the nature of the +# information that LVM2 reports. +log { + + # Controls the messages sent to stdout or stderr. + # There are three levels of verbosity, 3 being the most verbose. + verbose = 0 + + # Should we send log messages through syslog? + # 1 is yes; 0 is no. + syslog = 1 + + # Should we log error and debug messages to a file? + # By default there is no log file. + #file = "/var/log/lvm2.log" + + # Should we overwrite the log file each time the program is run? + # By default we append. + overwrite = 0 + + # What level of log messages should we send to the log file and/or syslog? + # There are 6 syslog-like log levels currently in use - 2 to 7 inclusive. + # 7 is the most verbose (LOG_DEBUG). + level = 0 + + # Format of output messages + # Whether or not (1 or 0) to indent messages according to their severity + indent = 1 + + # Whether or not (1 or 0) to display the command name on each line output + command_names = 0 + + # A prefix to use before the message text (but after the command name, + # if selected). Default is two spaces, so you can see/grep the severity + # of each message. + prefix = " " + + # To make the messages look similar to the original LVM tools use: + # indent = 0 + # command_names = 1 + # prefix = " -- " + + # Set this if you want log messages during activation. + # Don't use this in low memory situations (can deadlock). + # activation = 0 +} + +# Configuration of metadata backups and archiving. In LVM2 when we +# talk about a 'backup' we mean making a copy of the metadata for the +# *current* system. The 'archive' contains old metadata configurations. +# Backups are stored in a human readeable text format. +backup { + + # Should we maintain a backup of the current metadata configuration ? + # Use 1 for Yes; 0 for No. + # Think very hard before turning this off! + backup = 1 + + # Where shall we keep it ? + # Remember to back up this directory regularly! + backup_dir = "/etc/lvm/backup" + + # Should we maintain an archive of old metadata configurations. + # Use 1 for Yes; 0 for No. + # On by default. Think very hard before turning this off. + archive = 1 + + # Where should archived files go ? + # Remember to back up this directory regularly! + archive_dir = "/etc/lvm/archive" + + # What is the minimum number of archive files you wish to keep ? + retain_min = 10 + + # What is the minimum time you wish to keep an archive file for ? + retain_days = 30 +} + +# Settings for the running LVM2 in shell (readline) mode. +shell { + + # Number of lines of history to store in ~/.lvm_history + history_size = 100 +} + + +# Miscellaneous global LVM2 settings +global { + + # The file creation mask for any files and directories created. + # Interpreted as octal if the first digit is zero. + umask = 077 + + # Allow other users to read the files + #umask = 022 + + # Enabling test mode means that no changes to the on disk metadata + # will be made. Equivalent to having the -t option on every + # command. Defaults to off. + test = 0 + + # Default value for --units argument + units = "h" + + # Since version 2.02.54, the tools distinguish between powers of + # 1024 bytes (e.g. KiB, MiB, GiB) and powers of 1000 bytes (e.g. + # KB, MB, GB). + # If you have scripts that depend on the old behaviour, set this to 0 + # temporarily until you update them. + si_unit_consistency = 1 + + # Whether or not to communicate with the kernel device-mapper. + # Set to 0 if you want to use the tools to manipulate LVM metadata + # without activating any logical volumes. + # If the device-mapper kernel driver is not present in your kernel + # setting this to 0 should suppress the error messages. + activation = 1 + + # If we can't communicate with device-mapper, should we try running + # the LVM1 tools? + # This option only applies to 2.4 kernels and is provided to help you + # switch between device-mapper kernels and LVM1 kernels. + # The LVM1 tools need to be installed with .lvm1 suffices + # e.g. vgscan.lvm1 and they will stop working after you start using + # the new lvm2 on-disk metadata format. + # The default value is set when the tools are built. + # fallback_to_lvm1 = 0 + + # The default metadata format that commands should use - "lvm1" or "lvm2". + # The command line override is -M1 or -M2. + # Defaults to "lvm2". + # format = "lvm2" + + # Location of proc filesystem + proc = "/proc" + + # Type of locking to use. Defaults to local file-based locking (1). + # Turn locking off by setting to 0 (dangerous: risks metadata corruption + # if LVM2 commands get run concurrently). + # Type 2 uses the external shared library locking_library. + # Type 3 uses built-in clustered locking. + # Type 4 uses read-only locking which forbids any operations that might + # change metadata. + locking_type = 1 + + # Set to 0 to fail when a lock request cannot be satisfied immediately. + wait_for_locks = 1 + + # If using external locking (type 2) and initialisation fails, + # with this set to 1 an attempt will be made to use the built-in + # clustered locking. + # If you are using a customised locking_library you should set this to 0. + fallback_to_clustered_locking = 1 + + # If an attempt to initialise type 2 or type 3 locking failed, perhaps + # because cluster components such as clvmd are not running, with this set + # to 1 an attempt will be made to use local file-based locking (type 1). + # If this succeeds, only commands against local volume groups will proceed. + # Volume Groups marked as clustered will be ignored. + fallback_to_local_locking = 1 + + # Local non-LV directory that holds file-based locks while commands are + # in progress. A directory like /tmp that may get wiped on reboot is OK. + locking_dir = "/var/lock/lvm" + + # Whenever there are competing read-only and read-write access requests for + # a volume group's metadata, instead of always granting the read-only + # requests immediately, delay them to allow the read-write requests to be + # serviced. Without this setting, write access may be stalled by a high + # volume of read-only requests. + # NB. This option only affects locking_type = 1 viz. local file-based + # locking. + prioritise_write_locks = 1 + + # Other entries can go here to allow you to load shared libraries + # e.g. if support for LVM1 metadata was compiled as a shared library use + # format_libraries = "liblvm2format1.so" + # Full pathnames can be given. + + # Search this directory first for shared libraries. + # library_dir = "/lib" + + # The external locking library to load if locking_type is set to 2. + # locking_library = "liblvm2clusterlock.so" + + # Treat any internal errors as fatal errors, aborting the process that + # encountered the internal error. Please only enable for debugging. + abort_on_internal_errors = 0 +} + +activation { + # Set to 0 to disable udev synchronisation (if compiled into the binaries). + # Processes will not wait for notification from udev. + # They will continue irrespective of any possible udev processing + # in the background. You should only use this if udev is not running + # or has rules that ignore the devices LVM2 creates. + # The command line argument --nodevsync takes precedence over this setting. + # If set to 1 when udev is not running, and there are LVM2 processes + # waiting for udev, run 'dmsetup udevcomplete_all' manually to wake them up. + udev_sync = 1 + + # Set to 0 to disable the udev rules installed by LVM2 (if built with + # --enable-udev_rules). LVM2 will then manage the /dev nodes and symlinks + # for active logical volumes directly itself. + # N.B. Manual intervention may be required if this setting is changed + # while any logical volumes are active. + udev_rules = 1 + + # How to fill in missing stripes if activating an incomplete volume. + # Using "error" will make inaccessible parts of the device return + # I/O errors on access. You can instead use a device path, in which + # case, that device will be used to in place of missing stripes. + # But note that using anything other than "error" with mirrored + # or snapshotted volumes is likely to result in data corruption. + missing_stripe_filler = "error" + + # How much stack (in KB) to reserve for use while devices suspended + reserved_stack = 256 + + # How much memory (in KB) to reserve for use while devices suspended + reserved_memory = 8192 + + # Nice value used while devices suspended + process_priority = -18 + + # If volume_list is defined, each LV is only activated if there is a + # match against the list. + # "vgname" and "vgname/lvname" are matched exactly. + # "@tag" matches any tag set in the LV or VG. + # "@*" matches if any tag defined on the host is also set in the LV or VG + # + # volume_list = [ "vg1", "vg2/lvol1", "@tag1", "@*" ] + + # Size (in KB) of each copy operation when mirroring + mirror_region_size = 512 + + # Setting to use when there is no readahead value stored in the metadata. + # + # "none" - Disable readahead. + # "auto" - Use default value chosen by kernel. + readahead = "auto" + + # 'mirror_image_fault_policy' and 'mirror_log_fault_policy' define + # how a device failure affecting a mirror is handled. + # A mirror is composed of mirror images (copies) and a log. + # A disk log ensures that a mirror does not need to be re-synced + # (all copies made the same) every time a machine reboots or crashes. + # + # In the event of a failure, the specified policy will be used to determine + # what happens. This applies to automatic repairs (when the mirror is being + # monitored by dmeventd) and to manual lvconvert --repair when + # --use-policies is given. + # + # "remove" - Simply remove the faulty device and run without it. If + # the log device fails, the mirror would convert to using + # an in-memory log. This means the mirror will not + # remember its sync status across crashes/reboots and + # the entire mirror will be re-synced. If a + # mirror image fails, the mirror will convert to a + # non-mirrored device if there is only one remaining good + # copy. + # + # "allocate" - Remove the faulty device and try to allocate space on + # a new device to be a replacement for the failed device. + # Using this policy for the log is fast and maintains the + # ability to remember sync state through crashes/reboots. + # Using this policy for a mirror device is slow, as it + # requires the mirror to resynchronize the devices, but it + # will preserve the mirror characteristic of the device. + # This policy acts like "remove" if no suitable device and + # space can be allocated for the replacement. + # + # "allocate_anywhere" - Not yet implemented. Useful to place the log device + # temporarily on same physical volume as one of the mirror + # images. This policy is not recommended for mirror devices + # since it would break the redundant nature of the mirror. This + # policy acts like "remove" if no suitable device and space can + # be allocated for the replacement. + + mirror_log_fault_policy = "allocate" + mirror_image_fault_policy = "remove" + + # While activating devices, I/O to devices being (re)configured is + # suspended, and as a precaution against deadlocks, LVM2 needs to pin + # any memory it is using so it is not paged out. Groups of pages that + # are known not to be accessed during activation need not be pinned + # into memory. Each string listed in this setting is compared against + # each line in /proc/self/maps, and the pages corresponding to any + # lines that match are not pinned. On some systems locale-archive was + # found to make up over 80% of the memory used by the process. + # mlock_filter = [ "locale/locale-archive", "gconv/gconv-modules.cache" ] + + # Set to 1 to revert to the default behaviour prior to version 2.02.62 + # which used mlockall() to pin the whole process's memory while activating + # devices. + use_mlockall = 0 + + # Monitoring is enabled by default when activating logical volumes. + # Set to 0 to disable monitoring or use the --ignoremonitoring option. + monitoring = 1 + + # When pvmove or lvconvert must wait for the kernel to finish + # synchronising or merging data, they check and report progress + # at intervals of this number of seconds. The default is 15 seconds. + # If this is set to 0 and there is only one thing to wait for, there + # are no progress reports, but the process is awoken immediately the + # operation is complete. + polling_interval = 15 +} + + +#################### +# Advanced section # +#################### + +# Metadata settings +# +# metadata { + # Default number of copies of metadata to hold on each PV. 0, 1 or 2. + # You might want to override it from the command line with 0 + # when running pvcreate on new PVs which are to be added to large VGs. + + # pvmetadatacopies = 1 + + # Approximate default size of on-disk metadata areas in sectors. + # You should increase this if you have large volume groups or + # you want to retain a large on-disk history of your metadata changes. + + # pvmetadatasize = 255 + + # List of directories holding live copies of text format metadata. + # These directories must not be on logical volumes! + # It's possible to use LVM2 with a couple of directories here, + # preferably on different (non-LV) filesystems, and with no other + # on-disk metadata (pvmetadatacopies = 0). Or this can be in + # addition to on-disk metadata areas. + # The feature was originally added to simplify testing and is not + # supported under low memory situations - the machine could lock up. + # + # Never edit any files in these directories by hand unless you + # you are absolutely sure you know what you are doing! Use + # the supplied toolset to make changes (e.g. vgcfgrestore). + + # dirs = [ "/etc/lvm/metadata", "/mnt/disk2/lvm/metadata2" ] +#} + +# Event daemon +# +dmeventd { + # mirror_library is the library used when monitoring a mirror device. + # + # "libdevmapper-event-lvm2mirror.so" attempts to recover from + # failures. It removes failed devices from a volume group and + # reconfigures a mirror as necessary. If no mirror library is + # provided, mirrors are not monitored through dmeventd. + + mirror_library = "libdevmapper-event-lvm2mirror.so" + + # snapshot_library is the library used when monitoring a snapshot device. + # + # "libdevmapper-event-lvm2snapshot.so" monitors the filling of + # snapshots and emits a warning through syslog, when the use of + # snapshot exceedes 80%. The warning is repeated when 85%, 90% and + # 95% of the snapshot are filled. + + snapshot_library = "libdevmapper-event-lvm2snapshot.so" +} --- LVM2/doc/Makefile.in 2010/04/09 21:42:49 1.9 +++ LVM2/doc/Makefile.in 2010/05/20 11:45:57 1.10 @@ -15,7 +15,7 @@ top_srcdir = @top_srcdir@ top_builddir = @top_builddir@ -CONFSRC=$(srcdir)/example.conf +CONFSRC=example.conf CONFDEST=lvm.conf include $(top_builddir)/make.tmpl From agk@sourceware.org Thu May 20 13:47:00 2010 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 20 May 2010 13:47:00 -0000 Subject: LVM2 ./Makefile.in ./WHATS_NEW ./configure ./c ... Message-ID: <20100520134728.25433.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-05-20 13:47:22 Modified files: . : Makefile.in WHATS_NEW configure configure.in make.tmpl.in doc : example.conf.in lib/config : defaults.h lib/misc : configure.h.in man : Makefile.in lvm.8.in lvm.conf.5.in vgcfgbackup.8.in Log message: Add install_system_dirs makefile target. Add configure options for system and locking directories. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/Makefile.in.diff?cvsroot=lvm2&r1=1.52&r2=1.53 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1569&r2=1.1570 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.diff?cvsroot=lvm2&r1=1.128&r2=1.129 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.in.diff?cvsroot=lvm2&r1=1.138&r2=1.139 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/make.tmpl.in.diff?cvsroot=lvm2&r1=1.99&r2=1.100 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.in.diff?cvsroot=lvm2&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/defaults.h.diff?cvsroot=lvm2&r1=1.59&r2=1.60 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/configure.h.in.diff?cvsroot=lvm2&r1=1.19&r2=1.20 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/Makefile.in.diff?cvsroot=lvm2&r1=1.36&r2=1.37 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvm.8.in.diff?cvsroot=lvm2&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvm.conf.5.in.diff?cvsroot=lvm2&r1=1.7&r2=1.8 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/vgcfgbackup.8.in.diff?cvsroot=lvm2&r1=1.1&r2=1.2 --- LVM2/Makefile.in 2010/04/13 13:28:52 1.52 +++ LVM2/Makefile.in 2010/05/20 13:47:21 1.53 @@ -78,6 +78,14 @@ check check_cluster check_local: all $(MAKE) -C test $(@) +install_system_dirs: + $(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_SYS_DIR) + $(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_ARCHIVE_DIR) + $(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_BACKUP_DIR) + $(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_CACHE_DIR) + $(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_LOCK_DIR) + $(INSTALL_ROOT_DATA) /dev/null $(DESTDIR)$(DEFAULT_CACHE_DIR)/.cache + LCOV_TRACES = libdm.info lib.info tools.info \ daemons/dmeventd.info daemons/clvmd.info CLEAN_TARGETS += $(LCOV_TRACES) --- LVM2/WHATS_NEW 2010/05/20 11:45:56 1.1569 +++ LVM2/WHATS_NEW 2010/05/20 13:47:21 1.1570 @@ -1,5 +1,7 @@ Version 2.02.66 - =============================== + Add install_system_dirs makefile target. + Add configure options for system and locking directories. Generate example.conf so default lvm.conf contents can be configured. Install lvmconf script by default. Remove unnecessary versioned dmeventd plugin symlinks. --- LVM2/configure 2010/05/20 11:45:56 1.128 +++ LVM2/configure 2010/05/20 13:47:21 1.129 @@ -689,6 +689,11 @@ DMEVENTD DL_LIBS DEVMAPPER +DEFAULT_LOCK_DIR +DEFAULT_CACHE_SUBDIR +DEFAULT_BACKUP_SUBDIR +DEFAULT_ARCHIVE_SUBDIR +DEFAULT_SYS_DIR DEBUG COPTIMISE_FLAG CONFDIR @@ -851,6 +856,11 @@ with_udevdir with_dmeventd_pidfile with_dmeventd_path +with_default_system_dir +with_default_archive_subdir +with_default_backup_subdir +with_default_cache_subdir +with_default_locking_dir with_interface ' ac_precious_vars='build_alias @@ -1573,6 +1583,11 @@ --with-udevdir=DIR udev rules in DIR [UPREFIX/lib/udev/rules.d] --with-dmeventd-pidfile=PATH dmeventd pidfile [/var/run/dmeventd.pid] --with-dmeventd-path=PATH dmeventd path [EPREFIX/sbin/dmeventd] + --with-default-system-dir=DIR Default LVM system directory [/etc/lvm] + --with-default-archive-subdir=SUBDIR Default metadata archive subdir [archive] + --with-default-backup-subdir=SUBDIR Default metadata backup subdir [backup] + --with-default-cache-subdir=SUBDIR Default metadata cache subdir [cache] + --with-default-locking-dir=DIR Default locking directory [/var/lock/lvm] --with-interface=IFACE Choose kernel interface (ioctl) [ioctl] Some influential environment variables: @@ -15485,6 +15500,82 @@ fi ################################################################################ + + + +# Check whether --with-default-system-dir was given. +if test "${with_default_system_dir+set}" = set; then + withval=$with_default_system_dir; DEFAULT_SYS_DIR="$withval" +else + DEFAULT_SYS_DIR="/etc/lvm" +fi + +cat >>confdefs.h <<_ACEOF +#define DEFAULT_SYS_DIR "$DEFAULT_SYS_DIR" +_ACEOF + + + + + +# Check whether --with-default-archive-subdir was given. +if test "${with_default_archive_subdir+set}" = set; then + withval=$with_default_archive_subdir; DEFAULT_ARCHIVE_SUBDIR="$withval" +else + DEFAULT_ARCHIVE_SUBDIR="archive" +fi + +cat >>confdefs.h <<_ACEOF +#define DEFAULT_ARCHIVE_SUBDIR "$DEFAULT_ARCHIVE_SUBDIR" +_ACEOF + + + + + +# Check whether --with-default-backup-subdir was given. +if test "${with_default_backup_subdir+set}" = set; then + withval=$with_default_backup_subdir; DEFAULT_BACKUP_SUBDIR="$withval" +else + DEFAULT_BACKUP_SUBDIR="backup" +fi + +cat >>confdefs.h <<_ACEOF +#define DEFAULT_BACKUP_SUBDIR "$DEFAULT_BACKUP_SUBDIR" +_ACEOF + + + + + +# Check whether --with-default-cache-subdir was given. +if test "${with_default_cache_subdir+set}" = set; then + withval=$with_default_cache_subdir; DEFAULT_CACHE_SUBDIR="$withval" +else + DEFAULT_CACHE_SUBDIR="cache" +fi + +cat >>confdefs.h <<_ACEOF +#define DEFAULT_CACHE_SUBDIR "$DEFAULT_CACHE_SUBDIR" +_ACEOF + + + + + +# Check whether --with-default-locking-dir was given. +if test "${with_default_locking_dir+set}" = set; then + withval=$with_default_locking_dir; DEFAULT_LOCK_DIR="$withval" +else + DEFAULT_LOCK_DIR="/var/lock/lvm" +fi + +cat >>confdefs.h <<_ACEOF +#define DEFAULT_LOCK_DIR "$DEFAULT_LOCK_DIR" +_ACEOF + + +################################################################################ { $as_echo "$as_me:$LINENO: checking for kernel interface choice" >&5 $as_echo_n "checking for kernel interface choice... " >&6; } @@ -15616,6 +15707,11 @@ + + + + + ################################################################################ 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" --- LVM2/configure.in 2010/05/20 11:45:57 1.138 +++ LVM2/configure.in 2010/05/20 13:47:21 1.139 @@ -1020,6 +1020,43 @@ fi ################################################################################ +dnl -- various defaults +AH_TEMPLATE(DEFAULT_SYS_DIR, [Path to LVM system directory.]) +AC_ARG_WITH(default-system-dir, + [ --with-default-system-dir=DIR Default LVM system directory [[/etc/lvm]] ], + [ DEFAULT_SYS_DIR="$withval" ], + [ DEFAULT_SYS_DIR="/etc/lvm" ]) +AC_DEFINE_UNQUOTED(DEFAULT_SYS_DIR,["$DEFAULT_SYS_DIR"] ) + +AH_TEMPLATE(DEFAULT_ARCHIVE_SUBDIR, [Name of default metadata archive subdirectory.]) +AC_ARG_WITH(default-archive-subdir, + [ --with-default-archive-subdir=SUBDIR Default metadata archive subdir [[archive]] ], + [ DEFAULT_ARCHIVE_SUBDIR="$withval" ], + [ DEFAULT_ARCHIVE_SUBDIR="archive" ]) +AC_DEFINE_UNQUOTED(DEFAULT_ARCHIVE_SUBDIR,["$DEFAULT_ARCHIVE_SUBDIR"]) + +AH_TEMPLATE(DEFAULT_BACKUP_SUBDIR, [Name of default metadata backup subdirectory.]) +AC_ARG_WITH(default-backup-subdir, + [ --with-default-backup-subdir=SUBDIR Default metadata backup subdir [[backup]] ], + [ DEFAULT_BACKUP_SUBDIR="$withval" ], + [ DEFAULT_BACKUP_SUBDIR="backup" ]) +AC_DEFINE_UNQUOTED(DEFAULT_BACKUP_SUBDIR,["$DEFAULT_BACKUP_SUBDIR"] ) + +AH_TEMPLATE(DEFAULT_CACHE_SUBDIR, [Name of default metadata backup subdirectory.]) +AC_ARG_WITH(default-cache-subdir, + [ --with-default-cache-subdir=SUBDIR Default metadata cache subdir [[cache]] ], + [ DEFAULT_CACHE_SUBDIR="$withval" ], + [ DEFAULT_CACHE_SUBDIR="cache" ]) +AC_DEFINE_UNQUOTED(DEFAULT_CACHE_SUBDIR,["$DEFAULT_CACHE_SUBDIR"] ) + +AH_TEMPLATE(DEFAULT_LOCK_DIR, [Name of default locking directory.]) +AC_ARG_WITH(default-locking-dir, + [ --with-default-locking-dir=DIR Default locking directory [[/var/lock/lvm]] ], + [ DEFAULT_LOCK_DIR="$withval" ], + [ DEFAULT_LOCK_DIR="/var/lock/lvm" ]) +AC_DEFINE_UNQUOTED(DEFAULT_LOCK_DIR,["$DEFAULT_LOCK_DIR"] ) + +################################################################################ dnl -- which kernel interface to use (ioctl only) AC_MSG_CHECKING(for kernel interface choice) AC_ARG_WITH(interface, @@ -1075,6 +1112,11 @@ AC_SUBST(CPG_LIBS) AC_SUBST(CSCOPE_CMD) AC_SUBST(DEBUG) +AC_SUBST(DEFAULT_SYS_DIR) +AC_SUBST(DEFAULT_ARCHIVE_SUBDIR) +AC_SUBST(DEFAULT_BACKUP_SUBDIR) +AC_SUBST(DEFAULT_CACHE_SUBDIR) +AC_SUBST(DEFAULT_LOCK_DIR) AC_SUBST(DEVMAPPER) AC_SUBST(DLM_CFLAGS) AC_SUBST(DLM_LIBS) --- LVM2/make.tmpl.in 2010/05/20 11:20:35 1.99 +++ LVM2/make.tmpl.in 2010/05/20 13:47:21 1.100 @@ -67,6 +67,12 @@ USRLIB_RELPATH = $(shell echo $(abspath $(usrlibdir) $(libdir)) | \ $(AWK) -f $(top_srcdir)/scripts/relpath.awk) +DEFAULT_SYS_DIR = @DEFAULT_SYS_DIR@ +DEFAULT_ARCHIVE_DIR = $(DEFAULT_SYS_DIR)/@DEFAULT_ARCHIVE_SUBDIR@ +DEFAULT_BACKUP_DIR = $(DEFAULT_SYS_DIR)/@DEFAULT_BACKUP_SUBDIR@ +DEFAULT_CACHE_DIR = $(DEFAULT_SYS_DIR)/@DEFAULT_CACHE_SUBDIR@ +DEFAULT_LOCK_DIR = @DEFAULT_LOCK_DIR@ + # Setup vpath search paths for some suffixes vpath %.c $(srcdir) vpath %.in $(srcdir) @@ -94,6 +100,9 @@ INSTALL_DATA = $(INSTALL) -p $(M_INSTALL_DATA) INSTALL_WDATA = $(INSTALL) -p -m 644 +INSTALL_ROOT_DIR = $(INSTALL) -m 0700 -d +INSTALL_ROOT_DATA = $(INSTALL) -m 0600 + .SUFFIXES: .c .d .o .so .a .po .pot .mo .dylib CFLAGS += -fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wmissing-noreturn -Wformat-security --- LVM2/doc/example.conf.in 2010/05/20 11:45:57 1.1 +++ LVM2/doc/example.conf.in 2010/05/20 13:47:21 1.2 @@ -1,10 +1,10 @@ # This is an example configuration file for the LVM2 system. # It contains the default settings that would be used if there was no -# /etc/lvm/lvm.conf file. +# @DEFAULT_SYS_DIR@/lvm.conf file. # # Refer to 'man lvm.conf' for further information including the file layout. # -# To put this file in a different directory and override /etc/lvm set +# To put this file in a different directory and override @DEFAULT_SYS_DIR@ set # the environment variable LVM_SYSTEM_DIR before running the tools. @@ -66,12 +66,12 @@ # The results of the filtering are cached on disk to avoid # rescanning dud devices (which can take a very long time). - # By default this cache is stored in the /etc/lvm/cache directory + # By default this cache is stored in the @DEFAULT_SYS_DIR@/@DEFAULT_CACHE_SUBDIR@ directory # in a file called '.cache'. # It is safe to delete the contents: the tools regenerate it. # (The old setting 'cache' is still respected if neither of # these new ones is present.) - cache_dir = "/etc/lvm/cache" + cache_dir = "@DEFAULT_SYS_DIR@/@DEFAULT_CACHE_SUBDIR@" cache_file_prefix = "" # You can turn off writing this cache file by setting this to 0. @@ -192,7 +192,7 @@ # Where shall we keep it ? # Remember to back up this directory regularly! - backup_dir = "/etc/lvm/backup" + backup_dir = "@DEFAULT_SYS_DIR@/@DEFAULT_BACKUP_SUBDIR@" # Should we maintain an archive of old metadata configurations. # Use 1 for Yes; 0 for No. @@ -201,7 +201,7 @@ # Where should archived files go ? # Remember to back up this directory regularly! - archive_dir = "/etc/lvm/archive" + archive_dir = "@DEFAULT_SYS_DIR@/@DEFAULT_ARCHIVE_SUBDIR@" # What is the minimum number of archive files you wish to keep ? retain_min = 10 @@ -295,7 +295,7 @@ # Local non-LV directory that holds file-based locks while commands are # in progress. A directory like /tmp that may get wiped on reboot is OK. - locking_dir = "/var/lock/lvm" + locking_dir = "@DEFAULT_LOCK_DIR@" # Whenever there are competing read-only and read-write access requests for # a volume group's metadata, instead of always granting the read-only --- LVM2/lib/config/defaults.h 2010/03/05 14:48:34 1.59 +++ LVM2/lib/config/defaults.h 2010/05/20 13:47:21 1.60 @@ -19,15 +19,11 @@ #define DEFAULT_ARCHIVE_ENABLED 1 #define DEFAULT_BACKUP_ENABLED 1 -#define DEFAULT_ARCHIVE_SUBDIR "archive" -#define DEFAULT_BACKUP_SUBDIR "backup" -#define DEFAULT_CACHE_SUBDIR "cache" #define DEFAULT_CACHE_FILE_PREFIX "" #define DEFAULT_ARCHIVE_DAYS 30 #define DEFAULT_ARCHIVE_NUMBER 10 -#define DEFAULT_SYS_DIR "/etc/lvm" #define DEFAULT_DEV_DIR "/dev" #define DEFAULT_PROC_DIR "/proc" #define DEFAULT_SYSFS_SCAN 1 @@ -37,7 +33,6 @@ #define DEFAULT_DATA_ALIGNMENT_OFFSET_DETECTION 1 #define DEFAULT_DATA_ALIGNMENT_DETECTION 1 -#define DEFAULT_LOCK_DIR "/var/lock/lvm" #define DEFAULT_LOCKING_LIB "liblvm2clusterlock.so" #define DEFAULT_FALLBACK_TO_LOCAL_LOCKING 1 #define DEFAULT_FALLBACK_TO_CLUSTERED_LOCKING 1 --- LVM2/lib/misc/configure.h.in 2010/03/23 14:44:42 1.19 +++ LVM2/lib/misc/configure.h.in 2010/05/20 13:47:21 1.20 @@ -17,9 +17,24 @@ /* Define to 1 if using `alloca.c'. */ #undef C_ALLOCA +/* Name of default metadata archive subdirectory. */ +#undef DEFAULT_ARCHIVE_SUBDIR + +/* Name of default metadata backup subdirectory. */ +#undef DEFAULT_BACKUP_SUBDIR + +/* Name of default metadata backup subdirectory. */ +#undef DEFAULT_CACHE_SUBDIR + +/* Name of default locking directory. */ +#undef DEFAULT_LOCK_DIR + /* Define to 0 to reinstate the pre-2.02.54 handling of unit suffixes. */ #undef DEFAULT_SI_UNIT_CONSISTENCY +/* Path to LVM system directory. */ +#undef DEFAULT_SYS_DIR + /* Define to 1 to enable LVM2 device-mapper interaction. */ #undef DEVMAPPER_SUPPORT --- LVM2/man/Makefile.in 2010/04/09 21:42:51 1.36 +++ LVM2/man/Makefile.in 2010/05/20 13:47:22 1.37 @@ -67,7 +67,7 @@ %: %.in @case "$@" in \ */*) ;; \ - *) echo "Creating $@" ; $(SED) -e "s/#VERSION#/$(LVM_VERSION)/" $< > $@ ;; \ + *) echo "Creating $@" ; $(SED) -e "s+#VERSION#+$(LVM_VERSION)+;s+#DEFAULT_SYS_DIR#+$(DEFAULT_SYS_DIR)+;s+#DEFAULT_ARCHIVE_DIR#+$(DEFAULT_ARCHIVE_DIR)+;s+#DEFAULT_BACKUP_DIR#+$(DEFAULT_BACKUP_DIR)+;s+#DEFAULT_CACHE_DIR#+$(DEFAULT_CACHE_DIR)+;s+#DEFAULT_LOCK_DIR#+$(DEFAULT_LOCK_DIR)+" $< > $@ ;; \ esac install_man5: $(MAN5) --- LVM2/man/lvm.8.in 2009/09/14 19:42:13 1.4 +++ LVM2/man/lvm.8.in 2010/05/20 13:47:22 1.5 @@ -254,7 +254,7 @@ \fBLVM_SYSTEM_DIR\fP Directory containing lvm.conf and other LVM system files. -Defaults to "/etc/lvm". +Defaults to "#DEFAULT_SYS_DIR#". .TP \fBHOME\fP Directory containing .lvm_history if the internal readline shell @@ -277,7 +277,7 @@ .SH DIAGNOSTICS All tools return a status code of zero on success or non-zero on failure. .SH FILES -.I /etc/lvm/lvm.conf +.I #DEFAULT_SYS_DIR#/lvm.conf .br .I $HOME/.lvm_history .SH SEE ALSO --- LVM2/man/lvm.conf.5.in 2009/09/15 13:49:11 1.7 +++ LVM2/man/lvm.conf.5.in 2010/05/20 13:47:22 1.8 @@ -2,7 +2,7 @@ .SH NAME lvm.conf \- Configuration file for LVM2 .SH SYNOPSIS -.B /etc/lvm/lvm.conf +.B #DEFAULT_SYS_DIR#/lvm.conf .SH DESCRIPTION lvm.conf is loaded during the initialisation phase of \fBlvm\fP (8). This file can in turn lead to other files @@ -105,7 +105,7 @@ \fBdevices { filter=["r|cdrom|"] }\fP .IP \fBcache_dir\fP \(em Persistent filter cache file directory. -Defaults to "/etc/lvm/cache". +Defaults to "#DEFAULT_CACHE_DIR#". .IP \fBwrite_cache_state\fP \(em Set to 0 to disable the writing out of the persistent filter cache file when \fBlvm\fP exits. @@ -206,12 +206,12 @@ .IP \fBarchive_dir\fP \(em Directory used for automatic metadata archives. Backup copies of former metadata for each volume group are archived here. -Defaults to "/etc/lvm/archive". +Defaults to "#DEFAULT_ARCHIVE_DIR#". .IP \fBbackup_dir\fP \(em Directory used for automatic metadata backups. A single backup copy of the current metadata for each volume group is stored here. -Defaults to "/etc/lvm/backup". +Defaults to "#DEFAULT_BACKUP_DIR#". .IP \fBarchive\fP \(em Whether or not tools automatically archive existing metadata into \fBarchive_dir\fP before making changes to it. @@ -420,11 +420,11 @@ understand how things work: to make changes you should always use the tools as normal, or else vgcfgbackup, edit backup, vgcfgrestore. .SH FILES -.I /etc/lvm/lvm.conf -.I /etc/lvm/archive -.I /etc/lvm/backup -.I /etc/lvm/cache/.cache -.I /var/lock/lvm +.I #DEFAULT_SYS_DIR#/lvm.conf +.I #DEFAULT_ARCHIVE_DIR# +.I #DEFAULT_BACKUP_DIR# +.I #DEFAULT_CACHE_DIR#/.cache +.I #DEFAULT_LOCK_DIR# .SH SEE ALSO .BR lvm (8), .BR umask (2), --- LVM2/man/vgcfgbackup.8.in 2008/10/08 12:50:13 1.1 +++ LVM2/man/vgcfgbackup.8.in 2010/05/20 13:47:22 1.2 @@ -18,13 +18,13 @@ will be backed up. .sp In a default installation, each volume group gets backed up into a separate -file bearing the name of the volume group in the directory /etc/lvm/backup. +file bearing the name of the volume group in the directory #DEFAULT_BACKUP_DIR#. You can write the backup to an alternative file using -f. In this case if you are backing up more than one volume group the filename is treated as a template, and %s gets replaced by the volume group name. .sp NB. This DOESN'T backup user/system data in logical -volume(s)! Backup /etc/lvm regularly too. +volume(s)! Backup #DEFAULT_SYS_DIR# regularly too. .SH OPTIONS See \fBlvm\fP for common options. .SH SEE ALSO From agk@sourceware.org Thu May 20 14:45:00 2010 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 20 May 2010 14:45:00 -0000 Subject: LVM2 ./Makefile.in ./WHATS_NEW ./make.tmpl.in ... Message-ID: <20100520144520.5880.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-05-20 14:45:17 Modified files: . : Makefile.in WHATS_NEW make.tmpl.in scripts : Makefile.in Log message: Add make install_initscripts Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/Makefile.in.diff?cvsroot=lvm2&r1=1.53&r2=1.54 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1570&r2=1.1571 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/make.tmpl.in.diff?cvsroot=lvm2&r1=1.100&r2=1.101 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/Makefile.in.diff?cvsroot=lvm2&r1=1.17&r2=1.18 --- LVM2/Makefile.in 2010/05/20 13:47:21 1.53 +++ LVM2/Makefile.in 2010/05/20 14:45:14 1.54 @@ -86,6 +86,9 @@ $(INSTALL_ROOT_DIR) $(DESTDIR)$(DEFAULT_LOCK_DIR) $(INSTALL_ROOT_DATA) /dev/null $(DESTDIR)$(DEFAULT_CACHE_DIR)/.cache +install_initscripts: + $(MAKE) -C scripts install_initscripts + LCOV_TRACES = libdm.info lib.info tools.info \ daemons/dmeventd.info daemons/clvmd.info CLEAN_TARGETS += $(LCOV_TRACES) --- LVM2/WHATS_NEW 2010/05/20 13:47:21 1.1570 +++ LVM2/WHATS_NEW 2010/05/20 14:45:14 1.1571 @@ -1,6 +1,6 @@ Version 2.02.66 - =============================== - Add install_system_dirs makefile target. + Add install_system_dirs and install_initscripts makefile targets. Add configure options for system and locking directories. Generate example.conf so default lvm.conf contents can be configured. Install lvmconf script by default. --- LVM2/make.tmpl.in 2010/05/20 13:47:21 1.100 +++ LVM2/make.tmpl.in 2010/05/20 14:45:14 1.101 @@ -90,7 +90,7 @@ # Handle installation of files ifeq ("@WRITE_INSTALL@", "yes") # leaving defaults -M_INSTALL_PROGRAM = +M_INSTALL_SCRIPT = M_INSTALL_DATA = -m 644 else M_INSTALL_PROGRAM = -m 555 @@ -100,8 +100,10 @@ INSTALL_DATA = $(INSTALL) -p $(M_INSTALL_DATA) INSTALL_WDATA = $(INSTALL) -p -m 644 +INSTALL_DIR = $(INSTALL) -m 0755 -d INSTALL_ROOT_DIR = $(INSTALL) -m 0700 -d INSTALL_ROOT_DATA = $(INSTALL) -m 0600 +INSTALL_SCRIPT = $(INSTALL) -p -m $(M_INSTALL_PROGRAM) .SUFFIXES: .c .d .o .so .a .po .pot .mo .dylib --- LVM2/scripts/Makefile.in 2010/05/20 11:20:38 1.17 +++ LVM2/scripts/Makefile.in 2010/05/20 14:45:17 1.18 @@ -31,4 +31,15 @@ install: install_lvm2 +# FIXME Customise for other distributions +install_initscripts: + $(INSTALL_DIR) $(DESTDIR)/etc/rc.d/init.d + $(INSTALL_SCRIPT) lvm2_monitoring_init_red_hat $(DESTDIR)/etc/rc.d/init.d/lvm2-monitor +ifneq ("@CLVMD@", "none") + $(INSTALL_SCRIPT) clvmd_init_red_hat $(DESTDIR)/etc/rc.d/init.d/clvmd +endif +ifeq ("@BUILD_CMIRRORD@", "yes") + $(INSTALL_SCRIPT) cmirrord_init_red_hat $(DESTDIR)/etc/rc.d/init.d/cmirrord +endif + DISTCLEAN_TARGETS += clvmd_init_red_hat cmirrord_init_red_hat lvm2_monitoring_init_red_hat From agk@sourceware.org Thu May 20 22:24:00 2010 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 20 May 2010 22:24:00 -0000 Subject: LVM2 ./WHATS_NEW lib/report/report.c Message-ID: <20100520222437.12972.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-05-20 22:24:35 Modified files: . : WHATS_NEW lib/report : report.c Log message: If unable to obtain snapshot percentage leave value blank on reports. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1571&r2=1.1572 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.115&r2=1.116 --- LVM2/WHATS_NEW 2010/05/20 14:45:14 1.1571 +++ LVM2/WHATS_NEW 2010/05/20 22:24:33 1.1572 @@ -1,5 +1,6 @@ Version 2.02.66 - =============================== + If unable to obtain snapshot percentage leave value blank on reports. Add install_system_dirs and install_initscripts makefile targets. Add configure options for system and locking directories. Generate example.conf so default lvm.conf contents can be configured. --- LVM2/lib/report/report.c 2010/02/15 20:27:33 1.115 +++ LVM2/lib/report/report.c 2010/05/20 22:24:35 1.116 @@ -1019,7 +1019,7 @@ } if ((!lv_is_cow(lv) && !lv_is_merging_origin(lv)) || - (lv_info(lv->vg->cmd, lv, &info, 0, 0) && !info.exists)) { + !lv_info(lv->vg->cmd, lv, &info, 0, 0) || !info.exists) { *sortval = UINT64_C(0); dm_report_field_set_value(field, "", sortval); return 1; From agk@sourceware.org Thu May 20 22:27:00 2010 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 20 May 2010 22:27:00 -0000 Subject: LVM2 VERSION VERSION_DM WHATS_NEW WHATS_NEW_DM Message-ID: <20100520222727.14892.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-05-20 22:27:26 Modified files: . : VERSION VERSION_DM WHATS_NEW WHATS_NEW_DM Log message: pre-release Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/VERSION.diff?cvsroot=lvm2&r1=1.236&r2=1.237 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/VERSION_DM.diff?cvsroot=lvm2&r1=1.47&r2=1.48 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1572&r2=1.1573 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.371&r2=1.372 --- LVM2/VERSION 2010/05/17 20:18:13 1.236 +++ LVM2/VERSION 2010/05/20 22:27:26 1.237 @@ -1 +1 @@ -2.02.66(2)-cvs (2010-05-17) +2.02.66(2)-cvs (2010-05-20) --- LVM2/VERSION_DM 2010/05/17 20:18:13 1.47 +++ LVM2/VERSION_DM 2010/05/20 22:27:26 1.48 @@ -1 +1 @@ -1.02.49-cvs (2010-05-17) +1.02.48-cvs (2010-05-20) --- LVM2/WHATS_NEW 2010/05/20 22:24:33 1.1572 +++ LVM2/WHATS_NEW 2010/05/20 22:27:26 1.1573 @@ -1,4 +1,4 @@ -Version 2.02.66 - +Version 2.02.66 - 20th May 2010 =============================== If unable to obtain snapshot percentage leave value blank on reports. Add install_system_dirs and install_initscripts makefile targets. @@ -9,7 +9,7 @@ Add tests for lvm_vgname_from_{pvid|device}. Add lvm2app interfaces to lookup a vgname from a pvid and pvname. Update pvchange to always obtain a vg handle for each pv to process. - Add Add find_vgname_from_{pvname|pvid} functions. + Add find_vgname_from_{pvname|pvid} functions. Add pvid_from_devname and lvmcache_vgname_from_pvid lvmcache functions. Validate orphan and VG_GLOBAL lock order too. Accept orphan VG names as parameters to lock_vol() and related functions. --- LVM2/WHATS_NEW_DM 2010/05/17 20:18:13 1.371 +++ LVM2/WHATS_NEW_DM 2010/05/20 22:27:26 1.372 @@ -1,6 +1,3 @@ -Version 1.02.49 - -================================ - Version 1.02.48 - 17th May 2010 ================================ Use -d to control level of messages sent to syslog by dmeventd. From agk@sourceware.org Thu May 20 22:32:00 2010 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 20 May 2010 22:32:00 -0000 Subject: LVM2 ./configure.in lib/misc/configure.h.in Message-ID: <20100520223245.16798.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-05-20 22:32:44 Modified files: . : configure.in lib/misc : configure.h.in Log message: backup->cache Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.in.diff?cvsroot=lvm2&r1=1.139&r2=1.140 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/configure.h.in.diff?cvsroot=lvm2&r1=1.20&r2=1.21 --- LVM2/configure.in 2010/05/20 13:47:21 1.139 +++ LVM2/configure.in 2010/05/20 22:32:44 1.140 @@ -1042,7 +1042,7 @@ [ DEFAULT_BACKUP_SUBDIR="backup" ]) AC_DEFINE_UNQUOTED(DEFAULT_BACKUP_SUBDIR,["$DEFAULT_BACKUP_SUBDIR"] ) -AH_TEMPLATE(DEFAULT_CACHE_SUBDIR, [Name of default metadata backup subdirectory.]) +AH_TEMPLATE(DEFAULT_CACHE_SUBDIR, [Name of default metadata cache subdirectory.]) AC_ARG_WITH(default-cache-subdir, [ --with-default-cache-subdir=SUBDIR Default metadata cache subdir [[cache]] ], [ DEFAULT_CACHE_SUBDIR="$withval" ], --- LVM2/lib/misc/configure.h.in 2010/05/20 13:47:21 1.20 +++ LVM2/lib/misc/configure.h.in 2010/05/20 22:32:44 1.21 @@ -23,7 +23,7 @@ /* Name of default metadata backup subdirectory. */ #undef DEFAULT_BACKUP_SUBDIR -/* Name of default metadata backup subdirectory. */ +/* Name of default metadata cache subdirectory. */ #undef DEFAULT_CACHE_SUBDIR /* Name of default locking directory. */ From agk@sourceware.org Thu May 20 22:54:00 2010 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 20 May 2010 22:54:00 -0000 Subject: LVM2 make.tmpl.in Message-ID: <20100520225459.6200.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-05-20 22:54:59 Modified files: . : make.tmpl.in Log message: Fix $(INSTALL_SCRIPT) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/make.tmpl.in.diff?cvsroot=lvm2&r1=1.101&r2=1.102 --- LVM2/make.tmpl.in 2010/05/20 14:45:14 1.101 +++ LVM2/make.tmpl.in 2010/05/20 22:54:58 1.102 @@ -103,7 +103,7 @@ INSTALL_DIR = $(INSTALL) -m 0755 -d INSTALL_ROOT_DIR = $(INSTALL) -m 0700 -d INSTALL_ROOT_DATA = $(INSTALL) -m 0600 -INSTALL_SCRIPT = $(INSTALL) -p -m $(M_INSTALL_PROGRAM) +INSTALL_SCRIPT = $(INSTALL) -p $(M_INSTALL_PROGRAM) .SUFFIXES: .c .d .o .so .a .po .pot .mo .dylib From agk@sourceware.org Thu May 20 23:21:00 2010 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 20 May 2010 23:21:00 -0000 Subject: LVM2 VERSION VERSION_DM WHATS_NEW WHATS_NEW_DM Message-ID: <20100520232156.32743.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-05-20 23:21:54 Modified files: . : VERSION VERSION_DM WHATS_NEW WHATS_NEW_DM Log message: post-release Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/VERSION.diff?cvsroot=lvm2&r1=1.237&r2=1.238 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/VERSION_DM.diff?cvsroot=lvm2&r1=1.48&r2=1.49 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1573&r2=1.1574 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.372&r2=1.373 --- LVM2/VERSION 2010/05/20 22:27:26 1.237 +++ LVM2/VERSION 2010/05/20 23:21:53 1.238 @@ -1 +1 @@ -2.02.66(2)-cvs (2010-05-20) +2.02.67(2)-cvs (2010-05-20) --- LVM2/VERSION_DM 2010/05/20 22:27:26 1.48 +++ LVM2/VERSION_DM 2010/05/20 23:21:53 1.49 @@ -1 +1 @@ -1.02.48-cvs (2010-05-20) +1.02.49-cvs (2010-05-20) --- LVM2/WHATS_NEW 2010/05/20 22:27:26 1.1573 +++ LVM2/WHATS_NEW 2010/05/20 23:21:53 1.1574 @@ -1,3 +1,6 @@ +Version 2.02.67 - +=============================== + Version 2.02.66 - 20th May 2010 =============================== If unable to obtain snapshot percentage leave value blank on reports. --- LVM2/WHATS_NEW_DM 2010/05/20 22:27:26 1.372 +++ LVM2/WHATS_NEW_DM 2010/05/20 23:21:53 1.373 @@ -1,3 +1,6 @@ +Version 1.02.49 - +================================ + Version 1.02.48 - 17th May 2010 ================================ Use -d to control level of messages sent to syslog by dmeventd. From zkabelac@sourceware.org Fri May 21 12:19:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 21 May 2010 12:19:00 -0000 Subject: LVM2 ./WHATS_NEW tools/toollib.c Message-ID: <20100521121923.4031.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-21 12:19:23 Modified files: . : WHATS_NEW tools : toollib.c Log message: Return ECMD_FAILED for break in process_each_lv() and process_each_segment_in_lv() Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1574&r2=1.1575 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.197&r2=1.198 --- LVM2/WHATS_NEW 2010/05/20 23:21:53 1.1574 +++ LVM2/WHATS_NEW 2010/05/21 12:19:22 1.1575 @@ -1,5 +1,6 @@ Version 2.02.67 - =============================== + Return ECMD_FAILED for break in process_each_lv() and process_each_segment_in_lv(). Version 2.02.66 - 20th May 2010 =============================== --- LVM2/tools/toollib.c 2010/05/06 11:15:56 1.197 +++ LVM2/tools/toollib.c 2010/05/21 12:19:22 1.198 @@ -329,8 +329,9 @@ unlock_and_release_vg(cmd, vg, vgname); if (ret > ret_max) ret_max = ret; + /* FIXME: logic for breaking command is not consistent */ if (sigint_caught()) - break; + return ECMD_FAILED; } return ret_max; @@ -408,8 +409,9 @@ ret = process_single_seg(cmd, seg, handle); if (ret > ret_max) ret_max = ret; + /* FIXME: logic for breaking command is not consistent */ if (sigint_caught()) - break; + return ECMD_FAILED; } return ret_max; From zkabelac@sourceware.org Fri May 21 12:21:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 21 May 2010 12:21:00 -0000 Subject: LVM2 ./WHATS_NEW tools/toollib.c tools/toollib ... Message-ID: <20100521122154.4914.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-21 12:21:52 Modified files: . : WHATS_NEW tools : toollib.c toollib.h vgdisplay.c Log message: API change for args of process_each_lv_in_vg() Patch adds failed_lvnames to the list of parameters for process_each_lv_in_vg(). If the list is not NULL it will be filled with LV names of failing LVs during function execution. Application could later reiterate only on failed LVs. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1575&r2=1.1576 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.198&r2=1.199 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.h.diff?cvsroot=lvm2&r1=1.73&r2=1.74 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgdisplay.c.diff?cvsroot=lvm2&r1=1.27&r2=1.28 --- LVM2/WHATS_NEW 2010/05/21 12:19:22 1.1575 +++ LVM2/WHATS_NEW 2010/05/21 12:21:51 1.1576 @@ -1,5 +1,6 @@ Version 2.02.67 - =============================== + Extend process_each_lv_in_vg() with support for list of failed lvnames. Return ECMD_FAILED for break in process_each_lv() and process_each_segment_in_lv(). Version 2.02.66 - 20th May 2010 --- LVM2/tools/toollib.c 2010/05/21 12:19:22 1.198 +++ LVM2/tools/toollib.c 2010/05/21 12:21:52 1.199 @@ -86,6 +86,7 @@ struct volume_group *vg, const struct dm_list *arg_lvnames, const struct dm_list *tags, + struct dm_list *failed_lvnames, void *handle, process_single_lv_fn_t process_single_lv) { @@ -96,7 +97,7 @@ unsigned tags_supplied = 0; unsigned lvargs_supplied = 0; unsigned lvargs_matched = 0; - + char *lv_name; struct lv_list *lvl; if (!vg_check_status(vg, EXPORTED_VG)) @@ -155,6 +156,14 @@ continue; ret = process_single_lv(cmd, lvl->lv, handle); + if (ret != ECMD_PROCESSED && failed_lvnames) { + lv_name = dm_pool_strdup(cmd->mem, lvl->lv->name); + if (!lv_name || + !str_list_add(cmd->mem, failed_lvnames, lv_name)) { + log_error("Allocation failed for str_list."); + return ECMD_FAILED; + } + } if (ret > ret_max) ret_max = ret; if (sigint_caught()) @@ -325,7 +334,7 @@ } ret = process_each_lv_in_vg(cmd, vg, &lvnames, tags_arg, - handle, process_single_lv); + NULL, handle, process_single_lv); unlock_and_release_vg(cmd, vg, vgname); if (ret > ret_max) ret_max = ret; --- LVM2/tools/toollib.h 2010/04/13 23:57:41 1.73 +++ LVM2/tools/toollib.h 2010/05/21 12:21:52 1.74 @@ -78,6 +78,7 @@ struct volume_group *vg, const struct dm_list *arg_lvnames, const struct dm_list *tags, + struct dm_list *failed_lvnames, void *handle, process_single_lv_fn_t process_single_lv); --- LVM2/tools/vgdisplay.c 2009/10/26 14:37:09 1.27 +++ LVM2/tools/vgdisplay.c 2010/05/21 12:21:52 1.28 @@ -37,7 +37,7 @@ if (arg_count(cmd, verbose_ARG)) { vgdisplay_extents(vg); - process_each_lv_in_vg(cmd, vg, NULL, NULL, NULL, + process_each_lv_in_vg(cmd, vg, NULL, NULL, NULL, NULL, (process_single_lv_fn_t)lvdisplay_full); log_print("--- Physical volumes ---"); From zkabelac@sourceware.org Fri May 21 12:24:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 21 May 2010 12:24:00 -0000 Subject: LVM2 ./WHATS_NEW libdm/.exported_symbols libdm ... Message-ID: <20100521122416.5723.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-21 12:24:15 Modified files: . : WHATS_NEW libdm : .exported_symbols libdevmapper.h libdm-deptree.c Log message: Replicator: libdm support Introducing new API calls: dm_tree_node_add_replicator_target() dm_tree_node_add_replicator_dev_target(). Define new typedef dm_replicator_mode_t. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1576&r2=1.1577 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/.exported_symbols.diff?cvsroot=lvm2&r1=1.52&r2=1.53 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.113&r2=1.114 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.75&r2=1.76 --- LVM2/WHATS_NEW 2010/05/21 12:21:51 1.1576 +++ LVM2/WHATS_NEW 2010/05/21 12:24:15 1.1577 @@ -1,5 +1,6 @@ Version 2.02.67 - =============================== + Initial libdm support for Replicator target (API is not stable yet). Extend process_each_lv_in_vg() with support for list of failed lvnames. Return ECMD_FAILED for break in process_each_lv() and process_each_segment_in_lv(). --- LVM2/libdm/.exported_symbols 2010/05/06 10:10:16 1.52 +++ LVM2/libdm/.exported_symbols 2010/05/21 12:24:15 1.53 @@ -80,6 +80,8 @@ 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 --- LVM2/libdm/libdevmapper.h 2010/05/06 10:10:16 1.113 +++ LVM2/libdm/libdevmapper.h 2010/05/21 12:24:15 1.114 @@ -439,6 +439,41 @@ const char *log_uuid, unsigned area_count, uint32_t flags); + +/* + * Replicator operation mode + * Note: API for Replicator is not yet stable + */ +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); +/* End of Replicator API */ + int dm_tree_node_add_target_area(struct dm_tree_node *node, const char *dev_name, const char *dlid, --- LVM2/libdm/libdm-deptree.c 2010/04/07 23:51:34 1.75 +++ LVM2/libdm/libdm-deptree.c 2010/05/21 12:24:15 1.76 @@ -27,12 +27,16 @@ /* FIXME Fix interface so this is used only by LVM */ #define UUID_PREFIX "LVM-" +#define REPLICATOR_LOCAL_SITE 0 + /* Supported segment types */ enum { SEG_CRYPT, SEG_ERROR, SEG_LINEAR, SEG_MIRRORED, + SEG_REPLICATOR, + SEG_REPLICATOR_DEV, SEG_SNAPSHOT, SEG_SNAPSHOT_ORIGIN, SEG_SNAPSHOT_MERGE, @@ -50,6 +54,8 @@ { SEG_ERROR, "error" }, { SEG_LINEAR, "linear" }, { SEG_MIRRORED, "mirror" }, + { SEG_REPLICATOR, "replicator" }, + { SEG_REPLICATOR_DEV, "replicator-dev" }, { SEG_SNAPSHOT, "snapshot" }, { SEG_SNAPSHOT_ORIGIN, "snapshot-origin" }, { SEG_SNAPSHOT_MERGE, "snapshot-merge" }, @@ -64,6 +70,23 @@ struct dm_tree_node *dev_node; uint64_t offset; + + unsigned rsite_index; /* Replicator site index */ + struct dm_tree_node *slog; /* Replicator sync log node */ + uint64_t region_size; /* Replicator sync log size */ + uint32_t flags; /* Replicator sync log flags */ +}; + +/* Replicator-log has a list of sites */ +/* FIXME: maybe move to seg_area too? */ +struct replicator_site { + struct dm_list list; + + unsigned rsite_index; + dm_replicator_mode_t mode; + uint32_t async_timeout; + uint32_t fall_behind_ios; + uint64_t fall_behind_data; }; /* Per-segment properties */ @@ -74,8 +97,8 @@ uint64_t size; - unsigned area_count; /* Linear + Striped + Mirrored + Crypt */ - struct dm_list areas; /* Linear + Striped + Mirrored + Crypt */ + unsigned area_count; /* Linear + Striped + Mirrored + Crypt + Replicator */ + struct dm_list areas; /* Linear + Striped + Mirrored + Crypt + Replicator */ uint32_t stripe_size; /* Striped */ @@ -85,7 +108,7 @@ struct dm_tree_node *origin; /* Snapshot + Snapshot origin */ struct dm_tree_node *merge; /* Snapshot */ - struct dm_tree_node *log; /* Mirror */ + struct dm_tree_node *log; /* Mirror + Replicator */ uint32_t region_size; /* Mirror */ unsigned clustered; /* Mirror */ unsigned mirror_area_count; /* Mirror */ @@ -97,6 +120,13 @@ const char *iv; /* Crypt */ uint64_t iv_offset; /* Crypt */ const char *key; /* Crypt */ + + const char *rlog_type; /* Replicator */ + struct dm_list rsites; /* Replicator */ + unsigned rsite_count; /* Replicator */ + unsigned rdevice_count; /* Replicator */ + struct dm_tree_node *replicator;/* Replicator-dev */ + uint64_t rdevice_index; /* Replicator-dev */ }; /* Per-device properties */ @@ -1342,13 +1372,51 @@ struct seg_area *area; char devbuf[DM_FORMAT_DEV_BUFSIZE]; unsigned first_time = 1; + const char *logtype; + unsigned log_parm_count; dm_list_iterate_items(area, &seg->areas) { if (!_build_dev_string(devbuf, sizeof(devbuf), area->dev_node)) return_0; - EMIT_PARAMS(*pos, "%s%s %" PRIu64, first_time ? "" : " ", - devbuf, area->offset); + switch (seg->type) { + case SEG_REPLICATOR_DEV: + EMIT_PARAMS(*pos, " %d 1 %s", area->rsite_index, devbuf); + if (first_time) + EMIT_PARAMS(*pos, " nolog 0"); + else { + /* Remote devices */ + log_parm_count = (area->flags & + (DM_NOSYNC | DM_FORCESYNC)) ? 2 : 1; + + if (!area->slog) { + devbuf[0] = 0; /* Only core log parameters */ + logtype = "core"; + } else { + devbuf[0] = ' '; /* Extra space before device name */ + if (!_build_dev_string(devbuf + 1, + sizeof(devbuf) - 1, + area->slog)) + return_0; + logtype = "disk"; + log_parm_count++; /* Extra sync log device name parameter */ + } + + EMIT_PARAMS(*pos, " %s %u%s %" PRIu64, logtype, + log_parm_count, devbuf, area->region_size); + + logtype = (area->flags & DM_NOSYNC) ? + " nosync" : (area->flags & DM_FORCESYNC) ? + " sync" : NULL; + + if (logtype) + EMIT_PARAMS(*pos, logtype); + } + break; + default: + EMIT_PARAMS(*pos, "%s%s %" PRIu64, first_time ? "" : " ", + devbuf, area->offset); + } first_time = 0; } @@ -1356,6 +1424,42 @@ return 1; } +static int _replicator_emit_segment_line(const struct load_segment *seg, char *params, + size_t paramsize, int *pos) +{ + const struct load_segment *rlog_seg; + struct replicator_site *rsite; + char rlogbuf[DM_FORMAT_DEV_BUFSIZE]; + unsigned parm_count; + + if (!seg->log || !_build_dev_string(rlogbuf, sizeof(rlogbuf), seg->log)) + return_0; + + rlog_seg = dm_list_item(dm_list_last(&seg->log->props.segs), + struct load_segment); + + EMIT_PARAMS(*pos, "%s 4 %s 0 auto %" PRIu64, + seg->rlog_type, rlogbuf, rlog_seg->size); + + dm_list_iterate_items(rsite, &seg->rsites) { + parm_count = (rsite->fall_behind_data + || rsite->fall_behind_ios + || rsite->async_timeout) ? 4 : 2; + + EMIT_PARAMS(*pos, " blockdev %u %u %s", parm_count, rsite->rsite_index, + (rsite->mode == DM_REPLICATOR_SYNC) ? "synchronous" : "asynchronous"); + + if (rsite->fall_behind_data) + EMIT_PARAMS(*pos, " data %" PRIu64, rsite->fall_behind_data); + else if (rsite->fall_behind_ios) + EMIT_PARAMS(*pos, " ios %" PRIu32, rsite->fall_behind_ios); + else if (rsite->async_timeout) + EMIT_PARAMS(*pos, " timeout %" PRIu32, rsite->async_timeout); + } + + return 1; +} + /* * Returns: 1 on success, 0 on failure */ @@ -1499,6 +1603,21 @@ if (!r) return_0; break; + case SEG_REPLICATOR: + if ((r = _replicator_emit_segment_line(seg, params, paramsize, + &pos)) <= 0) { + stack; + return r; + } + break; + case SEG_REPLICATOR_DEV: + if (!seg->replicator || !_build_dev_string(originbuf, + sizeof(originbuf), + seg->replicator)) + return_0; + + EMIT_PARAMS(pos, "%s %" PRIu64, originbuf, seg->rdevice_index); + break; case SEG_SNAPSHOT: case SEG_SNAPSHOT_MERGE: if (!_build_dev_string(originbuf, sizeof(originbuf), seg->origin)) @@ -1527,6 +1646,7 @@ switch(seg->type) { case SEG_ERROR: + case SEG_REPLICATOR: case SEG_SNAPSHOT: case SEG_SNAPSHOT_ORIGIN: case SEG_SNAPSHOT_MERGE: @@ -1534,6 +1654,7 @@ break; case SEG_CRYPT: case SEG_LINEAR: + case SEG_REPLICATOR_DEV: case SEG_STRIPED: if ((r = _emit_areas_line(dmt, seg, params, paramsize, &pos)) <= 0) { stack; @@ -1996,6 +2117,171 @@ return 1; } +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) +{ + struct load_segment *rseg; + struct replicator_site *rsite; + + /* Local site0 - adds replicator segment and links rlog device */ + if (rsite_index == REPLICATOR_LOCAL_SITE) { + if (node->props.segment_count) { + log_error(INTERNAL_ERROR "Attempt to add replicator segment to already used node."); + return 0; + } + + if (!(rseg = _add_segment(node, SEG_REPLICATOR, size))) + return_0; + + if (!(rseg->log = dm_tree_find_node_by_uuid(node->dtree, rlog_uuid))) { + log_error("Missing replicator log uuid %s.", rlog_uuid); + return 0; + } + + if (!_link_tree_nodes(node, rseg->log)) + return_0; + + if (strcmp(rlog_type, "ringbuffer") != 0) { + log_error("Unsupported replicator log type %s.", rlog_type); + return 0; + } + + if (!(rseg->rlog_type = dm_pool_strdup(node->dtree->mem, rlog_type))) + return_0; + + dm_list_init(&rseg->rsites); + rseg->rdevice_count = 0; + node->activation_priority = 1; + } + + /* Add site to segment */ + if (mode == DM_REPLICATOR_SYNC + && (async_timeout || fall_behind_ios || fall_behind_data)) { + log_error("Async parameters passed for synchronnous replicator."); + return 0; + } + + if (node->props.segment_count != 1) { + log_error(INTERNAL_ERROR "Attempt to add remote site area before setting replicator log."); + return 0; + } + + rseg = dm_list_item(dm_list_last(&node->props.segs), struct load_segment); + if (rseg->type != SEG_REPLICATOR) { + log_error(INTERNAL_ERROR "Attempt to use non replicator segment %s.", + dm_segtypes[rseg->type].target); + return 0; + } + + if (!(rsite = dm_pool_zalloc(node->dtree->mem, sizeof(*rsite)))) { + log_error("Failed to allocate remote site segment."); + return 0; + } + + dm_list_add(&rseg->rsites, &rsite->list); + rseg->rsite_count++; + + rsite->mode = mode; + rsite->async_timeout = async_timeout; + rsite->fall_behind_data = fall_behind_data; + rsite->fall_behind_ios = fall_behind_ios; + rsite->rsite_index = rsite_index; + + return 1; +} + +/* Appends device node to Replicator */ +int dm_tree_node_add_replicator_dev_target(struct dm_tree_node *node, + uint64_t size, + const char *replicator_uuid, + uint64_t rdevice_index, + const char *rdev_uuid, + unsigned rsite_index, + const char *slog_uuid, + uint32_t slog_flags, + uint32_t slog_region_size) +{ + struct seg_area *area; + struct load_segment *rseg; + struct load_segment *rep_seg; + + if (rsite_index == REPLICATOR_LOCAL_SITE) { + /* Site index for local target */ + if (!(rseg = _add_segment(node, SEG_REPLICATOR_DEV, size))) + return_0; + + if (!(rseg->replicator = dm_tree_find_node_by_uuid(node->dtree, replicator_uuid))) { + log_error("Missing replicator uuid %s.", replicator_uuid); + return 0; + } + + /* Local slink0 for replicator must be always initialized first */ + if (rseg->replicator->props.segment_count != 1) { + log_error(INTERNAL_ERROR "Attempt to use non replicator segment."); + return 0; + } + + rep_seg = dm_list_item(dm_list_last(&rseg->replicator->props.segs), struct load_segment); + if (rep_seg->type != SEG_REPLICATOR) { + log_error(INTERNAL_ERROR "Attempt to use non replicator segment %s.", + dm_segtypes[rep_seg->type].target); + return 0; + } + rep_seg->rdevice_count++; + + if (!_link_tree_nodes(node, rseg->replicator)) + return_0; + + rseg->rdevice_index = rdevice_index; + } else { + /* Local slink0 for replicator must be always initialized first */ + if (node->props.segment_count != 1) { + log_error(INTERNAL_ERROR "Attempt to use non replicator-dev segment."); + return 0; + } + + rseg = dm_list_item(dm_list_last(&node->props.segs), struct load_segment); + if (rseg->type != SEG_REPLICATOR_DEV) { + log_error(INTERNAL_ERROR "Attempt to use non replicator-dev segment %s.", + dm_segtypes[rseg->type].target); + return 0; + } + } + + if (!(slog_flags & DM_CORELOG) && !slog_uuid) { + log_error("Unspecified sync log uuid."); + return 0; + } + + if (!dm_tree_node_add_target_area(node, NULL, rdev_uuid, 0)) + return_0; + + area = dm_list_item(dm_list_last(&rseg->areas), struct seg_area); + + if (!(slog_flags & DM_CORELOG)) { + if (!(area->slog = dm_tree_find_node_by_uuid(node->dtree, slog_uuid))) { + log_error("Couldn't find sync log uuid %s.", slog_uuid); + return 0; + } + + if (!_link_tree_nodes(node, area->slog)) + return_0; + } + + area->flags = slog_flags; + area->region_size = slog_region_size; + area->rsite_index = rsite_index; + + return 1; +} + static int _add_area(struct dm_tree_node *node, struct load_segment *seg, struct dm_tree_node *dev_node, uint64_t offset) { struct seg_area *area; From zkabelac@sourceware.org Fri May 21 12:27:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 21 May 2010 12:27:00 -0000 Subject: LVM2 ./WHATS_NEW libdm/.exported_symbols libdm ... Message-ID: <20100521122704.7926.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-21 12:27:03 Modified files: . : WHATS_NEW libdm : .exported_symbols libdevmapper.h libdm-deptree.c Log message: Replicator: support deactivate of replicator-dev nodes Introducing dm_tree_node_set_presuspend_node() for presuspending child node (i.e. replicator control target) before deactivation of parent node (i.e. replicator-dev target). This patch presents no functional change to current dtree - only replicator target currently sets presuspend node for dev nodes. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1577&r2=1.1578 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/.exported_symbols.diff?cvsroot=lvm2&r1=1.53&r2=1.54 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdevmapper.h.diff?cvsroot=lvm2&r1=1.114&r2=1.115 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.76&r2=1.77 --- LVM2/WHATS_NEW 2010/05/21 12:24:15 1.1577 +++ LVM2/WHATS_NEW 2010/05/21 12:27:02 1.1578 @@ -1,5 +1,6 @@ Version 2.02.67 - =============================== + Added dm_tree_node_set_presuspend_node() to presuspend child in deactivate. Initial libdm support for Replicator target (API is not stable yet). Extend process_each_lv_in_vg() with support for list of failed lvnames. Return ECMD_FAILED for break in process_each_lv() and process_each_segment_in_lv(). --- LVM2/libdm/.exported_symbols 2010/05/21 12:24:15 1.53 +++ LVM2/libdm/.exported_symbols 2010/05/21 12:27:03 1.54 @@ -82,6 +82,7 @@ dm_tree_node_add_target_area dm_tree_node_add_replicator_target dm_tree_node_add_replicator_dev_target +dm_tree_node_set_presuspend_node dm_tree_node_set_read_ahead dm_tree_skip_lockfs dm_tree_use_no_flush_suspend --- LVM2/libdm/libdevmapper.h 2010/05/21 12:24:15 1.114 +++ LVM2/libdm/libdevmapper.h 2010/05/21 12:27:03 1.115 @@ -474,6 +474,9 @@ uint32_t slog_region_size); /* End of Replicator API */ +void dm_tree_node_set_presuspend_node(struct dm_tree_node *node, + struct dm_tree_node *presuspend_node); + int dm_tree_node_add_target_area(struct dm_tree_node *node, const char *dev_name, const char *dlid, --- LVM2/libdm/libdm-deptree.c 2010/05/21 12:24:15 1.76 +++ LVM2/libdm/libdm-deptree.c 2010/05/21 12:27:03 1.77 @@ -168,6 +168,12 @@ void *context; /* External supplied context */ struct load_properties props; /* For creation/table (re)load */ + + /* + * If presuspend of child node is needed + * Note: only direct child is allowed + */ + struct dm_tree_node *presuspend_node; }; struct dm_tree { @@ -684,6 +690,12 @@ dnode->props.read_ahead_flags = read_ahead_flags; } +void dm_tree_node_set_presuspend_node(struct dm_tree_node *node, + struct dm_tree_node *presuspend_node) +{ + node->presuspend_node = presuspend_node; +} + int dm_tree_add_dev(struct dm_tree *dtree, uint32_t major, uint32_t minor) { return _add_dev(dtree, &dtree->root, major, minor, 0) ? 1 : 0; @@ -794,6 +806,10 @@ if (!_uuid_prefix_matches(uuid, uuid_prefix, uuid_prefix_len)) continue; + /* Ignore if parent node wants to presuspend this node */ + if (dlink->node->presuspend_node == node) + continue; + if (!(dinfo = dm_tree_node_get_info(dlink->node))) { stack; /* FIXME Is this normal? */ return 0; @@ -1095,6 +1111,11 @@ continue; } + /* Suspend child node first if requested */ + if (child->presuspend_node && + !dm_tree_suspend_children(child, uuid_prefix, uuid_prefix_len)) + continue; + if (!_deactivate_node(name, info.major, info.minor, &child->dtree->cookie, child->udev_flags)) { log_error("Unable to deactivate %s (%" PRIu32 From zkabelac@sourceware.org Fri May 21 12:30:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 21 May 2010 12:30:00 -0000 Subject: LVM2 ./WHATS_NEW libdm/libdm-deptree.c Message-ID: <20100521123036.8843.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-21 12:30:35 Modified files: . : WHATS_NEW libdm : libdm-deptree.c Log message: Replicator: check open_count for parents of presuspend_node For deactivation of Replicator check in advance that all heads have open_count == 0. For this presuspend_node is used as all head nodes are linking this control node. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1578&r2=1.1579 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.77&r2=1.78 --- LVM2/WHATS_NEW 2010/05/21 12:27:02 1.1578 +++ LVM2/WHATS_NEW 2010/05/21 12:30:35 1.1579 @@ -1,5 +1,6 @@ Version 2.02.67 - =============================== + 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). Extend process_each_lv_in_vg() with support for list of failed lvnames. --- LVM2/libdm/libdm-deptree.c 2010/05/21 12:27:03 1.77 +++ LVM2/libdm/libdm-deptree.c 2010/05/21 12:30:35 1.78 @@ -902,6 +902,44 @@ return r; } +/* Check if all parent nodes of given node have open_count == 0 */ +static int _node_has_closed_parents(struct dm_tree_node *node, + const char *uuid_prefix, + size_t uuid_prefix_len) +{ + struct dm_tree_link *dlink; + const struct dm_info *dinfo; + struct dm_info info; + const char *uuid; + + /* Iterate through parents of this node */ + dm_list_iterate_items(dlink, &node->used_by) { + if (!(uuid = dm_tree_node_get_uuid(dlink->node))) { + stack; + continue; + } + + /* Ignore if it doesn't belong to this VG */ + if (!_uuid_prefix_matches(uuid, uuid_prefix, uuid_prefix_len)) + continue; + + if (!(dinfo = dm_tree_node_get_info(dlink->node))) { + stack; /* FIXME Is this normal? */ + return 0; + } + + /* Refresh open_count */ + if (!_info_by_dev(dinfo->major, dinfo->minor, 1, &info) || + !info.exists) + continue; + + if (info.open_count) + return 0; + } + + return 1; +} + static int _deactivate_node(const char *name, uint32_t major, uint32_t minor, uint32_t *cookie, uint16_t udev_flags) { @@ -1100,7 +1138,11 @@ !info.exists) continue; - if (info.open_count) { + /* Also checking open_count in parent nodes of presuspend_node */ + if (info.open_count || + (child->presuspend_node && + !_node_has_closed_parents(child->presuspend_node, + uuid_prefix, uuid_prefix_len))) { /* Only report error from (likely non-internal) dependency at top level */ if (!level) { log_error("Unable to deactivate open %s (%" PRIu32 From zkabelac@sourceware.org Fri May 21 12:36:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 21 May 2010 12:36:00 -0000 Subject: LVM2 ./WHATS_NEW ./configure ./configure.in li ... Message-ID: <20100521123633.10573.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-21 12:36:31 Modified files: . : WHATS_NEW configure configure.in lib : Makefile.in lib/commands : toolcontext.c lib/format_text: flags.c lib/metadata : lv_manip.c merge.c metadata-exported.h segtype.h lib/misc : configure.h.in Log message: Replicator: base lvm2 support 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. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1579&r2=1.1580 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.diff?cvsroot=lvm2&r1=1.129&r2=1.130 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.in.diff?cvsroot=lvm2&r1=1.140&r2=1.141 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/Makefile.in.diff?cvsroot=lvm2&r1=1.102&r2=1.103 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.97&r2=1.98 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/flags.c.diff?cvsroot=lvm2&r1=1.41&r2=1.42 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.229&r2=1.230 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/merge.c.diff?cvsroot=lvm2&r1=1.41&r2=1.42 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.146&r2=1.147 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/segtype.h.diff?cvsroot=lvm2&r1=1.27&r2=1.28 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/configure.h.in.diff?cvsroot=lvm2&r1=1.21&r2=1.22 --- LVM2/WHATS_NEW 2010/05/21 12:30:35 1.1579 +++ LVM2/WHATS_NEW 2010/05/21 12:36:30 1.1580 @@ -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). --- LVM2/configure 2010/05/20 13:47:21 1.129 +++ LVM2/configure 2010/05/21 12:36:30 1.130 @@ -660,6 +660,7 @@ PTHREAD_LIBS POOL PKGCONFIG +REPLICATORS MIRRORS LVM_RELEASE_DATE LVM_RELEASE @@ -824,6 +825,7 @@ with_cluster with_snapshots with_mirrors +with_replicators enable_readline enable_realtime with_clvmd @@ -1563,6 +1565,7 @@ 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) @@ -9345,6 +9348,32 @@ 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. @@ -15712,8 +15741,9 @@ + ################################################################################ -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 @@ "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" ;; --- LVM2/configure.in 2010/05/20 22:32:44 1.140 +++ LVM2/configure.in 2010/05/21 12:36:30 1.141 @@ -303,6 +303,21 @@ 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], @@ -1151,6 +1166,7 @@ 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/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile +lib/replicator/Makefile lib/misc/lvm-version.h lib/snapshot/Makefile libdm/Makefile --- LVM2/lib/Makefile.in 2010/04/09 21:42:50 1.102 +++ LVM2/lib/Makefile.in 2010/05/21 12:36:30 1.103 @@ -32,6 +32,10 @@ SUBDIRS += mirror endif +ifeq ("@REPLICATORS@", "shared") + SUBDIRS += replicator +endif + SOURCES =\ activate/activate.c \ cache/lvmcache.c \ @@ -74,6 +78,7 @@ 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 @@ 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 @@ format_pool \ snapshot \ mirror \ + replicator \ locking endif --- LVM2/lib/commands/toolcontext.c 2010/05/13 13:04:05 1.97 +++ LVM2/lib/commands/toolcontext.c 2010/05/21 12:36:31 1.98 @@ -936,6 +936,11 @@ 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() && --- LVM2/lib/format_text/flags.c 2010/01/13 01:56:18 1.41 +++ LVM2/lib/format_text/flags.c 2010/05/21 12:36:31 1.42 @@ -67,6 +67,8 @@ {PARTIAL_LV, NULL, 0}, {POSTORDER_FLAG, NULL, 0}, {VIRTUAL_ORIGIN, NULL, 0}, + {REPLICATOR, NULL, 0}, + {REPLICATOR_LOG, NULL, 0}, {0, NULL, 0} }; --- LVM2/lib/metadata/lv_manip.c 2010/04/23 19:27:10 1.229 +++ LVM2/lib/metadata/lv_manip.c 2010/05/21 12:36:31 1.230 @@ -2008,6 +2008,7 @@ 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; } --- LVM2/lib/metadata/merge.c 2010/04/09 01:00:11 1.41 +++ LVM2/lib/metadata/merge.c 2010/05/21 12:36:31 1.42 @@ -72,6 +72,8 @@ 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 @@ 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) { --- LVM2/lib/metadata/metadata-exported.h 2010/05/19 11:52:37 1.146 +++ LVM2/lib/metadata/metadata-exported.h 2010/05/21 12:36:31 1.147 @@ -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 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 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 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 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 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, --- LVM2/lib/metadata/segtype.h 2010/01/15 16:35:26 1.27 +++ LVM2/lib/metadata/segtype.h 2010/05/21 12:36:31 1.28 @@ -35,9 +35,13 @@ #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_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 --- LVM2/lib/misc/configure.h.in 2010/05/20 22:32:44 1.21 +++ LVM2/lib/misc/configure.h.in 2010/05/21 12:36:31 1.22 @@ -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 From zkabelac@sourceware.org Fri May 21 12:40:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 21 May 2010 12:40:00 -0000 Subject: LVM2/lib metadata/replicator_manip.c replicati ... Message-ID: <20100521124005.12697.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-21 12:40:05 Added files: lib/metadata : replicator_manip.c lib/replication: Makefile.in replicator.c Log message: Replicator: new files for Replicator target Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/replicator_manip.c.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/replication/Makefile.in.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/replication/replicator.c.diff?cvsroot=lvm2&r1=NONE&r2=1.1 /cvs/lvm2/LVM2/lib/metadata/replicator_manip.c,v --> standard output revision 1.1 --- LVM2/lib/metadata/replicator_manip.c +++ - 2010-05-21 12:40:05.711937000 +0000 @@ -0,0 +1,327 @@ +/* + * 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 Lesser General Public License v.2.1. + * + * You should have received a copy of the GNU Lesser 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 + */ + +#include "lib.h" +#include "metadata.h" +#include "segtype.h" + +/* Add lv as replicator_dev device */ +int replicator_dev_add_rimage(struct replicator_device *rdev, + struct logical_volume *lv) +{ + if (!lv || !rdev) + return_0; + + if (lv_is_rimage(lv)) { + log_error("Logical volume %s is already part of other " + "replicator.", lv->name); + return 0; + } + + if (rdev->lv) { + log_error("Logical volume %s can not be attached to an " + "already defined replicator device", lv->name); + return 0; + } + + lv_set_hidden(lv); + lv->rdevice = rdev; + rdev->lv = lv; + + return add_seg_to_segs_using_this_lv(lv, rdev->replicator_dev); +} + +/* Remove lv from replicator_dev device */ +struct logical_volume *replicator_dev_remove_rimage(struct replicator_device *rdev) +{ + struct logical_volume *lv; + + if (!rdev || !rdev->lv) + return_NULL; + + lv = rdev->lv; + if (!remove_seg_from_segs_using_this_lv(lv, rdev->replicator_dev)) + return_NULL; + + /* FIXME: - check for site references */ + rdev->lv = NULL; + lv->rdevice = NULL; + lv_set_visible(lv); + + return lv; +} + +int replicator_dev_add_slog(struct replicator_device *rdev, + struct logical_volume *slog) +{ + if (!slog || !rdev) + return_0; + + if (rdev->slog) { + log_error("Replicator device in site %s already has sync log.", + rdev->rsite->name); + return 0; + } + + if (slog->rdevice) { + log_error("Sync log %s is already used by replicator %s.", + slog->name, slog->rdevice->rsite->replicator->name); + return 0; + } + + lv_set_hidden(slog); + slog->rdevice = rdev; + rdev->slog = slog; + + return add_seg_to_segs_using_this_lv(slog, rdev->replicator_dev); +} + +struct logical_volume *replicator_dev_remove_slog(struct replicator_device *rdev) +{ + struct logical_volume *lv; + + if (!rdev) + return_NULL; + + lv = rdev->slog; + if (!lv) { + log_error("Replicator device in site %s does not have sync log.", + rdev->rsite->name); + return NULL; + } + + if (!remove_seg_from_segs_using_this_lv(lv, rdev->replicator_dev)) + return_NULL; + + rdev->slog = NULL; + lv->rdevice = NULL; + lv_set_visible(lv); + + return lv; +} + +int replicator_add_replicator_dev(struct logical_volume *replicator_lv, + struct lv_segment *replicator_dev_seg) +{ + if (!replicator_lv) + return_0; + + if (!(replicator_lv->status & REPLICATOR)) { + dm_list_init(&replicator_lv->rsites); + lv_set_hidden(replicator_lv); + replicator_lv->status |= REPLICATOR; + } + + if (!replicator_dev_seg) + return 1; + + if (replicator_dev_seg->replicator) { + log_error("Replicator device %s is already part of replicator.", + replicator_dev_seg->lv->name); + return 0; + } + + replicator_dev_seg->replicator = replicator_lv; + + return add_seg_to_segs_using_this_lv(replicator_lv, replicator_dev_seg); +} + +/** + * Returns rimage ?? lv upon succeful detach of device + * entire LV entry should be removed by this crootall ?? + */ +struct logical_volume *replicator_remove_replicator_dev(struct lv_segment *replicator_dev_seg) +{ + struct logical_volume *lv = NULL; + + log_error("FIXME: not implemented."); +#if 0 + /* FIXME: - this is going to be complex.... */ + if (!replicator_dev_seg) + return_NULL; + + /* if slog or rimage - exit */ + + if (!remove_seg_from_segs_using_this_lv(lv, replicator_seg)) + return_NULL; + + replicator_seg->rlog_lv = NULL; + lv->status &= ~REPLICATOR_LOG; + lv_set_visible(lv); +#endif + + return lv; +} + +int replicator_add_rlog(struct lv_segment *replicator_seg, + struct logical_volume *rlog_lv) +{ + if (!rlog_lv) + return_0; + + if (rlog_lv->status & REPLICATOR_LOG) { + log_error("Rlog device %s is already used.", rlog_lv->name); + return 0; + } + + lv_set_hidden(rlog_lv); + rlog_lv->status |= REPLICATOR_LOG; + replicator_seg->rlog_lv = rlog_lv; + + return add_seg_to_segs_using_this_lv(rlog_lv, replicator_seg); +} + +struct logical_volume *replicator_remove_rlog(struct lv_segment *replicator_seg) +{ + struct logical_volume *lv; + + if (!replicator_seg) + return_0; + + if (!(lv = replicator_seg->rlog_lv)) { + log_error("Replog segment %s does not have rlog.", + replicator_seg->lv->name); + return NULL; + } + + if (!remove_seg_from_segs_using_this_lv(lv, replicator_seg)) + return_NULL; + + replicator_seg->rlog_lv = NULL; + lv->status &= ~REPLICATOR_LOG; + lv_set_visible(lv); + + return lv; +} + + +#if 0 +/* + * Create new LV to pretend the original LV + * this target will have a 'replicator' segment + */ +int lv_add_replicator(struct logical_volume *origin, const char *rep_suffix) +{ + struct logical_volume *rep_lv; + char *name; + size_t slen; + + if (!(name = strstr(origin->name, rep_suffix))) { + log_error("Failed to find replicator suffix %s in LV name %s", + rep_suffix, origin->name); + return 0; + } + slen = (size_t)(name - origin->name); + name = alloca(slen + 1); + memcpy(name, origin->name, slen); + name[slen] = 0; + + if ((rep_lv = find_lv(origin->vg, name))) { + rep_lv->status |= VIRTUAL; + return 1; + } + + if (!(rep_lv = lv_create_empty(name, &origin->lvid, + LVM_READ | LVM_WRITE | VISIBLE_LV, + ALLOC_INHERIT, origin->vg))) + return_0; + + if (!lv_add_virtual_segment(rep_lv, 0, origin->le_count, + get_segtype_from_string(origin->vg->cmd, + "error"))) + return_0; + + rep_lv->status |= VIRTUAL; + return 1; +} + +int lv_remove_replicator(struct logical_volume *lv) +{ + return 1; +} +#endif + +/** + * Is this segment part of active replicator + */ +int lv_is_active_replicator_dev(const struct logical_volume *lv) +{ + return ((lv->status & REPLICATOR) && + lv->rdevice && + lv->rdevice->rsite && + lv->rdevice->rsite->state == REPLICATOR_STATE_ACTIVE); +} + +/** + * Is this LV replicator control device + */ +int lv_is_replicator(const struct logical_volume *lv) +{ + return ((lv->status & REPLICATOR) && + !dm_list_empty(&lv->segments) && + seg_is_replicator(first_seg(lv))); +} + +/** + * Is this LV replicator device + */ +int lv_is_replicator_dev(const struct logical_volume *lv) +{ + return ((lv->status & REPLICATOR) && + !dm_list_empty(&lv->segments) && + seg_is_replicator_dev(first_seg(lv))); +} + +/** + * Is this LV replicated origin lv + */ +int lv_is_rimage(const struct logical_volume *lv) +{ + return (lv->rdevice && lv->rdevice->lv == lv); +} + +/** + * Is this LV rlog + */ +int lv_is_rlog(const struct logical_volume *lv) +{ + return (lv->status & REPLICATOR_LOG); +} + +/** + * Is this LV sync log + */ +int lv_is_slog(const struct logical_volume *lv) +{ + return (lv->rdevice && lv->rdevice->slog == lv); +} + +/** + * Returns first replicator-dev in site in case the LV is replicator-dev, + * NULL otherwise + */ +struct logical_volume *first_replicator_dev(const struct logical_volume *lv) +{ + struct replicator_device *rdev; + struct replicator_site *rsite; + + if (lv_is_replicator_dev(lv)) + dm_list_iterate_items(rsite, &first_seg(lv)->replicator->rsites) { + dm_list_iterate_items(rdev, &rsite->rdevices) + return rdev->replicator_dev->lv; + break; + } + + return NULL; +} /cvs/lvm2/LVM2/lib/replication/Makefile.in,v --> standard output revision 1.1 --- LVM2/lib/replication/Makefile.in +++ - 2010-05-21 12:40:05.812259000 +0000 @@ -0,0 +1,25 @@ +# +# 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@ + +SOURCES = replicator.c + +LIB_SHARED = liblvm2replicator.$(LIB_SUFFIX) +LIB_VERSION = $(LIB_VERSION_LVM) + +include $(top_builddir)/make.tmpl + +install: install_lib_shared_plugin /cvs/lvm2/LVM2/lib/replication/replicator.c,v --> standard output revision 1.1 --- LVM2/lib/replication/replicator.c +++ - 2010-05-21 12:40:05.897415000 +0000 @@ -0,0 +1,790 @@ +/* + * 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 Lesser General Public License v.2.1. + * + * You should have received a copy of the GNU Lesser 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 + */ + +#include "lib.h" +#include "toolcontext.h" +#include "metadata.h" +#include "segtype.h" +#include "text_export.h" +#include "text_import.h" +#include "config.h" +#include "activate.h" +#include "str_list.h" +#ifdef DMEVENTD +# include "sharedlib.h" +# include "libdevmapper-event.h" +#endif + +/* Dm kernel module name for replicator */ +#define REPLICATOR_MODULE "replicator" +#define REPLICATOR_DEV_MODULE "replicator-dev" + +/* + * Macro used as return argument - returns 0. + * return is left to be written in the function for better readability. + */ +#define SEG_LOG_ERROR(t, p...) \ + log_error(t " segment %s of logical volume %s.", ## p, \ + config_parent_name(sn), seg->lv->name), 0; + + +/* + * Replicator target + */ +static const char *_replicator_name(const struct lv_segment *seg) +{ + return seg->segtype->name; +} + +/* FIXME: missing implementation */ +static void _replicator_display(const struct lv_segment *seg) +{ + //const char *size; + //uint32_t s; + + log_print(" Replicator"); + if (seg->rlog_lv) + log_print(" Replicator volume\t%s", seg->rlog_lv->name); +} + +/* Wrapper for get_config_uint32() with default value */ +static uint32_t _get_config_uint32(const struct config_node *cn, + const char *path, + uint32_t def) +{ + uint32_t t; + + return get_config_uint32(cn, path, &t) ? t : def; +} + +/* Wrapper for get_config_uint64() with default value */ +static uint64_t _get_config_uint64(const struct config_node *cn, + const char *path, + uint64_t def) +{ + uint64_t t; + + return get_config_uint64(cn, path, &t) ? t : def; +} + + +/* Strings replicator_state_t enum */ +static const char _state_txt[NUM_REPLICATOR_STATE][8] = { + "passive", + "active" +}; + +/* Parse state string */ +static replicator_state_t _get_state(const struct config_node *sn, + const char *path, replicator_state_t def) +{ + char *str; + unsigned i; + + if (get_config_str(sn, path, &str)) { + for (i = 0; i < sizeof(_state_txt)/sizeof(_state_txt[0]); ++i) + if (strcasecmp(str, _state_txt[i]) == 0) + return (replicator_state_t) i; + + log_warn("%s: unknown value '%s', using default '%s' state", + path, str, _state_txt[def]); + } + + return def; +} + +/* Strings for replicator_action_t enum */ +static const char _op_mode_txt[NUM_DM_REPLICATOR_MODES][8] = { + "sync", + "warn", + "stall", + "drop", + "fail" +}; + + +/* Parse action string */ +static dm_replicator_mode_t _get_op_mode(const struct config_node *sn, + const char *path, dm_replicator_mode_t def) +{ + char *str; + unsigned i; + + if (get_config_str(sn, path, &str)) { + for (i = 0; i < sizeof(_op_mode_txt)/sizeof(_op_mode_txt[0]); ++i) + if (strcasecmp(str, _op_mode_txt[i]) == 0) { + log_very_verbose("Setting %s to %s", + path, _op_mode_txt[i]); + return (dm_replicator_mode_t) i; + } + log_warn("%s: unknown value '%s', using default '%s' operation mode", + path, str, _op_mode_txt[def]); + } + + return def; +} + +static struct replicator_site *_get_site(struct logical_volume *replicator, + const char *key) +{ + struct dm_pool *mem = replicator->vg->vgmem; + struct replicator_site *rsite; + + dm_list_iterate_items(rsite, &replicator->rsites) + if (strcasecmp(rsite->name, key) == 0) + return rsite; + + if (!(rsite = dm_pool_zalloc(mem, sizeof(*rsite)))) + return_NULL; + + if (!(rsite->name = dm_pool_strdup(mem, key))) + return_NULL; + + rsite->replicator = replicator; + dm_list_init(&rsite->rdevices); + dm_list_add(&replicator->rsites, &rsite->list); + + return rsite; +} + + +/* Parse replicator site element */ +static int _add_site(struct lv_segment *seg, + const char *key, + const struct config_node *sn) +{ + struct dm_pool *mem = seg->lv->vg->vgmem; + const struct config_node *cn; + struct replicator_site *rsite; + + if (!(rsite = _get_site(seg->lv, key))) + return_0; + + if (!find_config_node(sn, "site_index")) + return SEG_LOG_ERROR("Mandatory site_index is missing for"); + + rsite->state = _get_state(sn, "state", REPLICATOR_STATE_PASSIVE); + rsite->site_index = _get_config_uint32(sn, "site_index", 0); + if (rsite->site_index > seg->rsite_index_highest) + return SEG_LOG_ERROR("site_index=%d > highest_site_index=%d for", + rsite->site_index, seg->rsite_index_highest); + + rsite->fall_behind_data = _get_config_uint64(sn, "fall_behind_data", 0); + rsite->fall_behind_ios = _get_config_uint32(sn, "fall_behind_ios", 0); + rsite->fall_behind_timeout = _get_config_uint32(sn, "fall_behind_timeout", 0); + rsite->op_mode = DM_REPLICATOR_SYNC; + + if (rsite->fall_behind_data || + rsite->fall_behind_ios || + rsite->fall_behind_timeout) { + if (rsite->fall_behind_data && rsite->fall_behind_ios) + return SEG_LOG_ERROR("Defined both fall_behind_data " + "and fall_behind_ios in"); + + if (rsite->fall_behind_data && rsite->fall_behind_timeout) + return SEG_LOG_ERROR("Defined both fall_behind_data " + "and fall_behind_timeout in"); + + if (rsite->fall_behind_ios && rsite->fall_behind_timeout) + return SEG_LOG_ERROR("Defined both fall_behind_ios " + "and fall_behind_timeout in"); + + rsite->op_mode = _get_op_mode(sn, "operation_mode", + rsite->op_mode); + } + + if ((cn = find_config_node(sn, "volume_group"))) { + if (!cn->v || cn->v->type != CFG_STRING) + return SEG_LOG_ERROR("volume_group must be a string in"); + + if (!(rsite->vg_name = dm_pool_strdup(mem, cn->v->v.str))) + return_0; + + } else if (rsite->site_index != 0) + return SEG_LOG_ERROR("volume_group is mandatory for remote site in"); + + return 1; +} + + +/* Import replicator segment */ +static int _replicator_text_import(struct lv_segment *seg, + const struct config_node *sn, + struct dm_hash_table *pv_hash __attribute((unused))) +{ + const struct config_node *cn; + struct logical_volume *rlog_lv; + + if (!replicator_add_replicator_dev(seg->lv, NULL)) + return_0; + + if (!(cn = find_config_node(sn, "replicator_log")) || + !cn->v || cn->v->type != CFG_STRING) + return SEG_LOG_ERROR("Replicator log type must be a string in"); + + if (!(rlog_lv = find_lv(seg->lv->vg, cn->v->v.str))) + return SEG_LOG_ERROR("Unknown replicator log %s in", + cn->v->v.str); + + if (!(cn = find_config_node(sn, "replicator_log_type")) || + !cn->v || cn->v->type != CFG_STRING) + return SEG_LOG_ERROR("Replicator log's type must be a string in"); + if (strcasecmp(cn->v->v.str, "ringbuffer")) + return SEG_LOG_ERROR("Only ringbuffer replicator log type is supported in"); + + if (!(seg->rlog_type = dm_pool_strdup(seg->lv->vg->vgmem, cn->v->v.str))) + return_0; + + + log_very_verbose("replicator_log = %s", rlog_lv->name); + log_very_verbose("replicator_log_type = %s", seg->rlog_type); + + if (!replicator_add_rlog(seg, rlog_lv)) + return_0; + + seg->rdevice_index_highest = _get_config_uint64(sn, "highest_device_index", 0); + seg->rsite_index_highest = _get_config_uint32(sn, "highest_site_index", 0); + + seg->region_size = _get_config_uint32(sn, "sync_log_size", 0); + + for (; sn; sn = sn->sib) + if (!sn->v) { + for (cn = sn->sib; cn; cn = cn->sib) + if (!cn->v && (strcasecmp(cn->key ,sn->key) == 0)) + return SEG_LOG_ERROR("Detected duplicate site " + "name %s in", sn->key); + if (!_add_site(seg, sn->key, sn->child)) + return_0; + } + return 1; +} + +/* Export replicator segment */ +static int _replicator_text_export(const struct lv_segment *seg, + struct formatter *f) +{ + struct replicator_site *rsite; + + if (!seg->rlog_lv) + return_0; + + outf(f, "replicator_log = \"%s\"", seg->rlog_lv->name); + outf(f, "replicator_log_type = \"%s\"", seg->rlog_type); + outf(f, "highest_device_index = %" PRIu64, seg->rdevice_index_highest); + outf(f, "highest_site_index = %d", seg->rsite_index_highest); + + if (seg->region_size) + outsize(f, (uint64_t)seg->region_size, + "sync_log_size = %" PRIu32, seg->region_size); + + if (!dm_list_empty(&seg->lv->rsites)) + outnl(f); + + dm_list_iterate_items(rsite, &seg->lv->rsites) { + outf(f, "%s {", rsite->name); + out_inc_indent(f); + + outf(f, "state = \"%s\"", _state_txt[rsite->state]); + outf(f, "site_index = %d", rsite->site_index); + + /* Only non-default parameters are written */ + if (rsite->op_mode != DM_REPLICATOR_SYNC) + outf(f, "operation_mode = \"%s\"", + _op_mode_txt[rsite->op_mode]); + if (rsite->fall_behind_timeout) + outfc(f, "# seconds", "fall_behind_timeout = %u", + rsite->fall_behind_timeout); + if (rsite->fall_behind_ios) + outfc(f, "# io operations", "fall_behind_ios = %u", + rsite->fall_behind_ios); + if (rsite->fall_behind_data) + outsize(f, rsite->fall_behind_data, "fall_behind_data = %" PRIu64, + rsite->fall_behind_data); + if (rsite->state != REPLICATOR_STATE_ACTIVE && rsite->vg_name) + outf(f, "volume_group = \"%s\"", rsite->vg_name); + + out_dec_indent(f); + outf(f, "}"); + } + + return 1; +} + +#ifdef DEVMAPPER_SUPPORT +static int _replicator_add_target_line(struct dev_manager *dm, + struct dm_pool *mem, + struct cmd_context *cmd, + void **target_state, + struct lv_segment *seg, + struct dm_tree_node *node, + uint64_t len, + uint32_t *pvmove_mirror_count) +{ + const char *rlog_dlid; + struct replicator_site *rsite; + + if (!seg->rlog_lv) + return_0; + + if (!(rlog_dlid = build_dm_uuid(mem, seg->rlog_lv->lvid.s, NULL))) + return_0; + + dm_list_iterate_items(rsite, &seg->lv->rsites) { + if (!dm_tree_node_add_replicator_target(node, + seg->rlog_lv->size, + rlog_dlid, + seg->rlog_type, + rsite->site_index, + rsite->op_mode, + rsite->fall_behind_timeout, + rsite->fall_behind_data, + rsite->fall_behind_ios)) { + if (rsite->site_index == 0) { + log_error("Failed to add replicator log '%s' " + "to replicator '%s'.", + rlog_dlid, seg->lv->name); + return 0; + } + // FIXME: + } + } + + return 1; +} + +/* FIXME: write something useful for replicator here */ +static int _replicator_target_percent(void **target_state, + percent_range_t *percent_range, + struct dm_pool *mem, + struct cmd_context *cmd, + struct lv_segment *seg, + char *params, uint64_t *total_numerator, + uint64_t *total_denominator) +{ + return 1; +} + +/* Check for module presence */ +static int _replicator_target_present(struct cmd_context *cmd, + const struct lv_segment *seg __attribute((unused)), + unsigned *attributes __attribute((unused))) +{ + static int _checked = 0; + static int _present = 0; + + if (!_checked) { + _present = target_present(cmd, REPLICATOR_MODULE, 1); + _checked = 1; + } + + return _present; +} + +#endif + +static int _replicator_modules_needed(struct dm_pool *mem, + const struct lv_segment *seg __attribute((unused)), + struct dm_list *modules) +{ + if (!str_list_add(mem, modules, REPLICATOR_MODULE)) + return_0; + + if (!str_list_add(mem, modules, REPLICATOR_DEV_MODULE)) + return_0; + + return 1; +} + +static void _replicator_destroy(const struct segment_type *segtype) +{ + dm_free((void *)segtype); +} + +static struct segtype_handler _replicator_ops = { + .name = _replicator_name, + .display = _replicator_display, + .text_import = _replicator_text_import, + .text_export = _replicator_text_export, +#ifdef DEVMAPPER_SUPPORT + .add_target_line = _replicator_add_target_line, + .target_percent = _replicator_target_percent, + .target_present = _replicator_target_present, +#endif + .modules_needed = _replicator_modules_needed, + .destroy = _replicator_destroy, +}; + +/* + * Replicator-dev target + */ +static void _replicator_dev_display(const struct lv_segment *seg) +{ + //const char *size; + //uint32_t s; + // FIXME: debug test code for now + log_print(" Replicator\t\t%u", seg->area_count); + log_print(" Mirror size\t\t%u", seg->area_len); + if (seg->log_lv) + log_print(" Replicator log volume\t%s", seg->rlog_lv->name); + +} + +static int _add_device(struct lv_segment *seg, + const char *site_name, + const struct config_node *sn, + uint64_t devidx) +{ + struct dm_pool *mem = seg->lv->vg->vgmem; + struct logical_volume *lv = NULL; + struct logical_volume *slog_lv = NULL; + struct replicator_site *rsite = _get_site(seg->replicator, site_name); + struct replicator_device *rdev; + const char *dev_str = NULL; + const char *slog_str = NULL; + const struct config_node *cn; + + dm_list_iterate_items(rdev, &rsite->rdevices) + if (rdev->replicator_dev == seg) + return SEG_LOG_ERROR("Duplicate site found in"); + + if ((cn = find_config_node(sn, "sync_log"))) { + if (!cn->v || !cn->v->v.str) + return SEG_LOG_ERROR("Sync log must be a string in"); + slog_str = cn->v->v.str; + } + + if (!(cn = find_config_node(sn, "logical_volume")) || + !cn->v || !cn->v->v.str) + return SEG_LOG_ERROR("Logical volume must be a string in"); + + dev_str = cn->v->v.str; + + if (!seg->lv->rdevice) { + if (slog_str) + return SEG_LOG_ERROR("Sync log %s defined for local " + "device in", slog_str); + + /* Check for device in current VG */ + if (!(lv = find_lv(seg->lv->vg, dev_str))) + return SEG_LOG_ERROR("Logical volume %s not found in", + dev_str); + } else { + if (!slog_str) + return SEG_LOG_ERROR("Sync log is missing for remote " + "device in"); + /* Check for slog device in current VG */ + if (!(slog_lv = find_lv(seg->lv->vg, slog_str))) + return SEG_LOG_ERROR("Sync log %s not found in", + slog_str); + } + + if (!(rdev = dm_pool_zalloc(mem, sizeof(*rdev)))) + return_0; + + if (!(rdev->name = dm_pool_strdup(mem, dev_str))) + return_0; + + rdev->replicator_dev = seg; + rdev->rsite = rsite; + rdev->device_index = devidx; + + if (!seg->lv->rdevice) { + if (!replicator_dev_add_rimage(rdev, lv)) + return SEG_LOG_ERROR("LV inconsistency found in"); + seg->lv->rdevice = rdev; + } else { + if (!slog_str || + !(rdev->slog_name = dm_pool_strdup(mem, slog_str))) + return_0; + + if (!replicator_dev_add_slog(rdev, slog_lv)) + return SEG_LOG_ERROR("Sync log inconsistency found in"); + } + + dm_list_add(&rsite->rdevices, &rdev->list);// linked site list + + return 1; +} + +/* Import replicator segment */ +static int _replicator_dev_text_import(struct lv_segment *seg, + const struct config_node *sn, + struct dm_hash_table *pv_hash __attribute((unused))) +{ + const struct config_node *cn; + struct logical_volume *replicator; + uint64_t devidx; + + if (!(cn = find_config_node(sn, "replicator"))) + return SEG_LOG_ERROR("Replicator is missing for"); + + if (!cn->v || !cn->v->v.str) + return SEG_LOG_ERROR("Replicator must be a string for"); + + if (!(replicator = find_lv(seg->lv->vg, cn->v->v.str))) + return SEG_LOG_ERROR("Unknown replicator %s for", cn->v->v.str); + + if (!replicator_add_replicator_dev(replicator, seg)) + return_0; + + log_very_verbose("replicator=%s", replicator->name); + + /* Mandatory */ + if (!find_config_node(sn, "device_index") || + !get_config_uint64(sn, "device_index", &devidx)) + return SEG_LOG_ERROR("Could not read 'device_index' for"); + + /* Read devices from sites */ + for (; sn; sn = sn->sib) + if (!(sn->v) && !_add_device(seg, sn->key, sn->child, devidx)) + return_0; + + if (!seg->lv->rdevice) + return SEG_LOG_ERROR("Replicator device without site in"); + + seg->rlog_lv = NULL; + seg->lv->status |= REPLICATOR; + + return 1; +} + +/* Export replicator-dev segment */ +static int _replicator_dev_text_export(const struct lv_segment *seg, + struct formatter *f) +{ + struct replicator_site *rsite; + struct replicator_device *rdev; + + if (!seg->replicator || !seg->lv->rdevice) + return_0; + + outf(f, "replicator = \"%s\"", seg->replicator->name); + outf(f, "device_index = %" PRId64, seg->lv->rdevice->device_index); + + outnl(f); + + dm_list_iterate_items(rsite, &seg->replicator->rsites) { + dm_list_iterate_items(rdev, &rsite->rdevices) { + if (rdev->replicator_dev != seg) + continue; + + outf(f, "%s {", rdev->rsite->name); + + out_inc_indent(f); + + outf(f, "logical_volume = \"%s\"", + rdev->name ? rdev->name : rdev->lv->name); + + if (rdev->slog) + outf(f, "sync_log = \"%s\"", rdev->slog->name); + else if (rdev->slog_name) + outf(f, "sync_log = \"%s\"", rdev->slog_name); + + out_dec_indent(f); + + outf(f, "}"); + } + } + + return 1; +} + +#ifdef DEVMAPPER_SUPPORT +/* + * Add target for passive site matching the device index + */ +static int _replicator_dev_add_target_line(struct dev_manager *dm, + struct dm_pool *mem, + struct cmd_context *cmd, + void **target_state, + struct lv_segment *seg, + struct dm_tree_node *node, + uint64_t len, + uint32_t *pvmove_mirror_count) +{ + const char *replicator_dlid, *rdev_dlid, *slog_dlid; + struct replicator_device *rdev, *rdev_search; + struct replicator_site *rsite; + uint32_t slog_size; + uint32_t slog_flags; + + if (!lv_is_active_replicator_dev(seg->lv)) { + /* Create passive linear mapping */ + log_very_verbose("Inactive replicator %s using %s.", + seg->lv->name, seg->lv->rdevice->lv->name); + if (!dm_tree_node_add_linear_target(node, seg->lv->size)) + return_0; + if (!(rdev_dlid = build_dm_uuid(mem, seg->lv->rdevice->lv->lvid.s, NULL))) + return_0; + return dm_tree_node_add_target_area(node, NULL, rdev_dlid, 0); + } else if (seg->lv->rdevice->rsite->site_index) { + log_error("Active site with site_index != 0 (%s, %d)", + seg->lv->rdevice->rsite->name, + seg->lv->rdevice->rsite->site_index); + return 0; /* Replicator without any active site */ + } + + /* + * At this point all devices that have some connection with replicator + * must be present in dm_tree + */ + if (!seg_is_replicator_dev(seg) || + !(replicator_dlid = build_dm_uuid(mem, seg->replicator->lvid.s, NULL))) + return_0; + + /* Select remote devices with the same device index */ + dm_list_iterate_items(rsite, &seg->replicator->rsites) { + if (rsite->site_index == 0) { + /* Local slink0 device */ + rdev = seg->lv->rdevice; + } else { + rdev = NULL; + dm_list_iterate_items(rdev_search, &rsite->rdevices) { + if (rdev_search->replicator_dev == seg) { + rdev = rdev_search; + break; + } + } + + if (!rdev) { + log_error(INTERNAL_ERROR "rdev list not found."); + return 0; + } + } + + if (!rdev->lv || + !(rdev_dlid = build_dm_uuid(mem, rdev->lv->lvid.s, NULL))) + return_0; + + slog_dlid = NULL; + + /* Using either disk or core (in memory) log */ + if (rdev->slog) { + slog_flags = DM_NOSYNC; + slog_size = (uint32_t) rdev->slog->size; + if (!(slog_dlid = build_dm_uuid(mem, rdev->slog->lvid.s, NULL))) + return_0; + } else if (rdev->slog_name && + sscanf(rdev->slog_name, "%" PRIu32, &slog_size) == 1) { + slog_flags = DM_CORELOG | DM_FORCESYNC; + if (slog_size == 0) { + log_error("Failed to use empty corelog size " + "in replicator '%s'.", + rsite->replicator->name); + return 0; + } + } else { + slog_flags = DM_CORELOG | DM_FORCESYNC; + slog_size = 0; /* NOLOG */ + } + + if (!dm_tree_node_add_replicator_dev_target(node, + seg->lv->size, + replicator_dlid, + seg->lv->rdevice->device_index, + rdev_dlid, + rsite->site_index, + slog_dlid, + slog_flags, + slog_size)) { + return_0; + /* FIXME: handle 'state = dropped' in future */ + } + } + + return 1; +} + +/* FIXME: write something useful for replicator-dev here */ +static int _replicator_dev_target_percent(void **target_state, + percent_range_t *percent_range, + struct dm_pool *mem, + struct cmd_context *cmd, + struct lv_segment *seg, + char *params, + uint64_t *total_numerator, + uint64_t *total_denominator) +{ + return 1; +} + +/* Check for module presence */ +static int _replicator_dev_target_present(struct cmd_context *cmd, + const struct lv_segment *seg __attribute((unused)), + unsigned *attributes __attribute((unused))) +{ + static int _checked = 0; + static int _present = 0; + + if (!_checked) { + _present = target_present(cmd, REPLICATOR_DEV_MODULE, 1); + _checked = 1; + } + + return _present; +} + +#endif + +static struct segtype_handler _replicator_dev_ops = { + .name = _replicator_name, + .display = _replicator_dev_display, + .text_import = _replicator_dev_text_import, + .text_export = _replicator_dev_text_export, +#ifdef DEVMAPPER_SUPPORT + .add_target_line = _replicator_dev_add_target_line, + .target_percent = _replicator_dev_target_percent, + .target_present = _replicator_dev_target_present, +#endif + .modules_needed = _replicator_modules_needed, + .destroy = _replicator_destroy, +}; + +#ifdef REPLICATOR_INTERNAL +int init_replicator_segtype(struct segtype_library *seglib) +#else /* Shared */ +int init_multiple_segtype(struct segtype_library *seglib); +int init_multiple_segtype(struct segtype_library *seglib) +#endif +{ + struct segment_type *segtype; + + if (!(segtype = dm_malloc(sizeof(*segtype)))) + return_0; + + segtype->ops = &_replicator_ops; + segtype->name = REPLICATOR_MODULE; + segtype->private = NULL; + segtype->flags = SEG_REPLICATOR; + + if (!lvm_register_segtype(seglib, segtype)) + return_0; + + log_very_verbose("Initialised segtype: " REPLICATOR_MODULE); + + if (!(segtype = dm_malloc(sizeof(*segtype)))) + return_0; + + segtype->ops = &_replicator_dev_ops; + segtype->name = REPLICATOR_DEV_MODULE; + segtype->private = NULL; + segtype->flags = SEG_REPLICATOR_DEV; + + if (!lvm_register_segtype(seglib, segtype)) + return_0; + + log_very_verbose("Initialised segtype: " REPLICATOR_DEV_MODULE); + + return 1; +} From zkabelac@sourceware.org Fri May 21 12:43:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 21 May 2010 12:43:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/merge.c lib/meta ... Message-ID: <20100521124307.15132.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-21 12:43:02 Modified files: . : WHATS_NEW lib/metadata : merge.c metadata.h replicator_manip.c Log message: Replicator: check replicator segment Check for possible problems within replicator structures. Used also by vg_validate. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1580&r2=1.1581 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/merge.c.diff?cvsroot=lvm2&r1=1.42&r2=1.43 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.203&r2=1.204 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/replicator_manip.c.diff?cvsroot=lvm2&r1=1.1&r2=1.2 --- LVM2/WHATS_NEW 2010/05/21 12:36:30 1.1580 +++ LVM2/WHATS_NEW 2010/05/21 12:43:02 1.1581 @@ -1,5 +1,6 @@ Version 2.02.67 - =============================== + Add check_replicator_segment() for catching internal replicator errors. 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. --- LVM2/lib/metadata/merge.c 2010/05/21 12:36:31 1.42 +++ LVM2/lib/metadata/merge.c 2010/05/21 12:43:02 1.43 @@ -137,6 +137,9 @@ } } + if (seg_is_replicator(seg) && !check_replicator_segment(seg)) + inc_error_count; + for (s = 0; s < seg->area_count; s++) { if (seg_type(seg, s) == AREA_UNASSIGNED) { log_error("LV %s: segment %u has unassigned " --- LVM2/lib/metadata/metadata.h 2010/04/13 17:25:45 1.203 +++ LVM2/lib/metadata/metadata.h 2010/05/21 12:43:02 1.204 @@ -321,6 +321,12 @@ */ int check_lv_segments(struct logical_volume *lv, int complete_vg); + +/* + * Checks that a replicator segment is correct. + */ +int check_replicator_segment(const struct lv_segment *replicator_seg); + /* * Sometimes (eg, after an lvextend), it is possible to merge two * adjacent segments into a single segment. This function trys --- LVM2/lib/metadata/replicator_manip.c 2010/05/21 12:40:05 1.1 +++ LVM2/lib/metadata/replicator_manip.c 2010/05/21 12:43:02 1.2 @@ -252,6 +252,158 @@ } #endif +/* + * Check all replicator structures: + * only non-clustered VG for Replicator + * only one segment in replicator LV + * site has correct combination of operation_mode parameters + * site and related devices have correct index numbers + * duplicate site names, site indexes, device names, device indexes + */ +int check_replicator_segment(const struct lv_segment *rseg) +{ + struct replicator_site *rsite, *rsiteb; + struct replicator_device *rdev, *rdevb; + struct logical_volume *lv = rseg->lv; + int r = 1; + + if (vg_is_clustered(lv->vg)) { + log_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("Replicator %s segment size %d != 1", + lv->name, dm_list_size(&lv->segments)); + return 0; + } + + dm_list_iterate_items(rsite, &lv->rsites) { + if (rsite->op_mode == DM_REPLICATOR_SYNC) { + if (rsite->fall_behind_timeout) { + log_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("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("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("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("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("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("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("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("Duplicate VG name " + "%s detected for replicator %s.", + (rsite->vg_name) ? rsite->vg_name : "", + lv->name); + r = 0; + } + if (rsite->site_index == rsiteb->site_index) { + log_error("Duplicate site index %d detected " + "for replicator site %s/%s.", + rsite->site_index, lv->name, + rsite->name); + r = 0; + } + if (rsite->site_index > rseg->rsite_index_highest) { + log_error("Site index %d > %d (too high) " + "for replicator site %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("Duplicate sync log %s " + "detected for replicator %s.", + rdev->slog->name, lv->name); + r = 0; + } + if (strcasecmp(rdev->name, rdevb->name) == 0) { + log_error("Duplicate device name %s " + "detected for replicator %s.", + rdev->name, lv->name); + r = 0; + } + if (rdev->device_index == rdevb->device_index) { + log_error("Duplicate device index %" + PRId64 " detected for " + "replicator site %s/%s.", + rdev->device_index, + lv->name, rsite->name); + r = 0; + } + if (rdev->device_index > rseg->rdevice_index_highest) { + log_error("Device index %" PRIu64 + " > %" PRIu64 " (too high) " + "for replicator site %s/%s.", + rdev->device_index, + rseg->rdevice_index_highest, + lv->name, rsite->name); + r = 0; + } + } + } + } + + return r; +} + /** * Is this segment part of active replicator */ From zkabelac@sourceware.org Fri May 21 12:45:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 21 May 2010 12:45:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/metadata.c Message-ID: <20100521124523.17360.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-21 12:45:19 Modified files: . : WHATS_NEW lib/metadata : metadata.c Log message: Replicator: extend _lv_each_dependency() with dependencies for Replicator devices Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1581&r2=1.1582 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.343&r2=1.344 --- LVM2/WHATS_NEW 2010/05/21 12:43:02 1.1581 +++ LVM2/WHATS_NEW 2010/05/21 12:45:18 1.1582 @@ -1,6 +1,7 @@ Version 2.02.67 - =============================== - Add check_replicator_segment() for catching internal replicator errors. + Extend _lv_each_dependency() with Replicator dependencies. + Add check_replicator_segment() for catching internal Replicator errors. 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. --- LVM2/lib/metadata/metadata.c 2010/05/19 11:52:37 1.343 +++ LVM2/lib/metadata/metadata.c 2010/05/21 12:45:19 1.344 @@ -2001,6 +2001,8 @@ 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) { @@ -2011,6 +2013,8 @@ 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; From zkabelac@sourceware.org Fri May 21 12:47:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 21 May 2010 12:47:00 -0000 Subject: LVM2/lib/metadata metadata-exported.h Message-ID: <20100521124748.18423.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-21 12:47:47 Modified files: lib/metadata : metadata-exported.h Log message: Replicator: extend volume_group with list of VGs and flag Add pointer to linked list of opened VGs. List temporarily keeps the information about needed or locked and opened VGs for replicator target. Also add cmd_missing_vgs flag information for quick check and also for possible continuos process_each_lv() usage where we need to detect whether failure has been caused by missing VG or some other reason. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.147&r2=1.148 --- LVM2/lib/metadata/metadata-exported.h 2010/05/21 12:36:31 1.147 +++ LVM2/lib/metadata/metadata-exported.h 2010/05/21 12:47:46 1.148 @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -223,6 +223,8 @@ struct cmd_context *cmd; struct dm_pool *vgmem; struct format_instance *fid; + struct dm_list *cmd_vgs;/* List of wanted/locked and opened VGs */ + uint32_t cmd_missing_vgs;/* Flag marks missing VG */ uint32_t seqno; /* Metadata sequence number */ alloc_policy_t alloc; From zkabelac@sourceware.org Fri May 21 12:52:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 21 May 2010 12:52:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/metadata-exporte ... Message-ID: <20100521125202.20649.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-21 12:52:01 Modified files: . : WHATS_NEW lib/metadata : metadata-exported.h replicator_manip.c Log message: Replicator: add sorted cmd_vg list Introduce struct cmd_vg to store information about needed volume group name, vgid, flags and the pointer to opened VG. Keep VGs list in alphabetical order for locking order. Introduce functions: cmd_vg_add() add new cmd_vg entry. cmd_vg_lookup() search cmd_vgs for vg_name. cmd_vg_read() open VGs in cmd_vgs list. cmd_vg_release() close VGs in reversed order. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1582&r2=1.1583 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.148&r2=1.149 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/replicator_manip.c.diff?cvsroot=lvm2&r1=1.2&r2=1.3 --- LVM2/WHATS_NEW 2010/05/21 12:45:18 1.1582 +++ LVM2/WHATS_NEW 2010/05/21 12:52:01 1.1583 @@ -1,5 +1,6 @@ Version 2.02.67 - =============================== + Add functions for handling cmd_vg structure. Extend _lv_each_dependency() with Replicator dependencies. Add check_replicator_segment() for catching internal Replicator errors. Initial lvm2 support for Replicator metadata handling. --- LVM2/lib/metadata/metadata-exported.h 2010/05/21 12:47:46 1.148 +++ LVM2/lib/metadata/metadata-exported.h 2010/05/21 12:52:01 1.149 @@ -298,6 +298,15 @@ struct segment_type; +/* List with vg_name, vgid and flags */ +struct cmd_vg { + 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, @@ -798,6 +807,13 @@ 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 cmd_vg *cmd_vg_add(struct dm_pool *mem, struct dm_list *cmd_vgs, + const char *vg_name, const char *vgid, + uint32_t flags); +struct cmd_vg *cmd_vg_lookup(struct dm_list *cmd_vgs, + const char *vg_name, const char *vgid); +int cmd_vg_read(struct cmd_context *cmd, struct dm_list *cmd_vgs); +void cmd_vg_release(struct dm_list *cmd_vgs); struct logical_volume *find_pvmove_lv(struct volume_group *vg, struct device *dev, uint32_t lv_type); --- LVM2/lib/metadata/replicator_manip.c 2010/05/21 12:43:02 1.2 +++ LVM2/lib/metadata/replicator_manip.c 2010/05/21 12:52:01 1.3 @@ -13,6 +13,7 @@ */ #include "lib.h" +#include "locking.h" #include "metadata.h" #include "segtype.h" @@ -477,3 +478,127 @@ return NULL; } + +/** + * Add VG open parameters to sorted cmd_vg list. + * + * Maintain the alphabeticaly ordered list, avoid duplications. + * + * \return Returns newly created or already present cmd_vg entry, + * or NULL in error case. + */ +struct cmd_vg *cmd_vg_add(struct dm_pool *mem, struct dm_list *cmd_vgs, + const char *vg_name, const char *vgid, + uint32_t flags) +{ + struct cmd_vg *cvl, *ins; + + if (!vg_name && !vgid) { + log_error("Either vg_name or vgid must be set."); + return NULL; + } + + /* Is it already in the list ? */ + if ((cvl = cmd_vg_lookup(cmd_vgs, vg_name, vgid))) + return cvl; + + if (!(cvl = dm_pool_zalloc(mem, sizeof(*cvl)))) { + log_error("Allocation of cmd_vg failed."); + return NULL; + } + + if (vg_name && !(cvl->vg_name = dm_pool_strdup(mem, vg_name))) { + dm_pool_free(mem, cvl); + log_error("Allocation of vg_name failed."); + return NULL; + } + + if (vgid && !(cvl->vgid = dm_pool_strdup(mem, vgid))) { + dm_pool_free(mem, cvl); + log_error("Allocation of vgid failed."); + return NULL; + } + + cvl->flags = flags; + + if (vg_name) + dm_list_iterate_items(ins, cmd_vgs) + if (strcmp(vg_name, ins->vg_name) < 0) { + cmd_vgs = &ins->list; /* new position */ + break; + } + + dm_list_add(cmd_vgs, &cvl->list); + + return cvl; +} + +/** + * Find cmd_vg with given vg_name in cmd_vgs list. + * + * \param cmd_vgs List of cmd_vg entries. + * + * \param vg_name Name of VG to be found. + + * \param vgid UUID of VG to be found. + * + * \return Returns cmd_vg entry if vg_name or vgid is found, + * NULL otherwise. + */ +struct cmd_vg *cmd_vg_lookup(struct dm_list *cmd_vgs, + const char *vg_name, const char *vgid) +{ + struct cmd_vg *cvl; + + dm_list_iterate_items(cvl, cmd_vgs) + if ((vgid && cvl->vgid && !strcmp(vgid, cvl->vgid)) || + (vg_name && cvl->vg_name && !strcmp(vg_name, cvl->vg_name))) + return cvl; + return NULL; +} + +/** + * Read and lock multiple VGs stored in cmd_vgs list alphabeticaly. + * On the success list head pointer is set to VGs' cmd_vgs. + * (supports FAILED_INCONSISTENT) + * + * \param cmd_vg Contains list of cmd_vg entries. + * + * \return Returns 1 if all VG in cmd_vgs list are correctly + * openned and locked, 0 otherwise. + */ +int cmd_vg_read(struct cmd_context *cmd, struct dm_list *cmd_vgs) +{ + struct cmd_vg *cvl; + + /* Iterate through alphabeticaly ordered cmd_vg list */ + dm_list_iterate_items(cvl, cmd_vgs) { + cvl->vg = vg_read(cmd, cvl->vg_name, cvl->vgid, cvl->flags); + if (vg_read_error(cvl->vg)) { + log_debug("Failed to vg_read %s", cvl->vg_name); + return 0; + } + cvl->vg->cmd_vgs = cmd_vgs; /* Make it usable in VG */ + } + + return 1; +} + +/** + * Release opened and locked VGs from list. + * + * \param cmd_vgs Contains list of cmd_vg entries. + */ +void cmd_vg_release(struct dm_list *cmd_vgs) +{ + struct cmd_vg *cvl; + + /* Backward iterate cmd_vg list */ + dm_list_iterate_back_items(cvl, cmd_vgs) { + if (vg_read_error(cvl->vg)) + vg_release(cvl->vg); + else + unlock_and_release_vg(cvl->vg->cmd, cvl->vg, cvl->vg_name); + cvl->vg = NULL; + } +} From zkabelac@sourceware.org Fri May 21 12:55:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 21 May 2010 12:55:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/metadata-exporte ... Message-ID: <20100521125532.22463.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-21 12:55:25 Modified files: . : WHATS_NEW lib/metadata : metadata-exported.h replicator_manip.c Log message: Replicator: add find_replicator_vgs Adding find_replicator_vgs() function to find all needed VGs for replicator-dev LV. This function is later called before taking lock_vol(). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1583&r2=1.1584 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.149&r2=1.150 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/replicator_manip.c.diff?cvsroot=lvm2&r1=1.3&r2=1.4 --- LVM2/WHATS_NEW 2010/05/21 12:52:01 1.1583 +++ LVM2/WHATS_NEW 2010/05/21 12:55:25 1.1584 @@ -1,5 +1,6 @@ Version 2.02.67 - =============================== + Add find_replicator_vgs() to discover all needed VGs for replicator-dev LV. Add functions for handling cmd_vg structure. Extend _lv_each_dependency() with Replicator dependencies. Add check_replicator_segment() for catching internal Replicator errors. --- LVM2/lib/metadata/metadata-exported.h 2010/05/21 12:52:01 1.149 +++ LVM2/lib/metadata/metadata-exported.h 2010/05/21 12:55:25 1.150 @@ -815,6 +815,8 @@ int cmd_vg_read(struct cmd_context *cmd, struct dm_list *cmd_vgs); void cmd_vg_release(struct dm_list *cmd_vgs); +int find_replicator_vgs(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, --- LVM2/lib/metadata/replicator_manip.c 2010/05/21 12:52:01 1.3 +++ LVM2/lib/metadata/replicator_manip.c 2010/05/21 12:55:25 1.4 @@ -602,3 +602,35 @@ cvl->vg = NULL; } } + +/** + * Find all needed remote VGs for processing given LV. + * Missing VGs are added to VG's cmd_vg list and flag cmd_missing_vgs is set. + */ +int find_replicator_vgs(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 || !lv->vg->cmd_vgs || + cmd_vg_lookup(lv->vg->cmd_vgs, rsite->vg_name, NULL)) + continue; + ret = 0; + /* Using cmd memory pool for cmd_vg list allocation */ + if (!cmd_vg_add(lv->vg->cmd->mem, lv->vg->cmd_vgs, + rsite->vg_name, NULL, 0)) { + lv->vg->cmd_missing_vgs = 0; /* do not retry */ + stack; + break; + } + + log_debug("VG: %s added as missing.", rsite->vg_name); + lv->vg->cmd_missing_vgs++; + } + + return ret; +} From zkabelac@sourceware.org Fri May 21 13:14:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 21 May 2010 13:14:00 -0000 Subject: LVM2/lib/replication .exported_symbols Message-ID: <20100521131404.2881.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-21 13:14:02 Added files: lib/replication: .exported_symbols Log message: Hmm - fixing cvs import mistake Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/replication/.exported_symbols.diff?cvsroot=lvm2&r1=NONE&r2=1.1 /cvs/lvm2/LVM2/lib/replication/.exported_symbols,v --> standard output revision 1.1 --- LVM2/lib/replication/.exported_symbols +++ - 2010-05-21 13:14:04.050396000 +0000 @@ -0,0 +1 @@ +init_segtype From zkabelac@sourceware.org Fri May 21 13:15:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 21 May 2010 13:15:00 -0000 Subject: LVM2/lib/replicator Message-ID: <20100521131536.13309.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-21 13:15:36 LVM2/lib/replicator Update of /cvs/lvm2/LVM2/lib/replicator In directory sourceware.org:/tmp/cvs-serv13123/replicator Log Message: Directory /cvs/lvm2/LVM2/lib/replicator added to the repository From zkabelac@sourceware.org Fri May 21 13:17:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 21 May 2010 13:17:00 -0000 Subject: LVM2/lib/replicator .exported_symbols Makefile ... Message-ID: <20100521131722.652.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-21 13:17:21 Added files: lib/replicator : .exported_symbols Makefile.in replicator.c Log message: Right directory name for replicator files. My local CVS was placing file in slightly different directory by using obsolete files. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/replicator/.exported_symbols.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/replicator/Makefile.in.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/replicator/replicator.c.diff?cvsroot=lvm2&r1=NONE&r2=1.1 /cvs/lvm2/LVM2/lib/replicator/.exported_symbols,v --> standard output revision 1.1 --- LVM2/lib/replicator/.exported_symbols +++ - 2010-05-21 13:17:21.869306000 +0000 @@ -0,0 +1 @@ +init_segtype /cvs/lvm2/LVM2/lib/replicator/Makefile.in,v --> standard output revision 1.1 --- LVM2/lib/replicator/Makefile.in +++ - 2010-05-21 13:17:21.965524000 +0000 @@ -0,0 +1,25 @@ +# +# 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@ + +SOURCES = replicator.c + +LIB_SHARED = liblvm2replicator.$(LIB_SUFFIX) +LIB_VERSION = $(LIB_VERSION_LVM) + +include $(top_builddir)/make.tmpl + +install: install_lib_shared_plugin /cvs/lvm2/LVM2/lib/replicator/replicator.c,v --> standard output revision 1.1 --- LVM2/lib/replicator/replicator.c +++ - 2010-05-21 13:17:22.085525000 +0000 @@ -0,0 +1,790 @@ +/* + * 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 Lesser General Public License v.2.1. + * + * You should have received a copy of the GNU Lesser 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 + */ + +#include "lib.h" +#include "toolcontext.h" +#include "metadata.h" +#include "segtype.h" +#include "text_export.h" +#include "text_import.h" +#include "config.h" +#include "activate.h" +#include "str_list.h" +#ifdef DMEVENTD +# include "sharedlib.h" +# include "libdevmapper-event.h" +#endif + +/* Dm kernel module name for replicator */ +#define REPLICATOR_MODULE "replicator" +#define REPLICATOR_DEV_MODULE "replicator-dev" + +/* + * Macro used as return argument - returns 0. + * return is left to be written in the function for better readability. + */ +#define SEG_LOG_ERROR(t, p...) \ + log_error(t " segment %s of logical volume %s.", ## p, \ + config_parent_name(sn), seg->lv->name), 0; + + +/* + * Replicator target + */ +static const char *_replicator_name(const struct lv_segment *seg) +{ + return seg->segtype->name; +} + +/* FIXME: missing implementation */ +static void _replicator_display(const struct lv_segment *seg) +{ + //const char *size; + //uint32_t s; + + log_print(" Replicator"); + if (seg->rlog_lv) + log_print(" Replicator volume\t%s", seg->rlog_lv->name); +} + +/* Wrapper for get_config_uint32() with default value */ +static uint32_t _get_config_uint32(const struct config_node *cn, + const char *path, + uint32_t def) +{ + uint32_t t; + + return get_config_uint32(cn, path, &t) ? t : def; +} + +/* Wrapper for get_config_uint64() with default value */ +static uint64_t _get_config_uint64(const struct config_node *cn, + const char *path, + uint64_t def) +{ + uint64_t t; + + return get_config_uint64(cn, path, &t) ? t : def; +} + + +/* Strings replicator_state_t enum */ +static const char _state_txt[NUM_REPLICATOR_STATE][8] = { + "passive", + "active" +}; + +/* Parse state string */ +static replicator_state_t _get_state(const struct config_node *sn, + const char *path, replicator_state_t def) +{ + char *str; + unsigned i; + + if (get_config_str(sn, path, &str)) { + for (i = 0; i < sizeof(_state_txt)/sizeof(_state_txt[0]); ++i) + if (strcasecmp(str, _state_txt[i]) == 0) + return (replicator_state_t) i; + + log_warn("%s: unknown value '%s', using default '%s' state", + path, str, _state_txt[def]); + } + + return def; +} + +/* Strings for replicator_action_t enum */ +static const char _op_mode_txt[NUM_DM_REPLICATOR_MODES][8] = { + "sync", + "warn", + "stall", + "drop", + "fail" +}; + + +/* Parse action string */ +static dm_replicator_mode_t _get_op_mode(const struct config_node *sn, + const char *path, dm_replicator_mode_t def) +{ + char *str; + unsigned i; + + if (get_config_str(sn, path, &str)) { + for (i = 0; i < sizeof(_op_mode_txt)/sizeof(_op_mode_txt[0]); ++i) + if (strcasecmp(str, _op_mode_txt[i]) == 0) { + log_very_verbose("Setting %s to %s", + path, _op_mode_txt[i]); + return (dm_replicator_mode_t) i; + } + log_warn("%s: unknown value '%s', using default '%s' operation mode", + path, str, _op_mode_txt[def]); + } + + return def; +} + +static struct replicator_site *_get_site(struct logical_volume *replicator, + const char *key) +{ + struct dm_pool *mem = replicator->vg->vgmem; + struct replicator_site *rsite; + + dm_list_iterate_items(rsite, &replicator->rsites) + if (strcasecmp(rsite->name, key) == 0) + return rsite; + + if (!(rsite = dm_pool_zalloc(mem, sizeof(*rsite)))) + return_NULL; + + if (!(rsite->name = dm_pool_strdup(mem, key))) + return_NULL; + + rsite->replicator = replicator; + dm_list_init(&rsite->rdevices); + dm_list_add(&replicator->rsites, &rsite->list); + + return rsite; +} + + +/* Parse replicator site element */ +static int _add_site(struct lv_segment *seg, + const char *key, + const struct config_node *sn) +{ + struct dm_pool *mem = seg->lv->vg->vgmem; + const struct config_node *cn; + struct replicator_site *rsite; + + if (!(rsite = _get_site(seg->lv, key))) + return_0; + + if (!find_config_node(sn, "site_index")) + return SEG_LOG_ERROR("Mandatory site_index is missing for"); + + rsite->state = _get_state(sn, "state", REPLICATOR_STATE_PASSIVE); + rsite->site_index = _get_config_uint32(sn, "site_index", 0); + if (rsite->site_index > seg->rsite_index_highest) + return SEG_LOG_ERROR("site_index=%d > highest_site_index=%d for", + rsite->site_index, seg->rsite_index_highest); + + rsite->fall_behind_data = _get_config_uint64(sn, "fall_behind_data", 0); + rsite->fall_behind_ios = _get_config_uint32(sn, "fall_behind_ios", 0); + rsite->fall_behind_timeout = _get_config_uint32(sn, "fall_behind_timeout", 0); + rsite->op_mode = DM_REPLICATOR_SYNC; + + if (rsite->fall_behind_data || + rsite->fall_behind_ios || + rsite->fall_behind_timeout) { + if (rsite->fall_behind_data && rsite->fall_behind_ios) + return SEG_LOG_ERROR("Defined both fall_behind_data " + "and fall_behind_ios in"); + + if (rsite->fall_behind_data && rsite->fall_behind_timeout) + return SEG_LOG_ERROR("Defined both fall_behind_data " + "and fall_behind_timeout in"); + + if (rsite->fall_behind_ios && rsite->fall_behind_timeout) + return SEG_LOG_ERROR("Defined both fall_behind_ios " + "and fall_behind_timeout in"); + + rsite->op_mode = _get_op_mode(sn, "operation_mode", + rsite->op_mode); + } + + if ((cn = find_config_node(sn, "volume_group"))) { + if (!cn->v || cn->v->type != CFG_STRING) + return SEG_LOG_ERROR("volume_group must be a string in"); + + if (!(rsite->vg_name = dm_pool_strdup(mem, cn->v->v.str))) + return_0; + + } else if (rsite->site_index != 0) + return SEG_LOG_ERROR("volume_group is mandatory for remote site in"); + + return 1; +} + + +/* Import replicator segment */ +static int _replicator_text_import(struct lv_segment *seg, + const struct config_node *sn, + struct dm_hash_table *pv_hash __attribute((unused))) +{ + const struct config_node *cn; + struct logical_volume *rlog_lv; + + if (!replicator_add_replicator_dev(seg->lv, NULL)) + return_0; + + if (!(cn = find_config_node(sn, "replicator_log")) || + !cn->v || cn->v->type != CFG_STRING) + return SEG_LOG_ERROR("Replicator log type must be a string in"); + + if (!(rlog_lv = find_lv(seg->lv->vg, cn->v->v.str))) + return SEG_LOG_ERROR("Unknown replicator log %s in", + cn->v->v.str); + + if (!(cn = find_config_node(sn, "replicator_log_type")) || + !cn->v || cn->v->type != CFG_STRING) + return SEG_LOG_ERROR("Replicator log's type must be a string in"); + if (strcasecmp(cn->v->v.str, "ringbuffer")) + return SEG_LOG_ERROR("Only ringbuffer replicator log type is supported in"); + + if (!(seg->rlog_type = dm_pool_strdup(seg->lv->vg->vgmem, cn->v->v.str))) + return_0; + + + log_very_verbose("replicator_log = %s", rlog_lv->name); + log_very_verbose("replicator_log_type = %s", seg->rlog_type); + + if (!replicator_add_rlog(seg, rlog_lv)) + return_0; + + seg->rdevice_index_highest = _get_config_uint64(sn, "highest_device_index", 0); + seg->rsite_index_highest = _get_config_uint32(sn, "highest_site_index", 0); + + seg->region_size = _get_config_uint32(sn, "sync_log_size", 0); + + for (; sn; sn = sn->sib) + if (!sn->v) { + for (cn = sn->sib; cn; cn = cn->sib) + if (!cn->v && (strcasecmp(cn->key ,sn->key) == 0)) + return SEG_LOG_ERROR("Detected duplicate site " + "name %s in", sn->key); + if (!_add_site(seg, sn->key, sn->child)) + return_0; + } + return 1; +} + +/* Export replicator segment */ +static int _replicator_text_export(const struct lv_segment *seg, + struct formatter *f) +{ + struct replicator_site *rsite; + + if (!seg->rlog_lv) + return_0; + + outf(f, "replicator_log = \"%s\"", seg->rlog_lv->name); + outf(f, "replicator_log_type = \"%s\"", seg->rlog_type); + outf(f, "highest_device_index = %" PRIu64, seg->rdevice_index_highest); + outf(f, "highest_site_index = %d", seg->rsite_index_highest); + + if (seg->region_size) + outsize(f, (uint64_t)seg->region_size, + "sync_log_size = %" PRIu32, seg->region_size); + + if (!dm_list_empty(&seg->lv->rsites)) + outnl(f); + + dm_list_iterate_items(rsite, &seg->lv->rsites) { + outf(f, "%s {", rsite->name); + out_inc_indent(f); + + outf(f, "state = \"%s\"", _state_txt[rsite->state]); + outf(f, "site_index = %d", rsite->site_index); + + /* Only non-default parameters are written */ + if (rsite->op_mode != DM_REPLICATOR_SYNC) + outf(f, "operation_mode = \"%s\"", + _op_mode_txt[rsite->op_mode]); + if (rsite->fall_behind_timeout) + outfc(f, "# seconds", "fall_behind_timeout = %u", + rsite->fall_behind_timeout); + if (rsite->fall_behind_ios) + outfc(f, "# io operations", "fall_behind_ios = %u", + rsite->fall_behind_ios); + if (rsite->fall_behind_data) + outsize(f, rsite->fall_behind_data, "fall_behind_data = %" PRIu64, + rsite->fall_behind_data); + if (rsite->state != REPLICATOR_STATE_ACTIVE && rsite->vg_name) + outf(f, "volume_group = \"%s\"", rsite->vg_name); + + out_dec_indent(f); + outf(f, "}"); + } + + return 1; +} + +#ifdef DEVMAPPER_SUPPORT +static int _replicator_add_target_line(struct dev_manager *dm, + struct dm_pool *mem, + struct cmd_context *cmd, + void **target_state, + struct lv_segment *seg, + struct dm_tree_node *node, + uint64_t len, + uint32_t *pvmove_mirror_count) +{ + const char *rlog_dlid; + struct replicator_site *rsite; + + if (!seg->rlog_lv) + return_0; + + if (!(rlog_dlid = build_dm_uuid(mem, seg->rlog_lv->lvid.s, NULL))) + return_0; + + dm_list_iterate_items(rsite, &seg->lv->rsites) { + if (!dm_tree_node_add_replicator_target(node, + seg->rlog_lv->size, + rlog_dlid, + seg->rlog_type, + rsite->site_index, + rsite->op_mode, + rsite->fall_behind_timeout, + rsite->fall_behind_data, + rsite->fall_behind_ios)) { + if (rsite->site_index == 0) { + log_error("Failed to add replicator log '%s' " + "to replicator '%s'.", + rlog_dlid, seg->lv->name); + return 0; + } + // FIXME: + } + } + + return 1; +} + +/* FIXME: write something useful for replicator here */ +static int _replicator_target_percent(void **target_state, + percent_range_t *percent_range, + struct dm_pool *mem, + struct cmd_context *cmd, + struct lv_segment *seg, + char *params, uint64_t *total_numerator, + uint64_t *total_denominator) +{ + return 1; +} + +/* Check for module presence */ +static int _replicator_target_present(struct cmd_context *cmd, + const struct lv_segment *seg __attribute((unused)), + unsigned *attributes __attribute((unused))) +{ + static int _checked = 0; + static int _present = 0; + + if (!_checked) { + _present = target_present(cmd, REPLICATOR_MODULE, 1); + _checked = 1; + } + + return _present; +} + +#endif + +static int _replicator_modules_needed(struct dm_pool *mem, + const struct lv_segment *seg __attribute((unused)), + struct dm_list *modules) +{ + if (!str_list_add(mem, modules, REPLICATOR_MODULE)) + return_0; + + if (!str_list_add(mem, modules, REPLICATOR_DEV_MODULE)) + return_0; + + return 1; +} + +static void _replicator_destroy(const struct segment_type *segtype) +{ + dm_free((void *)segtype); +} + +static struct segtype_handler _replicator_ops = { + .name = _replicator_name, + .display = _replicator_display, + .text_import = _replicator_text_import, + .text_export = _replicator_text_export, +#ifdef DEVMAPPER_SUPPORT + .add_target_line = _replicator_add_target_line, + .target_percent = _replicator_target_percent, + .target_present = _replicator_target_present, +#endif + .modules_needed = _replicator_modules_needed, + .destroy = _replicator_destroy, +}; + +/* + * Replicator-dev target + */ +static void _replicator_dev_display(const struct lv_segment *seg) +{ + //const char *size; + //uint32_t s; + // FIXME: debug test code for now + log_print(" Replicator\t\t%u", seg->area_count); + log_print(" Mirror size\t\t%u", seg->area_len); + if (seg->log_lv) + log_print(" Replicator log volume\t%s", seg->rlog_lv->name); + +} + +static int _add_device(struct lv_segment *seg, + const char *site_name, + const struct config_node *sn, + uint64_t devidx) +{ + struct dm_pool *mem = seg->lv->vg->vgmem; + struct logical_volume *lv = NULL; + struct logical_volume *slog_lv = NULL; + struct replicator_site *rsite = _get_site(seg->replicator, site_name); + struct replicator_device *rdev; + const char *dev_str = NULL; + const char *slog_str = NULL; + const struct config_node *cn; + + dm_list_iterate_items(rdev, &rsite->rdevices) + if (rdev->replicator_dev == seg) + return SEG_LOG_ERROR("Duplicate site found in"); + + if ((cn = find_config_node(sn, "sync_log"))) { + if (!cn->v || !cn->v->v.str) + return SEG_LOG_ERROR("Sync log must be a string in"); + slog_str = cn->v->v.str; + } + + if (!(cn = find_config_node(sn, "logical_volume")) || + !cn->v || !cn->v->v.str) + return SEG_LOG_ERROR("Logical volume must be a string in"); + + dev_str = cn->v->v.str; + + if (!seg->lv->rdevice) { + if (slog_str) + return SEG_LOG_ERROR("Sync log %s defined for local " + "device in", slog_str); + + /* Check for device in current VG */ + if (!(lv = find_lv(seg->lv->vg, dev_str))) + return SEG_LOG_ERROR("Logical volume %s not found in", + dev_str); + } else { + if (!slog_str) + return SEG_LOG_ERROR("Sync log is missing for remote " + "device in"); + /* Check for slog device in current VG */ + if (!(slog_lv = find_lv(seg->lv->vg, slog_str))) + return SEG_LOG_ERROR("Sync log %s not found in", + slog_str); + } + + if (!(rdev = dm_pool_zalloc(mem, sizeof(*rdev)))) + return_0; + + if (!(rdev->name = dm_pool_strdup(mem, dev_str))) + return_0; + + rdev->replicator_dev = seg; + rdev->rsite = rsite; + rdev->device_index = devidx; + + if (!seg->lv->rdevice) { + if (!replicator_dev_add_rimage(rdev, lv)) + return SEG_LOG_ERROR("LV inconsistency found in"); + seg->lv->rdevice = rdev; + } else { + if (!slog_str || + !(rdev->slog_name = dm_pool_strdup(mem, slog_str))) + return_0; + + if (!replicator_dev_add_slog(rdev, slog_lv)) + return SEG_LOG_ERROR("Sync log inconsistency found in"); + } + + dm_list_add(&rsite->rdevices, &rdev->list);// linked site list + + return 1; +} + +/* Import replicator segment */ +static int _replicator_dev_text_import(struct lv_segment *seg, + const struct config_node *sn, + struct dm_hash_table *pv_hash __attribute((unused))) +{ + const struct config_node *cn; + struct logical_volume *replicator; + uint64_t devidx; + + if (!(cn = find_config_node(sn, "replicator"))) + return SEG_LOG_ERROR("Replicator is missing for"); + + if (!cn->v || !cn->v->v.str) + return SEG_LOG_ERROR("Replicator must be a string for"); + + if (!(replicator = find_lv(seg->lv->vg, cn->v->v.str))) + return SEG_LOG_ERROR("Unknown replicator %s for", cn->v->v.str); + + if (!replicator_add_replicator_dev(replicator, seg)) + return_0; + + log_very_verbose("replicator=%s", replicator->name); + + /* Mandatory */ + if (!find_config_node(sn, "device_index") || + !get_config_uint64(sn, "device_index", &devidx)) + return SEG_LOG_ERROR("Could not read 'device_index' for"); + + /* Read devices from sites */ + for (; sn; sn = sn->sib) + if (!(sn->v) && !_add_device(seg, sn->key, sn->child, devidx)) + return_0; + + if (!seg->lv->rdevice) + return SEG_LOG_ERROR("Replicator device without site in"); + + seg->rlog_lv = NULL; + seg->lv->status |= REPLICATOR; + + return 1; +} + +/* Export replicator-dev segment */ +static int _replicator_dev_text_export(const struct lv_segment *seg, + struct formatter *f) +{ + struct replicator_site *rsite; + struct replicator_device *rdev; + + if (!seg->replicator || !seg->lv->rdevice) + return_0; + + outf(f, "replicator = \"%s\"", seg->replicator->name); + outf(f, "device_index = %" PRId64, seg->lv->rdevice->device_index); + + outnl(f); + + dm_list_iterate_items(rsite, &seg->replicator->rsites) { + dm_list_iterate_items(rdev, &rsite->rdevices) { + if (rdev->replicator_dev != seg) + continue; + + outf(f, "%s {", rdev->rsite->name); + + out_inc_indent(f); + + outf(f, "logical_volume = \"%s\"", + rdev->name ? rdev->name : rdev->lv->name); + + if (rdev->slog) + outf(f, "sync_log = \"%s\"", rdev->slog->name); + else if (rdev->slog_name) + outf(f, "sync_log = \"%s\"", rdev->slog_name); + + out_dec_indent(f); + + outf(f, "}"); + } + } + + return 1; +} + +#ifdef DEVMAPPER_SUPPORT +/* + * Add target for passive site matching the device index + */ +static int _replicator_dev_add_target_line(struct dev_manager *dm, + struct dm_pool *mem, + struct cmd_context *cmd, + void **target_state, + struct lv_segment *seg, + struct dm_tree_node *node, + uint64_t len, + uint32_t *pvmove_mirror_count) +{ + const char *replicator_dlid, *rdev_dlid, *slog_dlid; + struct replicator_device *rdev, *rdev_search; + struct replicator_site *rsite; + uint32_t slog_size; + uint32_t slog_flags; + + if (!lv_is_active_replicator_dev(seg->lv)) { + /* Create passive linear mapping */ + log_very_verbose("Inactive replicator %s using %s.", + seg->lv->name, seg->lv->rdevice->lv->name); + if (!dm_tree_node_add_linear_target(node, seg->lv->size)) + return_0; + if (!(rdev_dlid = build_dm_uuid(mem, seg->lv->rdevice->lv->lvid.s, NULL))) + return_0; + return dm_tree_node_add_target_area(node, NULL, rdev_dlid, 0); + } else if (seg->lv->rdevice->rsite->site_index) { + log_error("Active site with site_index != 0 (%s, %d)", + seg->lv->rdevice->rsite->name, + seg->lv->rdevice->rsite->site_index); + return 0; /* Replicator without any active site */ + } + + /* + * At this point all devices that have some connection with replicator + * must be present in dm_tree + */ + if (!seg_is_replicator_dev(seg) || + !(replicator_dlid = build_dm_uuid(mem, seg->replicator->lvid.s, NULL))) + return_0; + + /* Select remote devices with the same device index */ + dm_list_iterate_items(rsite, &seg->replicator->rsites) { + if (rsite->site_index == 0) { + /* Local slink0 device */ + rdev = seg->lv->rdevice; + } else { + rdev = NULL; + dm_list_iterate_items(rdev_search, &rsite->rdevices) { + if (rdev_search->replicator_dev == seg) { + rdev = rdev_search; + break; + } + } + + if (!rdev) { + log_error(INTERNAL_ERROR "rdev list not found."); + return 0; + } + } + + if (!rdev->lv || + !(rdev_dlid = build_dm_uuid(mem, rdev->lv->lvid.s, NULL))) + return_0; + + slog_dlid = NULL; + + /* Using either disk or core (in memory) log */ + if (rdev->slog) { + slog_flags = DM_NOSYNC; + slog_size = (uint32_t) rdev->slog->size; + if (!(slog_dlid = build_dm_uuid(mem, rdev->slog->lvid.s, NULL))) + return_0; + } else if (rdev->slog_name && + sscanf(rdev->slog_name, "%" PRIu32, &slog_size) == 1) { + slog_flags = DM_CORELOG | DM_FORCESYNC; + if (slog_size == 0) { + log_error("Failed to use empty corelog size " + "in replicator '%s'.", + rsite->replicator->name); + return 0; + } + } else { + slog_flags = DM_CORELOG | DM_FORCESYNC; + slog_size = 0; /* NOLOG */ + } + + if (!dm_tree_node_add_replicator_dev_target(node, + seg->lv->size, + replicator_dlid, + seg->lv->rdevice->device_index, + rdev_dlid, + rsite->site_index, + slog_dlid, + slog_flags, + slog_size)) { + return_0; + /* FIXME: handle 'state = dropped' in future */ + } + } + + return 1; +} + +/* FIXME: write something useful for replicator-dev here */ +static int _replicator_dev_target_percent(void **target_state, + percent_range_t *percent_range, + struct dm_pool *mem, + struct cmd_context *cmd, + struct lv_segment *seg, + char *params, + uint64_t *total_numerator, + uint64_t *total_denominator) +{ + return 1; +} + +/* Check for module presence */ +static int _replicator_dev_target_present(struct cmd_context *cmd, + const struct lv_segment *seg __attribute((unused)), + unsigned *attributes __attribute((unused))) +{ + static int _checked = 0; + static int _present = 0; + + if (!_checked) { + _present = target_present(cmd, REPLICATOR_DEV_MODULE, 1); + _checked = 1; + } + + return _present; +} + +#endif + +static struct segtype_handler _replicator_dev_ops = { + .name = _replicator_name, + .display = _replicator_dev_display, + .text_import = _replicator_dev_text_import, + .text_export = _replicator_dev_text_export, +#ifdef DEVMAPPER_SUPPORT + .add_target_line = _replicator_dev_add_target_line, + .target_percent = _replicator_dev_target_percent, + .target_present = _replicator_dev_target_present, +#endif + .modules_needed = _replicator_modules_needed, + .destroy = _replicator_destroy, +}; + +#ifdef REPLICATOR_INTERNAL +int init_replicator_segtype(struct segtype_library *seglib) +#else /* Shared */ +int init_multiple_segtype(struct segtype_library *seglib); +int init_multiple_segtype(struct segtype_library *seglib) +#endif +{ + struct segment_type *segtype; + + if (!(segtype = dm_malloc(sizeof(*segtype)))) + return_0; + + segtype->ops = &_replicator_ops; + segtype->name = REPLICATOR_MODULE; + segtype->private = NULL; + segtype->flags = SEG_REPLICATOR; + + if (!lvm_register_segtype(seglib, segtype)) + return_0; + + log_very_verbose("Initialised segtype: " REPLICATOR_MODULE); + + if (!(segtype = dm_malloc(sizeof(*segtype)))) + return_0; + + segtype->ops = &_replicator_dev_ops; + segtype->name = REPLICATOR_DEV_MODULE; + segtype->private = NULL; + segtype->flags = SEG_REPLICATOR_DEV; + + if (!lvm_register_segtype(seglib, segtype)) + return_0; + + log_very_verbose("Initialised segtype: " REPLICATOR_DEV_MODULE); + + return 1; +} From zkabelac@sourceware.org Fri May 21 13:18:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 21 May 2010 13:18:00 -0000 Subject: LVM2/lib/replication .exported_symbols Makefil ... Message-ID: <20100521131827.3999.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-21 13:18:26 Removed files: lib/replication: .exported_symbols Makefile.in replicator.c Log message: Remove files from wrong directory Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/replication/.exported_symbols.diff?cvsroot=lvm2&r1=1.1&r2=NONE http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/replication/Makefile.in.diff?cvsroot=lvm2&r1=1.1&r2=NONE http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/replication/replicator.c.diff?cvsroot=lvm2&r1=1.1&r2=NONE From zkabelac@sourceware.org Fri May 21 13:34:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 21 May 2010 13:34:00 -0000 Subject: LVM2/lib/metadata replicator_manip.c Message-ID: <20100521133411.13004.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-21 13:34:10 Modified files: lib/metadata : replicator_manip.c Log message: Add toolcontext.h header file. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/replicator_manip.c.diff?cvsroot=lvm2&r1=1.4&r2=1.5 --- LVM2/lib/metadata/replicator_manip.c 2010/05/21 12:55:25 1.4 +++ LVM2/lib/metadata/replicator_manip.c 2010/05/21 13:34:09 1.5 @@ -16,6 +16,7 @@ #include "locking.h" #include "metadata.h" #include "segtype.h" +#include "toolcontext.h" /* Add lv as replicator_dev device */ int replicator_dev_add_rimage(struct replicator_device *rdev, From zkabelac@sourceware.org Fri May 21 14:07:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 21 May 2010 14:07:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/metadata-exporte ... Message-ID: <20100521140724.17575.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-21 14:07:19 Modified files: . : WHATS_NEW lib/metadata : metadata-exported.h replicator_manip.c Log message: Replicator: add read and release VGs for rsites Add functions to read and release remote VGs for replicator sites in activation context. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1584&r2=1.1585 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.150&r2=1.151 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/replicator_manip.c.diff?cvsroot=lvm2&r1=1.5&r2=1.6 --- LVM2/WHATS_NEW 2010/05/21 12:55:25 1.1584 +++ LVM2/WHATS_NEW 2010/05/21 14:07:16 1.1585 @@ -1,5 +1,6 @@ Version 2.02.67 - =============================== + Add functions for read and release VGs list. Add find_replicator_vgs() to discover all needed VGs for replicator-dev LV. Add functions for handling cmd_vg structure. Extend _lv_each_dependency() with Replicator dependencies. --- LVM2/lib/metadata/metadata-exported.h 2010/05/21 12:55:25 1.150 +++ LVM2/lib/metadata/metadata-exported.h 2010/05/21 14:07:17 1.151 @@ -817,6 +817,9 @@ int find_replicator_vgs(struct logical_volume *lv); +int lv_read_replicator_vgs(struct logical_volume *lv); +void lv_release_replicator_vgs(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, --- LVM2/lib/metadata/replicator_manip.c 2010/05/21 13:34:09 1.5 +++ LVM2/lib/metadata/replicator_manip.c 2010/05/21 14:07:19 1.6 @@ -635,3 +635,59 @@ return ret; } + +/** + * Read all remote VGs from lv's replicator sites. + * Function is used in activation context and needs all VGs already locked. + */ +int lv_read_replicator_vgs(struct logical_volume *lv) +{ + struct replicator_device *rdev; + struct replicator_site *rsite; + struct volume_group *vg; + + if (!lv_is_replicator_dev(lv)) + return 1; + + dm_list_iterate_items(rsite, &first_seg(lv)->replicator->rsites) { + if (!rsite->vg_name) + continue; + vg = vg_read(lv->vg->cmd, rsite->vg_name, 0, 0); // READ_WITHOUT_LOCK + if (vg_read_error(vg)) { + log_error("Unable to read volume group %s", + rsite->vg_name); + goto bad; + } + rsite->vg = vg; + /* FIXME: handling missing LVs needs to be better */ + dm_list_iterate_items(rdev, &rsite->rdevices) + if (!(rdev->lv = find_lv(vg, rdev->name))) { + log_error("Unable to find %s in volume group %s", + rdev->name, rsite->vg_name); + goto bad; + } + } + + return 1; +bad: + lv_release_replicator_vgs(lv); + return 0; +} + +/** + * Release all VG resources taken by lv's replicator sites. + * Function is used in activation context and needs all VGs already locked. + */ +void lv_release_replicator_vgs(struct logical_volume *lv) +{ + struct replicator_site *rsite; + + if (!lv_is_replicator_dev(lv)) + return; + + dm_list_iterate_back_items(rsite, &first_seg(lv)->replicator->rsites) + if (rsite->vg_name && rsite->vg) { + vg_release(rsite->vg); + rsite->vg = NULL; + } +} From zkabelac@sourceware.org Fri May 21 14:11:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 21 May 2010 14:11:00 -0000 Subject: LVM2 ./WHATS_NEW tools/toollib.c Message-ID: <20100521141116.18841.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-21 14:11:13 Modified files: . : WHATS_NEW tools : toollib.c Log message: Replicator: use cmd_vg list for _process_one_vg() Patch modifes behavior of _process_one_vg(). In the first pass vg_read() collectis for replicator sorted list of additional VGs during lock_vol(). If any other VG is needed by the replicator and it is not yet opened then next iteration loop is taken with all collected VGs. Flag vg->cmd_missing_vgs detects missing VGs. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1585&r2=1.1586 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.199&r2=1.200 --- LVM2/WHATS_NEW 2010/05/21 14:07:16 1.1585 +++ LVM2/WHATS_NEW 2010/05/21 14:11:13 1.1586 @@ -1,5 +1,6 @@ Version 2.02.67 - =============================== + Update _process_one_vg() to work with cmd_vg struture. Add functions for read and release VGs list. Add find_replicator_vgs() to discover all needed VGs for replicator-dev LV. Add functions for handling cmd_vg structure. --- LVM2/tools/toollib.c 2010/05/21 12:21:52 1.199 +++ LVM2/tools/toollib.c 2010/05/21 14:11:13 1.200 @@ -432,37 +432,51 @@ uint32_t flags, void *handle, int ret_max, process_single_vg_fn_t process_single_vg) { - struct volume_group *vg; + struct dm_list cmd_vgs; + struct cmd_vg *cvl_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(&cmd_vgs); + if (!(cvl_vg = cmd_vg_add(cmd->mem, &cmd_vgs, vg_name, vgid, flags))) + return_0; + + for (;;) { + /* FIXME: consistent handling of command break */ + if (sigint_caught()) { + ret = ECMD_FAILED; + break; + } + if (!cmd_vg_read(cmd, &cmd_vgs)) + /* Allow FAILED_INCONSISTENT through only for vgcfgrestore */ + if (vg_read_error(cvl_vg->vg) && + (!((flags & READ_ALLOW_INCONSISTENT) && + (vg_read_error(cvl_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, &cvl_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_vg(cmd, vg_name, cvl_vg->vg, handle); + + if (vg_read_error(cvl_vg->vg)) /* FAILED_INCONSISTENT */ + break; + + if (!cvl_vg->vg->cmd_missing_vgs) + break; + + cmd_vg_release(&cmd_vgs); } - if ((ret = process_single_vg(cmd, vg_name, vg, - handle)) > ret_max) - ret_max = ret; + cmd_vg_release(&cmd_vgs); -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, From zkabelac@sourceware.org Fri May 21 14:15:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 21 May 2010 14:15:00 -0000 Subject: LVM2 ./WHATS_NEW tools/toollib.c Message-ID: <20100521141539.20115.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-21 14:15:39 Modified files: . : WHATS_NEW tools : toollib.c Log message: Replicator: use cmd_vg for process_each_lv_in_vg() As for _process_one_vg() we need similar retry loop for process_each_lv_in_vg(). This patch retries to process failed LVs with reopened VGs. Patch does not add any extra repeated invocations if there is not found any missing VG during LV processing. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1586&r2=1.1587 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.200&r2=1.201 --- LVM2/WHATS_NEW 2010/05/21 14:11:13 1.1586 +++ LVM2/WHATS_NEW 2010/05/21 14:15:39 1.1587 @@ -1,6 +1,7 @@ Version 2.02.67 - =============================== - Update _process_one_vg() to work with cmd_vg struture. + Update process_each_lv_in_vg() to use cmd_vg structure. + Update _process_one_vg() to work with cmd_vg structure. Add functions for read and release VGs list. Add find_replicator_vgs() to discover all needed VGs for replicator-dev LV. Add functions for handling cmd_vg structure. --- LVM2/tools/toollib.c 2010/05/21 14:11:13 1.200 +++ LVM2/tools/toollib.c 2010/05/21 14:15:39 1.201 @@ -155,6 +155,7 @@ if (!process_lv) continue; + lvl->lv->vg->cmd_missing_vgs = 0; ret = process_single_lv(cmd, lvl->lv, handle); if (ret != ECMD_PROCESSED && failed_lvnames) { lv_name = dm_pool_strdup(cmd->mem, lvl->lv->name); @@ -163,6 +164,8 @@ log_error("Allocation failed for str_list."); return ECMD_FAILED; } + if (lvl->lv->vg->cmd_missing_vgs) + ret = ECMD_PROCESSED; } if (ret > ret_max) ret_max = ret; @@ -190,7 +193,9 @@ struct dm_list *tags_arg; struct dm_list *vgnames; /* VGs to process */ struct str_list *sll, *strl; - struct volume_group *vg; + struct cmd_vg *cvl_vg; + struct dm_list cmd_vgs; + struct dm_list failed_lvnames; struct dm_list tags, lvnames; struct dm_list arg_lvnames; /* Cmdline vgname or vgname/lvname */ char *vglv; @@ -200,6 +205,7 @@ dm_list_init(&tags); dm_list_init(&arg_lvnames); + dm_list_init(&failed_lvnames); if (argc) { struct dm_list arg_vgnames; @@ -295,13 +301,17 @@ } } - vg = NULL; dm_list_iterate_items(strl, vgnames) { vgname = strl->str; - vg = vg_read(cmd, vgname, NULL, flags); + dm_list_init(&cmd_vgs); + if (!(cvl_vg = cmd_vg_add(cmd->mem, &cmd_vgs, + vgname, NULL, flags))) { + stack; + return ECMD_FAILED; + } - if (vg_read_error(vg)) { - vg_release(vg); + if (!cmd_vg_read(cmd, &cmd_vgs)) { + cmd_vg_release(&cmd_vgs); if (ret_max < ECMD_FAILED) { log_error("Skipping volume group %s", vgname); ret_max = ECMD_FAILED; @@ -327,17 +337,34 @@ dm_pool_strdup(cmd->mem, lv_name + 1))) { log_error("strlist allocation failed"); - unlock_and_release_vg(cmd, vg, vgname); + cmd_vg_release(&cmd_vgs); return ECMD_FAILED; } } } - ret = process_each_lv_in_vg(cmd, vg, &lvnames, tags_arg, - NULL, handle, process_single_lv); - unlock_and_release_vg(cmd, vg, vgname); + while (!sigint_caught()) { + ret = process_each_lv_in_vg(cmd, cvl_vg->vg, &lvnames, + tags_arg, &failed_lvnames, + handle, process_single_lv); + if (ret != ECMD_PROCESSED || + dm_list_empty(&failed_lvnames)) + break; + + /* Try again with failed LVs in this VG */ + dm_list_init(&lvnames); + dm_list_splice(&lvnames, &failed_lvnames); + + cmd_vg_release(&cmd_vgs); + if (!cmd_vg_read(cmd, &cmd_vgs)) { + ret = ECMD_FAILED; /* break */ + break; + } + } if (ret > ret_max) ret_max = ret; + + cmd_vg_release(&cmd_vgs); /* FIXME: logic for breaking command is not consistent */ if (sigint_caught()) return ECMD_FAILED; From zkabelac@sourceware.org Fri May 21 14:29:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 21 May 2010 14:29:00 -0000 Subject: LVM2 ./WHATS_NEW lib/locking/locking.h Message-ID: <20100521142951.27953.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-21 14:29:49 Modified files: . : WHATS_NEW lib/locking : locking.h Log message: Replicator: lock_lv_vol() finds missing VGs Find and check for all needed VGs before calling lock_vol(). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1587&r2=1.1588 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.55&r2=1.56 --- LVM2/WHATS_NEW 2010/05/21 14:15:39 1.1587 +++ LVM2/WHATS_NEW 2010/05/21 14:29:49 1.1588 @@ -1,5 +1,6 @@ Version 2.02.67 - =============================== + Check for missing VGs before taking lock_lv_vol (for Replicator). Update process_each_lv_in_vg() to use cmd_vg structure. Update _process_one_vg() to work with cmd_vg structure. Add functions for read and release VGs list. --- LVM2/lib/locking/locking.h 2010/05/19 01:49:08 1.55 +++ LVM2/lib/locking/locking.h 2010/05/21 14:29:49 1.56 @@ -130,7 +130,9 @@ (vg_is_clustered((lv)->vg) ? LCK_CLUSTER_VG : 0) #define lock_lv_vol(cmd, lv, flags) \ - lock_vol(cmd, (lv)->lvid.s, flags | LCK_LV_CLUSTERED(lv)) + (find_replicator_vgs((lv)) ? \ + lock_vol(cmd, (lv)->lvid.s, flags | LCK_LV_CLUSTERED(lv)) : \ + 0) #define unlock_vg(cmd, vol) lock_vol(cmd, vol, LCK_VG_UNLOCK) #define unlock_and_release_vg(cmd, vg, vol) \ From zkabelac@sourceware.org Fri May 21 14:34:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 21 May 2010 14:34:00 -0000 Subject: LVM2 ./WHATS_NEW lib/activate/activate.c Message-ID: <20100521143403.30825.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-21 14:34:02 Modified files: . : WHATS_NEW lib/activate : activate.c Log message: Replicator: activate checks for missing vgs Activation needs to have all remote VGs locked to pass for replicator. So if activated LV is replicator-dev LV - read all remote VGs. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1588&r2=1.1589 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.168&r2=1.169 --- LVM2/WHATS_NEW 2010/05/21 14:29:49 1.1588 +++ LVM2/WHATS_NEW 2010/05/21 14:34:01 1.1589 @@ -1,6 +1,7 @@ Version 2.02.67 - =============================== - Check for missing VGs before taking lock_lv_vol (for Replicator). + Activation code read and releases also remote VGs (Replicator). + Check for missing VGs before taking lock_vol (Replicator). Update process_each_lv_in_vg() to use cmd_vg structure. Update _process_one_vg() to work with cmd_vg structure. Add functions for read and release VGs list. --- LVM2/lib/activate/activate.c 2010/03/26 22:15:43 1.168 +++ LVM2/lib/activate/activate.c 2010/05/21 14:34:02 1.169 @@ -865,6 +865,9 @@ goto out; } + if (!lv_read_replicator_vgs(lv)) + goto_out; + lv_calculate_readahead(lv, NULL); /* If VG was precommitted, preload devices for the LV */ @@ -894,8 +897,10 @@ out: if (lv_pre) vg_release(lv_pre->vg); - if (lv) + if (lv) { + lv_release_replicator_vgs(lv); vg_release(lv->vg); + } return r; } @@ -1025,6 +1030,9 @@ goto_out; } + if (!lv_read_replicator_vgs(lv)) + goto_out; + lv_calculate_readahead(lv, NULL); if (!monitor_dev_for_events(cmd, lv, 0)) @@ -1038,8 +1046,10 @@ if (!lv_info(cmd, lv, &info, 1, 0) || info.exists) r = 0; out: - if (lv) + if (lv) { + lv_release_replicator_vgs(lv); vg_release(lv->vg); + } return r; } @@ -1118,6 +1128,9 @@ goto out; } + if (!lv_read_replicator_vgs(lv)) + goto_out; + lv_calculate_readahead(lv, NULL); if (exclusive) @@ -1133,8 +1146,10 @@ stack; out: - if (lv) + if (lv) { + lv_release_replicator_vgs(lv); vg_release(lv->vg); + } return r; } From zkabelac@sourceware.org Fri May 21 14:48:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Fri, 21 May 2010 14:48:00 -0000 Subject: LVM2 ./WHATS_NEW lib/activate/dev_manager.c Message-ID: <20100521144759.3751.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-21 14:47:59 Modified files: . : WHATS_NEW lib/activate : dev_manager.c Log message: Replicator: update _create_partial_dtree() Adding function _add_partial_replicator_to_dtree() to create partial tree for Replicator target. Using dm_tree_node_set_presuspend_node() for Replicator. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1589&r2=1.1590 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.191&r2=1.192 --- LVM2/WHATS_NEW 2010/05/21 14:34:01 1.1589 +++ LVM2/WHATS_NEW 2010/05/21 14:47:58 1.1590 @@ -1,5 +1,6 @@ Version 2.02.67 - =============================== + Add _add_partial_replicator_to_dtree(). Activation code read and releases also remote VGs (Replicator). Check for missing VGs before taking lock_vol (Replicator). Update process_each_lv_in_vg() to use cmd_vg structure. --- LVM2/lib/activate/dev_manager.c 2010/05/14 12:39:52 1.191 +++ LVM2/lib/activate/dev_manager.c 2010/05/21 14:47:59 1.192 @@ -865,6 +865,84 @@ } /* + * Add replicator devices + * + * Using _add_dev_to_dtree() directly instead of _add_lv_to_dtree() + * to avoid extra checks with extensions. + */ +static int _add_partial_replicator_to_dtree(struct dev_manager *dm, + struct dm_tree *dtree, + struct logical_volume *lv) +{ + struct logical_volume *rlv = first_seg(lv)->replicator; + struct replicator_device *rdev; + struct replicator_site *rsite; + struct dm_tree_node *rep_node, *rdev_node; + const char *uuid; + + if (!lv_is_active_replicator_dev(lv)) { + if (!_add_dev_to_dtree(dm, dtree, lv->rdevice->lv, + NULL)) + return_0; + return 1; + } + + /* Add _rlog and replicator device */ + if (!_add_dev_to_dtree(dm, dtree, first_seg(rlv)->rlog_lv, NULL)) + return_0; + + if (!_add_dev_to_dtree(dm, dtree, rlv, NULL)) + return_0; + + if (!(uuid = build_dm_uuid(dm->mem, rlv->lvid.s, NULL))) + return_0; + + rep_node = dm_tree_find_node_by_uuid(dtree, uuid); + + /* Add all related devices for replicator */ + dm_list_iterate_items(rsite, &rlv->rsites) + dm_list_iterate_items(rdev, &rsite->rdevices) { + if (rsite->state == REPLICATOR_STATE_ACTIVE) { + /* Add _rimage LV */ + if (!_add_dev_to_dtree(dm, dtree, rdev->lv, NULL)) + return_0; + + /* Add replicator-dev LV, except of the already added one */ + if ((lv != rdev->replicator_dev->lv) && + !_add_dev_to_dtree(dm, dtree, + rdev->replicator_dev->lv, NULL)) + return_0; + + /* If replicator exists - try connect existing heads */ + if (rep_node) { + uuid = build_dm_uuid(dm->mem, + rdev->replicator_dev->lv->lvid.s, + NULL); + if (!uuid) + return_0; + + rdev_node = dm_tree_find_node_by_uuid(dtree, uuid); + if (rdev_node) + dm_tree_node_set_presuspend_node(rdev_node, + rep_node); + } + } + + if (!rdev->rsite->vg_name) + continue; + + if (!_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; + } + + return 1; +} + +/* * Add LV and any known dependencies */ static int _add_lv_to_dtree(struct dev_manager *dm, struct dm_tree *dtree, struct logical_volume *lv) @@ -883,6 +961,11 @@ !_add_dev_to_dtree(dm, dtree, first_seg(lv)->log_lv, NULL)) return_0; + /* Adding LV head of replicator adds all other related devs */ + if (lv_is_replicator_dev(lv) && + !_add_partial_replicator_to_dtree(dm, dtree, lv)) + return_0; + return 1; } From mpatocka@sourceware.org Fri May 21 15:28:00 2010 From: mpatocka@sourceware.org (mpatocka@sourceware.org) Date: Fri, 21 May 2010 15:28:00 -0000 Subject: LVM2 ./WHATS_NEW scripts/relpath.awk Message-ID: <20100521152821.16681.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mpatocka@sourceware.org 2010-05-21 15:28:16 Modified files: . : WHATS_NEW scripts : relpath.awk Log message: Fix scripts/relpath.awk to work with mawk length(array) is specific to GNU awk and doesn't work in mawk. Use a return value of "split" function to indicate array size, this is supported in both gawk and mawk. This patch fixes the following errors during "make install" when mawk is installed as a default awk. mawk: scripts/relpath.awk: line 25: illegal reference to array from mawk: scripts/relpath.awk: line 25: illegal reference to array to mawk: scripts/relpath.awk: line 27: illegal reference to array from mawk: scripts/relpath.awk: line 32: illegal reference to array to Signed-off-by: Mikulas Patocka Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1590&r2=1.1591 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/relpath.awk.diff?cvsroot=lvm2&r1=1.3&r2=1.4 --- LVM2/WHATS_NEW 2010/05/21 14:47:58 1.1590 +++ LVM2/WHATS_NEW 2010/05/21 15:28:16 1.1591 @@ -1,5 +1,6 @@ Version 2.02.67 - =============================== + Fixed scripts/relpath.awk to work in mawk Add _add_partial_replicator_to_dtree(). Activation code read and releases also remote VGs (Replicator). Check for missing VGs before taking lock_vol (Replicator). --- LVM2/scripts/relpath.awk 2010/04/30 14:49:45 1.3 +++ LVM2/scripts/relpath.awk 2010/05/21 15:28:16 1.4 @@ -19,17 +19,17 @@ # -> ../../e/f/ { - split($1, from, "/"); - split($2, to, "/") ; + length_from = split($1, from, "/"); + length_to = split($2, to, "/") ; l = 1; - while (l <= length(from) && l <= length(to) && from[l] == to[l]) + while (l <= length_from && l <= length_to && from[l] == to[l]) l++; - for (i = l; i <= length(from) && length(from[i]); i++) { + for (i = l; i <= length_from && length(from[i]); i++) { if (i > l) p = sprintf("%s/", p); p = sprintf("%s..", p); } - for (i = l; i <= length(to) && length(to[i]); i++) { + for (i = l; i <= length_to && length(to[i]); i++) { if (length(p) > 0) p = sprintf("%s/", p); p = sprintf("%s%s", p, to[i]); From zkabelac@sourceware.org Mon May 24 08:59:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Mon, 24 May 2010 08:59:00 -0000 Subject: LVM2 ./WHATS_NEW tools/vgchange.c Message-ID: <20100524085931.5827.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-24 08:59:30 Modified files: . : WHATS_NEW tools : vgchange.c Log message: Replicator: VG with cmd_missing_vgs does not generate output Do not print message if missing VG is found. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1591&r2=1.1592 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.102&r2=1.103 --- LVM2/WHATS_NEW 2010/05/21 15:28:16 1.1591 +++ LVM2/WHATS_NEW 2010/05/24 08:59:29 1.1592 @@ -1,5 +1,6 @@ Version 2.02.67 - =============================== + Avoid print activation message if there is a missing VG (Replicator). Fixed scripts/relpath.awk to work in mawk Add _add_partial_replicator_to_dtree(). Activation code read and releases also remote VGs (Replicator). --- LVM2/tools/vgchange.c 2010/05/06 11:15:56 1.102 +++ LVM2/tools/vgchange.c 2010/05/24 08:59:30 1.103 @@ -224,8 +224,10 @@ 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); + /* Print message only if there was not found a missing VG */ + if (!vg->cmd_missing_vgs) + log_print("%d logical volume(s) in volume group \"%s\" now active", + lvs_in_vg_activated(vg), vg->name); return ret; } From zkabelac@sourceware.org Mon May 24 09:01:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Mon, 24 May 2010 09:01:00 -0000 Subject: LVM2 ./WHATS_NEW lib/activate/dev_manager.c Message-ID: <20100524090106.7042.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-24 09:01:05 Modified files: . : WHATS_NEW lib/activate : dev_manager.c Log message: Replicator: add replicator to dtree Adding all replicator related LVs to dtree. Start of one replicator_dev initiate start of all other related. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1592&r2=1.1593 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.192&r2=1.193 --- LVM2/WHATS_NEW 2010/05/24 08:59:29 1.1592 +++ LVM2/WHATS_NEW 2010/05/24 09:01:05 1.1593 @@ -1,5 +1,6 @@ Version 2.02.67 - =============================== + Add Replicators' LVs to dtree for activation. Avoid print activation message if there is a missing VG (Replicator). Fixed scripts/relpath.awk to work in mawk Add _add_partial_replicator_to_dtree(). --- LVM2/lib/activate/dev_manager.c 2010/05/21 14:47:59 1.192 +++ LVM2/lib/activate/dev_manager.c 2010/05/24 09:01:05 1.193 @@ -1200,6 +1200,61 @@ 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 */ +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; + + /* For inactive replicator add linear mapping */ + 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, @@ -1230,9 +1285,12 @@ !_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; From zkabelac@sourceware.org Mon May 24 09:03:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Mon, 24 May 2010 09:03:00 -0000 Subject: LVM2 ./WHATS_NEW tools/vgchange.c Message-ID: <20100524090342.15596.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-24 09:03:39 Modified files: . : WHATS_NEW tools : vgchange.c Log message: Replicator: update activate code for vgchange Activate only the first replicator-dev LV, that activates all other related LVs from Replicator. In case of error during this activation, it will not retry again for other heads (less confusing error log). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1593&r2=1.1594 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.103&r2=1.104 --- LVM2/WHATS_NEW 2010/05/24 09:01:05 1.1593 +++ LVM2/WHATS_NEW 2010/05/24 09:03:39 1.1594 @@ -1,5 +1,6 @@ Version 2.02.67 - =============================== + Activate only first head of Replicator for vgchange -ay. Add Replicators' LVs to dtree for activation. Avoid print activation message if there is a missing VG (Replicator). Fixed scripts/relpath.awk to work in mawk --- LVM2/tools/vgchange.c 2010/05/24 08:59:30 1.103 +++ LVM2/tools/vgchange.c 2010/05/24 09:03:39 1.104 @@ -104,6 +104,11 @@ if ((lv->status & MIRROR_IMAGE) || (lv->status & MIRROR_LOG)) continue; + /* Only request activation of the first replicator-dev LV */ + /* Avoids retry with all heads in case of failure */ + 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)) && From zkabelac@sourceware.org Mon May 24 09:04:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Mon, 24 May 2010 09:04:00 -0000 Subject: LVM2 ./Makefile.in lib/activate/dev_manager.c ... Message-ID: <20100524090428.24732.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-24 09:04:28 Modified files: . : Makefile.in lib/activate : dev_manager.c lib/metadata : segtype.h libdm : libdm-deptree.c Log message: Update Copyright date for resently modifed files Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/Makefile.in.diff?cvsroot=lvm2&r1=1.54&r2=1.55 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.193&r2=1.194 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/segtype.h.diff?cvsroot=lvm2&r1=1.28&r2=1.29 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.78&r2=1.79 --- LVM2/Makefile.in 2010/05/20 14:45:14 1.54 +++ LVM2/Makefile.in 2010/05/24 09:04:27 1.55 @@ -1,6 +1,6 @@ # # Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. -# Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. +# Copyright (C) 2004-2010 Red Hat, Inc. All rights reserved. # # This file is part of LVM2. # --- LVM2/lib/activate/dev_manager.c 2010/05/24 09:01:05 1.193 +++ LVM2/lib/activate/dev_manager.c 2010/05/24 09:04:27 1.194 @@ -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. * --- LVM2/lib/metadata/segtype.h 2010/05/21 12:36:31 1.28 +++ LVM2/lib/metadata/segtype.h 2010/05/24 09:04:27 1.29 @@ -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. * --- LVM2/libdm/libdm-deptree.c 2010/05/21 12:30:35 1.78 +++ LVM2/libdm/libdm-deptree.c 2010/05/24 09:04:27 1.79 @@ -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. * From mornfall@sourceware.org Mon May 24 15:28:00 2010 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Mon, 24 May 2010 15:28:00 -0000 Subject: LVM2/test t-pvcreate-operation-md.sh Message-ID: <20100524152846.6076.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2010-05-24 15:28:45 Modified files: test : t-pvcreate-operation-md.sh Log message: Skip t-pvcreate-operation-md if mdadm fails to create the required device. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-pvcreate-operation-md.sh.diff?cvsroot=lvm2&r1=1.5&r2=1.6 --- LVM2/test/t-pvcreate-operation-md.sh 2010/04/13 21:42:44 1.5 +++ LVM2/test/t-pvcreate-operation-md.sh 2010/05/24 15:28:45 1.6 @@ -45,9 +45,10 @@ } # create 2 disk MD raid0 array (stripe_width=128K) -[ -b "$mddev" ] && exit 200 +test -b "$mddev" && exit 200 mdadm --create $mddev --auto=md --level 0 --raid-devices=2 --chunk 64 $dev1 $dev2 trap 'aux cleanup_md' EXIT # cleanup this MD device at the end of the test +test -b "$mddev" || exit 200 # Test alignment of PV on MD without any MD-aware or topology-aware detection # - should treat $mddev just like any other block device From mornfall@sourceware.org Mon May 24 15:32:00 2010 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Mon, 24 May 2010 15:32:00 -0000 Subject: LVM2 lib/activate/activate.c lib/activate/acti ... Message-ID: <20100524153225.8939.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2010-05-24 15:32:21 Modified files: lib/activate : activate.c activate.h dev_manager.c dev_manager.h lib/metadata : metadata-exported.h metadata.c metadata.h mirror.c segtype.h lib/mirror : mirrored.c test : t-lvconvert-repair-policy.sh t-lvconvert-repair.sh test-utils.sh tools : lvconvert.c pvmove.c Added files: test : t-lvconvert-repair-transient.sh Log message: Account for mirror transient status when doing lvconvert --repair. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.169&r2=1.170 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.67&r2=1.68 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.194&r2=1.195 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.h.diff?cvsroot=lvm2&r1=1.32&r2=1.33 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.151&r2=1.152 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.344&r2=1.345 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.204&r2=1.205 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.117&r2=1.118 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/segtype.h.diff?cvsroot=lvm2&r1=1.29&r2=1.30 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.67&r2=1.68 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvconvert-repair-transient.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvconvert-repair-policy.sh.diff?cvsroot=lvm2&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvconvert-repair.sh.diff?cvsroot=lvm2&r1=1.7&r2=1.8 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/test-utils.sh.diff?cvsroot=lvm2&r1=1.43&r2=1.44 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.133&r2=1.134 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvmove.c.diff?cvsroot=lvm2&r1=1.76&r2=1.77 --- LVM2/lib/activate/activate.c 2010/05/21 14:34:02 1.169 +++ LVM2/lib/activate/activate.c 2010/05/24 15:32:20 1.170 @@ -478,6 +478,28 @@ /* * Returns 1 if percent set, else 0 on failure. */ +int lv_check_transient(struct logical_volume *lv) +{ + int r; + struct dev_manager *dm; + + if (!activation()) + return 0; + + if (!(dm = dev_manager_create(lv->vg->cmd, lv->vg->name))) + return_0; + + if (!(r = dev_manager_transient(dm, lv))) + stack; + + dev_manager_destroy(dm); + + return r; +} + +/* + * Returns 1 if percent set, else 0 on failure. + */ int lv_snapshot_percent(const struct logical_volume *lv, float *percent, percent_range_t *percent_range) { --- LVM2/lib/activate/activate.h 2010/05/13 18:38:38 1.67 +++ LVM2/lib/activate/activate.h 2010/05/24 15:32:20 1.68 @@ -78,6 +78,7 @@ int lv_activation_filter(struct cmd_context *cmd, const char *lvid_s, int *activate_lv); +int lv_check_transient(struct logical_volume *lv); /* * Returns 1 if percent has been set, else 0. */ --- LVM2/lib/activate/dev_manager.c 2010/05/24 09:04:27 1.194 +++ LVM2/lib/activate/dev_manager.c 2010/05/24 15:32:20 1.195 @@ -543,6 +543,68 @@ return 0; } +int dev_manager_transient(struct dev_manager *dm, struct logical_volume *lv) +{ + int r = 0; + struct dm_task *dmt; + struct dm_info info; + void *next = NULL; + uint64_t start, length; + char *type = NULL; + char *params = NULL; + char *dlid = NULL; + const struct dm_list *segh = &lv->segments; + struct lv_segment *seg = NULL; + + if (!(dlid = build_dm_uuid(dm->mem, lv->lvid.s, NULL))) + return_0; + + if (!(dmt = _setup_task(0, dlid, NULL, DM_DEVICE_STATUS, 0, 0))) + return_0; + + if (!dm_task_no_open_count(dmt)) + log_error("Failed to disable open_count"); + + if (!dm_task_run(dmt)) + goto_out; + + if (!dm_task_get_info(dmt, &info) || !info.exists) + goto_out; + + do { + next = dm_get_next_target(dmt, next, &start, &length, &type, + ¶ms); + if (lv) { + if (!(segh = dm_list_next(&lv->segments, segh))) { + log_error("Number of segments in active LV %s " + "does not match metadata", lv->name); + goto out; + } + seg = dm_list_item(segh, struct lv_segment); + } + + if (!type || !params) + continue; + + if (seg->segtype->ops->check_transient_status && + !seg->segtype->ops->check_transient_status(seg, params)) + goto_out; + + } while (next); + + if (lv && (segh = dm_list_next(&lv->segments, segh))) { + log_error("Number of segments in active LV %s does not " + "match metadata", lv->name); + goto out; + } + + r = 1; + + out: + dm_task_destroy(dmt); + return r; +} + /* * dev_manager implementation. */ --- LVM2/lib/activate/dev_manager.h 2010/02/24 20:00:56 1.32 +++ LVM2/lib/activate/dev_manager.h 2010/05/24 15:32:20 1.33 @@ -57,6 +57,7 @@ int dev_manager_preload(struct dev_manager *dm, struct logical_volume *lv, int *flush_required); int dev_manager_deactivate(struct dev_manager *dm, struct logical_volume *lv); +int dev_manager_transient(struct dev_manager *dm, struct logical_volume *lv); int dev_manager_mknodes(const struct logical_volume *lv); --- LVM2/lib/metadata/metadata-exported.h 2010/05/21 14:07:17 1.151 +++ LVM2/lib/metadata/metadata-exported.h 2010/05/24 15:32:20 1.152 @@ -754,7 +754,8 @@ uint32_t split_count, struct dm_list *removable_pvs); int lv_remove_mirrors(struct cmd_context *cmd, struct logical_volume *lv, uint32_t mirrors, uint32_t log_count, - struct dm_list *pvs, uint64_t status_mask); + int (*is_removable)(struct logical_volume *, void *), + void *removable_baton, uint64_t status_mask); int is_temporary_mirror_layer(const struct logical_volume *lv); struct logical_volume * find_temporary_mirror(const struct logical_volume *lv); @@ -769,7 +770,8 @@ struct dm_list *allocatable_pvs, alloc_policy_t alloc); int remove_mirror_images(struct logical_volume *lv, uint32_t num_mirrors, - struct dm_list *removable_pvs, unsigned remove_log); + int (*is_removable)(struct logical_volume *, void *), + void *removable_baton, unsigned remove_log); int add_mirror_images(struct cmd_context *cmd, struct logical_volume *lv, uint32_t mirrors, uint32_t stripes, uint32_t stripe_size, uint32_t region_size, struct dm_list *allocatable_pvs, alloc_policy_t alloc, --- LVM2/lib/metadata/metadata.c 2010/05/21 12:45:19 1.344 +++ LVM2/lib/metadata/metadata.c 2010/05/24 15:32:20 1.345 @@ -2117,7 +2117,7 @@ * propagated transitively, so LVs referencing other LVs are marked * partial as well, if any of their referenced LVs are marked partial. */ -static int _vg_mark_partial_lvs(struct volume_group *vg) +int vg_mark_partial_lvs(struct volume_group *vg) { struct logical_volume *lv; struct lv_list *lvl; @@ -2654,7 +2654,7 @@ if (vg_missing_pv_count(correct_vg)) { log_verbose("There are %d physical volumes missing.", vg_missing_pv_count(correct_vg)); - _vg_mark_partial_lvs(correct_vg); + vg_mark_partial_lvs(correct_vg); } *consistent = 1; return correct_vg; @@ -2945,7 +2945,7 @@ if (vg_missing_pv_count(correct_vg)) { log_verbose("There are %d physical volumes missing.", vg_missing_pv_count(correct_vg)); - _vg_mark_partial_lvs(correct_vg); + vg_mark_partial_lvs(correct_vg); } if ((correct_vg->status & PVMOVE) && !pvmove_mode()) { --- LVM2/lib/metadata/metadata.h 2010/05/21 12:43:02 1.204 +++ LVM2/lib/metadata/metadata.h 2010/05/24 15:32:20 1.205 @@ -383,5 +383,7 @@ struct physical_volume *pv_by_path(struct cmd_context *cmd, const char *pv_name); int add_pv_to_vg(struct volume_group *vg, const char *pv_name, struct physical_volume *pv); +int vg_mark_partial_lvs(struct volume_group *vg); +int is_mirror_image_removable(struct logical_volume *mimage_lv, void *baton); #endif --- LVM2/lib/metadata/mirror.c 2010/05/14 15:19:43 1.117 +++ LVM2/lib/metadata/mirror.c 2010/05/24 15:32:20 1.118 @@ -435,14 +435,17 @@ } /* Check if mirror image LV is removable with regard to given removable_pvs */ -static int _is_mirror_image_removable(struct logical_volume *mimage_lv, - struct dm_list *removable_pvs) +int is_mirror_image_removable(struct logical_volume *mimage_lv, void *baton) { struct physical_volume *pv; struct lv_segment *seg; int pv_found; struct pv_list *pvl; uint32_t s; + struct dm_list *removable_pvs = baton; + + if (!baton || dm_list_empty(removable_pvs)) + return 1; dm_list_iterate_items(seg, &mimage_lv->segments) { for (s = 0; s < seg->area_count; s++) { @@ -508,7 +511,7 @@ sub_lv = seg_lv(mirrored_seg, i); if (!is_temporary_mirror_layer(sub_lv) && - _is_mirror_image_removable(sub_lv, removable_pvs)) { + is_mirror_image_removable(sub_lv, removable_pvs)) { if (!shift_mirror_images(mirrored_seg, i)) return_0; count--; @@ -754,13 +757,13 @@ */ static int _remove_mirror_images(struct logical_volume *lv, uint32_t num_removed, - struct dm_list *removable_pvs, + int (*is_removable)(struct logical_volume *, void *), + void *removable_baton, unsigned remove_log, unsigned collapse, uint32_t *removed) { uint32_t m; int32_t s; - int removable_pvs_specified; struct logical_volume *sub_lv; struct logical_volume *detached_log_lv = NULL; struct logical_volume *temp_layer_lv = NULL; @@ -770,9 +773,6 @@ struct lv_list *lvl; struct dm_list tmp_orphan_lvs; - removable_pvs_specified = (removable_pvs && - !dm_list_empty(removable_pvs)) ? 1 : 0; - if (removed) *removed = 0; @@ -781,38 +781,32 @@ old_area_count, old_area_count - num_removed, remove_log ? " and no log volume" : ""); - if (collapse && - (removable_pvs_specified || (old_area_count - num_removed != 1))) { + if (collapse && (old_area_count - num_removed != 1)) { log_error("Incompatible parameters to _remove_mirror_images"); return 0; } /* Move removable_pvs to end of array */ - if (removable_pvs_specified) { - for (s = mirrored_seg->area_count - 1; - s >= 0 && old_area_count - new_area_count < num_removed; - s--) { - sub_lv = seg_lv(mirrored_seg, s); - - if (!is_temporary_mirror_layer(sub_lv) && - _is_mirror_image_removable(sub_lv, removable_pvs)) { - /* - * Check if the user is trying to pull the - * primary mirror image when the mirror is - * not in-sync. - */ - if ((s == 0) && !_mirrored_lv_in_sync(lv) && - !(lv->status & PARTIAL_LV)) { - log_error("Unable to remove primary mirror image while mirror is not in-sync"); - return_0; - } - if (!shift_mirror_images(mirrored_seg, s)) - return_0; - new_area_count--; + for (s = mirrored_seg->area_count - 1; + s >= 0 && old_area_count - new_area_count < num_removed; + s--) { + sub_lv = seg_lv(mirrored_seg, s); + if (!is_temporary_mirror_layer(sub_lv) && + is_removable(sub_lv, removable_baton)) { + /* + * Check if the user is trying to pull the + * primary mirror image when the mirror is + * not in-sync. + */ + if ((s == 0) && !_mirrored_lv_in_sync(lv) && + !(lv->status & PARTIAL_LV)) { + log_error("Unable to remove primary mirror image while mirror is not in-sync"); + return_0; } + if (!shift_mirror_images(mirrored_seg, s)) + return_0; + new_area_count--; } - if (num_removed && old_area_count == new_area_count) - return 1; } /* @@ -822,6 +816,9 @@ */ new_area_count = old_area_count - num_removed; + if (num_removed && old_area_count == new_area_count) + return 1; + /* Remove mimage LVs from the segment */ dm_list_init(&tmp_orphan_lvs); for (m = new_area_count; m < mirrored_seg->area_count; m++) { @@ -956,7 +953,8 @@ * Remove the number of mirror images from the LV */ int remove_mirror_images(struct logical_volume *lv, uint32_t num_mirrors, - struct dm_list *removable_pvs, unsigned remove_log) + int (*is_removable)(struct logical_volume *, void *), + void *removable_baton, unsigned remove_log) { uint32_t num_removed, removed_once, r; uint32_t existing_mirrors = lv_mirror_count(lv); @@ -972,7 +970,8 @@ removed_once = first_seg(next_lv)->area_count - 1; if (!_remove_mirror_images(next_lv, removed_once, - removable_pvs, remove_log, 0, &r)) + is_removable, removable_baton, + remove_log, 0, &r)) return_0; if (r < removed_once) { @@ -999,6 +998,11 @@ return 1; } +static int _no_removable_images(struct logical_volume *lv __attribute((unused)), + void *baton __attribute((unused))) { + return 0; +} + /* * Collapsing temporary mirror layers. * @@ -1031,7 +1035,7 @@ if (!_remove_mirror_images(mirror_seg->lv, mirror_seg->area_count - 1, - NULL, 1, 1, NULL)) { + _no_removable_images, NULL, 1, 1, NULL)) { log_error("Failed to release mirror images"); return 0; } @@ -1156,7 +1160,8 @@ init_mirror_in_sync(in_sync); r = _remove_mirror_images(mirrored_seg->lv, old_num_mirrors - num_mirrors, - removable_pvs, remove_log, 0, NULL); + is_mirror_image_removable, removable_pvs, + remove_log, 0, NULL); if (!r) /* Unable to remove bad devices */ return 0; @@ -1549,7 +1554,7 @@ } if (!remove_mirror_images(lv, lv_mirror_count(lv), - removable_pvs, 1U)) + is_mirror_image_removable, removable_pvs, 1U)) return_0; return 1; @@ -1929,7 +1934,9 @@ */ int lv_remove_mirrors(struct cmd_context *cmd __attribute((unused)), struct logical_volume *lv, - uint32_t mirrors, uint32_t log_count, struct dm_list *pvs, + uint32_t mirrors, uint32_t log_count, + int (*is_removable)(struct logical_volume *, void *), + void *removable_baton, uint64_t status_mask) { uint32_t new_mirrors; @@ -1957,7 +1964,8 @@ if (seg_type(seg, 0) == AREA_LV && seg_lv(seg, 0)->status & MIRROR_IMAGE) return remove_mirror_images(lv, new_mirrors + 1, - pvs, log_count ? 1U : 0); + is_removable, removable_baton, + log_count ? 1U : 0); /* MIRROR_BY_SEG */ if (log_count) { --- LVM2/lib/metadata/segtype.h 2010/05/24 09:04:27 1.29 +++ LVM2/lib/metadata/segtype.h 2010/05/24 15:32:21 1.30 @@ -82,6 +82,7 @@ struct dm_tree_node *node, uint64_t len, uint32_t *pvmove_mirror_count); int (*target_status_compatible) (const char *type); + int (*check_transient_status) (struct lv_segment *seg, char *params); int (*target_percent) (void **target_state, percent_range_t *percent_range, struct dm_pool * mem, --- LVM2/lib/mirror/mirrored.c 2010/04/14 13:01:42 1.67 +++ LVM2/lib/mirror/mirrored.c 2010/05/24 15:32:21 1.68 @@ -239,6 +239,117 @@ return 1; } +static int _mirrored_transient_status(struct lv_segment *seg, char *params) +{ + int i, j; + struct logical_volume *lv = seg->lv; + struct lvinfo info; + char *p = NULL; + char **args, **log_args; + struct logical_volume **images; + struct logical_volume *log; + int num_devs, log_argc; + int failed = 0; + char *status; + + log_error("Mirrored transient status: \"%s\"", params); + + /* number of devices */ + if (!dm_split_words(params, 1, 0, &p)) + return_0; + + if (!(num_devs = atoi(p))) + return_0; + + p += strlen(p) + 1; + + if (num_devs > DEFAULT_MIRROR_MAX_IMAGES) { + log_error("Unexpectedly many (%d) mirror images in %s.", + num_devs, lv->name); + return_0; + } + + args = alloca((num_devs + 5) * sizeof(char *)); + images = alloca(num_devs * sizeof(struct logical_volume *)); + + if (dm_split_words(p, num_devs + 4, 0, args) < num_devs + 4) + return_0; + + log_argc = atoi(args[3 + num_devs]); + log_args = alloca(log_argc * sizeof(char *)); + + if (log_argc > 16) { + log_error("Unexpectedly many (%d) log arguments in %s.", + log_argc, lv->name); + return_0; + } + + + if (dm_split_words(args[3 + num_devs] + strlen(args[3 + num_devs]) + 1, + log_argc, 0, log_args) < log_argc) + return_0; + + if (num_devs != seg->area_count) { + log_error("Active mirror has a wrong number of mirror images!"); + log_error("Metadata says %d, kernel says %d.", seg->area_count, num_devs); + return_0; + } + + if (!strcmp(log_args[0], "disk")) { + char buf[32]; + log = first_seg(lv)->log_lv; + lv_info(lv->vg->cmd, log, &info, 0, 0); + log_debug("Found mirror log at %d:%d", info.major, info.minor); + sprintf(buf, "%d:%d", info.major, info.minor); + if (strcmp(buf, log_args[1])) { + log_error("Mirror log mismatch. Metadata says %s, kernel says %s.", + buf, log_args[1]); + return_0; + } + log_very_verbose("Status of log (%s): %s", buf, log_args[2]); + if (log_args[2][0] != 'A') { + log->status |= PARTIAL_LV; + ++failed; + } + } + + for (i = 0; i < num_devs; ++i) + images[i] = NULL; + + for (i = 0; i < seg->area_count; ++i) { + char buf[32]; + lv_info(lv->vg->cmd, seg_lv(seg, i), &info, 0, 0); + log_debug("Found mirror leg at %d:%d", info.major, info.minor); + sprintf(buf, "%d:%d", info.major, info.minor); + for (j = 0; j < num_devs; ++j) { + if (!strcmp(buf, args[j])) { + log_debug("Match: metadata image %d matches kernel image %d", i, j); + images[j] = seg_lv(seg, i); + } + } + } + + status = args[2 + num_devs]; + + for (i = 0; i < num_devs; ++i) { + if (!images[i]) { + log_error("Failed to find image %d (%s).", i, args[i]); + return_0; + } + log_very_verbose("Status of image %d: %c", i, status[i]); + if (status[i] != 'A') { + images[i]->status |= PARTIAL_LV; + ++failed; + } + } + + /* update PARTIAL_LV flags across the VG */ + if (failed) + vg_mark_partial_lvs(lv->vg); + + return 1; +} + static int _add_log(struct dm_pool *mem, struct lv_segment *seg, struct dm_tree_node *node, uint32_t area_count, uint32_t region_size) { @@ -564,6 +675,7 @@ .add_target_line = _mirrored_add_target_line, .target_percent = _mirrored_target_percent, .target_present = _mirrored_target_present, + .check_transient_status = _mirrored_transient_status, #ifdef DMEVENTD .target_monitored = _target_monitored, .target_monitor_events = _target_monitor_events, /cvs/lvm2/LVM2/test/t-lvconvert-repair-transient.sh,v --> standard output revision 1.1 --- LVM2/test/t-lvconvert-repair-transient.sh +++ - 2010-05-24 15:32:24.865853000 +0000 @@ -0,0 +1,26 @@ +#!/bin/bash +# Copyright (C) 2008 Red Hat, Inc. All rights reserved. +# +# 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 + +. ./test-utils.sh + +prepare_vg 5 + +# fail multiple devices + +lvcreate -m 3 --ig -L 1 -n 4way $vg +disable_dev $dev2 $dev4 +mkfs.ext3 $DM_DEV_DIR/$vg/4way +enable_dev $dev2 $dev4 +echo n | lvconvert --repair $vg/4way 2>&1 | tee 4way.out +lvs -a -o +devices | not grep unknown +vgreduce --removemissing $vg +check mirror $vg 4way +lvchange -a n $vg/4way --- LVM2/test/t-lvconvert-repair-policy.sh 2010/04/14 13:51:58 1.4 +++ LVM2/test/t-lvconvert-repair-policy.sh 2010/05/24 15:32:21 1.5 @@ -32,40 +32,49 @@ lvchange -a n $vg/mirror # Fail a leg of a mirror. -disable_dev $dev1 +aux disable_dev $dev1 lvchange --partial -a y $vg/mirror repair 'activation { mirror_image_fault_policy = "remove" }' check linear $vg mirror -cleanup $dev1 +aux cleanup $dev1 # Fail a leg of a mirror. # Expected result: Mirror (leg replaced) -disable_dev $dev1 +aux disable_dev $dev1 repair 'activation { mirror_image_fault_policy = "replace" }' check mirror $vg mirror lvs | grep mirror_mlog -cleanup $dev1 +aux cleanup $dev1 # Fail a leg of a mirror (use old name for policy specification) # Expected result: Mirror (leg replaced) -disable_dev $dev1 +aux disable_dev $dev1 repair 'activation { mirror_device_fault_policy = "replace" }' check mirror $vg mirror lvs | grep mirror_mlog -cleanup $dev1 +aux cleanup $dev1 # Fail a leg of a mirror w/ no available spare # Expected result: 2-way with corelog -disable_dev $dev2 $dev4 +aux disable_dev $dev2 $dev4 repair 'activation { mirror_image_fault_policy = "replace" }' check mirror $vg mirror lvs | not grep mirror_mlog -cleanup $dev2 $dev4 +aux cleanup $dev2 $dev4 # Fail the log device of a mirror w/ no available spare # Expected result: mirror w/ corelog -disable_dev $dev3 $dev4 -lvconvert --repair --use-policies --config 'activation { mirror_image_fault_policy = "replace" }' $vg/mirror +aux disable_dev $dev3 $dev4 +repair 'activation { mirror_image_fault_policy = "replace" }' $vg/mirror check mirror $vg mirror lvs | not grep mirror_mlog +aux cleanup $dev3 $dev4 + +# Fail the log device with a remove policy +# Expected result: mirror w/ corelog +lvchange -a y $vg/mirror +aux disable_dev $dev3 $dev4 +repair 'activation { mirror_log_fault_policy = "remove" }' +check mirror $vg mirror core +lvs | not grep mirror_mlog cleanup $dev3 $dev4 --- LVM2/test/t-lvconvert-repair.sh 2010/04/14 13:51:58 1.7 +++ LVM2/test/t-lvconvert-repair.sh 2010/05/24 15:32:21 1.8 @@ -11,38 +11,59 @@ . ./test-utils.sh -prepare_vg 5 # fail multiple devices -lvcreate -m 3 --ig -L 1 -n 4way $vg +aux prepare_vg 5 +lvcreate -m 3 --ig -L 1 -n 4way $vg $dev1 $dev2 $dev3 $dev4 $dev5:0 disable_dev $dev2 $dev4 echo n | lvconvert --repair $vg/4way 2>&1 | tee 4way.out lvs -a -o +devices | not grep unknown vgreduce --removemissing $vg enable_dev $dev2 $dev4 -check mirror $vg 4way -lvchange -a n $vg/4way - -vgremove -ff $vg -vgcreate -c n $vg $dev1 $dev2 $dev3 $dev4 +check mirror $vg 4way $dev5 +aux prepare_vg 5 lvcreate -m 2 --ig -L 1 -n 3way $vg disable_dev $dev1 $dev2 echo n | lvconvert --repair $vg/3way +check linear $vg 3way lvs -a -o +devices | not grep unknown +lvs -a -o +devices | not grep mlog +dmsetup ls | grep $PREFIX | not grep mlog vgreduce --removemissing $vg enable_dev $dev1 $dev2 check linear $vg 3way -lvchange -a n $vg/3way + +# fail just log and get it removed + +aux prepare_vg 5 +lvcreate -m 2 --ig -L 1 -n 3way $vg $dev1 $dev2 $dev3 $dev4:0 +disable_dev $dev4 +echo n | lvconvert --repair $vg/3way +check mirror $vg 3way core +lvs -a -o +devices | not grep unknown +lvs -a -o +devices | not grep mlog +dmsetup ls | grep $PREFIX | not grep mlog +vgreduce --removemissing $vg +enable_dev $dev4 + +aux prepare_vg 5 +lvcreate -m 1 --ig -L 1 -n 2way $vg $dev1 $dev2 $dev3:0 +disable_dev $dev3 +echo n | lvconvert --repair $vg/2way +check mirror $vg 2way core +lvs -a -o +devices | not grep unknown +lvs -a -o +devices | not grep mlog +vgreduce --removemissing $vg +enable_dev $dev3 # fail single devices -vgremove -ff $vg -vgcreate -c n $vg $dev1 $dev2 $dev3 +aux prepare_vg 5 +vgreduce $vg $dev4 lvcreate -m 1 --ig -L 1 -n mirror $vg - lvchange -a n $vg/mirror vgextend $vg $dev4 disable_dev $dev1 --- LVM2/test/test-utils.sh 2010/05/14 14:56:40 1.43 +++ LVM2/test/test-utils.sh 2010/05/24 15:32:21 1.44 @@ -373,6 +373,7 @@ level = 9 file = "$TESTDIR/debug.log" overwrite = 1 + activation = 1 } backup { backup = 0 --- LVM2/tools/lvconvert.c 2010/04/28 17:41:30 1.133 +++ LVM2/tools/lvconvert.c 2010/05/24 15:32:21 1.134 @@ -15,6 +15,7 @@ #include "tools.h" #include "polldaemon.h" #include "lv_alloc.h" +#include "metadata.h" struct lvconvert_params { int snapshot; @@ -603,6 +604,12 @@ return failed_pvs; } +static int _is_partial_lv(struct logical_volume *lv, + void *baton __attribute((unused))) +{ + return lv->status & PARTIAL_LV; +} + /* * Walk down the stacked mirror LV to the original mirror LV. */ @@ -727,7 +734,7 @@ } /* Reducing redundancy of the log */ - return remove_mirror_images(log_lv, log_count, operable_pvs, 1U); + return remove_mirror_images(log_lv, log_count, is_mirror_image_removable, operable_pvs, 1U); } /* @@ -913,6 +920,34 @@ return 1; } +static int _reload_lv(struct cmd_context *cmd, struct logical_volume *lv) +{ + log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name); + + if (!vg_write(lv->vg)) + return_0; + + if (!suspend_lv(cmd, lv)) { + log_error("Failed to lock %s", lv->name); + vg_revert(lv->vg); + return 0; + } + + if (!vg_commit(lv->vg)) { + if (!resume_lv(cmd, lv)) + stack; + return_0; + } + + log_very_verbose("Updating \"%s\" in kernel", lv->name); + + if (!resume_lv(cmd, lv)) { + log_error("Problem reactivating %s", lv->name); + return 0; + } + return 1; +} + /* * _lvconvert_mirrors_aux * @@ -1005,6 +1040,16 @@ } /* + * Is there already a convert in progress? We do not + * currently allow more than one. + */ + if (find_temporary_mirror(lv) || (lv->status & CONVERTING)) { + log_error("%s is already being converted. Unable to start another conversion.", + lv->name); + return 0; + } + + /* * Log addition/removal should be done before the layer * insertion to make the end result consistent with * linear-to-mirror conversion. @@ -1064,7 +1109,7 @@ nmc, operable_pvs)) return 0; } else if (!lv_remove_mirrors(cmd, lv, nmc, nlc, - operable_pvs, 0)) + is_mirror_image_removable, operable_pvs, 0)) return_0; goto out; /* Just in case someone puts code between */ @@ -1084,29 +1129,8 @@ out_skip_log_convert: - log_very_verbose("Updating logical volume \"%s\" on disk(s)", lv->name); - - if (!vg_write(lv->vg)) - return_0; - - if (!suspend_lv(cmd, lv)) { - log_error("Failed to lock %s", lv->name); - vg_revert(lv->vg); - goto out; - } - - if (!vg_commit(lv->vg)) { - if (!resume_lv(cmd, lv)) - stack; - goto_out; - } - - log_very_verbose("Updating \"%s\" in kernel", lv->name); - - if (!resume_lv(cmd, lv)) { - log_error("Problem reactivating %s", lv->name); - goto out; - } + if (!_reload_lv(cmd, lv)) + return 0; return 1; } @@ -1139,6 +1163,8 @@ cmd->partial_activation = 1; lp->need_polling = 0; + lv_check_transient(lv); /* TODO check this in lib for all commands? */ + if (!(lv->status & PARTIAL_LV)) { log_error("%s is consistent. Nothing to repair.", lv->name); return 1; @@ -1195,11 +1221,13 @@ if (!_lv_update_log_type(cmd, lp, lv, failed_pvs, new_log_count)) return 0; - /* - * Remove all failed_pvs - */ - if (!_lvconvert_mirrors_aux(cmd, lv, lp, failed_pvs, - lp->mirrors, new_log_count)) + if (failed_mirrors) { + if (!lv_remove_mirrors(cmd, lv, failed_mirrors, new_log_count, + _is_partial_lv, NULL, 0)) + return 0; + } + + if (!_reload_lv(cmd, lv)) return 0; /* @@ -1209,6 +1237,13 @@ if (replace_mirrors) lp->mirrors = old_mimage_count; + /* + * It does not make sense to replace the log if the volume is no longer + * a mirror. + */ + if (!replace_mirrors && lp->mirrors == 1) + replace_log = 0; + log_count = replace_log ? old_log_count : new_log_count; while (replace_mirrors || replace_log) { @@ -1226,10 +1261,10 @@ } } - if (lp->mirrors != old_mimage_count) + if (replace_mirrors && lp->mirrors != old_mimage_count) log_warn("WARNING: Failed to replace %d of %d images in volume %s", old_mimage_count - lp->mirrors, old_mimage_count, lv->name); - if (log_count != old_log_count) + if (replace_log && log_count != old_log_count) log_warn("WARNING: Failed to replace %d of %d logs in volume %s", old_log_count - log_count, old_log_count, lv->name); --- LVM2/tools/pvmove.c 2010/04/09 01:00:11 1.76 +++ LVM2/tools/pvmove.c 2010/05/24 15:32:21 1.77 @@ -292,7 +292,7 @@ /* Update metadata to remove mirror segments and break dependencies */ dm_list_init(&lvs_completed); - if (!lv_remove_mirrors(cmd, lv_mirr, 1, 0, NULL, PVMOVE) || + if (!lv_remove_mirrors(cmd, lv_mirr, 1, 0, NULL, NULL, PVMOVE) || !remove_layers_for_segments_all(cmd, lv_mirr, PVMOVE, &lvs_completed)) { return 0; From agk@sourceware.org Mon May 24 16:30:00 2010 From: agk@sourceware.org (agk@sourceware.org) Date: Mon, 24 May 2010 16:30:00 -0000 Subject: LVM2 ./WHATS_NEW lib/mirror/mirrored.c Message-ID: <20100524163018.26663.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-05-24 16:30:16 Modified files: . : WHATS_NEW lib/mirror : mirrored.c Log message: Update clustered log kernel module name to log-userspace. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1594&r2=1.1595 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.68&r2=1.69 --- LVM2/WHATS_NEW 2010/05/24 09:03:39 1.1594 +++ LVM2/WHATS_NEW 2010/05/24 16:30:15 1.1595 @@ -1,5 +1,6 @@ Version 2.02.67 - =============================== + Update clustered log kernel module name to log-userspace. Activate only first head of Replicator for vgchange -ay. Add Replicators' LVs to dtree for activation. Avoid print activation message if there is a missing VG (Replicator). --- LVM2/lib/mirror/mirrored.c 2010/05/24 15:32:21 1.68 +++ LVM2/lib/mirror/mirrored.c 2010/05/24 16:30:16 1.69 @@ -503,7 +503,7 @@ * FIXME: Fails incorrectly if cmirror was built into kernel. */ if (attributes) { - if (!_mirror_attributes && module_present(cmd, "log-clustered")) + if (!_mirror_attributes && module_present(cmd, "log-userspace")) _mirror_attributes |= MIRROR_LOG_CLUSTERED; *attributes = _mirror_attributes; } From mornfall@sourceware.org Mon May 24 16:33:00 2010 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Mon, 24 May 2010 16:33:00 -0000 Subject: LVM2/test t-lvconvert-repair-transient.sh Message-ID: <20100524163322.28557.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2010-05-24 16:33:21 Modified files: test : t-lvconvert-repair-transient.sh Log message: t-lvconvert-repair-transient hangs on .33 and on RHEL6 kernel -> disable Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvconvert-repair-transient.sh.diff?cvsroot=lvm2&r1=1.1&r2=1.2 --- LVM2/test/t-lvconvert-repair-transient.sh 2010/05/24 15:32:21 1.1 +++ LVM2/test/t-lvconvert-repair-transient.sh 2010/05/24 16:33:21 1.2 @@ -13,6 +13,8 @@ prepare_vg 5 +exit 200 # this breaks upstream .33 and RHEL6 kernel :( + # fail multiple devices lvcreate -m 3 --ig -L 1 -n 4way $vg From mbroz@sourceware.org Mon May 24 17:18:00 2010 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Mon, 24 May 2010 17:18:00 -0000 Subject: LVM2/test test-utils.sh Message-ID: <20100524171825.32344.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2010-05-24 17:18:12 Modified files: test : test-utils.sh Log message: Replace lvm.conf instead of truncating it. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/test-utils.sh.diff?cvsroot=lvm2&r1=1.44&r2=1.45 --- LVM2/test/test-utils.sh 2010/05/24 15:32:21 1.44 +++ LVM2/test/test-utils.sh 2010/05/24 17:18:05 1.45 @@ -358,7 +358,7 @@ filter='[ "a/dev\/mirror/", "a/dev\/mapper\/.*pv[0-9_]*$/", "r/.*/" ]' locktype= if test -n "$LVM_TEST_LOCKING"; then locktype="locking_type = $LVM_TEST_LOCKING"; fi - cat > $TESTDIR/etc/lvm.conf <<-EOF + cat > $TESTDIR/etc/lvm.conf.new <<-EOF $LVM_TEST_CONFIG devices { dir = "$DM_DEV_DIR" @@ -391,6 +391,8 @@ polling_interval = 0 } EOF + # FIXME remove this workaround after mmap & truncating file problems solved + mv $TESTDIR/etc/lvm.conf.new $TESTDIR/etc/lvm.conf cat $TESTDIR/etc/lvm.conf } From mbroz@sourceware.org Mon May 24 17:19:00 2010 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Mon, 24 May 2010 17:19:00 -0000 Subject: LVM2/test test-utils.sh Message-ID: <20100524171953.1639.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2010-05-24 17:19:50 Modified files: test : test-utils.sh Log message: Use mv -f for replace config in test. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/test-utils.sh.diff?cvsroot=lvm2&r1=1.45&r2=1.46 --- LVM2/test/test-utils.sh 2010/05/24 17:18:05 1.45 +++ LVM2/test/test-utils.sh 2010/05/24 17:19:50 1.46 @@ -392,7 +392,7 @@ } EOF # FIXME remove this workaround after mmap & truncating file problems solved - mv $TESTDIR/etc/lvm.conf.new $TESTDIR/etc/lvm.conf + mv -f $TESTDIR/etc/lvm.conf.new $TESTDIR/etc/lvm.conf cat $TESTDIR/etc/lvm.conf } From agk@sourceware.org Mon May 24 17:46:00 2010 From: agk@sourceware.org (agk@sourceware.org) Date: Mon, 24 May 2010 17:46:00 -0000 Subject: LVM2 ./WHATS_NEW lib/mirror/mirrored.c libdm/l ... Message-ID: <20100524174648.10784.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-05-24 17:46:48 Modified files: . : WHATS_NEW lib/mirror : mirrored.c libdm : libdm-deptree.c Log message: Choose between clustered log versions based on kernel version. Add fixmes for broken strcmp. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1595&r2=1.1596 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.69&r2=1.70 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.79&r2=1.80 --- LVM2/WHATS_NEW 2010/05/24 16:30:15 1.1595 +++ LVM2/WHATS_NEW 2010/05/24 17:46:47 1.1596 @@ -1,6 +1,6 @@ Version 2.02.67 - =============================== - Update clustered log kernel module name to log-userspace. + Update clustered log kernel module name to log-userspace for 2.6.31 onwards. Activate only first head of Replicator for vgchange -ay. Add Replicators' LVs to dtree for activation. Avoid print activation message if there is a missing VG (Replicator). --- LVM2/lib/mirror/mirrored.c 2010/05/24 16:30:16 1.69 +++ LVM2/lib/mirror/mirrored.c 2010/05/24 17:46:47 1.70 @@ -28,6 +28,8 @@ #include "sharedlib.h" #include "str_list.h" +#include + #ifdef DMEVENTD # include "libdevmapper-event.h" #endif @@ -471,6 +473,7 @@ uint32_t maj, min, patchlevel; unsigned maj2, min2, patchlevel2; char vsn[80]; + struct utsname uts; if (!_mirrored_checked) { _mirrored_present = target_present(cmd, "mirror", 1); @@ -503,8 +506,18 @@ * FIXME: Fails incorrectly if cmirror was built into kernel. */ if (attributes) { - if (!_mirror_attributes && module_present(cmd, "log-userspace")) - _mirror_attributes |= MIRROR_LOG_CLUSTERED; + if (!_mirror_attributes) { + /* + * The dm-log-userspace module was added to the + * 2.6.31 kernel. + */ + /* FIXME Replace the broken string comparison! */ + if (!uname(&uts) && strncmp(uts.release, "2.6.31", 6) < 0) { + if (module_present(cmd, "log-clustered")) + _mirror_attributes |= MIRROR_LOG_CLUSTERED; + } else if (module_present(cmd, "log-userspace")) + _mirror_attributes |= MIRROR_LOG_CLUSTERED; + } *attributes = _mirror_attributes; } _mirrored_checked = 1; --- LVM2/libdm/libdm-deptree.c 2010/05/24 09:04:27 1.79 +++ LVM2/libdm/libdm-deptree.c 2010/05/24 17:46:47 1.80 @@ -1575,6 +1575,7 @@ * The dm-log-userspace module was added to the * 2.6.31 kernel. */ + /* FIXME Replace the broken string comparison! */ if (strncmp(uts.release, "2.6.31", 6) >= 0) dm_log_userspace = 1; } From mbroz@sourceware.org Mon May 24 19:27:00 2010 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Mon, 24 May 2010 19:27:00 -0000 Subject: LVM2/test t-topology-support.sh Message-ID: <20100524192739.1100.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2010-05-24 19:27:38 Modified files: test : t-topology-support.sh Log message: Fix topology test after last changes to not leak loop devices. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-topology-support.sh.diff?cvsroot=lvm2&r1=1.3&r2=1.4 --- LVM2/test/t-topology-support.sh 2010/04/07 14:46:27 1.3 +++ LVM2/test/t-topology-support.sh 2010/05/24 19:27:38 1.4 @@ -68,7 +68,8 @@ sector_size=$LOGICAL_BLOCK_SIZE physblk_exp=3 check_logical_block_size $SCSI_DEBUG_DEV $LOGICAL_BLOCK_SIZE -aux prepare_vg $NUM_DEVS $PER_DEV_SIZE +aux prepare_pvs $NUM_DEVS $PER_DEV_SIZE +vgcreate -c n $vg $devs test_snapshot_mount vgremove $vg @@ -82,7 +83,8 @@ sector_size=$LOGICAL_BLOCK_SIZE physblk_exp=3 lowest_aligned=7 check_logical_block_size $SCSI_DEBUG_DEV $LOGICAL_BLOCK_SIZE -aux prepare_vg $NUM_DEVS $PER_DEV_SIZE +aux prepare_pvs $NUM_DEVS $PER_DEV_SIZE +vgcreate -c n $vg $devs test_snapshot_mount vgremove $vg @@ -96,6 +98,7 @@ sector_size=$LOGICAL_BLOCK_SIZE check_logical_block_size $SCSI_DEBUG_DEV $LOGICAL_BLOCK_SIZE -aux prepare_vg $NUM_DEVS $PER_DEV_SIZE +aux prepare_pvs $NUM_DEVS $PER_DEV_SIZE +vgcreate -c n $vg $devs test_snapshot_mount vgremove $vg From agk@sourceware.org Mon May 24 22:53:00 2010 From: agk@sourceware.org (agk@sourceware.org) Date: Mon, 24 May 2010 22:53:00 -0000 Subject: LVM2 ./WHATS_NEW lib/device/dev-cache.c Message-ID: <20100524225349.5670.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-05-24 22:53:49 Modified files: . : WHATS_NEW lib/device : dev-cache.c Log message: Avoid selecting names under /dev/block if there is an alternative. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1596&r2=1.1597 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-cache.c.diff?cvsroot=lvm2&r1=1.56&r2=1.57 --- LVM2/WHATS_NEW 2010/05/24 17:46:47 1.1596 +++ LVM2/WHATS_NEW 2010/05/24 22:53:48 1.1597 @@ -1,5 +1,6 @@ Version 2.02.67 - =============================== + Avoid selecting names under /dev/block if there is an alternative. Update clustered log kernel module name to log-userspace for 2.6.31 onwards. Activate only first head of Replicator for vgchange -ay. Add Replicators' LVs to dtree for activation. --- LVM2/lib/device/dev-cache.c 2009/07/15 20:02:46 1.56 +++ LVM2/lib/device/dev-cache.c 2010/05/24 22:53:49 1.57 @@ -40,6 +40,7 @@ struct dm_hash_table *names; struct btree *devices; struct dm_regex *preferred_names_matcher; + const char *dev_dir; int has_scanned; struct dm_list dirs; @@ -155,6 +156,7 @@ char p0[PATH_MAX], p1[PATH_MAX]; char *s0, *s1; struct stat stat0, stat1; + size_t devdir_len; /* * FIXME Better to compare patterns one-at-a-time against all names. @@ -179,6 +181,19 @@ * Built-in rules. */ + /* + * Anything beats /dev/block. + */ + devdir_len = strlen(_cache.dev_dir); + if (!strncmp(path0, _cache.dev_dir, devdir_len) && + !strncmp(path1, _cache.dev_dir, devdir_len)) { + if (!strncmp(path0 + devdir_len, "block/", 6)) { + if (strncmp(path1 + devdir_len, "block/", 6)) + return 1; + } else if (!strncmp(path1 + devdir_len, "block/", 6)) + return 0; + } + /* Return the path with fewer slashes */ for (p = path0; p++; p = (const char *) strchr(p, '/')) slash0++; @@ -545,6 +560,11 @@ goto bad; } + if (!(_cache.dev_dir = _strdup(cmd->dev_dir))) { + log_error("strdup dev_dir failed."); + goto bad; + } + dm_list_init(&_cache.dirs); dm_list_init(&_cache.files); From agk@sourceware.org Mon May 24 23:11:00 2010 From: agk@sourceware.org (agk@sourceware.org) Date: Mon, 24 May 2010 23:11:00 -0000 Subject: LVM2 ./WHATS_NEW lib/mirror/mirrored.c lib/mis ... Message-ID: <20100524231137.27689.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2010-05-24 23:11:36 Modified files: . : WHATS_NEW lib/mirror : mirrored.c lib/misc : util.h libdm : libdm-deptree.c Log message: Replace strncmp kernel version number checks with proper ones Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1597&r2=1.1598 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.70&r2=1.71 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/util.h.diff?cvsroot=lvm2&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.80&r2=1.81 --- LVM2/WHATS_NEW 2010/05/24 22:53:48 1.1597 +++ LVM2/WHATS_NEW 2010/05/24 23:11:34 1.1598 @@ -1,5 +1,6 @@ Version 2.02.67 - =============================== + Replace strncmp kernel version number checks with proper ones. Avoid selecting names under /dev/block if there is an alternative. Update clustered log kernel module name to log-userspace for 2.6.31 onwards. Activate only first head of Replicator for vgchange -ay. --- LVM2/lib/mirror/mirrored.c 2010/05/24 17:46:47 1.70 +++ LVM2/lib/mirror/mirrored.c 2010/05/24 23:11:35 1.71 @@ -474,6 +474,7 @@ unsigned maj2, min2, patchlevel2; char vsn[80]; struct utsname uts; + unsigned kmaj, kmin, krel; if (!_mirrored_checked) { _mirrored_present = target_present(cmd, "mirror", 1); @@ -511,8 +512,9 @@ * The dm-log-userspace module was added to the * 2.6.31 kernel. */ - /* FIXME Replace the broken string comparison! */ - if (!uname(&uts) && strncmp(uts.release, "2.6.31", 6) < 0) { + if (!uname(&uts) && + (sscanf(uts.release, "%u.%u.%u", &kmaj, &kmin, &krel) == 3) && + KERNEL_VERSION(kmaj, kmin, krel) < KERNEL_VERSION(2, 6, 31)) { if (module_present(cmd, "log-clustered")) _mirror_attributes |= MIRROR_LOG_CLUSTERED; } else if (module_present(cmd, "log-userspace")) --- LVM2/lib/misc/util.h 2008/06/23 19:04:34 1.5 +++ LVM2/lib/misc/util.h 2010/05/24 23:11:35 1.6 @@ -27,4 +27,6 @@ #define uninitialized_var(x) x = x +#define KERNEL_VERSION(major, minor, release) (((major) << 16) + ((minor) << 8) + (release)) + #endif --- LVM2/libdm/libdm-deptree.c 2010/05/24 17:46:47 1.80 +++ LVM2/libdm/libdm-deptree.c 2010/05/24 23:11:35 1.81 @@ -1540,9 +1540,9 @@ int pos = 0; char logbuf[DM_FORMAT_DEV_BUFSIZE]; const char *logtype; + unsigned kmaj, kmin, krel; - r = uname(&uts); - if (r) + if (!uname(&uts) || sscanf(uts.release, "%u.%u.%u", &kmaj, &kmin, &krel) != 3) return_0; if ((seg->flags & DM_BLOCK_ON_ERROR)) { @@ -1556,7 +1556,7 @@ * "handle_errors" by the dm-mirror module's version * number (>= 1.12) or by the kernel version (>= 2.6.22). */ - if (strncmp(uts.release, "2.6.22", 6) >= 0) + if (KERNEL_VERSION(kmaj, kmin, krel) >= KERNEL_VERSION(2, 6, 22)) handle_errors = 1; else block_on_error = 1; @@ -1575,8 +1575,7 @@ * The dm-log-userspace module was added to the * 2.6.31 kernel. */ - /* FIXME Replace the broken string comparison! */ - if (strncmp(uts.release, "2.6.31", 6) >= 0) + if (KERNEL_VERSION(kmaj, kmin, krel) >= KERNEL_VERSION(2, 6, 31)) dm_log_userspace = 1; } From zkabelac@sourceware.org Tue May 25 08:40:00 2010 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Tue, 25 May 2010 08:40:00 -0000 Subject: LVM2/libdm libdm-deptree.c Message-ID: <20100525084038.27701.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-05-25 08:40:37 Modified files: libdm : libdm-deptree.c Log message: Fix copy&paste detection of kernel release version. Add log_error to avoid return_0 without log_error. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-deptree.c.diff?cvsroot=lvm2&r1=1.81&r2=1.82 --- LVM2/libdm/libdm-deptree.c 2010/05/24 23:11:35 1.81 +++ LVM2/libdm/libdm-deptree.c 2010/05/25 08:40:36 1.82 @@ -1542,8 +1542,10 @@ const char *logtype; unsigned kmaj, kmin, krel; - if (!uname(&uts) || sscanf(uts.release, "%u.%u.%u", &kmaj, &kmin, &krel) != 3) - return_0; + if (uname(&uts) == -1 || sscanf(uts.release, "%u.%u.%u", &kmaj, &kmin, &krel) != 3) { + log_error("Cannot read kernel release version"); + return 0; + } if ((seg->flags & DM_BLOCK_ON_ERROR)) { /* From prajnoha@sourceware.org Thu May 27 15:02:00 2010 From: prajnoha@sourceware.org (prajnoha@sourceware.org) Date: Thu, 27 May 2010 15:02:00 -0000 Subject: LVM2 ./WHATS_NEW_DM libdm/libdm-common.c Message-ID: <20100527150258.3489.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: prajnoha@sourceware.org 2010-05-27 15:02:57 Modified files: . : WHATS_NEW_DM libdm : libdm-common.c Log message: Use expected union semun for arguments in selected semaphore operations. This is standard and expected use. It also prevents errors related with misalignment of the arguments for semaphore operations on some architectures. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.373&r2=1.374 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/libdm/libdm-common.c.diff?cvsroot=lvm2&r1=1.95&r2=1.96 --- LVM2/WHATS_NEW_DM 2010/05/20 23:21:53 1.373 +++ LVM2/WHATS_NEW_DM 2010/05/27 15:02:56 1.374 @@ -1,5 +1,6 @@ Version 1.02.49 - ================================ + Use expected union semun for arguments in selected semaphore operations. Version 1.02.48 - 17th May 2010 ================================ --- LVM2/libdm/libdm-common.c 2010/05/03 21:06:53 1.95 +++ LVM2/libdm/libdm-common.c 2010/05/27 15:02:56 1.96 @@ -43,6 +43,18 @@ #define DEV_DIR "/dev/" +#ifdef UDEV_SYNC_SUPPORT +#ifdef _SEM_SEMUN_UNDEFINED +union semun +{ + int val; /* value for SETVAL */ + struct semid_ds *buf; /* buffer for IPC_STAT & IPC_SET */ + unsigned short int *array; /* array for GETALL & SETALL */ + struct seminfo *__buf; /* buffer for IPC_INFO */ +}; +#endif +#endif + static char _dm_dir[PATH_MAX] = DEV_DIR DM_DIR; static int _verbose = 0; @@ -1076,6 +1088,7 @@ int gen_semid; uint16_t base_cookie; uint32_t gen_cookie; + union semun sem_arg; if ((fd = open("/dev/urandom", O_RDONLY)) < 0) { log_error("Failed to open /dev/urandom " @@ -1123,7 +1136,9 @@ log_debug("Udev cookie 0x%" PRIx32 " (semid %d) created", gen_cookie, gen_semid); - if (semctl(gen_semid, 0, SETVAL, 1) < 0) { + sem_arg.val = 1; + + if (semctl(gen_semid, 0, SETVAL, sem_arg) < 0) { log_error("semid %d: semctl failed: %s", gen_semid, strerror(errno)); /* We have to destroy just created semaphore * so it won't stay in the system. */ From snitzer@sourceware.org Thu May 27 19:00:00 2010 From: snitzer@sourceware.org (snitzer@sourceware.org) Date: Thu, 27 May 2010 19:00:00 -0000 Subject: LVM2 ./WHATS_NEW man/dmsetup.8.in Message-ID: <20100527190021.7752.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: snitzer@sourceware.org 2010-05-27 19:00:20 Modified files: . : WHATS_NEW man : dmsetup.8.in Log message: Document 'clear' in dmsetup man page. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1598&r2=1.1599 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/dmsetup.8.in.diff?cvsroot=lvm2&r1=1.34&r2=1.35 --- LVM2/WHATS_NEW 2010/05/24 23:11:34 1.1598 +++ LVM2/WHATS_NEW 2010/05/27 19:00:14 1.1599 @@ -1,5 +1,6 @@ Version 2.02.67 - =============================== + Document 'clear' in dmsetup man page. Replace strncmp kernel version number checks with proper ones. Avoid selecting names under /dev/block if there is an alternative. Update clustered log kernel module name to log-userspace for 2.6.31 onwards. --- LVM2/man/dmsetup.8.in 2010/03/09 13:42:29 1.34 +++ LVM2/man/dmsetup.8.in 2010/05/27 19:00:20 1.35 @@ -175,6 +175,10 @@ .br Display the library and kernel driver version. .SH COMMANDS +.IP \fBclear +.I device_name +.br +Destroys the table in the inactive table slot for device_name. .IP \fBcreate .I device_name [-u uuid] [--notable | --table | table_file] .br From snitzer@sourceware.org Fri May 28 03:50:00 2010 From: snitzer@sourceware.org (snitzer@sourceware.org) Date: Fri, 28 May 2010 03:50:00 -0000 Subject: LVM2 ./WHATS_NEW ./WHATS_NEW_DM man/lvcreate.8.in Message-ID: <20100528035019.20553.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: snitzer@sourceware.org 2010-05-28 03:50:19 Modified files: . : WHATS_NEW WHATS_NEW_DM man : lvcreate.8.in Log message: Add --type parameter description to the lvcreate man page. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1599&r2=1.1600 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW_DM.diff?cvsroot=lvm2&r1=1.374&r2=1.375 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvcreate.8.in.diff?cvsroot=lvm2&r1=1.17&r2=1.18 --- LVM2/WHATS_NEW 2010/05/27 19:00:14 1.1599 +++ LVM2/WHATS_NEW 2010/05/28 03:50:15 1.1600 @@ -1,6 +1,6 @@ Version 2.02.67 - =============================== - Document 'clear' in dmsetup man page. + Add --type parameter description to the lvcreate man page. Replace strncmp kernel version number checks with proper ones. Avoid selecting names under /dev/block if there is an alternative. Update clustered log kernel module name to log-userspace for 2.6.31 onwards. --- LVM2/WHATS_NEW_DM 2010/05/27 15:02:56 1.374 +++ LVM2/WHATS_NEW_DM 2010/05/28 03:50:15 1.375 @@ -1,5 +1,6 @@ Version 1.02.49 - ================================ + Document 'clear' in dmsetup man page. Use expected union semun for arguments in selected semaphore operations. Version 1.02.48 - 17th May 2010 --- LVM2/man/lvcreate.8.in 2010/03/26 22:15:43 1.17 +++ LVM2/man/lvcreate.8.in 2010/05/28 03:50:18 1.18 @@ -18,6 +18,7 @@ [\-n|\-\-name LogicalVolumeName] [\-p|\-\-permission r|rw] [\-r|\-\-readahead ReadAheadSectors|auto|none] [\-t|\-\-test] +[\-\-type SegmentType] [\-v|\-\-verbose] [\-Z|\-\-zero y|n] VolumeGroupName [PhysicalVolumePath[:PE[-PE]]...] .br @@ -183,6 +184,14 @@ rate at which the snapshot data is growing so you can avoid running out of space. .TP +.I \-\-type SegmentType +Create a logical volume that uses the specified segment type +(e.g. "mirror", "snapshot", "striped"). Especially useful when no +existing commandline switch alias enables the use of the desired type +(e.g. "error" or "zero" types). Many segment types already have a +commandline switch alias that will enable their use (-s is an alias for +--type snapshot). +.TP .I \-\-virtualsize VirtualSize Create a sparse device of the given size (in MB by default) using a snapshot. Anything written to the device will be returned when reading from it.