From mornfall@sourceware.org Wed Jul 9 09:59:00 2008 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Wed, 09 Jul 2008 09:59:00 -0000 Subject: LVM2 ./WHATS_NEW ./configure ./configure.in dm ... Message-ID: <20080709095943.17766.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2008-07-09 09:59:42 Modified files: . : WHATS_NEW configure configure.in dmeventd/mirror: Makefile.in dmeventd/snapshot: Makefile.in Log message: Fix dmeventd regression where mirror and snapshot monitoring libraries failed to link against liblvm2cmd. Dmeventd DSOs *require* lvm2cmd to be linked in. For the future: 1) AC_SUBST does not create Makefile variables, only @foo@-style substitutions 2) When using `test', whitespace around `=' is essential: test a=b is true, as is test a=a Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.925&r2=1.926 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.diff?cvsroot=lvm2&r1=1.73&r2=1.74 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.in.diff?cvsroot=lvm2&r1=1.74&r2=1.75 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/dmeventd/mirror/Makefile.in.diff?cvsroot=lvm2&r1=1.6&r2=1.7 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/dmeventd/snapshot/Makefile.in.diff?cvsroot=lvm2&r1=1.2&r2=1.3 --- LVM2/WHATS_NEW 2008/06/27 22:35:22 1.925 +++ LVM2/WHATS_NEW 2008/07/09 09:59:41 1.926 @@ -1,5 +1,7 @@ Version 2.02.40 - ================================ + Fix dmeventd regression where mirror and snapshot monitoring libraries + failed to link against liblvm2cmd. Version 2.02.39 - 27th June 2008 ================================ --- LVM2/configure 2008/06/27 19:57:27 1.73 +++ LVM2/configure 2008/07/09 09:59:41 1.74 @@ -8726,10 +8726,11 @@ { echo "$as_me:$LINENO: result: $CMDLIB" >&5 echo "${ECHO_T}$CMDLIB" >&6; } -test $CMDLIB=yes \ +test x$CMDLIB = xyes \ && LVM2CMD_LIB=-llvm2cmd \ || LVM2CMD_LIB= + ################################################################################ { echo "$as_me:$LINENO: checking whether to install fsadm" >&5 echo $ECHO_N "checking whether to install fsadm... $ECHO_C" >&6; } @@ -8752,12 +8753,21 @@ { echo "$as_me:$LINENO: result: $DMEVENTD" >&5 echo "${ECHO_T}$DMEVENTD" >&6; } -if test x$DMEVENTD = xyes && test x$MIRRORS != xinternal; then -{ { echo "$as_me:$LINENO: error: --enable-dmeventd currently requires --with-mirrors=internal -" >&5 +if test x$DMEVENTD = xyes; then + if test x$MIRRORS != xinternal; then + { { echo "$as_me:$LINENO: error: --enable-dmeventd currently requires --with-mirrors=internal + " >&5 echo "$as_me: error: --enable-dmeventd currently requires --with-mirrors=internal -" >&2;} + " >&2;} + { (exit 1); exit 1; }; } + fi + if test x$CMDLIB = xno; then + { { echo "$as_me:$LINENO: error: --enable-dmeventd requires --enable-cmdlib to be used as well + " >&5 +echo "$as_me: error: --enable-dmeventd requires --enable-cmdlib to be used as well + " >&2;} { (exit 1); exit 1; }; } + fi fi if test x$DMEVENTD = xyes; then @@ -10260,7 +10270,7 @@ ac_cv_func_getmntent=yes cat >>confdefs.h <<\_ACEOF -#define HAVE_GETMNTENT +#define HAVE_GETMNTENT 1 _ACEOF else --- LVM2/configure.in 2008/06/27 19:57:27 1.74 +++ LVM2/configure.in 2008/07/09 09:59:42 1.75 @@ -366,10 +366,11 @@ CMDLIB=$enableval, CMDLIB=no) AC_MSG_RESULT($CMDLIB) AC_SUBST([LVM2CMD_LIB]) -test $CMDLIB=yes \ +test x$CMDLIB = xyes \ && LVM2CMD_LIB=-llvm2cmd \ || LVM2CMD_LIB= + ################################################################################ dnl -- Enable fsadm AC_MSG_CHECKING(whether to install fsadm) @@ -385,10 +386,17 @@ AC_MSG_RESULT($DMEVENTD) dnl -- dmeventd currently requires internal mirror support -if test x$DMEVENTD = xyes && test x$MIRRORS != xinternal; then -AC_MSG_ERROR( ---enable-dmeventd currently requires --with-mirrors=internal -) +if test x$DMEVENTD = xyes; then + if test x$MIRRORS != xinternal; then + AC_MSG_ERROR( + --enable-dmeventd currently requires --with-mirrors=internal + ) + fi + if test x$CMDLIB = xno; then + AC_MSG_ERROR( + --enable-dmeventd requires --enable-cmdlib to be used as well + ) + fi fi if test x$DMEVENTD = xyes; then --- LVM2/dmeventd/mirror/Makefile.in 2008/06/23 09:25:07 1.6 +++ LVM2/dmeventd/mirror/Makefile.in 2008/07/09 09:59:42 1.7 @@ -17,7 +17,7 @@ VPATH = @srcdir@ INCLUDES += -I${top_srcdir}/tools -CLDFLAGS += -L${top_srcdir}/tools -ldevmapper $(LVM2CMD_LIB) +CLDFLAGS += -L${top_srcdir}/tools -ldevmapper @LVM2CMD_LIB@ SOURCES = dmeventd_mirror.c --- LVM2/dmeventd/snapshot/Makefile.in 2008/06/23 09:25:08 1.2 +++ LVM2/dmeventd/snapshot/Makefile.in 2008/07/09 09:59:42 1.3 @@ -17,7 +17,7 @@ VPATH = @srcdir@ INCLUDES += -I${top_srcdir}/tools -CLDFLAGS += -L${top_srcdir}/tools -ldevmapper $(LVM2CMD_LIB) +CLDFLAGS += -L${top_srcdir}/tools -ldevmapper @LVM2CMD_LIB@ SOURCES = dmeventd_snapshot.c From agk@sourceware.org Thu Jul 10 09:50:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 10 Jul 2008 09:50:00 -0000 Subject: LVM2 WHATS_NEW Message-ID: <20080710095024.18491.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-07-10 09:50:23 Modified files: . : WHATS_NEW Log message: . Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.926&r2=1.927 --- LVM2/WHATS_NEW 2008/07/09 09:59:41 1.926 +++ LVM2/WHATS_NEW 2008/07/10 09:50:23 1.927 @@ -1,7 +1,6 @@ Version 2.02.40 - ================================ - Fix dmeventd regression where mirror and snapshot monitoring libraries - failed to link against liblvm2cmd. + Fix dmeventd monitoring libraries to link against liblvm2cmd again. (2.02.39) Version 2.02.39 - 27th June 2008 ================================ From mornfall@sourceware.org Thu Jul 10 11:30:00 2008 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Thu, 10 Jul 2008 11:30:00 -0000 Subject: LVM2 ./WHATS_NEW lib/format_text/export.c lib/ ... Message-ID: <20080710113058.4303.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2008-07-10 11:30:58 Modified files: . : WHATS_NEW lib/format_text: export.c flags.c import-export.h import_vsn1.c Log message: Add "flags" metadata field (akin to "status") for backward-compatible flags. The "status" field is treated as it ever has been, unknown flags there are treated as fatal metadata errors. However, in the "flags" field, any unknown flags will be ignored and silently dropped. This improves backward-compatibility possibilities. (Any versions without support for this new "flag" field will drop the field altogether, which is same as ignoring all the flags there.) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.927&r2=1.928 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/export.c.diff?cvsroot=lvm2&r1=1.63&r2=1.64 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/flags.c.diff?cvsroot=lvm2&r1=1.33&r2=1.34 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import-export.h.diff?cvsroot=lvm2&r1=1.20&r2=1.21 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import_vsn1.c.diff?cvsroot=lvm2&r1=1.50&r2=1.51 --- LVM2/WHATS_NEW 2008/07/10 09:50:23 1.927 +++ LVM2/WHATS_NEW 2008/07/10 11:30:57 1.928 @@ -1,5 +1,6 @@ Version 2.02.40 - ================================ + Add "flags" metadata field (akin to "status") for backward-compatible flags. Fix dmeventd monitoring libraries to link against liblvm2cmd again. (2.02.39) Version 2.02.39 - 27th June 2008 --- LVM2/lib/format_text/export.c 2008/04/01 22:40:12 1.63 +++ LVM2/lib/format_text/export.c 2008/07/10 11:30:57 1.64 @@ -321,6 +321,20 @@ return 1; } +static int _print_flag_config(struct formatter *f, int status, int type) +{ + char buffer[4096]; + if (!print_flags(status, type | STATUS_FLAG, buffer, sizeof(buffer))) + return_0; + outf(f, "status = %s", buffer); + + if (!print_flags(status, type, buffer, sizeof(buffer))) + return_0; + outf(f, "flags = %s", buffer); + + return 1; +} + static int _print_vg(struct formatter *f, struct volume_group *vg) { char buffer[4096]; @@ -332,9 +346,8 @@ outf(f, "seqno = %u", vg->seqno); - if (!print_flags(vg->status, VG_FLAGS, buffer, sizeof(buffer))) + if (!_print_flag_config(f, vg->status, VG_FLAGS)) return_0; - outf(f, "status = %s", buffer); if (!list_empty(&vg->tags)) { if (!print_tags(&vg->tags, buffer, sizeof(buffer))) @@ -408,9 +421,8 @@ return_0; outnl(f); - if (!print_flags(pv->status, PV_FLAGS, buffer, sizeof(buffer))) + if (!_print_flag_config(f, pv->status, PV_FLAGS)) return_0; - outf(f, "status = %s", buffer); if (!list_empty(&pv->tags)) { if (!print_tags(&pv->tags, buffer, sizeof(buffer))) @@ -520,9 +532,8 @@ outf(f, "id = \"%s\"", buffer); - if (!print_flags(lv->status, LV_FLAGS, buffer, sizeof(buffer))) + if (!_print_flag_config(f, lv->status, LV_FLAGS)) return_0; - outf(f, "status = %s", buffer); if (!list_empty(&lv->tags)) { if (!print_tags(&lv->tags, buffer, sizeof(buffer))) --- LVM2/lib/format_text/flags.c 2008/01/30 13:59:59 1.33 +++ LVM2/lib/format_text/flags.c 2008/07/10 11:30:57 1.34 @@ -25,48 +25,49 @@ struct flag { const int mask; const char *description; + int kind; }; static struct flag _vg_flags[] = { - {EXPORTED_VG, "EXPORTED"}, - {RESIZEABLE_VG, "RESIZEABLE"}, - {PARTIAL_VG, "PARTIAL"}, - {PVMOVE, "PVMOVE"}, - {LVM_READ, "READ"}, - {LVM_WRITE, "WRITE"}, - {CLUSTERED, "CLUSTERED"}, - {SHARED, "SHARED"}, - {PRECOMMITTED, NULL}, - {0, NULL} + {EXPORTED_VG, "EXPORTED", STATUS_FLAG}, + {RESIZEABLE_VG, "RESIZEABLE", STATUS_FLAG}, + {PARTIAL_VG, "PARTIAL", STATUS_FLAG}, + {PVMOVE, "PVMOVE", STATUS_FLAG}, + {LVM_READ, "READ", STATUS_FLAG}, + {LVM_WRITE, "WRITE", STATUS_FLAG}, + {CLUSTERED, "CLUSTERED", STATUS_FLAG}, + {SHARED, "SHARED", STATUS_FLAG}, + {PRECOMMITTED, NULL, 0}, + {0, NULL, 0} }; static struct flag _pv_flags[] = { - {ALLOCATABLE_PV, "ALLOCATABLE"}, - {EXPORTED_VG, "EXPORTED"}, - {0, NULL} + {ALLOCATABLE_PV, "ALLOCATABLE", STATUS_FLAG}, + {EXPORTED_VG, "EXPORTED", STATUS_FLAG}, + {0, NULL, 0} }; static struct flag _lv_flags[] = { - {LVM_READ, "READ"}, - {LVM_WRITE, "WRITE"}, - {FIXED_MINOR, "FIXED_MINOR"}, - {VISIBLE_LV, "VISIBLE"}, - {PVMOVE, "PVMOVE"}, - {LOCKED, "LOCKED"}, - {MIRROR_NOTSYNCED, "NOTSYNCED"}, - {MIRROR_IMAGE, NULL}, - {MIRROR_LOG, NULL}, - {MIRRORED, NULL}, - {VIRTUAL, NULL}, - {SNAPSHOT, NULL}, - {ACTIVATE_EXCL, NULL}, - {CONVERTING, NULL}, - {0, NULL} + {LVM_READ, "READ", STATUS_FLAG}, + {LVM_WRITE, "WRITE", STATUS_FLAG}, + {FIXED_MINOR, "FIXED_MINOR", STATUS_FLAG}, + {VISIBLE_LV, "VISIBLE", STATUS_FLAG}, + {PVMOVE, "PVMOVE", STATUS_FLAG}, + {LOCKED, "LOCKED", STATUS_FLAG}, + {MIRROR_NOTSYNCED, "NOTSYNCED", STATUS_FLAG}, + {MIRROR_IMAGE, NULL, 0}, + {MIRROR_LOG, NULL, 0}, + {MIRRORED, NULL, 0}, + {VIRTUAL, NULL, 0}, + {SNAPSHOT, NULL, 0}, + {ACTIVATE_EXCL, NULL, 0}, + {CONVERTING, NULL, 0}, + {0, NULL, 0} }; static struct flag *_get_flags(int type) { - switch (type) { + switch (type & ~STATUS_FLAG) { case VG_FLAGS: return _vg_flags; @@ -101,6 +102,9 @@ if (status & flags[f].mask) { status &= ~flags[f].mask; + if ((type & STATUS_FLAG) != flags[f].kind) + continue; + /* Internal-only flag? */ if (!flags[f].description) continue; @@ -151,7 +155,7 @@ break; } - if (!flags[f].description) { + if (!flags[f].description && (type & STATUS_FLAG)) { log_err("Unknown status flag '%s'.", cv->v.str); return 0; } @@ -160,6 +164,6 @@ } out: - *status = s; + *status |= s; return 1; } --- LVM2/lib/format_text/import-export.h 2007/08/20 20:55:26 1.20 +++ LVM2/lib/format_text/import-export.h 2008/07/10 11:30:57 1.21 @@ -36,9 +36,11 @@ * common code for reading and writing them. */ enum { + COMPATIBLE_FLAG = 0x0, VG_FLAGS, PV_FLAGS, - LV_FLAGS + LV_FLAGS, + STATUS_FLAG = 0x8, }; struct text_vg_version_ops { --- LVM2/lib/format_text/import_vsn1.c 2008/01/31 12:35:31 1.50 +++ LVM2/lib/format_text/import_vsn1.c 2008/07/10 11:30:57 1.51 @@ -125,6 +125,31 @@ return 1; } +static int _read_flag_config(struct config_node *n, int *status, int type) +{ + struct config_node *cn; + *status = 0; + + if (!(cn = find_config_node(n, "status"))) { + log_error("Could not find status flags."); + return 0; + } + + if (!(read_flags(status, type | STATUS_FLAG, cn->v))) { + log_error("Could not read status flags."); + return 0; + } + + if (cn = find_config_node(n, "flags")) { + if (!(read_flags(status, type, cn->v))) { + log_error("Could not read flags."); + return 0; + } + } + + return 1; +} + static int _read_pv(struct format_instance *fid, struct dm_pool *mem, struct volume_group *vg, struct config_node *pvn, struct config_node *vgn __attribute((unused)), @@ -181,12 +206,7 @@ memcpy(&pv->vgid, &vg->id, sizeof(vg->id)); - if (!(cn = find_config_node(pvn, "status"))) { - log_error("Couldn't find status flags for physical volume."); - return 0; - } - - if (!(read_flags(&pv->status, PV_FLAGS, cn->v))) { + if (!_read_flag_config(pvn, &pv->status, PV_FLAGS)) { log_error("Couldn't read status flags for physical volume."); return 0; } @@ -493,13 +513,9 @@ return 0; } - if (!(cn = find_config_node(lvn, "status"))) { - log_error("Couldn't find status flags for logical volume."); - return 0; - } - - if (!(read_flags(&lv->status, LV_FLAGS, cn->v))) { - log_error("Couldn't read status flags for logical volume."); + if (!_read_flag_config(lvn, &lv->status, LV_FLAGS)) { + log_error("Couldn't read status flags for logical volume %s.", + lv->name); return 0; } @@ -692,14 +708,8 @@ goto bad; } - if (!(cn = find_config_node(vgn, "status"))) { - log_error("Couldn't find status flags for volume group %s.", - vg->name); - goto bad; - } - - if (!(read_flags(&vg->status, VG_FLAGS, cn->v))) { - log_error("Couldn't read status flags for volume group %s.", + if (!_read_flag_config(vgn, &vg->status, VG_FLAGS)) { + log_error("Error reading flags of volume group %s.", vg->name); goto bad; } @@ -855,18 +865,12 @@ return 0; } - if (!(cn = find_config_node(vgn, "status"))) { + if (!_read_flag_config(vgn, vgstatus, VG_FLAGS)) { log_error("Couldn't find status flags for volume group %s.", vgname); return 0; } - if (!(read_flags(vgstatus, VG_FLAGS, cn->v))) { - log_error("Couldn't read status flags for volume group %s.", - vgname); - return 0; - } - return vgname; } From mornfall@sourceware.org Fri Jul 11 09:19:00 2008 From: mornfall@sourceware.org (mornfall@sourceware.org) Date: Fri, 11 Jul 2008 09:19:00 -0000 Subject: LVM2/lib/format_text import_vsn1.c Message-ID: <20080711091954.8912.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mornfall@sourceware.org 2008-07-11 09:19:54 Modified files: lib/format_text: import_vsn1.c Log message: Fix gcc warnings. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import_vsn1.c.diff?cvsroot=lvm2&r1=1.51&r2=1.52 --- LVM2/lib/format_text/import_vsn1.c 2008/07/10 11:30:57 1.51 +++ LVM2/lib/format_text/import_vsn1.c 2008/07/11 09:19:54 1.52 @@ -125,7 +125,7 @@ return 1; } -static int _read_flag_config(struct config_node *n, int *status, int type) +static int _read_flag_config(struct config_node *n, uint32_t *status, int type) { struct config_node *cn; *status = 0; @@ -140,7 +140,7 @@ return 0; } - if (cn = find_config_node(n, "flags")) { + if ((cn = find_config_node(n, "flags"))) { if (!(read_flags(status, type, cn->v))) { log_error("Could not read flags."); return 0; @@ -836,7 +836,7 @@ struct config_tree *cft, struct id *vgid, uint32_t *vgstatus, char **creation_host) { - struct config_node *vgn, *cn; + struct config_node *vgn; struct dm_pool *mem = fmt->cmd->mem; char *vgname; int old_suppress; From agk@sourceware.org Tue Jul 15 00:25:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 15 Jul 2008 00:25:00 -0000 Subject: LVM2 ./WHATS_NEW lib/activate/dev_manager.c li ... Message-ID: <20080715002552.29343.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-07-15 00:25:52 Modified files: . : WHATS_NEW lib/activate : dev_manager.c lib/metadata : segtype.h lib/mirror : mirrored.c lib/snapshot : snapshot.c Log message: Cease recognising snapshot-in-use percentages returned by early development kernels. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.928&r2=1.929 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.138&r2=1.139 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/segtype.h.diff?cvsroot=lvm2&r1=1.20&r2=1.21 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.55&r2=1.56 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/snapshot/snapshot.c.diff?cvsroot=lvm2&r1=1.30&r2=1.31 --- LVM2/WHATS_NEW 2008/07/10 11:30:57 1.928 +++ LVM2/WHATS_NEW 2008/07/15 00:25:51 1.929 @@ -1,6 +1,7 @@ Version 2.02.40 - ================================ - Add "flags" metadata field (akin to "status") for backward-compatible flags. + Cease recognising snapshot-in-use percentages returned by early devt kernels. + Add backward-compatible flags field to on-disk format_text metadata. Fix dmeventd monitoring libraries to link against liblvm2cmd again. (2.02.39) Version 2.02.39 - 27th June 2008 --- LVM2/lib/activate/dev_manager.c 2008/06/18 11:32:14 1.138 +++ LVM2/lib/activate/dev_manager.c 2008/07/15 00:25:51 1.139 @@ -379,8 +379,7 @@ !segtype->ops->target_percent(&dm->target_state, dm->mem, dm->cmd, seg, params, &total_numerator, - &total_denominator, - percent)) + &total_denominator)) goto_out; } while (next); @@ -393,7 +392,7 @@ if (total_denominator) *percent = (float) total_numerator *100 / total_denominator; - else if (*percent < 0) + else *percent = 100; log_debug("LV percent: %f", *percent); --- LVM2/lib/metadata/segtype.h 2008/06/25 16:52:26 1.20 +++ LVM2/lib/metadata/segtype.h 2008/07/15 00:25:51 1.21 @@ -77,7 +77,7 @@ struct cmd_context *cmd, struct lv_segment *seg, char *params, uint64_t *total_numerator, - uint64_t *total_denominator, float *percent); + uint64_t *total_denominator); int (*target_present) (const struct lv_segment *seg, unsigned *attributes); int (*modules_needed) (struct dm_pool *mem, --- LVM2/lib/mirror/mirrored.c 2008/04/10 18:53:36 1.55 +++ LVM2/lib/mirror/mirrored.c 2008/07/15 00:25:51 1.56 @@ -176,8 +176,7 @@ static int _mirrored_target_percent(void **target_state, struct dm_pool *mem, struct cmd_context *cmd, struct lv_segment *seg, char *params, uint64_t *total_numerator, - uint64_t *total_denominator, - float *percent __attribute((unused))) + uint64_t *total_denominator) { struct mirror_state *mirr_state; uint64_t numerator, denominator; --- LVM2/lib/snapshot/snapshot.c 2008/04/07 10:23:47 1.30 +++ LVM2/lib/snapshot/snapshot.c 2008/07/15 00:25:52 1.31 @@ -95,20 +95,14 @@ struct cmd_context *cmd __attribute((unused)), struct lv_segment *seg __attribute((unused)), char *params, uint64_t *total_numerator, - uint64_t *total_denominator, float *percent) + uint64_t *total_denominator) { - float percent2; uint64_t numerator, denominator; - if (strchr(params, '/')) { - if (sscanf(params, "%" PRIu64 "/%" PRIu64, - &numerator, &denominator) == 2) { - *total_numerator += numerator; - *total_denominator += denominator; - } - } else if (sscanf(params, "%f", &percent2) == 1) { - *percent += percent2; - *percent /= 2; + if (sscanf(params, "%" PRIu64 "/%" PRIu64, + &numerator, &denominator) == 2) { + *total_numerator += numerator; + *total_denominator += denominator; } return 1; From agk@sourceware.org Wed Jul 16 10:46:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 16 Jul 2008 10:46:00 -0000 Subject: LVM2 ./WHATS_NEW tools/pvchange.c Message-ID: <20080716104612.25412.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-07-16 10:46:12 Modified files: . : WHATS_NEW tools : pvchange.c Log message: Fix pvchange -M1 -u to preserve existing extent locations when there's a VG. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.929&r2=1.930 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvchange.c.diff?cvsroot=lvm2&r1=1.59&r2=1.60 --- LVM2/WHATS_NEW 2008/07/15 00:25:51 1.929 +++ LVM2/WHATS_NEW 2008/07/16 10:46:12 1.930 @@ -1,5 +1,6 @@ Version 2.02.40 - ================================ + Fix pvchange -M1 -u to preserve existing extent locations when there's a VG. Cease recognising snapshot-in-use percentages returned by early devt kernels. Add backward-compatible flags field to on-disk format_text metadata. Fix dmeventd monitoring libraries to link against liblvm2cmd again. (2.02.39) --- LVM2/tools/pvchange.c 2008/02/06 15:47:28 1.59 +++ LVM2/tools/pvchange.c 2008/07/16 10:46:12 1.60 @@ -26,6 +26,9 @@ struct list mdas; uint64_t sector; uint32_t orig_pe_alloc_count; + /* FIXME Next three only required for format1. */ + uint32_t orig_pe_count, orig_pe_size; + uint64_t orig_pe_start; const char *pv_name = pv_dev_name(pv); const char *tag = NULL; @@ -171,6 +174,12 @@ if (!is_orphan(pv)) { orig_vg_name = pv_vg_name(pv); orig_pe_alloc_count = pv_pe_alloc_count(pv); + + /* FIXME format1 pv_write doesn't preserve these. */ + orig_pe_size = pv_pe_size(pv); + orig_pe_start = pv_pe_start(pv); + orig_pe_count = pv_pe_count(pv); + pv->vg_name = pv->fmt->orphan_vg_name; pv->pe_alloc_count = 0; if (!(pv_write(cmd, pv, NULL, INT64_C(-1)))) { @@ -181,6 +190,10 @@ } pv->vg_name = orig_vg_name; pv->pe_alloc_count = orig_pe_alloc_count; + + pv->pe_size = orig_pe_size; + pv->pe_start = orig_pe_start; + pv->pe_count = orig_pe_count; } } From wysochanski@sourceware.org Wed Jul 16 21:32:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Wed, 16 Jul 2008 21:32:00 -0000 Subject: LVM2 lib/format_text/format-text.c ./WHATS_NEW ... Message-ID: <20080716213239.7402.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-07-16 21:32:39 Modified files: lib/format_text: format-text.c . : WHATS_NEW Added files: test : t-pvcreate-usage.sh Log message: Add pvcreate sanity tests, check for label_write() failure in _text_pv_write(). Failure to check for label_write() return code caused the following test to indicate it passed when it really failed: pvcreate rejects labelsector > 1000000000000 Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.90&r2=1.91 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-pvcreate-usage.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.930&r2=1.931 --- LVM2/lib/format_text/format-text.c 2008/03/17 16:51:31 1.90 +++ LVM2/lib/format_text/format-text.c 2008/07/16 21:32:38 1.91 @@ -1363,7 +1363,10 @@ } } - label_write(pv->dev, label); + if (!label_write(pv->dev, label)) { + dev_close(pv->dev); + return_0; + } if (!dev_close(pv->dev)) return_0; /cvs/lvm2/LVM2/test/t-pvcreate-usage.sh,v --> standard output revision 1.1 --- LVM2/test/t-pvcreate-usage.sh +++ - 2008-07-16 21:32:39.280246000 +0000 @@ -0,0 +1,115 @@ +#!/bin/sh +# 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 + +test_description='Test pvcreate option values' +privileges_required_=1 + +. ./test-lib.sh + +cleanup_() +{ + test -n "$d1" && losetup -d "$d1" + test -n "$d2" && losetup -d "$d2" + test -n "$d3" && losetup -d "$d3" + test -n "$d4" && losetup -d "$d4" + rm -f "$f1" "$f2" "$f3" "$f4" +} + +test_expect_success \ + 'set up temp files, loopback devices, PVs, vgname' \ + 'f1=$(pwd)/1 && d1=$(loop_setup_ "$f1") && + f2=$(pwd)/2 && d2=$(loop_setup_ "$f2") && + f3=$(pwd)/3 && d3=$(loop_setup_ "$f3") && + f4=$(pwd)/4 && d4=$(loop_setup_ "$f4")' + +# x. negative setphysicalvolumesize, metadatasize +test_expect_success \ + 'pvcreate rejects negative setphysicalvolumesize' \ + 'pvcreate --setphysicalvolumesize -1024 $d1; + status=$?; echo status=$status; test $status != 0' + +test_expect_success \ + 'pvcreate rejects negative metadatasize' \ + 'pvcreate --metadatasize -1024 $d1; + status=$?; echo status=$status; test $status != 0' + +# x. metadatasize 0, defaults to 255 +# FIXME: unable to check default value, not in reporting cmds +# should default to 255 according to code +# check_pv_field_ pv_mda_size 255 && +test_expect_success \ + 'pvcreate accepts metadatasize 0' \ + 'pvcreate --metadatasize 0 $d1 && + pvremove $d1' + +# x. metadatasize too large +# For some reason we allow this, even though there's no room for data? +#test_expect_success \ +# 'pvcreate rejects metadatasize too large' \ +# 'pvcreate --metadatasize 100000000000000 $d1; +# status=$?; echo status=$status; test $status != 0' + +# x. metadatacopies < 0, defaults to 1 +test_expect_success \ + 'pvcreate rejects metadatacopies < 0' \ + 'pvcreate --metadatacopies -1 $d1; + status=$?; echo status=$status; test $status != 0' + +# x. metadatacopies = 0, 1, 2 pass, > 2 fail +test_expect_success \ + 'pvcreate accepts metadatacopies = 0, 1, 2' \ + 'pvcreate --metadatacopies 0 $d1 && + pvcreate --metadatacopies 1 $d2 && + pvcreate --metadatacopies 2 $d3 && + check_pv_field_ $d1 pv_mda_count 0 && + check_pv_field_ $d2 pv_mda_count 1 && + check_pv_field_ $d3 pv_mda_count 2 && + pvremove $d1 && + pvremove $d2 && + pvremove $d3' + +# x. metadatacopies > 2 fail +test_expect_success \ + 'pvcreate rejects metadatacopies > 2' \ + 'pvcreate --metadatacopies 3 $d1 && + status=$?; echo status=$status; test $status != 0' + +# x. bogus device given +test_expect_success \ + 'pvcreate rejects invalid device' \ + 'pvcreate $d1bogus && + status=$?; echo status=$status; test $status != 0' + +# x. labelsector out of range (< 0 or > deviceSizeInSectors) +test_expect_success \ + 'pvcreate rejects labelsector < 0' \ + 'pvcreate --labelsector -1 $d1; + status=$?; echo status=$status; test $status != 0' + +test_expect_success \ + 'pvcreate rejects labelsector > 1000000000000' \ + 'pvcreate --labelsector 1000000000000 $d1; + status=$?; echo status=$status; test $status != 0' + +# other possibilites based on code inspection (not sure how hard) +# x. device too small (min of 512 * 1024 KB) +# x. device filtered out +# x. unable to open /dev/urandom RDONLY +# x. device too large (pe_count > UINT32_MAX) +# x. device read-only +# x. unable to open device readonly +# x. BLKGETSIZE64 fails +# x. set size to value inconsistent with device / PE size + +test_done +# Local Variables: +# indent-tabs-mode: nil +# End: --- LVM2/WHATS_NEW 2008/07/16 10:46:12 1.930 +++ LVM2/WHATS_NEW 2008/07/16 21:32:38 1.931 @@ -1,5 +1,6 @@ Version 2.02.40 - ================================ + Add pvcreate sanity tests, check for label_write() failure in _text_pv_write(). Fix pvchange -M1 -u to preserve existing extent locations when there's a VG. Cease recognising snapshot-in-use percentages returned by early devt kernels. Add backward-compatible flags field to on-disk format_text metadata. From wysochanski@sourceware.org Thu Jul 17 03:17:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Thu, 17 Jul 2008 03:17:00 -0000 Subject: LVM2 ./WHATS_NEW test/t-pvcreate-usage.sh test ... Message-ID: <20080717031703.22076.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-07-17 03:17:02 Modified files: . : WHATS_NEW test : t-pvcreate-usage.sh t-vgsplit-usage.sh Added files: test : t-pvcreate-operation.sh Log message: Update pvcreate and vgsplit tests. Add more pvcreate tests. Start handling lvm1 and lvm2 metadata and metadatacopies=0,1. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.931&r2=1.932 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-pvcreate-operation.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-pvcreate-usage.sh.diff?cvsroot=lvm2&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-vgsplit-usage.sh.diff?cvsroot=lvm2&r1=1.5&r2=1.6 --- LVM2/WHATS_NEW 2008/07/16 21:32:38 1.931 +++ LVM2/WHATS_NEW 2008/07/17 03:16:59 1.932 @@ -1,6 +1,7 @@ Version 2.02.40 - ================================ - Add pvcreate sanity tests, check for label_write() failure in _text_pv_write(). + Check for label_write() failure in _text_pv_write(). + Add pvcreate tests and update vgsplit tests to handle lvm1 and lvm2 metadata. Fix pvchange -M1 -u to preserve existing extent locations when there's a VG. Cease recognising snapshot-in-use percentages returned by early devt kernels. Add backward-compatible flags field to on-disk format_text metadata. /cvs/lvm2/LVM2/test/t-pvcreate-operation.sh,v --> standard output revision 1.1 --- LVM2/test/t-pvcreate-operation.sh +++ - 2008-07-17 03:17:02.366739000 +0000 @@ -0,0 +1,72 @@ +#!/bin/sh +# 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 + +test_description='Test pvcreate logic operation' +privileges_required_=1 + +. ./test-lib.sh + +cleanup_() +{ + test -n "$d1" && losetup -d "$d1" + test -n "$d2" && losetup -d "$d2" + test -n "$d3" && losetup -d "$d3" + test -n "$d4" && losetup -d "$d4" + rm -f "$f1" "$f2" "$f3" "$f4" +} + +test_expect_success \ + 'set up temp files, loopback devices, PVs, vgname' \ + 'f1=$(pwd)/1 && d1=$(loop_setup_ "$f1") && + f2=$(pwd)/2 && d2=$(loop_setup_ "$f2") && + f3=$(pwd)/3 && d3=$(loop_setup_ "$f3") && + f4=$(pwd)/4 && d4=$(loop_setup_ "$f4") && + vg1=$(this_test_)-test-vg1-$$' + +for mdatype in 1 2 +do +test_expect_success \ + "pvcreate (lvm$mdatype) fails when PV belongs to VG" \ + 'pvcreate -M$mdatype $d1 && + vgcreate -M$mdatype $vg1 $d1 && + pvcreate -M$mdatype $d1; + status=$?; echo status=$status; test $status != 0 && + vgremove -f $vg1 && + pvremove -f $d1' + +done + +test_expect_success \ + 'pvcreate (lvm2) fails when PV with metadatacopies=0 belongs to VG' \ + 'pvcreate --metadatacopies 0 $d1 && + pvcreate --metadatacopies 1 $d2 && + vgcreate $vg1 $d1 $d2 && + pvcreate $d1; + status=$?; echo status=$status; test $status != 0 && + vgremove -f $vg1 && + pvremove -f $d2 && + pvremove -f $d1' + +test_expect_success \ + 'pvcreate (lvm2) succeeds with -ff when PV with metadatacopies=0 belongs to VG' \ + 'pvcreate --metadatacopies 0 $d1 && + pvcreate --metadatacopies 1 $d2 && + vgcreate $vg1 $d1 $d2 && + pvcreate -ff -y $d1 && + vgreduce --removemissing $vg1 && + vgremove -ff $vg1 && + pvremove -f $d2 && + pvremove -f $d1' + +test_done +# Local Variables: +# indent-tabs-mode: nil +# End: --- LVM2/test/t-pvcreate-usage.sh 2008/07/16 21:32:38 1.1 +++ LVM2/test/t-pvcreate-usage.sh 2008/07/17 03:17:01 1.2 @@ -28,9 +28,9 @@ 'f1=$(pwd)/1 && d1=$(loop_setup_ "$f1") && f2=$(pwd)/2 && d2=$(loop_setup_ "$f2") && f3=$(pwd)/3 && d3=$(loop_setup_ "$f3") && - f4=$(pwd)/4 && d4=$(loop_setup_ "$f4")' + f4=$(pwd)/4 && d4=$(loop_setup_ "$f4") && + vg1=$(this_test_)-test-vg1-$$' -# x. negative setphysicalvolumesize, metadatasize test_expect_success \ 'pvcreate rejects negative setphysicalvolumesize' \ 'pvcreate --setphysicalvolumesize -1024 $d1; @@ -57,13 +57,11 @@ # 'pvcreate --metadatasize 100000000000000 $d1; # status=$?; echo status=$status; test $status != 0' -# x. metadatacopies < 0, defaults to 1 test_expect_success \ 'pvcreate rejects metadatacopies < 0' \ 'pvcreate --metadatacopies -1 $d1; status=$?; echo status=$status; test $status != 0' -# x. metadatacopies = 0, 1, 2 pass, > 2 fail test_expect_success \ 'pvcreate accepts metadatacopies = 0, 1, 2' \ 'pvcreate --metadatacopies 0 $d1 && @@ -76,19 +74,16 @@ pvremove $d2 && pvremove $d3' -# x. metadatacopies > 2 fail test_expect_success \ 'pvcreate rejects metadatacopies > 2' \ - 'pvcreate --metadatacopies 3 $d1 && + 'pvcreate --metadatacopies 3 $d1; status=$?; echo status=$status; test $status != 0' -# x. bogus device given test_expect_success \ 'pvcreate rejects invalid device' \ - 'pvcreate $d1bogus && + 'pvcreate $d1bogus; status=$?; echo status=$status; test $status != 0' -# x. labelsector out of range (< 0 or > deviceSizeInSectors) test_expect_success \ 'pvcreate rejects labelsector < 0' \ 'pvcreate --labelsector -1 $d1; --- LVM2/test/t-vgsplit-usage.sh 2008/04/10 19:59:43 1.5 +++ LVM2/test/t-vgsplit-usage.sh 2008/07/17 03:17:01 1.6 @@ -36,12 +36,17 @@ vg2=$(this_test_)-test-vg2-$$ && lv1=$(this_test_)-test-lv1-$$ && lv2=$(this_test_)-test-lv2-$$ && - lv3=$(this_test_)-test-lv3-$$ && - pvcreate $d1 $d2 $d3 $d4' + lv3=$(this_test_)-test-lv3-$$' +for mdatype in 1 2 +do test_expect_success \ - 'vgsplit accepts new vg as destination of split' \ - 'vgcreate $vg1 $d1 $d2 && + "(lvm$mdatype) setup PVs" \ + 'pvcreate -M$mdatype $d1 $d2 $d3 $d4' + +test_expect_success \ + "(lvm$mdatype) vgsplit accepts new vg as destination of split" \ + 'vgcreate -M$mdatype $vg1 $d1 $d2 && vgsplit $vg1 $vg2 $d1 1>err; status=$?; echo status=$status; test $status = 0 && grep "New volume group \"$vg2\" successfully split from \"$vg1\"" err && @@ -49,9 +54,9 @@ vgremove $vg2' test_expect_success \ - 'vgsplit accepts existing vg as destination of split' \ - 'vgcreate $vg1 $d1 $d2 && - vgcreate $vg2 $d3 $d4 && + "(lvm$mdatype) vgsplit accepts existing vg as destination of split" \ + 'vgcreate -M$mdatype $vg1 $d1 $d2 && + vgcreate -M$mdatype $vg2 $d3 $d4 && vgsplit $vg1 $vg2 $d1 1>err; status=$?; echo status=$status; test $status = 0 && grep "Existing volume group \"$vg2\" successfully split from \"$vg1\"" err && @@ -59,25 +64,25 @@ vgremove $vg2' test_expect_success \ - 'vgsplit accepts --maxphysicalvolumes 128 on new VG' \ - 'vgcreate $vg1 $d1 $d2 && + "(lvm$mdatype) vgsplit accepts --maxphysicalvolumes 128 on new VG" \ + 'vgcreate -M$mdatype $vg1 $d1 $d2 && vgsplit --maxphysicalvolumes 128 $vg1 $vg2 $d1 && check_vg_field_ $vg2 max_pv 128 && vgremove $vg1 && vgremove $vg2' test_expect_success \ - 'vgsplit accepts --maxlogicalvolumes 128 on new VG' \ - 'vgcreate $vg1 $d1 $d2 && + "(lvm$mdatype) vgsplit accepts --maxlogicalvolumes 128 on new VG" \ + 'vgcreate -M$mdatype $vg1 $d1 $d2 && vgsplit --maxlogicalvolumes 128 $vg1 $vg2 $d1 && check_vg_field_ $vg2 max_lv 128 && vgremove $vg1 && vgremove $vg2' test_expect_success \ - 'vgsplit rejects split because max_pv of destination would be exceeded' \ - 'vgcreate --maxphysicalvolumes 2 $vg1 $d1 $d2 && - vgcreate --maxphysicalvolumes 2 $vg2 $d3 $d4 && + "(lvm$mdatype) vgsplit rejects split because max_pv of destination would be exceeded" \ + 'vgcreate -M$mdatype --maxphysicalvolumes 2 $vg1 $d1 $d2 && + vgcreate -M$mdatype --maxphysicalvolumes 2 $vg2 $d3 $d4 && vgsplit $vg1 $vg2 $d1 2>err; status=$?; echo status=$status; test $status = 5 && grep "^ Maximum number of physical volumes (2) exceeded" err && @@ -85,9 +90,9 @@ vgremove $vg1' test_expect_success \ - 'vgsplit rejects split because maxphysicalvolumes given with existing vg' \ - 'vgcreate --maxphysicalvolumes 2 $vg1 $d1 $d2 && - vgcreate --maxphysicalvolumes 2 $vg2 $d3 $d4 && + "(lvm$mdatype) vgsplit rejects split because maxphysicalvolumes given with existing vg" \ + 'vgcreate -M$mdatype --maxphysicalvolumes 2 $vg1 $d1 $d2 && + vgcreate -M$mdatype --maxphysicalvolumes 2 $vg2 $d3 $d4 && vgsplit --maxphysicalvolumes 2 $vg1 $vg2 $d1 2>err; status=$?; echo status=$status; test $status = 5 && grep "^ Volume group \"$vg2\" exists, but new VG option specified" err && @@ -95,9 +100,9 @@ vgremove $vg1' test_expect_success \ - 'vgsplit rejects split because maxlogicalvolumes given with existing vg' \ - 'vgcreate --maxlogicalvolumes 2 $vg1 $d1 $d2 && - vgcreate --maxlogicalvolumes 2 $vg2 $d3 $d4 && + "(lvm$mdatype) vgsplit rejects split because maxlogicalvolumes given with existing vg" \ + 'vgcreate -M$mdatype --maxlogicalvolumes 2 $vg1 $d1 $d2 && + vgcreate -M$mdatype --maxlogicalvolumes 2 $vg2 $d3 $d4 && vgsplit --maxlogicalvolumes 2 $vg1 $vg2 $d1 2>err; status=$?; echo status=$status; test $status = 5 && grep "^ Volume group \"$vg2\" exists, but new VG option specified" err && @@ -105,9 +110,9 @@ vgremove $vg1' test_expect_success \ - 'vgsplit rejects split because alloc given with existing vg' \ - 'vgcreate --alloc cling $vg1 $d1 $d2 && - vgcreate --alloc cling $vg2 $d3 $d4 && + "(lvm$mdatype) vgsplit rejects split because alloc given with existing vg" \ + 'vgcreate -M$mdatype --alloc cling $vg1 $d1 $d2 && + vgcreate -M$mdatype --alloc cling $vg2 $d3 $d4 && vgsplit --alloc cling $vg1 $vg2 $d1 2>err; status=$?; echo status=$status; test $status = 5 && grep "^ Volume group \"$vg2\" exists, but new VG option specified" err && @@ -115,9 +120,9 @@ vgremove $vg1' test_expect_success \ - 'vgsplit rejects split because clustered given with existing vg' \ - 'vgcreate --clustered n $vg1 $d1 $d2 && - vgcreate --clustered n $vg2 $d3 $d4 && + "(lvm$mdatype) vgsplit rejects split because clustered given with existing vg" \ + 'vgcreate -M$mdatype --clustered n $vg1 $d1 $d2 && + vgcreate -M$mdatype --clustered n $vg2 $d3 $d4 && vgsplit --clustered n $vg1 $vg2 $d1 2>err; status=$?; echo status=$status; test $status = 5 && grep "^ Volume group \"$vg2\" exists, but new VG option specified" err && @@ -125,22 +130,10 @@ vgremove $vg1' test_expect_success \ - 'vgsplit rejects split because metadata types differ' \ - 'pvcreate -ff -M1 $d3 $d4 && - pvcreate -ff -M2 $d1 $d2 && - vgcreate -M1 $vg1 $d3 $d4 && - vgcreate -M2 $vg2 $d1 $d2 && - vgsplit $vg1 $vg2 $d3 2>err; - status=$?; echo status=$status; test $status = 5 && - grep "^ Metadata types differ" err && - vgremove $vg2 && - vgremove $vg1' - -test_expect_success \ - 'vgsplit rejects vg with active lv' \ - 'pvcreate -ff -M2 $d3 $d4 && - vgcreate $vg1 $d1 $d2 && - vgcreate $vg2 $d3 $d4 && + "(lvm$mdatype) vgsplit rejects vg with active lv" \ + 'pvcreate -ff -M$mdatype $d3 $d4 && + vgcreate -M$mdatype $vg1 $d1 $d2 && + vgcreate -M$mdatype $vg2 $d3 $d4 && lvcreate -l 4 -n $lv1 $vg1 && vgsplit $vg1 $vg2 $d1 2>err; status=$?; echo status=$status; test $status = 5 && @@ -149,9 +142,9 @@ vgremove -f $vg1' test_expect_success \ - 'vgsplit rejects split because max_lv is exceeded' \ - 'vgcreate --maxlogicalvolumes 2 $vg1 $d1 $d2 && - vgcreate --maxlogicalvolumes 2 $vg2 $d3 $d4 && + "(lvm$mdatype) vgsplit rejects split because max_lv is exceeded" \ + 'vgcreate -M$mdatype --maxlogicalvolumes 2 $vg1 $d1 $d2 && + vgcreate -M$mdatype --maxlogicalvolumes 2 $vg2 $d3 $d4 && lvcreate -l 4 -n $lv1 $vg1 && lvcreate -l 4 -n $lv2 $vg1 && lvcreate -l 4 -n $lv3 $vg2 && @@ -164,8 +157,8 @@ vgremove -f $vg1' test_expect_success \ - 'verify default - max_lv attribute from new VG is same as source VG' \ - 'vgcreate $vg1 $d1 $d2 && + "(lvm$mdatype) vgsplit verify default - max_lv attribute from new VG is same as source VG" \ + 'vgcreate -M$mdatype $vg1 $d1 $d2 && lvcreate -l 4 -n $lv1 $vg1 && vgchange -an $vg1 && vgsplit $vg1 $vg2 $d1 && @@ -174,8 +167,8 @@ vgremove -f $vg1' test_expect_success \ - 'verify default - max_pv attribute from new VG is same as source VG' \ - 'vgcreate $vg1 $d1 $d2 && + "(lvm$mdatype) vgsplit verify default - max_pv attribute from new VG is same as source VG" \ + 'vgcreate -M$mdatype $vg1 $d1 $d2 && lvcreate -l 4 -n $lv1 $vg1 && vgchange -an $vg1 && vgsplit $vg1 $vg2 $d1 && @@ -184,8 +177,8 @@ vgremove -f $vg1' test_expect_success \ - 'verify default - vg_fmt attribute from new VG is same as source VG' \ - 'vgcreate $vg1 $d1 $d2 && + "(lvm$mdatype) vgsplit verify default - vg_fmt attribute from new VG is same as source VG" \ + 'vgcreate -M$mdatype $vg1 $d1 $d2 && lvcreate -l 4 -n $lv1 $vg1 && vgchange -an $vg1 && vgsplit $vg1 $vg2 $d1 && @@ -194,9 +187,9 @@ vgremove -f $vg1' test_expect_success \ - 'vgsplit rejects split because PV not in VG' \ - 'vgcreate $vg1 $d1 $d2 && - vgcreate $vg2 $d3 $d4 && + "(lvm$mdatype) vgsplit rejects split because PV not in VG" \ + 'vgcreate -M$mdatype $vg1 $d1 $d2 && + vgcreate -M$mdatype $vg2 $d3 $d4 && lvcreate -l 4 -n $lv1 $vg1 && lvcreate -l 4 -n $lv2 $vg1 && vgchange -an $vg1 && @@ -204,6 +197,19 @@ status=$?; echo status=$status; test $status = 5 && vgremove -f $vg2 && vgremove -f $vg1' +done + +test_expect_success \ + '(lvm2) vgsplit rejects split because metadata types differ' \ + 'pvcreate -ff -M1 $d3 $d4 && + pvcreate -ff -M2 $d1 $d2 && + vgcreate -M1 $vg1 $d3 $d4 && + vgcreate -M2 $vg2 $d1 $d2 && + vgsplit $vg1 $vg2 $d3 2>err; + status=$?; echo status=$status; test $status = 5 && + grep "^ Metadata types differ" err && + vgremove $vg2 && + vgremove $vg1' test_done # Local Variables: From wysochanski@sourceware.org Thu Jul 17 04:03:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Thu, 17 Jul 2008 04:03:00 -0000 Subject: LVM2/test t-vgsplit-usage.sh Message-ID: <20080717040304.32437.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-07-17 04:03:04 Modified files: test : t-vgsplit-usage.sh Log message: Only use lvm2 metadata for now. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-vgsplit-usage.sh.diff?cvsroot=lvm2&r1=1.6&r2=1.7 --- LVM2/test/t-vgsplit-usage.sh 2008/07/17 03:17:01 1.6 +++ LVM2/test/t-vgsplit-usage.sh 2008/07/17 04:03:04 1.7 @@ -38,7 +38,7 @@ lv2=$(this_test_)-test-lv2-$$ && lv3=$(this_test_)-test-lv3-$$' -for mdatype in 1 2 +for mdatype in 2 do test_expect_success \ "(lvm$mdatype) setup PVs" \ From wysochanski@sourceware.org Thu Jul 17 15:19:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Thu, 17 Jul 2008 15:19:00 -0000 Subject: LVM2/tools lvcreate.c Message-ID: <20080717151943.2052.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-07-17 15:19:42 Modified files: tools : lvcreate.c Log message: Refactor _lvcreate() - no functional change. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.175&r2=1.176 --- LVM2/tools/lvcreate.c 2008/06/05 13:38:30 1.175 +++ LVM2/tools/lvcreate.c 2008/07/17 15:19:42 1.176 @@ -523,8 +523,6 @@ struct lvinfo info; uint32_t pv_extent_count; - status |= lp->permission | VISIBLE_LV; - if (lp->lv_name && find_lv_in_vg(vg, lp->lv_name)) { log_error("Logical volume \"%s\" already exists in " "volume group \"%s\"", lp->lv_name, lp->vg_name); @@ -544,16 +542,6 @@ return 0; } - /* - * Create the pv list. - */ - if (lp->pv_count) { - if (!(pvh = create_pv_list(cmd->mem, vg, - lp->pv_count, lp->pvs, 1))) - return_0; - } else - pvh = &vg->pvs; - if (lp->stripe_size > vg->extent_size) { log_error("Reducing requested stripe size %s to maximum, " "physical extent size %s", @@ -594,6 +582,16 @@ lp->extents = (uint64_t) tmp_size / vg->extent_size; } + /* + * Create the pv list. + */ + if (lp->pv_count) { + if (!(pvh = create_pv_list(cmd->mem, vg, + lp->pv_count, lp->pvs, 1))) + return_0; + } else + pvh = &vg->pvs; + switch(lp->percent) { case PERCENT_VG: lp->extents = lp->extents * vg->extent_count / 100; @@ -631,6 +629,8 @@ return 0; } + status |= lp->permission | VISIBLE_LV; + if (lp->snapshot) { if (!activation()) { log_error("Can't create snapshot without using " From wysochanski@sourceware.org Mon Jul 21 18:50:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Mon, 21 Jul 2008 18:50:00 -0000 Subject: LVM2/test t-pvcreate-operation.sh Message-ID: <20080721185011.7527.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-07-21 18:50:10 Modified files: test : t-pvcreate-operation.sh Log message: Add more pvcreate tests to validate writing lvm2 label using --labelsector. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-pvcreate-operation.sh.diff?cvsroot=lvm2&r1=1.1&r2=1.2 --- LVM2/test/t-pvcreate-operation.sh 2008/07/17 03:17:01 1.1 +++ LVM2/test/t-pvcreate-operation.sh 2008/07/21 18:50:10 1.2 @@ -66,6 +66,20 @@ pvremove -f $d2 && pvremove -f $d1' +for i in 0 1 2 3 +do + test_expect_success \ + "pvcreate (lvm2) succeeds writing LVM label at sector $i" \ + 'pvcreate --labelsector $i $d1 && + dd if=$d1 bs=512 skip=$i count=1 status=noxfer 2>&1 | strings | grep -q LABELONE; + test $? == 0 && + pvremove -f $d1' +done + +test_expect_failure \ + "pvcreate (lvm2) fails writing LVM label at sector 4" \ + 'pvcreate --labelsector 4 $d1' + test_done # Local Variables: # indent-tabs-mode: nil From wysochanski@sourceware.org Mon Jul 21 19:26:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Mon, 21 Jul 2008 19:26:00 -0000 Subject: LVM2 ./WHATS_NEW tools/pvcreate.c Message-ID: <20080721192635.14866.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-07-21 19:26:33 Modified files: . : WHATS_NEW tools : pvcreate.c Log message: Refactor pvcreate to divide parameter parsing & validation from create logic. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.932&r2=1.933 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.63&r2=1.64 --- LVM2/WHATS_NEW 2008/07/17 03:16:59 1.932 +++ LVM2/WHATS_NEW 2008/07/21 19:26:33 1.933 @@ -1,5 +1,6 @@ Version 2.02.40 - ================================ + Refactor pvcreate to divide parameter parsing & validation from create logic. Check for label_write() failure in _text_pv_write(). Add pvcreate tests and update vgsplit tests to handle lvm1 and lvm2 metadata. Fix pvchange -M1 -u to preserve existing extent locations when there's a VG. --- LVM2/tools/pvcreate.c 2008/06/24 20:10:32 1.63 +++ LVM2/tools/pvcreate.c 2008/07/21 19:26:33 1.64 @@ -275,57 +275,84 @@ return ECMD_FAILED; } -int pvcreate(struct cmd_context *cmd, int argc, char **argv) +/* + * Intial sanity checking of command-line arguments and fill in parameters + * for pvcreate command. More comprehensive validation is done in + * pvcreate_validate_params(). + */ +static int pvcreate_fill_params(struct cmd_context *cmd, + int argc, char **argv, + struct pvcreate_params *pp) { - int i, r; - int ret = ECMD_PROCESSED; - struct pvcreate_params pp; - if (!argc) { log_error("Please enter a physical volume path"); - return EINVALID_CMD_LINE; + return 0; } if (arg_count(cmd, restorefile_ARG) && !arg_count(cmd, uuidstr_ARG)) { log_error("--uuid is required with --restorefile"); - return EINVALID_CMD_LINE; + return 0; } if (arg_count(cmd, uuidstr_ARG) && argc != 1) { log_error("Can only set uuid on one volume at once"); - return EINVALID_CMD_LINE; + return 0; } if (arg_count(cmd, yes_ARG) && !arg_count(cmd, force_ARG)) { log_error("Option y can only be given with option f"); - return EINVALID_CMD_LINE; + return 0; } if (arg_int_value(cmd, labelsector_ARG, 0) >= LABEL_SCAN_SECTORS) { log_error("labelsector must be less than %lu", LABEL_SCAN_SECTORS); - return EINVALID_CMD_LINE; + return 0; } if (!(cmd->fmt->features & FMT_MDAS) && (arg_count(cmd, metadatacopies_ARG) || arg_count(cmd, metadatasize_ARG))) { log_error("Metadata parameters only apply to text format"); - return EINVALID_CMD_LINE; + return 0; } if (arg_count(cmd, metadatacopies_ARG) && arg_int_value(cmd, metadatacopies_ARG, -1) > 2) { log_error("Metadatacopies may only be 0, 1 or 2"); - return EINVALID_CMD_LINE; + return 0; } if (arg_count(cmd, zero_ARG)) - pp.zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n"); + pp->zero = strcmp(arg_str_value(cmd, zero_ARG, "y"), "n"); else if (arg_count(cmd, restorefile_ARG) || arg_count(cmd, uuidstr_ARG)) - pp.zero = 0; + pp->zero = 0; else - pp.zero = 1; + pp->zero = 1; + + return 1; +} + + +static int pvcreate_validate_params(struct cmd_context *cmd, + struct pvcreate_params *pp) +{ + return 1; +} + +int pvcreate(struct cmd_context *cmd, int argc, char **argv) +{ + int i, r; + int ret = ECMD_PROCESSED; + struct pvcreate_params pp; + + if (!pvcreate_fill_params(cmd, argc, argv, &pp)) { + return EINVALID_CMD_LINE; + } + + if (!pvcreate_validate_params(cmd, &pp)) { + return EINVALID_CMD_LINE; + } for (i = 0; i < argc; i++) { r = pvcreate_single(cmd, argv[i], &pp); From wysochanski@sourceware.org Mon Jul 21 19:27:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Mon, 21 Jul 2008 19:27:00 -0000 Subject: LVM2/tools pvcreate.c Message-ID: <20080721192722.15094.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-07-21 19:27:22 Modified files: tools : pvcreate.c Log message: Refactor pvcreate - divide parameter parsing & validation from create logic. Move size (setphysicalvolumesize option), metadatacopies and metadatasize validation. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.64&r2=1.65 --- LVM2/tools/pvcreate.c 2008/07/21 19:26:33 1.64 +++ LVM2/tools/pvcreate.c 2008/07/21 19:27:22 1.65 @@ -18,6 +18,9 @@ struct pvcreate_params { int zero; + uint64_t size; + int pvmetadatacopies; + uint64_t pvmetadatasize; }; const char _really_init[] = @@ -142,11 +145,8 @@ void *existing_pv; struct id id, *idp = NULL; const char *uuid = NULL; - uint64_t size = 0; struct device *dev; struct list mdas; - int pvmetadatacopies; - uint64_t pvmetadatasize; struct volume_group *vg; const char *restorefile; uint64_t pe_start = 0; @@ -196,28 +196,6 @@ if (sigint_caught()) goto error; - if (arg_sign_value(cmd, physicalvolumesize_ARG, 0) == SIGN_MINUS) { - log_error("Physical volume size may not be negative"); - goto error; - } - size = arg_uint64_value(cmd, physicalvolumesize_ARG, UINT64_C(0)); - - if (arg_sign_value(cmd, metadatasize_ARG, 0) == SIGN_MINUS) { - log_error("Metadata size may not be negative"); - goto error; - } - pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, UINT64_C(0)); - if (!pvmetadatasize) - pvmetadatasize = find_config_tree_int(cmd, - "metadata/pvmetadatasize", - DEFAULT_PVMETADATASIZE); - - pvmetadatacopies = arg_int_value(cmd, metadatacopies_ARG, -1); - if (pvmetadatacopies < 0) - pvmetadatacopies = find_config_tree_int(cmd, - "metadata/pvmetadatacopies", - DEFAULT_PVMETADATACOPIES); - if (!(dev = dev_cache_get(pv_name, cmd->filter))) { log_error("%s: Couldn't find device. Check your filters?", pv_name); @@ -225,9 +203,9 @@ } list_init(&mdas); - if (!(pv = pv_create(cmd, dev, idp, size, pe_start, - extent_count, extent_size, - pvmetadatacopies, pvmetadatasize, &mdas))) { + if (!(pv = pv_create(cmd, dev, idp, pp->size, pe_start, + extent_count, extent_size, pp->pvmetadatacopies, + pp->pvmetadatasize,&mdas))) { log_error("Failed to setup physical volume \"%s\"", pv_name); goto error; } @@ -276,13 +254,17 @@ } /* - * Intial sanity checking of command-line arguments and fill in parameters - * for pvcreate command. More comprehensive validation is done in - * pvcreate_validate_params(). + * Intial sanity checking of command-line arguments and fill in 'pp' fields. + * + * Input arguments: + * cmd, argc, argv + * + * Output arguments: + * pp: structure allocated by caller, fields written / validated here */ -static int pvcreate_fill_params(struct cmd_context *cmd, - int argc, char **argv, - struct pvcreate_params *pp) +static int pvcreate_validate_params(struct cmd_context *cmd, + int argc, char **argv, + struct pvcreate_params *pp) { if (!argc) { log_error("Please enter a physical volume path"); @@ -330,30 +312,43 @@ else pp->zero = 1; - return 1; -} + if (arg_sign_value(cmd, physicalvolumesize_ARG, 0) == SIGN_MINUS) { + log_error("Physical volume size may not be negative"); + return 0; + } + pp->size = arg_uint64_value(cmd, physicalvolumesize_ARG, UINT64_C(0)); + if (arg_sign_value(cmd, metadatasize_ARG, 0) == SIGN_MINUS) { + log_error("Metadata size may not be negative"); + return 0; + } + + pp->pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, UINT64_C(0)); + if (!pp->pvmetadatasize) + pp->pvmetadatasize = find_config_tree_int(cmd, + "metadata/pvmetadatasize", + DEFAULT_PVMETADATASIZE); + + pp->pvmetadatacopies = arg_int_value(cmd, metadatacopies_ARG, -1); + if (pp->pvmetadatacopies < 0) + pp->pvmetadatacopies = find_config_tree_int(cmd, + "metadata/pvmetadatacopies", + DEFAULT_PVMETADATACOPIES); -static int pvcreate_validate_params(struct cmd_context *cmd, - struct pvcreate_params *pp) -{ return 1; } + int pvcreate(struct cmd_context *cmd, int argc, char **argv) { int i, r; int ret = ECMD_PROCESSED; struct pvcreate_params pp; - if (!pvcreate_fill_params(cmd, argc, argv, &pp)) { + if (!pvcreate_validate_params(cmd, argc, argv, &pp)) { return EINVALID_CMD_LINE; } - if (!pvcreate_validate_params(cmd, &pp)) { - return EINVALID_CMD_LINE; - } - for (i = 0; i < argc; i++) { r = pvcreate_single(cmd, argv[i], &pp); if (r > ret) From wysochanski@sourceware.org Wed Jul 23 19:29:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Wed, 23 Jul 2008 19:29:00 -0000 Subject: LVM2/tools pvcreate.c Message-ID: <20080723192959.8157.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-07-23 19:29:59 Modified files: tools : pvcreate.c Log message: Refactor pvcreate - move labelsector parameter parsing & validation. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.65&r2=1.66 --- LVM2/tools/pvcreate.c 2008/07/21 19:27:22 1.65 +++ LVM2/tools/pvcreate.c 2008/07/23 19:29:58 1.66 @@ -21,6 +21,7 @@ uint64_t size; int pvmetadatacopies; uint64_t pvmetadatasize; + int64_t labelsector; }; const char _really_init[] = @@ -237,8 +238,7 @@ log_very_verbose("Writing physical volume data to disk \"%s\"", pv_name); if (!(pv_write(cmd, (struct physical_volume *)pv, &mdas, - arg_int64_value(cmd, labelsector_ARG, - DEFAULT_LABELSECTOR)))) { + pp->labelsector))) { log_error("Failed to write physical volume \"%s\"", pv_name); goto error; } @@ -290,6 +290,9 @@ log_error("labelsector must be less than %lu", LABEL_SCAN_SECTORS); return 0; + } else { + pp->labelsector = arg_int64_value(cmd, labelsector_ARG, + DEFAULT_LABELSECTOR); } if (!(cmd->fmt->features & FMT_MDAS) && From wysochanski@sourceware.org Wed Jul 23 19:46:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Wed, 23 Jul 2008 19:46:00 -0000 Subject: LVM2 ./WHATS_NEW lib/device/device.h tools/pvc ... Message-ID: <20080723194634.12755.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-07-23 19:46:33 Modified files: . : WHATS_NEW lib/device : device.h tools : pvcreate.c pvremove.c Log message: Remove dead code, is_lvm_partition() - no functional change. This code does nothing. The function is #defined to 1 which ensures the only two if statements referencing it will never be true. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.933&r2=1.934 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/device/device.h.diff?cvsroot=lvm2&r1=1.34&r2=1.35 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.66&r2=1.67 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvremove.c.diff?cvsroot=lvm2&r1=1.21&r2=1.22 --- LVM2/WHATS_NEW 2008/07/21 19:26:33 1.933 +++ LVM2/WHATS_NEW 2008/07/23 19:46:33 1.934 @@ -1,5 +1,6 @@ Version 2.02.40 - ================================ + Remove dead code, is_lvm_partition() - no functional change. Refactor pvcreate to divide parameter parsing & validation from create logic. Check for label_write() failure in _text_pv_write(). Add pvcreate tests and update vgsplit tests to handle lvm1 and lvm2 metadata. --- LVM2/lib/device/device.h 2007/08/20 20:55:25 1.34 +++ LVM2/lib/device/device.h 2008/07/23 19:46:33 1.35 @@ -94,11 +94,6 @@ /* Does device contain md superblock? If so, where? */ int dev_is_md(struct device *dev, uint64_t *sb); -/* FIXME Check partition type if appropriate */ - -#define is_lvm_partition(a) 1 -/* int is_lvm_partition(const char *name); */ - int is_partitioned_dev(struct device *dev); #endif --- LVM2/tools/pvcreate.c 2008/07/23 19:29:58 1.66 +++ LVM2/tools/pvcreate.c 2008/07/23 19:46:33 1.67 @@ -37,13 +37,6 @@ struct device *dev; uint64_t md_superblock; - /* is the partition type set correctly ? */ - if ((arg_count(cmd, force_ARG) < 1) && !is_lvm_partition(name)) { - log_error("%s: Not LVM partition type: use -f to override", - name); - return 0; - } - /* Is there a pv here already? */ /* FIXME Use partial mode here? */ pv = pv_read(cmd, name, NULL, NULL, 0); --- LVM2/tools/pvremove.c 2007/11/22 01:25:06 1.21 +++ LVM2/tools/pvremove.c 2008/07/23 19:46:33 1.22 @@ -26,13 +26,6 @@ { struct physical_volume *pv; - /* is the partition type set correctly ? */ - if ((arg_count(cmd, force_ARG) < 1) && !is_lvm_partition(name)) { - log_error("%s: Not LVM partition type: use -f to override", - name); - return 0; - } - /* Is there a pv here already? */ /* If not, this is an error unless you used -f. */ if (!(pv = pv_read(cmd, name, NULL, NULL, 1))) { From meyering@sourceware.org Thu Jul 24 14:54:00 2008 From: meyering@sourceware.org (meyering@sourceware.org) Date: Thu, 24 Jul 2008 14:54:00 -0000 Subject: LVM2 configure Message-ID: <20080724145427.6071.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: meyering@sourceware.org 2008-07-24 14:54:26 Modified files: . : configure Log message: configure: regenerate Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.diff?cvsroot=lvm2&r1=1.74&r2=1.75 --- LVM2/configure 2008/07/09 09:59:41 1.74 +++ LVM2/configure 2008/07/24 14:54:26 1.75 @@ -8509,7 +8509,7 @@ if test "${enable_readline+set}" = set; then enableval=$enable_readline; READLINE=$enableval else - READLINE=yes + READLINE=maybe fi { echo "$as_me:$LINENO: result: $READLINE" >&5 @@ -8783,7 +8783,7 @@ fi; ################################################################################ -if test x$READLINE = xyes; then +if test x$READLINE != xno; then { echo "$as_me:$LINENO: checking for library containing tgetent" >&5 echo $ECHO_N "checking for library containing tgetent... $ECHO_C" >&6; } if test "${ac_cv_search_tgetent+set}" = set; then @@ -8864,9 +8864,13 @@ ac_res=$ac_cv_search_tgetent if test "$ac_res" != no; then test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" - + tg_found=yes else - { { echo "$as_me:$LINENO: error: termcap could not be found which is required for the + tg_found=no +fi + + test x$READLINE:$tg_found = xyes:no && + { { echo "$as_me:$LINENO: error: termcap could not be found which is required for the --enable-readline option (which is enabled by default). Either disable readline support with --disable-readline or download and install termcap from: ftp.gnu.org/gnu/termcap @@ -8885,9 +8889,6 @@ not found either - but you could try installing that as well. " >&2;} { (exit 1); exit 1; }; } - -fi - fi ################################################################################ @@ -9488,9 +9489,8 @@ ################################################################################ -if test x$READLINE = xyes; then - -{ echo "$as_me:$LINENO: checking for readline in -lreadline" >&5 +if test x$READLINE != xno; then + { echo "$as_me:$LINENO: checking for readline in -lreadline" >&5 echo $ECHO_N "checking for readline in -lreadline... $ECHO_C" >&6; } if test "${ac_cv_lib_readline_readline+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -9552,14 +9552,13 @@ { echo "$as_me:$LINENO: result: $ac_cv_lib_readline_readline" >&5 echo "${ECHO_T}$ac_cv_lib_readline_readline" >&6; } if test $ac_cv_lib_readline_readline = yes; then - cat >>confdefs.h <<_ACEOF -#define HAVE_LIBREADLINE 1 -_ACEOF - - LIBS="-lreadline $LIBS" - + rl_found=yes else - { { echo "$as_me:$LINENO: error: GNU Readline could not be found which is required for the + rl_found=no +fi + + test x$READLINE:$rl_found = xyes:no && + { { echo "$as_me:$LINENO: error: GNU Readline could not be found which is required for the --enable-readline option (which is enabled by default). Either disable readline support with --disable-readline or download and install readline from: ftp.gnu.org/gnu/readline @@ -9574,10 +9573,8 @@ package as well (which may be called readline-devel or something similar). " >&2;} { (exit 1); exit 1; }; } - -fi - - { echo "$as_me:$LINENO: checking for rl_completion_matches" >&5 + if test $rl_found = yes; then + { echo "$as_me:$LINENO: checking for rl_completion_matches" >&5 echo $ECHO_N "checking for rl_completion_matches... $ECHO_C" >&6; } if test "${ac_cv_func_rl_completion_matches+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -9671,6 +9668,7 @@ #define READLINE_SUPPORT 1 _ACEOF + fi fi ################################################################################ From meyering@sourceware.org Thu Jul 24 14:54:00 2008 From: meyering@sourceware.org (meyering@sourceware.org) Date: Thu, 24 Jul 2008 14:54:00 -0000 Subject: LVM2 WHATS_NEW configure.in Message-ID: <20080724145406.5922.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: meyering@sourceware.org 2008-07-24 14:54:06 Modified files: . : WHATS_NEW configure.in Log message: Don't make configure fail when readline library is not available. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.934&r2=1.935 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.in.diff?cvsroot=lvm2&r1=1.75&r2=1.76 --- LVM2/WHATS_NEW 2008/07/23 19:46:33 1.934 +++ LVM2/WHATS_NEW 2008/07/24 14:54:06 1.935 @@ -1,5 +1,6 @@ Version 2.02.40 - ================================ + configure no longer fails when the readline library is not available Remove dead code, is_lvm_partition() - no functional change. Refactor pvcreate to divide parameter parsing & validation from create logic. Check for label_write() failure in _text_pv_write(). --- LVM2/configure.in 2008/07/09 09:59:42 1.75 +++ LVM2/configure.in 2008/07/24 14:54:06 1.76 @@ -273,7 +273,7 @@ AC_MSG_CHECKING(whether to enable readline) AC_ARG_ENABLE([readline], [ --disable-readline Disable readline support], - [READLINE=$enableval], [READLINE=yes]) + [READLINE=$enableval], [READLINE=maybe]) AC_MSG_RESULT($READLINE) ################################################################################ @@ -410,9 +410,11 @@ ################################################################################ dnl -- Check for termcap (Shamelessly copied from parted 1.4.17) -if test x$READLINE = xyes; then - AC_SEARCH_LIBS(tgetent, ncurses curses termcap termlib, , - AC_MSG_ERROR( +if test x$READLINE != xno; then + AC_SEARCH_LIBS([tgetent], [ncurses curses termcap termlib], + [tg_found=yes], [tg_found=no]) + test x$READLINE:$tg_found = xyes:no && + AC_MSG_ERROR( termcap could not be found which is required for the --enable-readline option (which is enabled by default). Either disable readline support with --disable-readline or download and install termcap from: @@ -422,7 +424,6 @@ Note: (n)curses also seems to work as a substitute for termcap. This was not found either - but you could try installing that as well. ) - ) fi ################################################################################ @@ -514,9 +515,10 @@ ################################################################################ dnl -- Check for readline (Shamelessly copied from parted 1.4.17) -if test x$READLINE = xyes; then - AC_CHECK_LIB(readline, readline, , - AC_MSG_ERROR( +if test x$READLINE != xno; then + AC_CHECK_LIB([readline], [readline], [rl_found=yes], [rl_found=no]) + test x$READLINE:$rl_found = xyes:no && + AC_MSG_ERROR( GNU Readline could not be found which is required for the --enable-readline option (which is enabled by default). Either disable readline support with --disable-readline or download and install readline from: @@ -524,12 +526,13 @@ Note: if you are using precompiled packages you will also need the development package as well (which may be called readline-devel or something similar). ) - ) - AC_CHECK_FUNC([rl_completion_matches], - AC_DEFINE([HAVE_RL_COMPLETION_MATCHES], 1, - [Define to 1 if rl_completion_matches() is available.])) - AC_DEFINE([READLINE_SUPPORT], 1, - [Define to 1 to include the LVM readline shell.]) + if test $rl_found = yes; then + AC_CHECK_FUNC([rl_completion_matches], + AC_DEFINE([HAVE_RL_COMPLETION_MATCHES], 1, + [Define to 1 if rl_completion_matches() is available.])) + AC_DEFINE([READLINE_SUPPORT], 1, + [Define to 1 to include the LVM readline shell.]) + fi fi ################################################################################ From agk@sourceware.org Thu Jul 24 15:25:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 24 Jul 2008 15:25:00 -0000 Subject: LVM2/tools pvcreate.c pvremove.c Message-ID: <20080724152510.7361.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-07-24 15:25:10 Modified files: tools : pvcreate.c pvremove.c Log message: reinstate lost FIXME - only if kernel gives the info, not to be worked out in userspace - with lvm.conf option to enable/disable the check Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.67&r2=1.68 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvremove.c.diff?cvsroot=lvm2&r1=1.22&r2=1.23 --- LVM2/tools/pvcreate.c 2008/07/23 19:46:33 1.67 +++ LVM2/tools/pvcreate.c 2008/07/24 15:25:09 1.68 @@ -37,6 +37,8 @@ struct device *dev; uint64_t md_superblock; + /* FIXME Check partition type is LVM unless --force is given */ + /* Is there a pv here already? */ /* FIXME Use partial mode here? */ pv = pv_read(cmd, name, NULL, NULL, 0); --- LVM2/tools/pvremove.c 2008/07/23 19:46:33 1.22 +++ LVM2/tools/pvremove.c 2008/07/24 15:25:09 1.23 @@ -26,6 +26,8 @@ { struct physical_volume *pv; + /* FIXME Check partition type is LVM unless --force is given */ + /* Is there a pv here already? */ /* If not, this is an error unless you used -f. */ if (!(pv = pv_read(cmd, name, NULL, NULL, 1))) { From agk@sourceware.org Thu Jul 24 15:39:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 24 Jul 2008 15:39:00 -0000 Subject: LVM2 WHATS_NEW Message-ID: <20080724153947.13776.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-07-24 15:39:47 Modified files: . : WHATS_NEW Log message: . Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.935&r2=1.936 --- LVM2/WHATS_NEW 2008/07/24 14:54:06 1.935 +++ LVM2/WHATS_NEW 2008/07/24 15:39:47 1.936 @@ -1,8 +1,8 @@ Version 2.02.40 - ================================ - configure no longer fails when the readline library is not available - Remove dead code, is_lvm_partition() - no functional change. - Refactor pvcreate to divide parameter parsing & validation from create logic. + Fix configure to work w/o readline unless --enable-readline used. (2.02.39) + Remove is_lvm_partition template which has not yet been coded. + Refactor pvcreate to separate parameter parsing from validation logic. Check for label_write() failure in _text_pv_write(). Add pvcreate tests and update vgsplit tests to handle lvm1 and lvm2 metadata. Fix pvchange -M1 -u to preserve existing extent locations when there's a VG. From wysochanski@sourceware.org Thu Jul 24 17:33:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Thu, 24 Jul 2008 17:33:00 -0000 Subject: LVM2/test t-pvcreate-operation.sh Message-ID: <20080724173340.30965.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-07-24 17:33:40 Modified files: test : t-pvcreate-operation.sh Log message: Add pvcreate tests for uuid and restorefile. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-pvcreate-operation.sh.diff?cvsroot=lvm2&r1=1.2&r2=1.3 --- LVM2/test/t-pvcreate-operation.sh 2008/07/21 18:50:10 1.2 +++ LVM2/test/t-pvcreate-operation.sh 2008/07/24 17:33:40 1.3 @@ -80,6 +80,33 @@ "pvcreate (lvm2) fails writing LVM label at sector 4" \ 'pvcreate --labelsector 4 $d1' +backupfile=mybackupfile-$(this_test_) +uuid1=freddy-fred-fred-fred-fred-fred-freddy +uuid2=freddy-fred-fred-fred-fred-fred-fredie +bogusuuid=fred + +test_expect_failure \ + 'pvcreate rejects uuid option with less than 32 characters' \ + 'pvcreate --uuid $bogusuuid $d1' + +test_expect_success \ + 'pvcreate rejects uuid already in use' \ + 'pvcreate --uuid freddy-fred-fred-fred-fred-fred-freddy $d1 && + pvcreate --uuid freddy-fred-fred-fred-fred-fred-freddy $d2; + status=$?; echo status=$status; test $status != 0' + +test_expect_success \ + 'pvcreate rejects non-existent file given with restorefile' \ + 'pvcreate --uuid $uuid1 --restorefile $backupfile $d1; + status=$?; echo status=$status; test $status != 0' + +test_expect_success \ + 'pvcreate rejects restorefile with uuid not found in file' \ + 'pvcreate --uuid $uuid1 $d1 && + vgcfgbackup -f $backupfile && + pvcreate --uuid $uuid2 --restorefile $backupfile $d2; + status=$?; echo status=$status; test $status != 0' + test_done # Local Variables: # indent-tabs-mode: nil From wysochanski@sourceware.org Fri Jul 25 00:30:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Fri, 25 Jul 2008 00:30:00 -0000 Subject: LVM2 test/t-pvcreate-operation.sh tools/pvcreate.c Message-ID: <20080725003057.5116.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-07-25 00:30:57 Modified files: test : t-pvcreate-operation.sh tools : pvcreate.c Log message: Refactor pvcreate - move uuid and restorefile options. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-pvcreate-operation.sh.diff?cvsroot=lvm2&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.68&r2=1.69 --- LVM2/test/t-pvcreate-operation.sh 2008/07/24 17:33:40 1.3 +++ LVM2/test/t-pvcreate-operation.sh 2008/07/25 00:30:57 1.4 @@ -91,8 +91,8 @@ test_expect_success \ 'pvcreate rejects uuid already in use' \ - 'pvcreate --uuid freddy-fred-fred-fred-fred-fred-freddy $d1 && - pvcreate --uuid freddy-fred-fred-fred-fred-fred-freddy $d2; + 'pvcreate --uuid $uuid1 $d1 && + pvcreate --uuid $uuid1 $d2; status=$?; echo status=$status; test $status != 0' test_expect_success \ --- LVM2/tools/pvcreate.c 2008/07/24 15:25:09 1.68 +++ LVM2/tools/pvcreate.c 2008/07/25 00:30:57 1.69 @@ -22,6 +22,12 @@ int pvmetadatacopies; uint64_t pvmetadatasize; int64_t labelsector; + struct id id; /* FIXME: redundant */ + struct id *idp; + uint64_t pe_start; + uint32_t extent_count; + uint32_t extent_size; + const char *restorefile; }; const char _really_init[] = @@ -138,47 +144,16 @@ { struct pvcreate_params *pp = (struct pvcreate_params *) handle; void *pv; - void *existing_pv; - struct id id, *idp = NULL; - const char *uuid = NULL; struct device *dev; struct list mdas; - struct volume_group *vg; - const char *restorefile; - uint64_t pe_start = 0; - uint32_t extent_count = 0, extent_size = 0; - if (arg_count(cmd, uuidstr_ARG)) { - uuid = arg_str_value(cmd, uuidstr_ARG, ""); - if (!id_read_format(&id, uuid)) - return EINVALID_CMD_LINE; - if ((dev = device_from_pvid(cmd, &id)) && + if (pp->idp) { + if ((dev = device_from_pvid(cmd, pp->idp)) && (dev != dev_cache_get(pv_name, cmd->filter))) { - log_error("uuid %s already in use on \"%s\"", uuid, - dev_name(dev)); - return ECMD_FAILED; - } - idp = &id; - } - - if (arg_count(cmd, restorefile_ARG)) { - restorefile = arg_str_value(cmd, restorefile_ARG, ""); - /* The uuid won't already exist */ - init_partial(1); - if (!(vg = backup_read_vg(cmd, NULL, restorefile))) { - log_error("Unable to read volume group from %s", - restorefile); - return ECMD_FAILED; - } - init_partial(0); - if (!(existing_pv = find_pv_in_vg_by_uuid(vg, idp))) { - log_error("Can't find uuid %s in backup file %s", - uuid, restorefile); + log_error("uuid %s already in use on \"%s\"", + pp->idp->uuid, dev_name(dev)); return ECMD_FAILED; } - pe_start = pv_pe_start(existing_pv); - extent_size = pv_pe_size(existing_pv); - extent_count = pv_pe_count(existing_pv); } if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) { @@ -199,8 +174,9 @@ } list_init(&mdas); - if (!(pv = pv_create(cmd, dev, idp, pp->size, pe_start, - extent_count, extent_size, pp->pvmetadatacopies, + if (!(pv = pv_create(cmd, dev, pp->idp, pp->size, pp->pe_start, + pp->extent_count, pp->extent_size, + pp->pvmetadatacopies, pp->pvmetadatasize,&mdas))) { log_error("Failed to setup physical volume \"%s\"", pv_name); goto error; @@ -261,6 +237,12 @@ int argc, char **argv, struct pvcreate_params *pp) { + const char *uuid = NULL; + void *existing_pv; + struct volume_group *vg; + + memset(pp, 0, sizeof(*pp)); + if (!argc) { log_error("Please enter a physical volume path"); return 0; @@ -276,6 +258,33 @@ return 0; } + if (arg_count(cmd, uuidstr_ARG)) { + uuid = arg_str_value(cmd, uuidstr_ARG, ""); + if (!id_read_format(&pp->id, uuid)) + return 0; + pp->idp = &pp->id; + } + + if (arg_count(cmd, restorefile_ARG)) { + pp->restorefile = arg_str_value(cmd, restorefile_ARG, ""); + /* The uuid won't already exist */ + init_partial(1); + if (!(vg = backup_read_vg(cmd, NULL, pp->restorefile))) { + log_error("Unable to read volume group from %s", + pp->restorefile); + return 0; + } + init_partial(0); + if (!(existing_pv = find_pv_in_vg_by_uuid(vg, pp->idp))) { + log_error("Can't find uuid %s in backup file %s", + uuid, pp->restorefile); + return 0; + } + pp->pe_start = pv_pe_start(existing_pv); + pp->extent_size = pv_pe_size(existing_pv); + pp->extent_count = pv_pe_count(existing_pv); + } + if (arg_count(cmd, yes_ARG) && !arg_count(cmd, force_ARG)) { log_error("Option y can only be given with option f"); return 0; From meyering@sourceware.org Fri Jul 25 08:00:00 2008 From: meyering@sourceware.org (meyering@sourceware.org) Date: Fri, 25 Jul 2008 08:00:00 -0000 Subject: LVM2 configure Message-ID: <20080725080041.32055.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: meyering@sourceware.org 2008-07-25 08:00:41 Modified files: . : configure Log message: configure: regenerate Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.diff?cvsroot=lvm2&r1=1.75&r2=1.76 --- LVM2/configure 2008/07/24 14:54:26 1.75 +++ LVM2/configure 2008/07/25 08:00:40 1.76 @@ -9490,7 +9490,9 @@ ################################################################################ if test x$READLINE != xno; then - { echo "$as_me:$LINENO: checking for readline in -lreadline" >&5 + rl_found=yes + +{ echo "$as_me:$LINENO: checking for readline in -lreadline" >&5 echo $ECHO_N "checking for readline in -lreadline... $ECHO_C" >&6; } if test "${ac_cv_lib_readline_readline+set}" = set; then echo $ECHO_N "(cached) $ECHO_C" >&6 @@ -9552,7 +9554,12 @@ { echo "$as_me:$LINENO: result: $ac_cv_lib_readline_readline" >&5 echo "${ECHO_T}$ac_cv_lib_readline_readline" >&6; } if test $ac_cv_lib_readline_readline = yes; then - rl_found=yes + cat >>confdefs.h <<_ACEOF +#define HAVE_LIBREADLINE 1 +_ACEOF + + LIBS="-lreadline $LIBS" + else rl_found=no fi @@ -9574,9 +9581,13 @@ " >&2;} { (exit 1); exit 1; }; } if test $rl_found = yes; then - { echo "$as_me:$LINENO: checking for rl_completion_matches" >&5 -echo $ECHO_N "checking for rl_completion_matches... $ECHO_C" >&6; } -if test "${ac_cv_func_rl_completion_matches+set}" = set; then + +for ac_func in rl_completion_matches +do +as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_func" >&5 +echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6; } +if { as_var=$as_ac_var; eval "test \"\${$as_var+set}\" = set"; }; then echo $ECHO_N "(cached) $ECHO_C" >&6 else cat >conftest.$ac_ext <<_ACEOF @@ -9585,12 +9596,12 @@ cat confdefs.h >>conftest.$ac_ext cat >>conftest.$ac_ext <<_ACEOF /* end confdefs.h. */ -/* Define rl_completion_matches to an innocuous variant, in case declares rl_completion_matches. +/* Define $ac_func to an innocuous variant, in case declares $ac_func. For example, HP-UX 11i declares gettimeofday. */ -#define rl_completion_matches innocuous_rl_completion_matches +#define $ac_func innocuous_$ac_func /* System header to define __stub macros and hopefully few prototypes, - which can conflict with char rl_completion_matches (); below. + which can conflict with char $ac_func (); below. Prefer to if __STDC__ is defined, since exists even on freestanding compilers. */ @@ -9600,7 +9611,7 @@ # include #endif -#undef rl_completion_matches +#undef $ac_func /* Override any GCC internal prototype to avoid an error. Use char because int might match the return type of a GCC @@ -9608,18 +9619,18 @@ #ifdef __cplusplus extern "C" #endif -char rl_completion_matches (); +char $ac_func (); /* The GNU C library defines this for functions which it implements to always fail with ENOSYS. Some functions are actually named something starting with __ and the normal name is an alias. */ -#if defined __stub_rl_completion_matches || defined __stub___rl_completion_matches +#if defined __stub_$ac_func || defined __stub___$ac_func choke me #endif int main () { -return rl_completion_matches (); +return $ac_func (); ; return 0; } @@ -9642,26 +9653,27 @@ test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then - ac_cv_func_rl_completion_matches=yes + eval "$as_ac_var=yes" else echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 - ac_cv_func_rl_completion_matches=no + eval "$as_ac_var=no" fi rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ conftest$ac_exeext conftest.$ac_ext fi -{ echo "$as_me:$LINENO: result: $ac_cv_func_rl_completion_matches" >&5 -echo "${ECHO_T}$ac_cv_func_rl_completion_matches" >&6; } -if test $ac_cv_func_rl_completion_matches = yes; then - -cat >>confdefs.h <<\_ACEOF -#define HAVE_RL_COMPLETION_MATCHES 1 +ac_res=`eval echo '${'$as_ac_var'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_var'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF fi +done cat >>confdefs.h <<\_ACEOF From meyering@sourceware.org Fri Jul 25 08:00:00 2008 From: meyering@sourceware.org (meyering@sourceware.org) Date: Fri, 25 Jul 2008 08:00:00 -0000 Subject: LVM2 configure.in Message-ID: <20080725080020.31919.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: meyering@sourceware.org 2008-07-25 08:00:20 Modified files: . : configure.in Log message: Avoid compiler warnings (provoked by new configure.in bug) on RHEL5. Do not override the default action of AC_CHECK_LIB([readline],... (i.e., leave the ACTION-IF-FOUND parameter blank) so that the subsequent check for rl_completion_matches can use -lreadline. Also, replace AC_CHECK_FUNC+AC_DEFINE with an equivalent AC_CHECK_FUNCS call. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.in.diff?cvsroot=lvm2&r1=1.76&r2=1.77 --- LVM2/configure.in 2008/07/24 14:54:06 1.76 +++ LVM2/configure.in 2008/07/25 08:00:18 1.77 @@ -516,7 +516,8 @@ ################################################################################ dnl -- Check for readline (Shamelessly copied from parted 1.4.17) if test x$READLINE != xno; then - AC_CHECK_LIB([readline], [readline], [rl_found=yes], [rl_found=no]) + rl_found=yes + AC_CHECK_LIB([readline], [readline], , [rl_found=no]) test x$READLINE:$rl_found = xyes:no && AC_MSG_ERROR( GNU Readline could not be found which is required for the @@ -527,9 +528,7 @@ package as well (which may be called readline-devel or something similar). ) if test $rl_found = yes; then - AC_CHECK_FUNC([rl_completion_matches], - AC_DEFINE([HAVE_RL_COMPLETION_MATCHES], 1, - [Define to 1 if rl_completion_matches() is available.])) + AC_CHECK_FUNCS([rl_completion_matches]) AC_DEFINE([READLINE_SUPPORT], 1, [Define to 1 to include the LVM readline shell.]) fi From wysochanski@sourceware.org Fri Jul 25 14:12:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Fri, 25 Jul 2008 14:12:00 -0000 Subject: LVM2/tools pvcreate.c Message-ID: <20080725141230.1851.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-07-25 14:12:30 Modified files: tools : pvcreate.c Log message: Refactor pvcreate - use '0' for no --uuid or --restorefile options. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.69&r2=1.70 --- LVM2/tools/pvcreate.c 2008/07/25 00:30:57 1.69 +++ LVM2/tools/pvcreate.c 2008/07/25 14:12:29 1.70 @@ -23,11 +23,11 @@ uint64_t pvmetadatasize; int64_t labelsector; struct id id; /* FIXME: redundant */ - struct id *idp; + struct id *idp; /* 0 if no --uuid option */ uint64_t pe_start; uint32_t extent_count; uint32_t extent_size; - const char *restorefile; + const char *restorefile; /* 0 if no --restorefile option */ }; const char _really_init[] = @@ -37,7 +37,8 @@ * See if we may pvcreate on this device. * 0 indicates we may not. */ -static int pvcreate_check(struct cmd_context *cmd, const char *name) +static int pvcreate_check(struct cmd_context *cmd, const char *name, + struct pvcreate_params *pp) { struct physical_volume *pv; struct device *dev; @@ -112,8 +113,8 @@ /* Wipe superblock? */ if (dev_is_md(dev, &md_superblock) && - ((!arg_count(cmd, uuidstr_ARG) && - !arg_count(cmd, restorefile_ARG)) || + ((!pp->idp && + !pp->restorefile) || arg_count(cmd, yes_ARG) || (yes_no_prompt("Software RAID md superblock " "detected on %s. Wipe it? [y/n] ", name) == 'y'))) { @@ -161,7 +162,7 @@ return ECMD_FAILED; } - if (!pvcreate_check(cmd, pv_name)) + if (!pvcreate_check(cmd, pv_name, pp)) goto error; if (sigint_caught()) From wysochanski@sourceware.org Fri Jul 25 14:37:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Fri, 25 Jul 2008 14:37:00 -0000 Subject: LVM2 test/t-pvcreate-operation.sh tools/pvcreate.c Message-ID: <20080725143701.27268.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-07-25 14:36:56 Modified files: test : t-pvcreate-operation.sh tools : pvcreate.c Log message: Refactor pvcreate - --force parameter. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-pvcreate-operation.sh.diff?cvsroot=lvm2&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.70&r2=1.71 --- LVM2/test/t-pvcreate-operation.sh 2008/07/25 00:30:57 1.4 +++ LVM2/test/t-pvcreate-operation.sh 2008/07/25 14:36:52 1.5 @@ -45,7 +45,7 @@ done test_expect_success \ - 'pvcreate (lvm2) fails when PV with metadatacopies=0 belongs to VG' \ + 'pvcreate (lvm2) fails without -ff when PV with metadatacopies=0 belongs to VG' \ 'pvcreate --metadatacopies 0 $d1 && pvcreate --metadatacopies 1 $d2 && vgcreate $vg1 $d1 $d2 && --- LVM2/tools/pvcreate.c 2008/07/25 14:12:29 1.70 +++ LVM2/tools/pvcreate.c 2008/07/25 14:36:55 1.71 @@ -28,6 +28,7 @@ uint32_t extent_count; uint32_t extent_size; const char *restorefile; /* 0 if no --restorefile option */ + force_t force; }; const char _really_init[] = @@ -64,7 +65,7 @@ /* Allow partial & exported VGs to be destroyed. */ /* We must have -ff to overwrite a non orphan */ - if (pv && !is_orphan(pv) && arg_count(cmd, force_ARG) != 2) { + if (pv && !is_orphan(pv) && pp->force != DONT_PROMPT_OVERRIDE) { log_error("Can't initialize physical volume \"%s\" of " "volume group \"%s\" without -ff", name, pv_vg_name(pv)); return 0; @@ -129,7 +130,7 @@ if (sigint_caught()) return 0; - if (pv && !is_orphan(pv) && arg_count(cmd, force_ARG)) { + if (pv && !is_orphan(pv) && pp->force) { log_warn("WARNING: Forcing physical volume creation on " "%s%s%s%s", name, !is_orphan(pv) ? " of volume group \"" : "", @@ -291,6 +292,8 @@ return 0; } + pp->force = arg_count(cmd, force_ARG); + if (arg_int_value(cmd, labelsector_ARG, 0) >= LABEL_SCAN_SECTORS) { log_error("labelsector must be less than %lu", LABEL_SCAN_SECTORS); From wysochanski@sourceware.org Fri Jul 25 14:45:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Fri, 25 Jul 2008 14:45:00 -0000 Subject: LVM2/tools pvcreate.c Message-ID: <20080725144526.31663.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-07-25 14:45:25 Modified files: tools : pvcreate.c Log message: Refactor pvcreate - --yes argument Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.71&r2=1.72 --- LVM2/tools/pvcreate.c 2008/07/25 14:36:55 1.71 +++ LVM2/tools/pvcreate.c 2008/07/25 14:45:24 1.72 @@ -29,6 +29,7 @@ uint32_t extent_size; const char *restorefile; /* 0 if no --restorefile option */ force_t force; + unsigned yes; }; const char _really_init[] = @@ -72,7 +73,7 @@ } /* prompt */ - if (pv && !is_orphan(pv) && !arg_count(cmd, yes_ARG) && + if (pv && !is_orphan(pv) && !pp->yes && yes_no_prompt(_really_init, name, pv_vg_name(pv)) == 'n') { log_print("%s: physical volume not initialized", name); return 0; @@ -114,9 +115,7 @@ /* Wipe superblock? */ if (dev_is_md(dev, &md_superblock) && - ((!pp->idp && - !pp->restorefile) || - arg_count(cmd, yes_ARG) || + ((!pp->idp && !pp->restorefile) || pp->yes || (yes_no_prompt("Software RAID md superblock " "detected on %s. Wipe it? [y/n] ", name) == 'y'))) { log_print("Wiping software RAID md superblock on %s", name); @@ -292,6 +291,7 @@ return 0; } + pp->yes = arg_count(cmd, yes_ARG); pp->force = arg_count(cmd, force_ARG); if (arg_int_value(cmd, labelsector_ARG, 0) >= LABEL_SCAN_SECTORS) { From wysochanski@sourceware.org Fri Jul 25 14:59:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Fri, 25 Jul 2008 14:59:00 -0000 Subject: LVM2 test/t-pvcreate-operation.sh tools/pvcreate.c Message-ID: <20080725145952.3552.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-07-25 14:59:51 Modified files: test : t-pvcreate-operation.sh tools : pvcreate.c Log message: Refactor pvcreate - simplify return codes. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-pvcreate-operation.sh.diff?cvsroot=lvm2&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.72&r2=1.73 --- LVM2/test/t-pvcreate-operation.sh 2008/07/25 14:36:52 1.5 +++ LVM2/test/t-pvcreate-operation.sh 2008/07/25 14:59:51 1.6 @@ -42,6 +42,18 @@ vgremove -f $vg1 && pvremove -f $d1' +test_expect_success \ + "pvcreate (lvm$mdatype) fails when PV1 does and PV2 does not belong to VG" \ + 'pvcreate -M$mdatype $d1 && + pvcreate -M$mdatype $d2 && + vgcreate -M$mdatype $vg1 $d1 && + echo pvcreate a second time on $d2 and $d1 && + pvcreate -M$mdatype $d2 $d1; + status=$?; echo status=$status; test $status != 0 && + vgremove -f $vg1 && + pvremove -f $d2 && + pvremove -f $d1' + done test_expect_success \ --- LVM2/tools/pvcreate.c 2008/07/25 14:45:24 1.72 +++ LVM2/tools/pvcreate.c 2008/07/25 14:59:51 1.73 @@ -153,13 +153,13 @@ (dev != dev_cache_get(pv_name, cmd->filter))) { log_error("uuid %s already in use on \"%s\"", pp->idp->uuid, dev_name(dev)); - return ECMD_FAILED; + return 0; } } if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) { log_error("Can't get lock for orphan PVs"); - return ECMD_FAILED; + return 0; } if (!pvcreate_check(cmd, pv_name, pp)) @@ -218,11 +218,11 @@ log_print("Physical volume \"%s\" successfully created", pv_name); unlock_vg(cmd, VG_ORPHANS); - return ECMD_PROCESSED; + return 1; error: unlock_vg(cmd, VG_ORPHANS); - return ECMD_FAILED; + return 0; } /* @@ -352,7 +352,7 @@ int pvcreate(struct cmd_context *cmd, int argc, char **argv) { - int i, r; + int i; int ret = ECMD_PROCESSED; struct pvcreate_params pp; @@ -361,9 +361,9 @@ } for (i = 0; i < argc; i++) { - r = pvcreate_single(cmd, argv[i], &pp); - if (r > ret) - ret = r; + if (!pvcreate_single(cmd, argv[i], &pp)) + ret = ECMD_FAILED; + if (sigint_caught()) return ret; } From wysochanski@sourceware.org Tue Jul 29 18:35:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Tue, 29 Jul 2008 18:35:00 -0000 Subject: LVM2/man pvcreate.8 Message-ID: <20080729183501.15524.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-07-29 18:35:01 Modified files: man : pvcreate.8 Log message: Fix trivial typo in pvcreate man page. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/pvcreate.8.diff?cvsroot=lvm2&r1=1.6&r2=1.7 --- LVM2/man/pvcreate.8 2008/01/04 11:48:40 1.6 +++ LVM2/man/pvcreate.8 2008/07/29 18:35:00 1.7 @@ -126,5 +126,5 @@ .sp .SH SEE ALSO .BR lvm "(8), " vgcreate "(8), " vgextend "(8), " lvcreate "(8), " -.BR cfdisk "(8), " fdisk "(8), " losetup "(8), " mdadd "(8), " +.BR cfdisk "(8), " fdisk "(8), " losetup "(8), " mdadm "(8), " .BR vgcfgrestore "(8), " vgconvert "(8)" From wysochanski@sourceware.org Tue Jul 29 21:05:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Tue, 29 Jul 2008 21:05:00 -0000 Subject: LVM2 test/t-000-basic.sh test/t-pvcreate-opera ... Message-ID: <20080729210523.13824.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-07-29 21:05:20 Modified files: test : t-000-basic.sh t-pvcreate-operation.sh tools : pvcreate.c Log message: Add pvcreate tests to verify failure on md array detection. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-000-basic.sh.diff?cvsroot=lvm2&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-pvcreate-operation.sh.diff?cvsroot=lvm2&r1=1.6&r2=1.7 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.73&r2=1.74 --- LVM2/test/t-000-basic.sh 2007/12/05 09:49:08 1.2 +++ LVM2/test/t-000-basic.sh 2008/07/29 21:05:02 1.3 @@ -32,4 +32,9 @@ 'ensure they are the same' \ 'diff -u actual expected' +# Need mdadm for some pvcreate tests +test_expect_success \ + 'verify mdadm is installed and in path (needed for pvcreate tests)' \ + 'which mdadm' + test_done --- LVM2/test/t-pvcreate-operation.sh 2008/07/25 14:59:51 1.6 +++ LVM2/test/t-pvcreate-operation.sh 2008/07/29 21:05:10 1.7 @@ -54,6 +54,16 @@ pvremove -f $d2 && pvremove -f $d1' +# NOTE: Force pvcreate after test completion to ensure clean device +test_expect_success \ + "pvcreate (lvm$mdatype) fails on md component device" \ + 'mdadm -C -l raid0 -n 2 /dev/md0 $d1 $d2 && + pvcreate -M$mdatype $d1; + status=$?; echo status=$status; test $status != 0 && + mdadm --stop /dev/md0 && + pvcreate -ff -y -M$mdatype $d1 $d2 && + pvremove -f $d1 $d2' + done test_expect_success \ --- LVM2/tools/pvcreate.c 2008/07/25 14:59:51 1.73 +++ LVM2/tools/pvcreate.c 2008/07/29 21:05:20 1.74 @@ -106,6 +106,9 @@ return 0; } + /* + * This test will fail if the device belongs to an MD array. + */ if (!dev_test_excl(dev)) { /* FIXME Detect whether device-mapper itself is still using it */ log_error("Can't open %s exclusively. Mounted filesystem?", From agk@sourceware.org Thu Jul 31 10:50:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 31 Jul 2008 10:50:00 -0000 Subject: LVM2 ./WHATS_NEW lib/format_text/format-text.c Message-ID: <20080731105019.32561.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-07-31 10:50:19 Modified files: . : WHATS_NEW lib/format_text: format-text.c Log message: Refactor _text_pv_read and always return mda list if requested. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.936&r2=1.937 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.91&r2=1.92 --- LVM2/WHATS_NEW 2008/07/24 15:39:47 1.936 +++ LVM2/WHATS_NEW 2008/07/31 10:50:12 1.937 @@ -1,5 +1,6 @@ Version 2.02.40 - ================================ + Refactor _text_pv_read and always return mda list if requested. Fix configure to work w/o readline unless --enable-readline used. (2.02.39) Remove is_lvm_partition template which has not yet been coded. Refactor pvcreate to separate parameter parsing from validation logic. --- LVM2/lib/format_text/format-text.c 2008/07/16 21:32:38 1.91 +++ LVM2/lib/format_text/format-text.c 2008/07/31 10:50:18 1.92 @@ -1396,43 +1396,33 @@ return 1; } -static int _text_pv_read(const struct format_type *fmt, const char *pv_name, - struct physical_volume *pv, struct list *mdas) +static int _get_pv_if_in_vg(struct lvmcache_info *info, + struct physical_volume *pv) { - struct label *label; - struct device *dev; - struct lvmcache_info *info; - struct metadata_area *mda, *mda_new; - struct mda_context *mdac, *mdac_new; - struct data_area_list *da; + if (info->vginfo && info->vginfo->vgname && + !is_orphan_vg(info->vginfo->vgname) && + get_pv_from_vg_by_id(info->fmt, info->vginfo->vgname, + info->vginfo->vgid, info->dev->pvid, pv)) + return 1; - if (!(dev = dev_cache_get(pv_name, fmt->cmd->filter))) - return_0; + return 0; +} - /* FIXME Optimise out repeated reading when cache lock held */ - if (!(label_read(dev, &label, UINT64_C(0)))) - return_0; - info = (struct lvmcache_info *) label->info; +static int _populate_pv_fields(struct lvmcache_info *info, + struct physical_volume *pv) +{ + struct data_area_list *da; /* Have we already cached vgname? */ - if (info->vginfo && info->vginfo->vgname && - !is_orphan_vg(info->vginfo->vgname) && - get_pv_from_vg_by_id(info->fmt, info->vginfo->vgname, - info->vginfo->vgid, info->dev->pvid, pv)) { + if (_get_pv_if_in_vg(info, pv)) return 1; - } /* Perform full scan (just the first time) and try again */ if (!memlock() && !full_scan_done()) { - lvmcache_label_scan(fmt->cmd, 2); + lvmcache_label_scan(info->fmt->cmd, 2); - if (info->vginfo && info->vginfo->vgname && - !is_orphan_vg(info->vginfo->vgname) && - get_pv_from_vg_by_id(info->fmt, info->vginfo->vgname, - info->vginfo->vgid, - info->dev->pvid, pv)) { + if (_get_pv_if_in_vg(info, pv)) return 1; - } } /* Orphan */ @@ -1445,13 +1435,35 @@ /* Currently only support exactly one data area */ if (list_size(&info->das) != 1) { log_error("Must be exactly one data area (found %d) on PV %s", - list_size(&info->das), dev_name(dev)); + list_size(&info->das), dev_name(info->dev)); return 0; } list_iterate_items(da, &info->das) pv->pe_start = da->disk_locn.offset >> SECTOR_SHIFT; + return 1; +} + +static int _text_pv_read(const struct format_type *fmt, const char *pv_name, + struct physical_volume *pv, struct list *mdas) +{ + struct label *label; + struct device *dev; + struct lvmcache_info *info; + struct metadata_area *mda, *mda_new; + struct mda_context *mdac, *mdac_new; + + if (!(dev = dev_cache_get(pv_name, fmt->cmd->filter))) + return_0; + + if (!(label_read(dev, &label, UINT64_C(0)))) + return_0; + info = (struct lvmcache_info *) label->info; + + if (!_populate_pv_fields(info, pv)) + return 0; + if (!mdas) return 1; From agk@sourceware.org Thu Jul 31 12:28:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 31 Jul 2008 12:28:00 -0000 Subject: LVM2 ./WHATS_NEW tools/pvchange.c Message-ID: <20080731122851.5251.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-07-31 12:28:51 Modified files: . : WHATS_NEW tools : pvchange.c Log message: Fix pvchange to handle PVs without mdas. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.937&r2=1.938 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvchange.c.diff?cvsroot=lvm2&r1=1.60&r2=1.61 --- LVM2/WHATS_NEW 2008/07/31 10:50:12 1.937 +++ LVM2/WHATS_NEW 2008/07/31 12:28:50 1.938 @@ -1,5 +1,6 @@ Version 2.02.40 - ================================ + Fix pvchange to handle PVs without mdas. Refactor _text_pv_read and always return mda list if requested. Fix configure to work w/o readline unless --enable-readline used. (2.02.39) Remove is_lvm_partition template which has not yet been coded. --- LVM2/tools/pvchange.c 2008/07/16 10:46:12 1.60 +++ LVM2/tools/pvchange.c 2008/07/31 12:28:51 1.61 @@ -54,7 +54,6 @@ } /* If in a VG, must change using volume group. */ - /* FIXME: handle PVs with no MDAs */ if (!is_orphan(pv)) { vg_name = pv_vg_name(pv); @@ -233,8 +232,6 @@ struct list *pvslist; struct list mdas; - list_init(&mdas); - if (arg_count(cmd, allocatable_ARG) + arg_count(cmd, addtag_ARG) + arg_count(cmd, deltag_ARG) + arg_count(cmd, uuid_ARG) != 1) { log_error("Please give exactly one option of -x, -uuid, " @@ -256,12 +253,34 @@ log_verbose("Using physical volume(s) on command line"); for (; opt < argc; opt++) { pv_name = argv[opt]; - /* FIXME Read VG instead - pv_read will fail */ + list_init(&mdas); if (!(pv = pv_read(cmd, pv_name, &mdas, NULL, 1))) { log_error("Failed to read physical volume %s", pv_name); continue; } + /* + * If a PV has no MDAs it may appear to be an + * orphan until the metadata is read off + * another PV in the same VG. Detecting this + * means checking every VG by scanning every + * PV on the system. + */ + if (is_orphan(pv) && !list_size(&mdas)) { + if (!scan_vgs_for_pvs(cmd)) { + log_error("Rescan for PVs without " + "metadata areas failed."); + continue; + } + if (!(pv = pv_read(cmd, pv_name, + NULL, NULL, 1))) { + log_error("Failed to read " + "physical volume %s", + pv_name); + continue; + } + } + total++; done += _pvchange_single(cmd, pv, NULL); } From agk@sourceware.org Thu Jul 31 12:38:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 31 Jul 2008 12:38:00 -0000 Subject: LVM2 tools/pvremove.c ./WHATS_NEW Message-ID: <20080731123831.14093.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-07-31 12:38:31 Modified files: tools : pvremove.c . : WHATS_NEW Log message: fix pvremove for pvs without mdas Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvremove.c.diff?cvsroot=lvm2&r1=1.23&r2=1.24 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.938&r2=1.939 --- LVM2/tools/pvremove.c 2008/07/24 15:25:09 1.23 +++ LVM2/tools/pvremove.c 2008/07/31 12:38:31 1.24 @@ -25,18 +25,40 @@ static int pvremove_check(struct cmd_context *cmd, const char *name) { struct physical_volume *pv; + struct list mdas; + + list_init(&mdas); /* FIXME Check partition type is LVM unless --force is given */ /* Is there a pv here already? */ /* If not, this is an error unless you used -f. */ - if (!(pv = pv_read(cmd, name, NULL, NULL, 1))) { + if (!(pv = pv_read(cmd, name, &mdas, NULL, 1))) { if (arg_count(cmd, force_ARG)) return 1; log_error("Physical Volume %s not found", name); return 0; } + /* + * If a PV has no MDAs it may appear to be an + * orphan until the metadata is read off + * another PV in the same VG. Detecting this + * means checking every VG by scanning every + * PV on the system. + */ + if (is_orphan(pv) && !list_size(&mdas)) { + if (!scan_vgs_for_pvs(cmd)) { + log_error("Rescan for PVs without metadata areas " + "failed."); + return 0; + } + if (!(pv = pv_read(cmd, name, NULL, NULL, 1))) { + log_error("Failed to read physical volume %s", name); + return 0; + } + } + /* orphan ? */ if (is_orphan(pv)) return 1; --- LVM2/WHATS_NEW 2008/07/31 12:28:50 1.938 +++ LVM2/WHATS_NEW 2008/07/31 12:38:31 1.939 @@ -1,6 +1,6 @@ Version 2.02.40 - ================================ - Fix pvchange to handle PVs without mdas. + Fix pvchange and pvremove to handle PVs without mdas. Refactor _text_pv_read and always return mda list if requested. Fix configure to work w/o readline unless --enable-readline used. (2.02.39) Remove is_lvm_partition template which has not yet been coded. From agk@sourceware.org Thu Jul 31 12:40:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 31 Jul 2008 12:40:00 -0000 Subject: LVM2/tools pvchange.c Message-ID: <20080731124052.17162.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-07-31 12:40:52 Modified files: tools : pvchange.c Log message: remove unused mdas variable Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvchange.c.diff?cvsroot=lvm2&r1=1.61&r2=1.62 --- LVM2/tools/pvchange.c 2008/07/31 12:28:51 1.61 +++ LVM2/tools/pvchange.c 2008/07/31 12:40:52 1.62 @@ -23,7 +23,6 @@ struct volume_group *vg = NULL; const char *vg_name = NULL; struct pv_list *pvl; - struct list mdas; uint64_t sector; uint32_t orig_pe_alloc_count; /* FIXME Next three only required for format1. */ @@ -38,8 +37,6 @@ int allocatable = 0; int tagarg = 0; - list_init(&mdas); - if (arg_count(cmd, addtag_ARG)) tagarg = addtag_ARG; else if (arg_count(cmd, deltag_ARG)) @@ -100,7 +97,7 @@ return 0; } - if (!(pv = pv_read(cmd, pv_name, &mdas, §or, 1))) { + if (!(pv = pv_read(cmd, pv_name, NULL, §or, 1))) { unlock_vg(cmd, vg_name); log_error("Unable to read PV \"%s\"", pv_name); return 0; From agk@sourceware.org Thu Jul 31 13:03:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 31 Jul 2008 13:03:00 -0000 Subject: LVM2 ./WHATS_NEW tools/lvchange.c Message-ID: <20080731130302.4228.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-07-31 13:03:02 Modified files: . : WHATS_NEW tools : lvchange.c Log message: Change lvchange exit status to indicate if any part of the operation failed. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.939&r2=1.940 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvchange.c.diff?cvsroot=lvm2&r1=1.92&r2=1.93 --- LVM2/WHATS_NEW 2008/07/31 12:38:31 1.939 +++ LVM2/WHATS_NEW 2008/07/31 13:03:01 1.940 @@ -1,5 +1,6 @@ Version 2.02.40 - ================================ + Change lvchange exit status to indicate if any part of the operation failed. Fix pvchange and pvremove to handle PVs without mdas. Refactor _text_pv_read and always return mda list if requested. Fix configure to work w/o readline unless --enable-readline used. (2.02.39) --- LVM2/tools/lvchange.c 2008/06/18 11:32:14 1.92 +++ LVM2/tools/lvchange.c 2008/07/31 13:03:01 1.93 @@ -545,7 +545,7 @@ static int lvchange_single(struct cmd_context *cmd, struct logical_volume *lv, void *handle __attribute((unused))) { - int doit = 0; + int doit = 0, docmds = 0; int archived = 0; if (!(lv->vg->status & LVM_WRITE) && @@ -606,6 +606,7 @@ return ECMD_FAILED; archived = 1; doit += lvchange_permission(cmd, lv); + docmds++; } /* allocation policy change */ @@ -614,6 +615,7 @@ return ECMD_FAILED; archived = 1; doit += lvchange_alloc(cmd, lv); + docmds++; } /* read ahead sector change */ @@ -622,6 +624,7 @@ return ECMD_FAILED; archived = 1; doit += lvchange_readahead(cmd, lv); + docmds++; } /* read ahead sector change */ @@ -630,6 +633,7 @@ return ECMD_FAILED; archived = 1; doit += lvchange_persistent(cmd, lv); + docmds++; if (sigint_caught()) return ECMD_FAILED; } @@ -640,6 +644,7 @@ return ECMD_FAILED; archived = 1; doit += lvchange_tag(cmd, lv, addtag_ARG); + docmds++; } /* del tag */ @@ -648,6 +653,7 @@ return ECMD_FAILED; archived = 1; doit += lvchange_tag(cmd, lv, deltag_ARG); + docmds++; } if (doit) @@ -674,6 +680,9 @@ return ECMD_FAILED; } + if (doit != docmds) + return ECMD_FAILED; + return ECMD_PROCESSED; } From agk@sourceware.org Thu Jul 31 13:07:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 31 Jul 2008 13:07:00 -0000 Subject: LVM2 lib/config/config.c ./WHATS_NEW lib/forma ... Message-ID: <20080731130702.8172.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-07-31 13:07:01 Modified files: lib/config : config.c . : WHATS_NEW lib/format_text: format-text.c Log message: Avoid looping forever in _pv_analyze_mda_raw used by pvck. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/config.c.diff?cvsroot=lvm2&r1=1.69&r2=1.70 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.940&r2=1.941 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/format-text.c.diff?cvsroot=lvm2&r1=1.92&r2=1.93 --- LVM2/lib/config/config.c 2008/06/03 17:51:04 1.69 +++ LVM2/lib/config/config.c 2008/07/31 13:06:55 1.70 @@ -1276,7 +1276,7 @@ begin_count = _count_tokens(str, len, TOK_SECTION_B); end_count = _count_tokens(str, len, TOK_SECTION_E); - if (begin_count && end_count && (begin_count - end_count == 0)) + if (begin_count && end_count && (begin_count == end_count)) return 1; else return 0; --- LVM2/WHATS_NEW 2008/07/31 13:03:01 1.940 +++ LVM2/WHATS_NEW 2008/07/31 13:07:01 1.941 @@ -1,5 +1,6 @@ Version 2.02.40 - ================================ + Avoid looping forever in _pv_analyze_mda_raw used by pvck. Change lvchange exit status to indicate if any part of the operation failed. Fix pvchange and pvremove to handle PVs without mdas. Refactor _text_pv_read and always return mda list if requested. --- LVM2/lib/format_text/format-text.c 2008/07/31 10:50:18 1.92 +++ LVM2/lib/format_text/format-text.c 2008/07/31 13:07:01 1.93 @@ -139,7 +139,7 @@ struct raw_locn *rlocn; uint64_t area_start; uint64_t area_size; - uint64_t prev_sector; + uint64_t prev_sector, prev_sector2; uint64_t latest_mrec_offset; int i; uint64_t offset; @@ -184,8 +184,11 @@ offset2 = size2 = 0; i = 0; while (prev_sector != latest_mrec_offset) { + prev_sector2 = prev_sector; prev_sector = _get_prev_sector_circular(area_start, area_size, prev_sector); + if (prev_sector > prev_sector2) + goto_out; /* * FIXME: for some reason, the whole metadata region from * area->start to area->start+area->size is not used. From agk@sourceware.org Thu Jul 31 14:43:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 31 Jul 2008 14:43:00 -0000 Subject: LVM2 ./WHATS_NEW lib/mirror/mirrored.c Message-ID: <20080731144340.5562.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-07-31 14:43:39 Modified files: . : WHATS_NEW lib/mirror : mirrored.c Log message: Change clustered mirror kernel module name from cmirror to dm-log-clustered. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.941&r2=1.942 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.56&r2=1.57 --- LVM2/WHATS_NEW 2008/07/31 13:07:01 1.941 +++ LVM2/WHATS_NEW 2008/07/31 14:43:39 1.942 @@ -1,5 +1,6 @@ Version 2.02.40 - ================================ + Change clustered mirror kernel module name from cmirror to dm-log-clustered. Avoid looping forever in _pv_analyze_mda_raw used by pvck. Change lvchange exit status to indicate if any part of the operation failed. Fix pvchange and pvremove to handle PVs without mdas. --- LVM2/lib/mirror/mirrored.c 2008/07/15 00:25:51 1.56 +++ LVM2/lib/mirror/mirrored.c 2008/07/31 14:43:39 1.57 @@ -375,7 +375,7 @@ * FIXME: Fails incorrectly if cmirror was built into kernel. */ if (attributes) { - if (!_mirror_attributes && module_present("cmirror")) + if (!_mirror_attributes && module_present("log-clustered")) _mirror_attributes |= MIRROR_LOG_CLUSTERED; *attributes = _mirror_attributes; } From agk@sourceware.org Thu Jul 31 15:38:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 31 Jul 2008 15:38:00 -0000 Subject: LVM2 lib/misc/last-path-component.h tools/lvmc ... Message-ID: <20080731153852.20945.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-07-31 15:38:52 Modified files: lib/misc : last-path-component.h tools : lvmcmdline.c Log message: remove now-redundant slash-stripping Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/misc/last-path-component.h.diff?cvsroot=lvm2&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.67&r2=1.68 --- LVM2/lib/misc/last-path-component.h 2007/10/03 16:10:04 1.1 +++ LVM2/lib/misc/last-path-component.h 2008/07/31 15:38:51 1.2 @@ -21,7 +21,8 @@ static inline char *last_path_component(char const *name) { - char const *slash = strrchr (name, '/'); + char const *slash = strrchr(name, '/'); char const *res = slash ? slash + 1 : name; - return (char *) res; + + return (char *)res; } --- LVM2/tools/lvmcmdline.c 2008/06/06 19:28:35 1.67 +++ LVM2/tools/lvmcmdline.c 2008/07/31 15:38:52 1.68 @@ -1165,8 +1165,6 @@ _close_stray_fds(); base = last_path_component(argv[0]); - while (*base == '/') - base++; if (strcmp(base, "lvm") && strcmp(base, "lvm.static") && strcmp(base, "initrd-lvm")) alias = 1;