From ccaulfield@sourceware.org Tue Apr 1 15:01:00 2008 From: ccaulfield@sourceware.org (ccaulfield@sourceware.org) Date: Tue, 01 Apr 2008 15:01:00 -0000 Subject: LVM2 ./WHATS_NEW daemons/clvmd/clvmd-cman.c Message-ID: <20080401150130.26704.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: ccaulfield@sourceware.org 2008-04-01 15:01:30 Modified files: . : WHATS_NEW daemons/clvmd : clvmd-cman.c Log message: Fix another allocation bug with clvmd and large node IDs.` Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.812&r2=1.813 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-cman.c.diff?cvsroot=lvm2&r1=1.21&r2=1.22 --- LVM2/WHATS_NEW 2008/03/28 19:08:23 1.812 +++ LVM2/WHATS_NEW 2008/04/01 15:01:30 1.813 @@ -1,5 +1,6 @@ Version 2.02.34 - =================================== + Fix another allocation bug with clvmd and large node IDs. Add find_lv_in_lv_list() and find_pv_in_pv_list(). Fix uninitialised variable in clvmd that could cause odd hangs. Add vgmerge tests. --- LVM2/daemons/clvmd/clvmd-cman.c 2008/03/25 10:41:59 1.21 +++ LVM2/daemons/clvmd/clvmd-cman.c 2008/04/01 15:01:30 1.22 @@ -297,6 +297,8 @@ { int retnodes; int status; + int i; + int high_nodeid = 0; num_nodes = cman_get_node_count(c_handle); if (num_nodes == -1) { @@ -325,10 +327,16 @@ exit(6); } + /* Get the highest nodeid */ + for (i=0; i high_nodeid) + high_nodeid = nodes[i].cn_nodeid; + } + if (node_updown == NULL) { size_t buf_len; - if (num_nodes > max_updown_nodes) - max_updown_nodes = num_nodes; + if (high_nodeid >= max_updown_nodes) + max_updown_nodes = high_nodeid + 1; buf_len = sizeof(int) * max_updown_nodes; node_updown = malloc(buf_len); if (node_updown) From wysochanski@sourceware.org Tue Apr 1 22:15:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Tue, 01 Apr 2008 22:15:00 -0000 Subject: LVM2 ./WHATS_NEW tools/lvresize.c Message-ID: <20080401221517.12825.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-01 22:15:16 Modified files: . : WHATS_NEW tools : lvresize.c Log message: Fix redundant lvresize message if vg doesn't exist. BEFORE: tools/lvm lvresize -l +4 vg22/lv1linear Volume group "vg22" not found Volume group vg22 doesn't exist AFTER: tools/lvm lvresize -l +4 vg22/lv1linear Volume group "vg22" not found Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.813&r2=1.814 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.93&r2=1.94 --- LVM2/WHATS_NEW 2008/04/01 15:01:30 1.813 +++ LVM2/WHATS_NEW 2008/04/01 22:15:16 1.814 @@ -1,5 +1,6 @@ Version 2.02.34 - =================================== + Fix redundant lvresize message if vg doesn't exist. Fix another allocation bug with clvmd and large node IDs. Add find_lv_in_lv_list() and find_pv_in_pv_list(). Fix uninitialised variable in clvmd that could cause odd hangs. --- LVM2/tools/lvresize.c 2008/02/06 12:45:32 1.93 +++ LVM2/tools/lvresize.c 2008/04/01 22:15:16 1.94 @@ -654,10 +654,8 @@ log_verbose("Finding volume group %s", lp.vg_name); if (!(vg = vg_lock_and_read(cmd, lp.vg_name, NULL, LCK_VG_WRITE, CLUSTERED | EXPORTED_VG | LVM_WRITE, - CORRECT_INCONSISTENT))) { - log_error("Volume group %s doesn't exist", lp.vg_name); + CORRECT_INCONSISTENT))) return ECMD_FAILED; - } if (!(r = _lvresize(cmd, vg, &lp))) stack; From agk@sourceware.org Tue Apr 1 22:40:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 01 Apr 2008 22:40:00 -0000 Subject: LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ... Message-ID: <20080401224014.23642.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-01 22:40:13 Modified files: . : WHATS_NEW lib/cache : lvmcache.c lvmcache.h lib/format_text: export.c import.c lib/metadata : metadata.c metadata.h Log message: Cache VG metadata internally while VG lock is held. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.814&r2=1.815 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.39&r2=1.40 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.18&r2=1.19 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/export.c.diff?cvsroot=lvm2&r1=1.62&r2=1.63 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_text/import.c.diff?cvsroot=lvm2&r1=1.46&r2=1.47 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.163&r2=1.164 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.h.diff?cvsroot=lvm2&r1=1.179&r2=1.180 --- LVM2/WHATS_NEW 2008/04/01 22:15:16 1.814 +++ LVM2/WHATS_NEW 2008/04/01 22:40:12 1.815 @@ -1,5 +1,6 @@ Version 2.02.34 - =================================== + Cache VG metadata internally while VG lock is held. Fix redundant lvresize message if vg doesn't exist. Fix another allocation bug with clvmd and large node IDs. Add find_lv_in_lv_list() and find_pv_in_pv_list(). --- LVM2/lib/cache/lvmcache.c 2008/03/17 16:51:31 1.39 +++ LVM2/lib/cache/lvmcache.c 2008/04/01 22:40:12 1.40 @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -49,15 +49,53 @@ return 1; } -static void _update_cache_info_lock_state(struct lvmcache_info *info, int locked) +/* Volume Group metadata cache functions */ +static void _free_cached_vgmetadata(struct lvmcache_vginfo *vginfo) +{ + if (!vginfo || !vginfo->vgmetadata) + return; + + dm_free(vginfo->vgmetadata); + + vginfo->vgmetadata = NULL; + vginfo->fid = NULL; + + log_debug("Metadata cache: VG %s wiped.", vginfo->vgname); +} + +static void _store_metadata(struct lvmcache_vginfo *vginfo, + struct volume_group *vg, unsigned precommitted) +{ + int size; + + if (vginfo->vgmetadata) + _free_cached_vgmetadata(vginfo); + + if (!(size = export_vg_to_buffer(vg, &vginfo->vgmetadata))) { + stack; + return; + } + + vginfo->fid = vg->fid; + vginfo->precommitted = precommitted; + + log_debug("Metadata cache: VG %s stored (%d bytes%s).", vginfo->vgname, + size, precommitted ? ", precommitted" : ""); +} + +static void _update_cache_info_lock_state(struct lvmcache_info *info, + int locked, + int *cached_vgmetadata_valid) { int was_locked = (info->status & CACHE_LOCKED) ? 1 : 0; /* * Cache becomes invalid whenever lock state changes */ - if (was_locked != locked) + if (was_locked != locked) { info->status |= CACHE_INVALID; + *cached_vgmetadata_valid = 0; + } if (locked) info->status |= CACHE_LOCKED; @@ -69,9 +107,14 @@ int locked) { struct lvmcache_info *info; + int cached_vgmetadata_valid = 1; list_iterate_items(info, &vginfo->infos) - _update_cache_info_lock_state(info, locked); + _update_cache_info_lock_state(info, locked, + &cached_vgmetadata_valid); + + if (!cached_vgmetadata_valid) + _free_cached_vgmetadata(vginfo); } static void _update_cache_lock_state(const char *vgname, int locked) @@ -238,6 +281,17 @@ return 1; } +static int _vginfo_is_valid(struct lvmcache_vginfo *vginfo) +{ + struct lvmcache_info *info; + + list_iterate_items(info, &vginfo->infos) + if (!_info_is_valid(info)) + return 0; + + return 1; +} + /* * If valid_only is set, data will only be returned if the cached data is * known still to be valid. @@ -329,6 +383,32 @@ return r; } +struct volume_group *lvmcache_get_vg(const char *vgid, unsigned precommitted) +{ + struct lvmcache_vginfo *vginfo; + struct volume_group *vg; + + if (!vgid || !(vginfo = vginfo_from_vgid(vgid)) || !vginfo->vgmetadata) + return NULL; + + if (!_vginfo_is_valid(vginfo)) + return NULL; + + if ((precommitted && !vginfo->precommitted) || + (!precommitted && vginfo->precommitted)) + return NULL; + + if (!(vg = import_vg_from_buffer(vginfo->vgmetadata, vginfo->fid)) || + !vg_validate(vg)) { + _free_cached_vgmetadata(vginfo); + return_NULL; + } + + log_debug("Using cached metadata for VG %s.", vginfo->vgname); + + return vg; +} + struct list *lvmcache_get_vgids(struct cmd_context *cmd, int full_scan) { struct list *vgids; @@ -490,20 +570,6 @@ return; } */ -int lvmcache_store_vg(struct lvmcache_vginfo *vginfo, struct volume_group *vg, - unsigned precommitted) -{ - return 1; -} - -void lvmcache_drop_vg(const char *vgname) -{ - struct lvmcache_vginfo *vginfo; - - if (!(vginfo = vginfo_from_vgname(vgname, NULL))) - return; -} - static int _lvmcache_update_pvid(struct lvmcache_info *info, const char *pvid) { if (!strcmp(info->dev->pvid, pvid)) @@ -803,7 +869,7 @@ /* store text representation of vg to cache */ if ((vginfo = vginfo_from_vgname(vg->name, NULL))) - lvmcache_store_vg(vginfo, vg, precommitted); + _store_metadata(vginfo, vg, precommitted); return 1; } @@ -935,6 +1001,7 @@ dm_free(vginfo->vgname); if (vginfo->creation_host) dm_free(vginfo->creation_host); + _free_cached_vgmetadata(vginfo); dm_free(vginfo); } while ((vginfo = next)); } --- LVM2/lib/cache/lvmcache.h 2008/03/17 16:51:31 1.18 +++ LVM2/lib/cache/lvmcache.h 2008/04/01 22:40:12 1.19 @@ -109,4 +109,7 @@ struct list *lvmcache_get_pvids(struct cmd_context *cmd, const char *vgname, const char *vgid); +/* Returns cached volume group metadata. */ +struct volume_group *lvmcache_get_vg(const char *vgid, unsigned precommitted); + #endif --- LVM2/lib/format_text/export.c 2008/03/12 16:03:22 1.62 +++ LVM2/lib/format_text/export.c 2008/04/01 22:40:12 1.63 @@ -742,5 +742,10 @@ return r; } +int export_vg_to_buffer(struct volume_group *vg, char **buf) +{ + return text_vg_export_raw(vg, "", buf); +} + #undef outf #undef outnl --- LVM2/lib/format_text/import.c 2008/03/13 12:33:22 1.46 +++ LVM2/lib/format_text/import.c 2008/04/01 22:40:12 1.47 @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -130,3 +130,27 @@ return text_vg_import_fd(fid, file, NULL, (off_t)0, 0, (off_t)0, 0, NULL, 0, when, desc); } + +struct volume_group *import_vg_from_buffer(char *buf, + struct format_instance *fid) +{ + struct volume_group *vg = NULL; + struct config_tree *cft; + struct text_vg_version_ops **vsn; + + _init_text_import(); + + if (!(cft = create_config_tree_from_string(fid->fmt->cmd, buf))) + return_NULL; + + for (vsn = &_text_vsn_list[0]; *vsn; vsn++) { + if (!(*vsn)->check_version(cft)) + continue; + if (!(vg = (*vsn)->read_vg(fid, cft))) + stack; + break; + } + + destroy_config_tree(cft); + return vg; +} --- LVM2/lib/metadata/metadata.c 2008/03/28 19:08:23 1.163 +++ LVM2/lib/metadata/metadata.c 2008/04/01 22:40:12 1.164 @@ -1316,9 +1316,6 @@ int cache_updated = 0; int failed = 0; - /* Forget all cached instances of vg and force reread */ - lvmcache_drop_vg(vg->name); - /* Commit to each copy of the metadata area */ list_iterate_items(mda, &vg->fid->metadata_areas) { failed = 0; @@ -1455,6 +1452,11 @@ return _vg_read_orphans(cmd, vgname); } + if ((correct_vg = lvmcache_get_vg(vgid, precommitted))) { + *consistent = 1; + return correct_vg; + } + /* Find the vgname in the cache */ /* If it's not there we must do full scan to be completely sure */ if (!(fmt = fmt_from_vgname(vgname, vgid))) { --- LVM2/lib/metadata/metadata.h 2008/03/28 19:08:23 1.179 +++ LVM2/lib/metadata/metadata.h 2008/04/01 22:40:13 1.180 @@ -313,6 +313,13 @@ struct lv_segment *get_only_segment_using_this_lv(struct logical_volume *lv); /* + * For internal metadata caching. + */ +int export_vg_to_buffer(struct volume_group *vg, char **buf); +struct volume_group *import_vg_from_buffer(char *buf, + struct format_instance *fid); + +/* * Mirroring functions */ From wysochanski@sourceware.org Wed Apr 2 12:17:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Wed, 02 Apr 2008 12:17:00 -0000 Subject: LVM2 tools/lvresize.c test/t-lvresize-usage.sh Message-ID: <20080402121731.26629.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-02 12:17:31 Modified files: tools : lvresize.c Added files: test : t-lvresize-usage.sh Log message: Fix lvresize to dump stack if vg_lock_and_read() fails. Necessary because vg_lock_and_read() may fail silently if the vg_check_status() call fails. Also add lvresize tests. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvresize-usage.sh.diff?cvsroot=lvm2&r1=NONE&r2=1.1 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.94&r2=1.95 /cvs/lvm2/LVM2/test/t-lvresize-usage.sh,v --> standard output revision 1.1 --- LVM2/test/t-lvresize-usage.sh +++ - 2008-04-02 12:17:31.542123000 +0000 @@ -0,0 +1,55 @@ +#!/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 lvresize command options for validity' +privileges_required_=1 + +. ./test-lib.sh + +cleanup_() +{ + test -n "$vg" && { + vgchange -an "$vg" + lvremove -ff "$vg" + vgremove "$vg" + } > "$test_dir_/cleanup.log" + test -n "$d1" && losetup -d "$d1" + test -n "$d2" && losetup -d "$d2" + rm -f "$f1" "$f2" +} + +test_expect_success \ + 'set up temp files, loopback devices, PVs, and a VG' \ + 'f1=$(pwd)/1 && d1=$(loop_setup_ "$f1") && + f2=$(pwd)/2 && d2=$(loop_setup_ "$f2") && + pvcreate $d1 $d2 && + vg=$(this_test_)-test-vg-$$ && + vgcreate $vg $d1 $d2' + +lv=lvresize-usage-$$ + +test_expect_success \ + 'lvresize normal operation succeeds' \ + 'lvcreate -L 64M -n $lv -i2 $vg && + lvresize -l +4 $vg/$lv && + lvremove -ff $vg' + +test_expect_success \ + 'lvresize rejects an invalid vgname' \ + 'lvcreate -L 64M -n $lv -i2 $vg && + lvresize -v -l +4 xxx/$lv && + echo status=$?; test $? = 5 && + lvremove -ff $vg' + +test_done +# Local Variables: +# indent-tabs-mode: nil +# End: --- LVM2/tools/lvresize.c 2008/04/01 22:15:16 1.94 +++ LVM2/tools/lvresize.c 2008/04/02 12:17:30 1.95 @@ -654,8 +654,10 @@ log_verbose("Finding volume group %s", lp.vg_name); if (!(vg = vg_lock_and_read(cmd, lp.vg_name, NULL, LCK_VG_WRITE, CLUSTERED | EXPORTED_VG | LVM_WRITE, - CORRECT_INCONSISTENT))) + CORRECT_INCONSISTENT))) { + stack; return ECMD_FAILED; + } if (!(r = _lvresize(cmd, vg, &lp))) stack; From wysochanski@sourceware.org Wed Apr 2 13:08:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Wed, 02 Apr 2008 13:08:00 -0000 Subject: LVM2 ./WHATS_NEW tools/vgsplit.c Message-ID: <20080402130849.29631.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-02 13:08:49 Modified files: . : WHATS_NEW tools : vgsplit.c Log message: Suppress "Volume group not found" message when vgsplit of new VG. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.815&r2=1.816 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.52&r2=1.53 --- LVM2/WHATS_NEW 2008/04/01 22:40:12 1.815 +++ LVM2/WHATS_NEW 2008/04/02 13:08:49 1.816 @@ -1,5 +1,7 @@ Version 2.02.34 - =================================== + Suppress excess messages when vgsplit into a new vg. + Suppress duplicate message when lvresize fails because of invalid vgname. Cache VG metadata internally while VG lock is held. Fix redundant lvresize message if vg doesn't exist. Fix another allocation bug with clvmd and large node IDs. --- LVM2/tools/vgsplit.c 2008/03/26 17:26:32 1.52 +++ LVM2/tools/vgsplit.c 2008/04/02 13:08:49 1.53 @@ -220,6 +220,7 @@ int opt; int active; int existing_vg; + int old_suppress; struct pv_list *pvl; if (argc < 3) { @@ -253,9 +254,11 @@ } log_verbose("Checking for new volume group \"%s\"", vg_name_to); + old_suppress = log_suppress(2); if ((vg_to = vg_lock_and_read(cmd, vg_name_to, NULL, LCK_VG_WRITE | LCK_NONBLOCK, 0, 0))) { + log_suppress(old_suppress); existing_vg = 1; if (new_vg_option_specified(cmd)) { log_error("Volume group \"%s\" exists, but new VG " @@ -265,6 +268,7 @@ if (!vgs_are_compatible(cmd, vg_from,vg_to)) goto error; } else { + log_suppress(old_suppress); existing_vg = 0; /* Set metadata format of original VG */ From wysochanski@sourceware.org Wed Apr 2 19:30:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Wed, 02 Apr 2008 19:30:00 -0000 Subject: LVM2 ./WHATS_NEW tools/vgsplit.c Message-ID: <20080402193013.8962.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-02 19:30:13 Modified files: . : WHATS_NEW tools : vgsplit.c Log message: Fix vgsplit locking and remove unneeded error messages when split into new VG. When vg_lock_and_read() calls were added, they were done so incorrectly for the destination VG (vg_to). This resulted in the VG lock not obtained when a new VG was the destination (vg_lock_and_read() would fail in the vg_read() clause, which would then release the lock before returning NULL), and could result in corrupted destination VG. The fix was to put back the original lock_vol() and vg_read() calls for 'vg_to'. The failure of vg_read() indicates "vg does not exist", and we key off that to determine whether we are dealing with a new or existing VG as the destination. The first two error messages were also the result of the incorrect vg_lock_and_read() calls: Volume group "new" not found cluster request failed: Invalid argument New volume group "new" successfully split from "vg" Fixes https://bugzilla.redhat.com/show_bug.cgi?id=438249 Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.816&r2=1.817 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.53&r2=1.54 --- LVM2/WHATS_NEW 2008/04/02 13:08:49 1.816 +++ LVM2/WHATS_NEW 2008/04/02 19:30:12 1.817 @@ -1,6 +1,6 @@ Version 2.02.34 - =================================== - Suppress excess messages when vgsplit into a new vg. + Fix vgsplit locking, remove unneeded error messages when split into new VG. Suppress duplicate message when lvresize fails because of invalid vgname. Cache VG metadata internally while VG lock is held. Fix redundant lvresize message if vg doesn't exist. --- LVM2/tools/vgsplit.c 2008/04/02 13:08:49 1.53 +++ LVM2/tools/vgsplit.c 2008/04/02 19:30:12 1.54 @@ -222,6 +222,7 @@ int existing_vg; int old_suppress; struct pv_list *pvl; + int consistent; if (argc < 3) { log_error("Existing VG, new VG and physical volumes required."); @@ -254,11 +255,14 @@ } log_verbose("Checking for new volume group \"%s\"", vg_name_to); - old_suppress = log_suppress(2); - if ((vg_to = vg_lock_and_read(cmd, vg_name_to, NULL, - LCK_VG_WRITE | LCK_NONBLOCK, - 0, 0))) { - log_suppress(old_suppress); + if (!lock_vol(cmd, vg_name_to, LCK_VG_WRITE | LCK_NONBLOCK)) { + log_error("Can't get lock for %s", vg_name_to); + unlock_vg(cmd, vg_name_from); + return ECMD_FAILED; + } + + consistent = 0; + if ((vg_to = vg_read(cmd, vg_name_to, NULL, &consistent))) { existing_vg = 1; if (new_vg_option_specified(cmd)) { log_error("Volume group \"%s\" exists, but new VG " @@ -341,7 +345,13 @@ /* store it on disks */ log_verbose("Writing out updated volume groups"); - /* Write out new VG as EXPORTED */ + /* + * First, write out the new VG as EXPORTED. We do this first in case + * there is a crash - we will still have the new VG information, in an + * exported state. Recovery after this point would be removal of the + * new VG and redoing the vgsplit. + * FIXME: recover automatically or instruct the user? + */ vg_to->status |= EXPORTED_VG; if (!archive(vg_to)) @@ -352,7 +362,11 @@ backup(vg_to); - /* Write out updated old VG */ + /* + * Next, write out the updated old VG. If we crash after this point, + * recovery is a vgimport on the new VG. + * FIXME: recover automatically or instruct the user the user? + */ if (vg_from->pv_count) { if (!vg_write(vg_from) || !vg_commit(vg_from)) goto error; @@ -360,10 +374,13 @@ backup(vg_from); } - /* Remove EXPORTED flag from new VG */ + /* + * Finally, remove the EXPORTED flag from the new VG and write it out. + */ + consistent = 1; if (!test_mode() && - !(vg_to = vg_lock_and_read(cmd, vg_name_to, NULL, LCK_NONE, 0, - CORRECT_INCONSISTENT | FAIL_INCONSISTENT))) { + (!(vg_to = vg_read(cmd, vg_name_to, NULL, &consistent)) + || !consistent)) { log_error("Volume group \"%s\" became inconsistent: please " "fix manually", vg_name_to); goto error; From agk@sourceware.org Wed Apr 2 21:23:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 02 Apr 2008 21:23:00 -0000 Subject: LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/comm ... Message-ID: <20080402212339.20555.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-02 21:23:39 Modified files: . : WHATS_NEW lib/cache : lvmcache.c lib/commands : toolcontext.h tools : commands.h lvmcmdline.c tools.h Log message: Add per-command flags to control which commands use the VG metadata cache. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.817&r2=1.818 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.40&r2=1.41 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.h.diff?cvsroot=lvm2&r1=1.21&r2=1.22 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/commands.h.diff?cvsroot=lvm2&r1=1.108&r2=1.109 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.61&r2=1.62 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/tools.h.diff?cvsroot=lvm2&r1=1.60&r2=1.61 --- LVM2/WHATS_NEW 2008/04/02 19:30:12 1.817 +++ LVM2/WHATS_NEW 2008/04/02 21:23:38 1.818 @@ -1,5 +1,6 @@ Version 2.02.34 - =================================== + Add per-command flags to control which commands use the VG metadata cache. Fix vgsplit locking, remove unneeded error messages when split into new VG. Suppress duplicate message when lvresize fails because of invalid vgname. Cache VG metadata internally while VG lock is held. --- LVM2/lib/cache/lvmcache.c 2008/04/01 22:40:12 1.40 +++ LVM2/lib/cache/lvmcache.c 2008/04/02 21:23:39 1.41 @@ -868,7 +868,8 @@ } /* store text representation of vg to cache */ - if ((vginfo = vginfo_from_vgname(vg->name, NULL))) + if (vg->cmd->current_settings.cache_vgmetadata && + (vginfo = vginfo_from_vgname(vg->name, NULL))) _store_metadata(vginfo, vg, precommitted); return 1; --- LVM2/lib/commands/toolcontext.h 2007/11/09 16:51:53 1.21 +++ LVM2/lib/commands/toolcontext.h 2008/04/02 21:23:39 1.22 @@ -34,6 +34,7 @@ int archive; /* should we archive ? */ int backup; /* should we backup ? */ int read_ahead; /* DM_READ_AHEAD_NONE or _AUTO */ + int cache_vgmetadata; const char *msg_prefix; struct format_type *fmt; uint64_t unit_factor; --- LVM2/tools/commands.h 2008/01/22 02:48:53 1.108 +++ LVM2/tools/commands.h 2008/04/02 21:23:39 1.109 @@ -30,6 +30,7 @@ xx(dumpconfig, "Dump active configuration", + 0, "dumpconfig " "\t[-f|--file filename] " "\n" "[ConfigurationVariable...]\n", @@ -37,10 +38,12 @@ xx(formats, "List available metadata formats", + 0, "formats\n") xx(help, "Display help for commands", + 0, "help " "\n") /********* @@ -55,6 +58,7 @@ xx(lvchange, "Change the attributes of logical volume(s)", + CACHE_VGMETADATA, "lvchange\n" "\t[-A|--autobackup y|n]\n" "\t[-a|--available [e|l]y|n]\n" @@ -87,6 +91,7 @@ xx(lvconvert, "Change logical volume layout", + 0, "lvconvert " "[-m|--mirrors Mirrors [{--mirrorlog {disk|core}|--corelog}]]\n" "\t[-R|--regionsize MirrorLogRegionSize]\n" @@ -114,6 +119,7 @@ xx(lvcreate, "Create a logical volume", + 0, "lvcreate " "\n" "\t[-A|--autobackup {y|n}]\n" "\t[--addtag Tag]\n" @@ -165,6 +171,7 @@ xx(lvdisplay, "Display information about a logical volume", + 0, "lvdisplay\n" "\t[-a|--all]\n" "\t[-c|--colon]\n" @@ -205,6 +212,7 @@ xx(lvextend, "Add space to a logical volume", + 0, "lvextend\n" "\t[-A|--autobackup y|n]\n" "\t[--alloc AllocationPolicy]\n" @@ -228,6 +236,7 @@ xx(lvmchange, "With the device mapper, this is obsolete and does nothing.", + 0, "lvmchange\n" "\t[-d|--debug]\n" "\t[-h|--help]\n" @@ -239,6 +248,7 @@ xx(lvmdiskscan, "List devices that may be used as physical volumes", + 0, "lvmdiskscan\n" "\t[-d|--debug]\n" "\t[-h|--help]\n" @@ -249,6 +259,7 @@ xx(lvmsadc, "Collect activity data", + 0, "lvmsadc\n" "\t[-d|--debug]\n" "\t[-h|--help]\n" @@ -258,6 +269,7 @@ xx(lvmsar, "Create activity report", + 0, "lvmsar\n" "\t[-d|--debug]\n" "\t[-f|--full]\n" @@ -271,6 +283,7 @@ xx(lvreduce, "Reduce the size of a logical volume", + 0, "lvreduce\n" "\t[-A|--autobackup y|n]\n" "\t[-d|--debug]\n" @@ -291,6 +304,7 @@ xx(lvremove, "Remove logical volume(s) from the system", + 0, "lvremove\n" "\t[-A|--autobackup y|n]\n" "\t[-d|--debug]\n" @@ -305,6 +319,7 @@ xx(lvrename, "Rename a logical volume", + 0, "lvrename " "\t[-A|--autobackup {y|n}] " "\n" "\t[-d|--debug] " "\n" @@ -319,6 +334,7 @@ xx(lvresize, "Resize a logical volume", + 0, "lvresize\n" "\t[-A|--autobackup y|n]\n" "\t[--alloc AllocationPolicy]\n" @@ -340,6 +356,7 @@ xx(lvs, "Display information about logical volumes", + 0, "lvs" "\n" "\t[-a|--all]\n" "\t[--aligned]\n" @@ -366,6 +383,7 @@ xx(lvscan, "List all logical volumes in all volume groups", + 0, "lvscan " "\n" "\t[-a|--all]\n" "\t[-b|--blockdevice] " "\n" @@ -380,6 +398,7 @@ xx(pvchange, "Change attributes of physical volume(s)", + 0, "pvchange\n" "\t[-a|--all]\n" "\t[-A|--autobackup y|n]\n" @@ -399,6 +418,7 @@ xx(pvresize, "Resize physical volume(s)", + 0, "pvresize " "\n" "\t[-d|--debug]" "\n" "\t[-h|-?|--help] " "\n" @@ -412,6 +432,7 @@ xx(pvck, "Check the consistency of physical volume(s)", + 0, "pvck " "\t[-d|--debug]\n" "\t[-h|--help]\n" @@ -424,6 +445,7 @@ xx(pvcreate, "Initialize physical volume(s) for use by LVM", + 0, "pvcreate " "\n" "\t[--restorefile file]\n" "\t[-d|--debug]" "\n" @@ -448,6 +470,7 @@ xx(pvdata, "Display the on-disk metadata for physical volume(s)", + 0, "pvdata " "\n" "\t[-a|--all] " "\n" "\t[-d|--debug] " "\n" @@ -466,6 +489,7 @@ xx(pvdisplay, "Display various attributes of physical volume(s)", + 0, "pvdisplay\n" "\t[-c|--colon]\n" "\t[-d|--debug]\n" @@ -502,6 +526,7 @@ xx(pvmove, "Move extents from one physical volume to another", + 0, "pvmove " "\n" "\t[--abort]\n" "\t[-A|--autobackup {y|n}]\n" @@ -523,6 +548,7 @@ xx(pvremove, "Remove LVM label(s) from physical volume(s)", + 0, "pvremove " "\n" "\t[-d|--debug]" "\n" "\t[-f[f]|--force [--force]] " "\n" @@ -537,6 +563,7 @@ xx(pvs, "Display information about physical volumes", + 0, "pvs" "\n" "\t[--aligned]\n" "\t[-a|--all]\n" @@ -563,6 +590,7 @@ xx(pvscan, "List all physical volumes", + 0, "pvscan " "\n" "\t[-d|--debug] " "\n" "\t{-e|--exported | -n|--novolumegroup} " "\n" @@ -579,10 +607,12 @@ xx(segtypes, "List available segment types", + 0, "segtypes\n") xx(vgcfgbackup, "Backup volume group configuration(s)", + 0, "vgcfgbackup " "\n" "\t[-d|--debug] " "\n" "\t[-f|--file filename] " "\n" @@ -597,6 +627,7 @@ xx(vgcfgrestore, "Restore volume group configuration", + 0, "vgcfgrestore " "\n" "\t[-d|--debug] " "\n" "\t[-f|--file filename] " "\n" @@ -613,6 +644,7 @@ xx(vgchange, "Change volume group attributes", + CACHE_VGMETADATA, "vgchange" "\n" "\t[-A|--autobackup {y|n}] " "\n" "\t[--alloc AllocationPolicy] " "\n" @@ -643,6 +675,7 @@ xx(vgck, "Check the consistency of volume group(s)", + 0, "vgck " "\t[-d|--debug]\n" "\t[-h|--help]\n" @@ -652,6 +685,7 @@ xx(vgconvert, "Change volume group metadata format", + 0, "vgconvert " "\n" "\t[-d|--debug]" "\n" "\t[-h|--help] " "\n" @@ -669,6 +703,7 @@ xx(vgcreate, "Create a volume group", + 0, "vgcreate" "\n" "\t[-A|--autobackup {y|n}] " "\n" "\t[--addtag Tag] " "\n" @@ -690,6 +725,7 @@ xx(vgdisplay, "Display volume group information", + 0, "vgdisplay " "\n" "\t[-c|--colon | -s|--short | -v|--verbose]" "\n" "\t[-d|--debug] " "\n" @@ -725,6 +761,7 @@ xx(vgexport, "Unregister volume group(s) from the system", + 0, "vgexport " "\n" "\t[-a|--all] " "\n" "\t[-d|--debug] " "\n" @@ -737,6 +774,7 @@ xx(vgextend, "Add physical volumes to a volume group", + 0, "vgextend\n" "\t[-A|--autobackup y|n]\n" "\t[-d|--debug]\n" @@ -750,6 +788,7 @@ xx(vgimport, "Register exported volume group with system", + 0, "vgimport " "\n" "\t[-a|--all]\n" "\t[-d|--debug] " "\n" @@ -764,6 +803,7 @@ xx(vgmerge, "Merge volume groups", + 0, "vgmerge\n" "\t[-A|--autobackup y|n]\n" "\t[-d|--debug]\n" @@ -778,6 +818,7 @@ xx(vgmknodes, "Create the special files for volume group devices in /dev", + 0, "vgmknodes\n" "\t[-d|--debug]\n" "\t[-h|--help]\n" @@ -790,6 +831,7 @@ xx(vgreduce, "Remove physical volume(s) from a volume group", + 0, "vgreduce\n" "\t[-a|--all]\n" "\t[-A|--autobackup y|n]\n" @@ -807,6 +849,7 @@ xx(vgremove, "Remove volume group(s)", + 0, "vgremove\n" "\t[-d|--debug]\n" "\t[-f|--force]\n" @@ -820,6 +863,7 @@ xx(vgrename, "Rename a volume group", + 0, "vgrename\n" "\t[-A|--autobackup y|n]\n" "\t[-d|--debug]\n" @@ -834,6 +878,7 @@ xx(vgs, "Display information about volume groups", + 0, "vgs" "\n" "\t[--aligned]\n" "\t[-a|--all]\n" @@ -859,6 +904,7 @@ xx(vgscan, "Search for all volume groups", + 0, "vgscan " "\t[-d|--debug]\n" "\t[-h|--help]\n" @@ -872,6 +918,7 @@ xx(vgsplit, "Move physical volumes into a new or existing volume group", + 0, "vgsplit " "\n" "\t[-A|--autobackup {y|n}] " "\n" "\t[--alloc AllocationPolicy] " "\n" @@ -893,5 +940,6 @@ xx(version, "Display software and driver version information", + 0, "version\n" ) --- LVM2/tools/lvmcmdline.c 2008/01/30 14:00:02 1.61 +++ LVM2/tools/lvmcmdline.c 2008/04/02 21:23:39 1.62 @@ -421,6 +421,7 @@ } static void _create_new_command(const char *name, command_fn command, + unsigned flags, const char *desc, const char *usagestr, int nargs, int *args) { @@ -434,12 +435,13 @@ nc->desc = desc; nc->usage = usagestr; nc->fn = command; + nc->flags = flags; nc->num_args = nargs; nc->valid_args = args; } -static void _register_command(const char *name, command_fn fn, - const char *desc, const char *usagestr, ...) +static void _register_command(const char *name, command_fn fn, const char *desc, + unsigned flags, const char *usagestr, ...) { int nargs = 0, i; int *args; @@ -464,16 +466,16 @@ va_end(ap); /* enter the command in the register */ - _create_new_command(name, fn, desc, usagestr, nargs, args); + _create_new_command(name, fn, flags, desc, usagestr, nargs, args); } void lvm_register_commands(void) { -#define xx(a, b, c...) _register_command(# a, a, b, ## c, \ - driverloaded_ARG, \ - debug_ARG, help_ARG, help2_ARG, \ - version_ARG, verbose_ARG, \ - quiet_ARG, config_ARG, -1); +#define xx(a, b, c, d...) _register_command(# a, a, b, c, ## d, \ + driverloaded_ARG, \ + debug_ARG, help_ARG, help2_ARG, \ + version_ARG, verbose_ARG, \ + quiet_ARG, config_ARG, -1); #include "commands.h" #undef xx } @@ -707,6 +709,7 @@ cmd->current_settings.archive = arg_int_value(cmd, autobackup_ARG, cmd->current_settings.archive); cmd->current_settings.backup = arg_int_value(cmd, autobackup_ARG, cmd->current_settings.backup); + cmd->current_settings.cache_vgmetadata = cmd->command->flags & CACHE_VGMETADATA ? 1 : 0; if (arg_count(cmd, partial_ARG)) { init_partial(1); --- LVM2/tools/tools.h 2008/01/10 18:35:51 1.60 +++ LVM2/tools/tools.h 2008/04/02 21:23:39 1.61 @@ -117,6 +117,8 @@ void *ptr; }; +#define CACHE_VGMETADATA 0x00000001 + /* a register of the lvm commands */ struct command { const char *name; @@ -124,6 +126,8 @@ const char *usage; command_fn fn; + unsigned flags; + int num_args; int *valid_args; }; From agk@sourceware.org Wed Apr 2 21:31:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 02 Apr 2008 21:31:00 -0000 Subject: LVM2/lib/commands toolcontext.c Message-ID: <20080402213114.24318.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-02 21:31:14 Modified files: lib/commands : toolcontext.c Log message: enable vg metadata cache by default Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.57&r2=1.58 --- LVM2/lib/commands/toolcontext.c 2008/01/30 13:59:58 1.57 +++ LVM2/lib/commands/toolcontext.c 2008/04/02 21:31:14 1.58 @@ -987,6 +987,7 @@ if (!_init_backup(cmd)) goto error; + cmd->default_settings.cache_vgmetadata = 1; cmd->current_settings = cmd->default_settings; cmd->config_valid = 1; From agk@sourceware.org Thu Apr 3 10:29:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 03 Apr 2008 10:29:00 -0000 Subject: LVM2 ./WHATS_NEW lib/filters/filter.c Message-ID: <20080403102901.2986.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-03 10:29:00 Modified files: . : WHATS_NEW lib/filters : filter.c Log message: fix vd->virtblk Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.818&r2=1.819 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/filters/filter.c.diff?cvsroot=lvm2&r1=1.45&r2=1.46 --- LVM2/WHATS_NEW 2008/04/02 21:23:38 1.818 +++ LVM2/WHATS_NEW 2008/04/03 10:29:00 1.819 @@ -22,7 +22,7 @@ Use return_0 in a couple more places. Correct a function name typo in _line_append error message. Include limits.h in clvmd so it compiles with newer headers. - Add VirtIO disks (vd) to filters. + Add VirtIO disks (virtblk) to filters. Fix resetting of MIRROR_IMAGE and VISIBLE_LV after removal of LV. (2.02.30) Fix remove_layer_from_lv to empty the LV before removing it. (2.02.30) Add missing no-longer-used segs_using_this_lv test to check_lv_segments. --- LVM2/lib/filters/filter.c 2008/03/05 18:15:04 1.45 +++ LVM2/lib/filters/filter.c 2008/04/03 10:29:00 1.46 @@ -77,7 +77,7 @@ {"xvd", 16}, /* Xen virtual block device */ {"vdisk", 8}, /* SUN's LDOM virtual block device */ {"ps3disk", 16}, /* PlayStation 3 internal disk */ - {"vd", 8}, /* VirtIO disk */ + {"virtblk", 8}, /* VirtIO disk */ {NULL, 0} }; From agk@sourceware.org Thu Apr 3 14:32:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 03 Apr 2008 14:32:00 -0000 Subject: LVM2 WHATS_NEW Message-ID: <20080403143232.4203.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-03 14:32:31 Modified files: . : WHATS_NEW Log message: . Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.819&r2=1.820 --- LVM2/WHATS_NEW 2008/04/03 10:29:00 1.819 +++ LVM2/WHATS_NEW 2008/04/03 14:32:31 1.820 @@ -1,7 +1,7 @@ Version 2.02.34 - =================================== Add per-command flags to control which commands use the VG metadata cache. - Fix vgsplit locking, remove unneeded error messages when split into new VG. + Fix vgsplit locking of new VG and avoid erroneous error message. (2.02.29) Suppress duplicate message when lvresize fails because of invalid vgname. Cache VG metadata internally while VG lock is held. Fix redundant lvresize message if vg doesn't exist. From agk@sourceware.org Thu Apr 3 14:40:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 03 Apr 2008 14:40:00 -0000 Subject: LVM2 WHATS_NEW Message-ID: <20080403144035.7586.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-03 14:40:34 Modified files: . : WHATS_NEW Log message: . Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.820&r2=1.821 --- LVM2/WHATS_NEW 2008/04/03 14:32:31 1.820 +++ LVM2/WHATS_NEW 2008/04/03 14:40:34 1.821 @@ -1,7 +1,8 @@ Version 2.02.34 - =================================== Add per-command flags to control which commands use the VG metadata cache. - Fix vgsplit locking of new VG and avoid erroneous error message. (2.02.29) + Fix vgsplit locking of new VG (2.02.30). + Avoid erroneous vgsplit error message for new VG. (2.02.29) Suppress duplicate message when lvresize fails because of invalid vgname. Cache VG metadata internally while VG lock is held. Fix redundant lvresize message if vg doesn't exist. From agk@sourceware.org Thu Apr 3 18:56:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 03 Apr 2008 18:56:00 -0000 Subject: LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/lock ... Message-ID: <20080403185641.3595.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-03 18:56:40 Modified files: . : WHATS_NEW lib/cache : lvmcache.c lib/locking : file_locking.c Log message: Add some basic internal VG lock validation. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.821&r2=1.822 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.41&r2=1.42 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/file_locking.c.diff?cvsroot=lvm2&r1=1.34&r2=1.35 --- LVM2/WHATS_NEW 2008/04/03 14:40:34 1.821 +++ LVM2/WHATS_NEW 2008/04/03 18:56:39 1.822 @@ -1,5 +1,6 @@ Version 2.02.34 - =================================== + Add some basic internal VG lock validation. Add per-command flags to control which commands use the VG metadata cache. Fix vgsplit locking of new VG (2.02.30). Avoid erroneous vgsplit error message for new VG. (2.02.29) --- LVM2/lib/cache/lvmcache.c 2008/04/02 21:23:39 1.41 +++ LVM2/lib/cache/lvmcache.c 2008/04/03 18:56:40 1.42 @@ -17,6 +17,7 @@ #include "lvmcache.h" #include "toolcontext.h" #include "dev-cache.h" +#include "locking.h" #include "metadata.h" #include "filter.h" #include "memlock.h" @@ -29,6 +30,7 @@ static struct list _vginfos; static int _has_scanned = 0; static int _vgs_locked = 0; +static int _vg_global_lock_held = 0; /* Global lock held when cache wiped? */ int lvmcache_init(void) { @@ -46,6 +48,9 @@ if (!(_lock_hash = dm_hash_create(128))) return 0; + if (_vg_global_lock_held) + lvmcache_lock_vgname(VG_GLOBAL, 0); + return 1; } @@ -134,6 +139,10 @@ return; } + if (dm_hash_lookup(_lock_hash, vgname)) + log_error("Internal error: Nested locking attempted on VG %s.", + vgname); + if (!dm_hash_insert(_lock_hash, vgname, (void *) 1)) log_error("Cache locking failure for %s", vgname); @@ -152,6 +161,10 @@ void lvmcache_unlock_vgname(const char *vgname) { + if (!dm_hash_lookup(_lock_hash, vgname)) + log_error("Internal error: Attempt to unlock unlocked VG %s.", + vgname); + _update_cache_lock_state(vgname, 0); dm_hash_remove(_lock_hash, vgname); @@ -1007,13 +1020,25 @@ } while ((vginfo = next)); } -static void _lvmcache_destroy_lockname(int present __attribute((unused))) +static void _lvmcache_destroy_lockname(struct dm_hash_node *n) { - /* Nothing to do */ + char *vgname; + + if (!dm_hash_get_data(_lock_hash, n)) + return; + + vgname = dm_hash_get_key(_lock_hash, n); + + if (!strcmp(vgname, VG_GLOBAL)) + _vg_global_lock_held = 1; + else + log_error("Internal error: Volume Group %s was not unlocked", + dm_hash_get_key(_lock_hash, n)); } void lvmcache_destroy(void) { + struct dm_hash_node *n; log_verbose("Wiping internal VG cache"); _has_scanned = 0; @@ -1037,7 +1062,8 @@ } if (_lock_hash) { - dm_hash_iter(_lock_hash, (dm_hash_iterate_fn) _lvmcache_destroy_lockname); + dm_hash_iterate(n, _lock_hash) + _lvmcache_destroy_lockname(n); dm_hash_destroy(_lock_hash); _lock_hash = NULL; } --- LVM2/lib/locking/file_locking.c 2008/01/30 13:59:59 1.34 +++ LVM2/lib/locking/file_locking.c 2008/04/03 18:56:40 1.35 @@ -221,7 +221,7 @@ "%s/V_%s", _lock_dir, resource); if (!_lock_file(lockfile, flags)) - return 0; + return_0; switch (flags & LCK_TYPE_MASK) { case LCK_UNLOCK: From ccaulfield@sourceware.org Fri Apr 4 08:53:00 2008 From: ccaulfield@sourceware.org (ccaulfield@sourceware.org) Date: Fri, 04 Apr 2008 08:53:00 -0000 Subject: LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c Message-ID: <20080404085347.11783.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: ccaulfield@sourceware.org 2008-04-04 08:53:47 Modified files: . : WHATS_NEW daemons/clvmd : lvm-functions.c Log message: If lvm.conf was touched, clvmd attempted to update the toolcontext but only did half of the job. It now shares the do_refresh_cache() function that vgscan invokes. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.822&r2=1.823 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.37&r2=1.38 --- LVM2/WHATS_NEW 2008/04/03 18:56:39 1.822 +++ LVM2/WHATS_NEW 2008/04/04 08:53:46 1.823 @@ -1,5 +1,6 @@ Version 2.02.34 - =================================== + Make clvmd refresh the context correctly when lvm.conf is updated. Add some basic internal VG lock validation. Add per-command flags to control which commands use the VG metadata cache. Fix vgsplit locking of new VG (2.02.30). --- LVM2/daemons/clvmd/lvm-functions.c 2007/12/05 13:17:18 1.37 +++ LVM2/daemons/clvmd/lvm-functions.c 2008/04/04 08:53:47 1.38 @@ -1,6 +1,6 @@ /* * Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -318,7 +318,7 @@ pthread_mutex_lock(&lvm_lock); if (!cmd->config_valid || config_files_changed(cmd)) { /* Reinitialise various settings inc. logging, filters */ - if (!refresh_toolcontext(cmd)) { + if (do_refresh_cache()) { log_error("Updated config file invalid. Aborting."); pthread_mutex_unlock(&lvm_lock); return EINVAL; @@ -437,7 +437,7 @@ return 0; } -/* Check if a VG is un use by LVM1 so we don't stomp on it */ +/* Check if a VG is in use by LVM1 so we don't stomp on it */ int do_check_lvm1(const char *vgname) { int status; From mbroz@sourceware.org Fri Apr 4 11:59:00 2008 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Fri, 04 Apr 2008 11:59:00 -0000 Subject: LVM2 ./WHATS_NEW test/t-pv-range-overflow.sh t ... Message-ID: <20080404115933.31080.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2008-04-04 11:59:32 Modified files: . : WHATS_NEW test : t-pv-range-overflow.sh tools : pvmove.c Log message: Add validation of LV name to pvmove -n. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.823&r2=1.824 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-pv-range-overflow.sh.diff?cvsroot=lvm2&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvmove.c.diff?cvsroot=lvm2&r1=1.48&r2=1.49 --- LVM2/WHATS_NEW 2008/04/04 08:53:46 1.823 +++ LVM2/WHATS_NEW 2008/04/04 11:59:29 1.824 @@ -1,5 +1,6 @@ Version 2.02.34 - =================================== + Add validation of LV name to pvmove -n. Make clvmd refresh the context correctly when lvm.conf is updated. Add some basic internal VG lock validation. Add per-command flags to control which commands use the VG metadata cache. --- LVM2/test/t-pv-range-overflow.sh 2007/09/24 19:19:18 1.2 +++ LVM2/test/t-pv-range-overflow.sh 2008/04/04 11:59:30 1.3 @@ -37,14 +37,13 @@ lvcreate -L4 -n"$lv" "$vg"' # Test for the bogus diagnostic reported in BZ 284771 -# http://bugzilla.redhat.com/284771. Once the BZ is fixed, -# update the code below to expect an improved diagnostic. +# http://bugzilla.redhat.com/284771. test_expect_success \ 'run pvmove with an unrecognized LV name to show bad diagnostic' \ 'pvmove -v -nbogus $d1 $d2 2> err test $? = 5 && tail -n1 err > out && - echo " No data to move for $vg" > expected && + echo " Logical volume bogus not found." > expected && diff -u out expected' # With lvm-2.02.28 and earlier, on a system with 64-bit "long int", --- LVM2/tools/pvmove.c 2008/01/30 14:00:02 1.48 +++ LVM2/tools/pvmove.c 2008/04/04 11:59:31 1.49 @@ -147,6 +147,7 @@ struct logical_volume *lv_mirr, *lv; struct lv_list *lvl; uint32_t log_count = 0; + int lv_found = 0; /* FIXME Cope with non-contiguous => splitting existing segments */ if (!(lv_mirr = lv_create_empty("pvmove%d", NULL, @@ -168,9 +169,13 @@ /* Find segments to be moved and set up mirrors */ list_iterate_items(lvl, &vg->lvs) { lv = lvl->lv; - if ((lv == lv_mirr) || - (lv_name && strcmp(lv->name, lv_name))) + if ((lv == lv_mirr)) continue; + if (lv_name) { + if (strcmp(lv->name, lv_name)) + continue; + lv_found = 1; + } if (lv_is_origin(lv) || lv_is_cow(lv)) { log_print("Skipping snapshot-related LV %s", lv->name); continue; @@ -196,6 +201,11 @@ return_NULL; } + if (lv_name && !lv_found) { + log_error("Logical volume %s not found.", lv_name); + return NULL; + } + /* Is temporary mirror empty? */ if (!lv_mirr->le_count) { log_error("No data to move for %s", vg->name); @@ -310,6 +320,11 @@ stack; return EINVALID_CMD_LINE; } + + if (!validate_name(lv_name)) { + log_error("Logical volume name %s is invalid", lv_name); + return EINVALID_CMD_LINE; + } } /* Read VG */ From wysochanski@sourceware.org Fri Apr 4 15:41:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Fri, 04 Apr 2008 15:41:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/metadata.c Message-ID: <20080404154121.25753.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-04 15:41:20 Modified files: . : WHATS_NEW lib/metadata : metadata.c Log message: Add check to vg_commit() to ensure lock is held before writing new VG metadata. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.824&r2=1.825 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.164&r2=1.165 --- LVM2/WHATS_NEW 2008/04/04 11:59:29 1.824 +++ LVM2/WHATS_NEW 2008/04/04 15:41:20 1.825 @@ -1,5 +1,6 @@ Version 2.02.34 - =================================== + Add check to vg_commit() ensuring VG lock held before writing new VG metadata. Add validation of LV name to pvmove -n. Make clvmd refresh the context correctly when lvm.conf is updated. Add some basic internal VG lock validation. --- LVM2/lib/metadata/metadata.c 2008/04/01 22:40:12 1.164 +++ LVM2/lib/metadata/metadata.c 2008/04/04 15:41:20 1.165 @@ -1316,6 +1316,12 @@ int cache_updated = 0; int failed = 0; + if (!vgname_is_locked(vg->name)) { + log_error("Internal error: Attempt to write new VG metadata " + "without locking %s", vg->name); + return cache_updated; + } + /* Commit to each copy of the metadata area */ list_iterate_items(mda, &vg->fid->metadata_areas) { failed = 0; From mbroz@sourceware.org Mon Apr 7 10:23:00 2008 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Mon, 07 Apr 2008 10:23:00 -0000 Subject: LVM2 ./WHATS_NEW lib/activate/activate.c lib/a ... Message-ID: <20080407102349.18643.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2008-04-07 10:23:47 Modified files: . : WHATS_NEW lib/activate : activate.c activate.h dev_manager.c lib/error : errseg.c lib/metadata : mirror.c segtype.h lib/mirror : mirrored.c lib/snapshot : snapshot.c lib/striped : striped.c lib/zero : zero.c tools : lvconvert.c lvcreate.c pvmove.c Log message: Add detection of clustered mirror log capability. Currently only check for kernel module presence. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.825&r2=1.826 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.133&r2=1.134 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.59&r2=1.60 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.134&r2=1.135 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/error/errseg.c.diff?cvsroot=lvm2&r1=1.16&r2=1.17 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/mirror.c.diff?cvsroot=lvm2&r1=1.70&r2=1.71 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/segtype.h.diff?cvsroot=lvm2&r1=1.18&r2=1.19 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.52&r2=1.53 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/snapshot/snapshot.c.diff?cvsroot=lvm2&r1=1.29&r2=1.30 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/striped/striped.c.diff?cvsroot=lvm2&r1=1.24&r2=1.25 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/zero/zero.c.diff?cvsroot=lvm2&r1=1.16&r2=1.17 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.61&r2=1.62 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.172&r2=1.173 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvmove.c.diff?cvsroot=lvm2&r1=1.49&r2=1.50 --- LVM2/WHATS_NEW 2008/04/04 15:41:20 1.825 +++ LVM2/WHATS_NEW 2008/04/07 10:23:46 1.826 @@ -1,5 +1,6 @@ Version 2.02.34 - =================================== + Add detection of clustered mirror log capability. Add check to vg_commit() ensuring VG lock held before writing new VG metadata. Add validation of LV name to pvmove -n. Make clvmd refresh the context correctly when lvm.conf is updated. --- LVM2/lib/activate/activate.c 2008/01/31 12:19:35 1.133 +++ LVM2/lib/activate/activate.c 2008/04/07 10:23:46 1.134 @@ -391,12 +391,26 @@ return r; } -int target_present(const char *target_name, int use_modprobe) +int module_present(const char *target_name) { - uint32_t maj, min, patchlevel; + int ret = 0; #ifdef MODPROBE_CMD char module[128]; + + if (dm_snprintf(module, sizeof(module), "dm-%s", target_name) < 0) { + log_error("module_present module name too long: %s", + target_name); + return 0; + } + + ret = exec_cmd(MODPROBE_CMD, module, "", ""); #endif + return ret; +} + +int target_present(const char *target_name, int use_modprobe) +{ + uint32_t maj, min, patchlevel; if (!activation()) return 0; @@ -406,14 +420,7 @@ if (target_version(target_name, &maj, &min, &patchlevel)) return 1; - if (dm_snprintf(module, sizeof(module), "dm-%s", target_name) - < 0) { - log_error("target_present module name too long: %s", - target_name); - return 0; - } - - if (!exec_cmd(MODPROBE_CMD, module, "", "")) + if (!module_present(target_name)) return_0; } #endif --- LVM2/lib/activate/activate.h 2007/11/12 20:51:53 1.59 +++ LVM2/lib/activate/activate.h 2008/04/07 10:23:46 1.60 @@ -30,6 +30,9 @@ uint32_t read_ahead; }; +/* target attribute flags */ +#define MIRROR_LOG_CLUSTERED 0x00000001U + void set_activation(int activation); int activation(void); @@ -37,6 +40,7 @@ int library_version(char *version, size_t size); int lvm1_present(struct cmd_context *cmd); +int module_present(const char *target_name); int target_present(const char *target_name, int use_modprobe); int target_version(const char *target_name, uint32_t *maj, uint32_t *min, uint32_t *patchlevel); --- LVM2/lib/activate/dev_manager.c 2008/01/30 13:59:57 1.134 +++ LVM2/lib/activate/dev_manager.c 2008/04/07 10:23:46 1.135 @@ -823,7 +823,7 @@ layer ? "-" : "", layer ? : ""); if (seg_present->segtype->ops->target_present && - !seg_present->segtype->ops->target_present(seg_present)) { + !seg_present->segtype->ops->target_present(seg_present, NULL)) { log_error("Can't expand LV %s: %s target support missing " "from kernel?", seg->lv->name, seg_present->segtype->name); return 0; --- LVM2/lib/error/errseg.c 2008/01/30 13:59:58 1.16 +++ LVM2/lib/error/errseg.c 2008/04/07 10:23:46 1.17 @@ -51,7 +51,8 @@ return dm_tree_node_add_error_target(node, len); } -static int _errseg_target_present(const struct lv_segment *seg __attribute((unused))) +static int _errseg_target_present(const struct lv_segment *seg __attribute((unused)), + unsigned *attributes __attribute((unused))) { static int _errseg_checked = 0; static int _errseg_present = 0; --- LVM2/lib/metadata/mirror.c 2008/02/22 13:28:29 1.70 +++ LVM2/lib/metadata/mirror.c 2008/04/07 10:23:46 1.71 @@ -1300,7 +1300,7 @@ return_0; if (activation() && segtype->ops->target_present && - !segtype->ops->target_present(NULL)) { + !segtype->ops->target_present(NULL, NULL)) { log_error("%s: Required device-mapper target(s) not " "detected in your kernel", segtype->name); return 0; --- LVM2/lib/metadata/segtype.h 2007/08/20 20:55:26 1.18 +++ LVM2/lib/metadata/segtype.h 2008/04/07 10:23:46 1.19 @@ -78,7 +78,8 @@ struct lv_segment *seg, char *params, uint64_t *total_numerator, uint64_t *total_denominator, float *percent); - int (*target_present) (const struct lv_segment *seg); + int (*target_present) (const struct lv_segment *seg, + unsigned *attributes); int (*modules_needed) (struct dm_pool *mem, const struct lv_segment *seg, struct list *modules); --- LVM2/lib/mirror/mirrored.c 2008/01/31 12:19:35 1.52 +++ LVM2/lib/mirror/mirrored.c 2008/04/07 10:23:46 1.53 @@ -33,6 +33,7 @@ #endif static int _block_on_error_available = 0; +static unsigned _mirror_attributes = 0; enum { MIRR_DISABLED, @@ -343,7 +344,8 @@ return add_areas_line(dm, seg, node, start_area, area_count); } -static int _mirrored_target_present(const struct lv_segment *seg __attribute((unused))) +static int _mirrored_target_present(const struct lv_segment *seg __attribute((unused)), + unsigned *attributes) { static int _mirrored_checked = 0; static int _mirrored_present = 0; @@ -369,6 +371,15 @@ _block_on_error_available = 1; } + /* + * Check only for modules if atttributes requested and no previous check. + * FIXME: need better check + */ + if (attributes) { + if (!_mirror_attributes && module_present("cmirror")) + _mirror_attributes |= MIRROR_LOG_CLUSTERED; + *attributes = _mirror_attributes; + } _mirrored_checked = 1; return _mirrored_present; --- LVM2/lib/snapshot/snapshot.c 2008/01/31 12:19:36 1.29 +++ LVM2/lib/snapshot/snapshot.c 2008/04/07 10:23:47 1.30 @@ -114,7 +114,8 @@ return 1; } -static int _snap_target_present(const struct lv_segment *seg __attribute((unused))) +static int _snap_target_present(const struct lv_segment *seg __attribute((unused)), + unsigned *attributes __attribute((unused))) { static int _snap_checked = 0; static int _snap_present = 0; --- LVM2/lib/striped/striped.c 2008/01/30 14:00:01 1.24 +++ LVM2/lib/striped/striped.c 2008/04/07 10:23:47 1.25 @@ -175,7 +175,8 @@ return add_areas_line(dm, seg, node, 0u, seg->area_count); } -static int _striped_target_present(const struct lv_segment *seg __attribute((unused))) +static int _striped_target_present(const struct lv_segment *seg __attribute((unused)), + unsigned *attributes __attribute((unused))) { static int _striped_checked = 0; static int _striped_present = 0; --- LVM2/lib/zero/zero.c 2008/01/30 14:00:01 1.16 +++ LVM2/lib/zero/zero.c 2008/04/07 10:23:47 1.17 @@ -50,7 +50,8 @@ return dm_tree_node_add_zero_target(node, len); } -static int _zero_target_present(const struct lv_segment *seg __attribute((unused))) +static int _zero_target_present(const struct lv_segment *seg __attribute((unused)), + unsigned *attributes __attribute((unused))) { static int _zero_checked = 0; static int _zero_present = 0; --- LVM2/tools/lvconvert.c 2008/02/12 13:29:08 1.61 +++ LVM2/tools/lvconvert.c 2008/04/07 10:23:47 1.62 @@ -219,7 +219,7 @@ } if (activation() && lp->segtype->ops->target_present && - !lp->segtype->ops->target_present(NULL)) { + !lp->segtype->ops->target_present(NULL, NULL)) { log_error("%s: Required device-mapper target(s) not " "detected in your kernel", lp->segtype->name); return 0; --- LVM2/tools/lvcreate.c 2008/01/30 14:00:01 1.172 +++ LVM2/tools/lvcreate.c 2008/04/07 10:23:47 1.173 @@ -420,7 +420,7 @@ } if (activation() && lp->segtype->ops->target_present && - !lp->segtype->ops->target_present(NULL)) { + !lp->segtype->ops->target_present(NULL, NULL)) { log_error("%s: Required device-mapper target(s) not " "detected in your kernel", lp->segtype->name); return 0; --- LVM2/tools/pvmove.c 2008/04/04 11:59:31 1.49 +++ LVM2/tools/pvmove.c 2008/04/07 10:23:47 1.50 @@ -17,6 +17,30 @@ #include "polldaemon.h" #include "display.h" +static int pvmove_target_present(struct cmd_context *cmd, int clustered) +{ + const struct segment_type *segtype; + unsigned attr = 0; + + if (!(segtype = get_segtype_from_string(cmd, "mirror"))) + return_0; + + if (activation() && segtype->ops->target_present && + !segtype->ops->target_present(NULL, clustered ? &attr : NULL)) { + log_error("%s: Required device-mapper target(s) not " + "detected in your kernel", segtype->name); + return 0; + } + + if (clustered && !(attr & MIRROR_LOG_CLUSTERED)) { + log_error("%s: Required device-mapper clustered log " + "module not detected in your kernel", segtype->name); + return 0; + } + + return 1; +} + /* Allow /dev/vgname/lvname, vgname/lvname or lvname */ static const char *_extract_lvname(struct cmd_context *cmd, const char *vgname, const char *arg) @@ -540,17 +564,9 @@ char *pv_name = NULL; char *colon; int ret; - const struct segment_type *segtype; - if (!(segtype = get_segtype_from_string(cmd, "mirror"))) - return_0; - - if (activation() && segtype->ops->target_present && - !segtype->ops->target_present(NULL)) { - log_error("%s: Required device-mapper target(s) not " - "detected in your kernel", segtype->name); + if (!pvmove_target_present(cmd, 0)) return 0; - } if (argc) { pv_name = argv[0]; From mbroz@sourceware.org Mon Apr 7 13:53:00 2008 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Mon, 07 Apr 2008 13:53:00 -0000 Subject: LVM2 ./WHATS_NEW lib/log/log.c Message-ID: <20080407135327.16949.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2008-04-07 13:53:27 Modified files: . : WHATS_NEW lib/log : log.c Log message: Fix output if overriding command_names on cmdline. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.826&r2=1.827 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/log/log.c.diff?cvsroot=lvm2&r1=1.42&r2=1.43 --- LVM2/WHATS_NEW 2008/04/07 10:23:46 1.826 +++ LVM2/WHATS_NEW 2008/04/07 13:53:26 1.827 @@ -1,5 +1,6 @@ Version 2.02.34 - =================================== + Fix output if overriding command_names on cmdline. Add detection of clustered mirror log capability. Add check to vg_commit() ensuring VG lock held before writing new VG metadata. Add validation of LV name to pvmove -n. --- LVM2/lib/log/log.c 2008/01/30 13:59:59 1.42 +++ LVM2/lib/log/log.c 2008/04/07 13:53:26 1.43 @@ -215,12 +215,18 @@ void set_cmd_name(const char *cmd) { - if (!_log_cmd_name) - return; strncpy(_cmd_name, cmd, sizeof(_cmd_name)); _cmd_name[sizeof(_cmd_name) - 1] = '\0'; } +static const char *_command_name() +{ + if (!_log_cmd_name) + return ""; + + return _cmd_name; +} + void init_msg_prefix(const char *prefix) { strncpy(_msg_prefix, prefix, sizeof(_msg_prefix)); @@ -352,7 +358,7 @@ _verbose_level <= _LOG_DEBUG) break; if (_verbose_level >= _LOG_DEBUG) { - fprintf(stderr, "%s%s%s", locn, _cmd_name, + fprintf(stderr, "%s%s%s", locn, _command_name(), _msg_prefix); if (_indent) fprintf(stderr, " "); @@ -363,7 +369,7 @@ case _LOG_INFO: if (_verbose_level >= _LOG_INFO) { - fprintf(stderr, "%s%s%s", locn, _cmd_name, + fprintf(stderr, "%s%s%s", locn, _command_name(), _msg_prefix); if (_indent) fprintf(stderr, " "); @@ -373,7 +379,7 @@ break; case _LOG_NOTICE: if (_verbose_level >= _LOG_NOTICE) { - fprintf(stderr, "%s%s%s", locn, _cmd_name, + fprintf(stderr, "%s%s%s", locn, _command_name(), _msg_prefix); if (_indent) fprintf(stderr, " "); @@ -383,14 +389,15 @@ break; case _LOG_WARN: if (_verbose_level >= _LOG_WARN) { - fprintf(use_stderr ? stderr : stdout, "%s%s", _cmd_name, _msg_prefix); + fprintf(use_stderr ? stderr : stdout, "%s%s", + _command_name(), _msg_prefix); vfprintf(use_stderr ? stderr : stdout, trformat, ap); fputc('\n', use_stderr ? stderr : stdout); } break; case _LOG_ERR: if (_verbose_level >= _LOG_ERR) { - fprintf(stderr, "%s%s%s", locn, _cmd_name, + fprintf(stderr, "%s%s%s", locn, _command_name(), _msg_prefix); vfprintf(stderr, trformat, ap); fputc('\n', stderr); @@ -399,7 +406,7 @@ case _LOG_FATAL: default: if (_verbose_level >= _LOG_FATAL) { - fprintf(stderr, "%s%s%s", locn, _cmd_name, + fprintf(stderr, "%s%s%s", locn, _command_name(), _msg_prefix); vfprintf(stderr, trformat, ap); fputc('\n', stderr); @@ -413,7 +420,7 @@ return; if (_log_to_file && (_log_while_suspended || !memlock())) { - fprintf(_log_file, "%s:%d %s%s", file, line, _cmd_name, + fprintf(_log_file, "%s:%d %s%s", file, line, _command_name(), _msg_prefix); va_start(ap, format); @@ -436,7 +443,7 @@ memset(&buf, ' ', sizeof(buf)); bufused = 0; if ((n = dm_snprintf(buf, sizeof(buf) - bufused - 1, - "%s:%d %s%s", file, line, _cmd_name, + "%s:%d %s%s", file, line, _command_name(), _msg_prefix)) == -1) goto done; From mbroz@sourceware.org Mon Apr 7 19:17:00 2008 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Mon, 07 Apr 2008 19:17:00 -0000 Subject: LVM2 ./WHATS_NEW lib/locking/file_locking.c li ... Message-ID: <20080407191731.27733.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2008-04-07 19:17:30 Modified files: . : WHATS_NEW lib/locking : file_locking.c locking.c no_locking.c Log message: Update lvmcache VG lock state for all locking types now. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.827&r2=1.828 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/file_locking.c.diff?cvsroot=lvm2&r1=1.35&r2=1.36 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.44&r2=1.45 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/no_locking.c.diff?cvsroot=lvm2&r1=1.14&r2=1.15 --- LVM2/WHATS_NEW 2008/04/07 13:53:26 1.827 +++ LVM2/WHATS_NEW 2008/04/07 19:17:29 1.828 @@ -1,5 +1,6 @@ Version 2.02.34 - =================================== + Update lvmcache VG lock state for all locking types now. Fix output if overriding command_names on cmdline. Add detection of clustered mirror log capability. Add check to vg_commit() ensuring VG lock held before writing new VG metadata. --- LVM2/lib/locking/file_locking.c 2008/04/03 18:56:40 1.35 +++ LVM2/lib/locking/file_locking.c 2008/04/07 19:17:29 1.36 @@ -21,7 +21,6 @@ #include "defaults.h" #include "lvm-file.h" #include "lvm-string.h" -#include "lvmcache.h" #include #include @@ -222,16 +221,6 @@ if (!_lock_file(lockfile, flags)) return_0; - - switch (flags & LCK_TYPE_MASK) { - case LCK_UNLOCK: - lvmcache_unlock_vgname(resource); - break; - default: - lvmcache_lock_vgname(resource, - (flags & LCK_TYPE_MASK) == - LCK_READ); - } break; case LCK_LV: switch (flags & LCK_TYPE_MASK) { --- LVM2/lib/locking/locking.c 2008/01/30 13:59:59 1.44 +++ LVM2/lib/locking/locking.c 2008/04/07 19:17:29 1.45 @@ -21,6 +21,7 @@ #include "toolcontext.h" #include "memlock.h" #include "defaults.h" +#include "lvmcache.h" #include #include @@ -315,22 +316,29 @@ */ static int _lock_vol(struct cmd_context *cmd, const char *resource, uint32_t flags) { + int ret = 0; + _block_signals(flags); _lock_memory(flags); assert(resource); - if (!(_locking.lock_resource(cmd, resource, flags))) { - _unlock_memory(flags); - _unblock_signals(); - return 0; + if ((ret = _locking.lock_resource(cmd, resource, flags))) { + if ((flags & LCK_SCOPE_MASK) == LCK_VG) { + if ((flags & LCK_TYPE_MASK) == LCK_UNLOCK) + lvmcache_unlock_vgname(resource); + else + lvmcache_lock_vgname(resource, (flags & LCK_TYPE_MASK) + == LCK_READ); + } + + _update_vg_lock_count(flags); } - _update_vg_lock_count(flags); _unlock_memory(flags); _unblock_signals(); - return 1; + return ret; } int lock_vol(struct cmd_context *cmd, const char *vol, uint32_t flags) --- LVM2/lib/locking/no_locking.c 2008/01/30 13:59:59 1.14 +++ LVM2/lib/locking/no_locking.c 2008/04/07 19:17:29 1.15 @@ -18,7 +18,6 @@ #include "locking_types.h" #include "lvm-string.h" #include "activate.h" -#include "lvmcache.h" #include @@ -41,15 +40,6 @@ { switch (flags & LCK_SCOPE_MASK) { case LCK_VG: - switch (flags & LCK_TYPE_MASK) { - case LCK_UNLOCK: - lvmcache_unlock_vgname(resource); - break; - default: - lvmcache_lock_vgname(resource, - (flags & LCK_TYPE_MASK) == - LCK_READ); - } break; case LCK_LV: switch (flags & LCK_TYPE_MASK) { From agk@sourceware.org Mon Apr 7 22:12:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Mon, 07 Apr 2008 22:12:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/metadata.c Message-ID: <20080407221238.30851.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-07 22:12:37 Modified files: . : WHATS_NEW lib/metadata : metadata.c Log message: create fids for internal orphan VGs Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.828&r2=1.829 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.165&r2=1.166 --- LVM2/WHATS_NEW 2008/04/07 19:17:29 1.828 +++ LVM2/WHATS_NEW 2008/04/07 22:12:35 1.829 @@ -1,5 +1,6 @@ Version 2.02.34 - =================================== + Create a fid for internal orphan VGs. Update lvmcache VG lock state for all locking types now. Fix output if overriding command_names on cmdline. Add detection of clustered mirror log capability. --- LVM2/lib/metadata/metadata.c 2008/04/04 15:41:20 1.165 +++ LVM2/lib/metadata/metadata.c 2008/04/07 22:12:37 1.166 @@ -1382,6 +1382,15 @@ return NULL; } + /* create format instance with appropriate metadata area */ + if (!(vg->fid = vginfo->fmt->ops->create_instance(vginfo->fmt, + orphan_vgname, NULL, + NULL))) { + log_error("Failed to create format instance"); + dm_pool_free(cmd->mem, vg); + return NULL; + } + list_iterate_items(info, &vginfo->infos) { if (!(pv = _pv_read(cmd, dev_name(info->dev), NULL, NULL, 1))) { continue; From agk@sourceware.org Tue Apr 8 12:49:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 08 Apr 2008 12:49:00 -0000 Subject: LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ... Message-ID: <20080408124923.25754.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-08 12:49:21 Modified files: . : WHATS_NEW lib/cache : lvmcache.c lvmcache.h lib/commands : toolcontext.c toolcontext.h lib/format_pool: format_pool.c format_pool.h lib/metadata : metadata.c tools : lvmcmdline.c pvcreate.c pvscan.c vgreduce.c vgrename.c vgscan.c Log message: Fix vgreduce to use vg_split_mdas to check sufficient mdas remain. Add (empty) orphan VGs to lvmcache during initialisation. Fix orphan VG name used for format_pool. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.829&r2=1.830 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.42&r2=1.43 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.19&r2=1.20 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.58&r2=1.59 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.h.diff?cvsroot=lvm2&r1=1.22&r2=1.23 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/format_pool.c.diff?cvsroot=lvm2&r1=1.14&r2=1.15 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format_pool/format_pool.h.diff?cvsroot=lvm2&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.166&r2=1.167 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.62&r2=1.63 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvcreate.c.diff?cvsroot=lvm2&r1=1.61&r2=1.62 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvscan.c.diff?cvsroot=lvm2&r1=1.45&r2=1.46 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgreduce.c.diff?cvsroot=lvm2&r1=1.79&r2=1.80 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgrename.c.diff?cvsroot=lvm2&r1=1.50&r2=1.51 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgscan.c.diff?cvsroot=lvm2&r1=1.29&r2=1.30 --- LVM2/WHATS_NEW 2008/04/07 22:12:35 1.829 +++ LVM2/WHATS_NEW 2008/04/08 12:49:20 1.830 @@ -1,5 +1,8 @@ Version 2.02.34 - =================================== + Fix vgreduce to use vg_split_mdas to check sufficient mdas remain. + Add (empty) orphan VGs to lvmcache during initialisation. + Fix orphan VG name used for format_pool. Create a fid for internal orphan VGs. Update lvmcache VG lock state for all locking types now. Fix output if overriding command_names on cmdline. --- LVM2/lib/cache/lvmcache.c 2008/04/03 18:56:40 1.42 +++ LVM2/lib/cache/lvmcache.c 2008/04/08 12:49:20 1.43 @@ -536,34 +536,38 @@ return NULL; } -static int _drop_vginfo(struct lvmcache_info *info) +/* + * vginfo must be info->vginfo unless info is NULL + */ +static int _drop_vginfo(struct lvmcache_info *info, struct lvmcache_vginfo *vginfo) { - if (!list_empty(&info->list)) { + if (info && !list_empty(&info->list)) { list_del(&info->list); list_init(&info->list); } - if (info->vginfo && list_empty(&info->vginfo->infos)) { - dm_hash_remove(_vgname_hash, info->vginfo->vgname); - if (info->vginfo->next) { - if (!dm_hash_insert(_vgname_hash, info->vginfo->vgname, info->vginfo->next)) { + if (vginfo && !is_orphan_vg(vginfo->vgname) && list_empty(&vginfo->infos)) { + dm_hash_remove(_vgname_hash, vginfo->vgname); + if (vginfo->next) { + if (!dm_hash_insert(_vgname_hash, vginfo->vgname, vginfo->next)) { log_error("vg hash re-insertion failed: %s", - info->vginfo->vgname); + vginfo->vgname); return 0; } } - if (info->vginfo->vgname) - dm_free(info->vginfo->vgname); - if (info->vginfo->creation_host) - dm_free(info->vginfo->creation_host); - if (*info->vginfo->vgid) - dm_hash_remove(_vgid_hash, info->vginfo->vgid); - list_del(&info->vginfo->list); + if (vginfo->vgname) + dm_free(vginfo->vgname); + if (vginfo->creation_host) + dm_free(vginfo->creation_host); + if (*vginfo->vgid) + dm_hash_remove(_vgid_hash, vginfo->vgid); + list_del(&vginfo->list); dm_free(info->vginfo); } - info->vginfo = NULL; + if (info) + info->vginfo = NULL; return 1; } @@ -574,7 +578,7 @@ if (info->dev->pvid[0] && _pvid_hash) dm_hash_remove(_pvid_hash, info->dev->pvid); - _drop_vginfo(info); + _drop_vginfo(info, info->vginfo); info->label->labeller->ops->destroy_label(info->label->labeller, info->label); @@ -599,31 +603,36 @@ return 1; } -static int _lvmcache_update_vgid(struct lvmcache_info *info, const char *vgid) +/* + * vginfo must be info->vginfo unless info is NULL (orphans) + */ +static int _lvmcache_update_vgid(struct lvmcache_info *info, + struct lvmcache_vginfo *vginfo, + const char *vgid) { - if (!vgid || !info->vginfo || - !strncmp(info->vginfo->vgid, vgid, ID_LEN)) + if (!vgid || !vginfo || + !strncmp(vginfo->vgid, vgid, ID_LEN)) return 1; - if (info->vginfo && *info->vginfo->vgid) - dm_hash_remove(_vgid_hash, info->vginfo->vgid); + if (vginfo && *vginfo->vgid) + dm_hash_remove(_vgid_hash, vginfo->vgid); if (!vgid) { - log_debug("lvmcache: %s: clearing VGID", dev_name(info->dev)); + log_debug("lvmcache: %s: clearing VGID", info ? dev_name(info->dev) : vginfo->vgname); return 1; } - strncpy(info->vginfo->vgid, vgid, ID_LEN); - info->vginfo->vgid[ID_LEN] = '\0'; - if (!dm_hash_insert(_vgid_hash, info->vginfo->vgid, info->vginfo)) { + strncpy(vginfo->vgid, vgid, ID_LEN); + vginfo->vgid[ID_LEN] = '\0'; + if (!dm_hash_insert(_vgid_hash, vginfo->vgid, vginfo)) { log_error("_lvmcache_update: vgid hash insertion failed: %s", - info->vginfo->vgid); + vginfo->vgid); return 0; } - if (!is_orphan_vg(info->vginfo->vgname)) + if (!is_orphan_vg(vginfo->vgname)) log_debug("lvmcache: %s: setting %s VGID to %s", - dev_name(info->dev), info->vginfo->vgname, - info->vginfo->vgid); + dev_name(info->dev), vginfo->vgname, + vginfo->vgid); return 1; } @@ -714,16 +723,18 @@ static int _lvmcache_update_vgname(struct lvmcache_info *info, const char *vgname, const char *vgid, - uint32_t vgstatus, const char *creation_host) + uint32_t vgstatus, const char *creation_host, + const struct format_type *fmt) { struct lvmcache_vginfo *vginfo, *primary_vginfo; // struct lvmcache_vginfo *old_vginfo, *next; - if (!vgname || (info->vginfo && !strcmp(info->vginfo->vgname, vgname))) + if (!vgname || (info && info->vginfo && !strcmp(info->vginfo->vgname, vgname))) return 1; /* Remove existing vginfo entry */ - _drop_vginfo(info); + if (info) + _drop_vginfo(info, info->vginfo); /* Get existing vginfo or create new one */ if (!(vginfo = vginfo_from_vgname(vgname, vgid))) { @@ -791,18 +802,25 @@ ***/ } - info->vginfo = vginfo; - list_add(&vginfo->infos, &info->list); + if (info) { + info->vginfo = vginfo; + list_add(&vginfo->infos, &info->list); + } else if (!_lvmcache_update_vgid(info, vginfo, vgid)) /* Orphans */ + return_0; _update_cache_vginfo_lock_state(vginfo, vgname_is_locked(vgname)); /* FIXME Check consistency of list! */ - vginfo->fmt = info->fmt; + vginfo->fmt = fmt; - log_debug("lvmcache: %s: now in VG %s%s%s%s", dev_name(info->dev), - vgname, vginfo->vgid[0] ? " (" : "", - vginfo->vgid[0] ? vginfo->vgid : "", - vginfo->vgid[0] ? ")" : ""); + if (info) + log_debug("lvmcache: %s: now in VG %s%s%s%s", + dev_name(info->dev), + vgname, vginfo->vgid[0] ? " (" : "", + vginfo->vgid[0] ? vginfo->vgid : "", + vginfo->vgid[0] ? ")" : ""); + else + log_debug("lvmcache: initialised VG %s", vgname); return 1; } @@ -842,6 +860,16 @@ return 1; } +int lvmcache_add_orphan_vginfo(const char *vgname, struct format_type *fmt) +{ + if (!_lock_hash && !lvmcache_init()) { + log_error("Internal cache initialisation failed"); + return 0; + } + + return _lvmcache_update_vgname(NULL, vgname, vgname, 0, "", fmt); +} + int lvmcache_update_vgname_and_id(struct lvmcache_info *info, const char *vgname, const char *vgid, uint32_t vgstatus, const char *creation_host) @@ -852,9 +880,10 @@ vgname = info->fmt->orphan_vg_name; vgid = vgname; } + if (!_lvmcache_update_vgname(info, vgname, vgid, vgstatus, - creation_host) || - !_lvmcache_update_vgid(info, vgid) || + creation_host, info->fmt) || + !_lvmcache_update_vgid(info, info->vginfo, vgid) || !_lvmcache_update_vgstatus(info, vgstatus, creation_host)) return_0; @@ -1036,7 +1065,7 @@ dm_hash_get_key(_lock_hash, n)); } -void lvmcache_destroy(void) +void lvmcache_destroy(struct cmd_context *cmd, int retain_orphans) { struct dm_hash_node *n; log_verbose("Wiping internal VG cache"); @@ -1069,4 +1098,7 @@ } list_init(&_vginfos); + + if (retain_orphans) + init_lvmcache_orphans(cmd); } --- LVM2/lib/cache/lvmcache.h 2008/04/01 22:40:12 1.19 +++ LVM2/lib/cache/lvmcache.h 2008/04/08 12:49:20 1.20 @@ -63,7 +63,7 @@ }; int lvmcache_init(void); -void lvmcache_destroy(void); +void lvmcache_destroy(struct cmd_context *cmd, int retain_orphans); /* Set full_scan to 1 to reread every filtered device label or * 2 to rescan /dev for new devices */ @@ -74,6 +74,7 @@ struct device *dev, const char *vgname, const char *vgid, uint32_t vgstatus); +int lvmcache_add_orphan_vginfo(const char *vgname, struct format_type *fmt); void lvmcache_del(struct lvmcache_info *info); /* Update things */ --- LVM2/lib/commands/toolcontext.c 2008/04/02 21:31:14 1.58 +++ LVM2/lib/commands/toolcontext.c 2008/04/08 12:49:20 1.59 @@ -721,6 +721,17 @@ return 0; } +int init_lvmcache_orphans(struct cmd_context *cmd) +{ + struct format_type *fmt; + + list_iterate_items(fmt, &cmd->formats) + if (!lvmcache_add_orphan_vginfo(fmt->orphan_vg_name, fmt)) + return_0; + + return 1; +} + static int _init_segtypes(struct cmd_context *cmd) { struct segment_type *segtype; @@ -981,6 +992,9 @@ if (!_init_formats(cmd)) goto error; + if (!init_lvmcache_orphans(cmd)) + goto error; + if (!_init_segtypes(cmd)) goto error; @@ -1044,7 +1058,7 @@ */ activation_release(); - lvmcache_destroy(); + lvmcache_destroy(cmd, 0); label_exit(); _destroy_segtypes(&cmd->segtypes); _destroy_formats(&cmd->formats); @@ -1086,6 +1100,9 @@ if (!_init_formats(cmd)) return 0; + if (!init_lvmcache_orphans(cmd)) + return 0; + if (!_init_segtypes(cmd)) return 0; @@ -1107,7 +1124,7 @@ archive_exit(cmd); backup_exit(cmd); - lvmcache_destroy(); + lvmcache_destroy(cmd, 0); label_exit(); _destroy_segtypes(&cmd->segtypes); _destroy_formats(&cmd->formats); --- LVM2/lib/commands/toolcontext.h 2008/04/02 21:23:39 1.22 +++ LVM2/lib/commands/toolcontext.h 2008/04/08 12:49:20 1.23 @@ -95,5 +95,6 @@ void destroy_toolcontext(struct cmd_context *cmd); int refresh_toolcontext(struct cmd_context *cmd); int config_files_changed(struct cmd_context *cmd); +int init_lvmcache_orphans(struct cmd_context *cmd); #endif --- LVM2/lib/format_pool/format_pool.c 2008/02/06 15:47:27 1.14 +++ LVM2/lib/format_pool/format_pool.c 2008/04/08 12:49:20 1.15 @@ -24,8 +24,6 @@ #include "format_pool.h" #include "pool_label.h" -#define FMT_POOL_NAME "pool" - /* Must be called after pvs are imported */ static struct user_subpool *_build_usp(struct list *pls, struct dm_pool *mem, int *sps) @@ -316,7 +314,7 @@ fmt->ops = &_format_pool_ops; fmt->name = FMT_POOL_NAME; fmt->alias = NULL; - fmt->orphan_vg_name = ORPHAN_VG_NAME(FMT_POOL_NAME); + fmt->orphan_vg_name = FMT_POOL_ORPHAN_VG_NAME; fmt->features = 0; fmt->private = NULL; --- LVM2/lib/format_pool/format_pool.h 2007/08/20 20:55:25 1.2 +++ LVM2/lib/format_pool/format_pool.h 2008/04/08 12:49:20 1.3 @@ -18,6 +18,9 @@ #include "metadata.h" +#define FMT_POOL_NAME "pool" +#define FMT_POOL_ORPHAN_VG_NAME ORPHAN_VG_NAME(FMT_POOL_NAME) + #ifdef POOL_INTERNAL struct format_type *init_pool_format(struct cmd_context *cmd); #endif --- LVM2/lib/metadata/metadata.c 2008/04/07 22:12:37 1.166 +++ LVM2/lib/metadata/metadata.c 2008/04/08 12:49:20 1.167 @@ -692,6 +692,10 @@ return 1; } +/* + * Separate metadata areas after splitting a VG. + * Also accepts orphan VG as destination (for vgreduce). + */ int vg_split_mdas(struct cmd_context *cmd __attribute((unused)), struct volume_group *vg_from, struct volume_group *vg_to) { @@ -708,11 +712,16 @@ continue; } - if (!mda->ops->mda_in_vg(vg_from->fid, vg_from, mda)) - list_move(&mda->list, mdas_to); + if (!mda->ops->mda_in_vg(vg_from->fid, vg_from, mda)) { + if (is_orphan_vg(vg_to->name)) + list_del(&mda->list); + else + list_move(&mda->list, mdas_to); + } } - if (list_empty(mdas_from) || list_empty(mdas_to)) + if (list_empty(mdas_from) || + (!is_orphan_vg(vg_to->name) && list_empty(mdas_to))) return common_mda; return 1; @@ -1366,6 +1375,8 @@ struct volume_group *vg; struct physical_volume *pv; + lvmcache_label_scan(cmd, 0); + if (!(vginfo = vginfo_from_vgname(orphan_vgname, NULL))) return_NULL; --- LVM2/tools/lvmcmdline.c 2008/04/02 21:23:39 1.62 +++ LVM2/tools/lvmcmdline.c 2008/04/08 12:49:21 1.63 @@ -938,7 +938,7 @@ out: if (test_mode()) { log_verbose("Test mode: Wiping internal cache"); - lvmcache_destroy(); + lvmcache_destroy(cmd, 1); } if (cmd->cft_override) { --- LVM2/tools/pvcreate.c 2008/01/30 14:00:02 1.61 +++ LVM2/tools/pvcreate.c 2008/04/08 12:49:21 1.62 @@ -81,7 +81,7 @@ unlock_vg(cmd, VG_ORPHANS); persistent_filter_wipe(cmd->filter); - lvmcache_destroy(); + lvmcache_destroy(cmd, 1); init_md_filtering(0); if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) { --- LVM2/tools/pvscan.c 2008/01/30 14:00:02 1.45 +++ LVM2/tools/pvscan.c 2008/04/08 12:49:21 1.46 @@ -130,7 +130,7 @@ } persistent_filter_wipe(cmd->filter); - lvmcache_destroy(); + lvmcache_destroy(cmd, 1); log_verbose("Walking through all physical volumes"); if (!(pvslist = get_pvs(cmd))) { --- LVM2/tools/vgreduce.c 2008/02/06 15:47:28 1.79 +++ LVM2/tools/vgreduce.c 2008/04/08 12:49:21 1.80 @@ -353,6 +353,8 @@ void *handle __attribute((unused))) { struct pv_list *pvl; + struct volume_group *orphan_vg; + int consistent = 1; const char *name = pv_dev_name(pv); if (pv_pe_alloc_count(pv)) { @@ -366,10 +368,17 @@ return ECMD_FAILED; } + if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE | LCK_NONBLOCK)) { + log_error("Can't get lock for orphan PVs"); + return ECMD_FAILED; + } + pvl = find_pv_in_vg(vg, name); - if (!archive(vg)) + if (!archive(vg)) { + unlock_vg(cmd, VG_ORPHANS); return ECMD_FAILED; + } log_verbose("Removing \"%s\" from volume group \"%s\"", name, vg->name); @@ -381,6 +390,7 @@ if (!dev_get_size(pv_dev(pv), &pv->size)) { log_error("%s: Couldn't get size.", pv_dev_name(pv)); + unlock_vg(cmd, VG_ORPHANS); return ECMD_FAILED; } @@ -388,9 +398,24 @@ vg->free_count -= pv_pe_count(pv) - pv_pe_alloc_count(pv); vg->extent_count -= pv_pe_count(pv); + if(!(orphan_vg = vg_read(cmd, vg->fid->fmt->orphan_vg_name, NULL, &consistent)) || + !consistent) { + log_error("Unable to read existing orphan PVs"); + unlock_vg(cmd, VG_ORPHANS); + return ECMD_FAILED; + } + + if (!vg_split_mdas(cmd, vg, orphan_vg) || !vg->pv_count) { + log_error("Cannot remove final metadata area on \"%s\" from \"%s\"", + name, vg->name); + unlock_vg(cmd, VG_ORPHANS); + return ECMD_FAILED; + } + if (!vg_write(vg) || !vg_commit(vg)) { log_error("Removal of physical volume \"%s\" from " "\"%s\" failed", name, vg->name); + unlock_vg(cmd, VG_ORPHANS); return ECMD_FAILED; } @@ -398,9 +423,11 @@ log_error("Failed to clear metadata from physical " "volume \"%s\" " "after removal from \"%s\"", name, vg->name); + unlock_vg(cmd, VG_ORPHANS); return ECMD_FAILED; } + unlock_vg(cmd, VG_ORPHANS); backup(vg); log_print("Removed \"%s\" from volume group \"%s\"", name, vg->name); --- LVM2/tools/vgrename.c 2008/01/30 14:00:02 1.50 +++ LVM2/tools/vgrename.c 2008/04/08 12:49:21 1.51 @@ -151,7 +151,7 @@ /* FIXME lvmcache corruption - vginfo duplicated instead of renamed */ persistent_filter_wipe(cmd->filter); - lvmcache_destroy(); + lvmcache_destroy(cmd, 1); return 1; --- LVM2/tools/vgscan.c 2008/01/30 14:00:02 1.29 +++ LVM2/tools/vgscan.c 2008/04/08 12:49:21 1.30 @@ -57,7 +57,7 @@ } persistent_filter_wipe(cmd->filter); - lvmcache_destroy(); + lvmcache_destroy(cmd, 1); log_print("Reading all physical volumes. This may take a while..."); From ccaulfield@sourceware.org Tue Apr 8 13:03:00 2008 From: ccaulfield@sourceware.org (ccaulfield@sourceware.org) Date: Tue, 08 Apr 2008 13:03:00 -0000 Subject: LVM2 ./WHATS_NEW daemons/clvmd/lvm-functions.c Message-ID: <20080408130314.30488.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: ccaulfield@sourceware.org 2008-04-08 13:03:13 Modified files: . : WHATS_NEW daemons/clvmd : lvm-functions.c Log message: Add config file overrides to clvmd when it reads the LVs list so that config items 'command_names' and 'prefix' don't prevent it working. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.830&r2=1.831 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/lvm-functions.c.diff?cvsroot=lvm2&r1=1.38&r2=1.39 --- LVM2/WHATS_NEW 2008/04/08 12:49:20 1.830 +++ LVM2/WHATS_NEW 2008/04/08 13:03:13 1.831 @@ -1,5 +1,6 @@ Version 2.02.34 - =================================== + Addd config file overrides to clvmd when it reads the active LVs list Fix vgreduce to use vg_split_mdas to check sufficient mdas remain. Add (empty) orphan VGs to lvmcache during initialisation. Fix orphan VG name used for format_pool. --- LVM2/daemons/clvmd/lvm-functions.c 2008/04/04 08:53:47 1.38 +++ LVM2/daemons/clvmd/lvm-functions.c 2008/04/08 13:03:13 1.39 @@ -470,7 +470,7 @@ char line[255]; FILE *vgs = popen - ("lvm pvs --nolocking --noheadings -o vg_name", "r"); + ("lvm pvs --config 'log{command_names=0 prefix=\"\"}' --nolocking --noheadings -o vg_name", "r"); sync_unlock("P_orphans", LCK_EXCL); @@ -511,7 +511,7 @@ char line[255]; FILE *lvs = popen - ("lvm lvs --nolocking --noheadings -o vg_uuid,lv_uuid,lv_attr,vg_attr", + ("lvm lvs --config 'log{command_names=0 prefix=\"\"}' --nolocking --noheadings -o vg_uuid,lv_uuid,lv_attr,vg_attr", "r"); if (!lvs) From agk@sourceware.org Tue Apr 8 14:22:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 08 Apr 2008 14:22:00 -0000 Subject: LVM2 ./WHATS_NEW man/vgcreate.8 tools/vgcreate.c Message-ID: <20080408142214.13148.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-08 14:22:13 Modified files: . : WHATS_NEW man : vgcreate.8 tools : vgcreate.c Log message: Indicate whether or not VG is clustered in vgcreate log message. Mention default --clustered setting in vgcreate man page. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.831&r2=1.832 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/vgcreate.8.diff?cvsroot=lvm2&r1=1.7&r2=1.8 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgcreate.c.diff?cvsroot=lvm2&r1=1.56&r2=1.57 --- LVM2/WHATS_NEW 2008/04/08 13:03:13 1.831 +++ LVM2/WHATS_NEW 2008/04/08 14:22:12 1.832 @@ -1,6 +1,8 @@ Version 2.02.34 - =================================== - Addd config file overrides to clvmd when it reads the active LVs list + Indicate whether or not VG is clustered in vgcreate log message. + Mention default --clustered setting in vgcreate man page. + Add config file overrides to clvmd when it reads the active LVs list. Fix vgreduce to use vg_split_mdas to check sufficient mdas remain. Add (empty) orphan VGs to lvmcache during initialisation. Fix orphan VG name used for format_pool. --- LVM2/man/vgcreate.8 2007/01/23 13:08:34 1.7 +++ LVM2/man/vgcreate.8 2008/04/08 14:22:13 1.8 @@ -35,12 +35,13 @@ See \fBlvm\fP for common options. .TP .BR \-c ", " \-\-clustered " " { y | n } -If clustered locking is enabled, this indicates whether this -Volume Group is shared with other nodes in the cluster or whether -it contains only local disks that are not visible on the other nodes. +If clustered locking is enabled, this defaults to \fBy\fP indicating that +this Volume Group is shared with other nodes in the cluster. + +If the new Volume Group contains only local disks that are not visible +on the other nodes, you must specify \fB\-\-clustered\ n\fP. If the cluster infrastructure is unavailable on a particular node at a -particular time, you may still be able to use Volume Groups that -are not marked as clustered. +particular time, you may still be able to use such Volume Groups. .TP .BR \-l ", " \-\-maxlogicalvolumes " " \fIMaxLogicalVolumes\fR Sets the maximum number of logical volumes allowed in this --- LVM2/tools/vgcreate.c 2008/01/17 15:31:18 1.56 +++ LVM2/tools/vgcreate.c 2008/04/08 14:22:13 1.57 @@ -21,6 +21,7 @@ struct vgcreate_params vp_def; struct volume_group *vg; const char *tag; + const char *clustered_message = ""; if (!argc) { log_error("Please provide volume group name and " @@ -78,10 +79,14 @@ } /* FIXME: move this inside vg_create? */ - if (vp_new.clustered) + if (vp_new.clustered) { vg->status |= CLUSTERED; - else + clustered_message = "Clustered "; + } else { vg->status &= ~CLUSTERED; + if (locking_is_clustered()) + clustered_message = "Non-clustered "; + } if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE)) { log_error("Can't get lock for orphan PVs"); @@ -112,7 +117,8 @@ backup(vg); - log_print("Volume group \"%s\" successfully created", vg->name); + log_print("%s%colume group \"%s\" successfully created", + clustered_message, *clustered_message ? 'v' : 'V', vg->name); return ECMD_PROCESSED; } From wysochanski@sourceware.org Tue Apr 8 21:38:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Tue, 08 Apr 2008 21:38:00 -0000 Subject: LVM2 ./WHATS_NEW tools/vgsplit.c Message-ID: <20080408213809.13010.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-08 21:38:09 Modified files: . : WHATS_NEW tools : vgsplit.c Log message: Fix vgsplit error paths to release vg_to lock. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.832&r2=1.833 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.54&r2=1.55 --- LVM2/WHATS_NEW 2008/04/08 14:22:12 1.832 +++ LVM2/WHATS_NEW 2008/04/08 21:38:08 1.833 @@ -1,5 +1,6 @@ Version 2.02.34 - =================================== + Fix vgsplit error paths to release vg_to lock. Indicate whether or not VG is clustered in vgcreate log message. Mention default --clustered setting in vgcreate man page. Add config file overrides to clvmd when it reads the active LVs list. --- LVM2/tools/vgsplit.c 2008/04/02 19:30:12 1.54 +++ LVM2/tools/vgsplit.c 2008/04/08 21:38:09 1.55 @@ -288,11 +288,13 @@ if (fill_vg_create_params(cmd, vg_name_to, &vp_new, &vp_def)) { unlock_vg(cmd, vg_name_from); + unlock_vg(cmd, vg_name_to); return EINVALID_CMD_LINE; } if (validate_vg_create_params(cmd, &vp_new)) { unlock_vg(cmd, vg_name_from); + unlock_vg(cmd, vg_name_to); return EINVALID_CMD_LINE; } From wysochanski@sourceware.org Tue Apr 8 21:47:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Tue, 08 Apr 2008 21:47:00 -0000 Subject: LVM2 ./WHATS_NEW tools/vgsplit.c Message-ID: <20080408214754.17456.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-08 21:47:54 Modified files: . : WHATS_NEW tools : vgsplit.c Log message: Fix vgsplit error display - fully remove log_suppress. Author: Dave Wysochanski Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.833&r2=1.834 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.55&r2=1.56 --- LVM2/WHATS_NEW 2008/04/08 21:38:08 1.833 +++ LVM2/WHATS_NEW 2008/04/08 21:47:54 1.834 @@ -1,5 +1,6 @@ Version 2.02.34 - =================================== + Fix vgsplit error display - fully remove log_suppress. Fix vgsplit error paths to release vg_to lock. Indicate whether or not VG is clustered in vgcreate log message. Mention default --clustered setting in vgcreate man page. --- LVM2/tools/vgsplit.c 2008/04/08 21:38:09 1.55 +++ LVM2/tools/vgsplit.c 2008/04/08 21:47:54 1.56 @@ -220,7 +220,6 @@ int opt; int active; int existing_vg; - int old_suppress; struct pv_list *pvl; int consistent; @@ -272,7 +271,6 @@ if (!vgs_are_compatible(cmd, vg_from,vg_to)) goto error; } else { - log_suppress(old_suppress); existing_vg = 0; /* Set metadata format of original VG */ From wysochanski@sourceware.org Tue Apr 8 22:02:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Tue, 08 Apr 2008 22:02:00 -0000 Subject: LVM2 WHATS_NEW Message-ID: <20080408220217.25362.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-08 22:02:16 Modified files: . : WHATS_NEW Log message: Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.834&r2=1.835 --- LVM2/WHATS_NEW 2008/04/08 21:47:54 1.834 +++ LVM2/WHATS_NEW 2008/04/08 22:02:16 1.835 @@ -1,6 +1,5 @@ Version 2.02.34 - =================================== - Fix vgsplit error display - fully remove log_suppress. Fix vgsplit error paths to release vg_to lock. Indicate whether or not VG is clustered in vgcreate log message. Mention default --clustered setting in vgcreate man page. From agk@sourceware.org Wed Apr 9 12:45:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 09 Apr 2008 12:45:00 -0000 Subject: LVM2 ./WHATS_NEW tools/polldaemon.h tools/pvmove.c Message-ID: <20080409124533.23529.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-09 12:45:33 Modified files: . : WHATS_NEW tools : polldaemon.h pvmove.c Log message: Fix some pvmove error status codes. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.835&r2=1.836 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/polldaemon.h.diff?cvsroot=lvm2&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvmove.c.diff?cvsroot=lvm2&r1=1.50&r2=1.51 --- LVM2/WHATS_NEW 2008/04/08 22:02:16 1.835 +++ LVM2/WHATS_NEW 2008/04/09 12:45:32 1.836 @@ -1,5 +1,6 @@ Version 2.02.34 - =================================== + Fix some pvmove error status codes. Fix vgsplit error paths to release vg_to lock. Indicate whether or not VG is clustered in vgcreate log message. Mention default --clustered setting in vgcreate man page. --- LVM2/tools/polldaemon.h 2007/12/22 12:13:29 1.4 +++ LVM2/tools/polldaemon.h 2008/04/09 12:45:32 1.5 @@ -19,21 +19,21 @@ #include "metadata-exported.h" struct poll_functions { - const char *(*get_copy_name_from_lv) (struct logical_volume * lv_mirr); - struct volume_group *(*get_copy_vg) (struct cmd_context * cmd, + const char *(*get_copy_name_from_lv) (struct logical_volume *lv_mirr); + struct volume_group *(*get_copy_vg) (struct cmd_context *cmd, const char *name); - struct logical_volume *(*get_copy_lv) (struct cmd_context * cmd, - struct volume_group * vg, + struct logical_volume *(*get_copy_lv) (struct cmd_context *cmd, + struct volume_group *vg, const char *name, uint32_t lv_type); - int (*update_metadata) (struct cmd_context * cmd, - struct volume_group * vg, - struct logical_volume * lv_mirr, - struct list * lvs_changed, int first_time); - int (*finish_copy) (struct cmd_context * cmd, - struct volume_group * vg, - struct logical_volume * lv_mirr, - struct list * lvs_changed); + int (*update_metadata) (struct cmd_context *cmd, + struct volume_group *vg, + struct logical_volume *lv_mirr, + struct list *lvs_changed, int first_time); + int (*finish_copy) (struct cmd_context *cmd, + struct volume_group *vg, + struct logical_volume *lv_mirr, + struct list *lvs_changed); }; struct daemon_parms { --- LVM2/tools/pvmove.c 2008/04/07 10:23:47 1.50 +++ LVM2/tools/pvmove.c 2008/04/09 12:45:32 1.51 @@ -565,8 +565,10 @@ char *colon; int ret; - if (!pvmove_target_present(cmd, 0)) - return 0; + if (!pvmove_target_present(cmd, 0)) { + stack; + return ECMD_FAILED; + } if (argc) { pv_name = argv[0]; @@ -577,7 +579,7 @@ (unsigned) (colon - pv_name)))) { log_error("Failed to clone PV name"); - return 0; + return ECMD_FAILED; } } @@ -587,7 +589,6 @@ stack; return ret; } - } return pvmove_poll(cmd, pv_name, From agk@sourceware.org Wed Apr 9 12:56:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 09 Apr 2008 12:56:00 -0000 Subject: LVM2 ./WHATS_NEW lib/locking/locking.c lib/loc ... Message-ID: <20080409125635.26515.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-09 12:56:34 Modified files: . : WHATS_NEW lib/locking : locking.c locking.h tools : lvconvert.c polldaemon.h pvmove.c Log message: Use clustered mirror log with pvmove in clustered VGs, if available. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.836&r2=1.837 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.45&r2=1.46 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.37&r2=1.38 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.62&r2=1.63 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/polldaemon.h.diff?cvsroot=lvm2&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvmove.c.diff?cvsroot=lvm2&r1=1.51&r2=1.52 --- LVM2/WHATS_NEW 2008/04/09 12:45:32 1.836 +++ LVM2/WHATS_NEW 2008/04/09 12:56:34 1.837 @@ -1,5 +1,6 @@ Version 2.02.34 - =================================== + Use clustered mirror log with pvmove in clustered VGs, if available. Fix some pvmove error status codes. Fix vgsplit error paths to release vg_to lock. Indicate whether or not VG is clustered in vgcreate log message. --- LVM2/lib/locking/locking.c 2008/04/07 19:17:29 1.45 +++ LVM2/lib/locking/locking.c 2008/04/09 12:56:34 1.46 @@ -412,19 +412,23 @@ } /* Lock a list of LVs */ -int activate_lvs_excl(struct cmd_context *cmd, struct list *lvs) +int activate_lvs(struct cmd_context *cmd, struct list *lvs, unsigned exclusive) { struct list *lvh; struct lv_list *lvl; list_iterate_items(lvl, lvs) { - if (!activate_lv_excl(cmd, lvl->lv)) { + if (!exclusive) { + if (!activate_lv(cmd, lvl->lv)) { + log_error("Failed to activate %s", lvl->lv->name); + return 0; + } + } else if (!activate_lv_excl(cmd, lvl->lv)) { log_error("Failed to activate %s", lvl->lv->name); list_uniterate(lvh, lvs, &lvl->list) { lvl = list_item(lvh, struct lv_list); activate_lv(cmd, lvl->lv); } - return 0; } } --- LVM2/lib/locking/locking.h 2007/11/15 21:30:52 1.37 +++ LVM2/lib/locking/locking.h 2008/04/09 12:56:34 1.38 @@ -120,7 +120,7 @@ /* Process list of LVs */ int suspend_lvs(struct cmd_context *cmd, struct list *lvs); int resume_lvs(struct cmd_context *cmd, struct list *lvs); -int activate_lvs_excl(struct cmd_context *cmd, struct list *lvs); +int activate_lvs(struct cmd_context *cmd, struct list *lvs, unsigned exclusive); /* Interrupt handling */ void sigint_clear(void); --- LVM2/tools/lvconvert.c 2008/04/07 10:23:47 1.62 +++ LVM2/tools/lvconvert.c 2008/04/09 12:56:34 1.63 @@ -258,7 +258,7 @@ struct volume_group *vg __attribute((unused)), struct logical_volume *lv __attribute((unused)), struct list *lvs_changed __attribute((unused)), - int first_time __attribute((unused))) + unsigned flags __attribute((unused))) { /* lvconvert mirror doesn't require periodical metadata update */ return 1; --- LVM2/tools/polldaemon.h 2008/04/09 12:45:32 1.5 +++ LVM2/tools/polldaemon.h 2008/04/09 12:56:34 1.6 @@ -29,7 +29,7 @@ int (*update_metadata) (struct cmd_context *cmd, struct volume_group *vg, struct logical_volume *lv_mirr, - struct list *lvs_changed, int first_time); + struct list *lvs_changed, unsigned flags); int (*finish_copy) (struct cmd_context *cmd, struct volume_group *vg, struct logical_volume *lv_mirr, --- LVM2/tools/pvmove.c 2008/04/09 12:45:32 1.51 +++ LVM2/tools/pvmove.c 2008/04/09 12:56:34 1.52 @@ -17,28 +17,43 @@ #include "polldaemon.h" #include "display.h" -static int pvmove_target_present(struct cmd_context *cmd, int clustered) +#define PVMOVE_FIRST_TIME 0x00000001 /* Called for first time */ + +static int _pvmove_target_present(struct cmd_context *cmd, int clustered) { const struct segment_type *segtype; unsigned attr = 0; + int found = 1; + static int _clustered_found = -1; + + if (clustered && _clustered_found >= 0) + return _clustered_found; if (!(segtype = get_segtype_from_string(cmd, "mirror"))) return_0; if (activation() && segtype->ops->target_present && - !segtype->ops->target_present(NULL, clustered ? &attr : NULL)) { - log_error("%s: Required device-mapper target(s) not " - "detected in your kernel", segtype->name); - return 0; - } + !segtype->ops->target_present(NULL, clustered ? &attr : NULL)) + found = 0; - if (clustered && !(attr & MIRROR_LOG_CLUSTERED)) { - log_error("%s: Required device-mapper clustered log " - "module not detected in your kernel", segtype->name); - return 0; + if (activation() && clustered) { + if (found && (attr & MIRROR_LOG_CLUSTERED)) + _clustered_found = found = 1; + else + _clustered_found = found = 0; } - return 1; + return found; +} + +static unsigned _pvmove_is_exclusive(struct cmd_context *cmd, + struct volume_group *vg) +{ + if (vg_status(vg) & CLUSTERED) + if (!_pvmove_target_present(cmd, 1)) + return 1; + + return 0; } /* Allow /dev/vgname/lvname, vgname/lvname or lvname */ @@ -250,10 +265,22 @@ return lv_mirr; } +static int _activate_lv(struct cmd_context *cmd, struct logical_volume *lv_mirr, + unsigned exclusive) +{ + if (exclusive) + return activate_lv_excl(cmd, lv_mirr); + + return activate_lv(cmd, lv_mirr); +} + static int _update_metadata(struct cmd_context *cmd, struct volume_group *vg, struct logical_volume *lv_mirr, - struct list *lvs_changed, int first_time) + struct list *lvs_changed, unsigned flags) { + unsigned exclusive = _pvmove_is_exclusive(cmd, vg); + unsigned first_time = (flags & PVMOVE_FIRST_TIME) ? 1 : 0; + log_verbose("Updating volume group metadata"); if (!vg_write(vg)) { log_error("ABORTING: Volume group metadata update failed."); @@ -289,7 +316,7 @@ /* Only the first mirror segment gets activated as a mirror */ /* FIXME: Add option to use a log */ if (first_time) { - if (!activate_lv_excl(cmd, lv_mirr)) { + if (!_activate_lv(cmd, lv_mirr, exclusive)) { if (!test_mode()) log_error("ABORTING: Temporary mirror " "activation failed. " @@ -326,7 +353,8 @@ struct list *lvs_changed; struct physical_volume *pv; struct logical_volume *lv_mirr; - int first_time = 1; + unsigned first_time = 1; + unsigned exclusive; pv_name_arg = argv[0]; argc--; @@ -359,6 +387,8 @@ return ECMD_FAILED; } + exclusive = _pvmove_is_exclusive(cmd, vg); + if ((lv_mirr = find_pvmove_lv(vg, pv_dev(pv), PVMOVE))) { log_print("Detected pvmove in progress for %s", pv_name); if (argc || lv_name) @@ -372,7 +402,7 @@ } /* Ensure mirror LV is active */ - if (!activate_lv_excl(cmd, lv_mirr)) { + if (!_activate_lv(cmd, lv_mirr, exclusive)) { log_error ("ABORTING: Temporary mirror activation failed."); unlock_vg(cmd, pv_vg_name(pv)); @@ -416,8 +446,8 @@ } } - /* Lock lvs_changed for exclusive use and activate (with old metadata) */ - if (!activate_lvs_excl(cmd, lvs_changed)) { + /* Lock lvs_changed and activate (with old metadata) */ + if (!activate_lvs(cmd, lvs_changed, exclusive)) { stack; unlock_vg(cmd, pv_vg_name(pv)); return ECMD_FAILED; @@ -429,7 +459,7 @@ if (first_time) { if (!_update_metadata - (cmd, vg, lv_mirr, lvs_changed, first_time)) { + (cmd, vg, lv_mirr, lvs_changed, PVMOVE_FIRST_TIME)) { stack; unlock_vg(cmd, pv_vg_name(pv)); return ECMD_FAILED; @@ -565,8 +595,10 @@ char *colon; int ret; - if (!pvmove_target_present(cmd, 0)) { - stack; + /* dm raid1 target must be present in every case */ + if (!_pvmove_target_present(cmd, 0)) { + log_error("Required device-mapper target(s) not " + "detected in your kernel"); return ECMD_FAILED; } From wysochanski@sourceware.org Wed Apr 9 13:47:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Wed, 09 Apr 2008 13:47:00 -0000 Subject: LVM2 ./WHATS_NEW tools/commands.h tools/vgsplit.c Message-ID: <20080409134714.24497.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-09 13:47:13 Modified files: . : WHATS_NEW tools : commands.h vgsplit.c Log message: Update vgsplit to take "-n LogicalVolumeName" on the commandline. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.837&r2=1.838 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/commands.h.diff?cvsroot=lvm2&r1=1.109&r2=1.110 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.56&r2=1.57 --- LVM2/WHATS_NEW 2008/04/09 12:56:34 1.837 +++ LVM2/WHATS_NEW 2008/04/09 13:47:13 1.838 @@ -1,5 +1,6 @@ Version 2.02.34 - =================================== + Update vgsplit to take "-n LogicalVolumeName" on the commandline. Use clustered mirror log with pvmove in clustered VGs, if available. Fix some pvmove error status codes. Fix vgsplit error paths to release vg_to lock. --- LVM2/tools/commands.h 2008/04/02 21:23:39 1.109 +++ LVM2/tools/commands.h 2008/04/09 13:47:13 1.110 @@ -927,16 +927,17 @@ "\t[-h|--help] " "\n" "\t[-l|--maxlogicalvolumes MaxLogicalVolumes]" "\n" "\t[-M|--metadatatype 1|2] " "\n" + "\t[-n|--name LogicalVolumeName]\n" "\t[-p|--maxphysicalvolumes MaxPhysicalVolumes] " "\n" "\t[-t|--test] " "\n" "\t[-v|--verbose] " "\n" "\t[--version]" "\n" "\tSourceVolumeGroupName DestinationVolumeGroupName" "\n" - "\tPhysicalVolumePath [PhysicalVolumePath...]\n", + "\t[PhysicalVolumePath...]\n", alloc_ARG, autobackup_ARG, clustered_ARG, maxlogicalvolumes_ARG, maxphysicalvolumes_ARG, - metadatatype_ARG, test_ARG) + metadatatype_ARG, name_ARG, test_ARG) xx(version, "Display software and driver version information", --- LVM2/tools/vgsplit.c 2008/04/08 21:47:54 1.56 +++ LVM2/tools/vgsplit.c 2008/04/09 13:47:13 1.57 @@ -15,10 +15,18 @@ #include "tools.h" -static void _move_pv(struct volume_group *vg_from, struct volume_group *vg_to, - struct pv_list *pvl) +static int _move_pv(struct volume_group *vg_from, struct volume_group *vg_to, + const char *pv_name) { struct physical_volume *pv; + struct pv_list *pvl; + + /* FIXME: handle tags */ + if (!(pvl = find_pv_in_vg(vg_from, pv_name))) { + log_error("Physical volume %s not in volume group %s", + pv_name, vg_from->name); + return 0; + } list_move(&pvl->list, &vg_to->pvs); @@ -32,6 +40,45 @@ vg_from->free_count -= pv_pe_count(pv) - pv_pe_alloc_count(pv); vg_to->free_count += pv_pe_count(pv) - pv_pe_alloc_count(pv); + + return 1; +} + +static int _move_pvs_used_by_lv(struct volume_group *vg_from, + struct volume_group *vg_to, + const char *lv_name) +{ + struct lv_segment *lvseg; + unsigned s; + struct lv_list *lvl; + struct logical_volume *lv; + + /* FIXME: handle tags */ + if (!(lvl = find_lv_in_vg(vg_from, lv_name))) { + log_error("Logical volume %s not in volume group %s", + lv_name, vg_from->name); + return 0; + } + + list_iterate_items(lvseg, &lvl->lv->segments) { + if (lvseg->log_lv) + if (!_move_pvs_used_by_lv(vg_from, vg_to, + lvseg->log_lv->name)) + return_0; + for (s = 0; s < lvseg->area_count; s++) { + if (seg_type(lvseg, s) == AREA_PV) { + if (!_move_pv(vg_from, vg_to, + pv_dev_name(seg_pv(lvseg, s)))) + return_0; + } else if (seg_type(lvseg, s) == AREA_LV) { + lv = seg_lv(lvseg, s); + if (!_move_pvs_used_by_lv(vg_from, vg_to, + lv->name)) + return_0; + } + } + } + return 1; } /* FIXME Why not (lv->vg == vg) ? */ @@ -220,14 +267,26 @@ int opt; int active; int existing_vg; - struct pv_list *pvl; int consistent; + const char *lv_name; - if (argc < 3) { - log_error("Existing VG, new VG and physical volumes required."); + if ((arg_count(cmd, name_ARG) + argc) < 3) { + log_error("Existing VG, new VG and either physical volumes " + "or logical volume required."); return EINVALID_CMD_LINE; } + if (arg_count(cmd, name_ARG) && (argc > 2)) { + log_error("A logical volume name cannot be given with " + "physical volumes."); + return ECMD_FAILED; + } + + if (arg_count(cmd, name_ARG)) + lv_name = arg_value(cmd, name_ARG); + else + lv_name = NULL; + vg_name_from = skip_dev_dir(cmd, argv[0], NULL); vg_name_to = skip_dev_dir(cmd, argv[1], NULL); argc -= 2; @@ -266,10 +325,10 @@ if (new_vg_option_specified(cmd)) { log_error("Volume group \"%s\" exists, but new VG " "option specified", vg_name_to); - goto error; + goto bad; } if (!vgs_are_compatible(cmd, vg_from,vg_to)) - goto error; + goto bad; } else { existing_vg = 0; @@ -299,7 +358,7 @@ if (!(vg_to = vg_create(cmd, vg_name_to, vp_new.extent_size, vp_new.max_pv, vp_new.max_lv, vp_new.alloc, 0, NULL))) - goto error; + goto bad; if (vg_from->status & CLUSTERED) vg_to->status |= CLUSTERED; @@ -307,40 +366,41 @@ /* Archive vg_from before changing it */ if (!archive(vg_from)) - goto error; + goto bad; /* Move PVs across to new structure */ for (opt = 0; opt < argc; opt++) { - if (!(pvl = find_pv_in_vg(vg_from, argv[opt]))) { - log_error("Physical volume %s not in volume group %s", - argv[opt], vg_from->name); - goto error; - } + if (!_move_pv(vg_from, vg_to, argv[opt])) + goto bad; + } - _move_pv(vg_from, vg_to, pvl); + /* If an LV given on the cmdline, move used_by PVs */ + if (lv_name) { + if (!_move_pvs_used_by_lv(vg_from, vg_to, lv_name)) + goto bad; } /* Move required LVs across, checking consistency */ if (!(_move_lvs(vg_from, vg_to))) - goto error; + goto bad; /* Move required snapshots across */ if (!(_move_snapshots(vg_from, vg_to))) - goto error; + goto bad; /* Move required mirrors across */ if (!(_move_mirrors(vg_from, vg_to))) - goto error; + goto bad; /* Split metadata areas and check if both vgs have at least one area */ if (!(vg_split_mdas(cmd, vg_from, vg_to)) && vg_from->pv_count) { log_error("Cannot split: Nowhere to store metadata for new Volume Group"); - goto error; + goto bad; } /* Set proper name for all PVs in new VG */ if (!vg_rename(cmd, vg_to, vg_name_to)) - goto error; + goto bad; /* store it on disks */ log_verbose("Writing out updated volume groups"); @@ -355,10 +415,10 @@ vg_to->status |= EXPORTED_VG; if (!archive(vg_to)) - goto error; + goto bad; if (!vg_write(vg_to) || !vg_commit(vg_to)) - goto error; + goto bad; backup(vg_to); @@ -369,7 +429,7 @@ */ if (vg_from->pv_count) { if (!vg_write(vg_from) || !vg_commit(vg_from)) - goto error; + goto bad; backup(vg_from); } @@ -383,13 +443,13 @@ || !consistent)) { log_error("Volume group \"%s\" became inconsistent: please " "fix manually", vg_name_to); - goto error; + goto bad; } vg_to->status &= ~EXPORTED_VG; if (!vg_write(vg_to) || !vg_commit(vg_to)) - goto error; + goto bad; backup(vg_to); @@ -401,7 +461,7 @@ vg_to->name, vg_from->name); return ECMD_PROCESSED; - error: + bad: unlock_vg(cmd, vg_name_from); unlock_vg(cmd, vg_name_to); return ECMD_FAILED; From wysochanski@sourceware.org Wed Apr 9 14:39:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Wed, 09 Apr 2008 14:39:00 -0000 Subject: LVM2 ./WHATS_NEW man/vgsplit.8 Message-ID: <20080409143956.27996.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-09 14:39:55 Modified files: . : WHATS_NEW man : vgsplit.8 Log message: Update vgsplit man page to reflect lvnames on cmdline. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.838&r2=1.839 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/vgsplit.8.diff?cvsroot=lvm2&r1=1.7&r2=1.8 --- LVM2/WHATS_NEW 2008/04/09 13:47:13 1.838 +++ LVM2/WHATS_NEW 2008/04/09 14:39:55 1.839 @@ -1,6 +1,7 @@ Version 2.02.34 - =================================== - Update vgsplit to take "-n LogicalVolumeName" on the commandline. + Update vgsplit man page to reflect lvnames on the cmdline. + Update vgsplit to take "-n LogicalVolumeName" on the cmdline. Use clustered mirror log with pvmove in clustered VGs, if available. Fix some pvmove error status codes. Fix vgsplit error paths to release vg_to lock. --- LVM2/man/vgsplit.8 2008/01/22 02:48:52 1.7 +++ LVM2/man/vgsplit.8 2008/04/09 14:39:55 1.8 @@ -15,18 +15,21 @@ .IR type ] .RB [ -p | \-\-maxphysicalvolumes .IR MaxPhysicalVolumes ] +.RB [ \-n | \-\-name +.IR LogicalVolumeName ] .RB [ \-t | \-\-test ] .RB [ \-v | \-\-verbose ] SourceVolumeGroupName DestinationVolumeGroupName -PhysicalVolumePath [PhysicalVolumePath...] +[ PhysicalVolumePath ...] .SH DESCRIPTION .B vgsplit -moves -.IR PhysicalVolumePath (s) -from +moves one or more physical volumes from .I SourceVolumeGroupName into -.I DestinationVolumeGroupName\fP. +.I DestinationVolumeGroupName\fP. The physical volumes moved can be +specified either explicitly via \fIPhysicalVolumePath\fP, or implicitly by +\fB-n\fP \fILogicalVolumeName\fP, in which case only physical volumes +underlying the specified logical volume will be moved. If .I DestinationVolumeGroupName @@ -46,9 +49,13 @@ volume group attributes with an existing destination volume group is an error, and no split will occur. -Logical Volumes cannot be split between Volume Groups. -Each existing Logical Volume must be entirely on the Physical Volumes forming -either the source or the destination Volume Group. +Logical volumes cannot be split between volume groups. \fBVgsplit(8)\fP only +moves complete physical volumes: To move part of a physical volume, use +\fBpvmove(8)\fP. Each existing logical volume must be entirely on the physical +volumes forming either the source or the destination volume group. For this +reason, \fBvgsplit(8)\fP may fail with an error if a split would result in a +logical volume being split across volume groups. + .SH OPTIONS See \fBlvm\fP for common options. .SH SEE ALSO From wysochanski@sourceware.org Wed Apr 9 14:47:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Wed, 09 Apr 2008 14:47:00 -0000 Subject: LVM2 ./WHATS_NEW test/t-vgsplit-operation.sh Message-ID: <20080409144734.749.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-09 14:47:34 Modified files: . : WHATS_NEW test : t-vgsplit-operation.sh Log message: Update vgsplit tests for lvnames on the cmdline. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.839&r2=1.840 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-vgsplit-operation.sh.diff?cvsroot=lvm2&r1=1.14&r2=1.15 --- LVM2/WHATS_NEW 2008/04/09 14:39:55 1.839 +++ LVM2/WHATS_NEW 2008/04/09 14:47:34 1.840 @@ -1,5 +1,6 @@ Version 2.02.34 - =================================== + Update vgsplit tests for lvnames on the cmdline. Update vgsplit man page to reflect lvnames on the cmdline. Update vgsplit to take "-n LogicalVolumeName" on the cmdline. Use clustered mirror log with pvmove in clustered VGs, if available. --- LVM2/test/t-vgsplit-operation.sh 2008/03/21 22:00:29 1.14 +++ LVM2/test/t-vgsplit-operation.sh 2008/04/09 14:47:34 1.15 @@ -56,15 +56,24 @@ # for i in new existing do +# +# We can have PVs or LVs on the cmdline +# +for j in PV LV +do test_expect_success \ - "vgsplit correctly splits single linear LV into $i VG" \ + "vgsplit correctly splits single linear LV into $i VG ($j args)" \ 'vgcreate $vg1 $d1 $d2 && if [ $i == existing ]; then vgcreate $vg2 $d3 $d4 fi && lvcreate -l 4 -n $lv1 $vg1 $d1 && vgchange -an $vg1 && - vgsplit $vg1 $vg2 $d1 && + if [ $j == PV ]; then + vgsplit $vg1 $vg2 $d1 + else + vgsplit -n $lv1 $vg1 $vg2 + fi && vg_validate_pvlv_counts_ $vg1 1 0 0 && if [ $i == existing ]; then vg_validate_pvlv_counts_ $vg2 3 1 0 @@ -76,14 +85,18 @@ vgremove -f $vg1' test_expect_success \ - "vgsplit correctly splits single striped LV into $i VG" \ + "vgsplit correctly splits single striped LV into $i VG ($j args)" \ 'vgcreate $vg1 $d1 $d2 && if [ $i == existing ]; then vgcreate $vg2 $d3 $d4 fi && lvcreate -l 4 -i 2 -n $lv1 $vg1 $d1 $d2 && vgchange -an $vg1 && - vgsplit $vg1 $vg2 $d1 $d2 && + if [ $j == PV ]; then + vgsplit $vg1 $vg2 $d1 $d2 + else + vgsplit -n $lv1 $vg1 $vg2 + fi && if [ $i == existing ]; then vg_validate_pvlv_counts_ $vg2 4 1 0 else @@ -93,43 +106,121 @@ vgremove -f $vg2' test_expect_success \ - "vgsplit correctly splits origin and snapshot LV into $i VG" \ - 'vgcreate $vg1 $d1 $d2 && + "vgsplit correctly splits mirror LV into $i VG ($j args)" \ + 'vgcreate $vg1 $d1 $d2 $d3 && if [ $i == existing ]; then - vgcreate $vg2 $d3 $d4 + vgcreate $vg2 $d4 fi && - lvcreate -l 64 -i 2 -n $lv1 $vg1 $d1 $d2 && - lvcreate -l 4 -i 2 -s -n $lv2 $vg1/$lv1 && + lvcreate -l 64 -m1 -n $lv1 $vg1 $d1 $d2 $d3 && vgchange -an $vg1 && - vgsplit $vg1 $vg2 $d1 $d2 && + if [ $j == PV ]; then + vgsplit $vg1 $vg2 $d1 $d2 $d3 + else + vgsplit -n $lv1 $vg1 $vg2 + fi && if [ $i == existing ]; then - vg_validate_pvlv_counts_ $vg2 4 1 1 + vg_validate_pvlv_counts_ $vg2 4 4 0 else - vg_validate_pvlv_counts_ $vg2 2 1 1 + vg_validate_pvlv_counts_ $vg2 3 4 0 fi && - lvremove -f $vg2/$lv2 && lvremove -f $vg2/$lv1 && vgremove -f $vg2' test_expect_success \ - "vgsplit correctly splits mirror LV into $i VG" \ - 'vgcreate $vg1 $d1 $d2 $d3 && + "vgsplit correctly splits origin and snapshot LV into $i VG ($j args)" \ + 'vgcreate $vg1 $d1 $d2 && if [ $i == existing ]; then - vgcreate $vg2 $d4 + vgcreate $vg2 $d3 $d4 fi && - lvcreate -l 64 -m1 -n $lv1 $vg1 $d1 $d2 $d3 && + lvcreate -l 64 -i 2 -n $lv1 $vg1 $d1 $d2 && + lvcreate -l 4 -i 2 -s -n $lv2 $vg1/$lv1 && vgchange -an $vg1 && - vgsplit $vg1 $vg2 $d1 $d2 $d3 && + if [ $j == PV ]; then + vgsplit $vg1 $vg2 $d1 $d2 + else + vgsplit -n $lv1 $vg1 $vg2 + fi && if [ $i == existing ]; then - vg_validate_pvlv_counts_ $vg2 4 4 0 + vg_validate_pvlv_counts_ $vg2 4 1 1 else - vg_validate_pvlv_counts_ $vg2 3 4 0 + vg_validate_pvlv_counts_ $vg2 2 1 1 fi && + lvremove -f $vg2/$lv2 && lvremove -f $vg2/$lv1 && vgremove -f $vg2' + +done done +# +# Test more complex setups where the code has to find associated PVs and +# LVs to split the VG correctly +# +test_expect_success \ + "vgsplit fails splitting 3 striped LVs into VG when only 1 LV specified" \ + 'vgcreate $vg1 $d1 $d2 $d3 $d4 && + lvcreate -l 4 -n $lv1 -i 2 $vg1 $d1 $d2 && + lvcreate -l 4 -n $lv2 -i 2 $vg1 $d2 $d3 && + lvcreate -l 4 -n $lv3 -i 2 $vg1 $d3 $d4 && + vgchange -an $vg1 && + vgsplit -n $lv1 $vg1 $vg2; + status=$?; echo status=$?; test $status = 5 && + vgremove -ff $vg1' + +test_expect_success \ + "vgsplit fails splitting one LV with 2 snapshots, only origin LV specified" \ + 'vgcreate $vg1 $d1 $d2 $d3 $d4 && + lvcreate -l 16 -n $lv1 $vg1 $d1 $d2 && + lvcreate -l 4 -n $lv2 -s $vg1/$lv1 && + lvcreate -l 4 -n $lv3 -s $vg1/$lv1 && + vg_validate_pvlv_counts_ $vg1 4 1 2 && + vgchange -an $vg1 && + vgsplit -n $lv1 $vg1 $vg2; + status=$?; echo status=$?; test $status = 5 && + lvremove -f $vg1/$lv2 && + lvremove -f $vg1/$lv3 && + lvremove -f $vg1/$lv1 && + vgremove -ff $vg1' + +test_expect_success \ + "vgsplit fails splitting one LV with 2 snapshots, only snapshot LV specified" \ + 'vgcreate $vg1 $d1 $d2 $d3 $d4 && + lvcreate -l 16 -n $lv1 $vg1 $d1 $d2 && + lvcreate -l 4 -n $lv2 -s $vg1/$lv1 && + lvcreate -l 4 -n $lv3 -s $vg1/$lv1 && + vg_validate_pvlv_counts_ $vg1 4 1 2 && + vgchange -an $vg1 && + vgsplit -n $lv2 $vg1 $vg2; + status=$?; echo status=$?; test $status = 5 && + lvremove -f $vg1/$lv2 && + lvremove -f $vg1/$lv3 && + lvremove -f $vg1/$lv1 && + vgremove -ff $vg1' + +test_expect_success \ + "vgsplit fails splitting one mirror LV, only one PV specified" \ + 'vgcreate $vg1 $d1 $d2 $d3 $d4 && + lvcreate -l 16 -n $lv1 -m1 $vg1 $d1 $d2 $d3 && + vg_validate_pvlv_counts_ $vg1 4 4 0 && + vgchange -an $vg1 && + vgsplit $vg1 $vg2 $d2 && + status=$?; echo status=$?; test $status = 5 && + vgremove -ff $vg1' + +test_expect_success \ + "vgsplit fails splitting 1 mirror + 1 striped LV, only striped LV specified" \ + 'vgcreate $vg1 $d1 $d2 $d3 $d4 && + lvcreate -l 16 -n $lv1 -m1 $vg1 $d1 $d2 $d3 && + lvcreate -l 16 -n $lv2 -i 2 $vg1 $d3 $d4 && + vg_validate_pvlv_counts_ $vg1 4 5 0 && + vgchange -an $vg1 && + vgsplit -n $lv2 $vg1 $vg2 2>err; + status=$?; echo status=$?; test $status = 5 && + vgremove -ff $vg1' + + test_done + # Local Variables: # indent-tabs-mode: nil # End: From wysochanski@sourceware.org Wed Apr 9 20:56:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Wed, 09 Apr 2008 20:56:00 -0000 Subject: LVM2 ./WHATS_NEW test/t-vgsplit-operation.sh t ... Message-ID: <20080409205606.25252.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-09 20:56:06 Modified files: . : WHATS_NEW test : t-vgsplit-operation.sh tools : vgsplit.c Log message: Fix vgsplit to only move hidden 'snapshotN' LVs when necessary. This bug has been around for a long time as far as I can tell. Without this fix, a vgsplit would unconditionally move the 'hidden/internal' snapshot LVs, and result in corrupted metadata in the following case: vg1: contains lv1, lv1snap, both on pvset1 vg1: contains lv2, on pvset2 "vgsplit vg1 vg2 pvset2" would result in "snapshot0" hidden LV being moved to vg2, and the origin and cow being left in vg1. The tools detect the corruption in vg2, but not in vg1. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.840&r2=1.841 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-vgsplit-operation.sh.diff?cvsroot=lvm2&r1=1.15&r2=1.16 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.57&r2=1.58 --- LVM2/WHATS_NEW 2008/04/09 14:47:34 1.840 +++ LVM2/WHATS_NEW 2008/04/09 20:56:05 1.841 @@ -1,5 +1,6 @@ Version 2.02.34 - =================================== + Fix vgsplit to only move hidden 'snapshotN' LVs when necessary. Update vgsplit tests for lvnames on the cmdline. Update vgsplit man page to reflect lvnames on the cmdline. Update vgsplit to take "-n LogicalVolumeName" on the cmdline. --- LVM2/test/t-vgsplit-operation.sh 2008/04/09 14:47:34 1.15 +++ LVM2/test/t-vgsplit-operation.sh 2008/04/09 20:56:06 1.16 @@ -149,6 +149,35 @@ lvremove -f $vg2/$lv1 && vgremove -f $vg2' +test_expect_success \ + "vgsplit correctly splits linear LV but not snap+origin LV into $i VG ($j args)" \ + 'vgcreate $vg1 $d1 $d2 && + if [ $i == existing ]; then + vgcreate $vg2 $d3 + fi && + lvcreate -l 64 -i 2 -n $lv1 $vg1 && + lvcreate -l 4 -i 2 -s -n $lv2 $vg1/$lv1 && + vgextend $vg1 $d4 && + lvcreate -l 64 -n $lv3 $vg1 $d4 && + vgchange -an $vg1 && + if [ $j == PV ]; then + vgsplit $vg1 $vg2 $d4 + else + vgsplit -n $lv3 $vg1 $vg2 + fi && + if [ $i == existing ]; then + vg_validate_pvlv_counts_ $vg2 2 1 0 + vg_validate_pvlv_counts_ $vg1 2 1 1 + else + vg_validate_pvlv_counts_ $vg2 1 1 0 + vg_validate_pvlv_counts_ $vg1 2 1 1 + fi && + lvremove -f $vg1/$lv2 && + lvremove -f $vg1/$lv1 && + lvremove -f $vg2/$lv3 && + vgremove -f $vg1 && + vgremove -f $vg2' + done done --- LVM2/tools/vgsplit.c 2008/04/09 13:47:13 1.57 +++ LVM2/tools/vgsplit.c 2008/04/09 20:56:06 1.58 @@ -164,6 +164,9 @@ return 1; } +/* + * Move the hidden / internal "snapshotN" LVs.from 'vg_from' to 'vg_to'. + */ static int _move_snapshots(struct volume_group *vg_from, struct volume_group *vg_to) { @@ -191,14 +194,21 @@ " two Volume Groups", seg->cow->name); return 0; } - } - /* Move this snapshot */ - list_del(lvh); - list_add(&vg_to->lvs, lvh); + /* + * At this point, the cow and origin should already be + * in vg_to. + */ + if (_lv_is_in_vg(vg_to, seg->cow) && + _lv_is_in_vg(vg_to, seg->origin)) { + list_del(lvh); + list_add(&vg_to->lvs, lvh); + + vg_from->snapshot_count--; + vg_to->snapshot_count++; + } + } - vg_from->snapshot_count--; - vg_to->snapshot_count++; } return 1; From wysochanski@sourceware.org Wed Apr 9 21:10:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Wed, 09 Apr 2008 21:10:00 -0000 Subject: LVM2/test t-vgsplit-operation.sh Message-ID: <20080409211013.6627.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-09 21:10:13 Modified files: test : t-vgsplit-operation.sh Log message: Add vgsplit tests to verify mirror is not moved unnecessarily. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-vgsplit-operation.sh.diff?cvsroot=lvm2&r1=1.16&r2=1.17 --- LVM2/test/t-vgsplit-operation.sh 2008/04/09 20:56:06 1.16 +++ LVM2/test/t-vgsplit-operation.sh 2008/04/09 21:10:13 1.17 @@ -20,7 +20,8 @@ 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 -n "$d5" && losetup -d "$d5" + rm -f "$f1" "$f2" "$f3" "$f4" "$f5" } vg_validate_pvlv_counts_() @@ -44,12 +45,13 @@ f2=$(pwd)/2 && d2=$(loop_setup_ "$f2") && f3=$(pwd)/3 && d3=$(loop_setup_ "$f3") && f4=$(pwd)/4 && d4=$(loop_setup_ "$f4") && + f5=$(pwd)/5 && d5=$(loop_setup_ "$f5") && vg1=$(this_test_)-test-vg1-$$ && 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' + pvcreate $d1 $d2 $d3 $d4 $d5' # # vgsplit can be done into a new or existing VG @@ -178,6 +180,33 @@ vgremove -f $vg1 && vgremove -f $vg2' +test_expect_success \ + "vgsplit correctly splits linear LV but not mirror LV into $i VG ($j args)" \ + 'vgcreate $vg1 $d1 $d2 $d3 && + if [ $i == existing ]; then + vgcreate $vg2 $d5 + fi && + lvcreate -l 64 -m1 -n $lv1 $vg1 $d1 $d2 $d3 && + vgextend $vg1 $d4 && + lvcreate -l 64 -n $lv2 $vg1 $d4 && + vgchange -an $vg1 && + if [ $j == PV ]; then + vgsplit $vg1 $vg2 $d4 + else + vgsplit -n $lv2 $vg1 $vg2 + fi && + if [ $i == existing ]; then + vg_validate_pvlv_counts_ $vg1 3 4 0 + vg_validate_pvlv_counts_ $vg2 2 1 0 + else + vg_validate_pvlv_counts_ $vg1 3 4 0 + vg_validate_pvlv_counts_ $vg2 1 1 0 + fi && + lvremove -f $vg1/$lv1 && + lvremove -f $vg2/$lv2 && + vgremove -f $vg1 && + vgremove -f $vg2' + done done From wysochanski@sourceware.org Thu Apr 10 01:06:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Thu, 10 Apr 2008 01:06:00 -0000 Subject: LVM2/test t-lvcreate-usage.sh t-mdata-strings. ... Message-ID: <20080410010649.26097.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-10 01:06:48 Modified files: test : t-lvcreate-usage.sh t-mdata-strings.sh t-vgcreate-usage.sh t-vgmerge-usage.sh t-vgsplit-operation.sh t-vgsplit-usage.sh Log message: Fix lvm tool exit code display in some tests. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvcreate-usage.sh.diff?cvsroot=lvm2&r1=1.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-mdata-strings.sh.diff?cvsroot=lvm2&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-vgcreate-usage.sh.diff?cvsroot=lvm2&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-vgmerge-usage.sh.diff?cvsroot=lvm2&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-vgsplit-operation.sh.diff?cvsroot=lvm2&r1=1.17&r2=1.18 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-vgsplit-usage.sh.diff?cvsroot=lvm2&r1=1.3&r2=1.4 --- LVM2/test/t-lvcreate-usage.sh 2008/01/17 18:05:57 1.4 +++ LVM2/test/t-lvcreate-usage.sh 2008/04/10 01:06:48 1.5 @@ -39,7 +39,7 @@ test_expect_success \ 'lvcreate rejects a negative stripe_size' \ 'lvcreate -L 64M -n $lv -i2 --stripesize -4 $vg 2>err; - status=$?; echo status=$?; test $status = 3 && + status=$?; echo status=$status; test $status = 3 && grep "^ Negative stripesize is invalid\$" err' test_expect_success \ --- LVM2/test/t-mdata-strings.sh 2008/03/12 17:34:58 1.1 +++ LVM2/test/t-mdata-strings.sh 2008/04/10 01:06:48 1.2 @@ -42,7 +42,7 @@ 'no parse errors and VG really exists' \ 'vgs 2>err && grep "Parse error" err; - status=$?; echo status=$?; test $status -ne 0 && + status=$?; echo status=$status; test $status -ne 0 && vgs $vg' test_done --- LVM2/test/t-vgcreate-usage.sh 2008/01/14 21:07:58 1.2 +++ LVM2/test/t-vgcreate-usage.sh 2008/04/10 01:06:48 1.3 @@ -51,32 +51,32 @@ test_expect_success \ 'vgcreate rejects a zero physical extent size' \ 'vgcreate --physicalextentsize 0 $vg $d1 $d2 2>err; - status=$?; echo status=$?; test $status = 3 && + status=$?; echo status=$status; test $status = 3 && grep "^ Physical extent size may not be zero\$" err' test_expect_success \ 'vgcreate rejects "inherit" allocation policy' \ 'vgcreate --alloc inherit $vg $d1 $d2 2>err; - status=$?; echo status=$?; test $status = 3 && + status=$?; echo status=$status; test $status = 3 && grep "^ Volume Group allocation policy cannot inherit from anything\$" err' test_expect_success \ 'vgcreate rejects vgname "."' \ 'vg=.; vgcreate $vg $d1 $d2 2>err; - status=$?; echo status=$?; test $status = 3 && + status=$?; echo status=$status; test $status = 3 && grep "New volume group name \"$vg\" is invalid\$" err' test_expect_success \ 'vgcreate rejects vgname greater than 128 characters' \ 'vginvalid=thisnameisridiculouslylongtotestvalidationcodecheckingmaximumsizethisiswhathappenswhenprogrammersgetboredandorarenotcreativedonttrythisathome; vgcreate $vginvalid $d1 $d2 2>err; - status=$?; echo status=$?; test $status = 3 && + status=$?; echo status=$status; test $status = 3 && grep "New volume group name \"$vginvalid\" is invalid\$" err' test_expect_success \ 'vgcreate rejects already existing vgname "/tmp/$vg"' \ 'touch /tmp/$vg; vgcreate $vg $d1 $d2 2>err; - status=$?; echo status=$?; test $status = 3 && + status=$?; echo status=$status; test $status = 3 && grep "New volume group name \"$vg\" is invalid\$" err' # FIXME: Not sure why this fails @@ -84,7 +84,7 @@ # 'vgcreate rejects MaxLogicalVolumes > 255' \ # 'vgcreate --metadatatype 1 --maxlogicalvolumes 1024 $vg $d1 $d2 2>err; # cp err save; -# status=$?; echo status=$?; test $status = 3 && +# status=$?; echo status=$status; test $status = 3 && # grep "^ Number of volumes may not exceed 255\$" err' test_done --- LVM2/test/t-vgmerge-usage.sh 2008/03/26 18:03:35 1.3 +++ LVM2/test/t-vgmerge-usage.sh 2008/04/10 01:06:48 1.4 @@ -45,7 +45,7 @@ 'vgcreate $vg1 $d1 $d2 && vgcreate $vg2 $d3 $d4 && vgmerge $vg1 $vg1 2>err; - status=$?; echo status=$?; test $status = 5 && + status=$?; echo status=$status; test $status = 5 && grep "^ Duplicate volume group name \"$vg1\"\$" err && vgremove $vg2 && vgremove $vg1' @@ -55,7 +55,7 @@ 'vgcreate --physicalextentsize 4M $vg1 $d1 $d2 && vgcreate --physicalextentsize 8M $vg2 $d3 $d4 && vgmerge $vg1 $vg2 2>err; - status=$?; echo status=$?; test $status = 5 && + status=$?; echo status=$status; test $status = 5 && grep "^ Extent sizes differ" err && vgremove $vg2 && vgremove $vg1' @@ -65,7 +65,7 @@ 'vgcreate --maxphysicalvolumes 2 $vg1 $d1 $d2 && vgcreate --maxphysicalvolumes 2 $vg2 $d3 $d4 && vgmerge $vg1 $vg2 2>err; - status=$?; echo status=$?; test $status = 5 && + status=$?; echo status=$status; test $status = 5 && grep "^ Maximum number of physical volumes (2) exceeded" err && vgremove $vg2 && vgremove $vg1' @@ -76,7 +76,7 @@ vgcreate $vg2 $d3 $d4 && lvcreate -l 4 -n lv1 $vg2 && vgmerge $vg1 $vg2 2>err; - status=$?; echo status=$?; test $status = 5 && + status=$?; echo status=$status; test $status = 5 && grep "^ Logical volumes in \"$vg2\" must be inactive\$" err && vgremove -f $vg2 && vgremove -f $vg1' @@ -91,7 +91,7 @@ vgchange -an $vg1 && vgchange -an $vg2 && vgmerge $vg1 $vg2 2>err; - status=$?; echo status=$?; test $status = 5 && + status=$?; echo status=$status; test $status = 5 && grep "^ Maximum number of logical volumes (2) exceeded" err && vgremove -f $vg2 && vgremove -f $vg1' --- LVM2/test/t-vgsplit-operation.sh 2008/04/09 21:10:13 1.17 +++ LVM2/test/t-vgsplit-operation.sh 2008/04/10 01:06:48 1.18 @@ -222,7 +222,7 @@ lvcreate -l 4 -n $lv3 -i 2 $vg1 $d3 $d4 && vgchange -an $vg1 && vgsplit -n $lv1 $vg1 $vg2; - status=$?; echo status=$?; test $status = 5 && + status=$?; echo status=$status; test $status = 5 && vgremove -ff $vg1' test_expect_success \ @@ -234,7 +234,7 @@ vg_validate_pvlv_counts_ $vg1 4 1 2 && vgchange -an $vg1 && vgsplit -n $lv1 $vg1 $vg2; - status=$?; echo status=$?; test $status = 5 && + status=$?; echo status=$status; test $status = 5 && lvremove -f $vg1/$lv2 && lvremove -f $vg1/$lv3 && lvremove -f $vg1/$lv1 && @@ -249,7 +249,7 @@ vg_validate_pvlv_counts_ $vg1 4 1 2 && vgchange -an $vg1 && vgsplit -n $lv2 $vg1 $vg2; - status=$?; echo status=$?; test $status = 5 && + status=$?; echo status=$status; test $status = 5 && lvremove -f $vg1/$lv2 && lvremove -f $vg1/$lv3 && lvremove -f $vg1/$lv1 && @@ -262,7 +262,7 @@ vg_validate_pvlv_counts_ $vg1 4 4 0 && vgchange -an $vg1 && vgsplit $vg1 $vg2 $d2 && - status=$?; echo status=$?; test $status = 5 && + status=$?; echo status=$status; test $status = 5 && vgremove -ff $vg1' test_expect_success \ @@ -273,7 +273,7 @@ vg_validate_pvlv_counts_ $vg1 4 5 0 && vgchange -an $vg1 && vgsplit -n $lv2 $vg1 $vg2 2>err; - status=$?; echo status=$?; test $status = 5 && + status=$?; echo status=$status; test $status = 5 && vgremove -ff $vg1' --- LVM2/test/t-vgsplit-usage.sh 2008/03/23 15:40:35 1.3 +++ LVM2/test/t-vgsplit-usage.sh 2008/04/10 01:06:48 1.4 @@ -43,7 +43,7 @@ 'vgsplit accepts new vg as destination of split' \ 'vgcreate $vg1 $d1 $d2 && vgsplit $vg1 $vg2 $d1 1>err; - status=$?; echo status=$?; test $status = 0 && + status=$?; echo status=$status; test $status = 0 && grep "New volume group \"$vg2\" successfully split from \"$vg1\"" err && vgremove $vg1 && vgremove $vg2' @@ -53,7 +53,7 @@ 'vgcreate $vg1 $d1 $d2 && vgcreate $vg2 $d3 $d4 && vgsplit $vg1 $vg2 $d1 1>err; - status=$?; echo status=$?; test $status = 0 && + status=$?; echo status=$status; test $status = 0 && grep "Existing volume group \"$vg2\" successfully split from \"$vg1\"" err && vgremove $vg1 && vgremove $vg2' @@ -79,7 +79,7 @@ 'vgcreate --maxphysicalvolumes 2 $vg1 $d1 $d2 && vgcreate --maxphysicalvolumes 2 $vg2 $d3 $d4 && vgsplit $vg1 $vg2 $d1 2>err; - status=$?; echo status=$?; test $status = 5 && + status=$?; echo status=$status; test $status = 5 && grep "^ Maximum number of physical volumes (2) exceeded" err && vgremove $vg2 && vgremove $vg1' @@ -89,7 +89,7 @@ 'vgcreate --maxphysicalvolumes 2 $vg1 $d1 $d2 && vgcreate --maxphysicalvolumes 2 $vg2 $d3 $d4 && vgsplit --maxphysicalvolumes 2 $vg1 $vg2 $d1 2>err; - status=$?; echo status=$?; test $status = 5 && + status=$?; echo status=$status; test $status = 5 && grep "^ Volume group \"$vg2\" exists, but new VG option specified" err && vgremove $vg2 && vgremove $vg1' @@ -99,7 +99,7 @@ 'vgcreate --maxlogicalvolumes 2 $vg1 $d1 $d2 && vgcreate --maxlogicalvolumes 2 $vg2 $d3 $d4 && vgsplit --maxlogicalvolumes 2 $vg1 $vg2 $d1 2>err; - status=$?; echo status=$?; test $status = 5 && + status=$?; echo status=$status; test $status = 5 && grep "^ Volume group \"$vg2\" exists, but new VG option specified" err && vgremove $vg2 && vgremove $vg1' @@ -109,7 +109,7 @@ 'vgcreate --alloc cling $vg1 $d1 $d2 && vgcreate --alloc cling $vg2 $d3 $d4 && vgsplit --alloc cling $vg1 $vg2 $d1 2>err; - status=$?; echo status=$?; test $status = 5 && + status=$?; echo status=$status; test $status = 5 && grep "^ Volume group \"$vg2\" exists, but new VG option specified" err && vgremove $vg2 && vgremove $vg1' @@ -119,7 +119,7 @@ 'vgcreate --clustered n $vg1 $d1 $d2 && vgcreate --clustered n $vg2 $d3 $d4 && vgsplit --clustered n $vg1 $vg2 $d1 2>err; - status=$?; echo status=$?; test $status = 5 && + status=$?; echo status=$status; test $status = 5 && grep "^ Volume group \"$vg2\" exists, but new VG option specified" err && vgremove $vg2 && vgremove $vg1' @@ -131,7 +131,7 @@ vgcreate -M1 $vg1 $d3 $d4 && vgcreate -M2 $vg2 $d1 $d2 && vgsplit $vg1 $vg2 $d3 2>err; - status=$?; echo status=$?; test $status = 5 && + status=$?; echo status=$status; test $status = 5 && grep "^ Metadata types differ" err && vgremove $vg2 && vgremove $vg1' @@ -143,7 +143,7 @@ vgcreate $vg2 $d3 $d4 && lvcreate -l 4 -n $lv1 $vg1 && vgsplit $vg1 $vg2 $d1 2>err; - status=$?; echo status=$?; test $status = 5 && + status=$?; echo status=$status; test $status = 5 && grep "^ Logical volumes in \"$vg1\" must be inactive\$" err && vgremove -f $vg2 && vgremove -f $vg1' @@ -158,7 +158,7 @@ vgchange -an $vg1 && vgchange -an $vg2 && vgsplit $vg1 $vg2 $d1 2>err; - status=$?; echo status=$?; test $status = 5 && + status=$?; echo status=$status; test $status = 5 && grep "^ Maximum number of logical volumes (2) exceeded" err && vgremove -f $vg2 && vgremove -f $vg1' @@ -201,7 +201,7 @@ lvcreate -l 4 -n $lv2 $vg1 && vgchange -an $vg1 && vgsplit $vg1 $vg2 $d3 2>err; - status=$?; echo status=$?; test $status = 5 && + status=$?; echo status=$status; test $status = 5 && vgremove -f $vg2 && vgremove -f $vg1' From wysochanski@sourceware.org Thu Apr 10 01:30:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Thu, 10 Apr 2008 01:30:00 -0000 Subject: LVM2/tools vgsplit.c Message-ID: <20080410013022.10906.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-10 01:30:22 Modified files: tools : vgsplit.c Log message: Add _move_one_lv() helper function for vgsplit. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.58&r2=1.59 --- LVM2/tools/vgsplit.c 2008/04/09 20:56:06 1.58 +++ LVM2/tools/vgsplit.c 2008/04/10 01:30:22 1.59 @@ -93,6 +93,25 @@ return 0; } +static int _move_one_lv(struct volume_group *vg_from, + struct volume_group *vg_to, + struct list *lvh) +{ + struct logical_volume *lv; + + lv = list_item(lvh, struct lv_list)->lv; + list_del(lvh); + list_add(&vg_to->lvs, lvh); + + if (lv->status & SNAPSHOT) { + vg_from->snapshot_count--; + vg_to->snapshot_count++; + } else { + vg_from->lv_count--; + vg_to->lv_count++; + } + return 1; +} static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to) { @@ -152,11 +171,8 @@ continue; /* Move this LV */ - list_del(lvh); - list_add(&vg_to->lvs, lvh); - - vg_from->lv_count--; - vg_to->lv_count++; + if (!_move_one_lv(vg_from, vg_to, lvh)) + return 0; } /* FIXME Ensure no LVs contain segs pointing at LVs in the other VG */ @@ -201,11 +217,8 @@ */ if (_lv_is_in_vg(vg_to, seg->cow) && _lv_is_in_vg(vg_to, seg->origin)) { - list_del(lvh); - list_add(&vg_to->lvs, lvh); - - vg_from->snapshot_count--; - vg_to->snapshot_count++; + if (!_move_one_lv(vg_from, vg_to, lvh)) + return 0; } } @@ -246,11 +259,8 @@ } if (seg_in == seg->area_count && log_in) { - list_del(lvh); - list_add(&vg_to->lvs, lvh); - - vg_from->lv_count--; - vg_to->lv_count++; + if (!_move_one_lv(vg_from, vg_to, lvh)) + return 0; } } From wysochanski@sourceware.org Thu Apr 10 02:15:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Thu, 10 Apr 2008 02:15:00 -0000 Subject: LVM2/tools vgsplit.c Message-ID: <20080410021556.2212.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-10 02:15:56 Modified files: tools : vgsplit.c Log message: Minor vgsplit cleanups. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.59&r2=1.60 --- LVM2/tools/vgsplit.c 2008/04/10 01:30:22 1.59 +++ LVM2/tools/vgsplit.c 2008/04/10 02:15:56 1.60 @@ -33,7 +33,7 @@ vg_from->pv_count--; vg_to->pv_count++; - pv = list_item(pvl, struct pv_list)->pv; + pv = pvl->pv; vg_from->extent_count -= pv_pe_count(pv); vg_to->extent_count += pv_pe_count(pv); @@ -100,8 +100,7 @@ struct logical_volume *lv; lv = list_item(lvh, struct lv_list)->lv; - list_del(lvh); - list_add(&vg_to->lvs, lvh); + list_move(lvh, &vg_to->lvs); if (lv->status & SNAPSHOT) { vg_from->snapshot_count--; From wysochanski@sourceware.org Thu Apr 10 17:09:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Thu, 10 Apr 2008 17:09:00 -0000 Subject: LVM2 ./WHATS_NEW lib/activate/dev_manager.c li ... Message-ID: <20080410170939.2786.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-10 17:09:32 Modified files: . : WHATS_NEW lib/activate : dev_manager.c lib/display : display.c lib/format1 : import-export.c lib/locking : locking.h lib/metadata : lv_manip.c metadata-exported.h metadata.c lib/mirror : mirrored.c lib/report : report.c tools : lvchange.c lvcreate.c pvmove.c vgchange.c vgsplit.c Log message: Add vg_is_clustered() helper function. Should be no functional change. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.841&r2=1.842 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/dev_manager.c.diff?cvsroot=lvm2&r1=1.135&r2=1.136 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/display/display.c.diff?cvsroot=lvm2&r1=1.87&r2=1.88 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/import-export.c.diff?cvsroot=lvm2&r1=1.95&r2=1.96 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.38&r2=1.39 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.152&r2=1.153 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.46&r2=1.47 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.167&r2=1.168 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.53&r2=1.54 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.77&r2=1.78 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvchange.c.diff?cvsroot=lvm2&r1=1.89&r2=1.90 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvcreate.c.diff?cvsroot=lvm2&r1=1.173&r2=1.174 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/pvmove.c.diff?cvsroot=lvm2&r1=1.52&r2=1.53 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgchange.c.diff?cvsroot=lvm2&r1=1.63&r2=1.64 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.60&r2=1.61 --- LVM2/WHATS_NEW 2008/04/09 20:56:05 1.841 +++ LVM2/WHATS_NEW 2008/04/10 17:09:29 1.842 @@ -1,5 +1,6 @@ Version 2.02.34 - =================================== + Add vg_is_clustered() helper function. Fix vgsplit to only move hidden 'snapshotN' LVs when necessary. Update vgsplit tests for lvnames on the cmdline. Update vgsplit man page to reflect lvnames on the cmdline. --- LVM2/lib/activate/dev_manager.c 2008/04/07 10:23:46 1.135 +++ LVM2/lib/activate/dev_manager.c 2008/04/10 17:09:30 1.136 @@ -836,7 +836,7 @@ /* If this is a snapshot origin, add real LV */ if (lv_is_origin(seg->lv) && !layer) { - if (seg->lv->vg->status & CLUSTERED) { + if (vg_is_clustered(seg->lv->vg)) { log_error("Clustered snapshots are not yet supported"); return 0; } --- LVM2/lib/display/display.c 2008/03/26 16:48:10 1.87 +++ LVM2/lib/display/display.c 2008/04/10 17:09:31 1.88 @@ -602,7 +602,7 @@ /* vg number not part of LVM2 design log_print ("VG # %u\n", vg->vg_number); */ - if (vg->status & CLUSTERED) { + if (vg_is_clustered(vg)) { log_print("Clustered yes"); log_print("Shared %s", vg->status & SHARED ? "yes" : "no"); --- LVM2/lib/format1/import-export.c 2008/02/06 15:47:27 1.95 +++ LVM2/lib/format1/import-export.c 2008/04/10 17:09:31 1.96 @@ -271,7 +271,7 @@ if (vg->status & LVM_WRITE) vgd->vg_access |= VG_WRITE; - if (vg->status & CLUSTERED) + if (vg_is_clustered(vg)) vgd->vg_access |= VG_CLUSTERED; if (vg->status & SHARED) --- LVM2/lib/locking/locking.h 2008/04/09 12:56:34 1.38 +++ LVM2/lib/locking/locking.h 2008/04/10 17:09:31 1.39 @@ -99,7 +99,7 @@ #define LCK_LV_DEACTIVATE (LCK_LV | LCK_NULL | LCK_NONBLOCK) #define LCK_LV_CLUSTERED(lv) \ - (((lv)->vg->status & CLUSTERED) ? LCK_CLUSTER_VG : 0) + (vg_is_clustered((lv)->vg) ? LCK_CLUSTER_VG : 0) #define lock_lv_vol(cmd, lv, flags) \ lock_vol(cmd, (lv)->lvid.s, flags | LCK_LV_CLUSTERED(lv)) --- LVM2/lib/metadata/lv_manip.c 2008/03/28 19:08:23 1.152 +++ LVM2/lib/metadata/lv_manip.c 2008/04/10 17:09:31 1.153 @@ -1983,7 +1983,7 @@ * 1) Clustered VG, and some remote nodes have the LV active * 2) Non-clustered VG, but LV active locally */ - if ((vg_status(vg) & CLUSTERED) && !activate_lv_excl(cmd, lv) && + if (vg_is_clustered(vg) && !activate_lv_excl(cmd, lv) && (force == PROMPT)) { if (yes_no_prompt("Logical volume \"%s\" is active on other " "cluster nodes. Really remove? [y/n]: ", --- LVM2/lib/metadata/metadata-exported.h 2008/03/26 16:48:10 1.46 +++ LVM2/lib/metadata/metadata-exported.h 2008/04/10 17:09:31 1.47 @@ -544,6 +544,7 @@ uint32_t pv_pe_alloc_count(const pv_t *pv); uint32_t vg_status(const vg_t *vg); +#define vg_is_clustered(vg) (vg_status((vg)) & CLUSTERED) struct vgcreate_params { char *vg_name; --- LVM2/lib/metadata/metadata.c 2008/04/08 12:49:20 1.167 +++ LVM2/lib/metadata/metadata.c 2008/04/10 17:09:31 1.168 @@ -1124,7 +1124,7 @@ } /* Clustering attribute must be the same */ - if ((vg_to->status & CLUSTERED) != (vg_from->status & CLUSTERED)) { + if (vg_is_clustered(vg_to) != vg_is_clustered(vg_from)) { log_error("Clustered attribute differs for \"%s\" and \"%s\"", vg_to->name, vg_from->name); return 0; @@ -2102,7 +2102,7 @@ int vg_check_status(const struct volume_group *vg, uint32_t status) { if ((status & CLUSTERED) && - (vg->status & CLUSTERED) && !locking_is_clustered() && + (vg_is_clustered(vg)) && !locking_is_clustered() && !lockingfailed()) { log_error("Skipping clustered volume group %s", vg->name); return 0; @@ -2240,7 +2240,6 @@ return vg->status; } - /** * pv_by_path - Given a device path return a PV handle if it is a PV * @cmd - handle to the LVM command instance --- LVM2/lib/mirror/mirrored.c 2008/04/07 10:23:46 1.53 +++ LVM2/lib/mirror/mirrored.c 2008/04/10 17:09:31 1.54 @@ -237,7 +237,7 @@ * in clustered VG. */ if ((!(seg->lv->status & ACTIVATE_EXCL) && - (seg->lv->vg->status & CLUSTERED))) + (vg_is_clustered(seg->lv->vg)))) clustered = 1; if (seg->log_lv) { @@ -519,7 +519,7 @@ !list_segment_modules(mem, first_seg(seg->log_lv), modules)) return_0; - if ((seg->lv->vg->status & CLUSTERED) && + if (vg_is_clustered(seg->lv->vg) && !str_list_add(mem, modules, "clog")) { log_error("cluster log string list allocation failed"); return 0; --- LVM2/lib/report/report.c 2008/02/06 15:47:28 1.77 +++ LVM2/lib/report/report.c 2008/04/10 17:09:32 1.78 @@ -439,7 +439,7 @@ repstr[4] = _alloc_policy_char(vg->alloc); - if (vg->status & CLUSTERED) + if (vg_is_clustered(vg)) repstr[5] = 'c'; else repstr[5] = '-'; --- LVM2/tools/lvchange.c 2008/01/30 14:00:01 1.89 +++ LVM2/tools/lvchange.c 2008/04/10 17:09:32 1.90 @@ -35,7 +35,7 @@ return 0; } - if ((lv->status & MIRRORED) && (lv->vg->status & CLUSTERED) && + if ((lv->status & MIRRORED) && (vg_is_clustered(lv->vg)) && lv_info(cmd, lv, &info, 0, 0) && info.exists) { log_error("Cannot change permissions of mirror \"%s\" " "while active.", lv->name); @@ -119,7 +119,7 @@ if (!deactivate_lv(cmd, lv)) return_0; } else { - if (lockingfailed() && (lv->vg->status & CLUSTERED)) { + if (lockingfailed() && (vg_is_clustered(lv->vg))) { log_verbose("Locking failed: ignoring clustered " "logical volume %s", lv->name); return 0; @@ -221,7 +221,7 @@ } } - if ((lv->vg->status & CLUSTERED) && !activate_lv_excl(cmd, lv)) { + if (vg_is_clustered(lv->vg) && !activate_lv_excl(cmd, lv)) { log_error("Can't get exclusive access to clustered volume %s", lv->name); return ECMD_FAILED; @@ -236,7 +236,7 @@ log_very_verbose("Starting resync of %s%s%s mirror \"%s\"", (active) ? "active " : "", - (lv->vg->status & CLUSTERED) ? "clustered " : "", + vg_is_clustered(lv->vg) ? "clustered " : "", (log_lv) ? "disk-logged" : "core-logged", lv->name); --- LVM2/tools/lvcreate.c 2008/04/07 10:23:47 1.173 +++ LVM2/tools/lvcreate.c 2008/04/10 17:09:32 1.174 @@ -638,7 +638,7 @@ return 0; } /* FIXME Allow exclusive activation. */ - if (vg_status(vg) & CLUSTERED) { + if (vg_is_clustered(vg)) { log_error("Clustered snapshots are not yet supported."); return 0; } --- LVM2/tools/pvmove.c 2008/04/09 12:56:34 1.52 +++ LVM2/tools/pvmove.c 2008/04/10 17:09:32 1.53 @@ -49,7 +49,7 @@ static unsigned _pvmove_is_exclusive(struct cmd_context *cmd, struct volume_group *vg) { - if (vg_status(vg) & CLUSTERED) + if (vg_is_clustered(vg)) if (!_pvmove_target_present(cmd, 1)) return 1; --- LVM2/tools/vgchange.c 2008/01/30 14:00:02 1.63 +++ LVM2/tools/vgchange.c 2008/04/10 17:09:32 1.64 @@ -134,7 +134,7 @@ return ECMD_FAILED; } - if (activate && lockingfailed() && (vg_status(vg) & CLUSTERED)) { + if (activate && lockingfailed() && (vg_is_clustered(vg))) { log_error("Locking inactive: ignoring clustered " "volume group %s", vg->name); return ECMD_FAILED; @@ -243,13 +243,13 @@ int clustered = !strcmp(arg_str_value(cmd, clustered_ARG, "n"), "y"); struct lv_list *lvl; - if (clustered && (vg_status(vg) & CLUSTERED)) { + if (clustered && (vg_is_clustered(vg))) { log_error("Volume group \"%s\" is already clustered", vg->name); return ECMD_FAILED; } - if (!clustered && !(vg_status(vg) & CLUSTERED)) { + if (!clustered && !(vg_is_clustered(vg))) { log_error("Volume group \"%s\" is already not clustered", vg->name); return ECMD_FAILED; --- LVM2/tools/vgsplit.c 2008/04/10 02:15:56 1.60 +++ LVM2/tools/vgsplit.c 2008/04/10 17:09:32 1.61 @@ -379,7 +379,7 @@ vp_new.alloc, 0, NULL))) goto bad; - if (vg_from->status & CLUSTERED) + if (vg_is_clustered(vg_from)) vg_to->status |= CLUSTERED; } From agk@sourceware.org Thu Apr 10 17:19:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 10 Apr 2008 17:19:00 -0000 Subject: LVM2 ./WHATS_NEW lib/display/display.c lib/rep ... Message-ID: <20080410171903.5361.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-10 17:19:02 Modified files: . : WHATS_NEW lib/display : display.c lib/report : columns.h report.c Log message: Fix vgdisplay 'Cur LV' field to match lvdisplay output. Fix lv_count report field to exclude hidden LVs. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.842&r2=1.843 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/display/display.c.diff?cvsroot=lvm2&r1=1.88&r2=1.89 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/columns.h.diff?cvsroot=lvm2&r1=1.27&r2=1.28 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.78&r2=1.79 --- LVM2/WHATS_NEW 2008/04/10 17:09:29 1.842 +++ LVM2/WHATS_NEW 2008/04/10 17:19:02 1.843 @@ -1,5 +1,7 @@ Version 2.02.34 - =================================== + Fix vgdisplay 'Cur LV' field to match lvdisplay output. + Fix lv_count report field to exclude hidden LVs. Add vg_is_clustered() helper function. Fix vgsplit to only move hidden 'snapshotN' LVs when necessary. Update vgsplit tests for lvnames on the cmdline. --- LVM2/lib/display/display.c 2008/04/10 17:09:31 1.88 +++ LVM2/lib/display/display.c 2008/04/10 17:19:02 1.89 @@ -574,6 +574,8 @@ { uint32_t access; uint32_t active_pvs; + uint32_t lv_count = 0; + struct lv_list *lvl; char uuid[64] __attribute((aligned(8))); if (vg->status & PARTIAL_VG) @@ -607,8 +609,13 @@ log_print("Shared %s", vg->status & SHARED ? "yes" : "no"); } + + list_iterate_items(lvl, &vg->lvs) + if (lv_is_visible(lvl->lv) && !(lvl->lv->status & SNAPSHOT)) + lv_count++; + log_print("MAX LV %u", vg->max_lv); - log_print("Cur LV %u", vg->lv_count + vg->snapshot_count); + log_print("Cur LV %u", lv_count); log_print("Open LV %u", lvs_in_vg_opened(vg)); /****** FIXME Max LV Size log_print ( "MAX LV Size %s", @@ -652,6 +659,8 @@ void vgdisplay_colons(const struct volume_group *vg) { uint32_t active_pvs; + uint32_t lv_count; + struct lv_list *lvl; const char *access; char uuid[64] __attribute((aligned(8))); @@ -660,6 +669,10 @@ else active_pvs = vg->pv_count; + list_iterate_items(lvl, &vg->lvs) + if (lv_is_visible(lvl->lv) || (lvl->lv->status & SNAPSHOT)) + lv_count++; + switch (vg->status & (LVM_READ | LVM_WRITE)) { case LVM_READ | LVM_WRITE: access = "r/w"; --- LVM2/lib/report/columns.h 2008/01/10 18:35:51 1.27 +++ LVM2/lib/report/columns.h 2008/04/10 17:19:02 1.28 @@ -66,7 +66,7 @@ FIELD(VGS, vg, NUM, "MaxLV", max_lv, 5, uint32, "max_lv", "Maximum number of LVs allowed in VG or 0 if unlimited.") FIELD(VGS, vg, NUM, "MaxPV", max_pv, 5, uint32, "max_pv", "Maximum number of PVs allowed in VG or 0 if unlimited.") FIELD(VGS, vg, NUM, "#PV", pv_count, 3, uint32, "pv_count", "Number of PVs.") -FIELD(VGS, vg, NUM, "#LV", lv_count, 3, uint32, "lv_count", "Number of LVs.") +FIELD(VGS, vg, NUM, "#LV", cmd, 3, lvcount, "lv_count", "Number of LVs.") FIELD(VGS, vg, NUM, "#SN", snapshot_count, 3, uint32, "snap_count", "Number of snapshots.") FIELD(VGS, vg, NUM, "Seq", seqno, 3, uint32, "vg_seqno", "Revision number of internal metadata. Incremented whenever it changes.") FIELD(VGS, vg, STR, "VG Tags", tags, 7, tags, "vg_tags", "Tags, if any.") --- LVM2/lib/report/report.c 2008/04/10 17:09:32 1.78 +++ LVM2/lib/report/report.c 2008/04/10 17:19:02 1.79 @@ -899,6 +899,21 @@ return _size64_disp(rh, mem, field, &freespace, private); } +static int _lvcount_disp(struct dm_report *rh, struct dm_pool *mem, + struct dm_report_field *field, + const void *data, void *private) +{ + const struct volume_group *vg = (const struct volume_group *) data; + struct lv_list *lvl; + uint32_t count = 0; + + list_iterate_items(lvl, &vg->lvs) + if (lv_is_visible(lvl->lv) && !(lvl->lv->status & SNAPSHOT)) + count++; + + return _uint32_disp(rh, mem, field, &count, private); +} + static int _lvsegcount_disp(struct dm_report *rh, struct dm_pool *mem, struct dm_report_field *field, const void *data, void *private) From agk@sourceware.org Thu Apr 10 18:19:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 10 Apr 2008 18:19:00 -0000 Subject: LVM2 VERSION WHATS_NEW Message-ID: <20080410181951.5186.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-10 18:19:50 Modified files: . : VERSION WHATS_NEW Log message: pre-release Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/VERSION.diff?cvsroot=lvm2&r1=1.168&r2=1.169 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.843&r2=1.844 --- LVM2/VERSION 2008/01/31 12:41:13 1.168 +++ LVM2/VERSION 2008/04/10 18:19:49 1.169 @@ -1 +1 @@ -2.02.34-cvs (2008-01-31) +2.02.34-cvs (2008-04-10) --- LVM2/WHATS_NEW 2008/04/10 17:19:02 1.843 +++ LVM2/WHATS_NEW 2008/04/10 18:19:49 1.844 @@ -1,5 +1,5 @@ -Version 2.02.34 - -=================================== +Version 2.02.34 - 10th April 2008 +================================= Fix vgdisplay 'Cur LV' field to match lvdisplay output. Fix lv_count report field to exclude hidden LVs. Add vg_is_clustered() helper function. From agk@sourceware.org Thu Apr 10 18:50:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 10 Apr 2008 18:50:00 -0000 Subject: LVM2/man lvm.conf.5 Message-ID: <20080410185003.17911.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-10 18:50:02 Modified files: man : lvm.conf.5 Log message: . Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/man/lvm.conf.5.diff?cvsroot=lvm2&r1=1.21&r2=1.22 --- LVM2/man/lvm.conf.5 2008/02/04 20:26:14 1.21 +++ LVM2/man/lvm.conf.5 2008/04/10 18:50:02 1.22 @@ -84,7 +84,7 @@ \fBpreferred_names\fP \(em List of patterns compared in turn against all the pathnames referencing the same device in in the scanned directories. The pathname that matches the earliest pattern in the list is the -one used in any output. As an example, if device mapper multipathing +one used in any output. As an example, if device-mapper multipathing is used, the following will select multipath device names: .br \fBdevices { preferred_names = [ "^/dev/mapper/mpath" ] }\fP From agk@sourceware.org Thu Apr 10 18:50:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 10 Apr 2008 18:50:00 -0000 Subject: LVM2/doc example.conf Message-ID: <20080410185037.18181.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-10 18:50:37 Modified files: doc : example.conf Log message: . Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/doc/example.conf.diff?cvsroot=lvm2&r1=1.35&r2=1.36 --- LVM2/doc/example.conf 2008/02/11 16:57:40 1.35 +++ LVM2/doc/example.conf 2008/04/10 18:50:37 1.36 @@ -25,9 +25,8 @@ # list of regular expressions in turn and the first match is used. preferred_names = [ ] - # If device-mapper multipath is used, more descriptive names might - # be preferred over the dm-N names: - # preferred_names = [ "^/dev/mapper/mpath" ] + # Try to avoid using undescriptive /dev/dm-N names, if present. + # preferred_names = [ "^/dev/mpath/", "^/dev/mapper/mpath", "^/dev/[hs]d" ] # A filter that tells LVM2 to only use a restricted set of devices. # The filter consists of an array of regular expressions. These From agk@sourceware.org Thu Apr 10 18:51:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 10 Apr 2008 18:51:00 -0000 Subject: LVM2 WHATS_NEW Message-ID: <20080410185117.18413.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-10 18:51:16 Modified files: . : WHATS_NEW Log message: . Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.844&r2=1.845 --- LVM2/WHATS_NEW 2008/04/10 18:19:49 1.844 +++ LVM2/WHATS_NEW 2008/04/10 18:51:16 1.845 @@ -1,5 +1,6 @@ Version 2.02.34 - 10th April 2008 ================================= + Improve preferred_names lvm.conf example. Fix vgdisplay 'Cur LV' field to match lvdisplay output. Fix lv_count report field to exclude hidden LVs. Add vg_is_clustered() helper function. From agk@sourceware.org Thu Apr 10 18:53:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 10 Apr 2008 18:53:00 -0000 Subject: LVM2/lib/mirror mirrored.c Message-ID: <20080410185336.18841.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-10 18:53:36 Modified files: lib/mirror : mirrored.c Log message: . Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/mirror/mirrored.c.diff?cvsroot=lvm2&r1=1.54&r2=1.55 --- LVM2/lib/mirror/mirrored.c 2008/04/10 17:09:31 1.54 +++ LVM2/lib/mirror/mirrored.c 2008/04/10 18:53:36 1.55 @@ -373,7 +373,7 @@ /* * Check only for modules if atttributes requested and no previous check. - * FIXME: need better check + * FIXME: Fails incorrectly if cmirror was built into kernel. */ if (attributes) { if (!_mirror_attributes && module_present("cmirror")) From wysochanski@sourceware.org Thu Apr 10 18:55:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Thu, 10 Apr 2008 18:55:00 -0000 Subject: LVM2/test t-vgsplit-operation.sh Message-ID: <20080410185541.19230.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-10 18:55:41 Modified files: test : t-vgsplit-operation.sh Log message: Update vgsplit tests that count LVs for adjusted LV counting. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-vgsplit-operation.sh.diff?cvsroot=lvm2&r1=1.18&r2=1.19 --- LVM2/test/t-vgsplit-operation.sh 2008/04/10 01:06:48 1.18 +++ LVM2/test/t-vgsplit-operation.sh 2008/04/10 18:55:40 1.19 @@ -121,9 +121,9 @@ vgsplit -n $lv1 $vg1 $vg2 fi && if [ $i == existing ]; then - vg_validate_pvlv_counts_ $vg2 4 4 0 + vg_validate_pvlv_counts_ $vg2 4 1 0 else - vg_validate_pvlv_counts_ $vg2 3 4 0 + vg_validate_pvlv_counts_ $vg2 3 1 0 fi && lvremove -f $vg2/$lv1 && vgremove -f $vg2' @@ -143,9 +143,9 @@ vgsplit -n $lv1 $vg1 $vg2 fi && if [ $i == existing ]; then - vg_validate_pvlv_counts_ $vg2 4 1 1 + vg_validate_pvlv_counts_ $vg2 4 2 1 else - vg_validate_pvlv_counts_ $vg2 2 1 1 + vg_validate_pvlv_counts_ $vg2 2 2 1 fi && lvremove -f $vg2/$lv2 && lvremove -f $vg2/$lv1 && @@ -169,10 +169,10 @@ fi && if [ $i == existing ]; then vg_validate_pvlv_counts_ $vg2 2 1 0 - vg_validate_pvlv_counts_ $vg1 2 1 1 + vg_validate_pvlv_counts_ $vg1 2 2 1 else vg_validate_pvlv_counts_ $vg2 1 1 0 - vg_validate_pvlv_counts_ $vg1 2 1 1 + vg_validate_pvlv_counts_ $vg1 2 2 1 fi && lvremove -f $vg1/$lv2 && lvremove -f $vg1/$lv1 && @@ -196,10 +196,10 @@ vgsplit -n $lv2 $vg1 $vg2 fi && if [ $i == existing ]; then - vg_validate_pvlv_counts_ $vg1 3 4 0 + vg_validate_pvlv_counts_ $vg1 3 2 0 vg_validate_pvlv_counts_ $vg2 2 1 0 else - vg_validate_pvlv_counts_ $vg1 3 4 0 + vg_validate_pvlv_counts_ $vg1 3 2 0 vg_validate_pvlv_counts_ $vg2 1 1 0 fi && lvremove -f $vg1/$lv1 && @@ -231,7 +231,7 @@ lvcreate -l 16 -n $lv1 $vg1 $d1 $d2 && lvcreate -l 4 -n $lv2 -s $vg1/$lv1 && lvcreate -l 4 -n $lv3 -s $vg1/$lv1 && - vg_validate_pvlv_counts_ $vg1 4 1 2 && + vg_validate_pvlv_counts_ $vg1 4 3 2 && vgchange -an $vg1 && vgsplit -n $lv1 $vg1 $vg2; status=$?; echo status=$status; test $status = 5 && @@ -246,7 +246,7 @@ lvcreate -l 16 -n $lv1 $vg1 $d1 $d2 && lvcreate -l 4 -n $lv2 -s $vg1/$lv1 && lvcreate -l 4 -n $lv3 -s $vg1/$lv1 && - vg_validate_pvlv_counts_ $vg1 4 1 2 && + vg_validate_pvlv_counts_ $vg1 4 3 2 && vgchange -an $vg1 && vgsplit -n $lv2 $vg1 $vg2; status=$?; echo status=$status; test $status = 5 && @@ -270,7 +270,7 @@ 'vgcreate $vg1 $d1 $d2 $d3 $d4 && lvcreate -l 16 -n $lv1 -m1 $vg1 $d1 $d2 $d3 && lvcreate -l 16 -n $lv2 -i 2 $vg1 $d3 $d4 && - vg_validate_pvlv_counts_ $vg1 4 5 0 && + vg_validate_pvlv_counts_ $vg1 4 2 0 && vgchange -an $vg1 && vgsplit -n $lv2 $vg1 $vg2 2>err; status=$?; echo status=$status; test $status = 5 && From agk@sourceware.org Thu Apr 10 19:14:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 10 Apr 2008 19:14:00 -0000 Subject: LVM2 lib/datastruct/list.c lib/datastruct/list ... Message-ID: <20080410191428.4201.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-10 19:14:27 Modified files: lib/datastruct : list.c list.h lib/metadata : metadata.c tools : vgmerge.c vgsplit.c Log message: make list_move consistent with other list fns Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/datastruct/list.c.diff?cvsroot=lvm2&r1=1.3&r2=1.4 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/datastruct/list.h.diff?cvsroot=lvm2&r1=1.26&r2=1.27 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.168&r2=1.169 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgmerge.c.diff?cvsroot=lvm2&r1=1.46&r2=1.47 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.61&r2=1.62 --- LVM2/lib/datastruct/list.c 2007/08/20 20:55:24 1.3 +++ LVM2/lib/datastruct/list.c 2008/04/10 19:14:26 1.4 @@ -66,6 +66,15 @@ } /* + * Remove an element from existing list and insert before 'head'. + */ +void list_move(struct list *head, struct list *elem) +{ + list_del(elem); + list_add(head, elem); +} + +/* * Is the list empty? */ int list_empty(const struct list *head) --- LVM2/lib/datastruct/list.h 2008/03/26 16:20:54 1.26 +++ LVM2/lib/datastruct/list.h 2008/04/10 19:14:26 1.27 @@ -55,14 +55,9 @@ void list_del(struct list *elem); /* - * Move an element from an existing list to list 'head'. - * Insert the element before 'head'. + * Remove an element from existing list and insert before 'head'. */ -static inline void list_move(struct list *item, struct list *head) -{ - list_del(item); - list_add(head, item); -} +void list_move(struct list *head, struct list *elem); /* * Is the list empty? --- LVM2/lib/metadata/metadata.c 2008/04/10 17:09:31 1.168 +++ LVM2/lib/metadata/metadata.c 2008/04/10 19:14:26 1.169 @@ -716,7 +716,7 @@ if (is_orphan_vg(vg_to->name)) list_del(&mda->list); else - list_move(&mda->list, mdas_to); + list_move(mdas_to, &mda->list); } } --- LVM2/tools/vgmerge.c 2008/03/26 17:26:32 1.46 +++ LVM2/tools/vgmerge.c 2008/04/10 19:14:26 1.47 @@ -54,7 +54,7 @@ struct list *pvh = vg_from->pvs.n; struct physical_volume *pv; - list_move(pvh, &vg_to->pvs); + list_move(&vg_to->pvs, pvh); pv = list_item(pvh, struct pv_list)->pv; pv->vg_name = dm_pool_strdup(cmd->mem, vg_to->name); @@ -89,13 +89,13 @@ while (!list_empty(&vg_from->lvs)) { struct list *lvh = vg_from->lvs.n; - list_move(lvh, &vg_to->lvs); + list_move(&vg_to->lvs, lvh); } while (!list_empty(&vg_from->fid->metadata_areas)) { struct list *mdah = vg_from->fid->metadata_areas.n; - list_move(mdah, &vg_to->fid->metadata_areas); + list_move(&vg_to->fid->metadata_areas, mdah); } vg_to->lv_count += vg_from->lv_count; --- LVM2/tools/vgsplit.c 2008/04/10 17:09:32 1.61 +++ LVM2/tools/vgsplit.c 2008/04/10 19:14:27 1.62 @@ -28,7 +28,7 @@ return 0; } - list_move(&pvl->list, &vg_to->pvs); + list_move(&vg_to->pvs, &pvl->list); vg_from->pv_count--; vg_to->pv_count++; @@ -100,7 +100,7 @@ struct logical_volume *lv; lv = list_item(lvh, struct lv_list)->lv; - list_move(lvh, &vg_to->lvs); + list_move(&vg_to->lvs, lvh); if (lv->status & SNAPSHOT) { vg_from->snapshot_count--; From agk@sourceware.org Thu Apr 10 19:16:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 10 Apr 2008 19:16:00 -0000 Subject: LVM2/lib/display display.c Message-ID: <20080410191637.5360.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-10 19:16:35 Modified files: lib/display : display.c Log message: fix 3rd copy Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/display/display.c.diff?cvsroot=lvm2&r1=1.89&r2=1.90 --- LVM2/lib/display/display.c 2008/04/10 17:19:02 1.89 +++ LVM2/lib/display/display.c 2008/04/10 19:16:35 1.90 @@ -670,7 +670,7 @@ active_pvs = vg->pv_count; list_iterate_items(lvl, &vg->lvs) - if (lv_is_visible(lvl->lv) || (lvl->lv->status & SNAPSHOT)) + if (lv_is_visible(lvl->lv) && !(lvl->lv->status & SNAPSHOT)) lv_count++; switch (vg->status & (LVM_READ | LVM_WRITE)) { From agk@sourceware.org Thu Apr 10 19:59:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 10 Apr 2008 19:59:00 -0000 Subject: LVM2 lib/metadata/metadata.c test/t-lvresize-u ... Message-ID: <20080410195947.1963.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-10 19:59:43 Modified files: lib/metadata : metadata.c test : t-lvresize-usage.sh t-vgmerge-operation.sh t-vgsplit-usage.sh tools : lvresize.c toollib.c vgsplit.c Log message: more pre-release cleanup Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.169&r2=1.170 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-lvresize-usage.sh.diff?cvsroot=lvm2&r1=1.1&r2=1.2 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-vgmerge-operation.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.4&r2=1.5 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.95&r2=1.96 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/toollib.c.diff?cvsroot=lvm2&r1=1.132&r2=1.133 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.62&r2=1.63 --- LVM2/lib/metadata/metadata.c 2008/04/10 19:14:26 1.169 +++ LVM2/lib/metadata/metadata.c 2008/04/10 19:59:42 1.170 @@ -885,6 +885,7 @@ list_iterate_items(pvl, pl) if (pvl->pv == pv) return pvl; + return NULL; } @@ -957,6 +958,7 @@ list_iterate_items(lvl, ll) if (lvl->lv == lv) return lvl; + return NULL; } --- LVM2/test/t-lvresize-usage.sh 2008/04/02 12:17:30 1.1 +++ LVM2/test/t-lvresize-usage.sh 2008/04/10 19:59:43 1.2 @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2007 Red Hat, Inc. All rights reserved. +# Copyright (C) 2007-2008 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions --- LVM2/test/t-vgmerge-operation.sh 2008/03/26 18:03:35 1.1 +++ LVM2/test/t-vgmerge-operation.sh 2008/04/10 19:59:43 1.2 @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2007 Red Hat, Inc. All rights reserved. +# Copyright (C) 2007-2008 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions --- LVM2/test/t-vgsplit-usage.sh 2008/04/10 01:06:48 1.4 +++ LVM2/test/t-vgsplit-usage.sh 2008/04/10 19:59:43 1.5 @@ -1,5 +1,5 @@ #!/bin/sh -# Copyright (C) 2007 Red Hat, Inc. All rights reserved. +# Copyright (C) 2007-2008 Red Hat, Inc. All rights reserved. # # This copyrighted material is made available to anyone wishing to use, # modify, copy, or redistribute it subject to the terms and conditions --- LVM2/tools/lvresize.c 2008/04/02 12:17:30 1.95 +++ LVM2/tools/lvresize.c 2008/04/10 19:59:43 1.96 @@ -229,8 +229,8 @@ argv++; argc--; - if (!(lp->lv_name = skip_dev_dir(cmd, lp->lv_name, &dev_dir_found)) - || (!(lp->vg_name = extract_vgname(cmd, lp->lv_name)))) { + if (!(lp->lv_name = skip_dev_dir(cmd, lp->lv_name, &dev_dir_found)) || + !(lp->vg_name = extract_vgname(cmd, lp->lv_name))) { log_error("Please provide a volume group name"); return 0; } @@ -269,6 +269,7 @@ uint32_t sz, str; struct list *pvh = NULL; char size_buf[SIZE_BUF]; + char lv_path[PATH_MAX]; /* does LV exist? */ if (!(lvl = find_lv_in_vg(vg, lp->lv_name))) { @@ -623,8 +624,6 @@ log_print("Logical volume %s successfully resized", lp->lv_name); if (lp->resizefs && (lp->resize == LV_EXTEND)) { - char lv_path[PATH_MAX]; - if (dm_snprintf(lv_path, PATH_MAX, "%s%s/%s", cmd->dev_dir, lp->vg_name, lp->lv_name) < 0) { log_error("Couldn't create LV path for %s", --- LVM2/tools/toollib.c 2008/03/25 15:24:59 1.132 +++ LVM2/tools/toollib.c 2008/04/10 19:59:43 1.133 @@ -1245,8 +1245,6 @@ return rc; } - - /* * Set members of struct vgcreate_params from cmdline. * Do preliminary validation with arg_*() interface. --- LVM2/tools/vgsplit.c 2008/04/10 19:14:27 1.62 +++ LVM2/tools/vgsplit.c 2008/04/10 19:59:43 1.63 @@ -93,13 +93,12 @@ return 0; } -static int _move_one_lv(struct volume_group *vg_from, - struct volume_group *vg_to, - struct list *lvh) +static void _move_one_lv(struct volume_group *vg_from, + struct volume_group *vg_to, + struct list *lvh) { - struct logical_volume *lv; + struct logical_volume *lv = list_item(lvh, struct lv_list)->lv; - lv = list_item(lvh, struct lv_list)->lv; list_move(&vg_to->lvs, lvh); if (lv->status & SNAPSHOT) { @@ -109,7 +108,6 @@ vg_from->lv_count--; vg_to->lv_count++; } - return 1; } static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to) @@ -170,8 +168,7 @@ continue; /* Move this LV */ - if (!_move_one_lv(vg_from, vg_to, lvh)) - return 0; + _move_one_lv(vg_from, vg_to, lvh); } /* FIXME Ensure no LVs contain segs pointing at LVs in the other VG */ @@ -215,10 +212,8 @@ * in vg_to. */ if (_lv_is_in_vg(vg_to, seg->cow) && - _lv_is_in_vg(vg_to, seg->origin)) { - if (!_move_one_lv(vg_from, vg_to, lvh)) - return 0; - } + _lv_is_in_vg(vg_to, seg->origin)) + _move_one_lv(vg_from, vg_to, lvh); } } @@ -344,10 +339,10 @@ if (new_vg_option_specified(cmd)) { log_error("Volume group \"%s\" exists, but new VG " "option specified", vg_name_to); - goto bad; + goto_bad; } if (!vgs_are_compatible(cmd, vg_from,vg_to)) - goto bad; + goto_bad; } else { existing_vg = 0; @@ -377,7 +372,7 @@ if (!(vg_to = vg_create(cmd, vg_name_to, vp_new.extent_size, vp_new.max_pv, vp_new.max_lv, vp_new.alloc, 0, NULL))) - goto bad; + goto_bad; if (vg_is_clustered(vg_from)) vg_to->status |= CLUSTERED; @@ -385,41 +380,39 @@ /* Archive vg_from before changing it */ if (!archive(vg_from)) - goto bad; + goto_bad; /* Move PVs across to new structure */ for (opt = 0; opt < argc; opt++) { if (!_move_pv(vg_from, vg_to, argv[opt])) - goto bad; + goto_bad; } /* If an LV given on the cmdline, move used_by PVs */ - if (lv_name) { - if (!_move_pvs_used_by_lv(vg_from, vg_to, lv_name)) - goto bad; - } + if (lv_name && !_move_pvs_used_by_lv(vg_from, vg_to, lv_name)) + goto_bad; /* Move required LVs across, checking consistency */ if (!(_move_lvs(vg_from, vg_to))) - goto bad; + goto_bad; /* Move required snapshots across */ if (!(_move_snapshots(vg_from, vg_to))) - goto bad; + goto_bad; /* Move required mirrors across */ if (!(_move_mirrors(vg_from, vg_to))) - goto bad; + goto_bad; /* Split metadata areas and check if both vgs have at least one area */ if (!(vg_split_mdas(cmd, vg_from, vg_to)) && vg_from->pv_count) { log_error("Cannot split: Nowhere to store metadata for new Volume Group"); - goto bad; + goto_bad; } /* Set proper name for all PVs in new VG */ if (!vg_rename(cmd, vg_to, vg_name_to)) - goto bad; + goto_bad; /* store it on disks */ log_verbose("Writing out updated volume groups"); @@ -434,21 +427,21 @@ vg_to->status |= EXPORTED_VG; if (!archive(vg_to)) - goto bad; + goto_bad; if (!vg_write(vg_to) || !vg_commit(vg_to)) - goto bad; + goto_bad; backup(vg_to); /* * Next, write out the updated old VG. If we crash after this point, * recovery is a vgimport on the new VG. - * FIXME: recover automatically or instruct the user the user? + * FIXME: recover automatically or instruct the user? */ if (vg_from->pv_count) { if (!vg_write(vg_from) || !vg_commit(vg_from)) - goto bad; + goto_bad; backup(vg_from); } @@ -458,17 +451,17 @@ */ consistent = 1; if (!test_mode() && - (!(vg_to = vg_read(cmd, vg_name_to, NULL, &consistent)) - || !consistent)) { + (!(vg_to = vg_read(cmd, vg_name_to, NULL, &consistent)) || + !consistent)) { log_error("Volume group \"%s\" became inconsistent: please " "fix manually", vg_name_to); - goto bad; + goto_bad; } vg_to->status &= ~EXPORTED_VG; if (!vg_write(vg_to) || !vg_commit(vg_to)) - goto bad; + goto_bad; backup(vg_to); From agk@sourceware.org Thu Apr 10 20:02:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 10 Apr 2008 20:02:00 -0000 Subject: LVM2/tools vgsplit.c Message-ID: <20080410200204.7718.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-10 20:02:04 Modified files: tools : vgsplit.c Log message: . Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.63&r2=1.64 --- LVM2/tools/vgsplit.c 2008/04/10 19:59:43 1.63 +++ LVM2/tools/vgsplit.c 2008/04/10 20:02:04 1.64 @@ -252,10 +252,8 @@ return 0; } - if (seg_in == seg->area_count && log_in) { - if (!_move_one_lv(vg_from, vg_to, lvh)) - return 0; - } + if (seg_in == seg->area_count && log_in) + _move_one_lv(vg_from, vg_to, lvh); } return 1; From agk@sourceware.org Thu Apr 10 20:07:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 10 Apr 2008 20:07:00 -0000 Subject: LVM2 VERSION WHATS_NEW Message-ID: <20080410200719.25173.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-10 20:07:19 Modified files: . : VERSION WHATS_NEW Log message: post-release Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/VERSION.diff?cvsroot=lvm2&r1=1.169&r2=1.170 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.845&r2=1.846 --- LVM2/VERSION 2008/04/10 18:19:49 1.169 +++ LVM2/VERSION 2008/04/10 20:07:18 1.170 @@ -1 +1 @@ -2.02.34-cvs (2008-04-10) +2.02.35-cvs (2008-04-10) --- LVM2/WHATS_NEW 2008/04/10 18:51:16 1.845 +++ LVM2/WHATS_NEW 2008/04/10 20:07:19 1.846 @@ -1,3 +1,6 @@ +Version 2.02.35 - +================================= + Version 2.02.34 - 10th April 2008 ================================= Improve preferred_names lvm.conf example. From wysochanski@sourceware.org Thu Apr 10 21:34:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Thu, 10 Apr 2008 21:34:00 -0000 Subject: LVM2/tools vgsplit.c Message-ID: <20080410213454.14213.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-10 21:34:53 Modified files: tools : vgsplit.c Log message: Update vgsplit to only restrict split with active LVs involved in split. Existing code will reject a vgsplit if any LVs in the source VG are active. This patch updates vgsplit to only check LVs involved in the split. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.64&r2=1.65 --- LVM2/tools/vgsplit.c 2008/04/10 20:02:04 1.64 +++ LVM2/tools/vgsplit.c 2008/04/10 21:34:53 1.65 @@ -93,7 +93,7 @@ return 0; } -static void _move_one_lv(struct volume_group *vg_from, +static int _move_one_lv(struct volume_group *vg_from, struct volume_group *vg_to, struct list *lvh) { @@ -101,6 +101,11 @@ list_move(&vg_to->lvs, lvh); + if (lv_is_active(lv)) { + log_error("Logical volume \"%s\" must be inactive", lv->name); + return 0; + } + if (lv->status & SNAPSHOT) { vg_from->snapshot_count--; vg_to->snapshot_count++; @@ -108,6 +113,7 @@ vg_from->lv_count--; vg_to->lv_count++; } + return 1; } static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to) @@ -168,7 +174,8 @@ continue; /* Move this LV */ - _move_one_lv(vg_from, vg_to, lvh); + if (!_move_one_lv(vg_from, vg_to, lvh)) + return 0; } /* FIXME Ensure no LVs contain segs pointing at LVs in the other VG */ @@ -212,8 +219,10 @@ * in vg_to. */ if (_lv_is_in_vg(vg_to, seg->cow) && - _lv_is_in_vg(vg_to, seg->origin)) - _move_one_lv(vg_from, vg_to, lvh); + _lv_is_in_vg(vg_to, seg->origin)) { + if (!_move_one_lv(vg_from, vg_to, lvh)) + return 0; + } } } @@ -252,8 +261,10 @@ return 0; } - if (seg_in == seg->area_count && log_in) - _move_one_lv(vg_from, vg_to, lvh); + if (seg_in == seg->area_count && log_in) { + if (!_move_one_lv(vg_from, vg_to, lvh)) + return 0; + } } return 1; @@ -277,7 +288,6 @@ char *vg_name_from, *vg_name_to; struct volume_group *vg_to, *vg_from; int opt; - int active; int existing_vg; int consistent; const char *lv_name; @@ -316,14 +326,6 @@ CORRECT_INCONSISTENT | FAIL_INCONSISTENT))) return ECMD_FAILED; - if ((active = lvs_in_vg_activated(vg_from))) { - /* FIXME Remove this restriction */ - log_error("Logical volumes in \"%s\" must be inactive", - vg_name_from); - unlock_vg(cmd, vg_name_from); - return ECMD_FAILED; - } - log_verbose("Checking for new volume group \"%s\"", vg_name_to); if (!lock_vol(cmd, vg_name_to, LCK_VG_WRITE | LCK_NONBLOCK)) { log_error("Can't get lock for %s", vg_name_to); From wysochanski@sourceware.org Thu Apr 10 21:34:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Thu, 10 Apr 2008 21:34:00 -0000 Subject: LVM2/lib/activate activate.c activate.h Message-ID: <20080410213419.14041.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-10 21:34:18 Modified files: lib/activate : activate.c activate.h Log message: Add lv_is_active() to determine whether an lv is active. Handles non-clustered as well as clustered. For clustered, the best we can do is try exclusive local activation. If this succeeds, we know it is not active elsewhere in the cluster. Otherwise, we assume it is active elsewhere. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.c.diff?cvsroot=lvm2&r1=1.134&r2=1.135 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/activate/activate.h.diff?cvsroot=lvm2&r1=1.60&r2=1.61 --- LVM2/lib/activate/activate.c 2008/04/07 10:23:46 1.134 +++ LVM2/lib/activate/activate.c 2008/04/10 21:34:18 1.135 @@ -674,6 +674,38 @@ } /* + * Determine whether an LV is active locally or in a cluster. + * Assumes vg lock held. + * Returns: + * 0 - not active locally or on any node in cluster + * 1 - active either locally or some node in the cluster + */ +int lv_is_active(struct logical_volume *lv) +{ + if (_lv_active(lv->vg->cmd, lv, 0)) + return 1; + + if (!vg_is_clustered(lv->vg)) + return 0; + + /* + * FIXME: Cluster does not report per-node LV activation status. + * Currently the best we can do is try exclusive local activation. + * If that succeeds, we know the LV is not active elsewhere in the + * cluster. + */ + if (activate_lv_excl(lv->vg->cmd, lv)) { + deactivate_lv(lv->vg->cmd, lv); + return 0; + } + + /* + * Exclusive local activation failed so assume it is active elsewhere. + */ + return 1; +} + +/* * Returns 0 if an attempt to (un)monitor the device failed. * Returns 1 otherwise. */ --- LVM2/lib/activate/activate.h 2008/04/07 10:23:46 1.60 +++ LVM2/lib/activate/activate.h 2008/04/10 21:34:18 1.61 @@ -91,6 +91,7 @@ int lvs_in_vg_activated_by_uuid_only(struct volume_group *vg); int lvs_in_vg_opened(const struct volume_group *vg); +int lv_is_active(struct logical_volume *lv); int monitor_dev_for_events(struct cmd_context *cmd, struct logical_volume *lv, int do_reg); From wysochanski@sourceware.org Thu Apr 10 21:38:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Thu, 10 Apr 2008 21:38:00 -0000 Subject: LVM2 ./WHATS_NEW test/t-vgsplit-operation.sh Message-ID: <20080410213852.15899.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-10 21:38:52 Modified files: . : WHATS_NEW test : t-vgsplit-operation.sh Log message: Update vgsplit test to verify loosening of active LV restriction. This and prior 2 commits resolve Red Hat bz 252041: Ability to vgsplit an active Volume Group where the split involves only inactive LVs Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.846&r2=1.847 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-vgsplit-operation.sh.diff?cvsroot=lvm2&r1=1.19&r2=1.20 --- LVM2/WHATS_NEW 2008/04/10 20:07:19 1.846 +++ LVM2/WHATS_NEW 2008/04/10 21:38:52 1.847 @@ -1,5 +1,8 @@ Version 2.02.35 - ================================= + Update vgsplit tests to verify loosening of active LV restriction. + Update vgsplit to only restrict split with active LVs involved in split. + Add lv_is_active() to determine whether an lv is active. Version 2.02.34 - 10th April 2008 ================================= --- LVM2/test/t-vgsplit-operation.sh 2008/04/10 18:55:40 1.19 +++ LVM2/test/t-vgsplit-operation.sh 2008/04/10 21:38:52 1.20 @@ -276,6 +276,65 @@ status=$?; echo status=$status; test $status = 5 && vgremove -ff $vg1' +# +# Verify vgsplit rejects active LVs only when active LVs involved in split +# +test_expect_success \ + "vgsplit fails, active mirror involved in split" \ + 'vgcreate $vg1 $d1 $d2 $d3 $d4 && + lvcreate -l 16 -n $lv1 -m1 $vg1 $d1 $d2 $d3 && + lvcreate -l 16 -n $lv2 $vg1 $d4 && + lvchange -an $vg1/$lv2 && + vg_validate_pvlv_counts_ $vg1 4 2 0 && + vgsplit -n $lv1 $vg1 $vg2; + status=$?; echo status=$status; test $status = 5 && + vg_validate_pvlv_counts_ $vg1 4 2 0 && + vgremove -ff $vg1' + +test_expect_success \ + "vgsplit succeeds, active mirror not involved in split" \ + 'vgcreate $vg1 $d1 $d2 $d3 $d4 && + lvcreate -l 16 -n $lv1 -m1 $vg1 $d1 $d2 $d3 && + lvcreate -l 16 -n $lv2 $vg1 $d4 && + lvchange -an $vg1/$lv2 && + vg_validate_pvlv_counts_ $vg1 4 2 0 && + vgsplit -n $lv2 $vg1 $vg2 && + vg_validate_pvlv_counts_ $vg1 3 1 0 && + vg_validate_pvlv_counts_ $vg2 1 1 0 && + vgremove -ff $vg1 && + vgremove -ff $vg2' + +test_expect_success \ + "vgsplit fails, active snapshot involved in split" \ + 'vgcreate $vg1 $d1 $d2 $d3 $d4 && + lvcreate -l 64 -i 2 -n $lv1 $vg1 $d1 $d2 && + lvcreate -l 4 -i 2 -s -n $lv2 $vg1/$lv1 && + lvcreate -l 64 -i 2 -n $lv3 $vg1 $d3 $d4 && + lvchange -an $vg1/$lv3 && + vg_validate_pvlv_counts_ $vg1 4 3 1 && + vgsplit -n $lv2 $vg1 $vg2; + status=$?; echo status=$status; test $status = 5 && + vg_validate_pvlv_counts_ $vg1 4 3 1 && + lvremove -f $vg1/$lv2 && + vgremove -ff $vg1' + +test_expect_success \ + "vgsplit succeeds, active snapshot not involved in split" \ + 'vgcreate $vg1 $d1 $d2 $d3 && + lvcreate -l 64 -i 2 -n $lv1 $vg1 $d1 $d2 && + lvcreate -l 4 -s -n $lv2 $vg1/$lv1 && + vgextend $vg1 $d4 && + lvcreate -l 64 -n $lv3 $vg1 $d4 && + lvchange -an $vg1/$lv3 && + vg_validate_pvlv_counts_ $vg1 4 3 1 && + vgsplit -n $lv3 $vg1 $vg2 && + vg_validate_pvlv_counts_ $vg1 3 2 1 && + vg_validate_pvlv_counts_ $vg2 1 1 0 && + vgchange -an $vg1 && + lvremove -f $vg1/$lv2 && + vgremove -ff $vg1 && + vgremove -ff $vg2' + test_done From wysochanski@sourceware.org Fri Apr 11 14:06:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Fri, 11 Apr 2008 14:06:00 -0000 Subject: LVM2/test lvm-utils.sh t-vgmerge-operation.sh ... Message-ID: <20080411140617.22959.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-11 14:06:16 Modified files: test : lvm-utils.sh t-vgmerge-operation.sh t-vgsplit-operation.sh Log message: Fix vgsplit and vgmerge tests for updated lv counting. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lvm-utils.sh.diff?cvsroot=lvm2&r1=1.9&r2=1.10 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-vgmerge-operation.sh.diff?cvsroot=lvm2&r1=1.2&r2=1.3 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-vgsplit-operation.sh.diff?cvsroot=lvm2&r1=1.20&r2=1.21 --- LVM2/test/lvm-utils.sh 2008/03/28 18:02:22 1.9 +++ LVM2/test/lvm-utils.sh 2008/04/11 14:06:16 1.10 @@ -86,6 +86,18 @@ return $(test $(lvs --noheadings -o $2 $1) == $3) } +vg_validate_pvlv_counts_() +{ + local local_vg=$1 + local num_pvs=$2 + local num_lvs=$3 + local num_snaps=$4 + + check_vg_field_ $local_vg pv_count $num_pvs && + check_vg_field_ $local_vg lv_count $num_lvs && + check_vg_field_ $local_vg snap_count $num_snaps +} + dmsetup_has_dm_devdir_support_() { # Detect support for the envvar. If it's supported, the --- LVM2/test/t-vgmerge-operation.sh 2008/04/10 19:59:43 1.2 +++ LVM2/test/t-vgmerge-operation.sh 2008/04/11 14:06:16 1.3 @@ -23,18 +23,6 @@ rm -f "$f1" "$f2" "$f3" "$f4" } -vg_validate_pvlv_counts_() -{ - local local_vg=$1 - local num_pvs=$2 - local num_lvs=$3 - local num_snaps=$4 - - check_vg_field_ $local_vg pv_count $num_pvs && - check_vg_field_ $local_vg lv_count $num_lvs && - check_vg_field_ $local_vg snap_count $num_snaps -} - test_expect_success \ 'set up temp files, loopback devices, PVs, vgnames' \ 'f1=$(pwd)/1 && d1=$(loop_setup_ "$f1") && @@ -81,10 +69,10 @@ lvcreate -l 16 -n $lv1 $vg1 && lvcreate -l 4 -s -n $lv2 $vg1/$lv1 && vgchange -an $vg1 && - vg_validate_pvlv_counts_ $vg1 2 1 1 && + vg_validate_pvlv_counts_ $vg1 2 2 1 && vg_validate_pvlv_counts_ $vg2 2 0 0 && vgmerge $vg2 $vg1 && - vg_validate_pvlv_counts_ $vg2 4 1 1 && + vg_validate_pvlv_counts_ $vg2 4 2 1 && lvremove -f $vg2/$lv2 && vgremove -f $vg2' @@ -94,10 +82,10 @@ vgcreate $vg2 $d4 && lvcreate -l 4 -n $lv1 -m1 $vg1 && vgchange -an $vg1 && - vg_validate_pvlv_counts_ $vg1 3 4 0 && + vg_validate_pvlv_counts_ $vg1 3 1 0 && vg_validate_pvlv_counts_ $vg2 1 0 0 && vgmerge $vg2 $vg1 && - vg_validate_pvlv_counts_ $vg2 4 4 0 && + vg_validate_pvlv_counts_ $vg2 4 1 0 && lvremove -f $vg2/$lv1 && vgremove -f $vg2' --- LVM2/test/t-vgsplit-operation.sh 2008/04/10 21:38:52 1.20 +++ LVM2/test/t-vgsplit-operation.sh 2008/04/11 14:06:16 1.21 @@ -24,18 +24,6 @@ rm -f "$f1" "$f2" "$f3" "$f4" "$f5" } -vg_validate_pvlv_counts_() -{ - local local_vg=$1 - local num_pvs=$2 - local num_lvs=$3 - local num_snaps=$4 - - check_vg_field_ $local_vg pv_count $num_pvs && - check_vg_field_ $local_vg lv_count $num_lvs && - check_vg_field_ $local_vg snap_count $num_snaps -} - # FIXME: paramaterize lvm1 vs lvm2 metadata; most of these tests should run # fine with lvm1 metadata as well; for now, just add disks 5 and 6 as lvm1 # metadata From agk@sourceware.org Mon Apr 14 19:24:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Mon, 14 Apr 2008 19:24:00 -0000 Subject: LVM2 ./WHATS_NEW lib/cache/lvmcache.c lib/cach ... Message-ID: <20080414192417.1011.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-14 19:24:16 Modified files: . : WHATS_NEW lib/cache : lvmcache.c lvmcache.h Log message: Don't store fid in VG metadata cache to avoid clvmd segfault. (2.02.34) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.847&r2=1.848 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.43&r2=1.44 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.20&r2=1.21 --- LVM2/WHATS_NEW 2008/04/10 21:38:52 1.847 +++ LVM2/WHATS_NEW 2008/04/14 19:24:15 1.848 @@ -1,5 +1,6 @@ Version 2.02.35 - ================================= + Don't store fid in VG metadata cache to avoid clvmd segfault. (2.02.34) Update vgsplit tests to verify loosening of active LV restriction. Update vgsplit to only restrict split with active LVs involved in split. Add lv_is_active() to determine whether an lv is active. --- LVM2/lib/cache/lvmcache.c 2008/04/08 12:49:20 1.43 +++ LVM2/lib/cache/lvmcache.c 2008/04/14 19:24:15 1.44 @@ -63,7 +63,6 @@ dm_free(vginfo->vgmetadata); vginfo->vgmetadata = NULL; - vginfo->fid = NULL; log_debug("Metadata cache: VG %s wiped.", vginfo->vgname); } @@ -81,7 +80,6 @@ return; } - vginfo->fid = vg->fid; vginfo->precommitted = precommitted; log_debug("Metadata cache: VG %s stored (%d bytes%s).", vginfo->vgname, @@ -400,6 +398,7 @@ { struct lvmcache_vginfo *vginfo; struct volume_group *vg; + struct format_instance *fid; if (!vgid || !(vginfo = vginfo_from_vgid(vgid)) || !vginfo->vgmetadata) return NULL; @@ -411,7 +410,12 @@ (!precommitted && vginfo->precommitted)) return NULL; - if (!(vg = import_vg_from_buffer(vginfo->vgmetadata, vginfo->fid)) || + fid = vginfo->fmt->ops->create_instance(vginfo->fmt, vginfo->vgname, + vgid, NULL); + if (!fid) + return NULL; + + if (!(vg = import_vg_from_buffer(vginfo->vgmetadata, fid)) || !vg_validate(vg)) { _free_cached_vgmetadata(vginfo); return_NULL; --- LVM2/lib/cache/lvmcache.h 2008/04/08 12:49:20 1.20 +++ LVM2/lib/cache/lvmcache.h 2008/04/14 19:24:16 1.21 @@ -45,7 +45,6 @@ struct lvmcache_vginfo *next; /* Another VG with same name? */ char *creation_host; char *vgmetadata; /* Copy of VG metadata as format_text string */ - struct format_instance *fid; /* fid associated with vgmetadata */ unsigned precommitted; /* Is vgmetadata live or precommitted? */ }; From agk@sourceware.org Mon Apr 14 19:49:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Mon, 14 Apr 2008 19:49:00 -0000 Subject: LVM2 ./WHATS_NEW lib/locking/cluster_locking.c Message-ID: <20080414194913.15694.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-14 19:49:13 Modified files: . : WHATS_NEW lib/locking : cluster_locking.c Log message: Don't attempt remote metadata backups of non-clustered VGs. (2.02.29) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.848&r2=1.849 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/cluster_locking.c.diff?cvsroot=lvm2&r1=1.25&r2=1.26 --- LVM2/WHATS_NEW 2008/04/14 19:24:15 1.848 +++ LVM2/WHATS_NEW 2008/04/14 19:49:12 1.849 @@ -1,5 +1,6 @@ Version 2.02.35 - ================================= + Don't attempt remote metadata backups of non-clustered VGs. (2.02.29) Don't store fid in VG metadata cache to avoid clvmd segfault. (2.02.34) Update vgsplit tests to verify loosening of active LV restriction. Update vgsplit to only restrict split with active LVs involved in split. --- LVM2/lib/locking/cluster_locking.c 2008/01/30 13:59:59 1.25 +++ LVM2/lib/locking/cluster_locking.c 2008/04/14 19:49:12 1.26 @@ -438,8 +438,10 @@ return 0; } - /* If we are unlocking a VG, then trigger remote metadata backups */ - if (cluster_cmd == CLVMD_CMD_LOCK_VG && ((flags & LCK_TYPE_MASK) == LCK_UNLOCK)) { + /* If we are unlocking a clustered VG, then trigger remote metadata backups */ + if (cluster_cmd == CLVMD_CMD_LOCK_VG && + ((flags & LCK_TYPE_MASK) == LCK_UNLOCK) && + (flags & LCK_CLUSTER_VG)) { log_very_verbose("Requesing backup of VG metadata for %s", resource); _lock_for_cluster(CLVMD_CMD_VG_BACKUP, LCK_CLUSTER_VG, resource); } From agk@sourceware.org Tue Apr 15 11:36:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 15 Apr 2008 11:36:00 -0000 Subject: LVM2 ./WHATS_NEW daemons/clvmd/clvmd-command.c ... Message-ID: <20080415113647.3794.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-15 11:36:46 Modified files: . : WHATS_NEW daemons/clvmd : clvmd-command.c lib/locking : cluster_locking.c Log message: rename P_global to P_#global Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.849&r2=1.850 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-command.c.diff?cvsroot=lvm2&r1=1.19&r2=1.20 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/cluster_locking.c.diff?cvsroot=lvm2&r1=1.26&r2=1.27 --- LVM2/WHATS_NEW 2008/04/14 19:49:12 1.849 +++ LVM2/WHATS_NEW 2008/04/15 11:36:46 1.850 @@ -1,5 +1,6 @@ Version 2.02.35 - ================================= + Rename P_global to P_#global. Don't attempt remote metadata backups of non-clustered VGs. (2.02.29) Don't store fid in VG metadata cache to avoid clvmd segfault. (2.02.34) Update vgsplit tests to verify loosening of active LV restriction. --- LVM2/daemons/clvmd/clvmd-command.c 2007/12/04 15:39:26 1.19 +++ LVM2/daemons/clvmd/clvmd-command.c 2008/04/15 11:36:46 1.20 @@ -118,8 +118,8 @@ lockname = &args[2]; /* Check to see if the VG is in use by LVM1 */ status = do_check_lvm1(lockname); - /* P_global causes a cache refresh */ - if (strcmp(lockname, "P_global") == 0) + /* P_#global causes a cache refresh */ + if (strcmp(lockname, "P_#global") == 0) do_refresh_cache(); break; --- LVM2/lib/locking/cluster_locking.c 2008/04/14 19:49:12 1.26 +++ LVM2/lib/locking/cluster_locking.c 2008/04/15 11:36:46 1.27 @@ -390,7 +390,7 @@ if (!*resource) /* FIXME Deprecated */ dm_snprintf(lockname, sizeof(lockname), "P_orphans"); else if (*resource == '#') - dm_snprintf(lockname, sizeof(lockname), "P_%s", resource + 1); + dm_snprintf(lockname, sizeof(lockname), "P_%s", resource); else dm_snprintf(lockname, sizeof(lockname), "V_%s", resource); From mbroz@sourceware.org Tue Apr 15 14:46:00 2008 From: mbroz@sourceware.org (mbroz@sourceware.org) Date: Tue, 15 Apr 2008 14:46:00 -0000 Subject: LVM2 ./WHATS_NEW daemons/clvmd/clvmd-command.c ... Message-ID: <20080415144620.20263.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: mbroz@sourceware.org 2008-04-15 14:46:19 Modified files: . : WHATS_NEW daemons/clvmd : clvmd-command.c lib/cache : lvmcache.c lvmcache.h lib/locking : cluster_locking.c file_locking.c locking.c locking.h lib/metadata : metadata.c Log message: Drop cached VG metadata before and after committing changes to it. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.850&r2=1.851 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-command.c.diff?cvsroot=lvm2&r1=1.20&r2=1.21 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.44&r2=1.45 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.h.diff?cvsroot=lvm2&r1=1.21&r2=1.22 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/cluster_locking.c.diff?cvsroot=lvm2&r1=1.27&r2=1.28 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/file_locking.c.diff?cvsroot=lvm2&r1=1.36&r2=1.37 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.c.diff?cvsroot=lvm2&r1=1.46&r2=1.47 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/locking/locking.h.diff?cvsroot=lvm2&r1=1.39&r2=1.40 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.170&r2=1.171 --- LVM2/WHATS_NEW 2008/04/15 11:36:46 1.850 +++ LVM2/WHATS_NEW 2008/04/15 14:46:18 1.851 @@ -1,5 +1,6 @@ Version 2.02.35 - ================================= + Drop cached VG metadata before and after committing changes to it. Rename P_global to P_#global. Don't attempt remote metadata backups of non-clustered VGs. (2.02.29) Don't store fid in VG metadata cache to avoid clvmd segfault. (2.02.34) --- LVM2/daemons/clvmd/clvmd-command.c 2008/04/15 11:36:46 1.20 +++ LVM2/daemons/clvmd/clvmd-command.c 2008/04/15 14:46:18 1.21 @@ -121,6 +121,8 @@ /* P_#global causes a cache refresh */ if (strcmp(lockname, "P_#global") == 0) do_refresh_cache(); + else if (strncmp(lockname, "P_", 2) == 0) + lvmcache_drop_metadata(lockname + 2); break; --- LVM2/lib/cache/lvmcache.c 2008/04/14 19:24:15 1.44 +++ LVM2/lib/cache/lvmcache.c 2008/04/15 14:46:18 1.45 @@ -130,6 +130,16 @@ _update_cache_vginfo_lock_state(vginfo, locked); } +void lvmcache_drop_metadata(const char *vgname) +{ + struct lvmcache_vginfo *vginfo; + + if (!(vginfo = vginfo_from_vgname(vgname, NULL))) + return; + + _free_cached_vgmetadata(vginfo); +} + void lvmcache_lock_vgname(const char *vgname, int read_only __attribute((unused))) { if (!_lock_hash && !lvmcache_init()) { --- LVM2/lib/cache/lvmcache.h 2008/04/14 19:24:16 1.21 +++ LVM2/lib/cache/lvmcache.h 2008/04/15 14:46:18 1.22 @@ -111,5 +111,6 @@ /* Returns cached volume group metadata. */ struct volume_group *lvmcache_get_vg(const char *vgid, unsigned precommitted); +void lvmcache_drop_metadata(const char *vgname); #endif --- LVM2/lib/locking/cluster_locking.c 2008/04/15 11:36:46 1.27 +++ LVM2/lib/locking/cluster_locking.c 2008/04/15 14:46:19 1.28 @@ -389,7 +389,7 @@ /* If the VG name is empty then lock the unused PVs */ if (!*resource) /* FIXME Deprecated */ dm_snprintf(lockname, sizeof(lockname), "P_orphans"); - else if (*resource == '#') + else if (*resource == '#' || (flags & LCK_CACHE)) dm_snprintf(lockname, sizeof(lockname), "P_%s", resource); else dm_snprintf(lockname, sizeof(lockname), "V_%s", --- LVM2/lib/locking/file_locking.c 2008/04/07 19:17:29 1.36 +++ LVM2/lib/locking/file_locking.c 2008/04/15 14:46:19 1.37 @@ -21,6 +21,7 @@ #include "defaults.h" #include "lvm-file.h" #include "lvm-string.h" +#include "lvmcache.h" #include #include @@ -209,6 +210,10 @@ switch (flags & LCK_SCOPE_MASK) { case LCK_VG: + if (flags & LCK_CACHE) { + lvmcache_drop_metadata(resource); + break; + } if (!*resource) /* FIXME Deprecated */ dm_snprintf(lockfile, sizeof(lockfile), "%s/P_orphans", _lock_dir); --- LVM2/lib/locking/locking.c 2008/04/09 12:56:34 1.46 +++ LVM2/lib/locking/locking.c 2008/04/15 14:46:19 1.47 @@ -324,7 +324,8 @@ assert(resource); if ((ret = _locking.lock_resource(cmd, resource, flags))) { - if ((flags & LCK_SCOPE_MASK) == LCK_VG) { + if ((flags & LCK_SCOPE_MASK) == LCK_VG && + !(flags & LCK_CACHE)) { if ((flags & LCK_TYPE_MASK) == LCK_UNLOCK) lvmcache_unlock_vgname(resource); else --- LVM2/lib/locking/locking.h 2008/04/10 17:09:31 1.39 +++ LVM2/lib/locking/locking.h 2008/04/15 14:46:19 1.40 @@ -69,6 +69,7 @@ #define LCK_HOLD 0x00000020U /* Hold lock when lock_vol returns? */ #define LCK_LOCAL 0x00000040U /* Don't propagate to other nodes */ #define LCK_CLUSTER_VG 0x00000080U /* VG is clustered */ +#define LCK_CACHE 0x00000100U /* Operation on cache using P_ lock */ /* * Additional lock bits for cluster communication @@ -91,6 +92,7 @@ #define LCK_VG_READ (LCK_VG | LCK_READ | LCK_HOLD) #define LCK_VG_WRITE (LCK_VG | LCK_WRITE | LCK_HOLD) #define LCK_VG_UNLOCK (LCK_VG | LCK_UNLOCK) +#define LCK_VG_DROP_CACHE (LCK_VG | LCK_WRITE | LCK_CACHE) #define LCK_LV_EXCLUSIVE (LCK_LV | LCK_EXCL | LCK_NONBLOCK) #define LCK_LV_SUSPEND (LCK_LV | LCK_WRITE | LCK_NONBLOCK) @@ -116,6 +118,8 @@ lock_lv_vol(cmd, lv, LCK_LV_ACTIVATE | LCK_HOLD | LCK_LOCAL) #define deactivate_lv_local(cmd, lv) \ lock_lv_vol(cmd, lv, LCK_LV_DEACTIVATE | LCK_LOCAL) +#define drop_cached_metadata(vg) \ + lock_vol((vg)->cmd, (vg)->name, LCK_VG_DROP_CACHE) /* Process list of LVs */ int suspend_lvs(struct cmd_context *cmd, struct list *lvs); --- LVM2/lib/metadata/metadata.c 2008/04/10 19:59:42 1.170 +++ LVM2/lib/metadata/metadata.c 2008/04/15 14:46:19 1.171 @@ -1333,6 +1333,11 @@ return cache_updated; } + if (!drop_cached_metadata(vg)) { + log_error("Unable to drop cached metadata for VG %s.", vg->name); + return 0; + } + /* Commit to each copy of the metadata area */ list_iterate_items(mda, &vg->fid->metadata_areas) { failed = 0; @@ -1348,6 +1353,10 @@ } } + if (!drop_cached_metadata(vg)) + log_error("Attempt to drop cached metadata failed " + "after commit for VG %s.", vg->name); + /* If at least one mda commit succeeded, it was committed */ return cache_updated; } From agk@sourceware.org Tue Apr 15 14:49:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 15 Apr 2008 14:49:00 -0000 Subject: LVM2 VERSION WHATS_NEW Message-ID: <20080415144918.22181.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-15 14:49:17 Modified files: . : VERSION WHATS_NEW Log message: pre-release Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/VERSION.diff?cvsroot=lvm2&r1=1.170&r2=1.171 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.851&r2=1.852 --- LVM2/VERSION 2008/04/10 20:07:18 1.170 +++ LVM2/VERSION 2008/04/15 14:49:17 1.171 @@ -1 +1 @@ -2.02.35-cvs (2008-04-10) +2.02.35-cvs (2008-04-15) --- LVM2/WHATS_NEW 2008/04/15 14:46:18 1.851 +++ LVM2/WHATS_NEW 2008/04/15 14:49:17 1.852 @@ -1,4 +1,4 @@ -Version 2.02.35 - +Version 2.02.35 - 15th April 2008 ================================= Drop cached VG metadata before and after committing changes to it. Rename P_global to P_#global. From agk@sourceware.org Tue Apr 15 14:54:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 15 Apr 2008 14:54:00 -0000 Subject: LVM2/lib/cache lvmcache.c Message-ID: <20080415145400.23403.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-15 14:54:00 Modified files: lib/cache : lvmcache.c Log message: missing stack Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.45&r2=1.46 --- LVM2/lib/cache/lvmcache.c 2008/04/15 14:46:18 1.45 +++ LVM2/lib/cache/lvmcache.c 2008/04/15 14:54:00 1.46 @@ -420,10 +420,10 @@ (!precommitted && vginfo->precommitted)) return NULL; - fid = vginfo->fmt->ops->create_instance(vginfo->fmt, vginfo->vgname, - vgid, NULL); - if (!fid) - return NULL; + if (!(fid = vginfo->fmt->ops->create_instance(vginfo->fmt, + vginfo->vgname, + vgid, NULL))) + return_NULL; if (!(vg = import_vg_from_buffer(vginfo->vgmetadata, fid)) || !vg_validate(vg)) { From agk@sourceware.org Tue Apr 15 14:57:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 15 Apr 2008 14:57:00 -0000 Subject: LVM2/tools vgsplit.c Message-ID: <20080415145713.24967.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-15 14:57:12 Modified files: tools : vgsplit.c Log message: missing stack Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.65&r2=1.66 --- LVM2/tools/vgsplit.c 2008/04/10 21:34:53 1.65 +++ LVM2/tools/vgsplit.c 2008/04/15 14:57:12 1.66 @@ -175,7 +175,7 @@ /* Move this LV */ if (!_move_one_lv(vg_from, vg_to, lvh)) - return 0; + return_0; } /* FIXME Ensure no LVs contain segs pointing at LVs in the other VG */ @@ -221,7 +221,7 @@ if (_lv_is_in_vg(vg_to, seg->cow) && _lv_is_in_vg(vg_to, seg->origin)) { if (!_move_one_lv(vg_from, vg_to, lvh)) - return 0; + return_0; } } @@ -263,7 +263,7 @@ if (seg_in == seg->area_count && log_in) { if (!_move_one_lv(vg_from, vg_to, lvh)) - return 0; + return_0; } } From agk@sourceware.org Tue Apr 15 15:01:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 15 Apr 2008 15:01:00 -0000 Subject: LVM2 VERSION WHATS_NEW Message-ID: <20080415150119.29447.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-15 15:01:18 Modified files: . : VERSION WHATS_NEW Log message: post-release Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/VERSION.diff?cvsroot=lvm2&r1=1.171&r2=1.172 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.852&r2=1.853 --- LVM2/VERSION 2008/04/15 14:49:17 1.171 +++ LVM2/VERSION 2008/04/15 15:01:18 1.172 @@ -1 +1 @@ -2.02.35-cvs (2008-04-15) +2.02.36-cvs (2008-04-15) --- LVM2/WHATS_NEW 2008/04/15 14:49:17 1.852 +++ LVM2/WHATS_NEW 2008/04/15 15:01:18 1.853 @@ -1,3 +1,6 @@ +Version 2.02.36 - +================================= + Version 2.02.35 - 15th April 2008 ================================= Drop cached VG metadata before and after committing changes to it. From agk@sourceware.org Fri Apr 18 12:50:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Fri, 18 Apr 2008 12:50:00 -0000 Subject: LVM2 ./WHATS_NEW tools/lvconvert.c Message-ID: <20080418125025.29262.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-18 12:50:24 Modified files: . : WHATS_NEW tools : lvconvert.c Log message: Fix lvconvert -m0 allocatable space check. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.853&r2=1.854 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvconvert.c.diff?cvsroot=lvm2&r1=1.63&r2=1.64 --- LVM2/WHATS_NEW 2008/04/15 15:01:18 1.853 +++ LVM2/WHATS_NEW 2008/04/18 12:50:24 1.854 @@ -1,5 +1,6 @@ Version 2.02.36 - ================================= + Fix lvconvert -m0 allocatable space check. Version 2.02.35 - 15th April 2008 ================================= --- LVM2/tools/lvconvert.c 2008/04/09 12:56:34 1.63 +++ LVM2/tools/lvconvert.c 2008/04/18 12:50:24 1.64 @@ -750,7 +750,7 @@ if (lp.pv_count) { if (!(lp.pvh = create_pv_list(cmd->mem, vg, lp.pv_count, - lp.pvs, 1))) + lp.pvs, 0))) goto_bad; } else lp.pvh = &vg->pvs; From agk@sourceware.org Sun Apr 20 00:15:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Sun, 20 Apr 2008 00:15:00 -0000 Subject: LVM2 ./WHATS_NEW lib/config/defaults.h lib/rep ... Message-ID: <20080420001509.22952.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-20 00:15:08 Modified files: . : WHATS_NEW lib/config : defaults.h lib/report : report.c report.h tools : args.h commands.h reporter.c Log message: Add --prefixes to reporting tools for field name prefix output format. E.g. lvs --prefixes --noheadings --unbuffered --units m --nosuffix (Used '--prefixes' for now, but I'm looking for a better name.) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.854&r2=1.855 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/config/defaults.h.diff?cvsroot=lvm2&r1=1.39&r2=1.40 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.79&r2=1.80 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.h.diff?cvsroot=lvm2&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/args.h.diff?cvsroot=lvm2&r1=1.56&r2=1.57 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/commands.h.diff?cvsroot=lvm2&r1=1.110&r2=1.111 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/reporter.c.diff?cvsroot=lvm2&r1=1.35&r2=1.36 --- LVM2/WHATS_NEW 2008/04/18 12:50:24 1.854 +++ LVM2/WHATS_NEW 2008/04/20 00:15:08 1.855 @@ -1,5 +1,6 @@ Version 2.02.36 - ================================= + Add --prefixes to reporting tools for field name prefix output format. Fix lvconvert -m0 allocatable space check. Version 2.02.35 - 15th April 2008 --- LVM2/lib/config/defaults.h 2008/01/17 15:31:18 1.39 +++ LVM2/lib/config/defaults.h 2008/04/20 00:15:08 1.40 @@ -102,6 +102,7 @@ #define DEFAULT_REP_ALIGNED 1 #define DEFAULT_REP_BUFFERED 1 #define DEFAULT_REP_HEADINGS 1 +#define DEFAULT_REP_PREFIXES 0 #define DEFAULT_REP_SEPARATOR " " #define DEFAULT_LVS_COLS "lv_name,vg_name,lv_attr,lv_size,origin,snap_percent,move_pv,mirror_log,copy_percent,convert_lv" --- LVM2/lib/report/report.c 2008/04/10 17:19:02 1.79 +++ LVM2/lib/report/report.c 2008/04/20 00:15:08 1.80 @@ -386,7 +386,7 @@ const uint32_t status = *(const uint32_t *) data; char *repstr; - if (!(repstr = dm_pool_zalloc(mem, 4))) { + if (!(repstr = dm_pool_zalloc(mem, 3))) { log_error("dm_pool_alloc failed"); return 0; } @@ -1077,9 +1077,10 @@ void *report_init(struct cmd_context *cmd, const char *format, const char *keys, report_type_t *report_type, const char *separator, - int aligned, int buffered, int headings) + int aligned, int buffered, int headings, int field_prefixes) { uint32_t report_flags = 0; + void *rh; if (aligned) report_flags |= DM_REPORT_OUTPUT_ALIGNED; @@ -1090,8 +1091,16 @@ if (headings) report_flags |= DM_REPORT_OUTPUT_HEADINGS; - return dm_report_init(report_type, _report_types, _fields, format, - separator, report_flags, keys, cmd); + if (field_prefixes) + report_flags |= DM_REPORT_OUTPUT_FIELD_NAME_PREFIX; + + rh = dm_report_init(report_type, _report_types, _fields, format, + separator, report_flags, keys, cmd); + + if (field_prefixes) + dm_report_set_output_field_name_prefix(rh, "lvm2_"); + + return rh; } /* --- LVM2/lib/report/report.h 2007/08/20 20:55:27 1.5 +++ LVM2/lib/report/report.h 2008/04/20 00:15:08 1.6 @@ -28,7 +28,7 @@ void *report_init(struct cmd_context *cmd, const char *format, const char *keys, report_type_t *report_type, const char *separator, - int aligned, int buffered, int headings); + int aligned, int buffered, int headings, int field_prefixes); void report_free(void *handle); int report_object(void *handle, struct volume_group *vg, struct logical_volume *lv, struct physical_volume *pv, --- LVM2/tools/args.h 2007/11/09 16:51:54 1.56 +++ LVM2/tools/args.h 2008/04/20 00:15:08 1.57 @@ -53,6 +53,7 @@ arg(config_ARG, '\0', "config", string_arg, 0) arg(trustcache_ARG, '\0', "trustcache", NULL, 0) arg(ignoremonitoring_ARG, '\0', "ignoremonitoring", NULL, 0) +arg(prefixes_ARG, '\0', "prefixes", NULL, 0) /* Allow some variations */ arg(resizable_ARG, '\0', "resizable", yes_no_arg, 0) --- LVM2/tools/commands.h 2008/04/09 13:47:13 1.110 +++ LVM2/tools/commands.h 2008/04/20 00:15:08 1.111 @@ -368,6 +368,7 @@ "\t[-o|--options [+]Field[,Field]]\n" "\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n" "\t[-P|--partial] " "\n" + "\t[--prefixes]\n" "\t[--segments]\n" "\t[--separator Separator]\n" "\t[--trustcache]\n" @@ -378,8 +379,9 @@ "\t[LogicalVolume[Path] [LogicalVolume[Path]...]]\n", aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG, - nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, segments_ARG, - separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG) + nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, prefixes_ARG, + segments_ARG, separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, + units_ARG) xx(lvscan, "List all logical volumes in all volume groups", @@ -575,6 +577,7 @@ "\t[-o|--options [+]Field[,Field]]\n" "\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n" "\t[-P|--partial] " "\n" + "\t[--prefixes]\n" "\t[--segments]\n" "\t[--separator Separator]\n" "\t[--trustcache]\n" @@ -585,8 +588,9 @@ "\t[PhysicalVolume [PhysicalVolume...]]\n", aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG, - nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, segments_ARG, - separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG) + nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, prefixes_ARG, + segments_ARG, separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, + units_ARG) xx(pvscan, "List all physical volumes", @@ -890,6 +894,7 @@ "\t[-o|--options [+]Field[,Field]]\n" "\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n" "\t[-P|--partial] " "\n" + "\t[--prefixes]\n" "\t[--separator Separator]\n" "\t[--trustcache]\n" "\t[--unbuffered]\n" @@ -899,8 +904,8 @@ "\t[VolumeGroupName [VolumeGroupName...]]\n", aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG, - nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, separator_ARG, - sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG) + nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, prefixes_ARG, + separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG) xx(vgscan, "Search for all volume groups", --- LVM2/tools/reporter.c 2008/01/30 14:00:02 1.35 +++ LVM2/tools/reporter.c 2008/04/20 00:15:08 1.36 @@ -158,7 +158,7 @@ char *str; const char *keys = NULL, *options = NULL, *separator; int r = ECMD_PROCESSED; - int aligned, buffered, headings; + int aligned, buffered, headings, field_prefixes; unsigned args_are_pvs; aligned = find_config_tree_int(cmd, "report/aligned", @@ -169,6 +169,8 @@ DEFAULT_REP_HEADINGS); separator = find_config_tree_str(cmd, "report/separator", DEFAULT_REP_SEPARATOR); + field_prefixes = find_config_tree_int(cmd, "report/prefixes", + DEFAULT_REP_PREFIXES); args_are_pvs = (report_type == PVS || report_type == PVSEGS) ? 1 : 0; @@ -270,10 +272,14 @@ buffered = 0; if (arg_count(cmd, noheadings_ARG)) headings = 0; + if (arg_count(cmd, prefixes_ARG)) { + aligned = 0; + field_prefixes = 1; + } if (!(report_handle = report_init(cmd, options, keys, &report_type, separator, aligned, buffered, - headings))) { + headings, field_prefixes))) { stack; return ECMD_FAILED; } From agk@sourceware.org Tue Apr 22 11:47:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 22 Apr 2008 11:47:00 -0000 Subject: LVM2 lib/format1/import-export.c ./WHATS_NEW Message-ID: <20080422114722.13233.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-22 11:47:22 Modified files: lib/format1 : import-export.c . : WHATS_NEW Log message: Fix metadata corruption writing lvm1-formatted metadata with snapshots. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/format1/import-export.c.diff?cvsroot=lvm2&r1=1.96&r2=1.97 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.855&r2=1.856 --- LVM2/lib/format1/import-export.c 2008/04/10 17:09:31 1.96 +++ LVM2/lib/format1/import-export.c 2008/04/22 11:47:22 1.97 @@ -284,7 +284,7 @@ vgd->vg_status |= VG_EXTENDABLE; vgd->lv_max = vg->max_lv; - vgd->lv_cur = vg->lv_count; + vgd->lv_cur = vg->lv_count + vg->snapshot_count; vgd->pv_max = vg->max_pv; vgd->pv_cur = vg->pv_count; --- LVM2/WHATS_NEW 2008/04/20 00:15:08 1.855 +++ LVM2/WHATS_NEW 2008/04/22 11:47:22 1.856 @@ -1,5 +1,6 @@ Version 2.02.36 - ================================= + Fix metadata corruption writing lvm1-formatted metadata with snapshots. Add --prefixes to reporting tools for field name prefix output format. Fix lvconvert -m0 allocatable space check. From agk@sourceware.org Tue Apr 22 12:54:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 22 Apr 2008 12:54:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/metadata.c lib/m ... Message-ID: <20080422125433.19007.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-22 12:54:33 Modified files: . : WHATS_NEW lib/metadata : metadata.c lv_manip.c Log message: Check lv_count in vg_validate. Fix internal LV counter when a snapshot is removed. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.856&r2=1.857 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.171&r2=1.172 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/lv_manip.c.diff?cvsroot=lvm2&r1=1.153&r2=1.154 --- LVM2/WHATS_NEW 2008/04/22 11:47:22 1.856 +++ LVM2/WHATS_NEW 2008/04/22 12:54:32 1.857 @@ -1,5 +1,7 @@ Version 2.02.36 - ================================= + Check lv_count in vg_validate. + Fix internal LV counter when a snapshot is removed. Fix metadata corruption writing lvm1-formatted metadata with snapshots. Add --prefixes to reporting tools for field name prefix output format. Fix lvconvert -m0 allocatable space check. --- LVM2/lib/metadata/metadata.c 2008/04/15 14:46:19 1.171 +++ LVM2/lib/metadata/metadata.c 2008/04/22 12:54:33 1.172 @@ -1177,6 +1177,7 @@ struct lv_list *lvl, *lvl2; char uuid[64] __attribute((aligned(8))); int r = 1; + uint32_t lv_count; /* FIXME Also check there's no data/metadata overlap */ @@ -1210,6 +1211,15 @@ r = 0; } + if ((lv_count = (uint32_t) list_size(&vg->lvs)) != + vg->lv_count + 2 * vg->snapshot_count) { + log_error("Internal error: #internal LVs (%u) != #LVs (%" + PRIu32 ") + 2 * #snapshots (%" PRIu32 ") in VG %s", + list_size(&vg->lvs), vg->lv_count, + vg->snapshot_count, vg->name); + r = 0; + } + list_iterate_items(lvl, &vg->lvs) { list_iterate_items(lvl2, &vg->lvs) { if (lvl == lvl2) --- LVM2/lib/metadata/lv_manip.c 2008/04/10 17:09:31 1.153 +++ LVM2/lib/metadata/lv_manip.c 2008/04/22 12:54:33 1.154 @@ -439,7 +439,8 @@ list_del(&lvl->list); - lv->vg->lv_count--; + if (!(lv->status & SNAPSHOT)) + lv->vg->lv_count--; } else if (lv->vg->fid->fmt->ops->lv_setup && !lv->vg->fid->fmt->ops->lv_setup(lv->vg->fid, lv)) return_0; From ccaulfield@sourceware.org Wed Apr 23 09:53:00 2008 From: ccaulfield@sourceware.org (ccaulfield@sourceware.org) Date: Wed, 23 Apr 2008 09:53:00 -0000 Subject: LVM2 ./WHATS_NEW daemons/clvmd/clvmd-openais.c Message-ID: <20080423095350.32558.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: ccaulfield@sourceware.org 2008-04-23 09:53:49 Modified files: . : WHATS_NEW daemons/clvmd : clvmd-openais.c Log message: Simplify locking code by using saLckResourceLock rather than saLckResourceLockAsync. Thanks to Xinwei Hu for the patch. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.857&r2=1.858 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-openais.c.diff?cvsroot=lvm2&r1=1.3&r2=1.4 --- LVM2/WHATS_NEW 2008/04/22 12:54:32 1.857 +++ LVM2/WHATS_NEW 2008/04/23 09:53:49 1.858 @@ -1,5 +1,6 @@ Version 2.02.36 - ================================= + Simply clvmd-openais by using non-async saLckResourceLock. Check lv_count in vg_validate. Fix internal LV counter when a snapshot is removed. Fix metadata corruption writing lvm1-formatted metadata with snapshots. --- LVM2/daemons/clvmd/clvmd-openais.c 2007/07/11 12:07:39 1.3 +++ LVM2/daemons/clvmd/clvmd-openais.c 2008/04/23 09:53:49 1.4 @@ -50,11 +50,6 @@ /* Timeout value for several openais calls */ #define TIMEOUT 10 -static void lck_lock_callback(SaInvocationT invocation, - SaLckLockStatusT lockStatus, - SaAisErrorT error); -static void lck_unlock_callback(SaInvocationT invocation, - SaAisErrorT error); static void cpg_deliver_callback (cpg_handle_t handle, struct cpg_name *groupName, uint32_t nodeid, @@ -92,11 +87,6 @@ .cpg_confchg_fn = cpg_confchg_callback, }; -SaLckCallbacksT lck_callbacks = { - .saLckLockGrantCallback = lck_lock_callback, - .saLckResourceUnlockCallback = lck_unlock_callback -}; - struct node_info { enum {NODE_UNKNOWN, NODE_DOWN, NODE_UP, NODE_CLVMD} state; @@ -305,32 +295,6 @@ num_nodes = joined_list_entries; } -static void lck_lock_callback(SaInvocationT invocation, - SaLckLockStatusT lockStatus, - SaAisErrorT error) -{ - struct lock_wait *lwait = (struct lock_wait *)(long)invocation; - - DEBUGLOG("lck_lock_callback, error = %d\n", error); - - lwait->status = error; - pthread_mutex_lock(&lwait->mutex); - pthread_cond_signal(&lwait->cond); - pthread_mutex_unlock(&lwait->mutex); -} - -static void lck_unlock_callback(SaInvocationT invocation, - SaAisErrorT error) -{ - struct lock_wait *lwait = (struct lock_wait *)(long)invocation; - - DEBUGLOG("lck_unlock_callback\n"); - - lwait->status = SA_AIS_OK; - pthread_mutex_lock(&lwait->mutex); - pthread_cond_signal(&lwait->cond); - pthread_mutex_unlock(&lwait->mutex); -} static int lck_dispatch(struct local_client *client, char *buf, int len, const char *csid, struct local_client **new_client) @@ -359,7 +323,7 @@ } err = saLckInitialize(&lck_handle, - &lck_callbacks, + NULL, &ver); if (err != SA_AIS_OK) { cpg_initialize(&cpg_handle, &cpg_callbacks); @@ -495,15 +459,11 @@ /* Real locking */ static int _lock_resource(char *resource, int mode, int flags, int *lockid) { - struct lock_wait lwait; struct lock_info *linfo; SaLckResourceHandleT res_handle; SaAisErrorT err; SaLckLockIdT lock_id; - - pthread_cond_init(&lwait.cond, NULL); - pthread_mutex_init(&lwait.mutex, NULL); - pthread_mutex_lock(&lwait.mutex); + SaLckLockStatusT lockStatus; /* This needs to be converted from DLM/LVM2 value for OpenAIS LCK */ if (flags & LCK_NONBLOCK) flags = SA_LCK_LOCK_NO_QUEUE; @@ -526,24 +486,24 @@ return ais_to_errno(err); } - err = saLckResourceLockAsync(res_handle, - (SaInvocationT)(long)&lwait, - &lock_id, - mode, - flags, - 0); - if (err != SA_AIS_OK) + err = saLckResourceLock( + res_handle, + &lock_id, + mode, + flags, + 0, + SA_TIME_END, + &lockStatus); + if (err != SA_AIS_OK && lockStatus != SA_LCK_LOCK_GRANTED) { free(linfo); saLckResourceClose(res_handle); return ais_to_errno(err); } - + /* Wait for it to complete */ - pthread_cond_wait(&lwait.cond, &lwait.mutex); - pthread_mutex_unlock(&lwait.mutex); - DEBUGLOG("lock_resource returning %d, lock_id=%llx\n", lwait.status, + DEBUGLOG("lock_resource returning %d, lock_id=%llx\n", err, lock_id); linfo->lock_id = lock_id; @@ -551,43 +511,34 @@ dm_hash_insert(lock_hash, resource, linfo); - return ais_to_errno(lwait.status); + return ais_to_errno(err); } static int _unlock_resource(char *resource, int lockid) { - struct lock_wait lwait; SaAisErrorT err; struct lock_info *linfo; - pthread_cond_init(&lwait.cond, NULL); - pthread_mutex_init(&lwait.mutex, NULL); - pthread_mutex_lock(&lwait.mutex); - DEBUGLOG("unlock_resource %s\n", resource); linfo = dm_hash_lookup(lock_hash, resource); if (!linfo) return 0; DEBUGLOG("unlock_resource: lockid: %llx\n", linfo->lock_id); - err = saLckResourceUnlockAsync((SaInvocationT)(long)&lwait, linfo->lock_id); + err = saLckResourceUnlock(linfo->lock_id, SA_TIME_END); if (err != SA_AIS_OK) { DEBUGLOG("Unlock returned %d\n", err); return ais_to_errno(err); } - /* Wait for it to complete */ - pthread_cond_wait(&lwait.cond, &lwait.mutex); - pthread_mutex_unlock(&lwait.mutex); - /* Release the resource */ dm_hash_remove(lock_hash, resource); saLckResourceClose(linfo->res_handle); free(linfo); - return ais_to_errno(lwait.status); + return ais_to_errno(err); } static int _sync_lock(const char *resource, int mode, int flags, int *lockid) From wysochanski@sourceware.org Wed Apr 23 12:53:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Wed, 23 Apr 2008 12:53:00 -0000 Subject: LVM2 ./WHATS_NEW tools/vgmerge.c Message-ID: <20080423125311.22330.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-23 12:53:10 Modified files: . : WHATS_NEW tools : vgmerge.c Log message: Fix internal snapshot_count when vgmerge with snapshots in source VG. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.858&r2=1.859 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgmerge.c.diff?cvsroot=lvm2&r1=1.47&r2=1.48 --- LVM2/WHATS_NEW 2008/04/23 09:53:49 1.858 +++ LVM2/WHATS_NEW 2008/04/23 12:53:10 1.859 @@ -1,5 +1,6 @@ Version 2.02.36 - ================================= + Fix internal snapshot_count when vgmerge with snapshots in source VG. Simply clvmd-openais by using non-async saLckResourceLock. Check lv_count in vg_validate. Fix internal LV counter when a snapshot is removed. --- LVM2/tools/vgmerge.c 2008/04/10 19:14:26 1.47 +++ LVM2/tools/vgmerge.c 2008/04/23 12:53:10 1.48 @@ -99,6 +99,7 @@ } vg_to->lv_count += vg_from->lv_count; + vg_to->snapshot_count += vg_from->snapshot_count; vg_to->extent_count += vg_from->extent_count; vg_to->free_count += vg_from->free_count; From wysochanski@sourceware.org Wed Apr 23 13:02:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Wed, 23 Apr 2008 13:02:00 -0000 Subject: LVM2/test lvm-utils.sh Message-ID: <20080423130203.28130.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-23 13:02:03 Modified files: test : lvm-utils.sh Log message: Update test function _check_{vg|lv|pv}_field to aid in test debug. Author: Dave Wysochanski Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/lvm-utils.sh.diff?cvsroot=lvm2&r1=1.10&r2=1.11 --- LVM2/test/lvm-utils.sh 2008/04/11 14:06:16 1.10 +++ LVM2/test/lvm-utils.sh 2008/04/23 13:02:03 1.11 @@ -63,7 +63,7 @@ { if test "$verbose" = "t" then - echo "check_vg_field_ VG: $1 actual: `vgs --noheadings -o $2 $1` expected $3" + echo "check_vg_field_ VG=$1, field=$2, actual=`vgs --noheadings -o $2 $1`, expected=$3" fi return $(test $(vgs --noheadings -o $2 $1) == $3) } @@ -72,7 +72,7 @@ { if test "$verbose" = "t" then - echo "check_pv_field_ PV: $1 actual: `pvs --noheadings -o $2 $1` expected $3" + echo "check_pv_field_ PV=$1, field=$2, actual=`pvs --noheadings -o $2 $1`, expected=$3" fi return $(test $(pvs --noheadings -o $2 $1) == $3) } @@ -81,7 +81,7 @@ { if test "$verbose" = "t" then - echo "check_lv_field_ LV: $1 actual: `lvs --noheadings -o $2 $1` expected $3" + echo "check_lv_field_ LV=$1, field=$2, actual=`lvs --noheadings -o $2 $1`, expected=$3" fi return $(test $(lvs --noheadings -o $2 $1) == $3) } From wysochanski@sourceware.org Wed Apr 23 14:33:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Wed, 23 Apr 2008 14:33:00 -0000 Subject: LVM2 ./WHATS_NEW lib/metadata/metadata-exporte ... Message-ID: <20080423143306.7289.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-23 14:33:06 Modified files: . : WHATS_NEW lib/metadata : metadata-exported.h tools : vgsplit.c Log message: Fix vgsplit internal counting of snapshot LVs. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.859&r2=1.860 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata-exported.h.diff?cvsroot=lvm2&r1=1.47&r2=1.48 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgsplit.c.diff?cvsroot=lvm2&r1=1.66&r2=1.67 --- LVM2/WHATS_NEW 2008/04/23 12:53:10 1.859 +++ LVM2/WHATS_NEW 2008/04/23 14:33:05 1.860 @@ -1,5 +1,6 @@ Version 2.02.36 - ================================= + Fix vgsplit internal counting of snapshot LVs. Fix internal snapshot_count when vgmerge with snapshots in source VG. Simply clvmd-openais by using non-async saLckResourceLock. Check lv_count in vg_validate. --- LVM2/lib/metadata/metadata-exported.h 2008/04/10 17:09:31 1.47 +++ LVM2/lib/metadata/metadata-exported.h 2008/04/23 14:33:05 1.48 @@ -202,7 +202,23 @@ uint32_t pv_count; struct list pvs; - /* logical volumes */ + /* + * logical volumes + * The following relationship should always hold: + * list_size(lvs) = lv_count + 2 * snapshot_count + * + * Snapshots consist of 2 instances of "struct logical_volume": + * - cow (lv_name is visible to the user) + * - snapshot (lv_name is 'snapshotN') + * Neither of these instances is reflected in lv_count, but we + * multiply the snapshot_count by 2. + * + * Mirrors consist of multiple instances of "struct logical_volume": + * - one for the mirror log + * - one for each mirror leg + * - one for the user-visible mirror LV + * all of the instances are reflected in lv_count. + */ uint32_t lv_count; uint32_t snapshot_count; struct list lvs; --- LVM2/tools/vgsplit.c 2008/04/15 14:57:12 1.66 +++ LVM2/tools/vgsplit.c 2008/04/23 14:33:06 1.67 @@ -109,7 +109,7 @@ if (lv->status & SNAPSHOT) { vg_from->snapshot_count--; vg_to->snapshot_count++; - } else { + } else if (!lv_is_cow(lv)) { vg_from->lv_count--; vg_to->lv_count++; } From wysochanski@sourceware.org Wed Apr 23 18:28:00 2008 From: wysochanski@sourceware.org (wysochanski@sourceware.org) Date: Wed, 23 Apr 2008 18:28:00 -0000 Subject: LVM2/test t-mirror-lvconvert.sh Message-ID: <20080423182800.13307.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: wysochanski@sourceware.org 2008-04-23 18:27:59 Modified files: test : t-mirror-lvconvert.sh Log message: Add test for rhbz440405 - lvconvert -m0 fails incorrectly if all PEs allocated. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/test/t-mirror-lvconvert.sh.diff?cvsroot=lvm2&r1=1.2&r2=1.3 --- LVM2/test/t-mirror-lvconvert.sh 2008/01/17 02:20:48 1.2 +++ LVM2/test/t-mirror-lvconvert.sh 2008/04/23 18:27:59 1.3 @@ -387,6 +387,16 @@ mirrorlog_is_on_ $vg/$lv1 $(pv_ 3) && check_and_cleanup_lvs_' +test_expect_success "rhbz440405: lvconvert -m0 incorrectly fails if all PEs allocated" \ + 'prepare_lvs_ && + lvcreate -l`pvs --noheadings -ope_count $(pv_ 1)` -m1 -n $lv1 $vg $(pv_ 1) $(pv_ 2) $(pv_ 3):0 && + check_mirror_count_ $vg/$lv1 2 && + check_mirror_log_ $vg/$lv1 && + lvconvert -m0 $vg/$lv1 $(pv_ 1) && + check_no_tmplvs_ $vg/$lv1 && + check_mirror_count_ $vg/$lv1 1 && + check_and_cleanup_lvs_' + # --------------------------------------------------------------------- test_done From agk@sourceware.org Thu Apr 24 02:22:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Thu, 24 Apr 2008 02:22:00 -0000 Subject: LVM2 lib/cache/lvmcache.c ./WHATS_NEW Message-ID: <20080424022207.13013.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-24 02:22:07 Modified files: lib/cache : lvmcache.c . : WHATS_NEW Log message: Exclude VG_GLOBAL from internal concurrent VG lock counter. (Avoids 'device left open' warning messages from vgscan etc.) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/cache/lvmcache.c.diff?cvsroot=lvm2&r1=1.46&r2=1.47 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.860&r2=1.861 --- LVM2/lib/cache/lvmcache.c 2008/04/15 14:54:00 1.46 +++ LVM2/lib/cache/lvmcache.c 2008/04/24 02:22:06 1.47 @@ -156,7 +156,8 @@ _update_cache_lock_state(vgname, 1); - _vgs_locked++; + if (strcmp(vgname, VG_GLOBAL)) + _vgs_locked++; } int vgname_is_locked(const char *vgname) @@ -178,7 +179,7 @@ dm_hash_remove(_lock_hash, vgname); /* FIXME Do this per-VG */ - if (!--_vgs_locked) + if (strcmp(vgname, VG_GLOBAL) && !--_vgs_locked) dev_close_all(); } --- LVM2/WHATS_NEW 2008/04/23 14:33:05 1.860 +++ LVM2/WHATS_NEW 2008/04/24 02:22:07 1.861 @@ -1,8 +1,9 @@ Version 2.02.36 - ================================= + Exclude VG_GLOBAL from internal concurrent VG lock counter. Fix vgsplit internal counting of snapshot LVs. - Fix internal snapshot_count when vgmerge with snapshots in source VG. - Simply clvmd-openais by using non-async saLckResourceLock. + Fix vgmerge snapshot_count when source VG contains snapshots. + Simplify clvmd-openais by using non-async saLckResourceLock. Check lv_count in vg_validate. Fix internal LV counter when a snapshot is removed. Fix metadata corruption writing lvm1-formatted metadata with snapshots. From ccaulfield@sourceware.org Mon Apr 28 08:57:00 2008 From: ccaulfield@sourceware.org (ccaulfield@sourceware.org) Date: Mon, 28 Apr 2008 08:57:00 -0000 Subject: LVM2 ./WHATS_NEW daemons/clvmd/clvmd-openais.c Message-ID: <20080428085712.4676.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: ccaulfield@sourceware.org 2008-04-28 08:57:11 Modified files: . : WHATS_NEW daemons/clvmd : clvmd-openais.c Log message: The attached patch is a try to make clvmd work correctly on openais stack. It does 2 things. 1. The cpg_deliver_callback make a compare between target_nodeid and our_nodeid. It turns out openais set target_nodeid to 0 sometimes. for broadcasting ? I change the behavior so that lvm will process_remote also on target_nodeid == 0 2. The joined_list passed to cpg_confchg_callback doesn't include the already exist nodes in the group, which leads to an incomplete node_hash. I simply add all other nodes in member_list to node_hash also. Thanks to Xinwei Hu for this patch. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.861&r2=1.862 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-openais.c.diff?cvsroot=lvm2&r1=1.4&r2=1.5 --- LVM2/WHATS_NEW 2008/04/24 02:22:07 1.861 +++ LVM2/WHATS_NEW 2008/04/28 08:57:11 1.862 @@ -1,5 +1,6 @@ Version 2.02.36 - ================================= + Fix nodes list in clvmd-openais, and allow for broadcast messages. Exclude VG_GLOBAL from internal concurrent VG lock counter. Fix vgsplit internal counting of snapshot LVs. Fix vgmerge snapshot_count when source VG contains snapshots. --- LVM2/daemons/clvmd/clvmd-openais.c 2008/04/23 09:53:49 1.4 +++ LVM2/daemons/clvmd/clvmd-openais.c 2008/04/28 08:57:11 1.5 @@ -245,12 +245,13 @@ memcpy(&target_nodeid, msg, OPENAIS_CSID_LEN); - DEBUGLOG("Got message from nodeid %d for %d. len %d\n", - nodeid, target_nodeid, msg_len-4); + DEBUGLOG("%u got message from nodeid %d for %d. len %d\n", + our_nodeid, nodeid, target_nodeid, msg_len-4); - if (target_nodeid == our_nodeid) - process_message(cluster_client, (char *)msg+OPENAIS_CSID_LEN, - msg_len-OPENAIS_CSID_LEN, (char*)&nodeid); + if (nodeid != our_nodeid) + if (target_nodeid == our_nodeid || target_nodeid == 0) + process_message(cluster_client, (char *)msg+OPENAIS_CSID_LEN, + msg_len-OPENAIS_CSID_LEN, (char*)&nodeid); } static void cpg_confchg_callback(cpg_handle_t handle, @@ -292,10 +293,29 @@ ninfo->state = NODE_DOWN; } + for (i=0; inodeid = member_list[i].nodeid; + dm_hash_insert_binary(node_hash, + (char *)&ninfo->nodeid, + OPENAIS_CSID_LEN, ninfo); + } + } + ninfo->state = NODE_CLVMD; + } + num_nodes = joined_list_entries; } - static int lck_dispatch(struct local_client *client, char *buf, int len, const char *csid, struct local_client **new_client) { From ccaulfield@sourceware.org Tue Apr 29 08:55:00 2008 From: ccaulfield@sourceware.org (ccaulfield@sourceware.org) Date: Tue, 29 Apr 2008 08:55:00 -0000 Subject: LVM2 ./WHATS_NEW daemons/clvmd/clvmd-openais.c Message-ID: <20080429085520.25895.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: ccaulfield@sourceware.org 2008-04-29 08:55:20 Modified files: . : WHATS_NEW daemons/clvmd : clvmd-openais.c Log message: . remove_lock_wait.diff remove the definition of "struct lock_wait", which is not used since the switch away from async version saLck . num_nodes should equal to member_list_entries, i.e. joined_list_entires is 0 when a node leaves the group. Thanks to Xinwei Hu for the patch. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.862&r2=1.863 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-openais.c.diff?cvsroot=lvm2&r1=1.5&r2=1.6 --- LVM2/WHATS_NEW 2008/04/28 08:57:11 1.862 +++ LVM2/WHATS_NEW 2008/04/29 08:55:19 1.863 @@ -1,5 +1,6 @@ Version 2.02.36 - ================================= + Remove unused struct in clvmd-openais, and use correct node count. Fix nodes list in clvmd-openais, and allow for broadcast messages. Exclude VG_GLOBAL from internal concurrent VG lock counter. Fix vgsplit internal counting of snapshot LVs. --- LVM2/daemons/clvmd/clvmd-openais.c 2008/04/28 08:57:11 1.5 +++ LVM2/daemons/clvmd/clvmd-openais.c 2008/04/29 08:55:20 1.6 @@ -100,13 +100,6 @@ SaNameT lock_name; }; -struct lock_wait -{ - pthread_cond_t cond; - pthread_mutex_t mutex; - int status; -}; - /* Set errno to something approximating the right value and return 0 or -1 */ static int ais_to_errno(SaAisErrorT err) { @@ -313,7 +306,7 @@ ninfo->state = NODE_CLVMD; } - num_nodes = joined_list_entries; + num_nodes = member_list_entries; } static int lck_dispatch(struct local_client *client, char *buf, int len, From zkabelac@sourceware.org Tue Apr 29 15:25:00 2008 From: zkabelac@sourceware.org (zkabelac@sourceware.org) Date: Tue, 29 Apr 2008 15:25:00 -0000 Subject: LVM2 ./WHATS_NEW scripts/fsadm.sh tools/lvresize.c Message-ID: <20080429152532.21263.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2008-04-29 15:25:28 Modified files: . : WHATS_NEW scripts : fsadm.sh tools : lvresize.c Log message: fixing fsadm usage with older blockdev,blkid,readline tools fixing lvresize extension code path where size was not set for fsadm Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.863&r2=1.864 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/fsadm.sh.diff?cvsroot=lvm2&r1=1.5&r2=1.6 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvresize.c.diff?cvsroot=lvm2&r1=1.96&r2=1.97 --- LVM2/WHATS_NEW 2008/04/29 08:55:19 1.863 +++ LVM2/WHATS_NEW 2008/04/29 15:25:25 1.864 @@ -11,6 +11,8 @@ Fix metadata corruption writing lvm1-formatted metadata with snapshots. Add --prefixes to reporting tools for field name prefix output format. Fix lvconvert -m0 allocatable space check. + Fix fsadm.sh to work with older blockdev,blkid,readlink + Fix lvresize - extension was not passing new size to fsadm Version 2.02.35 - 15th April 2008 ================================= --- LVM2/scripts/fsadm.sh 2008/02/06 12:45:32 1.5 +++ LVM2/scripts/fsadm.sh 2008/04/29 15:25:27 1.6 @@ -43,7 +43,9 @@ BLOCKDEV=blockdev BLKID=blkid GREP=grep +CUT=cut READLINK=readlink +READLINK_E="-e" FSCK=fsck XFS_CHECK=xfs_check @@ -154,9 +156,10 @@ # dereference device name if it is symbolic link detect_fs() { VOLUME=${1#/dev/} - VOLUME=$($READLINK -e -n "/dev/$VOLUME") || error "Cannot get readlink $1" + VOLUME=$($READLINK $READLINK_E -n "/dev/$VOLUME") || error "Cannot get readlink $1" # use /dev/null as cache file to be sure about the result - FSTYPE=$($BLKID -c /dev/null -o value -s TYPE "$VOLUME") || error "Cannot get FSTYPE of \"$VOLUME\"" + # use 'cut' to be compatible with older version of blkid that does not provide option '-o value' + FSTYPE=$($BLKID -c /dev/null -s TYPE "$VOLUME" | cut -d \" -f 2) || error "Cannot get FSTYPE of \"$VOLUME\"" verbose "\"$FSTYPE\" filesystem found on \"$VOLUME\"" } @@ -171,7 +174,15 @@ # get the full size of device in bytes detect_device_size() { - DEVSIZE=$($BLOCKDEV --getsize64 "$VOLUME") || error "Cannot read device \"$VOLUME\"" + # check if blockdev supports getsize64 + $BLOCKDEV 2>&1 | $GREP getsize64 >/dev/null + if test $? -eq 0; then + DEVSIZE=$($BLOCKDEV --getsize64 "$VOLUME") || error "Cannot read size of device \"$VOLUME\"" + else + DEVSIZE=$($BLOCKDEV --getsize "$VOLUME") || error "Cannot read size of device \"$VOLUME\"" + SSSIZE=$($BLOCKDEV --getss "$VOLUME") || error "Cannot block size read device \"$VOLUME\"" + DEVSIZE=$(($DEVSIZE * $SSSIZE)) + fi } # round up $1 / $2 @@ -349,9 +360,10 @@ test -n "$TUNE_EXT" -a -n "$RESIZE_EXT" -a -n "$TUNE_REISER" -a -n "$RESIZE_REISER" \ -a -n "$TUNE_XFS" -a -n "$RESIZE_XFS" -a -n "$MOUNT" -a -n "$UMOUNT" -a -n "$MKDIR" \ -a -n "$RMDIR" -a -n "$BLOCKDEV" -a -n "$BLKID" -a -n "$GREP" -a -n "$READLINK" \ - -a -n "$FSCK" -a -n "$XFS_CHECK" -a -n "LVRESIZE" \ + -a -n "$FSCK" -a -n "$XFS_CHECK" -a -n "LVRESIZE" -a -n "$CUT" \ || error "Required command definitions in the script are missing!" -$($READLINK -e -n / >/dev/null 2>&1) || error "$READLINK does not support options -e -n" + +$($READLINK -e -n / >/dev/null 2>&1) || READLINK_E="-f" TEST64BIT=$(( 1000 * 1000000000000 )) test $TEST64BIT -eq 1000000000000000 || error "Shell does not handle 64bit arithmetic" $(echo Y | $GREP Y >/dev/null) || error "Grep does not work properly" --- LVM2/tools/lvresize.c 2008/04/10 19:59:43 1.96 +++ LVM2/tools/lvresize.c 2008/04/29 15:25:28 1.97 @@ -630,6 +630,11 @@ lp->lv_name); return ECMD_FAILED; } + if (dm_snprintf(size_buf, SIZE_BUF, "%" PRIu64, + (uint64_t) lp->extents * vg->extent_size / 2) < 0) { + log_error("Couldn't generate new LV size string"); + return ECMD_FAILED; + } if (!exec_cmd("fsadm", "resize", lv_path, size_buf)) { stack; return ECMD_FAILED; From agk@sourceware.org Tue Apr 29 15:58:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 29 Apr 2008 15:58:00 -0000 Subject: LVM2 ./VERSION ./WHATS_NEW lib/metadata/metada ... Message-ID: <20080429155826.7501.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-29 15:58:25 Modified files: . : VERSION WHATS_NEW lib/metadata : metadata.c lib/report : report.c scripts : fsadm.sh tools : commands.h Log message: pre-release (bug fixes only - enhancements excluded) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/VERSION.diff?cvsroot=lvm2&r1=1.172&r2=1.173 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.864&r2=1.865 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.172&r2=1.173 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.80&r2=1.81 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/scripts/fsadm.sh.diff?cvsroot=lvm2&r1=1.6&r2=1.7 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/commands.h.diff?cvsroot=lvm2&r1=1.111&r2=1.112 --- LVM2/VERSION 2008/04/15 15:01:18 1.172 +++ LVM2/VERSION 2008/04/29 15:58:23 1.173 @@ -1 +1 @@ -2.02.36-cvs (2008-04-15) +2.02.36-cvs (2008-04-29) --- LVM2/WHATS_NEW 2008/04/29 15:25:25 1.864 +++ LVM2/WHATS_NEW 2008/04/29 15:58:24 1.865 @@ -1,18 +1,16 @@ -Version 2.02.36 - +Version 2.02.36 - 29th April 2008 ================================= + Fix fsadm.sh to work with older blockdev, blkid & readlink binaries. + Fix lvresize to pass new size to fsadm when extending device. Remove unused struct in clvmd-openais, and use correct node count. Fix nodes list in clvmd-openais, and allow for broadcast messages. Exclude VG_GLOBAL from internal concurrent VG lock counter. Fix vgsplit internal counting of snapshot LVs. Fix vgmerge snapshot_count when source VG contains snapshots. Simplify clvmd-openais by using non-async saLckResourceLock. - Check lv_count in vg_validate. Fix internal LV counter when a snapshot is removed. Fix metadata corruption writing lvm1-formatted metadata with snapshots. - Add --prefixes to reporting tools for field name prefix output format. Fix lvconvert -m0 allocatable space check. - Fix fsadm.sh to work with older blockdev,blkid,readlink - Fix lvresize - extension was not passing new size to fsadm Version 2.02.35 - 15th April 2008 ================================= --- LVM2/lib/metadata/metadata.c 2008/04/22 12:54:33 1.172 +++ LVM2/lib/metadata/metadata.c 2008/04/29 15:58:24 1.173 @@ -1213,11 +1213,10 @@ if ((lv_count = (uint32_t) list_size(&vg->lvs)) != vg->lv_count + 2 * vg->snapshot_count) { - log_error("Internal error: #internal LVs (%u) != #LVs (%" + log_debug("Internal error: #internal LVs (%u) != #LVs (%" PRIu32 ") + 2 * #snapshots (%" PRIu32 ") in VG %s", list_size(&vg->lvs), vg->lv_count, vg->snapshot_count, vg->name); - r = 0; } list_iterate_items(lvl, &vg->lvs) { --- LVM2/lib/report/report.c 2008/04/20 00:15:08 1.80 +++ LVM2/lib/report/report.c 2008/04/29 15:58:24 1.81 @@ -1091,15 +1091,9 @@ if (headings) report_flags |= DM_REPORT_OUTPUT_HEADINGS; - if (field_prefixes) - report_flags |= DM_REPORT_OUTPUT_FIELD_NAME_PREFIX; - rh = dm_report_init(report_type, _report_types, _fields, format, separator, report_flags, keys, cmd); - if (field_prefixes) - dm_report_set_output_field_name_prefix(rh, "lvm2_"); - return rh; } --- LVM2/scripts/fsadm.sh 2008/04/29 15:25:27 1.6 +++ LVM2/scripts/fsadm.sh 2008/04/29 15:58:24 1.7 @@ -159,7 +159,7 @@ VOLUME=$($READLINK $READLINK_E -n "/dev/$VOLUME") || error "Cannot get readlink $1" # use /dev/null as cache file to be sure about the result # use 'cut' to be compatible with older version of blkid that does not provide option '-o value' - FSTYPE=$($BLKID -c /dev/null -s TYPE "$VOLUME" | cut -d \" -f 2) || error "Cannot get FSTYPE of \"$VOLUME\"" + FSTYPE=$($BLKID -c /dev/null -s TYPE "$VOLUME" | $CUT -d \" -f 2) || error "Cannot get FSTYPE of \"$VOLUME\"" verbose "\"$FSTYPE\" filesystem found on \"$VOLUME\"" } --- LVM2/tools/commands.h 2008/04/20 00:15:08 1.111 +++ LVM2/tools/commands.h 2008/04/29 15:58:25 1.112 @@ -368,7 +368,6 @@ "\t[-o|--options [+]Field[,Field]]\n" "\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n" "\t[-P|--partial] " "\n" - "\t[--prefixes]\n" "\t[--segments]\n" "\t[--separator Separator]\n" "\t[--trustcache]\n" @@ -379,7 +378,7 @@ "\t[LogicalVolume[Path] [LogicalVolume[Path]...]]\n", aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG, - nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, prefixes_ARG, + nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, segments_ARG, separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG) @@ -577,7 +576,6 @@ "\t[-o|--options [+]Field[,Field]]\n" "\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n" "\t[-P|--partial] " "\n" - "\t[--prefixes]\n" "\t[--segments]\n" "\t[--separator Separator]\n" "\t[--trustcache]\n" @@ -588,7 +586,7 @@ "\t[PhysicalVolume [PhysicalVolume...]]\n", aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG, - nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, prefixes_ARG, + nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, segments_ARG, separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG) @@ -894,7 +892,6 @@ "\t[-o|--options [+]Field[,Field]]\n" "\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n" "\t[-P|--partial] " "\n" - "\t[--prefixes]\n" "\t[--separator Separator]\n" "\t[--trustcache]\n" "\t[--unbuffered]\n" @@ -904,7 +901,7 @@ "\t[VolumeGroupName [VolumeGroupName...]]\n", aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG, - nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, prefixes_ARG, + nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG) xx(vgscan, From agk@sourceware.org Tue Apr 29 16:11:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Tue, 29 Apr 2008 16:11:00 -0000 Subject: LVM2 ./VERSION ./WHATS_NEW lib/metadata/metada ... Message-ID: <20080429161130.27932.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-29 16:11:29 Modified files: . : VERSION WHATS_NEW lib/metadata : metadata.c lib/report : report.c tools : commands.h Log message: post-release - reinstate incomplete enhancements Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/VERSION.diff?cvsroot=lvm2&r1=1.173&r2=1.174 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.865&r2=1.866 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/metadata/metadata.c.diff?cvsroot=lvm2&r1=1.173&r2=1.174 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/report/report.c.diff?cvsroot=lvm2&r1=1.81&r2=1.82 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/commands.h.diff?cvsroot=lvm2&r1=1.112&r2=1.113 --- LVM2/VERSION 2008/04/29 15:58:23 1.173 +++ LVM2/VERSION 2008/04/29 16:11:26 1.174 @@ -1 +1 @@ -2.02.36-cvs (2008-04-29) +2.02.37-cvs (2008-04-29) --- LVM2/WHATS_NEW 2008/04/29 15:58:24 1.865 +++ LVM2/WHATS_NEW 2008/04/29 16:11:26 1.866 @@ -1,3 +1,8 @@ +Version 2.02.37 - +================================= + Check lv_count in vg_validate. + Add --prefixes to reporting tools for field name prefix output format. + Version 2.02.36 - 29th April 2008 ================================= Fix fsadm.sh to work with older blockdev, blkid & readlink binaries. --- LVM2/lib/metadata/metadata.c 2008/04/29 15:58:24 1.173 +++ LVM2/lib/metadata/metadata.c 2008/04/29 16:11:27 1.174 @@ -1213,10 +1213,11 @@ if ((lv_count = (uint32_t) list_size(&vg->lvs)) != vg->lv_count + 2 * vg->snapshot_count) { - log_debug("Internal error: #internal LVs (%u) != #LVs (%" + log_error("Internal error: #internal LVs (%u) != #LVs (%" PRIu32 ") + 2 * #snapshots (%" PRIu32 ") in VG %s", list_size(&vg->lvs), vg->lv_count, vg->snapshot_count, vg->name); + r = 0; } list_iterate_items(lvl, &vg->lvs) { --- LVM2/lib/report/report.c 2008/04/29 15:58:24 1.81 +++ LVM2/lib/report/report.c 2008/04/29 16:11:27 1.82 @@ -1091,9 +1091,15 @@ if (headings) report_flags |= DM_REPORT_OUTPUT_HEADINGS; + if (field_prefixes) + report_flags |= DM_REPORT_OUTPUT_FIELD_NAME_PREFIX; + rh = dm_report_init(report_type, _report_types, _fields, format, separator, report_flags, keys, cmd); + if (field_prefixes) + dm_report_set_output_field_name_prefix(rh, "lvm2_"); + return rh; } --- LVM2/tools/commands.h 2008/04/29 15:58:25 1.112 +++ LVM2/tools/commands.h 2008/04/29 16:11:28 1.113 @@ -368,6 +368,7 @@ "\t[-o|--options [+]Field[,Field]]\n" "\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n" "\t[-P|--partial] " "\n" + "\t[--prefixes]\n" "\t[--segments]\n" "\t[--separator Separator]\n" "\t[--trustcache]\n" @@ -378,7 +379,7 @@ "\t[LogicalVolume[Path] [LogicalVolume[Path]...]]\n", aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG, - nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, + nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, prefixes_ARG, segments_ARG, separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG) @@ -576,6 +577,7 @@ "\t[-o|--options [+]Field[,Field]]\n" "\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n" "\t[-P|--partial] " "\n" + "\t[--prefixes]\n" "\t[--segments]\n" "\t[--separator Separator]\n" "\t[--trustcache]\n" @@ -586,7 +588,7 @@ "\t[PhysicalVolume [PhysicalVolume...]]\n", aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG, - nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, + nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, prefixes_ARG, segments_ARG, separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG) @@ -892,6 +894,7 @@ "\t[-o|--options [+]Field[,Field]]\n" "\t[-O|--sort [+|-]key1[,[+|-]key2[,...]]]\n" "\t[-P|--partial] " "\n" + "\t[--prefixes]\n" "\t[--separator Separator]\n" "\t[--trustcache]\n" "\t[--unbuffered]\n" @@ -901,7 +904,7 @@ "\t[VolumeGroupName [VolumeGroupName...]]\n", aligned_ARG, all_ARG, ignorelockingfailure_ARG, noheadings_ARG, - nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, + nolocking_ARG, nosuffix_ARG, options_ARG, partial_ARG, prefixes_ARG, separator_ARG, sort_ARG, trustcache_ARG, unbuffered_ARG, units_ARG) xx(vgscan, From agk@sourceware.org Wed Apr 30 14:34:00 2008 From: agk@sourceware.org (agk@sourceware.org) Date: Wed, 30 Apr 2008 14:34:00 -0000 Subject: LVM2 ./WHATS_NEW tools/vgrename.c Message-ID: <20080430143403.32707.qmail@sourceware.org> CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2008-04-30 14:34:02 Modified files: . : WHATS_NEW tools : vgrename.c Log message: Don't touch /dev in vgrename if activation is disabled. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.866&r2=1.867 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/vgrename.c.diff?cvsroot=lvm2&r1=1.51&r2=1.52 --- LVM2/WHATS_NEW 2008/04/29 16:11:26 1.866 +++ LVM2/WHATS_NEW 2008/04/30 14:34:02 1.867 @@ -1,5 +1,6 @@ Version 2.02.37 - ================================= + Don't touch /dev in vgrename if activation is disabled. Check lv_count in vg_validate. Add --prefixes to reporting tools for field name prefix output format. --- LVM2/tools/vgrename.c 2008/04/08 12:49:21 1.51 +++ LVM2/tools/vgrename.c 2008/04/30 14:34:02 1.52 @@ -122,7 +122,7 @@ sprintf(old_path, "%s%s", dev_dir, vg_name_old); sprintf(new_path, "%s%s", dev_dir, vg_name_new); - if (dir_exists(old_path)) { + if (activation() && dir_exists(old_path)) { log_verbose("Renaming \"%s\" to \"%s\"", old_path, new_path); if (test_mode()) log_verbose("Test mode: Skipping rename.");