From mbroz@sourceware.org Fri Jan 5 15:53:00 2007 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Fri, 05 Jan 2007 15:53:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/lv_manip.c Message-ID: <20070105155341.706.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2007-01-05 15:53:41 Modified files: . : WHATS_NEW lib/metadata : lv_manip.c Log message: Fix create mirror with name longer than 22 chars. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.525&r2=1.526 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.114&r2=1.115 --- LVM2/WHATS_NEW 2006/12/20 16:19:01 1.525 +++ LVM2/WHATS_NEW 2007/01/05 15:53:40 1.526 @@ -1,5 +1,6 @@ Version 2.02.18 - ==================================== + Fix create mirror with name longer than 22 chars. Fix some activate.c prototypes when compiled without devmapper. Fix dmeventd mirror to cope if monitored device disappears. --- LVM2/lib/metadata/lv_manip.c 2006/12/13 03:39:58 1.114 +++ LVM2/lib/metadata/lv_manip.c 2007/01/05 15:53:40 1.115 @@ -1493,7 +1493,7 @@ struct cmd_context *cmd = vg->cmd; struct lv_list *ll = NULL; struct logical_volume *lv; - char dname[32]; + char dname[NAME_LEN]; if (vg->max_lv && (vg->max_lv == vg->lv_count)) { log_error("Maximum number of logical volumes (%u) reached " From agk@sourceware.org Mon Jan 8 14:24:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Mon, 08 Jan 2007 14:24:00 -0000 Subject: LVM2 ./WHATS_NEW dmeventd/mirror/dmeventd_mirr ... Message-ID: <20070108142421.11203.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-08 14:24:20 Modified files: . : WHATS_NEW dmeventd/mirror: dmeventd_mirror.c tools : lvmcmdlib.c Log message: Add dmeventd_mirror register_mutex, tidy initialisation & add memlock. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.526&r2=1.527 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/dmeventd/mirror/dmeventd_mirror.c.diff?cvsroot=lvm2&r1=1.9&r2=1.10 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdlib.c.diff?cvsroot=lvm2&r1=1.2&r2=1.3 --- LVM2/WHATS_NEW 2007/01/05 15:53:40 1.526 +++ LVM2/WHATS_NEW 2007/01/08 14:24:20 1.527 @@ -1,5 +1,6 @@ Version 2.02.18 - ==================================== + Add dmeventd_mirror register_mutex, tidy initialisation & add memlock. Fix create mirror with name longer than 22 chars. Fix some activate.c prototypes when compiled without devmapper. Fix dmeventd mirror to cope if monitored device disappears. --- LVM2/dmeventd/mirror/dmeventd_mirror.c 2006/12/20 14:34:05 1.9 +++ LVM2/dmeventd/mirror/dmeventd_mirror.c 2007/01/08 14:24:20 1.10 @@ -32,19 +32,30 @@ #define ME_INSYNC 1 #define ME_FAILURE 2 -static pthread_mutex_t _lock = PTHREAD_MUTEX_INITIALIZER; - -/* FIXME: We may need to lock around operations to these */ +/* + * register_device() is called first and performs initialisation. + * Only one device may be registered or unregistered at a time. + */ +static pthread_mutex_t _register_mutex = PTHREAD_MUTEX_INITIALIZER; + +/* + * Number of active registrations. + */ static int _register_count = 0; -/* FIXME Unsafe static? */ static struct dm_pool *_mem_pool = NULL; +static void *_lvm_handle = NULL; + +/* + * Currently only one event can be processed at a time. + */ +static pthread_mutex_t _event_mutex = PTHREAD_MUTEX_INITIALIZER; static int _get_mirror_event(char *params) { int i, r = ME_INSYNC; -#define MAX_ARGS 30; /* should support at least 8-way mirrors */ +#define MAX_ARGS 30 /* should support at least 8-way mirrors */ /* FIXME Remove unnecessary limit. It tells you how many devices there are - use it! */ char *args[MAX_ARGS]; @@ -122,7 +133,6 @@ static int _remove_failed_devices(const char *device) { int r; - void *handle; #define CMD_SIZE 256 /* FIXME Use system restriction */ char cmd_str[CMD_SIZE]; char *vg = NULL, *lv = NULL, *layer = NULL; @@ -144,10 +154,7 @@ return -ENAMETOOLONG; /* FIXME Replace with generic error return - reason for failure has already got logged */ } - lvm2_log_fn(_temporary_log_fn); - handle = lvm2_init(); - lvm2_log_level(handle, 1); - r = lvm2_run(handle, cmd_str); + r = lvm2_run(_lvm_handle, cmd_str); dm_pool_empty(_mem_pool); /* FIXME: not safe with multiple threads */ return (r == 1) ? 0 : -1; @@ -161,9 +168,9 @@ char *target_type = NULL; char *params; - if (pthread_mutex_trylock(&_lock)) { + if (pthread_mutex_trylock(&_event_mutex)) { syslog(LOG_NOTICE, "Another thread is handling an event. Waiting..."); - pthread_mutex_lock(&_lock); + pthread_mutex_lock(&_event_mutex); } /* FIXME Move inside libdevmapper */ if (!(dmt = dm_task_create(DM_DEVICE_STATUS))) { @@ -185,9 +192,10 @@ next = dm_get_next_target(dmt, next, &start, &length, &target_type, ¶ms); - if (!target_type) + if (!target_type) { syslog(LOG_INFO, "%s mapping lost.\n", device); continue; + } if (strcmp(target_type, "mirror")) { syslog(LOG_INFO, "%s has unmirrored portion.\n", device); @@ -225,11 +233,15 @@ fail: if (dmt) dm_task_destroy(dmt); - pthread_mutex_unlock(&_lock); + pthread_mutex_unlock(&_event_mutex); } int register_device(const char *device) { + int r = 0; + + pthread_mutex_lock(&_register_mutex); + syslog(LOG_INFO, "Monitoring mirror device, %s for events\n", device); /* @@ -237,19 +249,42 @@ * than enough for what we need (device mapper name splitting) */ if (!_mem_pool && !(_mem_pool = dm_pool_create("mirror_dso", 1024))) - return 0; + goto out; + + if (!_lvm_handle) { + lvm2_log_fn(_temporary_log_fn); + if (!(_lvm_handle = lvm2_init())) { + dm_pool_destroy(_mem_pool); + _mem_pool = NULL; + goto out; + } + lvm2_log_level(_lvm_handle, LVM2_LOG_SUPPRESS); + /* FIXME Temporary: move to dmeventd core */ + lvm2_run(_lvm_handle, "_memlock_inc"); + } _register_count++; + r = 1; + +out: + pthread_mutex_unlock(&_register_mutex); - return 1; + return r; } int unregister_device(const char *device) { + pthread_mutex_lock(&_register_mutex); + if (!--_register_count) { dm_pool_destroy(_mem_pool); _mem_pool = NULL; + lvm2_run(_lvm_handle, "_memlock_dec"); + lvm2_exit(_lvm_handle); + _lvm_handle = NULL; } - return 1; + pthread_mutex_unlock(&_register_mutex); + + return 1; } --- LVM2/tools/lvmcmdlib.c 2006/08/22 15:56:06 1.2 +++ LVM2/tools/lvmcmdlib.c 2007/01/08 14:24:20 1.3 @@ -77,7 +77,13 @@ goto out; } - ret = lvm_run_command(cmd, argc, argv); + /* FIXME Temporary - move to libdevmapper */ + if (!strcmp(cmdline, "_memlock_inc")) + memlock_inc(); + if (!strcmp(cmdline, "_memlock_dec")) + memlock_dec(); + else + ret = lvm_run_command(cmd, argc, argv); out: dm_free(cmdcopy); From agk@sourceware.org Tue Jan 9 20:31:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 09 Jan 2007 20:31:00 -0000 Subject: LVM2 ./WHATS_NEW ./configure ./configure.in ./ ... Message-ID: <20070109203109.7120.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-09 20:31:08 Modified files: . : WHATS_NEW configure configure.in make.tmpl.in lib/activate : dev_manager.c Log message: Add configure --with-dmdir to compile against a device-mapper source tree. Use no flush suspending for mirrors. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.527&r2=1.528 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.diff?cvsroot=lvm2&r1=1.55&r2=1.56 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.in.diff?cvsroot=lvm2&r1=1.54&r2=1.55 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/make.tmpl.in.diff?cvsroot=lvm2&r1=1.45&r2=1.46 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.117&r2=1.118 --- LVM2/WHATS_NEW 2007/01/08 14:24:20 1.527 +++ LVM2/WHATS_NEW 2007/01/09 20:31:08 1.528 @@ -1,5 +1,7 @@ Version 2.02.18 - ==================================== + Add configure --with-dmdir to compile against a device-mapper source tree. + Use no flush suspending for mirrors. Add dmeventd_mirror register_mutex, tidy initialisation & add memlock. Fix create mirror with name longer than 22 chars. Fix some activate.c prototypes when compiled without devmapper. --- LVM2/configure 2006/11/20 20:03:26 1.55 +++ LVM2/configure 2007/01/09 20:31:08 1.56 @@ -310,7 +310,7 @@ #endif" ac_default_prefix=/usr -ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os AWK CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN_S SET_MAKE RANLIB ac_ct_RANLIB CFLOW_CMD CSCOPE_CMD CPP EGREP ALLOCA LIBOBJS POW_LIB MSGFMT MODPROBE_CMD JOBS STATIC_LINK LVM1 POOL SNAPSHOTS MIRRORS OWNER GROUP COPTIMISE_FLAG CLDFLAGS CLDWHOLEARCHIVE CLDNOWHOLEARCHIVE LDDEPS LIB_SUFFIX LVM_VERSION LVM1_FALLBACK DEBUG DEVMAPPER HAVE_LIBDL HAVE_SELINUX HAVE_REALTIME CMDLIB LOCALEDIR CONFDIR STATICDIR INTL_PACKAGE INTL CLVMD CLUSTER FSADM DMEVENTD LTLIBOBJS' +ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os AWK CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN_S SET_MAKE RANLIB ac_ct_RANLIB CFLOW_CMD CSCOPE_CMD CPP EGREP ALLOCA LIBOBJS POW_LIB MSGFMT MODPROBE_CMD JOBS STATIC_LINK LVM1 POOL SNAPSHOTS MIRRORS OWNER GROUP COPTIMISE_FLAG CLDFLAGS CLDWHOLEARCHIVE CLDNOWHOLEARCHIVE LDDEPS LIB_SUFFIX LVM_VERSION LVM1_FALLBACK DEBUG DEVMAPPER HAVE_LIBDL HAVE_SELINUX HAVE_REALTIME CMDLIB LOCALEDIR CONFDIR STATICDIR DMDIR INTL_PACKAGE INTL CLVMD CLUSTER FSADM DMEVENTD LTLIBOBJS' ac_subst_files='' # Initialize some variables set by options. @@ -883,6 +883,7 @@ --with-localedir=DIR Translation files in DIR PREFIX/share/locale --with-confdir=DIR Configuration files in DIR /etc --with-staticdir=DIR Static binary in DIR EXEC_PREFIX/sbin + --with-dmdir=DIR Build against device-mapper source tree in DIR Some influential environment variables: CC C compiler command @@ -8964,6 +8965,15 @@ STATICDIR='${exec_prefix}/sbin' fi; + +# Check whether --with-dmdir or --without-dmdir was given. +if test "${with_dmdir+set}" = set; then + withval="$with_dmdir" + DMDIR="$withval" +else + DMDIR= +fi; + ################################################################################ if test x$READLINE = xyes; then @@ -11202,6 +11212,7 @@ + ################################################################################ ac_config_files="$ac_config_files Makefile make.tmpl daemons/Makefile daemons/clvmd/Makefile dmeventd/Makefile dmeventd/mirror/Makefile doc/Makefile include/Makefile lib/Makefile lib/format1/Makefile lib/format_pool/Makefile lib/locking/Makefile lib/mirror/Makefile lib/snapshot/Makefile man/Makefile po/Makefile scripts/Makefile tools/Makefile tools/version.h tools/fsadm/Makefile test/mm/Makefile test/device/Makefile test/format1/Makefile test/regex/Makefile test/filters/Makefile" cat >confcache <<\_ACEOF @@ -11900,6 +11911,7 @@ s,@LOCALEDIR@,$LOCALEDIR,;t t s,@CONFDIR@,$CONFDIR,;t t s,@STATICDIR@,$STATICDIR,;t t +s,@DMDIR@,$DMDIR,;t t s,@INTL_PACKAGE@,$INTL_PACKAGE,;t t s,@INTL@,$INTL,;t t s,@CLVMD@,$CLVMD,;t t --- LVM2/configure.in 2006/11/20 20:03:26 1.54 +++ LVM2/configure.in 2007/01/09 20:31:08 1.55 @@ -526,6 +526,11 @@ [ STATICDIR="$withval" ], [ STATICDIR='${exec_prefix}/sbin' ]) +AC_ARG_WITH(dmdir, + [ --with-dmdir=DIR Build against device-mapper source tree in DIR], + [ DMDIR="$withval" ], + [ DMDIR= ]) + ################################################################################ dnl -- Ensure additional headers required if test x$READLINE = xyes; then @@ -608,6 +613,7 @@ AC_SUBST(LOCALEDIR) AC_SUBST(CONFDIR) AC_SUBST(STATICDIR) +AC_SUBST(DMDIR) AC_SUBST(INTL_PACKAGE) AC_SUBST(INTL) AC_SUBST(CLVMD) --- LVM2/make.tmpl.in 2006/05/16 20:53:13 1.45 +++ LVM2/make.tmpl.in 2007/01/09 20:31:08 1.46 @@ -73,6 +73,10 @@ DEFS += -DINTL_PACKAGE=\"@INTL_PACKAGE@\" -DLOCALEDIR=\"@LOCALEDIR@\" endif +ifneq ("@DMDIR@", "") + LDFLAGS += -L@DMDIR@/lib/ioctl +endif + LDFLAGS += -L$(top_srcdir)/lib -L$(libdir) #DEFS += -DDEBUG_POOL @@ -89,6 +93,10 @@ INCLUDES += -I. -I$(top_srcdir)/include +ifneq ("@DMDIR@", "") + INCLUDES += -I@DMDIR@/include +endif + ifdef DESTDIR INCLUDES += -I$(DESTDIR)/usr/include endif --- LVM2/lib/activate/dev_manager.c 2006/11/30 23:11:39 1.117 +++ LVM2/lib/activate/dev_manager.c 2007/01/09 20:31:08 1.118 @@ -993,6 +993,8 @@ break; case SUSPEND: dm_tree_skip_lockfs(root); + if ((lv->status & MIRRORED) && !(lv->status & PVMOVE)) + dm_tree_use_no_flush_suspend(root); case SUSPEND_WITH_LOCKFS: if (!dm_tree_suspend_children(root, dlid, ID_LEN + sizeof(UUID_PREFIX) - 1)) goto_out; From agk@sourceware.org Tue Jan 9 21:12:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 09 Jan 2007 21:12:00 -0000 Subject: LVM2 ./WHATS_NEW lib/format_text/format-text.c ... Message-ID: <20070109211242.18959.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-09 21:12:41 Modified files: . : WHATS_NEW lib/format_text: format-text.c man : lvextend.8 tools : vgsplit.c Log message: Free memory in _raw_read_mda_header() error paths. Fix ambiguous vgsplit error message for split LV. Fix lvextend man page typo. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.528&r2=1.529 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.70&r2=1.71 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvextend.8.diff?cvsroot=lvm2&r1=1.8&r2=1.9 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.20&r2=1.21 --- LVM2/WHATS_NEW 2007/01/09 20:31:08 1.528 +++ LVM2/WHATS_NEW 2007/01/09 21:12:40 1.529 @@ -1,5 +1,8 @@ Version 2.02.18 - ==================================== + Free memory in _raw_read_mda_header() error paths. + Fix ambiguous vgsplit error message for split LV. + Fix lvextend man page typo. Add configure --with-dmdir to compile against a device-mapper source tree. Use no flush suspending for mirrors. Add dmeventd_mirror register_mutex, tidy initialisation & add memlock. --- LVM2/lib/format_text/format-text.c 2006/11/30 23:11:41 1.70 +++ LVM2/lib/format_text/format-text.c 2007/01/09 21:12:41 1.71 @@ -132,37 +132,40 @@ if (!dev_read(dev_area->dev, dev_area->start, MDA_HEADER_SIZE, mdah)) { stack; - dm_pool_free(fmt->cmd->mem, mdah); - return NULL; + goto error; } if (mdah->checksum_xl != xlate32(calc_crc(INITIAL_CRC, mdah->magic, MDA_HEADER_SIZE - sizeof(mdah->checksum_xl)))) { log_error("Incorrect metadata area header checksum"); - return NULL; + goto error; } _xlate_mdah(mdah); if (strncmp((char *)mdah->magic, FMTT_MAGIC, sizeof(mdah->magic))) { log_error("Wrong magic number in metadata area header"); - return NULL; + goto error; } if (mdah->version != FMTT_VERSION) { log_error("Incompatible metadata area header version: %d", mdah->version); - return NULL; + goto error; } if (mdah->start != dev_area->start) { log_error("Incorrect start sector in metadata area header: %" PRIu64, mdah->start); - return NULL; + goto error; } return mdah; + +error: + dm_pool_free(fmt->cmd->mem, mdah); + return NULL; } static int _raw_write_mda_header(const struct format_type *fmt, --- LVM2/man/lvextend.8 2006/11/10 18:24:11 1.8 +++ LVM2/man/lvextend.8 2007/01/09 21:12:41 1.9 @@ -31,7 +31,7 @@ free space in the Volume Group with the suffix %FREE. .TP .I \-L, \-\-size [+]LogicalVolumeSize[kKmMgGtTpPeE] -Extend or set the logical volume size in units in units of megabytes. +Extend or set the logical volume size in units of megabytes. A size suffix of M for megabytes, G for gigabytes, T for terabytes, P for petabytes or E for exabytes is optional. --- LVM2/tools/vgsplit.c 2006/10/13 13:22:44 1.20 +++ LVM2/tools/vgsplit.c 2007/01/09 21:12:41 1.21 @@ -84,9 +84,9 @@ pv = seg_pv(seg, s); if (vg_with) { if (!pv_is_in_vg(vg_with, pv)) { - log_error("Logical Volume %s " - "split between " - "Volume Groups", + log_error("Can't split Logical " + "Volume %s between " + "two Volume Groups", lv->name); return 0; } From agk@sourceware.org Tue Jan 9 22:07:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 09 Jan 2007 22:07:00 -0000 Subject: LVM2 WHATS_NEW configure configure.in Message-ID: <20070109220721.21366.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-09 22:07:20 Modified files: . : WHATS_NEW configure configure.in Log message: Remove 3 redundant AC_MSG_RESULTs from configure.in. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.529&r2=1.530 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.diff?cvsroot=lvm2&r1=1.56&r2=1.57 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.in.diff?cvsroot=lvm2&r1=1.55&r2=1.56 --- LVM2/WHATS_NEW 2007/01/09 21:12:40 1.529 +++ LVM2/WHATS_NEW 2007/01/09 22:07:20 1.530 @@ -1,5 +1,6 @@ Version 2.02.18 - ==================================== + Remove 3 redundant AC_MSG_RESULTs from configure.in. Free memory in _raw_read_mda_header() error paths. Fix ambiguous vgsplit error message for split LV. Fix lvextend man page typo. --- LVM2/configure 2007/01/09 20:31:08 1.56 +++ LVM2/configure 2007/01/09 22:07:20 1.57 @@ -8268,8 +8268,6 @@ ################################################################################ if test x$SELINUX = xyes; then - echo "$as_me:$LINENO: checking for sepol_check_context function" >&5 -echo $ECHO_N "checking for sepol_check_context function... $ECHO_C" >&6 echo "$as_me:$LINENO: checking for sepol_check_context in -lsepol" >&5 echo $ECHO_N "checking for sepol_check_context in -lsepol... $ECHO_C" >&6 if test "${ac_cv_lib_sepol_sepol_check_context+set}" = set; then @@ -8340,15 +8338,11 @@ HAVE_SEPOL=no fi - echo "$as_me:$LINENO: result: $HAVE_SEPOL" >&5 -echo "${ECHO_T}$HAVE_SEPOL" >&6 if test x$HAVE_SEPOL = xyes; then LIBS="-lsepol $LIBS" fi - echo "$as_me:$LINENO: checking for is_selinux_enabled function" >&5 -echo $ECHO_N "checking for is_selinux_enabled function... $ECHO_C" >&6 echo "$as_me:$LINENO: checking for is_selinux_enabled in -lselinux" >&5 echo $ECHO_N "checking for is_selinux_enabled in -lselinux... $ECHO_C" >&6 if test "${ac_cv_lib_selinux_is_selinux_enabled+set}" = set; then @@ -8419,8 +8413,6 @@ HAVE_SELINUX=no fi - echo "$as_me:$LINENO: result: $HAVE_SELINUX" >&5 -echo "${ECHO_T}$HAVE_SELINUX" >&6 if test x$HAVE_SELINUX = xyes; then @@ -8437,8 +8429,6 @@ ################################################################################ if test x$REALTIME = xyes; then - echo "$as_me:$LINENO: checking for clock_gettime function" >&5 -echo $ECHO_N "checking for clock_gettime function... $ECHO_C" >&6 echo "$as_me:$LINENO: checking for clock_gettime in -lrt" >&5 echo $ECHO_N "checking for clock_gettime in -lrt... $ECHO_C" >&6 if test "${ac_cv_lib_rt_clock_gettime+set}" = set; then @@ -8509,8 +8499,6 @@ HAVE_REALTIME=no fi - echo "$as_me:$LINENO: result: $HAVE_REALTIME" >&5 -echo "${ECHO_T}$HAVE_REALTIME" >&6 if test x$HAVE_REALTIME = xyes; then --- LVM2/configure.in 2007/01/09 20:31:08 1.55 +++ LVM2/configure.in 2007/01/09 22:07:20 1.56 @@ -438,17 +438,13 @@ ################################################################################ dnl -- Check for selinux if test x$SELINUX = xyes; then - AC_MSG_CHECKING(for sepol_check_context function) AC_CHECK_LIB(sepol, sepol_check_context, HAVE_SEPOL=yes, HAVE_SEPOL=no) - AC_MSG_RESULT($HAVE_SEPOL) if test x$HAVE_SEPOL = xyes; then LIBS="-lsepol $LIBS" fi - AC_MSG_CHECKING(for is_selinux_enabled function) AC_CHECK_LIB(selinux, is_selinux_enabled, HAVE_SELINUX=yes, HAVE_SELINUX=no) - AC_MSG_RESULT($HAVE_SELINUX) if test x$HAVE_SELINUX = xyes; then AC_DEFINE([HAVE_SELINUX], 1, [Define to 1 to include support for selinux.]) @@ -461,9 +457,7 @@ ################################################################################ dnl -- Check for realtime clock support if test x$REALTIME = xyes; then - AC_MSG_CHECKING(for clock_gettime function) AC_CHECK_LIB(rt, clock_gettime, HAVE_REALTIME=yes, HAVE_REALTIME=no) - AC_MSG_RESULT($HAVE_REALTIME) if test x$HAVE_REALTIME = xyes; then AC_DEFINE([HAVE_REALTIME], 1, [Define to 1 to include support for realtime clock.]) From agk@sourceware.org Tue Jan 9 23:14:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 09 Jan 2007 23:14:00 -0000 Subject: LVM2 tools/vgreduce.c ./WHATS_NEW Message-ID: <20070109231435.11073.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-09 23:14:35 Modified files: tools : vgreduce.c . : WHATS_NEW Log message: Avoid vgreduce error when mirror code removes the log LV. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgreduce.c.diff?cvsroot=lvm2&r1=1.54&r2=1.55 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.530&r2=1.531 --- LVM2/tools/vgreduce.c 2006/11/30 23:11:42 1.54 +++ LVM2/tools/vgreduce.c 2007/01/09 23:14:34 1.55 @@ -347,7 +347,9 @@ list_iterate_items(lvl, &lvs_changed) { log_verbose("Removing LV %s from VG %s", lvl->lv->name, lvl->lv->vg->name); - if (!lv_remove(lvl->lv)) { + /* Skip LVs already removed by mirror code */ + if (find_lv_in_vg(vg, lvl->lv->name) && + !lv_remove(lvl->lv)) { stack; return 0; } --- LVM2/WHATS_NEW 2007/01/09 22:07:20 1.530 +++ LVM2/WHATS_NEW 2007/01/09 23:14:35 1.531 @@ -1,5 +1,6 @@ Version 2.02.18 - ==================================== + Avoid vgreduce error when mirror code removes the log LV. Remove 3 redundant AC_MSG_RESULTs from configure.in. Free memory in _raw_read_mda_header() error paths. Fix ambiguous vgsplit error message for split LV. From agk@sourceware.org Tue Jan 9 23:22:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 09 Jan 2007 23:22:00 -0000 Subject: LVM2 ./WHATS_NEW lib/config/config.c lib/confi ... Message-ID: <20070109232232.17425.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-09 23:22:32 Modified files: . : WHATS_NEW lib/config : config.c config.h tools : commands.h dumpconfig.c Log message: dumpconfig accepts a list of configuration variables to display. Change dumpconfig to use --file to redirect output to a file. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.531&r2=1.532 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/config.c.diff?cvsroot=lvm2&r1=1.50&r2=1.51 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/config.h.diff?cvsroot=lvm2&r1=1.21&r2=1.22 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/commands.h.diff?cvsroot=lvm2&r1=1.92&r2=1.93 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/dumpconfig.c.diff?cvsroot=lvm2&r1=1.4&r2=1.5 --- LVM2/WHATS_NEW 2007/01/09 23:14:35 1.531 +++ LVM2/WHATS_NEW 2007/01/09 23:22:31 1.532 @@ -1,5 +1,7 @@ Version 2.02.18 - ==================================== + dumpconfig accepts a list of configuration variables to display. + Change dumpconfig to use --file to redirect output to a file. Avoid vgreduce error when mirror code removes the log LV. Remove 3 redundant AC_MSG_RESULTs from configure.in. Free memory in _raw_read_mda_header() error paths. --- LVM2/lib/config/config.c 2006/11/21 15:13:36 1.50 +++ LVM2/lib/config/config.c 2007/01/09 23:22:31 1.51 @@ -373,7 +373,8 @@ } } -static int _write_config(struct config_node *n, FILE *fp, int level) +static int _write_config(struct config_node *n, int only_one, FILE *fp, + int level) { char space[MAX_INDENT + 1]; int l = (level < MAX_INDENT) ? level : MAX_INDENT; @@ -386,12 +387,12 @@ space[i] = '\t'; space[i] = '\0'; - while (n) { + do { fprintf(fp, "%s%s", space, n->key); if (!n->v) { /* it's a sub section */ fprintf(fp, " {\n"); - _write_config(n->child, fp, level + 1); + _write_config(n->child, 0, fp, level + 1); fprintf(fp, "%s}", space); } else { /* it's a value */ @@ -411,13 +412,15 @@ } fprintf(fp, "\n"); n = n->sib; - } + } while (n && !only_one); /* FIXME: add error checking */ return 1; } -int write_config_file(struct config_tree *cft, const char *file) +int write_config_file(struct config_tree *cft, const char *file, + int argc, char **argv) { + struct config_node *cn; int r = 1; FILE *fp; @@ -430,9 +433,22 @@ } log_verbose("Dumping configuration to %s", file); - if (!_write_config(cft->root, fp, 0)) { - log_error("Failure while writing configuration"); - r = 0; + if (!argc) { + if (!_write_config(cft->root, 0, fp, 0)) { + log_error("Failure while writing configuration"); + r = 0; + } + } else while (argc--) { + if ((cn = find_config_node(cft->root, *argv))) { + if (!_write_config(cn, 1, fp, 0)) { + log_error("Failure while writing configuration"); + r = 0; + } + } else { + log_error("Configuration node %s not found", *argv); + r = 0; + } + argv++; } if (fp != stdout) --- LVM2/lib/config/config.h 2006/11/04 03:34:09 1.21 +++ LVM2/lib/config/config.h 2007/01/09 23:22:31 1.22 @@ -65,7 +65,8 @@ checksum_fn_t checksum_fn, uint32_t checksum); int read_config_file(struct config_tree *cft); -int write_config_file(struct config_tree *cft, const char *file); +int write_config_file(struct config_tree *cft, const char *file, + int argc, char **argv); time_t config_file_timestamp(struct config_tree *cft); int config_file_changed(struct config_tree *cft); int merge_config_tree(struct cmd_context *cmd, struct config_tree *cft, --- LVM2/tools/commands.h 2006/11/10 18:24:11 1.92 +++ LVM2/tools/commands.h 2007/01/09 23:22:31 1.93 @@ -30,7 +30,10 @@ xx(dumpconfig, "Dump active configuration", - "dumpconfig \n") + "dumpconfig " + "\t[-f|--file filename] " "\n" + "[ConfigurationVariable...]\n", + file_ARG) xx(formats, "List available metadata formats", --- LVM2/tools/dumpconfig.c 2004/03/30 19:35:42 1.4 +++ LVM2/tools/dumpconfig.c 2007/01/09 23:22:31 1.5 @@ -19,15 +19,10 @@ { const char *file = NULL; - if (argc == 1) - file = argv[0]; + if (arg_count(cmd, file_ARG)) + file = arg_str_value(cmd, file_ARG, ""); - if (argc > 1) { - log_error("Please specify one file for output"); - return EINVALID_CMD_LINE; - } - - if (!write_config_file(cmd->cft, file)) + if (!write_config_file(cmd->cft, file, argc, argv)) return ECMD_FAILED; return ECMD_PROCESSED; From mbroz@sourceware.org Wed Jan 10 14:13:00 2007 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Wed, 10 Jan 2007 14:13:00 -0000 Subject: LVM2 ./WHATS_NEW man/lvconvert.8 man/lvcreate. ... Message-ID: <20070110141348.28867.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2007-01-10 14:13:46 Modified files: . : WHATS_NEW man : lvconvert.8 lvcreate.8 tools : lvconvert.c lvcreate.c Log message: Print warning instead of error message if cannot zero volume Update lvconvert man page (snapshot option) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.532&r2=1.533 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvconvert.8.diff?cvsroot=lvm2&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvcreate.8.diff?cvsroot=lvm2&r1=1.13&r2=1.14 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.24&r2=1.25 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.131&r2=1.132 --- LVM2/WHATS_NEW 2007/01/09 23:22:31 1.532 +++ LVM2/WHATS_NEW 2007/01/10 14:13:46 1.533 @@ -1,5 +1,7 @@ Version 2.02.18 - ==================================== + Print warning instead of error message if cannot zero volume + Update lvconvert man page (snapshot option) dumpconfig accepts a list of configuration variables to display. Change dumpconfig to use --file to redirect output to a file. Avoid vgreduce error when mirror code removes the log LV. --- LVM2/man/lvconvert.8 2006/10/07 10:47:05 1.3 +++ LVM2/man/lvconvert.8 2007/01/10 14:13:46 1.4 @@ -1,20 +1,35 @@ .TH LVCONVERT 8 "LVM TOOLS" "Red Hat, Inc" \" -*- nroff -*- .SH NAME -lvconvert \- convert a logical volume between linear and mirror +lvconvert \- convert a logical volume from linear to mirror or snapshot .SH SYNOPSIS .B lvconvert -[\-m/\-\-mirrors Mirrors [\-\-corelog] [\-R/\-\-regionsize MirrorLogRegionSize]] +\-m/\-\-mirrors Mirrors [\-\-corelog] [\-R/\-\-regionsize MirrorLogRegionSize] [\-A/\-\-alloc AllocationPolicy] [\-h/\-?/\-\-help] [\-v/\-\-verbose] [\-\-version] +.br LogicalVolume[Path] [PhysicalVolume[Path]...] +.br + +.br +.B lvconvert +\-s/\-\-snapshot [\-c/\-\-chunksize ChunkSize] +[\-h/\-?/\-\-help] +[\-v/\-\-verbose] +[\-Z/\-\-zero y/n] +[\-\-version] +.br +OriginalLogicalVolume[Path] SnapshotLogicalVolume[Path] .SH DESCRIPTION lvconvert will change a linear logical volume to a mirror -logical volume or vis versa. It is also used to add and -remove disk logs from mirror devices. +logical volume or to a snapshot of linear volume and vice versa. +It is also used to add and remove disk logs from mirror devices. .SH OPTIONS See \fBlvm\fP for common options. +.br +Exactly one of \-\-mirrors or \-\-snapshot arguments required. +.br .TP .I \-m, \-\-mirrors Mirrors Specifies the degree of the mirror you wish to create. @@ -32,6 +47,19 @@ .I \-R, \-\-regionsize MirrorLogRegionSize A mirror is divided into regions of this size (in MB), and the mirror log uses this granularity to track which regions are in sync. +.br +.TP +.I \-s, \-\-snapshot +Create a snapshot from existing logical volume using another +existing logical volume as its origin. +.TP +.I \-c, \-\-chunksize ChunkSize +Power of 2 chunk size for the snapshot logical volume between 4k and 512k. +.TP +.I \-Z, \-\-zero y/n +Controls zeroing of the first KB of data in the snapshot. +If the volume is read only snapshot will not be zeroed. +.br .SH Examples "lvconvert -m1 vg00/lvol1" .br @@ -49,6 +77,12 @@ .br converts a mirror logical volume to a linear logical volume. +.br + +.br +"lvconvert -s vg00/lvol1 vg00/lvol2" +.br +converts logical volume "vg00/lvol2" to snapshot of original volume "vg00/lvol1" .SH SEE ALSO .BR lvm (8), --- LVM2/man/lvcreate.8 2006/11/10 18:24:11 1.13 +++ LVM2/man/lvcreate.8 2007/01/10 14:13:46 1.14 @@ -139,6 +139,10 @@ Controls zeroing of the first KB of data in the new logical volume. .br Default is yes. +.br +Volume will not be zeroed if read only flag is set. +.br +Snapshot volumes are zeroed always. .br Warning: trying to mount an unzeroed logical volume can cause the system to --- LVM2/tools/lvconvert.c 2006/12/13 03:39:58 1.24 +++ LVM2/tools/lvconvert.c 2007/01/10 14:13:46 1.25 @@ -446,8 +446,8 @@ return 0; } - if (!lp->zero) - log_error("WARNING: \"%s\" not zeroed", lv->name); + if (!lp->zero || !(lv->status & LVM_WRITE)) + log_print("WARNING: \"%s\" not zeroed", lv->name); else if (!set_lv(cmd, lv, 0, 0)) { log_error("Aborting. Failed to wipe snapshot " "exception store."); --- LVM2/tools/lvcreate.c 2006/11/10 18:24:11 1.131 +++ LVM2/tools/lvcreate.c 2007/01/10 14:13:46 1.132 @@ -434,6 +434,10 @@ else lp->permission = LVM_READ | LVM_WRITE; + /* Must not zero read only volume */ + if (!(lp->permission & LVM_WRITE)) + lp->zero = 0; + lp->minor = arg_int_value(cmd, minor_ARG, -1); lp->major = arg_int_value(cmd, major_ARG, -1); From agk@sourceware.org Wed Jan 10 19:56:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 10 Jan 2007 19:56:00 -0000 Subject: LVM2 ./WHATS_NEW man/lvconvert.8 tools/lvchange.c Message-ID: <20070110195639.20093.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-10 19:56:39 Modified files: . : WHATS_NEW man : lvconvert.8 tools : lvchange.c Log message: Prevent permission changes on active mirrors. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.533&r2=1.534 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvconvert.8.diff?cvsroot=lvm2&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvchange.c.diff?cvsroot=lvm2&r1=1.74&r2=1.75 --- LVM2/WHATS_NEW 2007/01/10 14:13:46 1.533 +++ LVM2/WHATS_NEW 2007/01/10 19:56:38 1.534 @@ -1,7 +1,8 @@ Version 2.02.18 - ==================================== - Print warning instead of error message if cannot zero volume - Update lvconvert man page (snapshot option) + Prevent permission changes on active mirrors. + Print warning instead of error message if lvconvert cannot zero volume. + Add snapshot options to lvconvert man page. dumpconfig accepts a list of configuration variables to display. Change dumpconfig to use --file to redirect output to a file. Avoid vgreduce error when mirror code removes the log LV. --- LVM2/man/lvconvert.8 2007/01/10 14:13:46 1.4 +++ LVM2/man/lvconvert.8 2007/01/10 19:56:38 1.5 @@ -58,7 +58,7 @@ .TP .I \-Z, \-\-zero y/n Controls zeroing of the first KB of data in the snapshot. -If the volume is read only snapshot will not be zeroed. +If the volume is read-only the snapshot will not be zeroed. .br .SH Examples "lvconvert -m1 vg00/lvol1" --- LVM2/tools/lvchange.c 2006/11/03 21:07:15 1.74 +++ LVM2/tools/lvchange.c 2007/01/10 19:56:39 1.75 @@ -19,6 +19,7 @@ struct logical_volume *lv) { uint32_t lv_access; + struct lvinfo info; lv_access = arg_uint_value(cmd, permission_ARG, 0); @@ -34,6 +35,13 @@ return 0; } + if ((lv->status & MIRRORED) && (lv->vg->status & CLUSTERED) && + lv_info(cmd, lv, &info, 0) && info.exists) { + log_error("Cannot change permissions of mirror \"%s\" " + "while active.", lv->name); + return 0; + } + if (lv_access & LVM_WRITE) { lv->status |= LVM_WRITE; log_verbose("Setting logical volume \"%s\" read/write", From agk@sourceware.org Thu Jan 11 17:12:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 11 Jan 2007 17:12:00 -0000 Subject: LVM2 ./WHATS_NEW ./make.tmpl.in daemons/clvmd/ ... Message-ID: <20070111171228.18295.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-11 17:12:27 Modified files: . : WHATS_NEW make.tmpl.in daemons/clvmd : Makefile.in tools : Makefile.in tools/fsadm : Makefile.in Log message: Use CFLAGS when linking so mixed sparc builds can supply -m64 Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.534&r2=1.535 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/make.tmpl.in.diff?cvsroot=lvm2&r1=1.46&r2=1.47 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/Makefile.in.diff?cvsroot=lvm2&r1=1.16&r2=1.17 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/Makefile.in.diff?cvsroot=lvm2&r1=1.77&r2=1.78 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/fsadm/Makefile.in.diff?cvsroot=lvm2&r1=1.1&r2=1.2 --- LVM2/WHATS_NEW 2007/01/10 19:56:38 1.534 +++ LVM2/WHATS_NEW 2007/01/11 17:12:26 1.535 @@ -1,5 +1,6 @@ Version 2.02.18 - ==================================== + Use CFLAGS when linking so mixed sparc builds can supply -m64. Prevent permission changes on active mirrors. Print warning instead of error message if lvconvert cannot zero volume. Add snapshot options to lvconvert man page. --- LVM2/make.tmpl.in 2007/01/09 20:31:08 1.46 +++ LVM2/make.tmpl.in 2007/01/11 17:12:26 1.47 @@ -75,6 +75,9 @@ ifneq ("@DMDIR@", "") LDFLAGS += -L@DMDIR@/lib/ioctl + ifeq ("@DMEVENTD@", "yes") + LDFLAGS += -L@DMDIR@/dmeventd + endif endif LDFLAGS += -L$(top_srcdir)/lib -L$(libdir) @@ -170,18 +173,19 @@ ifeq ("@LIB_SUFFIX@","so") $(LIB_SHARED): $(OBJECTS) $(LDDEPS) $(CC) -shared -Wl,-soname,$(notdir $@).$(LIB_VERSION) \ - $(CLDFLAGS) $(OBJECTS) $(LIBS) -o $@ + $(CFLAGS) $(CLDFLAGS) $(OBJECTS) $(LIBS) -o $@ endif ifeq ("@LIB_SUFFIX@","dylib") $(LIB_SHARED): $(OBJECTS) $(LDDEPS) $(CC) -dynamiclib -dylib_current_version,$(LIB_VERSION) \ - $(CLDFLAGS) $(OBJECTS) $(LIBS) -o $@ + $(CFLAGS) $(CLDFLAGS) $(OBJECTS) $(LIBS) -o $@ endif %.so: %.a $(CC) -shared -Wl,-soname,$(notdir $@).$(LIB_VERSION) \ - $(CLDFLAGS) $(LIBS) -o $@ @CLDWHOLEARCHIVE@ $< @CLDNOWHOLEARCHIVE@ + $(CFLAGS) $(CLDFLAGS) $(LIBS) -o $@ \ + @CLDWHOLEARCHIVE@ $< @CLDNOWHOLEARCHIVE@ $(LIB_STATIC): $(OBJECTS) $(RM) $@ --- LVM2/daemons/clvmd/Makefile.in 2006/10/04 08:22:16 1.16 +++ LVM2/daemons/clvmd/Makefile.in 2007/01/11 17:12:27 1.17 @@ -71,7 +71,8 @@ install_clvmd clvmd: $(OBJECTS) $(top_srcdir)/lib/liblvm.a - $(CC) -o clvmd $(OBJECTS) $(LDFLAGS) $(LVMLIBS) $(LMLIBS) $(LIBS) + $(CC) -o clvmd $(OBJECTS) $(CFLAGS) $(LDFLAGS) \ + $(LVMLIBS) $(LMLIBS) $(LIBS) .PHONY: install_clvmd --- LVM2/tools/Makefile.in 2006/10/26 20:37:13 1.77 +++ LVM2/tools/Makefile.in 2007/01/11 17:12:27 1.78 @@ -101,11 +101,12 @@ include $(top_srcdir)/make.tmpl lvm: $(OBJECTS) lvm.o $(top_srcdir)/lib/liblvm.a - $(CC) -o $@ $(OBJECTS) lvm.o $(LDFLAGS) $(LVMLIBS) $(LIBS) -rdynamic + $(CC) -o $@ $(CFLAGS) $(OBJECTS) lvm.o \ + $(LDFLAGS) $(LVMLIBS) $(LIBS) -rdynamic lvm.static: $(OBJECTS) lvm-static.o $(top_srcdir)/lib/liblvm.a - $(CC) -o $@ $(OBJECTS) lvm-static.o -static $(LDFLAGS) $(LVMLIBS) \ - $(LIBS) -rdynamic + $(CC) -o $@ $(CFLAGS) $(OBJECTS) lvm-static.o -static \ + $(LDFLAGS) $(LVMLIBS) $(LIBS) -rdynamic liblvm2cmd.a: $(top_srcdir)/lib/liblvm.a $(OBJECTS) lvmcmdlib.o lvm2cmd.o cat $(top_srcdir)/lib/liblvm.a > $@ --- LVM2/tools/fsadm/Makefile.in 2004/06/15 17:29:20 1.1 +++ LVM2/tools/fsadm/Makefile.in 2007/01/11 17:12:27 1.2 @@ -23,7 +23,7 @@ include $(top_srcdir)/make.tmpl fsadm: $(OBJECTS) - $(CC) -o $@ $(OBJECTS) -rdynamic + $(CC) -o $@ $(CFLAGS) $(OBJECTS) -rdynamic install: fsadm $(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) fsadm \ From agk@sourceware.org Thu Jan 11 19:52:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 11 Jan 2007 19:52:00 -0000 Subject: LVM2 ./WHATS_NEW dmeventd/mirror/dmeventd_mirror.c Message-ID: <20070111195206.5345.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-11 19:52:06 Modified files: . : WHATS_NEW dmeventd/mirror: dmeventd_mirror.c Log message: Remove dmeventd mirror status line word limit Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.535&r2=1.536 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/dmeventd/mirror/dmeventd_mirror.c.diff?cvsroot=lvm2&r1=1.10&r2=1.11 --- LVM2/WHATS_NEW 2007/01/11 17:12:26 1.535 +++ LVM2/WHATS_NEW 2007/01/11 19:52:06 1.536 @@ -1,5 +1,6 @@ Version 2.02.18 - ==================================== + Remove dmeventd mirror status line word limit. Use CFLAGS when linking so mixed sparc builds can supply -m64. Prevent permission changes on active mirrors. Print warning instead of error message if lvconvert cannot zero volume. --- LVM2/dmeventd/mirror/dmeventd_mirror.c 2007/01/08 14:24:20 1.10 +++ LVM2/dmeventd/mirror/dmeventd_mirror.c 2007/01/11 19:52:06 1.11 @@ -54,54 +54,51 @@ static int _get_mirror_event(char *params) { int i, r = ME_INSYNC; - -#define MAX_ARGS 30 /* should support at least 8-way mirrors */ -/* FIXME Remove unnecessary limit. It tells you how many devices there are - use it! */ - - char *args[MAX_ARGS]; + char **args = NULL; char *dev_status_str; char *log_status_str; char *sync_str; char *p; - int log_argc, num_devs, num_failures=0; - - /* FIXME Remove unnecessary limit - get num_devs here */ - if (MAX_ARGS <= dm_split_words(params, MAX_ARGS, 0, args)) { - syslog(LOG_ERR, "Unable to split mirror parameters: Arg list too long"); - return -E2BIG; /* FIXME Why? Unused */ - } + int log_argc, num_devs; /* * Unused: 0 409600 mirror * Used : 2 253:4 253:5 400/400 1 AA 3 cluster 253:3 A - */ - num_devs = atoi(args[0]); - - /* FIXME *Now* split rest of args */ + */ - dev_status_str = args[3 + num_devs]; - log_argc = atoi(args[4 + num_devs]); - log_status_str = args[4 + num_devs + log_argc]; - sync_str = args[1 + num_devs]; + /* number of devices */ + if (!dm_split_words(params, 1, 0, &p)) + goto out_parse; + + num_devs = atoi(p); + p += strlen(p) + 1; + + /* devices names + max log parameters */ + args = dm_malloc((num_devs + 8) * sizeof(char *)); + if (!args || dm_split_words(p, num_devs + 8, 0, args) < num_devs) + goto out_parse; + + dev_status_str = args[2 + num_devs]; + log_argc = atoi(args[3 + num_devs]); + log_status_str = args[3 + num_devs + log_argc]; + sync_str = args[num_devs]; /* Check for bad mirror devices */ for (i = 0; i < num_devs; i++) if (dev_status_str[i] == 'D') { - syslog(LOG_ERR, "Mirror device, %s, has failed.\n", args[i+1]); - num_failures++; + syslog(LOG_ERR, "Mirror device, %s, has failed.\n", args[i]); + r = ME_FAILURE; } - /* Check for bad log device */ - if (log_status_str[0] == 'D') { + /* Check for bad disk log device */ + if (log_argc > 1 && log_status_str[0] == 'D') { syslog(LOG_ERR, "Log device, %s, has failed.\n", - args[3 + num_devs + log_argc]); - num_failures++; + args[2 + num_devs + log_argc]); + r = ME_FAILURE; } - if (num_failures) { - r = ME_FAILURE; + if (r == ME_FAILURE) goto out; - } p = strstr(sync_str, "/"); if (p) { @@ -109,16 +106,19 @@ if (strcmp(sync_str, p+1)) r = ME_IGNORE; p[0] = '/'; - } else { - /* - * How the hell did we get this? - * Might mean all our parameters are screwed. - */ - syslog(LOG_ERR, "Unable to parse sync string."); - r = ME_IGNORE; - } - out: + } else + goto out_parse; + +out: + if (args) + dm_free(args); return r; + +out_parse: + if (args) + dm_free(args); + syslog(LOG_ERR, "Unable to parse mirror status string."); + return ME_IGNORE; } static void _temporary_log_fn(int level, const char *file, From agk@sourceware.org Thu Jan 11 20:11:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 11 Jan 2007 20:11:00 -0000 Subject: LVM2/dmeventd/mirror dmeventd_mirror.c Message-ID: <20070111201120.22188.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-11 20:11:20 Modified files: dmeventd/mirror: dmeventd_mirror.c Log message: fail if status args are missing Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/dmeventd/mirror/dmeventd_mirror.c.diff?cvsroot=lvm2&r1=1.11&r2=1.12 --- LVM2/dmeventd/mirror/dmeventd_mirror.c 2007/01/11 19:52:06 1.11 +++ LVM2/dmeventd/mirror/dmeventd_mirror.c 2007/01/11 20:11:19 1.12 @@ -58,7 +58,7 @@ char *dev_status_str; char *log_status_str; char *sync_str; - char *p; + char *p = NULL; int log_argc, num_devs; /* @@ -70,12 +70,13 @@ if (!dm_split_words(params, 1, 0, &p)) goto out_parse; - num_devs = atoi(p); + if (!(num_devs = atoi(p))) + goto out_parse; p += strlen(p) + 1; /* devices names + max log parameters */ args = dm_malloc((num_devs + 8) * sizeof(char *)); - if (!args || dm_split_words(p, num_devs + 8, 0, args) < num_devs) + if (!args || dm_split_words(p, num_devs + 8, 0, args) < num_devs + 8) goto out_parse; dev_status_str = args[2 + num_devs]; From agk@sourceware.org Thu Jan 11 22:24:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 11 Jan 2007 22:24:00 -0000 Subject: LVM2 ./WHATS_NEW dmeventd/mirror/dmeventd_mirr ... Message-ID: <20070111222432.29912.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-11 22:24:32 Modified files: . : WHATS_NEW dmeventd/mirror: dmeventd_mirror.c lib/mirror : mirrored.c Log message: updated dmeventd interface Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.536&r2=1.537 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/dmeventd/mirror/dmeventd_mirror.c.diff?cvsroot=lvm2&r1=1.12&r2=1.13 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.37&r2=1.38 --- LVM2/WHATS_NEW 2007/01/11 19:52:06 1.536 +++ LVM2/WHATS_NEW 2007/01/11 22:24:31 1.537 @@ -1,5 +1,6 @@ Version 2.02.18 - ==================================== + Revised libdevmapper-event interface for dmeventd. Remove dmeventd mirror status line word limit. Use CFLAGS when linking so mixed sparc builds can supply -m64. Prevent permission changes on active mirrors. --- LVM2/dmeventd/mirror/dmeventd_mirror.c 2007/01/11 20:11:19 1.12 +++ LVM2/dmeventd/mirror/dmeventd_mirror.c 2007/01/11 22:24:31 1.13 @@ -161,34 +161,18 @@ return (r == 1) ? 0 : -1; } -void process_event(const char *device, enum dm_event_type event) +void process_event(struct dm_task *dmt, enum dm_event_type event) { - struct dm_task *dmt; void *next = NULL; uint64_t start, length; char *target_type = NULL; char *params; + const char *device = dm_task_get_name(dmt); if (pthread_mutex_trylock(&_event_mutex)) { syslog(LOG_NOTICE, "Another thread is handling an event. Waiting..."); pthread_mutex_lock(&_event_mutex); } - /* FIXME Move inside libdevmapper */ - if (!(dmt = dm_task_create(DM_DEVICE_STATUS))) { - syslog(LOG_ERR, "Unable to create dm_task.\n"); - goto fail; - } - - if (!dm_task_set_name(dmt, device)) { - syslog(LOG_ERR, "Unable to set device name.\n"); - goto fail; - } - - if (!dm_task_run(dmt)) { - syslog(LOG_ERR, "Unable to run task.\n"); - goto fail; - } - do { next = dm_get_next_target(dmt, next, &start, &length, &target_type, ¶ms); @@ -226,24 +210,21 @@ case ME_IGNORE: break; default: - /* FIXME Wrong: it can also return -E2BIG but it's never used! */ + /* FIXME Provide value then! */ syslog(LOG_INFO, "Unknown event received.\n"); } } while (next); - fail: - if (dmt) - dm_task_destroy(dmt); pthread_mutex_unlock(&_event_mutex); } -int register_device(const char *device) +int register_device(const char *device, const char *uuid, int major, int minor) { int r = 0; pthread_mutex_lock(&_register_mutex); - syslog(LOG_INFO, "Monitoring mirror device, %s for events\n", device); + syslog(LOG_INFO, "Monitoring mirror device %s for events\n", device); /* * Need some space for allocations. 1024 should be more @@ -273,10 +254,13 @@ return r; } -int unregister_device(const char *device) +int unregister_device(const char *device, const char *uuid, int major, int minor) { pthread_mutex_lock(&_register_mutex); + syslog(LOG_INFO, "No longer monitoring mirror device %s for events\n", + device); + if (!--_register_count) { dm_pool_destroy(_mem_pool); _mem_pool = NULL; --- LVM2/lib/mirror/mirrored.c 2006/10/18 18:01:52 1.37 +++ LVM2/lib/mirror/mirrored.c 2007/01/11 22:24:32 1.38 @@ -397,6 +397,7 @@ char *dso, *name; struct logical_volume *lv; struct volume_group *vg; + struct dm_event_handler *handler; lv = seg->lv; vg = lv->vg; @@ -409,10 +410,18 @@ if (!(name = build_dm_name(vg->cmd->mem, vg->name, lv->name, NULL))) return_0; - /* FIXME Save a returned handle here so we can unregister it later */ - if (!dm_event_register(dso, name, DM_EVENT_ALL_ERRORS)) + if (!(handler = dm_event_handler_create())) return_0; + dm_event_handler_set_dso(handler, dso); + dm_event_handler_set_name(handler, name); + dm_event_handler_set_events(handler, DM_EVENT_ALL_ERRORS); + if (!dm_event_register(handler)) { + dm_event_handler_destroy(handler); + return_0; + } + dm_event_handler_destroy(handler); + log_info("Registered %s for events", name); return 1; @@ -425,6 +434,7 @@ char *name; struct logical_volume *lv; struct volume_group *vg; + struct dm_event_handler *handler; lv = seg->lv; vg = lv->vg; @@ -436,10 +446,18 @@ if (!(name = build_dm_name(vg->cmd->mem, vg->name, lv->name, NULL))) return_0; - /* FIXME Use handle returned by registration function instead of dso */ - if (!dm_event_unregister(dso, name, DM_EVENT_ALL_ERRORS)) + if (!(handler = dm_event_handler_create())) return_0; + dm_event_handler_set_dso(handler, dso); + dm_event_handler_set_name(handler, name); + dm_event_handler_set_events(handler, DM_EVENT_ALL_ERRORS); + if (!dm_event_unregister(handler)) { + dm_event_handler_destroy(handler); + return_0; + } + dm_event_handler_destroy(handler); + log_info("Unregistered %s for events", name); return 1; From agk@sourceware.org Thu Jan 11 22:49:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 11 Jan 2007 22:49:00 -0000 Subject: LVM2 VERSION WHATS_NEW Message-ID: <20070111224944.9197.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-11 22:49:44 Modified files: . : VERSION WHATS_NEW Log message: pre-release Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/VERSION.diff?cvsroot=lvm2&r1=1.135&r2=1.136 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.537&r2=1.538 --- LVM2/VERSION 2006/12/14 22:21:32 1.135 +++ LVM2/VERSION 2007/01/11 22:49:43 1.136 @@ -1 +1 @@ -2.02.18-cvs (2006-12-14) +2.02.18-cvs (2007-01-11) --- LVM2/WHATS_NEW 2007/01/11 22:24:31 1.537 +++ LVM2/WHATS_NEW 2007/01/11 22:49:43 1.538 @@ -1,5 +1,5 @@ -Version 2.02.18 - -==================================== +Version 2.02.18 - 11th January 2007 +=================================== Revised libdevmapper-event interface for dmeventd. Remove dmeventd mirror status line word limit. Use CFLAGS when linking so mixed sparc builds can supply -m64. From agk@sourceware.org Thu Jan 11 23:17:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 11 Jan 2007 23:17:00 -0000 Subject: LVM2 VERSION WHATS_NEW Message-ID: <20070111231726.31646.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-11 23:17:26 Modified files: . : VERSION WHATS_NEW Log message: post-release Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/VERSION.diff?cvsroot=lvm2&r1=1.136&r2=1.137 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.538&r2=1.539 --- LVM2/VERSION 2007/01/11 22:49:43 1.136 +++ LVM2/VERSION 2007/01/11 23:17:26 1.137 @@ -1 +1 @@ -2.02.18-cvs (2007-01-11) +2.02.19-cvs (2007-01-11) --- LVM2/WHATS_NEW 2007/01/11 22:49:43 1.538 +++ LVM2/WHATS_NEW 2007/01/11 23:17:26 1.539 @@ -1,3 +1,6 @@ +Version 2.02.19 - +=================================== + Version 2.02.18 - 11th January 2007 =================================== Revised libdevmapper-event interface for dmeventd. From agk@sourceware.org Fri Jan 12 20:38:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Fri, 12 Jan 2007 20:38:00 -0000 Subject: LVM2 ./VERSION ./WHATS_NEW dmeventd/mirror/dme ... Message-ID: <20070112203831.20631.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-12 20:38:30 Modified files: . : VERSION WHATS_NEW dmeventd/mirror: dmeventd_mirror.c lib/activate : activate.c lib/metadata : segtype.h lib/mirror : mirrored.c tools : lvchange.c lvrename.c vgchange.c Log message: Report dmeventd mirror monitoring status. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/VERSION.diff?cvsroot=lvm2&r1=1.137&r2=1.138 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.539&r2=1.540 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/dmeventd/mirror/dmeventd_mirror.c.diff?cvsroot=lvm2&r1=1.13&r2=1.14 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.115&r2=1.116 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/segtype.h.diff?cvsroot=lvm2&r1=1.14&r2=1.15 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.38&r2=1.39 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvchange.c.diff?cvsroot=lvm2&r1=1.75&r2=1.76 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvrename.c.diff?cvsroot=lvm2&r1=1.40&r2=1.41 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.54&r2=1.55 --- LVM2/VERSION 2007/01/11 23:17:26 1.137 +++ LVM2/VERSION 2007/01/12 20:38:29 1.138 @@ -1 +1 @@ -2.02.19-cvs (2007-01-11) +2.02.19-cvs (2007-01-12) --- LVM2/WHATS_NEW 2007/01/11 23:17:26 1.539 +++ LVM2/WHATS_NEW 2007/01/12 20:38:29 1.540 @@ -1,5 +1,7 @@ Version 2.02.19 - =================================== + Report dmeventd mirror monitoring status. + Fix dmeventd mirror status line processing. Version 2.02.18 - 11th January 2007 =================================== --- LVM2/dmeventd/mirror/dmeventd_mirror.c 2007/01/11 22:24:31 1.13 +++ LVM2/dmeventd/mirror/dmeventd_mirror.c 2007/01/12 20:38:29 1.14 @@ -15,7 +15,6 @@ #include "libdevmapper.h" #include "libdevmapper-event.h" #include "lvm2cmd.h" -#include "lvm-string.h" #include #include @@ -62,8 +61,12 @@ int log_argc, num_devs; /* - * Unused: 0 409600 mirror - * Used : 2 253:4 253:5 400/400 1 AA 3 cluster 253:3 A + * dm core parms: 0 409600 mirror + * Mirror core parms: 2 253:4 253:5 400/400 + * New-style failure params: 1 AA + * New-style log params: 3 cluster 253:3 A + * or 3 disk 253:3 A + * or 1 core */ /* number of devices */ @@ -74,9 +77,9 @@ goto out_parse; p += strlen(p) + 1; - /* devices names + max log parameters */ - args = dm_malloc((num_devs + 8) * sizeof(char *)); - if (!args || dm_split_words(p, num_devs + 8, 0, args) < num_devs + 8) + /* devices names + "400/400" + "1 AA" + 1 or 3 log parms + NULL */ + args = dm_malloc((num_devs + 7) * sizeof(char *)); + if (!args || dm_split_words(p, num_devs + 7, 0, args) < num_devs + 5) goto out_parse; dev_status_str = args[2 + num_devs]; --- LVM2/lib/activate/activate.c 2006/12/20 16:19:01 1.115 +++ LVM2/lib/activate/activate.c 2007/01/12 20:38:29 1.116 @@ -655,10 +655,11 @@ struct logical_volume *lv, int do_reg) { #ifdef DMEVENTD + int i, pending = 0, registered; int r = 0; struct list *tmp; struct lv_segment *seg; - int (*reg) (struct lv_segment *, int events); + int (*reg) (struct cmd_context *c, struct lv_segment *s, int e); if (do_reg && !dmeventd_register_mode()) return 1; @@ -666,24 +667,59 @@ list_iterate(tmp, &lv->segments) { seg = list_item(tmp, struct lv_segment); + if (!seg_monitored(seg) || (seg->status & PVMOVE)) + continue; reg = NULL; + /* Check monitoring status */ + if (seg->segtype->ops->target_registered) + registered = seg->segtype->ops->target_registered(seg, &pending); + else + continue; /* segtype doesn't support registration */ + + /* + * FIXME: We should really try again if pending + */ + registered = (pending) ? 0 : registered; + if (do_reg) { - if (seg->segtype->ops->target_register_events) + if (registered) + log_verbose("%s/%s already monitored.", lv->vg->name, lv->name); + else if (seg->segtype->ops->target_register_events) reg = seg->segtype->ops->target_register_events; - } else if (seg->segtype->ops->target_unregister_events) - reg = seg->segtype->ops->target_unregister_events; + } else { + if (!registered) + log_verbose("%s/%s already not monitored.", lv->vg->name, lv->name); + else if (seg->segtype->ops->target_unregister_events) + reg = seg->segtype->ops->target_unregister_events; + } + /* Do [un]monitor */ if (!reg) continue; /* FIXME specify events */ - if (!reg(seg, 0)) { + if (!reg(cmd, seg, 0)) { stack; return -1; } - r = 1; + /* Check [un]monitor results */ + /* Try a couple times if pending, but not forever... */ + for (i = 0; i < 10; i++) { + pending = 0; + registered = seg->segtype->ops->target_registered(seg, &pending); + if (pending || + (!registered && do_reg) || + (registered && !do_reg)) + log_very_verbose("%s/%s %smonitoring still pending.", + lv->vg->name, lv->name, do_reg ? "" : "un"); + else + break; + sleep(1); + } + + r = (registered && do_reg) || (!registered && !do_reg); } return r; @@ -728,7 +764,7 @@ } } - if (register_dev_for_events(cmd, lv, 0) != 1) + if (register_dev_for_events(cmd, lv, 0) < 0) /* FIXME Consider aborting here */ stack; @@ -786,7 +822,7 @@ memlock_dec(); fs_unlock(); - if (register_dev_for_events(cmd, lv, 1) != 1) + if (register_dev_for_events(cmd, lv, 1) < 0) stack; return 1; @@ -832,7 +868,7 @@ return 0; } - if (register_dev_for_events(cmd, lv, 0) != 1) + if (register_dev_for_events(cmd, lv, 0) < 0) stack; memlock_inc(); @@ -905,7 +941,7 @@ memlock_dec(); fs_unlock(); - if (!register_dev_for_events(cmd, lv, 1) != 1) + if (!register_dev_for_events(cmd, lv, 1) < 0) stack; return r; --- LVM2/lib/metadata/segtype.h 2006/10/18 18:01:52 1.14 +++ LVM2/lib/metadata/segtype.h 2007/01/12 20:38:29 1.15 @@ -32,6 +32,7 @@ #define SEG_FORMAT1_SUPPORT 0x00000010U #define SEG_VIRTUAL 0x00000020U #define SEG_CANNOT_BE_ZEROED 0x00000040U +#define SEG_MONITORED 0x00000080U #define seg_is_mirrored(seg) ((seg)->segtype->flags & SEG_AREAS_MIRRORED ? 1 : 0) #define seg_is_striped(seg) ((seg)->segtype->flags & SEG_AREAS_STRIPED ? 1 : 0) @@ -39,6 +40,7 @@ #define seg_is_virtual(seg) ((seg)->segtype->flags & SEG_VIRTUAL ? 1 : 0) #define seg_can_split(seg) ((seg)->segtype->flags & SEG_CAN_SPLIT ? 1 : 0) #define seg_cannot_be_zeroed(seg) ((seg)->segtype->flags & SEG_CANNOT_BE_ZEROED ? 1 : 0) +#define seg_monitored(seg) ((seg)->segtype->flags & SEG_MONITORED ? 1 : 0) #define segtype_is_striped(segtype) ((segtype)->flags & SEG_AREAS_STRIPED ? 1 : 0) #define segtype_is_mirrored(segtype) ((segtype)->flags & SEG_AREAS_MIRRORED ? 1 : 0) @@ -81,8 +83,11 @@ const struct lv_segment *seg, struct list *modules); void (*destroy) (const struct segment_type * segtype); - int (*target_register_events) (struct lv_segment *seg, int events); - int (*target_unregister_events) (struct lv_segment *seg, int events); + int (*target_registered) (struct lv_segment *seg, int *pending); + int (*target_register_events) (struct cmd_context *cmd, + struct lv_segment *seg, int events); + int (*target_unregister_events) (struct cmd_context *cmd, + struct lv_segment *seg, int events); }; struct segment_type *get_segtype_from_string(struct cmd_context *cmd, --- LVM2/lib/mirror/mirrored.c 2007/01/11 22:24:32 1.38 +++ LVM2/lib/mirror/mirrored.c 2007/01/12 20:38:30 1.39 @@ -368,13 +368,12 @@ } #ifdef DMEVENTD -static int _setup_registration(struct dm_pool *mem, struct cmd_context *cmd, - char **dso) +static int _setup_registration(struct cmd_context *cmd, char **dso) { char *path; const char *libpath; - if (!(path = dm_pool_alloc(mem, PATH_MAX))) { + if (!(path = dm_pool_alloc(cmd->mem, PATH_MAX))) { log_error("Failed to allocate dmeventd library path."); return 0; } @@ -389,9 +388,40 @@ return 1; } +static int _target_registered(struct lv_segment *seg, int *pending) +{ + char *dso, *name; + struct logical_volume *lv; + struct volume_group *vg; + enum dm_event_type events = 0; + + lv = seg->lv; + vg = lv->vg; + + *pending = 0; + if (!_setup_registration(vg->cmd, &dso)) { + stack; + return 0; + } + + if (!(name = build_dm_name(vg->cmd->mem, vg->name, lv->name, NULL))) + return_0; + + if (!dm_event_get_registered_device(&dso, &name, &events, 0)) + return 0; + + if (events & DM_EVENT_REGISTRATION_PENDING) { + *pending = 1; + events &= ~DM_EVENT_REGISTRATION_PENDING; + } + + return events; +} + /* FIXME This gets run while suspended and performs banned operations. */ /* FIXME Merge these two functions */ -static int _target_register_events(struct lv_segment *seg, +static int _target_register_events(struct cmd_context *cmd, + struct lv_segment *seg, int events) { char *dso, *name; @@ -402,12 +432,12 @@ lv = seg->lv; vg = lv->vg; - if (!_setup_registration(vg->cmd->mem, vg->cmd, &dso)) { + if (!_setup_registration(cmd, &dso)) { stack; return 0; } - if (!(name = build_dm_name(vg->cmd->mem, vg->name, lv->name, NULL))) + if (!(name = build_dm_name(cmd->mem, vg->name, lv->name, NULL))) return_0; if (!(handler = dm_event_handler_create())) @@ -427,7 +457,8 @@ return 1; } -static int _target_unregister_events(struct lv_segment *seg, +static int _target_unregister_events(struct cmd_context *cmd, + struct lv_segment *seg, int events) { char *dso; @@ -440,10 +471,10 @@ vg = lv->vg; /* FIXME Remove this and use handle to avoid config file race */ - if (!_setup_registration(vg->cmd->mem, vg->cmd, &dso)) + if (!_setup_registration(cmd, &dso)) return_0; - if (!(name = build_dm_name(vg->cmd->mem, vg->name, lv->name, NULL))) + if (!(name = build_dm_name(cmd->mem, vg->name, lv->name, NULL))) return_0; if (!(handler = dm_event_handler_create())) @@ -504,6 +535,7 @@ .target_percent = _mirrored_target_percent, .target_present = _mirrored_target_present, #ifdef DMEVENTD + .target_registered = _target_registered, .target_register_events = _target_register_events, .target_unregister_events = _target_unregister_events, #endif @@ -530,7 +562,7 @@ segtype->ops = &_mirrored_ops; segtype->name = "mirror"; segtype->private = NULL; - segtype->flags = SEG_AREAS_MIRRORED; + segtype->flags = SEG_AREAS_MIRRORED | SEG_MONITORED; log_very_verbose("Initialised segtype: %s", segtype->name); --- LVM2/tools/lvchange.c 2007/01/10 19:56:39 1.75 +++ LVM2/tools/lvchange.c 2007/01/12 20:38:30 1.76 @@ -104,8 +104,10 @@ (dmeventd_register_mode()) ? "" : "un", lv->name); r = 0; } else if (!r) { - log_verbose("Logical volume %s needs no monitoring.", - lv->name); + log_verbose("Logical volume %s needs no %smonitoring, or is already %smonitored", + (dmeventd_register_mode()) ? "" : "un", + lv->name, + (dmeventd_register_mode()) ? "" : "un"); r = 1; } --- LVM2/tools/lvrename.c 2006/09/02 01:18:17 1.40 +++ LVM2/tools/lvrename.c 2007/01/12 20:38:30 1.41 @@ -152,6 +152,14 @@ goto error; } + if ((lv->status & MIRRORED) || + (lv->status & MIRROR_LOG) || + (lv->status & MIRROR_IMAGE)) { + log_error("Mirrored LV, \"%s\" cannot be renamed: %s", + lv->name, strerror(ENOSYS)); + goto error; + } + if (!archive(lv->vg)) { stack; goto error; --- LVM2/tools/vgchange.c 2006/08/16 14:41:42 1.54 +++ LVM2/tools/vgchange.c 2007/01/12 20:38:30 1.55 @@ -53,8 +53,7 @@ } /* - * returns the number of monitored devices, not the number - * of _new_ monitored devices + * returns the number of _new_ monitored devices */ return count; @@ -117,7 +116,7 @@ if ((active = lvs_in_vg_activated(vg))) { monitored = _register_lvs_in_vg(cmd, vg, dmeventd_register_mode()); log_print("%d logical volume(s) in volume group " - "\"%s\" now %smonitored", + "\"%s\" %smonitored", monitored, vg->name, (dmeventd_register_mode()) ? "" : "un"); } @@ -157,7 +156,7 @@ "already active", active, vg->name); monitored = _register_lvs_in_vg(cmd, vg, dmeventd_register_mode()); log_verbose("%d existing logical volume(s) in volume " - "group \"%s\" now %smonitored", + "group \"%s\" %smonitored", monitored, vg->name, dmeventd_register_mode() ? "" : "un"); } From agk@sourceware.org Mon Jan 15 18:22:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Mon, 15 Jan 2007 18:22:00 -0000 Subject: LVM2 ./WHATS_NEW dmeventd/mirror/dmeventd_mirr ... Message-ID: <20070115182202.10577.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-15 18:22:02 Modified files: . : WHATS_NEW dmeventd/mirror: dmeventd_mirror.c lib/mirror : mirrored.c Log message: Some libdevmapper-event interface changes. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.540&r2=1.541 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/dmeventd/mirror/dmeventd_mirror.c.diff?cvsroot=lvm2&r1=1.14&r2=1.15 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.39&r2=1.40 --- LVM2/WHATS_NEW 2007/01/12 20:38:29 1.540 +++ LVM2/WHATS_NEW 2007/01/15 18:22:01 1.541 @@ -1,5 +1,6 @@ Version 2.02.19 - =================================== + Some libdevmapper-event interface changes. Report dmeventd mirror monitoring status. Fix dmeventd mirror status line processing. --- LVM2/dmeventd/mirror/dmeventd_mirror.c 2007/01/12 20:38:29 1.14 +++ LVM2/dmeventd/mirror/dmeventd_mirror.c 2007/01/15 18:22:01 1.15 @@ -164,7 +164,7 @@ return (r == 1) ? 0 : -1; } -void process_event(struct dm_task *dmt, enum dm_event_type event) +void process_event(struct dm_task *dmt, enum dm_event_mask event) { void *next = NULL; uint64_t start, length; --- LVM2/lib/mirror/mirrored.c 2007/01/12 20:38:30 1.39 +++ LVM2/lib/mirror/mirrored.c 2007/01/15 18:22:02 1.40 @@ -393,7 +393,7 @@ char *dso, *name; struct logical_volume *lv; struct volume_group *vg; - enum dm_event_type events = 0; + enum dm_event_mask evmask = 0; lv = seg->lv; vg = lv->vg; @@ -407,27 +407,27 @@ if (!(name = build_dm_name(vg->cmd->mem, vg->name, lv->name, NULL))) return_0; - if (!dm_event_get_registered_device(&dso, &name, &events, 0)) + if (!dm_event_get_registered_device(&dso, &name, &evmask, 0)) return 0; - if (events & DM_EVENT_REGISTRATION_PENDING) { + if (evmask & DM_EVENT_REGISTRATION_PENDING) { *pending = 1; - events &= ~DM_EVENT_REGISTRATION_PENDING; + evmask &= ~DM_EVENT_REGISTRATION_PENDING; } - return events; + return evmask; } /* FIXME This gets run while suspended and performs banned operations. */ /* FIXME Merge these two functions */ static int _target_register_events(struct cmd_context *cmd, struct lv_segment *seg, - int events) + int evmask) { char *dso, *name; struct logical_volume *lv; struct volume_group *vg; - struct dm_event_handler *handler; + struct dm_event_handler *dmevh; lv = seg->lv; vg = lv->vg; @@ -440,17 +440,17 @@ if (!(name = build_dm_name(cmd->mem, vg->name, lv->name, NULL))) return_0; - if (!(handler = dm_event_handler_create())) + if (!(dmevh = dm_event_handler_create())) return_0; - dm_event_handler_set_dso(handler, dso); - dm_event_handler_set_name(handler, name); - dm_event_handler_set_events(handler, DM_EVENT_ALL_ERRORS); - if (!dm_event_register(handler)) { - dm_event_handler_destroy(handler); + dm_event_handler_set_dso(dmevh, dso); + dm_event_handler_set_devname(dmevh, name); + dm_event_handler_set_event_mask(dmevh, DM_EVENT_ALL_ERRORS); + if (!dm_event_register_handler(dmevh)) { + dm_event_handler_destroy(dmevh); return_0; } - dm_event_handler_destroy(handler); + dm_event_handler_destroy(dmevh); log_info("Registered %s for events", name); @@ -459,13 +459,13 @@ static int _target_unregister_events(struct cmd_context *cmd, struct lv_segment *seg, - int events) + int evmask) { char *dso; char *name; struct logical_volume *lv; struct volume_group *vg; - struct dm_event_handler *handler; + struct dm_event_handler *dmevh; lv = seg->lv; vg = lv->vg; @@ -477,17 +477,17 @@ if (!(name = build_dm_name(cmd->mem, vg->name, lv->name, NULL))) return_0; - if (!(handler = dm_event_handler_create())) + if (!(dmevh = dm_event_handler_create())) return_0; - dm_event_handler_set_dso(handler, dso); - dm_event_handler_set_name(handler, name); - dm_event_handler_set_events(handler, DM_EVENT_ALL_ERRORS); - if (!dm_event_unregister(handler)) { - dm_event_handler_destroy(handler); + dm_event_handler_set_dso(dmevh, dso); + dm_event_handler_set_devname(dmevh, name); + dm_event_handler_set_event_mask(dmevh, DM_EVENT_ALL_ERRORS); + if (!dm_event_unregister_handler(dmevh)) { + dm_event_handler_destroy(dmevh); return_0; } - dm_event_handler_destroy(handler); + dm_event_handler_destroy(dmevh); log_info("Unregistered %s for events", name); From agk@sourceware.org Mon Jan 15 21:55:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Mon, 15 Jan 2007 21:55:00 -0000 Subject: LVM2 ./WHATS_NEW lib/device/device.c tools/too ... Message-ID: <20070115215512.16380.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-15 21:55:11 Modified files: . : WHATS_NEW lib/device : device.c tools : toollib.c Log message: Fix partition table processing after sparc changes (introduced in 2.02.16). Fix cmdline PE range processing segfault (introduced in 2.02.13). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.541&r2=1.542 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/device.c.diff?cvsroot=lvm2&r1=1.22&r2=1.23 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.95&r2=1.96 --- LVM2/WHATS_NEW 2007/01/15 18:22:01 1.541 +++ LVM2/WHATS_NEW 2007/01/15 21:55:11 1.542 @@ -1,5 +1,7 @@ Version 2.02.19 - =================================== + Fix partition table processing after sparc changes (2.02.16). + Fix cmdline PE range processing segfault (2.02.13). Some libdevmapper-event interface changes. Report dmeventd mirror monitoring status. Fix dmeventd mirror status line processing. --- LVM2/lib/device/device.c 2006/11/30 23:11:40 1.22 +++ LVM2/lib/device/device.c 2007/01/15 21:55:11 1.23 @@ -72,7 +72,7 @@ /* Check for msdos partition table */ part_magic = buf + PART_MAGIC_OFFSET/sizeof(buf[0]); if ((*part_magic == xlate16(PART_MAGIC))) { - part = (struct partition *) (buf + PART_OFFSET); + part = (struct partition *) (buf + PART_OFFSET/sizeof(buf[0])); for (p = 0; p < 4; p++, part++) { /* Table is invalid if boot indicator not 0 or 0x80 */ if ((part->boot_ind & 0x7f)) { --- LVM2/tools/toollib.c 2006/11/03 21:23:06 1.95 +++ LVM2/tools/toollib.c 2007/01/15 21:55:11 1.96 @@ -993,7 +993,7 @@ } /* Determine selected physical extents */ - if (!_parse_pes(mem, colon, pe_ranges, dev_name(pvl->pv->dev), + if (!_parse_pes(mem, colon, new_pvl->pe_ranges, dev_name(pvl->pv->dev), pvl->pv->pe_count)) { stack; return 0; From agk@sourceware.org Tue Jan 16 18:06:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 16 Jan 2007 18:06:00 -0000 Subject: LVM2 ./WHATS_NEW lib/mirror/mirrored.c lib/rep ... Message-ID: <20070116180612.24921.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-16 18:06:12 Modified files: . : WHATS_NEW lib/mirror : mirrored.c lib/report : report.c tools : lvmcmdlib.c reporter.c Log message: Move basic reporting functions into libdevmapper. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.542&r2=1.543 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.40&r2=1.41 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.50&r2=1.51 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdlib.c.diff?cvsroot=lvm2&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/reporter.c.diff?cvsroot=lvm2&r1=1.16&r2=1.17 --- LVM2/WHATS_NEW 2007/01/15 21:55:11 1.542 +++ LVM2/WHATS_NEW 2007/01/16 18:06:10 1.543 @@ -1,5 +1,6 @@ Version 2.02.19 - =================================== + Move basic reporting functions into libdevmapper. Fix partition table processing after sparc changes (2.02.16). Fix cmdline PE range processing segfault (2.02.13). Some libdevmapper-event interface changes. --- LVM2/lib/mirror/mirrored.c 2007/01/15 18:22:02 1.40 +++ LVM2/lib/mirror/mirrored.c 2007/01/16 18:06:11 1.41 @@ -444,7 +444,7 @@ return_0; dm_event_handler_set_dso(dmevh, dso); - dm_event_handler_set_devname(dmevh, name); + dm_event_handler_set_dev_name(dmevh, name); dm_event_handler_set_event_mask(dmevh, DM_EVENT_ALL_ERRORS); if (!dm_event_register_handler(dmevh)) { dm_event_handler_destroy(dmevh); @@ -481,7 +481,7 @@ return_0; dm_event_handler_set_dso(dmevh, dso); - dm_event_handler_set_devname(dmevh, name); + dm_event_handler_set_dev_name(dmevh, name); dm_event_handler_set_event_mask(dmevh, DM_EVENT_ALL_ERRORS); if (!dm_event_unregister_handler(dmevh)) { dm_event_handler_destroy(dmevh); --- LVM2/lib/report/report.c 2006/10/08 12:01:13 1.50 +++ LVM2/lib/report/report.c 2007/01/16 18:06:11 1.51 @@ -22,8 +22,17 @@ #include "activate.h" #include "segtype.h" #include "str_list.h" +#include "lvmcache.h" -/* +struct lvm_report_object { + struct volume_group *vg; + struct logical_volume *lv; + struct physical_volume *pv; + struct lv_segment *seg; + struct pv_segment *pvseg; +}; + +/* * For macro use */ static union { @@ -34,71 +43,6 @@ struct pv_segment _pvseg; } _dummy; -/* - * Report handle flags - */ -#define RH_SORT_REQUIRED 0x00000001 -#define RH_HEADINGS_PRINTED 0x00000002 -#define RH_BUFFERED 0x00000004 -#define RH_ALIGNED 0x00000008 -#define RH_HEADINGS 0x00000010 - -struct report_handle { - struct cmd_context *cmd; - struct dm_pool *mem; - - report_type_t type; - const char *field_prefix; - uint32_t flags; - const char *separator; - - uint32_t keys_count; - - /* Ordered list of fields needed for this report */ - struct list field_props; - - /* Rows of report data */ - struct list rows; -}; - -/* - * Per-field flags - */ -#define FLD_ALIGN_LEFT 0x00000001 -#define FLD_ALIGN_RIGHT 0x00000002 -#define FLD_STRING 0x00000004 -#define FLD_NUMBER 0x00000008 -#define FLD_HIDDEN 0x00000010 -#define FLD_SORT_KEY 0x00000020 -#define FLD_ASCENDING 0x00000040 -#define FLD_DESCENDING 0x00000080 - -struct field_properties { - struct list list; - uint32_t field_num; - uint32_t sort_posn; - int width; - uint32_t flags; -}; - -/* - * Report data - */ -struct field { - struct list list; - struct field_properties *props; - - const char *report_string; /* Formatted ready for display */ - const void *sort_value; /* Raw value for sorting */ -}; - -struct row { - struct list list; - struct report_handle *rh; - struct list fields; /* Fields in display order */ - struct field *(*sort_fields)[]; /* Fields in sort order */ -}; - static char _alloc_policy_char(alloc_policy_t alloc) { switch (alloc) { @@ -118,31 +62,25 @@ /* * Data-munging functions to prepare each data type for display and sorting */ -static int _string_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _string_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { - if (! - (field->report_string = - dm_pool_strdup(rh->mem, *(const char **) data))) { - log_error("dm_pool_strdup failed"); - return 0; - } - - field->sort_value = (const void *) field->report_string; - - return 1; + return dm_report_field_string(rh, mem, field, data); } -static int _dev_name_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _dev_name_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const char *name = dev_name(*(const struct device **) data); - return _string_disp(rh, field, &name); + return dm_report_field_string(rh, mem, field, &name); } -static int _devices_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _devices_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const struct lv_segment *seg = (const struct lv_segment *) data; unsigned int s; @@ -150,7 +88,7 @@ uint32_t extent = 0; char extent_str[32]; - if (!dm_pool_begin_object(rh->mem, 256)) { + if (!dm_pool_begin_object(mem, 256)) { log_error("dm_pool_begin_object failed"); return 0; } @@ -170,7 +108,7 @@ extent = 0; } - if (!dm_pool_grow_object(rh->mem, name, strlen(name))) { + if (!dm_pool_grow_object(mem, name, strlen(name))) { log_error("dm_pool_grow_object failed"); return 0; } @@ -181,173 +119,143 @@ return 0; } - if (!dm_pool_grow_object(rh->mem, extent_str, strlen(extent_str))) { + if (!dm_pool_grow_object(mem, extent_str, strlen(extent_str))) { log_error("dm_pool_grow_object failed"); return 0; } if ((s != seg->area_count - 1) && - !dm_pool_grow_object(rh->mem, ",", 1)) { + !dm_pool_grow_object(mem, ",", 1)) { log_error("dm_pool_grow_object failed"); return 0; } } - if (!dm_pool_grow_object(rh->mem, "\0", 1)) { + if (!dm_pool_grow_object(mem, "\0", 1)) { log_error("dm_pool_grow_object failed"); return 0; } - field->report_string = dm_pool_end_object(rh->mem); - field->sort_value = (const void *) field->report_string; + dm_report_field_set_value(field, dm_pool_end_object(mem), NULL); return 1; } -static int _tags_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _tags_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const struct list *tags = (const struct list *) data; struct str_list *sl; - if (!dm_pool_begin_object(rh->mem, 256)) { + if (!dm_pool_begin_object(mem, 256)) { log_error("dm_pool_begin_object failed"); return 0; } list_iterate_items(sl, tags) { - if (!dm_pool_grow_object(rh->mem, sl->str, strlen(sl->str)) || - (sl->list.n != tags && !dm_pool_grow_object(rh->mem, ",", 1))) { + if (!dm_pool_grow_object(mem, sl->str, strlen(sl->str)) || + (sl->list.n != tags && !dm_pool_grow_object(mem, ",", 1))) { log_error("dm_pool_grow_object failed"); return 0; } } - if (!dm_pool_grow_object(rh->mem, "\0", 1)) { + if (!dm_pool_grow_object(mem, "\0", 1)) { log_error("dm_pool_grow_object failed"); return 0; } - field->report_string = dm_pool_end_object(rh->mem); - field->sort_value = (const void *) field->report_string; + dm_report_field_set_value(field, dm_pool_end_object(mem), NULL); return 1; } -static int _modules_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _modules_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const struct logical_volume *lv = (const struct logical_volume *) data; struct list *modules; - if (!(modules = str_list_create(rh->mem))) { + if (!(modules = str_list_create(mem))) { log_error("modules str_list allocation failed"); return 0; } - if (!list_lv_modules(rh->mem, lv, modules)) + if (!list_lv_modules(mem, lv, modules)) return_0; - return _tags_disp(rh, field, modules); + return _tags_disp(rh, mem, field, modules, private); } -static int _vgfmt_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _vgfmt_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const struct volume_group *vg = (const struct volume_group *) data; if (!vg->fid) { - field->report_string = ""; - field->sort_value = (const void *) field->report_string; + dm_report_field_set_value(field, "", NULL); return 1; } - return _string_disp(rh, field, &vg->fid->fmt->name); + return _string_disp(rh, mem, field, &vg->fid->fmt->name, private); } -static int _pvfmt_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _pvfmt_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const struct physical_volume *pv = (const struct physical_volume *) data; if (!pv->fmt) { - field->report_string = ""; - field->sort_value = (const void *) field->report_string; + dm_report_field_set_value(field, "", NULL); return 1; } - return _string_disp(rh, field, &pv->fmt->name); + return _string_disp(rh, mem, field, &pv->fmt->name, private); } -static int _int_disp(struct report_handle *rh, struct field *field, - const void *data) -{ - const int value = *(const int *) data; - uint64_t *sortval; - char *repstr; - - if (!(repstr = dm_pool_zalloc(rh->mem, 13))) { - log_error("dm_pool_alloc failed"); - return 0; - } - - if (!(sortval = dm_pool_alloc(rh->mem, sizeof(int64_t)))) { - log_error("dm_pool_alloc failed"); - return 0; - } - - if (dm_snprintf(repstr, 12, "%d", value) < 0) { - log_error("int too big: %d", value); - return 0; - } - - *sortval = (const uint64_t) value; - field->sort_value = sortval; - field->report_string = repstr; - - return 1; -} - -static int _lvkmaj_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _lvkmaj_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const struct logical_volume *lv = (const struct logical_volume *) data; struct lvinfo info; uint64_t minusone = UINT64_C(-1); if (lv_info(lv->vg->cmd, lv, &info, 0) && info.exists) - return _int_disp(rh, field, &info.major); - else - return _int_disp(rh, field, &minusone); + return dm_report_field_int(rh, mem, field, &info.major); - return 1; + return dm_report_field_int(rh, mem, field, &minusone); } -static int _lvkmin_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _lvkmin_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const struct logical_volume *lv = (const struct logical_volume *) data; struct lvinfo info; uint64_t minusone = UINT64_C(-1); if (lv_info(lv->vg->cmd, lv, &info, 0) && info.exists) - return _int_disp(rh, field, &info.minor); - else - return _int_disp(rh, field, &minusone); + return dm_report_field_int(rh, mem, field, &info.minor); - return 1; + return dm_report_field_int(rh, mem, field, &minusone); } -static int _lvstatus_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _lvstatus_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const struct logical_volume *lv = (const struct logical_volume *) data; struct lvinfo info; char *repstr; float snap_percent; - if (!(repstr = dm_pool_zalloc(rh->mem, 7))) { + if (!(repstr = dm_pool_zalloc(mem, 7))) { log_error("dm_pool_alloc failed"); return 0; } @@ -419,19 +327,18 @@ repstr[5] = '-'; } - field->report_string = repstr; - field->sort_value = (const void *) field->report_string; - + dm_report_field_set_value(field, repstr, NULL); return 1; } -static int _pvstatus_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _pvstatus_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const uint32_t status = *(const uint32_t *) data; char *repstr; - if (!(repstr = dm_pool_zalloc(rh->mem, 4))) { + if (!(repstr = dm_pool_zalloc(mem, 4))) { log_error("dm_pool_alloc failed"); return 0; } @@ -446,19 +353,18 @@ else repstr[1] = '-'; - field->report_string = repstr; - field->sort_value = (const void *) field->report_string; - + dm_report_field_set_value(field, repstr, NULL); return 1; } -static int _vgstatus_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _vgstatus_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const struct volume_group *vg = (const struct volume_group *) data; char *repstr; - if (!(repstr = dm_pool_zalloc(rh->mem, 7))) { + if (!(repstr = dm_pool_zalloc(mem, 7))) { log_error("dm_pool_alloc failed"); return 0; } @@ -490,43 +396,43 @@ else repstr[5] = '-'; - field->report_string = repstr; - field->sort_value = (const void *) field->report_string; - + dm_report_field_set_value(field, repstr, NULL); return 1; } -static int _segtype_disp(struct report_handle *rh __attribute((unused)), - struct field *field, - const void *data) +static int _segtype_disp(struct dm_report *rh __attribute((unused)), + struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const struct lv_segment *seg = (const struct lv_segment *) data; - if (seg->area_count == 1) - field->report_string = "linear"; - else - field->report_string = seg->segtype->ops->name(seg); - field->sort_value = (const void *) field->report_string; + if (seg->area_count == 1) { + dm_report_field_set_value(field, "linear", NULL); + return 1; + } + dm_report_field_set_value(field, seg->segtype->ops->name(seg), NULL); return 1; } -static int _origin_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _origin_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const struct logical_volume *lv = (const struct logical_volume *) data; if (lv_is_cow(lv)) - return _string_disp(rh, field, &origin_from_cow(lv)->name); - - field->report_string = ""; - field->sort_value = (const void *) field->report_string; + return dm_report_field_string(rh, mem, field, + &origin_from_cow(lv)->name); + dm_report_field_set_value(field, "", NULL); return 1; } -static int _loglv_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _loglv_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const struct logical_volume *lv = (const struct logical_volume *) data; struct lv_segment *seg; @@ -534,29 +440,29 @@ list_iterate_items(seg, &lv->segments) { if (!seg_is_mirrored(seg) || !seg->log_lv) continue; - return _string_disp(rh, field, &seg->log_lv->name); + return dm_report_field_string(rh, mem, field, + &seg->log_lv->name); } - field->report_string = ""; - field->sort_value = (const void *) field->report_string; - + dm_report_field_set_value(field, "", NULL); return 1; } -static int _lvname_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _lvname_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const struct logical_volume *lv = (const struct logical_volume *) data; - char *repstr; + char *repstr, *lvname; size_t len; if (lv_is_visible(lv)) { repstr = lv->name; - return _string_disp(rh, field, &repstr); + return dm_report_field_string(rh, mem, field, &repstr); } len = strlen(lv->name) + 3; - if (!(repstr = dm_pool_zalloc(rh->mem, len))) { + if (!(repstr = dm_pool_zalloc(mem, len))) { log_error("dm_pool_alloc failed"); return 0; } @@ -566,18 +472,19 @@ return 0; } - field->report_string = repstr; - - if (!(field->sort_value = dm_pool_strdup(rh->mem, lv->name))) { + if (!(lvname = dm_pool_strdup(mem, lv->name))) { log_error("dm_pool_strdup failed"); return 0; } + dm_report_field_set_value(field, repstr, lvname); + return 1; } -static int _movepv_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _movepv_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const struct logical_volume *lv = (const struct logical_volume *) data; const char *name; @@ -587,106 +494,111 @@ if (!(seg->status & PVMOVE)) continue; name = dev_name(seg_dev(seg, 0)); - return _string_disp(rh, field, &name); + return dm_report_field_string(rh, mem, field, &name); } - field->report_string = ""; - field->sort_value = (const void *) field->report_string; - + dm_report_field_set_value(field, "", NULL); return 1; } -static int _size32_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _size32_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const uint32_t size = *(const uint32_t *) data; - const char *disp; + const char *disp, *repstr; uint64_t *sortval; - if (!*(disp = display_size_units(rh->cmd, (uint64_t) size))) { + if (!*(disp = display_size_units(private, (uint64_t) size))) { stack; return 0; } - if (!(field->report_string = dm_pool_strdup(rh->mem, disp))) { + if (!(repstr = dm_pool_strdup(mem, disp))) { log_error("dm_pool_strdup failed"); return 0; } - if (!(sortval = dm_pool_alloc(rh->mem, sizeof(uint64_t)))) { + if (!(sortval = dm_pool_alloc(mem, sizeof(uint64_t)))) { log_error("dm_pool_alloc failed"); return 0; } *sortval = (const uint64_t) size; - field->sort_value = (const void *) sortval; + + dm_report_field_set_value(field, repstr, sortval); return 1; } -static int _size64_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _size64_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const uint64_t size = *(const uint64_t *) data; - const char *disp; + const char *disp, *repstr; uint64_t *sortval; - if (!*(disp = display_size_units(rh->cmd, size))) { + if (!*(disp = display_size_units(private, size))) { stack; return 0; } - if (!(field->report_string = dm_pool_strdup(rh->mem, disp))) { + if (!(repstr = dm_pool_strdup(mem, disp))) { log_error("dm_pool_strdup failed"); return 0; } - if (!(sortval = dm_pool_alloc(rh->mem, sizeof(uint64_t)))) { + if (!(sortval = dm_pool_alloc(mem, sizeof(uint64_t)))) { log_error("dm_pool_alloc failed"); return 0; } *sortval = size; - field->sort_value = sortval; + dm_report_field_set_value(field, repstr, sortval); return 1; } -static int _vgsize_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _vgsize_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const struct volume_group *vg = (const struct volume_group *) data; uint64_t size; size = (uint64_t) vg->extent_count * vg->extent_size; - return _size64_disp(rh, field, &size); + return _size64_disp(rh, mem, field, &size, private); } -static int _segstart_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _segstart_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const struct lv_segment *seg = (const struct lv_segment *) data; uint64_t start; start = (uint64_t) seg->le * seg->lv->vg->extent_size; - return _size64_disp(rh, field, &start); + return _size64_disp(rh, mem, field, &start, private); } -static int _segsize_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _segsize_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const struct lv_segment *seg = (const struct lv_segment *) data; uint64_t size; size = (uint64_t) seg->len * seg->lv->vg->extent_size; - return _size64_disp(rh, field, &size); + return _size64_disp(rh, mem, field, &size, private); } -static int _chunksize_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _chunksize_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const struct lv_segment *seg = (const struct lv_segment *) data; uint64_t size; @@ -696,11 +608,12 @@ else size = 0; - return _size64_disp(rh, field, &size); + return _size64_disp(rh, mem, field, &size, private); } -static int _pvused_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _pvused_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const struct physical_volume *pv = (const struct physical_volume *) data; @@ -711,11 +624,12 @@ else used = (uint64_t) pv->pe_alloc_count * pv->pe_size; - return _size64_disp(rh, field, &used); + return _size64_disp(rh, mem, field, &used, private); } -static int _pvfree_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _pvfree_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const struct physical_volume *pv = (const struct physical_volume *) data; @@ -726,11 +640,12 @@ else freespace = (uint64_t) (pv->pe_count - pv->pe_alloc_count) * pv->pe_size; - return _size64_disp(rh, field, &freespace); + return _size64_disp(rh, mem, field, &freespace, private); } -static int _pvsize_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _pvsize_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const struct physical_volume *pv = (const struct physical_volume *) data; @@ -741,11 +656,12 @@ else size = (uint64_t) pv->pe_count * pv->pe_size; - return _size64_disp(rh, field, &size); + return _size64_disp(rh, mem, field, &size, private); } -static int _devsize_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _devsize_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const struct device *dev = *(const struct device **) data; uint64_t size; @@ -753,26 +669,28 @@ if (!dev_get_size(dev, &size)) size = 0; - return _size64_disp(rh, field, &size); + return _size64_disp(rh, mem, field, &size, private); } -static int _vgfree_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _vgfree_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const struct volume_group *vg = (const struct volume_group *) data; uint64_t freespace; freespace = (uint64_t) vg->free_count * vg->extent_size; - return _size64_disp(rh, field, &freespace); + return _size64_disp(rh, mem, field, &freespace, private); } -static int _uuid_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _uuid_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { char *repstr = NULL; - if (!(repstr = dm_pool_alloc(rh->mem, 40))) { + if (!(repstr = dm_pool_alloc(mem, 40))) { log_error("dm_pool_alloc failed"); return 0; } @@ -782,83 +700,39 @@ return 0; } - field->report_string = repstr; - field->sort_value = (const void *) field->report_string; - + dm_report_field_set_value(field, repstr, NULL); return 1; } -static int _uint32_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _uint32_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { - const uint32_t value = *(const uint32_t *) data; - uint64_t *sortval; - char *repstr; - - if (!(repstr = dm_pool_zalloc(rh->mem, 12))) { - log_error("dm_pool_alloc failed"); - return 0; - } - - if (!(sortval = dm_pool_alloc(rh->mem, sizeof(uint64_t)))) { - log_error("dm_pool_alloc failed"); - return 0; - } - - if (dm_snprintf(repstr, 11, "%u", value) < 0) { - log_error("uint32 too big: %u", value); - return 0; - } - - *sortval = (const uint64_t) value; - field->sort_value = sortval; - field->report_string = repstr; - - return 1; + return dm_report_field_uint32(rh, mem, field, data); } -static int _int32_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _int32_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { - const int32_t value = *(const int32_t *) data; - uint64_t *sortval; - char *repstr; - - if (!(repstr = dm_pool_zalloc(rh->mem, 13))) { - log_error("dm_pool_alloc failed"); - return 0; - } - - if (!(sortval = dm_pool_alloc(rh->mem, sizeof(int64_t)))) { - log_error("dm_pool_alloc failed"); - return 0; - } - - if (dm_snprintf(repstr, 12, "%d", value) < 0) { - log_error("int32 too big: %d", value); - return 0; - } - - *sortval = (const uint64_t) value; - field->sort_value = sortval; - field->report_string = repstr; - - return 1; + return dm_report_field_int32(rh, mem, field, data); } -static int _lvsegcount_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _lvsegcount_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const struct logical_volume *lv = (const struct logical_volume *) data; uint32_t count; count = list_size(&lv->segments); - return _uint32_disp(rh, field, &count); + return _uint32_disp(rh, mem, field, &count, private); } -static int _snpercent_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _snpercent_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { const struct logical_volume *lv = (const struct logical_volume *) data; struct lvinfo info; @@ -866,27 +740,31 @@ uint64_t *sortval; char *repstr; - if (!(sortval = dm_pool_alloc(rh->mem, sizeof(uint64_t)))) { + /* Suppress snapshot percentage if not using driver */ + if (!activation()) { + dm_report_field_set_value(field, "", NULL); + return 1; + } + + if (!(sortval = dm_pool_alloc(mem, sizeof(uint64_t)))) { log_error("dm_pool_alloc failed"); return 0; } if (!lv_is_cow(lv) || (lv_info(lv->vg->cmd, lv, &info, 0) && !info.exists)) { - field->report_string = ""; *sortval = UINT64_C(0); - field->sort_value = sortval; + dm_report_field_set_value(field, "", sortval); return 1; } if (!lv_snapshot_percent(lv, &snap_percent) || snap_percent < 0) { - field->report_string = "100.00"; *sortval = UINT64_C(100); - field->sort_value = sortval; + dm_report_field_set_value(field, "100.00", sortval); return 1; } - if (!(repstr = dm_pool_zalloc(rh->mem, 8))) { + if (!(repstr = dm_pool_zalloc(mem, 8))) { log_error("dm_pool_alloc failed"); return 0; } @@ -897,36 +775,35 @@ } *sortval = snap_percent * UINT64_C(1000); - field->sort_value = sortval; - field->report_string = repstr; + dm_report_field_set_value(field, repstr, sortval); return 1; } -static int _copypercent_disp(struct report_handle *rh, struct field *field, - const void *data) +static int _copypercent_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) { struct logical_volume *lv = (struct logical_volume *) data; float percent; uint64_t *sortval; char *repstr; - if (!(sortval = dm_pool_alloc(rh->mem, sizeof(uint64_t)))) { + if (!(sortval = dm_pool_alloc(mem, sizeof(uint64_t)))) { log_error("dm_pool_alloc failed"); return 0; } if ((!(lv->status & PVMOVE) && !(lv->status & MIRRORED)) || !lv_mirror_percent(lv->vg->cmd, lv, 0, &percent, NULL)) { - field->report_string = ""; *sortval = UINT64_C(0); - field->sort_value = sortval; + dm_report_field_set_value(field, "", sortval); return 1; } percent = copy_percent(lv); - if (!(repstr = dm_pool_zalloc(rh->mem, 8))) { + if (!(repstr = dm_pool_zalloc(mem, 8))) { log_error("dm_pool_alloc failed"); return 0; } @@ -937,330 +814,88 @@ } *sortval = percent * UINT64_C(1000); - field->sort_value = sortval; - field->report_string = repstr; + dm_report_field_set_value(field, repstr, sortval); return 1; } -/* - * Import column definitions - */ - -#define STR (FLD_STRING | FLD_ALIGN_LEFT) -#define NUM (FLD_NUMBER | FLD_ALIGN_RIGHT) -#define FIELD(type, strct, sorttype, head, field, width, func, id) {type, id, (off_t)((void *)&_dummy._ ## strct.field - (void *)&_dummy._ ## strct), head, width, sorttype, &_ ## func ## _disp}, +/* Report object types */ -static struct { - report_type_t type; - const char id[32]; - off_t offset; - const char heading[32]; - int width; - uint32_t flags; - field_report_fn report_fn; -} _fields[] = { -#include "columns.h" +/* necessary for displaying something for PVs not belonging to VG */ +static struct volume_group _dummy_vg = { + .name = (char *) ORPHAN, }; -#undef STR -#undef NUM -#undef FIELD - -const unsigned int _num_fields = sizeof(_fields) / sizeof(_fields[0]); - -static void _display_fields(void) +static void *_obj_get_vg(void *obj) { - uint32_t f; - const char *type, *last_type = ""; - - for (f = 0; f < _num_fields; f++) { - switch (_fields[f].type) { - case PVS: - type = "Physical Volume"; - break; - case LVS: - type = "Logical Volume"; - break; - case VGS: - type = "Volume Group"; - break; - case SEGS: - type = "Logical Volume Segment"; - break; - case PVSEGS: - type = "Physical Volume Segment"; - break; - default: - type = " "; - } + struct volume_group *vg = ((struct lvm_report_object *)obj)->vg; - if (type != last_type) { - if (*last_type) - log_print(" "); - log_print("%s Fields", type); - } - - log_print("- %s", _fields[f].id); - - last_type = type; - } + return vg ? vg : &_dummy_vg; } -/* - * Initialise report handle - */ -static int _field_match(struct report_handle *rh, const char *field, size_t len) +static void *_obj_get_lv(void *obj) { - uint32_t f, l; - struct field_properties *fp; - - if (!len) - return 0; - - for (f = 0; f < _num_fields; f++) { - if ((!strncasecmp(_fields[f].id, field, len) && - strlen(_fields[f].id) == len) || - (l = strlen(rh->field_prefix), - !strncasecmp(rh->field_prefix, _fields[f].id, l) && - !strncasecmp(_fields[f].id + l, field, len) && - strlen(_fields[f].id) == l + len)) { - rh->type |= _fields[f].type; - if (!(fp = dm_pool_zalloc(rh->mem, sizeof(*fp)))) { - log_error("struct field_properties allocation " - "failed"); - return 0; - } - fp->field_num = f; - fp->width = _fields[f].width; - fp->flags = _fields[f].flags; - - /* Suppress snapshot percentage if not using driver */ - if (!activation() - && !strncmp(field, "snap_percent", len)) - fp->flags |= FLD_HIDDEN; - - list_add(&rh->field_props, &fp->list); - return 1; - } - } - - return 0; + return ((struct lvm_report_object *)obj)->lv; } -static int _add_sort_key(struct report_handle *rh, uint32_t field_num, - uint32_t flags) +static void *_obj_get_pv(void *obj) { - struct field_properties *fp, *found = NULL; - - list_iterate_items(fp, &rh->field_props) { - if (fp->field_num == field_num) { - found = fp; - break; - } - } - - if (!found) { - /* Add as a non-display field */ - if (!(found = dm_pool_zalloc(rh->mem, sizeof(*found)))) { - log_error("struct field_properties allocation failed"); - return 0; - } - - rh->type |= _fields[field_num].type; - found->field_num = field_num; - found->width = _fields[field_num].width; - found->flags = _fields[field_num].flags | FLD_HIDDEN; - - list_add(&rh->field_props, &found->list); - } - - if (found->flags & FLD_SORT_KEY) { - log_error("Ignoring duplicate sort field: %s", - _fields[field_num].id); - return 1; - } - - found->flags |= FLD_SORT_KEY; - found->sort_posn = rh->keys_count++; - found->flags |= flags; - - return 1; + return ((struct lvm_report_object *)obj)->pv; } -static int _key_match(struct report_handle *rh, const char *key, size_t len) +static void *_obj_get_seg(void *obj) { - uint32_t f, l; - uint32_t flags = 0; - - if (!len) - return 0; - - if (*key == '+') { - key++; - len--; - flags = FLD_ASCENDING; - } else if (*key == '-') { - key++; - len--; - flags = FLD_DESCENDING; - } else - flags = FLD_ASCENDING; - - if (!len) { - log_error("Missing sort field name"); - return 0; - } - - for (f = 0; f < _num_fields; f++) { - if ((!strncasecmp(_fields[f].id, key, len) && - strlen(_fields[f].id) == len) || - (l = strlen(rh->field_prefix), - !strncasecmp(rh->field_prefix, _fields[f].id, l) && - !strncasecmp(_fields[f].id + l, key, len) && - strlen(_fields[f].id) == l + len)) { - return _add_sort_key(rh, f, flags); - } - } - - return 0; + return ((struct lvm_report_object *)obj)->seg; } -static int _parse_options(struct report_handle *rh, const char *format) +static void *_obj_get_pvseg(void *obj) { - const char *ws; /* Word start */ - const char *we = format; /* Word end */ + return ((struct lvm_report_object *)obj)->pvseg; +} - while (*we) { - /* Allow consecutive commas */ - while (*we && *we == ',') - we++; - ws = we; - while (*we && *we != ',') - we++; - if (!_field_match(rh, ws, (size_t) (we - ws))) { - _display_fields(); - log_print(" "); - log_error("Unrecognised field: %.*s", (int) (we - ws), - ws); - return 0; - } - } +static const struct dm_report_object_type _report_types[] = { + { VGS, "Volume Group", "vg_", _obj_get_vg }, + { LVS, "Logical Volume", "lv_", _obj_get_lv }, + { PVS, "Physical Volume", "pv_", _obj_get_pv }, + { SEGS, "Logical Volume Segment", "seg_", _obj_get_seg }, + { PVSEGS, "Physical Volume Segment", "pvseg_", _obj_get_pvseg }, + { 0, "", "", NULL }, +}; - return 1; -} +/* + * Import column definitions + */ -static int _parse_keys(struct report_handle *rh, const char *keys) -{ - const char *ws; /* Word start */ - const char *we = keys; /* Word end */ +#define STR (DM_REPORT_FIELD_STRING | DM_REPORT_FIELD_ALIGN_LEFT) +#define NUM (DM_REPORT_FIELD_NUMBER | DM_REPORT_FIELD_ALIGN_RIGHT) +#define FIELD(type, strct, sorttype, head, field, width, func, id) {type, id, (off_t)((void *)&_dummy._ ## strct.field - (void *)&_dummy._ ## strct), head, width, sorttype, &_ ## func ## _disp}, - while (*we) { - /* Allow consecutive commas */ - while (*we && *we == ',') - we++; - ws = we; - while (*we && *we != ',') - we++; - if (!_key_match(rh, ws, (size_t) (we - ws))) { - log_error("Unrecognised field: %.*s", (int) (we - ws), - ws); - return 0; - } - } +static struct dm_report_field_type _fields[] = { +#include "columns.h" +{0, "", 0, "", 0, 0, NULL}, +}; - return 1; -} +#undef STR +#undef NUM +#undef FIELD void *report_init(struct cmd_context *cmd, const char *format, const char *keys, - report_type_t *report_type, const char *separator, - int aligned, int buffered, int headings) + report_type_t *report_type, const char *separator, + int aligned, int buffered, int headings) { - struct report_handle *rh; - - if (!(rh = dm_pool_zalloc(cmd->mem, sizeof(*rh)))) { - log_error("report_handle dm_pool_zalloc failed"); - return 0; - } - - rh->cmd = cmd; - rh->type = *report_type; - rh->separator = separator; + uint32_t report_flags = 0; if (aligned) - rh->flags |= RH_ALIGNED; + report_flags |= DM_REPORT_OUTPUT_ALIGNED; if (buffered) - rh->flags |= RH_BUFFERED | RH_SORT_REQUIRED; + report_flags |= DM_REPORT_OUTPUT_BUFFERED; if (headings) - rh->flags |= RH_HEADINGS; - - list_init(&rh->field_props); - list_init(&rh->rows); - - switch (rh->type) { - case PVS: - rh->field_prefix = "pv_"; - break; - case LVS: - rh->field_prefix = "lv_"; - break; - case VGS: - rh->field_prefix = "vg_"; - break; - case SEGS: - rh->field_prefix = "seg_"; - break; - case PVSEGS: - rh->field_prefix = "pvseg_"; - break; - default: - rh->field_prefix = ""; - } - - if (!(rh->mem = dm_pool_create("report", 10 * 1024))) { - log_error("Allocation of memory pool for report failed"); - return NULL; - } - - /* Generate list of fields for output based on format string & flags */ - if (!_parse_options(rh, format)) - return NULL; - - if (!_parse_keys(rh, keys)) - return NULL; - - /* Ensure options selected are compatible */ - if (rh->type & SEGS) - rh->type |= LVS; - if (rh->type & PVSEGS) - rh->type |= PVS; - if ((rh->type & LVS) && (rh->type & PVS)) { - log_error("Can't report LV and PV fields at the same time"); - return NULL; - } - - /* Change report type if fields specified makes this necessary */ - if (rh->type & SEGS) - *report_type = SEGS; - else if (rh->type & LVS) - *report_type = LVS; - else if (rh->type & PVSEGS) - *report_type = PVSEGS; - else if (rh->type & PVS) - *report_type = PVS; - - return rh; -} - -void report_free(void *handle) -{ - struct report_handle *rh = handle; - - dm_pool_destroy(rh->mem); + report_flags |= DM_REPORT_OUTPUT_HEADINGS; - return; + return dm_report_init(report_type, _report_types, _fields, format, + separator, report_flags, keys, cmd); } /* @@ -1270,303 +905,13 @@ struct logical_volume *lv, struct physical_volume *pv, struct lv_segment *seg, struct pv_segment *pvseg) { - struct report_handle *rh = handle; - struct field_properties *fp; - struct row *row; - struct field *field; - void *data = NULL; - int skip; - - if (lv && pv) { - log_error("report_object: One of *lv and *pv must be NULL!"); - return 0; - } - - if (!(row = dm_pool_zalloc(rh->mem, sizeof(*row)))) { - log_error("struct row allocation failed"); - return 0; - } - - row->rh = rh; - - if ((rh->flags & RH_SORT_REQUIRED) && - !(row->sort_fields = dm_pool_zalloc(rh->mem, sizeof(struct field *) * - rh->keys_count))) { - log_error("row sort value structure allocation failed"); - return 0; - } - - list_init(&row->fields); - list_add(&rh->rows, &row->list); - - /* For each field to be displayed, call its report_fn */ - list_iterate_items(fp, &rh->field_props) { - skip = 0; - - if (!(field = dm_pool_zalloc(rh->mem, sizeof(*field)))) { - log_error("struct field allocation failed"); - return 0; - } - field->props = fp; - - switch (_fields[fp->field_num].type) { - case LVS: - data = (void *) lv + _fields[fp->field_num].offset; - break; - case VGS: - if (!vg) { - skip = 1; - break; - } - data = (void *) vg + _fields[fp->field_num].offset; - break; - case PVS: - data = (void *) pv + _fields[fp->field_num].offset; - break; - case SEGS: - data = (void *) seg + _fields[fp->field_num].offset; - break; - case PVSEGS: - data = (void *) pvseg + _fields[fp->field_num].offset; - } - - if (skip) { - field->report_string = ""; - field->sort_value = (const void *) field->report_string; - } else if (!_fields[fp->field_num].report_fn(rh, field, data)) { - log_error("report function failed for field %s", - _fields[fp->field_num].id); - return 0; - } - - if ((strlen(field->report_string) > field->props->width)) - field->props->width = strlen(field->report_string); - - if ((rh->flags & RH_SORT_REQUIRED) && - (field->props->flags & FLD_SORT_KEY)) { - (*row->sort_fields)[field->props->sort_posn] = field; - } - list_add(&row->fields, &field->list); - } - - if (!(rh->flags & RH_BUFFERED)) - report_output(handle); - - return 1; -} - -/* - * Print row of headings - */ -static int _report_headings(void *handle) -{ - struct report_handle *rh = handle; - struct field_properties *fp; - const char *heading; - char buf[1024]; + struct lvm_report_object obj; - if (rh->flags & RH_HEADINGS_PRINTED) - return 1; - - rh->flags |= RH_HEADINGS_PRINTED; - - if (!(rh->flags & RH_HEADINGS)) - return 1; - - if (!dm_pool_begin_object(rh->mem, 128)) { - log_error("dm_pool_begin_object failed for headings"); - return 0; - } - - /* First heading line */ - list_iterate_items(fp, &rh->field_props) { - if (fp->flags & FLD_HIDDEN) - continue; - - heading = _fields[fp->field_num].heading; - if (rh->flags & RH_ALIGNED) { - if (dm_snprintf(buf, sizeof(buf), "%-*.*s", - fp->width, fp->width, heading) < 0) { - log_error("snprintf heading failed"); - dm_pool_end_object(rh->mem); - return 0; - } - if (!dm_pool_grow_object(rh->mem, buf, fp->width)) - goto bad; - } else if (!dm_pool_grow_object(rh->mem, heading, strlen(heading))) - goto bad; - - if (!list_end(&rh->field_props, &fp->list)) - if (!dm_pool_grow_object(rh->mem, rh->separator, - strlen(rh->separator))) - goto bad; - } - if (!dm_pool_grow_object(rh->mem, "\0", 1)) { - log_error("dm_pool_grow_object failed"); - goto bad; - } - log_print("%s", (char *) dm_pool_end_object(rh->mem)); - - return 1; - - bad: - log_error("Failed to generate report headings for printing"); - - return 0; -} - -/* - * Sort rows of data - */ -static int _row_compare(const void *a, const void *b) -{ - const struct row *rowa = *(const struct row **) a; - const struct row *rowb = *(const struct row **) b; - const struct field *sfa, *sfb; - int32_t cnt = -1; - - for (cnt = 0; cnt < rowa->rh->keys_count; cnt++) { - sfa = (*rowa->sort_fields)[cnt]; - sfb = (*rowb->sort_fields)[cnt]; - if (sfa->props->flags & FLD_NUMBER) { - const uint64_t numa = - *(const uint64_t *) sfa->sort_value; - const uint64_t numb = - *(const uint64_t *) sfb->sort_value; - - if (numa == numb) - continue; - - if (sfa->props->flags & FLD_ASCENDING) { - return (numa > numb) ? 1 : -1; - } else { /* FLD_DESCENDING */ - return (numa < numb) ? 1 : -1; - } - } else { /* FLD_STRING */ - const char *stra = (const char *) sfa->sort_value; - const char *strb = (const char *) sfb->sort_value; - int cmp = strcmp(stra, strb); - - if (!cmp) - continue; - - if (sfa->props->flags & FLD_ASCENDING) { - return (cmp > 0) ? 1 : -1; - } else { /* FLD_DESCENDING */ - return (cmp < 0) ? 1 : -1; - } - } - } - - return 0; /* Identical */ -} - -static int _sort_rows(struct report_handle *rh) -{ - struct row *(*rows)[]; - uint32_t count = 0; - struct row *row; - - if (!(rows = dm_pool_alloc(rh->mem, sizeof(**rows) * - list_size(&rh->rows)))) { - log_error("sort array allocation failed"); - return 0; - } - - list_iterate_items(row, &rh->rows) - (*rows)[count++] = row; - - qsort(rows, count, sizeof(**rows), _row_compare); - - list_init(&rh->rows); - while (count--) - list_add_h(&rh->rows, &(*rows)[count]->list); - - return 1; -} - -/* - * Produce report output - */ -int report_output(void *handle) -{ - struct report_handle *rh = handle; - struct list *fh, *rowh, *ftmp, *rtmp; - struct row *row = NULL; - struct field *field; - const char *repstr; - char buf[4096]; - int width; - - if (list_empty(&rh->rows)) - return 1; - - /* Sort rows */ - if ((rh->flags & RH_SORT_REQUIRED)) - _sort_rows(rh); - - /* If headings not printed yet, calculate field widths and print them */ - if (!(rh->flags & RH_HEADINGS_PRINTED)) - _report_headings(rh); - - /* Print and clear buffer */ - list_iterate_safe(rowh, rtmp, &rh->rows) { - if (!dm_pool_begin_object(rh->mem, 512)) { - log_error("dm_pool_begin_object failed for row"); - return 0; - } - row = list_item(rowh, struct row); - list_iterate_safe(fh, ftmp, &row->fields) { - field = list_item(fh, struct field); - if (field->props->flags & FLD_HIDDEN) - continue; - - repstr = field->report_string; - width = field->props->width; - if (!(rh->flags & RH_ALIGNED)) { - if (!dm_pool_grow_object(rh->mem, repstr, - strlen(repstr))) - goto bad; - } else if (field->props->flags & FLD_ALIGN_LEFT) { - if (dm_snprintf(buf, sizeof(buf), "%-*.*s", - width, width, repstr) < 0) { - log_error("snprintf repstr failed"); - dm_pool_end_object(rh->mem); - return 0; - } - if (!dm_pool_grow_object(rh->mem, buf, width)) - goto bad; - } else if (field->props->flags & FLD_ALIGN_RIGHT) { - if (dm_snprintf(buf, sizeof(buf), "%*.*s", - width, width, repstr) < 0) { - log_error("snprintf repstr failed"); - dm_pool_end_object(rh->mem); - return 0; - } - if (!dm_pool_grow_object(rh->mem, buf, width)) - goto bad; - } - - if (!list_end(&row->fields, fh)) - if (!dm_pool_grow_object(rh->mem, rh->separator, - strlen(rh->separator))) - goto bad; - list_del(&field->list); - } - if (!dm_pool_grow_object(rh->mem, "\0", 1)) { - log_error("dm_pool_grow_object failed for row"); - return 0; - } - log_print("%s", (char *) dm_pool_end_object(rh->mem)); - list_del(&row->list); - } - - if (row) - dm_pool_free(rh->mem, row); - - return 1; + obj.vg = vg; + obj.lv = lv; + obj.pv = pv; + obj.seg = seg; + obj.pvseg = pvseg; - bad: - log_error("Failed to generate row for printing"); - return 0; + return dm_report_object(handle, &obj); } --- LVM2/tools/lvmcmdlib.c 2007/01/08 14:24:20 1.3 +++ LVM2/tools/lvmcmdlib.c 2007/01/16 18:06:11 1.4 @@ -16,6 +16,7 @@ #include "tools.h" #include "lvm2cmdline.h" #include "label.h" +#include "memlock.h" #include "version.h" #include "lvm2cmd.h" --- LVM2/tools/reporter.c 2006/09/02 01:18:17 1.16 +++ LVM2/tools/reporter.c 2007/01/16 18:06:12 1.17 @@ -25,7 +25,7 @@ return ECMD_FAILED; } - if (!report_object(handle, vg, NULL, NULL, NULL, NULL)) + if (!report_object(handle, vg, NULL, NULL, NULL, NULL)); return ECMD_FAILED; check_current_backup(vg); @@ -39,7 +39,7 @@ if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv)) return ECMD_PROCESSED; - if (!report_object(handle, lv->vg, lv, NULL, NULL, NULL)) + if (!report_object(handle, lv->vg, lv, NULL, NULL, NULL)); return ECMD_FAILED; return ECMD_PROCESSED; @@ -48,7 +48,7 @@ static int _segs_single(struct cmd_context *cmd __attribute((unused)), struct lv_segment *seg, void *handle) { - if (!report_object(handle, seg->lv->vg, seg->lv, NULL, seg, NULL)) + if (!report_object(handle, seg->lv->vg, seg->lv, NULL, seg, NULL)); return ECMD_FAILED; return ECMD_PROCESSED; @@ -78,7 +78,7 @@ goto out; } - if (!report_object(handle, vg, NULL, pv, NULL, pvseg)) + if (!report_object(handle, vg, NULL, pv, NULL, pvseg)); ret = ECMD_FAILED; out: @@ -128,7 +128,7 @@ } } - if (!report_object(handle, vg, NULL, pv, NULL, NULL)) + if (!report_object(handle, vg, NULL, pv, NULL, NULL)); ret = ECMD_FAILED; out: @@ -262,6 +262,26 @@ headings))) return 0; + /* Ensure options selected are compatible */ + if (report_type & SEGS) + report_type |= LVS; + if (report_type & PVSEGS) + report_type |= PVS; + if ((report_type & LVS) && (report_type & PVS)) { + log_error("Can't report LV and PV fields at the same time"); + return 0; + } + + /* Change report type if fields specified makes this necessary */ + if (report_type & SEGS) + report_type = SEGS; + else if (report_type & LVS) + report_type = LVS; + else if (report_type & PVSEGS) + report_type = PVSEGS; + else if (report_type & PVS) + report_type = PVS; + switch (report_type) { case LVS: r = process_each_lv(cmd, argc, argv, LCK_VG_READ, report_handle, @@ -285,9 +305,9 @@ break; } - report_output(report_handle); + dm_report_output(report_handle); - report_free(report_handle); + dm_report_free(report_handle); return r; } From agk@sourceware.org Tue Jan 16 23:05:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 16 Jan 2007 23:05:00 -0000 Subject: LVM2/lib/mirror mirrored.c Message-ID: <20070116230517.13775.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-16 23:05:15 Modified files: lib/mirror : mirrored.c Log message: use updated dm_event_get_registered_device interface Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.41&r2=1.42 --- LVM2/lib/mirror/mirrored.c 2007/01/16 18:06:11 1.41 +++ LVM2/lib/mirror/mirrored.c 2007/01/16 23:05:13 1.42 @@ -394,6 +394,7 @@ struct logical_volume *lv; struct volume_group *vg; enum dm_event_mask evmask = 0; + struct dm_event_handler *dmevh; lv = seg->lv; vg = lv->vg; @@ -407,14 +408,26 @@ if (!(name = build_dm_name(vg->cmd->mem, vg->name, lv->name, NULL))) return_0; - if (!dm_event_get_registered_device(&dso, &name, &evmask, 0)) + if (!(dmevh = dm_event_handler_create())) + return_0; + + dm_event_handler_set_dso(dmevh, dso); + dm_event_handler_set_dev_name(dmevh, name); + dm_event_handler_set_event_mask(dmevh, DM_EVENT_ALL_ERRORS); + + if (dm_event_get_registered_device(dmevh, 0)) { + dm_event_handler_destroy(dmevh); return 0; + } + evmask = dm_event_handler_get_event_mask(dmevh); if (evmask & DM_EVENT_REGISTRATION_PENDING) { *pending = 1; evmask &= ~DM_EVENT_REGISTRATION_PENDING; } + dm_event_handler_destroy(dmevh); + return evmask; } From agk@sourceware.org Wed Jan 17 15:00:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 17 Jan 2007 15:00:00 -0000 Subject: LVM2/lib/mirror mirrored.c Message-ID: <20070117150057.18109.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-17 15:00:57 Modified files: lib/mirror : mirrored.c Log message: merge _target_*register_events introduce _create_dm_event_handler() Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.42&r2=1.43 --- LVM2/lib/mirror/mirrored.c 2007/01/16 23:05:13 1.42 +++ LVM2/lib/mirror/mirrored.c 2007/01/17 15:00:57 1.43 @@ -368,7 +368,7 @@ } #ifdef DMEVENTD -static int _setup_registration(struct cmd_context *cmd, char **dso) +static int _get_mirror_dso_path(struct cmd_context *cmd, char **dso) { char *path; const char *libpath; @@ -388,6 +388,29 @@ return 1; } +static struct dm_event_handler *_create_dm_event_handler(const char *dmname, + const char *dso, + enum dm_event_mask mask) +{ + struct dm_event_handler *dmevh; + + if (!(dmevh = dm_event_handler_create())) + return_0; + + if (dm_event_handler_set_dso(dmevh, dso)) + goto fail; + + if (dm_event_handler_set_dev_name(dmevh, dmname)) + goto fail; + + dm_event_handler_set_event_mask(dmevh, mask); + return dmevh; + +fail: + dm_event_handler_destroy(dmevh); + return NULL; +} + static int _target_registered(struct lv_segment *seg, int *pending) { char *dso, *name; @@ -400,21 +423,15 @@ vg = lv->vg; *pending = 0; - if (!_setup_registration(vg->cmd, &dso)) { - stack; - return 0; - } + if (!_get_mirror_dso_path(vg->cmd, &dso)) + return_0; if (!(name = build_dm_name(vg->cmd->mem, vg->name, lv->name, NULL))) return_0; - if (!(dmevh = dm_event_handler_create())) + if (!(dmevh = _create_dm_event_handler(name, dso, DM_EVENT_ALL_ERRORS))) return_0; - dm_event_handler_set_dso(dmevh, dso); - dm_event_handler_set_dev_name(dmevh, name); - dm_event_handler_set_event_mask(dmevh, DM_EVENT_ALL_ERRORS); - if (dm_event_get_registered_device(dmevh, 0)) { dm_event_handler_destroy(dmevh); return 0; @@ -432,79 +449,50 @@ } /* FIXME This gets run while suspended and performs banned operations. */ -/* FIXME Merge these two functions */ -static int _target_register_events(struct cmd_context *cmd, +static int _target_set_events(struct cmd_context *cmd, struct lv_segment *seg, - int evmask) + int evmask, int set) { char *dso, *name; struct logical_volume *lv; struct volume_group *vg; struct dm_event_handler *dmevh; + int r; lv = seg->lv; vg = lv->vg; - if (!_setup_registration(cmd, &dso)) { - stack; - return 0; - } + if (!_get_mirror_dso_path(cmd, &dso)) + return_0; if (!(name = build_dm_name(cmd->mem, vg->name, lv->name, NULL))) return_0; - if (!(dmevh = dm_event_handler_create())) + if (!(dmevh = _create_dm_event_handler(name, dso, DM_EVENT_ALL_ERRORS))) return_0; - dm_event_handler_set_dso(dmevh, dso); - dm_event_handler_set_dev_name(dmevh, name); - dm_event_handler_set_event_mask(dmevh, DM_EVENT_ALL_ERRORS); - if (!dm_event_register_handler(dmevh)) { - dm_event_handler_destroy(dmevh); - return_0; - } + r = set ? dm_event_register_handler(dmevh) : dm_event_unregister_handler(dmevh); dm_event_handler_destroy(dmevh); + if (!r) + return_0; - log_info("Registered %s for events", name); + log_info("%s %s for events", set ? "Registered" : "Unregistered", name); return 1; } -static int _target_unregister_events(struct cmd_context *cmd, +static int _target_register_events(struct cmd_context *cmd, struct lv_segment *seg, - int evmask) + int events) { - char *dso; - char *name; - struct logical_volume *lv; - struct volume_group *vg; - struct dm_event_handler *dmevh; - - lv = seg->lv; - vg = lv->vg; - - /* FIXME Remove this and use handle to avoid config file race */ - if (!_setup_registration(cmd, &dso)) - return_0; - - if (!(name = build_dm_name(cmd->mem, vg->name, lv->name, NULL))) - return_0; - - if (!(dmevh = dm_event_handler_create())) - return_0; - - dm_event_handler_set_dso(dmevh, dso); - dm_event_handler_set_dev_name(dmevh, name); - dm_event_handler_set_event_mask(dmevh, DM_EVENT_ALL_ERRORS); - if (!dm_event_unregister_handler(dmevh)) { - dm_event_handler_destroy(dmevh); - return_0; - } - dm_event_handler_destroy(dmevh); - - log_info("Unregistered %s for events", name); + return _target_set_events(cmd, seg, events, 1); +} - return 1; +static int _target_unregister_events(struct cmd_context *cmd, + struct lv_segment *seg, + int events) +{ + return _target_set_events(cmd, seg, events, 0); } #endif /* DMEVENTD */ From agk@sourceware.org Wed Jan 17 16:23:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 17 Jan 2007 16:23:00 -0000 Subject: LVM2 ./WHATS_NEW lib/config/config.c Message-ID: <20070117162259.9017.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-17 16:22:59 Modified files: . : WHATS_NEW lib/config : config.c Log message: Fix a segfault if an empty config file section encountered. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.543&r2=1.544 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/config.c.diff?cvsroot=lvm2&r1=1.51&r2=1.52 --- LVM2/WHATS_NEW 2007/01/16 18:06:10 1.543 +++ LVM2/WHATS_NEW 2007/01/17 16:22:59 1.544 @@ -1,5 +1,6 @@ Version 2.02.19 - =================================== + Fix a segfault if an empty config file section encountered. Move basic reporting functions into libdevmapper. Fix partition table processing after sparc changes (2.02.16). Fix cmdline PE range processing segfault (2.02.13). --- LVM2/lib/config/config.c 2007/01/09 23:22:31 1.51 +++ LVM2/lib/config/config.c 2007/01/17 16:22:59 1.52 @@ -853,7 +853,7 @@ const struct config_node *n = _find_first_config_node(cn1, cn2, path); /* Empty strings are ignored */ - if ((n && n->v->type == CFG_STRING) && (*n->v->v.str)) { + if ((n && n->v && n->v->type == CFG_STRING) && (*n->v->v.str)) { log_very_verbose("Setting %s to %s", path, n->v->v.str); return n->v->v.str; } From agk@sourceware.org Wed Jan 17 17:51:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 17 Jan 2007 17:51:00 -0000 Subject: LVM2 VERSION WHATS_NEW Message-ID: <20070117175152.810.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-17 17:51:52 Modified files: . : VERSION WHATS_NEW Log message: pre-release Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/VERSION.diff?cvsroot=lvm2&r1=1.138&r2=1.139 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.544&r2=1.545 --- LVM2/VERSION 2007/01/12 20:38:29 1.138 +++ LVM2/VERSION 2007/01/17 17:51:51 1.139 @@ -1 +1 @@ -2.02.19-cvs (2007-01-12) +2.02.19-cvs (2007-01-17) --- LVM2/WHATS_NEW 2007/01/17 16:22:59 1.544 +++ LVM2/WHATS_NEW 2007/01/17 17:51:51 1.545 @@ -1,4 +1,4 @@ -Version 2.02.19 - +Version 2.02.19 - 17th January 2007 =================================== Fix a segfault if an empty config file section encountered. Move basic reporting functions into libdevmapper. From agk@sourceware.org Wed Jan 17 17:56:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 17 Jan 2007 17:56:00 -0000 Subject: LVM2 VERSION WHATS_NEW Message-ID: <20070117175615.4831.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-17 17:56:15 Modified files: . : VERSION WHATS_NEW Log message: post-release Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/VERSION.diff?cvsroot=lvm2&r1=1.139&r2=1.140 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.545&r2=1.546 --- LVM2/VERSION 2007/01/17 17:51:51 1.139 +++ LVM2/VERSION 2007/01/17 17:56:15 1.140 @@ -1 +1 @@ -2.02.19-cvs (2007-01-17) +2.02.20-cvs (2007-01-17) --- LVM2/WHATS_NEW 2007/01/17 17:51:51 1.545 +++ LVM2/WHATS_NEW 2007/01/17 17:56:15 1.546 @@ -1,3 +1,6 @@ +Version 2.02.20 - +=================================== + Version 2.02.19 - 17th January 2007 =================================== Fix a segfault if an empty config file section encountered. From agk@sourceware.org Thu Jan 18 17:48:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 18 Jan 2007 17:48:00 -0000 Subject: LVM2 ./WHATS_NEW lib/report/report.c Message-ID: <20070118174830.31424.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-18 17:48:29 Modified files: . : WHATS_NEW lib/report : report.c Log message: No longer necessary to specify alignment for report fields. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.546&r2=1.547 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.51&r2=1.52 --- LVM2/WHATS_NEW 2007/01/17 17:56:15 1.546 +++ LVM2/WHATS_NEW 2007/01/18 17:48:29 1.547 @@ -1,5 +1,6 @@ Version 2.02.20 - =================================== + No longer necessary to specify alignment for report fields. Version 2.02.19 - 17th January 2007 =================================== --- LVM2/lib/report/report.c 2007/01/16 18:06:11 1.51 +++ LVM2/lib/report/report.c 2007/01/18 17:48:29 1.52 @@ -866,8 +866,8 @@ * Import column definitions */ -#define STR (DM_REPORT_FIELD_STRING | DM_REPORT_FIELD_ALIGN_LEFT) -#define NUM (DM_REPORT_FIELD_NUMBER | DM_REPORT_FIELD_ALIGN_RIGHT) +#define STR DM_REPORT_FIELD_TYPE_STRING +#define NUM DM_REPORT_FIELD_TYPE_NUMBER #define FIELD(type, strct, sorttype, head, field, width, func, id) {type, id, (off_t)((void *)&_dummy._ ## strct.field - (void *)&_dummy._ ## strct), head, width, sorttype, &_ ## func ## _disp}, static struct dm_report_field_type _fields[] = { From agk@sourceware.org Thu Jan 18 22:33:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 18 Jan 2007 22:33:00 -0000 Subject: LVM2 ./WHATS_NEW man/lvs.8 man/pvs.8 man/vgs.8 Message-ID: <20070118223325.11011.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-18 22:33:24 Modified files: . : WHATS_NEW man : lvs.8 pvs.8 vgs.8 Log message: Update reporting man pages. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.547&r2=1.548 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvs.8.diff?cvsroot=lvm2&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/pvs.8.diff?cvsroot=lvm2&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/vgs.8.diff?cvsroot=lvm2&r1=1.3&r2=1.4 --- LVM2/WHATS_NEW 2007/01/18 17:48:29 1.547 +++ LVM2/WHATS_NEW 2007/01/18 22:33:24 1.548 @@ -1,5 +1,6 @@ Version 2.02.20 - =================================== + Update reporting man pages. No longer necessary to specify alignment for report fields. Version 2.02.19 - 17th January 2007 --- LVM2/man/lvs.8 2006/05/11 20:17:17 1.4 +++ LVM2/man/lvs.8 2007/01/18 22:33:24 1.5 @@ -35,11 +35,13 @@ lv_size, seg_count, origin, snap_percent, copy_percent, move_pv, lv_tags, segtype, stripes, -stripesize, chunksize, seg_start, seg_size, seg_tags, devices. +stripesize, chunksize, seg_start, seg_size, seg_tags, devices, +regionsize, mirror_log, modules. .IP With \-\-segments, any "seg_" prefixes are optional; otherwise any "lv_" prefixes are optional. Columns mentioned in \fBvgs (8)\fP can also be chosen. +Use \fb-o help\fP to view the full list of fields available. .IP The lv_attr bits are: .RS --- LVM2/man/pvs.8 2004/11/12 15:59:08 1.2 +++ LVM2/man/pvs.8 2007/01/18 22:33:24 1.3 @@ -31,9 +31,16 @@ Comma-separated ordered list of columns. Precede the list with '+' to append to the default selection of columns. Column names are: pv_fmt, pv_uuid, pv_size, dev_size, pv_free, pv_used, pv_name, pv_attr, pv_pe_count, -pv_pe_alloc_count, pv_tags. -The "pv_" prefix is optional. Columns mentioned in \fBvgs (8)\fP can also +pv_pe_alloc_count, pv_tags, pvseg_start, pvseg_size, pe_start. +With --segments, any "pvseg_" prefixes are optional; otherwise any +"pv_" prefixes are optional. Columns mentioned in \fBvgs (8)\fP can also be chosen. The pv_attr bits are: (a)llocatable and e(x)ported. +Use \fb-o help\fP to view the full list of fields available. +.TP +.I \-\-segments +Produces one line of output for each contiguous allocation of space on each +Physical Volume, showing the start (pvseg_start) and length (pvseg_size) in +units of physical extents. .TP .I \-O, \-\-sort Comma-separated ordered list of columns to sort by. Replaces the default --- LVM2/man/vgs.8 2005/08/15 23:34:11 1.3 +++ LVM2/man/vgs.8 2007/01/18 22:33:24 1.4 @@ -38,6 +38,7 @@ or \fBlvs (8)\fP can also be chosen, but columns cannot be taken from both at the same time. The vg_attr bits are: (w)riteable, (r)eadonly, resi(z)eable, e(x)ported, (p)artial and (c)lustered. +Use \fb-o help\fP to view the full list of fields available. .TP .I \-O, \-\-sort Comma-separated ordered list of columns to sort by. Replaces the default From agk@sourceware.org Fri Jan 19 22:21:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Fri, 19 Jan 2007 22:21:00 -0000 Subject: LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ... Message-ID: <20070119222148.27021.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-19 22:21:46 Modified files: . : WHATS_NEW daemons/clvmd : lvm-functions.c lib/activate : activate.c activate.h lib/locking : cluster_locking.c locking.h lib/log : log.c log.h lib/metadata : segtype.h lib/mirror : mirrored.c tools : lvchange.c vgchange.c Log message: register->monitor etc. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.548&r2=1.549 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.25&r2=1.26 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.116&r2=1.117 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.52&r2=1.53 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/cluster_locking.c.diff?cvsroot=lvm2&r1=1.16&r2=1.17 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.29&r2=1.30 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.c.diff?cvsroot=lvm2&r1=1.35&r2=1.36 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.h.diff?cvsroot=lvm2&r1=1.32&r2=1.33 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/segtype.h.diff?cvsroot=lvm2&r1=1.15&r2=1.16 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.43&r2=1.44 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvchange.c.diff?cvsroot=lvm2&r1=1.76&r2=1.77 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.55&r2=1.56 --- LVM2/WHATS_NEW 2007/01/18 22:33:24 1.548 +++ LVM2/WHATS_NEW 2007/01/19 22:21:44 1.549 @@ -1,5 +1,6 @@ Version 2.02.20 - =================================== + Change remaining dmeventd terminology 'register' to 'monitor'. Update reporting man pages. No longer necessary to specify alignment for report fields. --- LVM2/daemons/clvmd/lvm-functions.c 2006/10/24 18:49:31 1.25 +++ LVM2/daemons/clvmd/lvm-functions.c 2007/01/19 22:21:45 1.26 @@ -325,8 +325,8 @@ if (lock_flags & LCK_MIRROR_NOSYNC_MODE) init_mirror_in_sync(1); - if (!(lock_flags & LCK_DMEVENTD_REGISTER_MODE)) - init_dmeventd_register(0); + if (!(lock_flags & LCK_DMEVENTD_MONITOR_MODE)) + init_dmeventd_monitor(0); switch (command) { case LCK_LV_EXCLUSIVE: @@ -362,8 +362,8 @@ if (lock_flags & LCK_MIRROR_NOSYNC_MODE) init_mirror_in_sync(0); - if (!(lock_flags & LCK_DMEVENTD_REGISTER_MODE)) - init_dmeventd_register(DEFAULT_DMEVENTD_MONITOR); + if (!(lock_flags & LCK_DMEVENTD_MONITOR_MODE)) + init_dmeventd_monitor(DEFAULT_DMEVENTD_MONITOR); /* clean the pool for another command */ dm_pool_empty(cmd->mem); --- LVM2/lib/activate/activate.c 2007/01/12 20:38:29 1.116 +++ LVM2/lib/activate/activate.c 2007/01/19 22:21:45 1.117 @@ -640,28 +640,23 @@ } /* - * register_dev_for_events - * - * This function uses proper error codes (but breaks convention) - * to return: - * -1 on error - * 0 if the lv's targets don't do event [un]registration - * 0 if the lv is already [un]registered -- FIXME: not implemented - * 1 if the lv had a segment which was [un]registered - * - * Returns: -1 on error + * Returns 0 if an attempt to (un)monitor the device failed. + * Returns 1 otherwise. */ -int register_dev_for_events(struct cmd_context *cmd, - struct logical_volume *lv, int do_reg) +int monitor_dev_for_events(struct cmd_context *cmd, + struct logical_volume *lv, int monitor) { #ifdef DMEVENTD - int i, pending = 0, registered; - int r = 0; + int i, pending = 0, monitored; + int r = 1; struct list *tmp; struct lv_segment *seg; - int (*reg) (struct cmd_context *c, struct lv_segment *s, int e); + int (*monitor_fn) (struct cmd_context *c, struct lv_segment *s, int e); - if (do_reg && !dmeventd_register_mode()) + /* + * Nothing to do if dmeventd configured not to be used. + */ + if (monitor && !dmeventd_monitor_mode()) return 1; list_iterate(tmp, &lv->segments) { @@ -669,57 +664,61 @@ if (!seg_monitored(seg) || (seg->status & PVMOVE)) continue; - reg = NULL; + + monitor_fn = NULL; /* Check monitoring status */ - if (seg->segtype->ops->target_registered) - registered = seg->segtype->ops->target_registered(seg, &pending); + if (seg->segtype->ops->target_monitored) + monitored = seg->segtype->ops->target_monitored(seg, &pending); else continue; /* segtype doesn't support registration */ /* * FIXME: We should really try again if pending */ - registered = (pending) ? 0 : registered; + monitored = (pending) ? 0 : monitored; - if (do_reg) { - if (registered) + if (monitor) { + if (monitored) log_verbose("%s/%s already monitored.", lv->vg->name, lv->name); - else if (seg->segtype->ops->target_register_events) - reg = seg->segtype->ops->target_register_events; + else if (seg->segtype->ops->target_monitor_events) + monitor_fn = seg->segtype->ops->target_monitor_events; } else { - if (!registered) + if (!monitored) log_verbose("%s/%s already not monitored.", lv->vg->name, lv->name); - else if (seg->segtype->ops->target_unregister_events) - reg = seg->segtype->ops->target_unregister_events; + else if (seg->segtype->ops->target_unmonitor_events) + monitor_fn = seg->segtype->ops->target_unmonitor_events; } /* Do [un]monitor */ - if (!reg) + if (!monitor_fn) continue; + log_verbose("%sonitoring %s/%s", monitor ? "M" : "Not m", lv->vg->name, lv->name); + /* FIXME specify events */ - if (!reg(cmd, seg, 0)) { - stack; - return -1; + if (!monitor_fn(cmd, seg, 0)) { + log_error("%s/%s: %s segment monitoring function failed.", + lv->vg->name, lv->name, seg->segtype->name); + return 0; } /* Check [un]monitor results */ /* Try a couple times if pending, but not forever... */ for (i = 0; i < 10; i++) { pending = 0; - registered = seg->segtype->ops->target_registered(seg, &pending); + monitored = seg->segtype->ops->target_monitored(seg, &pending); if (pending || - (!registered && do_reg) || - (registered && !do_reg)) - log_very_verbose("%s/%s %smonitoring still pending.", - lv->vg->name, lv->name, do_reg ? "" : "un"); + (!monitored && monitor) || + (monitored && !monitor)) + log_very_verbose("%s/%s %smonitoring still pending: waiting...", + lv->vg->name, lv->name, monitor ? "" : "un"); else break; sleep(1); } - r = (registered && do_reg) || (!registered && !do_reg); + r = (monitored && monitor) || (!monitored && !monitor); } return r; @@ -764,7 +763,7 @@ } } - if (register_dev_for_events(cmd, lv, 0) < 0) + if (!monitor_dev_for_events(cmd, lv, 0)) /* FIXME Consider aborting here */ stack; @@ -822,7 +821,7 @@ memlock_dec(); fs_unlock(); - if (register_dev_for_events(cmd, lv, 1) < 0) + if (!monitor_dev_for_events(cmd, lv, 1)) stack; return 1; @@ -868,7 +867,7 @@ return 0; } - if (register_dev_for_events(cmd, lv, 0) < 0) + if (!monitor_dev_for_events(cmd, lv, 0)) stack; memlock_inc(); @@ -941,7 +940,7 @@ memlock_dec(); fs_unlock(); - if (!register_dev_for_events(cmd, lv, 1) < 0) + if (!monitor_dev_for_events(cmd, lv, 1)) stack; return r; --- LVM2/lib/activate/activate.h 2006/10/03 17:55:19 1.52 +++ LVM2/lib/activate/activate.h 2007/01/19 22:21:45 1.53 @@ -86,7 +86,7 @@ int lvs_in_vg_opened(struct volume_group *vg); -int register_dev_for_events(struct cmd_context *cmd, +int monitor_dev_for_events(struct cmd_context *cmd, struct logical_volume *lv, int do_reg); /* --- LVM2/lib/locking/cluster_locking.c 2006/12/01 23:10:26 1.16 +++ LVM2/lib/locking/cluster_locking.c 2007/01/19 22:21:45 1.17 @@ -321,8 +321,8 @@ if (mirror_in_sync()) args[1] |= LCK_MIRROR_NOSYNC_MODE; - if (dmeventd_register_mode()) - args[1] |= LCK_DMEVENTD_REGISTER_MODE; + if (dmeventd_monitor_mode()) + args[1] |= LCK_DMEVENTD_MONITOR_MODE; /* * VG locks are just that: locks, and have no side effects --- LVM2/lib/locking/locking.h 2006/12/11 14:00:26 1.29 +++ LVM2/lib/locking/locking.h 2007/01/19 22:21:45 1.30 @@ -75,7 +75,7 @@ */ #define LCK_PARTIAL_MODE 0x00000001 /* Running in partial mode */ #define LCK_MIRROR_NOSYNC_MODE 0x00000002 /* Mirrors don't require sync */ -#define LCK_DMEVENTD_REGISTER_MODE 0x00000004 /* Register with dmeventd */ +#define LCK_DMEVENTD_MONITOR_MODE 0x00000004 /* Register with dmeventd */ /* --- LVM2/lib/log/log.c 2006/08/21 12:54:53 1.35 +++ LVM2/lib/log/log.c 2007/01/19 22:21:45 1.36 @@ -48,7 +48,7 @@ static char _msg_prefix[30] = " "; static int _already_logging = 0; static int _mirror_in_sync = 0; -static int _dmeventd_register = DEFAULT_DMEVENTD_MONITOR; +static int _dmeventd_monitor = DEFAULT_DMEVENTD_MONITOR; static lvm2_log_fn_t _lvm2_log_fn = NULL; @@ -189,9 +189,9 @@ _mirror_in_sync = in_sync; } -void init_dmeventd_register(int reg) +void init_dmeventd_monitor(int reg) { - _dmeventd_register = reg; + _dmeventd_monitor = reg; } void init_cmd_name(int status) @@ -268,9 +268,9 @@ return _mirror_in_sync; } -int dmeventd_register_mode(void) +int dmeventd_monitor_mode(void) { - return _dmeventd_register; + return _dmeventd_monitor; } void init_debug(int level) --- LVM2/lib/log/log.h 2006/08/01 14:56:33 1.32 +++ LVM2/lib/log/log.h 2007/01/19 22:21:45 1.33 @@ -75,7 +75,7 @@ void init_lockingfailed(int level); void init_security_level(int level); void init_mirror_in_sync(int in_sync); -void init_dmeventd_register(int reg); +void init_dmeventd_monitor(int reg); void set_cmd_name(const char *cmd_name); @@ -90,7 +90,7 @@ int lockingfailed(void); int security_level(void); int mirror_in_sync(void); -int dmeventd_register_mode(void); +int dmeventd_monitor_mode(void); /* Suppress messages to stdout/stderr (1) or everywhere (2) */ /* Returns previous setting */ --- LVM2/lib/metadata/segtype.h 2007/01/12 20:38:29 1.15 +++ LVM2/lib/metadata/segtype.h 2007/01/19 22:21:45 1.16 @@ -83,10 +83,10 @@ const struct lv_segment *seg, struct list *modules); void (*destroy) (const struct segment_type * segtype); - int (*target_registered) (struct lv_segment *seg, int *pending); - int (*target_register_events) (struct cmd_context *cmd, + int (*target_monitored) (struct lv_segment *seg, int *pending); + int (*target_monitor_events) (struct cmd_context *cmd, struct lv_segment *seg, int events); - int (*target_unregister_events) (struct cmd_context *cmd, + int (*target_unmonitor_events) (struct cmd_context *cmd, struct lv_segment *seg, int events); }; --- LVM2/lib/mirror/mirrored.c 2007/01/17 15:00:57 1.43 +++ LVM2/lib/mirror/mirrored.c 2007/01/19 22:21:45 1.44 @@ -411,7 +411,7 @@ return NULL; } -static int _target_registered(struct lv_segment *seg, int *pending) +static int _target_monitored(struct lv_segment *seg, int *pending) { char *dso, *name; struct logical_volume *lv; @@ -476,19 +476,19 @@ if (!r) return_0; - log_info("%s %s for events", set ? "Registered" : "Unregistered", name); + log_info("%s %s for events", set ? "Monitored" : "Unmonitored", name); return 1; } -static int _target_register_events(struct cmd_context *cmd, +static int _target_monitor_events(struct cmd_context *cmd, struct lv_segment *seg, int events) { return _target_set_events(cmd, seg, events, 1); } -static int _target_unregister_events(struct cmd_context *cmd, +static int _target_unmonitor_events(struct cmd_context *cmd, struct lv_segment *seg, int events) { @@ -536,9 +536,9 @@ .target_percent = _mirrored_target_percent, .target_present = _mirrored_target_present, #ifdef DMEVENTD - .target_registered = _target_registered, - .target_register_events = _target_register_events, - .target_unregister_events = _target_unregister_events, + .target_monitored = _target_monitored, + .target_monitor_events = _target_monitor_events, + .target_unmonitor_events = _target_unmonitor_events, #endif #endif .modules_needed = _mirrored_modules_needed, --- LVM2/tools/lvchange.c 2007/01/12 20:38:30 1.76 +++ LVM2/tools/lvchange.c 2007/01/19 22:21:45 1.77 @@ -80,10 +80,9 @@ return 1; } -static int lvchange_registration(struct cmd_context *cmd, - struct logical_volume *lv) +static int lvchange_monitoring(struct cmd_context *cmd, + struct logical_volume *lv) { - int r; struct lvinfo info; if (!lv_info(cmd, lv, &info, 0) || !info.exists) { @@ -91,27 +90,14 @@ return 0; } - /* do not register pvmove lv's */ + /* do not monitor pvmove lv's */ if (lv->status & PVMOVE) return 1; - log_verbose("%smonitoring logical volume \"%s\"", - (dmeventd_register_mode()) ? "" : "Not ", lv->name); - r = register_dev_for_events(cmd, lv, dmeventd_register_mode()); - - if (r < 0) { - log_error("Unable to %smonitor logical volume, %s", - (dmeventd_register_mode()) ? "" : "un", lv->name); - r = 0; - } else if (!r) { - log_verbose("Logical volume %s needs no %smonitoring, or is already %smonitored", - (dmeventd_register_mode()) ? "" : "un", - lv->name, - (dmeventd_register_mode()) ? "" : "un"); - r = 1; - } + if (!monitor_dev_for_events(cmd, lv, dmeventd_monitor_mode())) + stack; - return r; + return 1; } static int lvchange_availability(struct cmd_context *cmd, @@ -605,7 +591,7 @@ return ECMD_FAILED; } - init_dmeventd_register(arg_int_value(cmd, monitor_ARG, DEFAULT_DMEVENTD_MONITOR)); + init_dmeventd_monitor(arg_int_value(cmd, monitor_ARG, DEFAULT_DMEVENTD_MONITOR)); /* access permission change */ if (arg_count(cmd, permission_ARG)) { @@ -675,7 +661,7 @@ if (!arg_count(cmd, available_ARG) && !arg_count(cmd, refresh_ARG) && arg_count(cmd, monitor_ARG)) { - if (!lvchange_registration(cmd, lv)) + if (!lvchange_monitoring(cmd, lv)) return ECMD_FAILED; } --- LVM2/tools/vgchange.c 2007/01/12 20:38:30 1.55 +++ LVM2/tools/vgchange.c 2007/01/19 22:21:45 1.56 @@ -15,7 +15,7 @@ #include "tools.h" -static int _register_lvs_in_vg(struct cmd_context *cmd, +static int _monitor_lvs_in_vg(struct cmd_context *cmd, struct volume_group *vg, int reg) { struct lv_list *lvl; @@ -23,7 +23,6 @@ struct lvinfo info; int lv_active; int count = 0; - int r; list_iterate_items(lvl, &vg->lvs) { lv = lvl->lv; @@ -39,16 +38,9 @@ if ((lv->status & PVMOVE) || !lv_active) continue; - r = register_dev_for_events(cmd, lv, reg); - - if (r < 0) { - log_error("Failed to %s logical volume, %s", - (reg) ? "register" : "unregister", - lv->name); + if (!monitor_dev_for_events(cmd, lv, reg)) { continue; - } - - if (r) + } else count++; } @@ -114,10 +106,10 @@ int active, monitored; if ((active = lvs_in_vg_activated(vg))) { - monitored = _register_lvs_in_vg(cmd, vg, dmeventd_register_mode()); + monitored = _monitor_lvs_in_vg(cmd, vg, dmeventd_monitor_mode()); log_print("%d logical volume(s) in volume group " "\"%s\" %smonitored", - monitored, vg->name, (dmeventd_register_mode()) ? "" : "un"); + monitored, vg->name, (dmeventd_monitor_mode()) ? "" : "un"); } return ECMD_PROCESSED; @@ -154,11 +146,11 @@ if (activate && (active = lvs_in_vg_activated(vg))) { log_verbose("%d logical volume(s) in volume group \"%s\" " "already active", active, vg->name); - monitored = _register_lvs_in_vg(cmd, vg, dmeventd_register_mode()); + monitored = _monitor_lvs_in_vg(cmd, vg, dmeventd_monitor_mode()); log_verbose("%d existing logical volume(s) in volume " "group \"%s\" %smonitored", monitored, vg->name, - dmeventd_register_mode() ? "" : "un"); + dmeventd_monitor_mode() ? "" : "un"); } if (activate && _activate_lvs_in_vg(cmd, vg, available)) @@ -540,7 +532,7 @@ return ECMD_FAILED; } - init_dmeventd_register(arg_int_value(cmd, monitor_ARG, DEFAULT_DMEVENTD_MONITOR)); + init_dmeventd_monitor(arg_int_value(cmd, monitor_ARG, DEFAULT_DMEVENTD_MONITOR)); if (arg_count(cmd, available_ARG)) r = _vgchange_available(cmd, vg); From agk@sourceware.org Mon Jan 22 15:07:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Mon, 22 Jan 2007 15:07:00 -0000 Subject: LVM2 ./WHATS_NEW lib/report/report.c Message-ID: <20070122150721.15625.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-22 15:07:21 Modified files: . : WHATS_NEW lib/report : report.c Log message: Streamline dm_report_field_* interface. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.549&r2=1.550 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.52&r2=1.53 --- LVM2/WHATS_NEW 2007/01/19 22:21:44 1.549 +++ LVM2/WHATS_NEW 2007/01/22 15:07:20 1.550 @@ -1,5 +1,6 @@ Version 2.02.20 - =================================== + Streamline dm_report_field_* interface. Change remaining dmeventd terminology 'register' to 'monitor'. Update reporting man pages. No longer necessary to specify alignment for report fields. --- LVM2/lib/report/report.c 2007/01/18 17:48:29 1.52 +++ LVM2/lib/report/report.c 2007/01/22 15:07:21 1.53 @@ -66,7 +66,7 @@ struct dm_report_field *field, const void *data, void *private) { - return dm_report_field_string(rh, mem, field, data); + return dm_report_field_string(rh, field, (const char **) data); } static int _dev_name_disp(struct dm_report *rh, struct dm_pool *mem, @@ -75,7 +75,7 @@ { const char *name = dev_name(*(const struct device **) data); - return dm_report_field_string(rh, mem, field, &name); + return dm_report_field_string(rh, field, &name); } static int _devices_disp(struct dm_report *rh, struct dm_pool *mem, @@ -227,9 +227,9 @@ uint64_t minusone = UINT64_C(-1); if (lv_info(lv->vg->cmd, lv, &info, 0) && info.exists) - return dm_report_field_int(rh, mem, field, &info.major); + return dm_report_field_int(rh, field, &info.major); - return dm_report_field_int(rh, mem, field, &minusone); + return dm_report_field_uint64(rh, field, &minusone); } static int _lvkmin_disp(struct dm_report *rh, struct dm_pool *mem, @@ -241,9 +241,9 @@ uint64_t minusone = UINT64_C(-1); if (lv_info(lv->vg->cmd, lv, &info, 0) && info.exists) - return dm_report_field_int(rh, mem, field, &info.minor); + return dm_report_field_int(rh, field, &info.minor); - return dm_report_field_int(rh, mem, field, &minusone); + return dm_report_field_uint64(rh, field, &minusone); } static int _lvstatus_disp(struct dm_report *rh, struct dm_pool *mem, @@ -423,8 +423,8 @@ const struct logical_volume *lv = (const struct logical_volume *) data; if (lv_is_cow(lv)) - return dm_report_field_string(rh, mem, field, - &origin_from_cow(lv)->name); + return dm_report_field_string(rh, field, + (const char **) &origin_from_cow(lv)->name); dm_report_field_set_value(field, "", NULL); return 1; @@ -440,8 +440,8 @@ list_iterate_items(seg, &lv->segments) { if (!seg_is_mirrored(seg) || !seg->log_lv) continue; - return dm_report_field_string(rh, mem, field, - &seg->log_lv->name); + return dm_report_field_string(rh, field, + (const char **) &seg->log_lv->name); } dm_report_field_set_value(field, "", NULL); @@ -458,7 +458,7 @@ if (lv_is_visible(lv)) { repstr = lv->name; - return dm_report_field_string(rh, mem, field, &repstr); + return dm_report_field_string(rh, field, (const char **) &repstr); } len = strlen(lv->name) + 3; @@ -494,7 +494,7 @@ if (!(seg->status & PVMOVE)) continue; name = dev_name(seg_dev(seg, 0)); - return dm_report_field_string(rh, mem, field, &name); + return dm_report_field_string(rh, field, &name); } dm_report_field_set_value(field, "", NULL); @@ -708,14 +708,14 @@ struct dm_report_field *field, const void *data, void *private) { - return dm_report_field_uint32(rh, mem, field, data); + return dm_report_field_uint32(rh, field, data); } static int _int32_disp(struct dm_report *rh, struct dm_pool *mem, struct dm_report_field *field, const void *data, void *private) { - return dm_report_field_int32(rh, mem, field, data); + return dm_report_field_int32(rh, field, data); } static int _lvsegcount_disp(struct dm_report *rh, struct dm_pool *mem, From agk@sourceware.org Tue Jan 23 13:08:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 23 Jan 2007 13:08:00 -0000 Subject: LVM2 ./WHATS_NEW man/vgchange.8 man/vgcreate.8 ... Message-ID: <20070123130835.2457.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-23 13:08:34 Modified files: . : WHATS_NEW man : vgchange.8 vgcreate.8 tools : commands.h Log message: Add --clustered to man pages. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.550&r2=1.551 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/vgchange.8.diff?cvsroot=lvm2&r1=1.11&r2=1.12 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/vgcreate.8.diff?cvsroot=lvm2&r1=1.6&r2=1.7 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/commands.h.diff?cvsroot=lvm2&r1=1.93&r2=1.94 --- LVM2/WHATS_NEW 2007/01/22 15:07:20 1.550 +++ LVM2/WHATS_NEW 2007/01/23 13:08:34 1.551 @@ -1,9 +1,10 @@ Version 2.02.20 - =================================== + Add --clustered to man pages. Streamline dm_report_field_* interface. Change remaining dmeventd terminology 'register' to 'monitor'. Update reporting man pages. - No longer necessary to specify alignment for report fields. + No longer necessary to specify alignment type for report fields. Version 2.02.19 - 17th January 2007 =================================== --- LVM2/man/vgchange.8 2006/08/18 22:35:59 1.11 +++ LVM2/man/vgchange.8 2007/01/23 13:08:34 1.12 @@ -10,6 +10,7 @@ .RB [ \-A | \-\-autobackup " {" y | n }] .RB [ \-a | \-\-available " [e|l] {" y | n }] .RB [ \-\-monitor " {" y | n }] +.RB [ \-c | \-\-clustered " {" y | n }] .RB [ \-d | \-\-debug] .RB [ \-\-deltag .IR Tag ] @@ -44,12 +45,12 @@ .SH OPTIONS See \fBlvm\fP for common options. .TP -.BR \-A ", " \-\-autobackup { y | n } +.BR \-A ", " \-\-autobackup " " { y | n } Controls automatic backup of metadata after the change. See .B vgcfgbackup (8). Default is yes. .TP -.BR \-a ", " \-\-available [e|l] { y | n } +.BR \-a ", " \-\-available " " [e|l] { y | n } Controls the availability of the logical volumes in the volume group for input/output. In other words, makes the logical volumes known/unknown to the kernel. @@ -60,6 +61,14 @@ Logical volumes with single-host snapshots are always activated exclusively because they can only be used on one node at once. .TP +.BR \-c ", " \-\-clustered " " { y | n } +If clustered locking is enabled, this indicates whether this +Volume Group is shared with other nodes in the cluster or whether +it contains only local disks that are not visible on the other nodes. +If the cluster infrastructure is unavailable on a particular node at a +particular time, you may still be able to use Volume Groups that +are not marked as clustered. +.TP .BR \-\-monitor " " { y | n } Controls whether or not a mirrored logical volume is monitored by dmeventd, if it is installed. @@ -108,7 +117,7 @@ The 2.4 kernel has a limitation of 2TB per block device. .TP -.BR \-x ", " \-\-resizeable { y | n } +.BR \-x ", " \-\-resizeable " " { y | n } Enables or disables the extension/reduction of this volume group with/by physical volumes. .SH EXAMPLES --- LVM2/man/vgcreate.8 2006/04/06 21:15:14 1.6 +++ LVM2/man/vgcreate.8 2007/01/23 13:08:34 1.7 @@ -8,6 +8,7 @@ .RB [ \-\-alloc .IR AllocationPolicy ] .RB [ \-A | \-\-autobackup " {" y | n }] +.RB [ \-c | \-\-clustered " {" y | n }] .RB [ \-d | \-\-debug ] .RB [ \-h | \-\-help ] .RB [ \-l | \-\-maxlogicalvolumes @@ -33,6 +34,14 @@ .SH OPTIONS See \fBlvm\fP for common options. .TP +.BR \-c ", " \-\-clustered " " { y | n } +If clustered locking is enabled, this indicates whether this +Volume Group is shared with other nodes in the cluster or whether +it contains only local disks that are not visible on the other nodes. +If the cluster infrastructure is unavailable on a particular node at a +particular time, you may still be able to use Volume Groups that +are not marked as clustered. +.TP .BR \-l ", " \-\-maxlogicalvolumes " " \fIMaxLogicalVolumes\fR Sets the maximum number of logical volumes allowed in this volume group. --- LVM2/tools/commands.h 2007/01/09 23:22:31 1.93 +++ LVM2/tools/commands.h 2007/01/23 13:08:34 1.94 @@ -657,7 +657,7 @@ "\t[-A|--autobackup {y|n}] " "\n" "\t[--addtag Tag] " "\n" "\t[--alloc AllocationPolicy] " "\n" - "\t[-c|--clustered] " "\n" + "\t[-c|--clustered {y|n}] " "\n" "\t[-d|--debug]" "\n" "\t[-h|--help]" "\n" "\t[-l|--maxlogicalvolumes MaxLogicalVolumes]" "\n" From agk@sourceware.org Tue Jan 23 15:58:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 23 Jan 2007 15:58:00 -0000 Subject: LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ... Message-ID: <20070123155808.14964.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-23 15:58:06 Modified files: . : WHATS_NEW daemons/clvmd : lvm-functions.c lib/commands : toolcontext.c toolcontext.h tools : lvmcmdline.c Log message: Fix refresh_toolcontext() always to wipe persistent device filter cache. Add is_long_lived to toolcontext. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.551&r2=1.552 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.26&r2=1.27 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.43&r2=1.44 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.h.diff?cvsroot=lvm2&r1=1.18&r2=1.19 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.38&r2=1.39 --- LVM2/WHATS_NEW 2007/01/23 13:08:34 1.551 +++ LVM2/WHATS_NEW 2007/01/23 15:58:05 1.552 @@ -1,5 +1,7 @@ Version 2.02.20 - =================================== + Fix refresh_toolcontext() always to wipe persistent device filter cache. + Add is_long_lived to toolcontext. Add --clustered to man pages. Streamline dm_report_field_* interface. Change remaining dmeventd terminology 'register' to 'monitor'. --- LVM2/daemons/clvmd/lvm-functions.c 2007/01/19 22:21:45 1.26 +++ LVM2/daemons/clvmd/lvm-functions.c 2007/01/23 15:58:05 1.27 @@ -575,7 +575,7 @@ /* Called to initialise the LVM context of the daemon */ int init_lvm(int using_gulm) { - if (!(cmd = create_toolcontext(NULL, 0))) { + if (!(cmd = create_toolcontext(NULL, 0, 1))) { log_error("Failed to allocate command context"); return 0; } --- LVM2/lib/commands/toolcontext.c 2006/11/04 03:34:09 1.43 +++ LVM2/lib/commands/toolcontext.c 2007/01/23 15:58:05 1.44 @@ -575,7 +575,7 @@ filters[0] : composite_filter_create(nr_filt, filters); } -static int _init_filters(struct cmd_context *cmd) +static int _init_filters(struct cmd_context *cmd, unsigned load_persistent_cache) { const char *dev_cache; struct dev_filter *f3, *f4; @@ -608,8 +608,13 @@ if (!*cmd->sys_dir) cmd->dump_filter = 0; - if (!stat(dev_cache, &st) && - (st.st_ctime != config_file_timestamp(cmd->cft)) && + /* + * Only load persistent filter device cache on startup if it is newer + * than the config file and this is not a long-lived process. + */ + if (load_persistent_cache && !cmd->is_long_lived && + !stat(dev_cache, &st) && + (st.st_ctime > config_file_timestamp(cmd->cft)) && !persistent_filter_load(f4, NULL)) log_verbose("Failed to load existing device cache from %s", dev_cache); @@ -881,7 +886,8 @@ } /* Entry point */ -struct cmd_context *create_toolcontext(struct arg *the_args, unsigned is_static) +struct cmd_context *create_toolcontext(struct arg *the_args, unsigned is_static, + unsigned is_long_lived) { struct cmd_context *cmd; @@ -905,6 +911,7 @@ memset(cmd, 0, sizeof(*cmd)); cmd->args = the_args; cmd->is_static = is_static; + cmd->is_long_lived = is_long_lived; cmd->hosttags = 0; list_init(&cmd->formats); list_init(&cmd->segtypes); @@ -953,7 +960,7 @@ if (!_init_dev_cache(cmd)) goto error; - if (!_init_filters(cmd)) + if (!_init_filters(cmd, 1)) goto error; if (!(cmd->mem = dm_pool_create("command", 4 * 1024))) { @@ -1022,10 +1029,10 @@ { log_verbose("Reloading config files"); - if (cmd->config_valid) { - if (cmd->dump_filter) - persistent_filter_dump(cmd->filter); - } + /* + * Don't update the persistent filter cache as we will + * perform a full rescan. + */ activation_release(); lvmcache_destroy(); @@ -1064,7 +1071,7 @@ if (!_init_dev_cache(cmd)) return 0; - if (!_init_filters(cmd)) + if (!_init_filters(cmd, 0)) return 0; if (!_init_formats(cmd)) --- LVM2/lib/commands/toolcontext.h 2006/08/18 21:17:18 1.18 +++ LVM2/lib/commands/toolcontext.h 2007/01/23 15:58:06 1.19 @@ -65,6 +65,7 @@ struct arg *args; char **argv; unsigned is_static; /* Static binary? */ + unsigned is_long_lived; /* Optimises persistent_filter handling */ struct dev_filter *filter; int dump_filter; /* Dump filter when exiting? */ @@ -88,7 +89,7 @@ char proc_dir[PATH_MAX]; }; -struct cmd_context *create_toolcontext(struct arg *the_args, unsigned is_static); +struct cmd_context *create_toolcontext(struct arg *the_args, unsigned is_static, unsigned is_long_lived); void destroy_toolcontext(struct cmd_context *cmd); int refresh_toolcontext(struct cmd_context *cmd); int config_files_changed(struct cmd_context *cmd); --- LVM2/tools/lvmcmdline.c 2006/11/14 15:28:50 1.38 +++ LVM2/tools/lvmcmdline.c 2007/01/23 15:58:06 1.39 @@ -1030,7 +1030,7 @@ { struct cmd_context *cmd; - if (!(cmd = create_toolcontext(&the_args[0], is_static))) { + if (!(cmd = create_toolcontext(&the_args[0], is_static, 0))) { stack; return NULL; } From agk@sourceware.org Tue Jan 23 16:03:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 23 Jan 2007 16:03:00 -0000 Subject: LVM2 ./WHATS_NEW lib/commands/toolcontext.c Message-ID: <20070123160354.18078.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-23 16:03:54 Modified files: . : WHATS_NEW lib/commands : toolcontext.c Log message: Long-lived processes write out persistent dev cache in refresh_toolcontext(). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.552&r2=1.553 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.44&r2=1.45 --- LVM2/WHATS_NEW 2007/01/23 15:58:05 1.552 +++ LVM2/WHATS_NEW 2007/01/23 16:03:53 1.553 @@ -1,5 +1,6 @@ Version 2.02.20 - =================================== + Long-lived processes write out persistent dev cache in refresh_toolcontext(). Fix refresh_toolcontext() always to wipe persistent device filter cache. Add is_long_lived to toolcontext. Add --clustered to man pages. --- LVM2/lib/commands/toolcontext.c 2007/01/23 15:58:05 1.44 +++ LVM2/lib/commands/toolcontext.c 2007/01/23 16:03:54 1.45 @@ -1080,6 +1080,13 @@ if (!_init_segtypes(cmd)) return 0; + /* + * If we are a long-lived process, write out the updated persistent + * device cache for the benefit of short-lived processes. + */ + if (cmd->is_long_lived && cmd->dump_filter) + persistent_filter_dump(cmd->filter); + cmd->config_valid = 1; return 1; } From agk@sourceware.org Tue Jan 23 17:40:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 23 Jan 2007 17:40:00 -0000 Subject: LVM2 ./WHATS_NEW dmeventd/mirror/dmeventd_mirror.c Message-ID: <20070123174040.28112.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-23 17:40:40 Modified files: . : WHATS_NEW dmeventd/mirror: dmeventd_mirror.c Log message: Add private variable to dmeventd shared library interface. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.553&r2=1.554 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/dmeventd/mirror/dmeventd_mirror.c.diff?cvsroot=lvm2&r1=1.15&r2=1.16 --- LVM2/WHATS_NEW 2007/01/23 16:03:53 1.553 +++ LVM2/WHATS_NEW 2007/01/23 17:40:40 1.554 @@ -1,5 +1,6 @@ Version 2.02.20 - =================================== + Add private variable to dmeventd shared library interface. Long-lived processes write out persistent dev cache in refresh_toolcontext(). Fix refresh_toolcontext() always to wipe persistent device filter cache. Add is_long_lived to toolcontext. --- LVM2/dmeventd/mirror/dmeventd_mirror.c 2007/01/15 18:22:01 1.15 +++ LVM2/dmeventd/mirror/dmeventd_mirror.c 2007/01/23 17:40:40 1.16 @@ -164,7 +164,8 @@ return (r == 1) ? 0 : -1; } -void process_event(struct dm_task *dmt, enum dm_event_mask event) +void process_event(struct dm_task *dmt, enum dm_event_mask event, + void **unused __attribute((unused))) { void *next = NULL; uint64_t start, length; @@ -221,7 +222,8 @@ pthread_mutex_unlock(&_event_mutex); } -int register_device(const char *device, const char *uuid, int major, int minor) +int register_device(const char *device, const char *uuid, int major, int minor, + void **unused __attribute((unused))) { int r = 0; @@ -257,7 +259,8 @@ return r; } -int unregister_device(const char *device, const char *uuid, int major, int minor) +int unregister_device(const char *device, const char *uuid, int major, int minor, + void **unused __attribute((unused))) { pthread_mutex_lock(&_register_mutex); From agk@sourceware.org Wed Jan 24 16:51:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 24 Jan 2007 16:51:00 -0000 Subject: LVM2 ./WHATS_NEW lib/activate/activate.c lib/m ... Message-ID: <20070124165125.22681.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-24 16:51:24 Modified files: . : WHATS_NEW lib/activate : activate.c lib/metadata : segtype.h lib/mirror : mirrored.c lib/report : columns.h report.c Log message: Add field definitions to report help text. Remove unnecessary cmd arg from target_*monitor_events(). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.554&r2=1.555 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.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.16&r2=1.17 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.44&r2=1.45 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/columns.h.diff?cvsroot=lvm2&r1=1.18&r2=1.19 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.53&r2=1.54 --- LVM2/WHATS_NEW 2007/01/23 17:40:40 1.554 +++ LVM2/WHATS_NEW 2007/01/24 16:51:23 1.555 @@ -1,5 +1,7 @@ Version 2.02.20 - =================================== + Add field definitions to report help text. + Remove unnecessary cmd arg from target_*monitor_events(). Add private variable to dmeventd shared library interface. Long-lived processes write out persistent dev cache in refresh_toolcontext(). Fix refresh_toolcontext() always to wipe persistent device filter cache. --- LVM2/lib/activate/activate.c 2007/01/19 22:21:45 1.117 +++ LVM2/lib/activate/activate.c 2007/01/24 16:51:23 1.118 @@ -697,7 +697,7 @@ log_verbose("%sonitoring %s/%s", monitor ? "M" : "Not m", lv->vg->name, lv->name); /* FIXME specify events */ - if (!monitor_fn(cmd, seg, 0)) { + if (!monitor_fn(seg, 0)) { log_error("%s/%s: %s segment monitoring function failed.", lv->vg->name, lv->name, seg->segtype->name); return 0; --- LVM2/lib/metadata/segtype.h 2007/01/19 22:21:45 1.16 +++ LVM2/lib/metadata/segtype.h 2007/01/24 16:51:24 1.17 @@ -84,10 +84,8 @@ struct list *modules); void (*destroy) (const struct segment_type * segtype); int (*target_monitored) (struct lv_segment *seg, int *pending); - int (*target_monitor_events) (struct cmd_context *cmd, - struct lv_segment *seg, int events); - int (*target_unmonitor_events) (struct cmd_context *cmd, - struct lv_segment *seg, int events); + int (*target_monitor_events) (struct lv_segment *seg, int events); + int (*target_unmonitor_events) (struct lv_segment *seg, int events); }; struct segment_type *get_segtype_from_string(struct cmd_context *cmd, --- LVM2/lib/mirror/mirrored.c 2007/01/19 22:21:45 1.44 +++ LVM2/lib/mirror/mirrored.c 2007/01/24 16:51:24 1.45 @@ -449,9 +449,7 @@ } /* FIXME This gets run while suspended and performs banned operations. */ -static int _target_set_events(struct cmd_context *cmd, - struct lv_segment *seg, - int evmask, int set) +static int _target_set_events(struct lv_segment *seg, int evmask, int set) { char *dso, *name; struct logical_volume *lv; @@ -462,10 +460,10 @@ lv = seg->lv; vg = lv->vg; - if (!_get_mirror_dso_path(cmd, &dso)) + if (!_get_mirror_dso_path(vg->cmd, &dso)) return_0; - if (!(name = build_dm_name(cmd->mem, vg->name, lv->name, NULL))) + if (!(name = build_dm_name(vg->cmd->mem, vg->name, lv->name, NULL))) return_0; if (!(dmevh = _create_dm_event_handler(name, dso, DM_EVENT_ALL_ERRORS))) @@ -481,18 +479,14 @@ return 1; } -static int _target_monitor_events(struct cmd_context *cmd, - struct lv_segment *seg, - int events) +static int _target_monitor_events(struct lv_segment *seg, int events) { - return _target_set_events(cmd, seg, events, 1); + return _target_set_events(seg, events, 1); } -static int _target_unmonitor_events(struct cmd_context *cmd, - struct lv_segment *seg, - int events) +static int _target_unmonitor_events(struct lv_segment *seg, int events) { - return _target_set_events(cmd, seg, events, 0); + return _target_set_events(seg, events, 0); } #endif /* DMEVENTD */ --- LVM2/lib/report/columns.h 2006/10/07 10:42:27 1.18 +++ LVM2/lib/report/columns.h 2007/01/24 16:51:24 1.19 @@ -18,67 +18,67 @@ * Display Fn, Unique format identifier */ /* *INDENT-OFF* */ -FIELD(LVS, lv, STR, "LV UUID", lvid.id[1], 38, uuid, "lv_uuid") -FIELD(LVS, lv, STR, "LV", lvid, 4, lvname, "lv_name") -FIELD(LVS, lv, STR, "Attr", lvid, 4, lvstatus, "lv_attr") -FIELD(LVS, lv, NUM, "Maj", major, 3, int32, "lv_major") -FIELD(LVS, lv, NUM, "Min", minor, 3, int32, "lv_minor") -FIELD(LVS, lv, STR, "KMaj", lvid, 4, lvkmaj, "lv_kernel_major") -FIELD(LVS, lv, STR, "KMin", lvid, 4, lvkmin, "lv_kernel_minor") -FIELD(LVS, lv, NUM, "LSize", size, 5, size64, "lv_size") -FIELD(LVS, lv, NUM, "#Seg", lvid, 4, lvsegcount, "seg_count") -FIELD(LVS, lv, STR, "Origin", lvid, 6, origin, "origin") -FIELD(LVS, lv, NUM, "Snap%", lvid, 6, snpercent, "snap_percent") -FIELD(LVS, lv, NUM, "Copy%", lvid, 6, copypercent, "copy_percent") -FIELD(LVS, lv, STR, "Move", lvid, 4, movepv, "move_pv") -FIELD(LVS, lv, STR, "LV Tags", tags, 7, tags, "lv_tags") -FIELD(LVS, lv, STR, "Log", lvid, 3, loglv, "mirror_log") -FIELD(LVS, lv, STR, "Modules", lvid, 7, modules, "modules") +FIELD(LVS, lv, STR, "LV UUID", lvid.id[1], 38, uuid, "lv_uuid", "Unique identifier") +FIELD(LVS, lv, STR, "LV", lvid, 4, lvname, "lv_name", "Name. LVs created for internal use are enclosed in brackets.") +FIELD(LVS, lv, STR, "Attr", lvid, 4, lvstatus, "lv_attr", "Various attributes - see man page.") +FIELD(LVS, lv, NUM, "Maj", major, 3, int32, "lv_major", "Persistent major number or -1 if not persistent.") +FIELD(LVS, lv, NUM, "Min", minor, 3, int32, "lv_minor", "Persistent minor number or -1 if not persistent.") +FIELD(LVS, lv, STR, "KMaj", lvid, 4, lvkmaj, "lv_kernel_major", "Currently assigned major number or -1 if LV is not active.") +FIELD(LVS, lv, STR, "KMin", lvid, 4, lvkmin, "lv_kernel_minor", "Currently assigned minor number or -1 if LV is not active.") +FIELD(LVS, lv, NUM, "LSize", size, 5, size64, "lv_size", "Size of LV in current units.") +FIELD(LVS, lv, NUM, "#Seg", lvid, 4, lvsegcount, "seg_count", "Number of segments in LV.") +FIELD(LVS, lv, STR, "Origin", lvid, 6, origin, "origin", "For snapshots, the origin device of this LV") +FIELD(LVS, lv, NUM, "Snap%", lvid, 6, snpercent, "snap_percent", "For snapshots, the percentage full if LV is active.") +FIELD(LVS, lv, NUM, "Copy%", lvid, 6, copypercent, "copy_percent", "For mirrors and pvmove, current percentage in-sync.") +FIELD(LVS, lv, STR, "Move", lvid, 4, movepv, "move_pv", "For pvmove, Source PV of temporary LV created by pvmove") +FIELD(LVS, lv, STR, "LV Tags", tags, 7, tags, "lv_tags", "Tags, if any.") +FIELD(LVS, lv, STR, "Log", lvid, 3, loglv, "mirror_log", "For mirrors, the LV holding the synchronisation log.") +FIELD(LVS, lv, STR, "Modules", lvid, 7, modules, "modules", "Kernel device-mapper modules required for this LV.") -FIELD(PVS, pv, STR, "Fmt", id, 3, pvfmt, "pv_fmt") -FIELD(PVS, pv, STR, "PV UUID", id, 38, uuid, "pv_uuid") -FIELD(PVS, pv, NUM, "PSize", id, 5, pvsize, "pv_size") -FIELD(PVS, pv, NUM, "DevSize", dev, 7, devsize, "dev_size") -FIELD(PVS, pv, NUM, "1st PE", pe_start, 7, size64, "pe_start") -FIELD(PVS, pv, NUM, "PFree", id, 5, pvfree, "pv_free") -FIELD(PVS, pv, NUM, "Used", id, 4, pvused, "pv_used") -FIELD(PVS, pv, STR, "PV", dev, 10, dev_name, "pv_name") -FIELD(PVS, pv, STR, "Attr", status, 4, pvstatus, "pv_attr") -FIELD(PVS, pv, NUM, "PE", pe_count, 3, uint32, "pv_pe_count") -FIELD(PVS, pv, NUM, "Alloc", pe_alloc_count, 5, uint32, "pv_pe_alloc_count") -FIELD(PVS, pv, STR, "PV Tags", tags, 7, tags, "pv_tags") +FIELD(PVS, pv, STR, "Fmt", id, 3, pvfmt, "pv_fmt", "Type of metadata.") +FIELD(PVS, pv, STR, "PV UUID", id, 38, uuid, "pv_uuid", "Unique identifier.") +FIELD(PVS, pv, NUM, "PSize", id, 5, pvsize, "pv_size", "Size of PV in current units.") +FIELD(PVS, pv, NUM, "DevSize", dev, 7, devsize, "dev_size", "Size of underlying device in current units.") +FIELD(PVS, pv, NUM, "1st PE", pe_start, 7, size64, "pe_start", "Offset to the start of data on the underlying device.") +FIELD(PVS, pv, NUM, "PFree", id, 5, pvfree, "pv_free", "Total amount of unallocated space in current units.") +FIELD(PVS, pv, NUM, "Used", id, 4, pvused, "pv_used", "Total amount of allocated space in current units.") +FIELD(PVS, pv, STR, "PV", dev, 10, dev_name, "pv_name", "Name.") +FIELD(PVS, pv, STR, "Attr", status, 4, pvstatus, "pv_attr", "Various attributes - see man page.") +FIELD(PVS, pv, NUM, "PE", pe_count, 3, uint32, "pv_pe_count", "Total number of Physical Extents.") +FIELD(PVS, pv, NUM, "Alloc", pe_alloc_count, 5, uint32, "pv_pe_alloc_count", "Total number of allocated Physical Extents.") +FIELD(PVS, pv, STR, "PV Tags", tags, 7, tags, "pv_tags", "Tags, if any.") -FIELD(VGS, vg, STR, "Fmt", cmd, 3, vgfmt, "vg_fmt") -FIELD(VGS, vg, STR, "VG UUID", id, 38, uuid, "vg_uuid") -FIELD(VGS, vg, STR, "VG", name, 4, string, "vg_name") -FIELD(VGS, vg, STR, "Attr", cmd, 5, vgstatus, "vg_attr") -FIELD(VGS, vg, NUM, "VSize", cmd, 5, vgsize, "vg_size") -FIELD(VGS, vg, NUM, "VFree", cmd, 5, vgfree, "vg_free") -FIELD(VGS, vg, STR, "SYS ID", system_id, 6, string, "vg_sysid") -FIELD(VGS, vg, NUM, "Ext", extent_size, 3, size32, "vg_extent_size") -FIELD(VGS, vg, NUM, "#Ext", extent_count, 4, uint32, "vg_extent_count") -FIELD(VGS, vg, NUM, "Free", free_count, 4, uint32, "vg_free_count") -FIELD(VGS, vg, NUM, "MaxLV", max_lv, 5, uint32, "max_lv") -FIELD(VGS, vg, NUM, "MaxPV", max_pv, 5, uint32, "max_pv") -FIELD(VGS, vg, NUM, "#PV", pv_count, 3, uint32, "pv_count") -FIELD(VGS, vg, NUM, "#LV", lv_count, 3, uint32, "lv_count") -FIELD(VGS, vg, NUM, "#SN", snapshot_count, 3, uint32, "snap_count") -FIELD(VGS, vg, NUM, "Seq", seqno, 3, uint32, "vg_seqno") -FIELD(VGS, vg, STR, "VG Tags", tags, 7, tags, "vg_tags") +FIELD(VGS, vg, STR, "Fmt", cmd, 3, vgfmt, "vg_fmt", "Type of metadata.") +FIELD(VGS, vg, STR, "VG UUID", id, 38, uuid, "vg_uuid", "Unique identifier.") +FIELD(VGS, vg, STR, "VG", name, 4, string, "vg_name", "Name.") +FIELD(VGS, vg, STR, "Attr", cmd, 5, vgstatus, "vg_attr", "Various attributes - see man page.") +FIELD(VGS, vg, NUM, "VSize", cmd, 5, vgsize, "vg_size", "Total size of VG in current units.") +FIELD(VGS, vg, NUM, "VFree", cmd, 5, vgfree, "vg_free", "Total amount of free space in current units.") +FIELD(VGS, vg, STR, "SYS ID", system_id, 6, string, "vg_sysid", "System ID indicating when and where it was created.") +FIELD(VGS, vg, NUM, "Ext", extent_size, 3, size32, "vg_extent_size", "Size of Physical Extents in current units.") +FIELD(VGS, vg, NUM, "#Ext", extent_count, 4, uint32, "vg_extent_count", "Total number of Physical Extents.") +FIELD(VGS, vg, NUM, "Free", free_count, 4, uint32, "vg_free_count", "Total number of unallocated Physical Extents.") +FIELD(VGS, vg, NUM, "MaxLV", max_lv, 5, uint32, "max_lv", "Maximum number of LVs allowed in VG or 0 if unlimited.") +FIELD(VGS, vg, NUM, "MaxPV", max_pv, 5, uint32, "max_pv", "Maximum number of PVs allowed in VG or 0 if unlimited.") +FIELD(VGS, vg, NUM, "#PV", pv_count, 3, uint32, "pv_count", "Number of PVs.") +FIELD(VGS, vg, NUM, "#LV", lv_count, 3, uint32, "lv_count", "Number of LVs.") +FIELD(VGS, vg, NUM, "#SN", snapshot_count, 3, uint32, "snap_count", "Number of snapshots.") +FIELD(VGS, vg, NUM, "Seq", seqno, 3, uint32, "vg_seqno", "Revision number of internal metadata. Incremented whenever it changes.") +FIELD(VGS, vg, STR, "VG Tags", tags, 7, tags, "vg_tags", "Tags, if any.") -FIELD(SEGS, seg, STR, "Type", list, 4, segtype, "segtype") -FIELD(SEGS, seg, NUM, "#Str", area_count, 4, uint32, "stripes") -FIELD(SEGS, seg, NUM, "Stripe", stripe_size, 6, size32, "stripesize") -FIELD(SEGS, seg, NUM, "Stripe", stripe_size, 6, size32, "stripe_size") -FIELD(SEGS, seg, NUM, "Chunk", list, 5, chunksize, "chunksize") -FIELD(SEGS, seg, NUM, "Chunk", list, 5, chunksize, "chunk_size") -FIELD(SEGS, seg, NUM, "Region", region_size, 6, size32, "regionsize") -FIELD(SEGS, seg, NUM, "Region", region_size, 6, size32, "region_size") -FIELD(SEGS, seg, NUM, "Start", list, 5, segstart, "seg_start") -FIELD(SEGS, seg, NUM, "SSize", list, 5, segsize, "seg_size") -FIELD(SEGS, seg, STR, "Seg Tags", tags, 8, tags, "seg_tags") -FIELD(SEGS, seg, STR, "Devices", list, 5, devices, "devices") +FIELD(SEGS, seg, STR, "Type", list, 4, segtype, "segtype", "Type of LV segment") +FIELD(SEGS, seg, NUM, "#Str", area_count, 4, uint32, "stripes", "Number of stripes or mirror legs.") +FIELD(SEGS, seg, NUM, "Stripe", stripe_size, 6, size32, "stripesize", "For stripes, amount of data placed on one device before switching to the next.") +FIELD(SEGS, seg, NUM, "Stripe", stripe_size, 6, size32, "stripe_size", "For stripes, amount of data placed on one device before switching to the next.") +FIELD(SEGS, seg, NUM, "Region", region_size, 6, size32, "regionsize", "For mirrors, the unit of data copied when synchronising devices.") +FIELD(SEGS, seg, NUM, "Region", region_size, 6, size32, "region_size", "For mirrors, the unit of data copied when synchronising devices.") +FIELD(SEGS, seg, NUM, "Chunk", list, 5, chunksize, "chunksize", "For snapshots, the unit of data used when tracking changes.") +FIELD(SEGS, seg, NUM, "Chunk", list, 5, chunksize, "chunk_size", "For snapshots, the unit of data used when tracking changes.") +FIELD(SEGS, seg, NUM, "Start", list, 5, segstart, "seg_start", "Offset within the LV to the start of the segment in current units.") +FIELD(SEGS, seg, NUM, "SSize", list, 5, segsize, "seg_size", "Size of segment in current units.") +FIELD(SEGS, seg, STR, "Seg Tags", tags, 8, tags, "seg_tags", "Tags, if any.") +FIELD(SEGS, seg, STR, "Devices", list, 5, devices, "devices", "Underlying devices used with starting extent numbers.") -FIELD(PVSEGS, pvseg, NUM, "Start", pe, 5, uint32, "pvseg_start") -FIELD(PVSEGS, pvseg, NUM, "SSize", len, 5, uint32, "pvseg_size") +FIELD(PVSEGS, pvseg, NUM, "Start", pe, 5, uint32, "pvseg_start", "Physical Extent number of start of segment.") +FIELD(PVSEGS, pvseg, NUM, "SSize", len, 5, uint32, "pvseg_size", "Number of extents in segment.") /* *INDENT-ON* */ --- LVM2/lib/report/report.c 2007/01/22 15:07:21 1.53 +++ LVM2/lib/report/report.c 2007/01/24 16:51:24 1.54 @@ -868,11 +868,11 @@ #define STR DM_REPORT_FIELD_TYPE_STRING #define NUM DM_REPORT_FIELD_TYPE_NUMBER -#define FIELD(type, strct, sorttype, head, field, width, func, id) {type, id, (off_t)((void *)&_dummy._ ## strct.field - (void *)&_dummy._ ## strct), head, width, sorttype, &_ ## func ## _disp}, +#define FIELD(type, strct, sorttype, head, field, width, func, id, desc) {type, id, (off_t)((void *)&_dummy._ ## strct.field - (void *)&_dummy._ ## strct), head, width, sorttype, &_ ## func ## _disp, desc}, static struct dm_report_field_type _fields[] = { #include "columns.h" -{0, "", 0, "", 0, 0, NULL}, +{0, "", 0, "", 0, 0, NULL, NULL}, }; #undef STR From agk@sourceware.org Wed Jan 24 22:06:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 24 Jan 2007 22:06:00 -0000 Subject: LVM2/lib/activate activate.c Message-ID: <20070124220613.21129.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-24 22:06:12 Modified files: lib/activate : activate.c Log message: fix earlier checkin Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.118&r2=1.119 --- LVM2/lib/activate/activate.c 2007/01/24 16:51:23 1.118 +++ LVM2/lib/activate/activate.c 2007/01/24 22:06:11 1.119 @@ -651,7 +651,7 @@ int r = 1; struct list *tmp; struct lv_segment *seg; - int (*monitor_fn) (struct cmd_context *c, struct lv_segment *s, int e); + int (*monitor_fn) (struct lv_segment *s, int e); /* * Nothing to do if dmeventd configured not to be used. From agk@sourceware.org Wed Jan 24 23:43:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 24 Jan 2007 23:43:00 -0000 Subject: LVM2 ./WHATS_NEW lib/activate/activate.c lib/l ... Message-ID: <20070124234328.21279.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-24 23:43:27 Modified files: . : WHATS_NEW lib/activate : activate.c lib/log : log.h tools : lvchange.c vgchange.c Added files: scripts : lvm2_monitoring_init_rhel4 Log message: lvm.static no longer interacts with dmeventd unless explicitly asked to. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.555&r2=1.556 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.119&r2=1.120 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.h.diff?cvsroot=lvm2&r1=1.33&r2=1.34 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/lvm2_monitoring_init_rhel4.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvchange.c.diff?cvsroot=lvm2&r1=1.77&r2=1.78 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.56&r2=1.57 --- LVM2/WHATS_NEW 2007/01/24 16:51:23 1.555 +++ LVM2/WHATS_NEW 2007/01/24 23:43:26 1.556 @@ -1,5 +1,6 @@ Version 2.02.20 - =================================== + lvm.static no longer interacts with dmeventd unless explicitly asked to. Add field definitions to report help text. Remove unnecessary cmd arg from target_*monitor_events(). Add private variable to dmeventd shared library interface. --- LVM2/lib/activate/activate.c 2007/01/24 22:06:11 1.119 +++ LVM2/lib/activate/activate.c 2007/01/24 23:43:27 1.120 @@ -653,6 +653,10 @@ struct lv_segment *seg; int (*monitor_fn) (struct lv_segment *s, int e); + /* skip dmeventd code altogether */ + if (dmeventd_monitor_mode() == DMEVENTD_MONITOR_IGNORE) + return 1; + /* * Nothing to do if dmeventd configured not to be used. */ --- LVM2/lib/log/log.h 2007/01/19 22:21:45 1.33 +++ LVM2/lib/log/log.h 2007/01/24 23:43:27 1.34 @@ -90,6 +90,8 @@ int lockingfailed(void); int security_level(void); int mirror_in_sync(void); + +#define DMEVENTD_MONITOR_IGNORE -1 int dmeventd_monitor_mode(void); /* Suppress messages to stdout/stderr (1) or everywhere (2) */ /cvs/lvm2/LVM2/scripts/lvm2_monitoring_init_rhel4,v --> standard output revision 1.1 --- LVM2/scripts/lvm2_monitoring_init_rhel4 +++ - 2007-01-24 23:43:28.352868000 +0000 @@ -0,0 +1,98 @@ +#!/bin/bash +# +# Copyright (C) 2007 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 +# +# This file is part of LVM2. +# It is required for the proper handling of failures of LVM2 mirror +# devices that were created using the -m option of lvcreate. +# +# +# chkconfig: 12345 02 99 +# description: Starts and stops dmeventd monitoring for lvm2 +# +### BEGIN INIT INFO +# Provides: +### END INIT INFO + +. /etc/init.d/functions + +VGCHANGE="/usr/sbin/vgchange" + +start() +{ + for ret in 0 + do + # TODO do we want to separate out already active groups only? + VGS=`vgs --noheadings -o name` + for vg in $VGS + do + if ! action "Starting monitoring for VG $vg:" $VGCHANGE --monitor y $vg + then + ret=$? + fi + done + + done + + return $ret +} + + +stop() +{ + for ret in 0 + do + # TODO do we want to separate out already active groups only? + VGS=`vgs --noheadings -o name` + for vg in $VGS + do + if ! action "Starting monitoring for VG $vg:" $VGCHANGE --monitor n $vg + then + ret=$? + fi + done + + done + +} + +ret=1 + +# See how we were called. +case "$1" in + start) + start + ret=$? + ;; + + stop) + stop + ret=$? + ;; + + restart) + if stop + then + start + fi + ret=$? + ;; + + status) + # TODO anyone with an idea how to dump monitored volumes? + ;; + + *) + echo $"Usage: $0 {start|stop|restart|status}" + ;; +esac + +exit $ret --- LVM2/tools/lvchange.c 2007/01/19 22:21:45 1.77 +++ LVM2/tools/lvchange.c 2007/01/24 23:43:27 1.78 @@ -94,7 +94,8 @@ if (lv->status & PVMOVE) return 1; - if (!monitor_dev_for_events(cmd, lv, dmeventd_monitor_mode())) + if ((dmeventd_monitor_mode() != DMEVENTD_MONITOR_IGNORE) && + !monitor_dev_for_events(cmd, lv, dmeventd_monitor_mode())) stack; return 1; @@ -591,7 +592,9 @@ return ECMD_FAILED; } - init_dmeventd_monitor(arg_int_value(cmd, monitor_ARG, DEFAULT_DMEVENTD_MONITOR)); + init_dmeventd_monitor(arg_int_value(cmd, monitor_ARG, + cmd->is_static ? + DMEVENTD_MONITOR_IGNORE : DEFAULT_DMEVENTD_MONITOR)); /* access permission change */ if (arg_count(cmd, permission_ARG)) { --- LVM2/tools/vgchange.c 2007/01/19 22:21:45 1.56 +++ LVM2/tools/vgchange.c 2007/01/24 23:43:27 1.57 @@ -105,7 +105,8 @@ { int active, monitored; - if ((active = lvs_in_vg_activated(vg))) { + if ((active = lvs_in_vg_activated(vg)) && + dmeventd_monitor_mode() != DMEVENTD_MONITOR_IGNORE) { monitored = _monitor_lvs_in_vg(cmd, vg, dmeventd_monitor_mode()); log_print("%d logical volume(s) in volume group " "\"%s\" %smonitored", @@ -146,11 +147,13 @@ if (activate && (active = lvs_in_vg_activated(vg))) { log_verbose("%d logical volume(s) in volume group \"%s\" " "already active", active, vg->name); - monitored = _monitor_lvs_in_vg(cmd, vg, dmeventd_monitor_mode()); - log_verbose("%d existing logical volume(s) in volume " - "group \"%s\" %smonitored", - monitored, vg->name, - dmeventd_monitor_mode() ? "" : "un"); + if (dmeventd_monitor_mode() != DMEVENTD_MONITOR_IGNORE) { + monitored = _monitor_lvs_in_vg(cmd, vg, dmeventd_monitor_mode()); + log_verbose("%d existing logical volume(s) in volume " + "group \"%s\" %smonitored", + monitored, vg->name, + dmeventd_monitor_mode() ? "" : "un"); + } } if (activate && _activate_lvs_in_vg(cmd, vg, available)) @@ -532,7 +535,9 @@ return ECMD_FAILED; } - init_dmeventd_monitor(arg_int_value(cmd, monitor_ARG, DEFAULT_DMEVENTD_MONITOR)); + init_dmeventd_monitor(arg_int_value(cmd, monitor_ARG, + cmd->is_static ? + DMEVENTD_MONITOR_IGNORE : DEFAULT_DMEVENTD_MONITOR)); if (arg_count(cmd, available_ARG)) r = _vgchange_available(cmd, vg); From agk@sourceware.org Wed Jan 24 23:44:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 24 Jan 2007 23:44:00 -0000 Subject: LVM2 WHATS_NEW Message-ID: <20070124234444.22281.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-24 23:44:44 Modified files: . : WHATS_NEW Log message: Add init script for dmeventd monitoring. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.556&r2=1.557 --- LVM2/WHATS_NEW 2007/01/24 23:43:26 1.556 +++ LVM2/WHATS_NEW 2007/01/24 23:44:43 1.557 @@ -1,5 +1,6 @@ Version 2.02.20 - =================================== + Add init script for dmeventd monitoring. lvm.static no longer interacts with dmeventd unless explicitly asked to. Add field definitions to report help text. Remove unnecessary cmd arg from target_*monitor_events(). From agk@sourceware.org Thu Jan 25 14:37:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 25 Jan 2007 14:37:00 -0000 Subject: LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c ... Message-ID: <20070125143750.28040.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-25 14:37:48 Modified files: . : WHATS_NEW daemons/clvmd : lvm-functions.c lib/commands : toolcontext.c lib/config : config.c lib/device : dev-io.c lib/filters : filter-persistent.c filter-sysfs.c filter.c lib/format_text: archive.c format-text.c lib/locking : file_locking.c lib/log : log.c lib/misc : lvm-file.c tools : lvmcmdline.c reporter.c Log message: Add some missing close() and fclose() return code checks. Fix exit statuses of reporting tools (2.02.19). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.557&r2=1.558 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.27&r2=1.28 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.45&r2=1.46 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/config.c.diff?cvsroot=lvm2&r1=1.52&r2=1.53 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-io.c.diff?cvsroot=lvm2&r1=1.55&r2=1.56 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter-persistent.c.diff?cvsroot=lvm2&r1=1.28&r2=1.29 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter-sysfs.c.diff?cvsroot=lvm2&r1=1.13&r2=1.14 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter.c.diff?cvsroot=lvm2&r1=1.36&r2=1.37 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/archive.c.diff?cvsroot=lvm2&r1=1.24&r2=1.25 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.71&r2=1.72 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/file_locking.c.diff?cvsroot=lvm2&r1=1.25&r2=1.26 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.c.diff?cvsroot=lvm2&r1=1.36&r2=1.37 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/lvm-file.c.diff?cvsroot=lvm2&r1=1.17&r2=1.18 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.39&r2=1.40 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/reporter.c.diff?cvsroot=lvm2&r1=1.17&r2=1.18 --- LVM2/WHATS_NEW 2007/01/24 23:44:43 1.557 +++ LVM2/WHATS_NEW 2007/01/25 14:37:46 1.558 @@ -1,5 +1,7 @@ Version 2.02.20 - =================================== + Add some missing close() and fclose() return code checks. + Fix exit statuses of reporting tools (2.02.19). Add init script for dmeventd monitoring. lvm.static no longer interacts with dmeventd unless explicitly asked to. Add field definitions to report help text. --- LVM2/daemons/clvmd/lvm-functions.c 2007/01/23 15:58:05 1.27 +++ LVM2/daemons/clvmd/lvm-functions.c 2007/01/25 14:37:47 1.28 @@ -473,7 +473,8 @@ sync_unlock(vg, LCK_EXCL); } - fclose(vgs); + if (fclose(vgs)) + DEBUGLOG("vgs fclose failed: %s\n", strerror(errno)); } /* @@ -523,7 +524,8 @@ } } } - fclose(lvs); + if (fclose(lvs)) + DEBUGLOG("lvs fclose failed: %s\n", strerror(errno)); return NULL; } --- LVM2/lib/commands/toolcontext.c 2007/01/23 16:03:54 1.45 +++ LVM2/lib/commands/toolcontext.c 2007/01/25 14:37:47 1.46 @@ -59,8 +59,6 @@ # include #endif -static FILE *_log; - static int _get_env_vars(struct cmd_context *cmd) { const char *e; @@ -1114,8 +1112,4 @@ activation_exit(); fin_log(); fin_syslog(); - - if (_log) - fclose(_log); - } --- LVM2/lib/config/config.c 2007/01/17 16:22:59 1.52 +++ LVM2/lib/config/config.c 2007/01/25 14:37:47 1.53 @@ -435,13 +435,13 @@ log_verbose("Dumping configuration to %s", file); if (!argc) { if (!_write_config(cft->root, 0, fp, 0)) { - log_error("Failure while writing configuration"); + log_error("Failure while writing to %s", file); r = 0; } } else while (argc--) { if ((cn = find_config_node(cft->root, *argv))) { if (!_write_config(cn, 1, fp, 0)) { - log_error("Failure while writing configuration"); + log_error("Failure while writing to %s", file); r = 0; } } else { @@ -451,8 +451,10 @@ argv++; } - if (fp != stdout) - fclose(fp); + if ((fp != stdout) && fclose(fp)) { + log_sys_error("fclose", file); + r = 0; + } return r; } --- LVM2/lib/device/dev-io.c 2006/11/30 23:11:40 1.55 +++ LVM2/lib/device/dev-io.c 2007/01/25 14:37:47 1.56 @@ -292,11 +292,14 @@ if (ioctl(fd, BLKSSZGET, &s) < 0) { log_sys_error("ioctl BLKSSZGET", name); - close(fd); + if (close(fd)) + log_sys_error("close", name); return 0; } - close(fd); + if (close(fd)) + log_sys_error("close", name); + *size = (uint32_t) s; log_very_verbose("%s: sector size is %" PRIu32 " bytes", name, *size); --- LVM2/lib/filters/filter-persistent.c 2006/11/04 03:34:09 1.28 +++ LVM2/lib/filters/filter-persistent.c 2007/01/25 14:37:47 1.29 @@ -239,7 +239,10 @@ /* _write_array(pf, fp, "invalid_devices", PF_BAD_DEVICE); */ fprintf(fp, "}\n"); - fclose(fp); + if (fclose(fp)) { + log_sys_error("fclose", tmp_file); + goto out; + } if (rename(tmp_file, pf->file)) log_error("%s: rename to %s failed: %s", tmp_file, pf->file, --- LVM2/lib/filters/filter-sysfs.c 2006/08/21 12:54:52 1.13 +++ LVM2/lib/filters/filter-sysfs.c 2007/01/25 14:37:47 1.14 @@ -54,7 +54,9 @@ } } - fclose(fp); + if (fclose(fp)) + log_sys_error("fclose", proc_mounts); + return r; } @@ -156,7 +158,9 @@ } r = _parse_dev(file, fp, result); - fclose(fp); + + if (fclose(fp)) + log_sys_error("fclose", file); return r; } --- LVM2/lib/filters/filter.c 2006/08/21 12:54:52 1.36 +++ LVM2/lib/filters/filter.c 2007/01/25 14:37:47 1.37 @@ -204,7 +204,8 @@ if (cv->type != CFG_STRING) { log_error("Expecting string in devices/types " "in config file"); - fclose(pd); + if (fclose(pd)) + log_sys_error("fclose", proc_devices); return 0; } dev_len = strlen(cv->v.str); @@ -214,14 +215,16 @@ log_error("Max partition count missing for %s " "in devices/types in config file", name); - fclose(pd); + if (fclose(pd)) + log_sys_error("fclose", proc_devices); return 0; } if (!cv->v.i) { log_error("Zero partition count invalid for " "%s in devices/types in config file", name); - fclose(pd); + if (fclose(pd)) + log_sys_error("fclose", proc_devices); return 0; } if (dev_len <= strlen(line + i) && @@ -232,7 +235,10 @@ } } } - fclose(pd); + + if (fclose(pd)) + log_sys_error("fclose", proc_devices); + return 1; } --- LVM2/lib/format_text/archive.c 2006/08/21 12:54:52 1.24 +++ LVM2/lib/format_text/archive.c 2007/01/25 14:37:48 1.25 @@ -249,17 +249,23 @@ if (!(fp = fdopen(fd, "w"))) { log_err("Couldn't create FILE object for archive."); - close(fd); + if (close(fd)) + log_sys_error("close", temp_file); return 0; } if (!text_vg_export_file(vg, desc, fp)) { stack; - fclose(fp); + if (fclose(fp)) + log_sys_error("fclose", temp_file); return 0; } - fclose(fp); + if (fclose(fp)) { + log_sys_error("fclose", temp_file); + /* Leave file behind as evidence of failure */ + return 0; + } /* * Now we want to rename this file to _index.vg. --- LVM2/lib/format_text/format-text.c 2007/01/09 21:12:41 1.71 +++ LVM2/lib/format_text/format-text.c 2007/01/25 14:37:48 1.72 @@ -710,7 +710,8 @@ if (!(fp = fdopen(fd, "w"))) { log_sys_error("fdopen", temp_file); - close(fd); + if (close(fd)) + log_sys_error("fclose", temp_file); return 0; } @@ -718,13 +719,15 @@ if (!text_vg_export_file(vg, tc->desc, fp)) { log_error("Failed to write metadata to %s.", temp_file); - fclose(fp); + if (fclose(fp)) + log_sys_error("fclose", temp_file); return 0; } if (fsync(fd) && (errno != EROFS) && (errno != EINVAL)) { log_sys_error("fsync", tc->path_edit); - fclose(fp); + if (fclose(fp)) + log_sys_error("fclose", tc->path_edit); return 0; } --- LVM2/lib/locking/file_locking.c 2006/08/21 12:54:52 1.25 +++ LVM2/lib/locking/file_locking.c 2007/01/25 14:37:48 1.26 @@ -163,8 +163,8 @@ log_very_verbose("Locking %s %c%c", ll->res, state, flags & LCK_NONBLOCK ? ' ' : 'B'); do { - if (ll->lf > -1) - close(ll->lf); + if ((ll->lf > -1) && close(ll->lf)) + log_sys_error("close", file); if ((ll->lf = open(file, O_CREAT | O_APPEND | O_RDWR, 0777)) < 0) { --- LVM2/lib/log/log.c 2007/01/19 22:21:45 1.36 +++ LVM2/lib/log/log.c 2007/01/25 14:37:48 1.37 @@ -120,7 +120,8 @@ } if (_log_to_file) { - fclose(_log_file); + if (fclose(_log_file)) + fprintf(stderr, "fclose() on log file failed: %s", strerror(errno)); _log_to_file = 0; } } --- LVM2/lib/misc/lvm-file.c 2006/11/04 03:34:10 1.17 +++ LVM2/lib/misc/lvm-file.c 2007/01/25 14:37:48 1.18 @@ -66,7 +66,8 @@ if (!fcntl(*fd, F_SETLK, &lock)) return 1; - close(*fd); + if (close(*fd)) + log_sys_error("close", buffer); } return 0; @@ -239,7 +240,8 @@ if (fsync(fd) && (errno != EROFS) && (errno != EINVAL)) log_sys_error("fsync", dir); - close(fd); + if (close(fd)) + log_sys_error("close", dir); out: dm_free(dir); --- LVM2/tools/lvmcmdline.c 2007/01/23 15:58:06 1.39 +++ LVM2/tools/lvmcmdline.c 2007/01/25 14:37:48 1.40 @@ -1065,8 +1065,9 @@ char buffer[CMD_LEN]; int ret = 0; int magic_number = 0; + char *script_file = argv[0]; - if ((script = fopen(argv[0], "r")) == NULL) + if ((script = fopen(script_file, "r")) == NULL) return ENO_SUCH_CMD; while (fgets(buffer, sizeof(buffer), script) != NULL) { @@ -1099,7 +1100,9 @@ lvm_run_command(cmd, argc, argv); } - fclose(script); + if (fclose(script)) + log_sys_error("fclose", script_file); + return ret; } --- LVM2/tools/reporter.c 2007/01/16 18:06:12 1.17 +++ LVM2/tools/reporter.c 2007/01/25 14:37:48 1.18 @@ -25,7 +25,7 @@ return ECMD_FAILED; } - if (!report_object(handle, vg, NULL, NULL, NULL, NULL)); + if (!report_object(handle, vg, NULL, NULL, NULL, NULL)) return ECMD_FAILED; check_current_backup(vg); @@ -39,7 +39,7 @@ if (!arg_count(cmd, all_ARG) && !lv_is_visible(lv)) return ECMD_PROCESSED; - if (!report_object(handle, lv->vg, lv, NULL, NULL, NULL)); + if (!report_object(handle, lv->vg, lv, NULL, NULL, NULL)) return ECMD_FAILED; return ECMD_PROCESSED; @@ -48,7 +48,7 @@ static int _segs_single(struct cmd_context *cmd __attribute((unused)), struct lv_segment *seg, void *handle) { - if (!report_object(handle, seg->lv->vg, seg->lv, NULL, seg, NULL)); + if (!report_object(handle, seg->lv->vg, seg->lv, NULL, seg, NULL)) return ECMD_FAILED; return ECMD_PROCESSED; @@ -78,7 +78,7 @@ goto out; } - if (!report_object(handle, vg, NULL, pv, NULL, pvseg)); + if (!report_object(handle, vg, NULL, pv, NULL, pvseg)) ret = ECMD_FAILED; out: @@ -128,7 +128,7 @@ } } - if (!report_object(handle, vg, NULL, pv, NULL, NULL)); + if (!report_object(handle, vg, NULL, pv, NULL, NULL)) ret = ECMD_FAILED; out: From agk@sourceware.org Thu Jan 25 21:22:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 25 Jan 2007 21:22:00 -0000 Subject: LVM2 ./WHATS_NEW doc/example.conf lib/activate ... Message-ID: <20070125212231.13385.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-25 21:22:30 Modified files: . : WHATS_NEW doc : example.conf lib/activate : activate.h dev_manager.c lib/commands : toolcontext.c lib/config : defaults.h lib/filters : filter.c lib/log : log.c log.h Log message: Add devices/ignore_suspended_devices to ignore suspended dm devices. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.558&r2=1.559 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.diff?cvsroot=lvm2&r1=1.27&r2=1.28 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.53&r2=1.54 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.118&r2=1.119 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.46&r2=1.47 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/defaults.h.diff?cvsroot=lvm2&r1=1.29&r2=1.30 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter.c.diff?cvsroot=lvm2&r1=1.37&r2=1.38 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.c.diff?cvsroot=lvm2&r1=1.37&r2=1.38 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.h.diff?cvsroot=lvm2&r1=1.34&r2=1.35 --- LVM2/WHATS_NEW 2007/01/25 14:37:46 1.558 +++ LVM2/WHATS_NEW 2007/01/25 21:22:29 1.559 @@ -1,5 +1,6 @@ Version 2.02.20 - =================================== + Add devices/ignore_suspended_devices to ignore suspended dm devices. Add some missing close() and fclose() return code checks. Fix exit statuses of reporting tools (2.02.19). Add init script for dmeventd monitoring. --- LVM2/doc/example.conf 2006/09/02 01:18:17 1.27 +++ LVM2/doc/example.conf 2007/01/25 21:22:30 1.28 @@ -79,6 +79,12 @@ # software RAID (md) devices by looking for md superblocks. # 1 enables; 0 disables. md_component_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 --- LVM2/lib/activate/activate.h 2007/01/19 22:21:45 1.53 +++ LVM2/lib/activate/activate.h 2007/01/25 21:22:30 1.54 @@ -95,4 +95,9 @@ int pv_uses_vg(struct physical_volume *pv, struct volume_group *vg); +/* + * Returns 1 if mapped device is not suspended. + */ +int device_is_usable(dev_t dev); + #endif --- LVM2/lib/activate/dev_manager.c 2007/01/09 20:31:08 1.118 +++ LVM2/lib/activate/dev_manager.c 2007/01/25 21:22:30 1.119 @@ -25,6 +25,7 @@ #include "targets.h" #include "config.h" #include "filter.h" +#include "activate.h" #include #include @@ -154,6 +155,42 @@ return r; } +int device_is_usable(dev_t dev) +{ + struct dm_task *dmt; + struct dm_info info; + int r = 0; + + if (!(dmt = dm_task_create(DM_DEVICE_INFO))) { + log_error("Failed to allocate dm_task struct to check dev status"); + return 0; + } + + if (!dm_task_set_major(dmt, MAJOR(dev)) || !dm_task_set_minor(dmt, MINOR(dev))) + goto_out; + + if (!dm_task_run(dmt)) { + log_error("Failed to get state of mapped device"); + goto out; + } + + if (!dm_task_get_info(dmt, &info)) + goto_out; + + if (!info.exists || info.suspended) + goto out; + + /* FIXME Also check for mirror block_on_error and mpath no paths */ + + /* FIXME Also check dependencies? */ + + r = 1; + + out: + dm_task_destroy(dmt); + return r; +} + static int _info(const char *name, const char *dlid, int mknodes, int with_open_count, struct dm_info *info, struct dm_pool *mem, char **uuid_out) --- LVM2/lib/commands/toolcontext.c 2007/01/25 14:37:47 1.46 +++ LVM2/lib/commands/toolcontext.c 2007/01/25 21:22:30 1.47 @@ -592,6 +592,9 @@ return 0; } + init_ignore_suspended_devices(find_config_tree_int(cmd, + "devices/ignore_suspended_devices", DEFAULT_IGNORE_SUSPENDED_DEVICES)); + dev_cache = find_config_tree_str(cmd, "devices/cache", cache_file); if (!(f4 = persistent_filter_create(f3, dev_cache))) { --- LVM2/lib/config/defaults.h 2006/09/02 01:18:17 1.29 +++ LVM2/lib/config/defaults.h 2007/01/25 21:22:30 1.30 @@ -30,6 +30,7 @@ #define DEFAULT_PROC_DIR "/proc" #define DEFAULT_SYSFS_SCAN 1 #define DEFAULT_MD_COMPONENT_DETECTION 1 +#define DEFAULT_IGNORE_SUSPENDED_DEVICES 1 #define DEFAULT_LOCK_DIR "/var/lock/lvm" #define DEFAULT_LOCKING_LIB "liblvm2clusterlock.so" --- LVM2/lib/filters/filter.c 2007/01/25 14:37:47 1.37 +++ LVM2/lib/filters/filter.c 2007/01/25 21:22:30 1.38 @@ -19,6 +19,7 @@ #include "lvm-string.h" #include "config.h" #include "metadata.h" +#include "activate.h" #include #include @@ -37,6 +38,7 @@ } device_info_t; static int _md_major = -1; +static int _device_mapper_major = -1; int md_major(void) { @@ -90,6 +92,13 @@ return 0; } + /* 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); + return 0; + } + /* Check it's accessible */ if (!dev_open_flags(dev, O_RDONLY, 0, 1)) { log_debug("%s: Skipping: open failed", name); @@ -182,10 +191,14 @@ if (!strncmp("md", line + i, 2) && isspace(*(line + i + 2))) _md_major = line_maj; + /* Look for device-mapper device */ + /* FIXME Cope with multiple majors */ + if (!strncmp("device-mapper", line + i, 13) && isspace(*(line + i + 13))) + _device_mapper_major = line_maj; + /* Go through the valid device names and if there is a match store max number of partitions */ for (j = 0; device_info[j].name != NULL; j++) { - dev_len = strlen(device_info[j].name); if (dev_len <= strlen(line + i) && !strncmp(device_info[j].name, line + i, dev_len) && --- LVM2/lib/log/log.c 2007/01/25 14:37:48 1.37 +++ LVM2/lib/log/log.c 2007/01/25 21:22:30 1.38 @@ -49,6 +49,7 @@ static int _already_logging = 0; static int _mirror_in_sync = 0; static int _dmeventd_monitor = DEFAULT_DMEVENTD_MONITOR; +static int _ignore_suspended_devices = 0; static lvm2_log_fn_t _lvm2_log_fn = NULL; @@ -195,6 +196,11 @@ _dmeventd_monitor = reg; } +void init_ignore_suspended_devices(int ignore) +{ + _ignore_suspended_devices = ignore; +} + void init_cmd_name(int status) { _log_cmd_name = status; @@ -274,6 +280,11 @@ return _dmeventd_monitor; } +int ignore_suspended_devices(void) +{ + return _ignore_suspended_devices; +} + void init_debug(int level) { _debug_level = level; --- LVM2/lib/log/log.h 2007/01/24 23:43:27 1.34 +++ LVM2/lib/log/log.h 2007/01/25 21:22:30 1.35 @@ -76,6 +76,7 @@ void init_security_level(int level); void init_mirror_in_sync(int in_sync); void init_dmeventd_monitor(int reg); +void init_ignore_suspended_devices(int ignore); void set_cmd_name(const char *cmd_name); @@ -90,6 +91,7 @@ int lockingfailed(void); int security_level(void); int mirror_in_sync(void); +int ignore_suspended_devices(void); #define DMEVENTD_MONITOR_IGNORE -1 int dmeventd_monitor_mode(void); From agk@sourceware.org Thu Jan 25 23:03:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 25 Jan 2007 23:03:00 -0000 Subject: LVM2/lib activate/dev_manager.c filters/filter.c Message-ID: <20070125230348.28682.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-25 23:03:48 Modified files: lib/activate : dev_manager.c lib/filters : filter.c Log message: also ignore mirrors Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.119&r2=1.120 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter.c.diff?cvsroot=lvm2&r1=1.38&r2=1.39 --- LVM2/lib/activate/dev_manager.c 2007/01/25 21:22:30 1.119 +++ LVM2/lib/activate/dev_manager.c 2007/01/25 23:03:47 1.120 @@ -159,9 +159,14 @@ { struct dm_task *dmt; struct dm_info info; + const char *name; + uint64_t start, length; + char *target_type = NULL; + char *params; + void *next = NULL; int r = 0; - if (!(dmt = dm_task_create(DM_DEVICE_INFO))) { + if (!(dmt = dm_task_create(DM_DEVICE_STATUS))) { log_error("Failed to allocate dm_task struct to check dev status"); return 0; } @@ -180,7 +185,18 @@ if (!info.exists || info.suspended) goto out; + name = dm_task_get_name(dmt); + /* FIXME Also check for mirror block_on_error and mpath no paths */ + /* For now, we exclude all mirrors */ + + do { + next = dm_get_next_target(dmt, next, &start, &length, + &target_type, ¶ms); + /* Skip if target type doesn't match */ + if (!strcmp(target_type, "mirror")) + goto out; + } while (next); /* FIXME Also check dependencies? */ --- LVM2/lib/filters/filter.c 2007/01/25 21:22:30 1.38 +++ LVM2/lib/filters/filter.c 2007/01/25 23:03:48 1.39 @@ -94,7 +94,7 @@ /* Skip suspended devices */ if (MAJOR(dev->dev) == _device_mapper_major && - ignore_suspended_devices() && device_is_usable(dev->dev)) { + ignore_suspended_devices() && !device_is_usable(dev->dev)) { log_debug("%s: Skipping: Suspended dm device", name); return 0; } From agk@sourceware.org Thu Jan 25 23:32:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 25 Jan 2007 23:32:00 -0000 Subject: LVM2 ./WHATS_NEW dmeventd/mirror/dmeventd_mirror.c Message-ID: <20070125233229.15148.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-25 23:32:29 Modified files: . : WHATS_NEW dmeventd/mirror: dmeventd_mirror.c Log message: dmeventd mirror sets ignore_suspended_devices and avoids scanning mirrors. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.559&r2=1.560 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/dmeventd/mirror/dmeventd_mirror.c.diff?cvsroot=lvm2&r1=1.16&r2=1.17 --- LVM2/WHATS_NEW 2007/01/25 21:22:29 1.559 +++ LVM2/WHATS_NEW 2007/01/25 23:32:29 1.560 @@ -1,5 +1,6 @@ Version 2.02.20 - =================================== + dmeventd mirror sets ignore_suspended_devices and avoids scanning mirrors. Add devices/ignore_suspended_devices to ignore suspended dm devices. Add some missing close() and fclose() return code checks. Fix exit statuses of reporting tools (2.02.19). --- LVM2/dmeventd/mirror/dmeventd_mirror.c 2007/01/23 17:40:40 1.16 +++ LVM2/dmeventd/mirror/dmeventd_mirror.c 2007/01/25 23:32:29 1.17 @@ -151,7 +151,7 @@ } /* FIXME Is any sanity-checking required on %s? */ - if (CMD_SIZE <= snprintf(cmd_str, CMD_SIZE, "vgreduce --removemissing %s", vg)) { + if (CMD_SIZE <= snprintf(cmd_str, CMD_SIZE, "vgreduce --config devices{ignore_suspended_devices=1} --removemissing %s", vg)) { /* this error should be caught above, but doesn't hurt to check again */ syslog(LOG_ERR, "Unable to form LVM command: Device name too long"); dm_pool_empty(_mem_pool); /* FIXME: not safe with multiple threads */ From agk@sourceware.org Thu Jan 25 23:37:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 25 Jan 2007 23:37:00 -0000 Subject: LVM2 VERSION WHATS_NEW Message-ID: <20070125233659.17714.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-25 23:36:59 Modified files: . : VERSION WHATS_NEW Log message: pre-release Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/VERSION.diff?cvsroot=lvm2&r1=1.140&r2=1.141 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.560&r2=1.561 --- LVM2/VERSION 2007/01/17 17:56:15 1.140 +++ LVM2/VERSION 2007/01/25 23:36:59 1.141 @@ -1 +1 @@ -2.02.20-cvs (2007-01-17) +2.02.20-cvs (2007-01-25) --- LVM2/WHATS_NEW 2007/01/25 23:32:29 1.560 +++ LVM2/WHATS_NEW 2007/01/25 23:36:59 1.561 @@ -1,4 +1,4 @@ -Version 2.02.20 - +Version 2.02.20 - 25th January 2007 =================================== dmeventd mirror sets ignore_suspended_devices and avoids scanning mirrors. Add devices/ignore_suspended_devices to ignore suspended dm devices. From agk@sourceware.org Thu Jan 25 23:40:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 25 Jan 2007 23:40:00 -0000 Subject: LVM2 VERSION WHATS_NEW Message-ID: <20070125234034.18661.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-25 23:40:33 Modified files: . : VERSION WHATS_NEW Log message: post-release Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/VERSION.diff?cvsroot=lvm2&r1=1.141&r2=1.142 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.561&r2=1.562 --- LVM2/VERSION 2007/01/25 23:36:59 1.141 +++ LVM2/VERSION 2007/01/25 23:40:33 1.142 @@ -1 +1 @@ -2.02.20-cvs (2007-01-25) +2.02.21-cvs (2007-01-25) --- LVM2/WHATS_NEW 2007/01/25 23:36:59 1.561 +++ LVM2/WHATS_NEW 2007/01/25 23:40:33 1.562 @@ -1,3 +1,6 @@ +Version 2.02.21 - +=================================== + Version 2.02.20 - 25th January 2007 =================================== dmeventd mirror sets ignore_suspended_devices and avoids scanning mirrors. From agk@sourceware.org Fri Jan 26 17:15:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Fri, 26 Jan 2007 17:15:00 -0000 Subject: LVM2 ./WHATS_NEW lib/device/dev-md.c Message-ID: <20070126171517.11826.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-26 17:15:16 Modified files: . : WHATS_NEW lib/device : dev-md.c Log message: Fix md signature check to handle both endiannesses. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.562&r2=1.563 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/dev-md.c.diff?cvsroot=lvm2&r1=1.3&r2=1.4 --- LVM2/WHATS_NEW 2007/01/25 23:40:33 1.562 +++ LVM2/WHATS_NEW 2007/01/26 17:15:16 1.563 @@ -1,5 +1,6 @@ Version 2.02.21 - =================================== + Fix md signature check to handle both endiannesses. Version 2.02.20 - 25th January 2007 =================================== --- LVM2/lib/device/dev-md.c 2004/11/27 22:07:41 1.3 +++ LVM2/lib/device/dev-md.c 2007/01/26 17:15:16 1.4 @@ -53,8 +53,10 @@ sb_offset = MD_NEW_SIZE_SECTORS(size) << SECTOR_SHIFT; /* Check if it is an md component device. */ + /* Version 1 is little endian; version 0.90.0 is machine endian */ if (dev_read(dev, sb_offset, sizeof(uint32_t), &md_magic) && - (md_magic == xlate32(MD_SB_MAGIC))) { + ((md_magic == xlate32(MD_SB_MAGIC)) || + (md_magic == MD_SB_MAGIC))) { if (sb) *sb = sb_offset; ret = 1; From agk@sourceware.org Sat Jan 27 02:09:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Sat, 27 Jan 2007 02:09:00 -0000 Subject: LVM2 ./WHATS_NEW tools/reporter.c Message-ID: <20070127020907.21750.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-27 02:09:06 Modified files: . : WHATS_NEW tools : reporter.c Log message: Fix vgs to treat args as VGs even when PV fields are displayed. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.563&r2=1.564 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/reporter.c.diff?cvsroot=lvm2&r1=1.18&r2=1.19 --- LVM2/WHATS_NEW 2007/01/26 17:15:16 1.563 +++ LVM2/WHATS_NEW 2007/01/27 02:09:05 1.564 @@ -1,5 +1,6 @@ Version 2.02.21 - =================================== + Fix vgs to treat args as VGs even when PV fields are displayed. Fix md signature check to handle both endiannesses. Version 2.02.20 - 25th January 2007 --- LVM2/tools/reporter.c 2007/01/25 14:37:48 1.18 +++ LVM2/tools/reporter.c 2007/01/27 02:09:06 1.19 @@ -138,6 +138,18 @@ return ret; } +static int _pvs_in_vg(struct cmd_context *cmd, const char *vg_name, + struct volume_group *vg, int consistent, + void *handle) +{ + if (!vg) { + log_error("Volume group %s not found", vg_name); + return ECMD_FAILED; + } + + return process_each_pv_in_vg(cmd, vg, NULL, handle, &_pvs_single); +} + static int _report(struct cmd_context *cmd, int argc, char **argv, report_type_t report_type) { @@ -146,8 +158,8 @@ char *str; const char *keys = NULL, *options = NULL, *separator; int r = ECMD_PROCESSED; - int aligned, buffered, headings; + unsigned args_are_pvs; aligned = find_config_tree_int(cmd, "report/aligned", DEFAULT_REP_ALIGNED); @@ -158,6 +170,8 @@ separator = find_config_tree_str(cmd, "report/separator", DEFAULT_REP_SEPARATOR); + args_are_pvs = (report_type == PVS || report_type == PVSEGS) ? 1 : 0; + switch (report_type) { case LVS: keys = find_config_tree_str(cmd, "report/lvs_sort", @@ -292,16 +306,24 @@ report_handle, &_vgs_single); break; case PVS: - r = process_each_pv(cmd, argc, argv, NULL, report_handle, - &_pvs_single); + if (args_are_pvs) + r = process_each_pv(cmd, argc, argv, NULL, + report_handle, &_pvs_single); + else + r = process_each_vg(cmd, argc, argv, LCK_VG_READ, 0, + report_handle, &_pvs_in_vg); break; case SEGS: r = process_each_lv(cmd, argc, argv, LCK_VG_READ, report_handle, &_lvsegs_single); break; case PVSEGS: - r = process_each_pv(cmd, argc, argv, NULL, report_handle, - &_pvsegs_single); + if (args_are_pvs) + r = process_each_pv(cmd, argc, argv, NULL, + report_handle, &_pvsegs_single); + else + r = process_each_vg(cmd, argc, argv, LCK_VG_READ, 0, + report_handle, &_pvs_in_vg); break; } From agk@sourceware.org Sat Jan 27 02:32:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Sat, 27 Jan 2007 02:32:00 -0000 Subject: LVM2/tools reporter.c Message-ID: <20070127023231.28858.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-27 02:32:31 Modified files: tools : reporter.c Log message: fix pvsegs report too Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/reporter.c.diff?cvsroot=lvm2&r1=1.19&r2=1.20 --- LVM2/tools/reporter.c 2007/01/27 02:09:06 1.19 +++ LVM2/tools/reporter.c 2007/01/27 02:32:31 1.20 @@ -150,6 +150,18 @@ return process_each_pv_in_vg(cmd, vg, NULL, handle, &_pvs_single); } +static int _pvsegs_in_vg(struct cmd_context *cmd, const char *vg_name, + struct volume_group *vg, int consistent, + void *handle) +{ + if (!vg) { + log_error("Volume group %s not found", vg_name); + return ECMD_FAILED; + } + + return process_each_pv_in_vg(cmd, vg, NULL, handle, &_pvsegs_single); +} + static int _report(struct cmd_context *cmd, int argc, char **argv, report_type_t report_type) { @@ -323,7 +335,7 @@ report_handle, &_pvsegs_single); else r = process_each_vg(cmd, argc, argv, LCK_VG_READ, 0, - report_handle, &_pvs_in_vg); + report_handle, &_pvsegs_in_vg); break; } From agk@sourceware.org Mon Jan 29 23:01:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Mon, 29 Jan 2007 23:01:00 -0000 Subject: LVM2 ./WHATS_NEW lib/report/report.c tools/vgs ... Message-ID: <20070129230119.32034.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-29 23:01:18 Modified files: . : WHATS_NEW lib/report : report.c tools : vgsplit.c Log message: Fix vgsplit to handle mirrors. Reorder fields in reporting field definitions. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.564&r2=1.565 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.54&r2=1.55 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.21&r2=1.22 --- LVM2/WHATS_NEW 2007/01/27 02:09:05 1.564 +++ LVM2/WHATS_NEW 2007/01/29 23:01:17 1.565 @@ -1,5 +1,7 @@ Version 2.02.21 - =================================== + Fix vgsplit to handle mirrors. + Reorder fields in reporting field definitions. Fix vgs to treat args as VGs even when PV fields are displayed. Fix md signature check to handle both endiannesses. --- LVM2/lib/report/report.c 2007/01/24 16:51:24 1.54 +++ LVM2/lib/report/report.c 2007/01/29 23:01:18 1.55 @@ -868,11 +868,11 @@ #define STR DM_REPORT_FIELD_TYPE_STRING #define NUM DM_REPORT_FIELD_TYPE_NUMBER -#define FIELD(type, strct, sorttype, head, field, width, func, id, desc) {type, id, (off_t)((void *)&_dummy._ ## strct.field - (void *)&_dummy._ ## strct), head, width, sorttype, &_ ## func ## _disp, desc}, +#define FIELD(type, strct, sorttype, head, field, width, func, id, desc) {type, sorttype, (off_t)((void *)&_dummy._ ## strct.field - (void *)&_dummy._ ## strct), width, id, head, &_ ## func ## _disp, desc}, static struct dm_report_field_type _fields[] = { #include "columns.h" -{0, "", 0, "", 0, 0, NULL, NULL}, +{0, 0, 0, 0, "", "", NULL, NULL}, }; #undef STR --- LVM2/tools/vgsplit.c 2007/01/09 21:12:41 1.21 +++ LVM2/tools/vgsplit.c 2007/01/29 23:01:18 1.22 @@ -72,6 +72,9 @@ if ((lv->status & SNAPSHOT)) continue; + if ((lv->status & MIRRORED)) + continue; + /* Ensure all the PVs used by this LV remain in the same */ /* VG as each other */ vg_with = NULL; @@ -161,6 +164,48 @@ return 1; } +static int _move_mirrors(struct volume_group *vg_from, + struct volume_group *vg_to) +{ + struct list *lvh, *lvht; + struct logical_volume *lv; + struct lv_segment *seg; + int i, seg_in, log_in; + + list_iterate_safe(lvh, lvht, &vg_from->lvs) { + lv = list_item(lvh, struct lv_list)->lv; + + if (!(lv->status & MIRRORED)) + continue; + + seg = first_seg(lv); + + seg_in = 0; + for (i = 0; i < seg->area_count; i++) + if (_lv_is_in_vg(vg_to, seg_lv(seg, i))) + seg_in++; + + log_in = (!seg->log_lv || _lv_is_in_vg(vg_to, seg->log_lv)); + + if ((seg_in && seg_in < seg->area_count) || + (seg_in && seg->log_lv && !log_in) || + (!seg_in && seg->log_lv && log_in)) { + log_error("Mirror %s split", lv->name); + return 0; + } + + if (seg_in == seg->area_count && log_in) { + list_del(lvh); + list_add(&vg_to->lvs, lvh); + + vg_from->lv_count--; + vg_to->lv_count++; + } + } + + return 1; +} + int vgsplit(struct cmd_context *cmd, int argc, char **argv) { char *vg_name_from, *vg_name_to; @@ -275,6 +320,10 @@ if (!(_move_snapshots(vg_from, vg_to))) goto error; + /* Move required mirrors across */ + if (!(_move_mirrors(vg_from, vg_to))) + goto error; + /* FIXME Split mdas properly somehow too! */ /* Currently we cheat by sharing the format instance and relying on * vg_write to ignore mdas outside the VG! Done this way, with text From agk@sourceware.org Tue Jan 30 18:02:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 30 Jan 2007 18:02:00 -0000 Subject: LVM2 ./WHATS_NEW scripts/lvm2_monitoring_init_ ... Message-ID: <20070130180216.25040.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-30 18:02:15 Modified files: . : WHATS_NEW scripts : lvm2_monitoring_init_rhel4 Log message: Add warning to lvm2_monitoring_init_rhel4 if attempting to stop monitoring. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.565&r2=1.566 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/lvm2_monitoring_init_rhel4.diff?cvsroot=lvm2&r1=1.1&r2=1.2 --- LVM2/WHATS_NEW 2007/01/29 23:01:17 1.565 +++ LVM2/WHATS_NEW 2007/01/30 18:02:15 1.566 @@ -1,5 +1,6 @@ Version 2.02.21 - =================================== + Add warning to lvm2_monitoring_init_rhel4 if attempting to stop monitoring. Fix vgsplit to handle mirrors. Reorder fields in reporting field definitions. Fix vgs to treat args as VGs even when PV fields are displayed. --- LVM2/scripts/lvm2_monitoring_init_rhel4 2007/01/24 23:43:27 1.1 +++ LVM2/scripts/lvm2_monitoring_init_rhel4 2007/01/30 18:02:15 1.2 @@ -25,11 +25,11 @@ . /etc/init.d/functions VGCHANGE="/usr/sbin/vgchange" +WARN=1 start() { - for ret in 0 - do + ret=0 # TODO do we want to separate out already active groups only? VGS=`vgs --noheadings -o name` for vg in $VGS @@ -40,50 +40,58 @@ fi done - done - - return $ret + return $ret } stop() { - for ret in 0 - do + ret=0 # TODO do we want to separate out already active groups only? + if test "$WARN" = "1"; then + echo "Not stopping monitoring, this is a dangerous operation. Please use force-stop to override." + return 1 + fi VGS=`vgs --noheadings -o name` for vg in $VGS do - if ! action "Starting monitoring for VG $vg:" $VGCHANGE --monitor n $vg + if ! action "Stopping monitoring for VG $vg:" $VGCHANGE --monitor n $vg then ret=$? fi done - - done - + return $ret } -ret=1 +result=1 # See how we were called. case "$1" in start) start - ret=$? + result=$? + ;; + + force-stop) + WARN=0 + stop + result=$? ;; stop) + test "$runlevel" = "0" && WARN=0 + test "$runlevel" = "6" && WARN=0 stop - ret=$? + result=$? ;; restart) + WARN=0 if stop then start fi - ret=$? + result=$? ;; status) @@ -91,8 +99,8 @@ ;; *) - echo $"Usage: $0 {start|stop|restart|status}" + echo $"Usage: $0 {start|stop|restart|status|force-stop}" ;; esac -exit $ret +exit $result From agk@sourceware.org Tue Jan 30 18:08:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 30 Jan 2007 18:08:00 -0000 Subject: LVM2 VERSION WHATS_NEW Message-ID: <20070130180818.3916.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-30 18:08:17 Modified files: . : VERSION WHATS_NEW Log message: pre-release Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/VERSION.diff?cvsroot=lvm2&r1=1.142&r2=1.143 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.566&r2=1.567 --- LVM2/VERSION 2007/01/25 23:40:33 1.142 +++ LVM2/VERSION 2007/01/30 18:08:17 1.143 @@ -1 +1 @@ -2.02.21-cvs (2007-01-25) +2.02.21-cvs (2007-01-30) --- LVM2/WHATS_NEW 2007/01/30 18:02:15 1.566 +++ LVM2/WHATS_NEW 2007/01/30 18:08:17 1.567 @@ -1,4 +1,4 @@ -Version 2.02.21 - +Version 2.02.21 - 30th January 2007 =================================== Add warning to lvm2_monitoring_init_rhel4 if attempting to stop monitoring. Fix vgsplit to handle mirrors. From agk@sourceware.org Tue Jan 30 21:37:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 30 Jan 2007 21:37:00 -0000 Subject: LVM2 VERSION WHATS_NEW Message-ID: <20070130213718.628.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-30 21:37:18 Modified files: . : VERSION WHATS_NEW Log message: post-release Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/VERSION.diff?cvsroot=lvm2&r1=1.143&r2=1.144 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.567&r2=1.568 --- LVM2/VERSION 2007/01/30 18:08:17 1.143 +++ LVM2/VERSION 2007/01/30 21:37:18 1.144 @@ -1 +1 @@ -2.02.21-cvs (2007-01-30) +2.02.22-cvs (2007-01-30) --- LVM2/WHATS_NEW 2007/01/30 18:08:17 1.567 +++ LVM2/WHATS_NEW 2007/01/30 21:37:18 1.568 @@ -1,3 +1,6 @@ +Version 2.02.22 - +=================================== + Version 2.02.21 - 30th January 2007 =================================== Add warning to lvm2_monitoring_init_rhel4 if attempting to stop monitoring. From agk@sourceware.org Wed Jan 31 16:26:00 2007 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 31 Jan 2007 16:26:00 -0000 Subject: LVM2 ./WHATS_NEW tools/vgreduce.c Message-ID: <20070131162623.18518.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2007-01-31 16:26:23 Modified files: . : WHATS_NEW tools : vgreduce.c Log message: Fix some &->&& vgreduce cmdline validation. [Andre Noll] Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.568&r2=1.569 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgreduce.c.diff?cvsroot=lvm2&r1=1.55&r2=1.56 --- LVM2/WHATS_NEW 2007/01/30 21:37:18 1.568 +++ LVM2/WHATS_NEW 2007/01/31 16:26:22 1.569 @@ -1,5 +1,6 @@ Version 2.02.22 - =================================== + Fix some vgreduce --removemissing command line validation. Version 2.02.21 - 30th January 2007 =================================== --- LVM2/tools/vgreduce.c 2007/01/09 23:14:34 1.55 +++ LVM2/tools/vgreduce.c 2007/01/31 16:26:23 1.56 @@ -427,13 +427,13 @@ int ret = 1; int consistent = 1; - if (!argc & !arg_count(cmd, removemissing_ARG)) { + if (!argc && !arg_count(cmd, removemissing_ARG)) { log_error("Please give volume group name and " "physical volume paths"); return EINVALID_CMD_LINE; } - if (!argc & arg_count(cmd, removemissing_ARG)) { + if (!argc && arg_count(cmd, removemissing_ARG)) { log_error("Please give volume group name"); return EINVALID_CMD_LINE; }