master - mirror: Avoid region size compiler warning.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=cb727a1cccc151...
Commit: cb727a1cccc1518a2b193c92ad5bff122b9220c9
Parent: 66d074e913d61bd9e5fa7cc67f25f90b4608b071
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Thu Feb 26 19:45:55 2015 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Thu Feb 26 19:45:55 2015 +0000
mirror: Avoid region size compiler warning.
format ‘%u’ expects type ‘unsigned int’, but argument 7 has type ‘uint64_t’
---
lib/metadata/mirror.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c
index 3f2fa2f..df91002 100644
--- a/lib/metadata/mirror.c
+++ b/lib/metadata/mirror.c
@@ -193,9 +193,7 @@ uint32_t adjusted_mirror_region_size(uint32_t extent_size, uint32_t extents,
* This code should be removed when the CPG restriction is
* lifted.
*/
- region_min = extents;
- region_min *= extent_size;
- region_min /= CMIRROR_REGION_COUNT_LIMIT;
+ region_min = extents * extent_size / CMIRROR_REGION_COUNT_LIMIT;
region_min_pow2 = 1;
while (region_min_pow2 < region_min)
region_min_pow2 *= 2;
@@ -203,11 +201,11 @@ uint32_t adjusted_mirror_region_size(uint32_t extent_size, uint32_t extents,
if (region_size < region_min_pow2) {
if (internal)
log_print_unless_silent("Increasing mirror region size from %"
- PRIu32 " to %" PRIu32 " sectors.",
+ PRIu32 " to %" PRIu64 " sectors.",
region_size, region_min_pow2);
else
log_verbose("Increasing mirror region size from %"
- PRIu32 " to %" PRIu32 " sectors.",
+ PRIu32 " to %" PRIu64 " sectors.",
region_size, region_min_pow2);
region_size = region_min_pow2;
}
9 years, 2 months
master - tests: more system_id tests
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=66d074e913d61b...
Commit: 66d074e913d61bd9e5fa7cc67f25f90b4608b071
Parent: b5394c8f260d091b7a41d78e3dbae32f90386cc4
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu Feb 26 13:22:47 2015 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu Feb 26 13:23:22 2015 -0600
tests: more system_id tests
---
test/shell/system_id.sh | 297 ++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 284 insertions(+), 13 deletions(-)
diff --git a/test/shell/system_id.sh b/test/shell/system_id.sh
index 3ef3e8b..6e80c1a 100644
--- a/test/shell/system_id.sh
+++ b/test/shell/system_id.sh
@@ -552,39 +552,310 @@ echo "$SID1" > $SIDFILE
vgremove $vg1
rm -f $SIDFILE
+# vgcfgbackup backs up foreign vg with --foreign
+SID1=sidfoofile1
+SID2=sidfoofile2
+SIDFILE=etc/lvm_test.conf
+rm -f $LVMLOCAL
+rm -f $SIDFILE
+echo "$SID1" > $SIDFILE
+aux lvmconf "global/system_id_source = file"
+aux lvmconf "global/system_id_file = $SIDFILE"
+# create a vg
+vgcreate $vg1 "$dev1"
+# normal vgs sees the vg
+vgs >err
+grep $vg1 err
+# change the local system_id, making the vg foreign
+echo "$SID2" > $SIDFILE
+# normal vgs doesn't see the vg
+vgs >err
+not grep $vg1 err
+# using --foreign we can back up the vg
+not vgcfgbackup $vg1
+vgcfgbackup --foreign $vg1
+# change our system_id back so we can remove the vg
+echo "$SID1" > $SIDFILE
+vgremove $vg1
+rm -f $SIDFILE
+
+
# Test handling of bad system_id source configurations
# The commands should proceed without a system_id.
# Look at the warning/error messages.
# vgcreate with source machineid, where no /etc/machine-id file exists
-# TODO
+if [ ! -e /etc/machine-id ]; then
+SID=""
+aux lvmconf "global/system_id_source = machineid"
+vgcreate $vg1 "$dev1" |& tee err
+vgs -o+systemid $vg1
+check vg_field $vg1 systemid $SID
+grep "No system ID found from system_id_source" err
+vgremove $vg1
+fi
# vgcreate with source uname, but uname is localhost
-# TODO
+# TODO: don't want to change the hostname on the test machine...
# vgcreate with source lvmlocal, but no lvmlocal.conf file
+SID=""
+rm -f $LVMLOCAL
+aux lvmconf "global/system_id_source = lvmlocal"
+vgcreate $vg1 "$dev1" |& tee err
+vgs -o+systemid $vg1
+check vg_field $vg1 systemid $SID
+grep "No system ID found from system_id_source" err
+vgremove $vg1
+rm -f $LVMLOCAL
+
# vgcreate with source lvmlocal, but no system_id = "x" entry
-# TODO
+SID=""
+LVMLOCAL=etc/lvmlocal.conf
+rm -f $LVMLOCAL
+echo "local {" > $LVMLOCAL
+# echo " system_id = $SID" >> $LVMLOCAL
+echo "}" >> $LVMLOCAL
+aux lvmconf "global/system_id_source = lvmlocal"
+vgcreate $vg1 "$dev1" |& tee err
+vgs -o+systemid $vg1
+check vg_field $vg1 systemid $SID
+grep "No system ID found from system_id_source" err
+vgremove $vg1
+rm -f $LVMLOCAL
+
+# vgcreate with source lvmlocal, and empty string system_id = ""
+SID=""
+LVMLOCAL=etc/lvmlocal.conf
+rm -f $LVMLOCAL
+echo "local {" > $LVMLOCAL
+echo " system_id = \"\"" >> $LVMLOCAL
+echo "}" >> $LVMLOCAL
+aux lvmconf "global/system_id_source = lvmlocal"
+vgcreate $vg1 "$dev1" |& tee err
+vgs -o+systemid $vg1
+check vg_field $vg1 systemid $SID
+grep "No system ID found from system_id_source" err
+vgremove $vg1
+rm -f $LVMLOCAL
# vgcreate with source file, but no system_id_file config
+SID=""
+SIDFILE=etc/lvm_test.conf
+rm -f $SIDFILE
+aux lvmconf "global/system_id_source = file"
+vgcreate $vg1 "$dev1" |& tee err
+vgs -o+systemid $vg1
+check vg_field $vg1 systemid $SID
+grep "No system ID found from system_id_source" err
+vgremove $vg1
+rm -f $SIDFILE
+
# vgcreate with source file, but system_id_file does not exist
-# TODO
+SID=""
+SIDFILE=etc/lvm_test.conf
+rm -f $SIDFILE
+aux lvmconf "global/system_id_source = file"
+aux lvmconf "global/system_id_file = $SIDFILE"
+vgcreate $vg1 "$dev1" |& tee err
+vgs -o+systemid $vg1
+check vg_field $vg1 systemid $SID
+grep "No system ID found from system_id_source" err
+vgremove $vg1
+rm -f $SIDFILE
# Test cases where lvmetad cache of a foreign VG are out of date
# because the foreign owner has changed the VG.
-# . Using the --foreign option should update the cache and produce
-# correct output
-# . Using vgimport should see that the VG is no longer foreign,
-# but has been exported.
-# . pvscan --cache, vgscan --cache should cause the latest
-# version of a foreign VG to be cached in lvmetad.
-# TODO
+test ! -e LOCAL_LVMETAD && exit 0
+
+# When a foreign vg is newer on disk than in lvmetad, using --foreign
+# should find the newer version. This simulates a foreign host changing
+# foreign vg by turning off lvmetad when we create an lv in the vg.
+SID1=sidfoofile1
+SID2=sidfoofile2
+SIDFILE=etc/lvm_test.conf
+rm -f $SIDFILE
+echo "$SID1" > $SIDFILE
+aux lvmconf "global/system_id_source = file"
+aux lvmconf "global/system_id_file = $SIDFILE"
+# create a vg with an lv
+vgcreate $vg1 "$dev1"
+lvcreate -n $lv1 -l 2 -an $vg1
+# normal vgs sees the vg and lv
+vgs >err
+grep $vg1 err
+check lv_exists $vg1 $lv1
+# go around lvmetad to create another lv in the vg,
+# forcing the lvmetad copy to be older than on disk.
+aux lvmconf 'global/use_lvmetad = 0'
+lvcreate -n $lv2 -l 2 -an $vg1
+aux lvmconf 'global/use_lvmetad = 1'
+# verify that the second lv is not in lvmetad
+lvs $vg1 >err
+grep $lv1 err
+not grep $lv2 err
+# change our system_id, making the vg foreign
+echo "$SID2" > $SIDFILE
+vgs >err
+not grep $vg1 err
+# using --foreign, we will get the latest vg from disk
+lvs --foreign $vg1 >err
+grep $vg1 err
+grep $lv1 err
+grep $lv2 err
+# change our system_id back to match the vg so it's not foreign
+echo "$SID1" > $SIDFILE
+lvremove $vg1/$lv1
+lvremove $vg1/$lv2
+vgremove $vg1
+rm -f $SIDFILE
+
+# vgimport should find the exported vg on disk even though
+# lvmetad's copy of the vg shows it's foreign.
+SID1=sidfoofile1
+SID2=sidfoofile2
+SIDFILE=etc/lvm_test.conf
+rm -f $SIDFILE
+echo "$SID1" > $SIDFILE
+aux lvmconf "global/system_id_source = file"
+aux lvmconf "global/system_id_file = $SIDFILE"
+# create a vg with an lv
+vgcreate $vg1 "$dev1"
+lvcreate -n $lv1 -l 2 -an $vg1
+# normal vgs sees the vg and lv
+vgs >err
+grep $vg1 err
+check lv_exists $vg1 $lv1
+# go around lvmetad to export the vg so that lvmetad still
+# has the original vg owned by SID1 in its cache
+aux lvmconf 'global/use_lvmetad = 0'
+vgexport $vg1
+aux lvmconf 'global/use_lvmetad = 1'
+# change the local system_id so the lvmetad copy of the vg is foreign
+echo "$SID2" > $SIDFILE
+# verify that lvmetad thinks the vg is foreign
+# (don't use --foreign to verify this because that will cause
+# the lvmetad cache to be updated, which we don't want yet)
+not vgs $vg1
+# attempt to import the vg that has been exported, but
+# which lvmetad thinks is foreign
+vgimport $vg1
+# verify that the imported vg has our system_id
+vgs -o+systemid $vg1 >err
+grep $vg1 err
+grep $SID2 err
+check lv_exists $vg1 $lv1
+lvremove $vg1/$lv1
+vgremove $vg1
+rm -f $SIDFILE
-# vgcfgbackup --foreign vg
-# TODO
+# pvscan --cache should cause the latest version of a foreign VG to be
+# cached in lvmetad. Without the --cache option, pvscan will see the old
+# version of the VG.
+SID1=sidfoofile1
+SID2=sidfoofile2
+SIDFILE=etc/lvm_test.conf
+rm -f $SIDFILE
+echo "$SID1" > $SIDFILE
+aux lvmconf "global/system_id_source = file"
+aux lvmconf "global/system_id_file = $SIDFILE"
+# create a vg with an lv
+vgcreate $vg1 "$dev1"
+lvcreate -n $lv1 -l 2 -an $vg1
+# normal vgs sees the vg and lv
+vgs >err
+grep $vg1 err
+check lv_exists $vg1 $lv1
+# go around lvmetad to create another lv in the vg,
+# forcing the lvmetad copy to be older than on disk.
+aux lvmconf 'global/use_lvmetad = 0'
+lvcreate -n $lv2 -l 2 -an $vg1
+aux lvmconf 'global/use_lvmetad = 1'
+# verify that the second lv is not in lvmetad
+lvs $vg1 >err
+grep $lv1 err
+not grep $lv2 err
+# verify that after pvscan without --cache, lvmetad still
+# reports the old version
+pvscan
+lvs $vg1 >err
+grep $lv1 err
+not grep $lv2 err
+# change our system_id, making the vg foreign
+echo "$SID2" > $SIDFILE
+not vgs $vg1 >err
+not grep $vg1 err
+# use pvscan --cache to update the foreign vg in lvmetad
+pvscan --cache
+not vgs $vg1 >err
+not grep $vg1 err
+# change our system_id back to SID1 so we can check that
+# lvmetad has the latest copy of the vg (without having
+# to use --foreign to check)
+echo "$SID1" > $SIDFILE
+vgs $vg1 >err
+grep $vg1 err
+lvs $vg1 >err
+grep $lv1 err
+grep $lv2 err
+lvremove $vg1/$lv1
+lvremove $vg1/$lv2
+vgremove $vg1
+rm -f $SIDFILE
+# repeat the same test for vgscan instead of pvscan
+SID1=sidfoofile1
+SID2=sidfoofile2
+SIDFILE=etc/lvm_test.conf
+rm -f $SIDFILE
+echo "$SID1" > $SIDFILE
+aux lvmconf "global/system_id_source = file"
+aux lvmconf "global/system_id_file = $SIDFILE"
+# create a vg with an lv
+vgcreate $vg1 "$dev1"
+lvcreate -n $lv1 -l 2 -an $vg1
+# normal vgs sees the vg and lv
+vgs >err
+grep $vg1 err
+check lv_exists $vg1 $lv1
+# go around lvmetad to create another lv in the vg,
+# forcing the lvmetad copy to be older than on disk.
+aux lvmconf 'global/use_lvmetad = 0'
+lvcreate -n $lv2 -l 2 -an $vg1
+aux lvmconf 'global/use_lvmetad = 1'
+# verify that the second lv is not in lvmetad
+lvs $vg1 >err
+grep $lv1 err
+not grep $lv2 err
+# verify that after vgscan without --cache, lvmetad still
+# reports the old version
+vgscan
+lvs $vg1 >err
+grep $lv1 err
+not grep $lv2 err
+# change our system_id, making the vg foreign
+echo "$SID2" > $SIDFILE
+not vgs $vg1 >err
+not grep $vg1 err
+# use vgscan --cache to update the foreign vg in lvmetad
+vgscan --cache
+not vgs $vg1 >err
+not grep $vg1 err
+# change our system_id back to SID1 so we can check that
+# lvmetad has the latest copy of the vg (without having
+# to use --foreign to check)
+echo "$SID1" > $SIDFILE
+vgs $vg1 >err
+grep $vg1 err
+lvs $vg1 >err
+grep $lv1 err
+grep $lv2 err
+lvremove $vg1/$lv1
+lvremove $vg1/$lv2
+vgremove $vg1
+rm -f $SIDFILE
9 years, 2 months
master - lvchange: Allow -prw to change kernel only.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=b5394c8f260d09...
Commit: b5394c8f260d091b7a41d78e3dbae32f90386cc4
Parent: 71d97fd88afa0d8240569412bb1d3d256e596f6d
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Thu Feb 26 18:38:26 2015 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Thu Feb 26 18:38:26 2015 +0000
lvchange: Allow -prw to change kernel only.
If an LV is already rw but still ro in the kernel, allow -prw to issue a
refresh to try to change the kernel state to rw.
Intended for use after clearing activation/read_only_volume_list in
lvm.conf.
---
tools/lvchange.c | 109 +++++++++++++++++++++++++++++-------------------------
1 files changed, 59 insertions(+), 50 deletions(-)
diff --git a/tools/lvchange.c b/tools/lvchange.c
index b44ef33..6ed953f 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -16,17 +16,18 @@
#include "tools.h"
#include "memlock.h"
-static int lvchange_permission(struct cmd_context *cmd,
- struct logical_volume *lv)
+static int _lvchange_permission(struct cmd_context *cmd,
+ struct logical_volume *lv)
{
uint32_t lv_access;
struct lvinfo info;
+ unsigned info_obtained = 0;
lv_access = arg_uint_value(cmd, permission_ARG, 0);
- if ((lv_access & LVM_WRITE) && (lv->status & LVM_WRITE)) {
- log_error("Logical volume \"%s\" is already writable",
- lv->name);
+ if (lv_is_external_origin(lv)) {
+ log_error("Cannot change permissions of external origin "
+ "\"%s\".", lv->name);
return 0;
}
@@ -36,14 +37,22 @@ static int lvchange_permission(struct cmd_context *cmd,
return 0;
}
- if (lv_is_external_origin(lv)) {
- log_error("Cannot change permissions of external origin "
- "\"%s\".", lv->name);
+ if ((lv_access & LVM_WRITE) && (lv->status & LVM_WRITE)) {
+ /* Refresh if it's read-write in metadata but read-only in kernel */
+ if (lv_info(cmd, lv, 0, &info, 0, 0) &&
+ (info_obtained = 1, info.exists) && info.read_only) {
+ log_print_unless_silent("Logical volume \"%s\" is already writable. Refreshing kernel state.",
+ lv->name);
+ return lv_refresh(cmd, lv);
+ }
+
+ log_error("Logical volume \"%s\" is already writable",
+ lv->name);
return 0;
}
if (lv_is_mirrored(lv) && vg_is_clustered(lv->vg) &&
- lv_info(cmd, lv, 0, &info, 0, 0) && info.exists) {
+ (info_obtained || lv_info(cmd, lv, 0, &info, 0, 0)) && info.exists) {
log_error("Cannot change permissions of mirror \"%s\" "
"while active.", lv->name);
return 0;
@@ -79,8 +88,8 @@ static int lvchange_permission(struct cmd_context *cmd,
return 1;
}
-static int lvchange_pool_update(struct cmd_context *cmd,
- struct logical_volume *lv)
+static int _lvchange_pool_update(struct cmd_context *cmd,
+ struct logical_volume *lv)
{
int update = 0;
unsigned val;
@@ -126,8 +135,8 @@ static int lvchange_pool_update(struct cmd_context *cmd,
return 1;
}
-static int lvchange_monitoring(struct cmd_context *cmd,
- struct logical_volume *lv)
+static int _lvchange_monitoring(struct cmd_context *cmd,
+ struct logical_volume *lv)
{
struct lvinfo info;
@@ -148,8 +157,8 @@ static int lvchange_monitoring(struct cmd_context *cmd,
return 1;
}
-static int lvchange_background_polling(struct cmd_context *cmd,
- struct logical_volume *lv)
+static int _lvchange_background_polling(struct cmd_context *cmd,
+ struct logical_volume *lv)
{
struct lvinfo info;
@@ -257,7 +266,7 @@ static int attach_metadata_devices(struct lv_segment *seg, struct dm_list *list)
*
* Suspend and resume a logical volume.
*/
-static int lvchange_refresh(struct cmd_context *cmd, struct logical_volume *lv)
+static int _lvchange_refresh(struct cmd_context *cmd, struct logical_volume *lv)
{
log_verbose("Refreshing logical volume \"%s\" (if active)", lv->name);
@@ -285,7 +294,7 @@ static int _reactivate_lv(struct logical_volume *lv,
*
* Force a mirror or RAID array to undergo a complete initializing resync.
*/
-static int lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
+static int _lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
{
int active = 0;
int exclusive = 0;
@@ -468,7 +477,7 @@ static int lvchange_resync(struct cmd_context *cmd, struct logical_volume *lv)
return 1;
}
-static int lvchange_alloc(struct cmd_context *cmd, struct logical_volume *lv)
+static int _lvchange_alloc(struct cmd_context *cmd, struct logical_volume *lv)
{
int want_contiguous = arg_int_value(cmd, contiguous_ARG, 0);
alloc_policy_t alloc = (alloc_policy_t)
@@ -499,8 +508,8 @@ static int lvchange_alloc(struct cmd_context *cmd, struct logical_volume *lv)
return 1;
}
-static int lvchange_errorwhenfull(struct cmd_context *cmd,
- struct logical_volume *lv)
+static int _lvchange_errorwhenfull(struct cmd_context *cmd,
+ struct logical_volume *lv)
{
unsigned ewf = arg_int_value(cmd, errorwhenfull_ARG, 0);
@@ -521,8 +530,8 @@ static int lvchange_errorwhenfull(struct cmd_context *cmd,
return 1;
}
-static int lvchange_readahead(struct cmd_context *cmd,
- struct logical_volume *lv)
+static int _lvchange_readahead(struct cmd_context *cmd,
+ struct logical_volume *lv)
{
unsigned read_ahead = 0;
unsigned pagesize = (unsigned) lvm_getpagesize() >> SECTOR_SHIFT;
@@ -566,8 +575,8 @@ static int lvchange_readahead(struct cmd_context *cmd,
return 1;
}
-static int lvchange_persistent(struct cmd_context *cmd,
- struct logical_volume *lv)
+static int _lvchange_persistent(struct cmd_context *cmd,
+ struct logical_volume *lv)
{
enum activation_change activate = CHANGE_AN;
@@ -639,7 +648,7 @@ static int lvchange_persistent(struct cmd_context *cmd,
return 1;
}
-static int lvchange_cachepolicy(struct cmd_context *cmd, struct logical_volume *lv)
+static int _lvchange_cachepolicy(struct cmd_context *cmd, struct logical_volume *lv)
{
struct dm_config_tree *policy = NULL;
int r = 0;
@@ -663,7 +672,7 @@ out:
return r;
}
-static int lvchange_tag(struct cmd_context *cmd, struct logical_volume *lv, int arg)
+static int _lvchange_tag(struct cmd_context *cmd, struct logical_volume *lv, int arg)
{
if (!change_tag(cmd, NULL, lv, NULL, arg))
return_0;
@@ -679,7 +688,7 @@ static int lvchange_tag(struct cmd_context *cmd, struct logical_volume *lv, int
return 1;
}
-static int lvchange_writemostly(struct logical_volume *lv)
+static int _lvchange_writemostly(struct logical_volume *lv)
{
int s, pv_count, i = 0;
char **pv_names;
@@ -779,7 +788,7 @@ static int lvchange_writemostly(struct logical_volume *lv)
return 1;
}
-static int lvchange_recovery_rate(struct logical_volume *lv)
+static int _lvchange_recovery_rate(struct logical_volume *lv)
{
struct cmd_context *cmd = lv->vg->cmd;
struct lv_segment *raid_seg = first_seg(lv);
@@ -810,7 +819,7 @@ static int lvchange_recovery_rate(struct logical_volume *lv)
return 1;
}
-static int lvchange_profile(struct logical_volume *lv)
+static int _lvchange_profile(struct logical_volume *lv)
{
const char *old_profile_name, *new_profile_name;
struct profile *new_profile;
@@ -841,7 +850,7 @@ static int lvchange_profile(struct logical_volume *lv)
return 1;
}
-static int lvchange_activation_skip(struct logical_volume *lv)
+static int _lvchange_activation_skip(struct logical_volume *lv)
{
int skip = arg_int_value(lv->vg->cmd, setactivationskip_ARG, 0);
@@ -860,7 +869,7 @@ static int lvchange_activation_skip(struct logical_volume *lv)
static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
- struct processing_handle *handle __attribute__((unused)))
+ struct processing_handle *handle __attribute__((unused)))
{
int doit = 0, docmds = 0;
struct logical_volume *origin;
@@ -966,7 +975,7 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
if (arg_count(cmd, permission_ARG)) {
if (!archive(lv->vg))
return_ECMD_FAILED;
- doit += lvchange_permission(cmd, lv);
+ doit += _lvchange_permission(cmd, lv);
docmds++;
}
@@ -974,7 +983,7 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
if (arg_count(cmd, contiguous_ARG) || arg_count(cmd, alloc_ARG)) {
if (!archive(lv->vg))
return_ECMD_FAILED;
- doit += lvchange_alloc(cmd, lv);
+ doit += _lvchange_alloc(cmd, lv);
docmds++;
}
@@ -982,7 +991,7 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
if (arg_count(cmd, errorwhenfull_ARG)) {
if (!archive(lv->vg))
return_ECMD_FAILED;
- doit += lvchange_errorwhenfull(cmd, lv);
+ doit += _lvchange_errorwhenfull(cmd, lv);
docmds++;
}
@@ -990,7 +999,7 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
if (arg_count(cmd, readahead_ARG)) {
if (!archive(lv->vg))
return_ECMD_FAILED;
- doit += lvchange_readahead(cmd, lv);
+ doit += _lvchange_readahead(cmd, lv);
docmds++;
}
@@ -998,7 +1007,7 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
if (arg_count(cmd, persistent_ARG)) {
if (!archive(lv->vg))
return_ECMD_FAILED;
- doit += lvchange_persistent(cmd, lv);
+ doit += _lvchange_persistent(cmd, lv);
docmds++;
if (sigint_caught())
return_ECMD_FAILED;
@@ -1008,7 +1017,7 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
arg_count(cmd, zero_ARG)) {
if (!archive(lv->vg))
return_ECMD_FAILED;
- doit += lvchange_pool_update(cmd, lv);
+ doit += _lvchange_pool_update(cmd, lv);
docmds++;
}
@@ -1016,7 +1025,7 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
if (arg_count(cmd, addtag_ARG)) {
if (!archive(lv->vg))
return_ECMD_FAILED;
- doit += lvchange_tag(cmd, lv, addtag_ARG);
+ doit += _lvchange_tag(cmd, lv, addtag_ARG);
docmds++;
}
@@ -1024,7 +1033,7 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
if (arg_count(cmd, deltag_ARG)) {
if (!archive(lv->vg))
return_ECMD_FAILED;
- doit += lvchange_tag(cmd, lv, deltag_ARG);
+ doit += _lvchange_tag(cmd, lv, deltag_ARG);
docmds++;
}
@@ -1032,7 +1041,7 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
if (arg_count(cmd, writemostly_ARG) || arg_count(cmd, writebehind_ARG)) {
if (!archive(lv->vg))
return_ECMD_FAILED;
- doit += lvchange_writemostly(lv);
+ doit += _lvchange_writemostly(lv);
docmds++;
}
@@ -1041,7 +1050,7 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
arg_count(cmd, maxrecoveryrate_ARG)) {
if (!archive(lv->vg))
return_ECMD_FAILED;
- doit += lvchange_recovery_rate(lv);
+ doit += _lvchange_recovery_rate(lv);
docmds++;
}
@@ -1050,21 +1059,21 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
arg_count(cmd, detachprofile_ARG)) {
if (!archive(lv->vg))
return_ECMD_FAILED;
- doit += lvchange_profile(lv);
+ doit += _lvchange_profile(lv);
docmds++;
}
if (arg_count(cmd, setactivationskip_ARG)) {
if (!archive(lv->vg))
return_ECMD_FAILED;
- doit += lvchange_activation_skip(lv);
+ doit += _lvchange_activation_skip(lv);
docmds++;
}
if (arg_count(cmd, cachepolicy_ARG) || arg_count(cmd, cachesettings_ARG)) {
if (!archive(lv->vg))
return_ECMD_FAILED;
- doit += lvchange_cachepolicy(cmd, lv);
+ doit += _lvchange_cachepolicy(cmd, lv);
docmds++;
}
@@ -1072,7 +1081,7 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
log_print_unless_silent("Logical volume \"%s\" changed.", lv->name);
if (arg_count(cmd, resync_ARG) &&
- !lvchange_resync(cmd, lv))
+ !_lvchange_resync(cmd, lv))
return_ECMD_FAILED;
if (arg_count(cmd, syncaction_ARG) &&
@@ -1084,15 +1093,15 @@ static int _lvchange_single(struct cmd_context *cmd, struct logical_volume *lv,
if (!_lvchange_activate(cmd, lv))
return_ECMD_FAILED;
} else if (arg_count(cmd, refresh_ARG)) {
- if (!lvchange_refresh(cmd, lv))
+ if (!_lvchange_refresh(cmd, lv))
return_ECMD_FAILED;
} else {
if (arg_count(cmd, monitor_ARG) &&
- !lvchange_monitoring(cmd, lv))
+ !_lvchange_monitoring(cmd, lv))
return_ECMD_FAILED;
if (arg_count(cmd, poll_ARG) &&
- !lvchange_background_polling(cmd, lv))
+ !_lvchange_background_polling(cmd, lv))
return_ECMD_FAILED;
}
@@ -1136,8 +1145,8 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
int update = update_partial_safe || update_partial_unsafe;
if (!update &&
- !arg_count(cmd, activate_ARG) && !arg_count(cmd, refresh_ARG) &&
- !arg_count(cmd, monitor_ARG) && !arg_count(cmd, poll_ARG)) {
+ !arg_count(cmd, activate_ARG) && !arg_count(cmd, refresh_ARG) &&
+ !arg_count(cmd, monitor_ARG) && !arg_count(cmd, poll_ARG)) {
log_error("Need 1 or more of -a, -C, -M, -p, -r, -Z, "
"--resync, --refresh, --alloc, --addtag, --deltag, "
"--monitor, --poll or --discards");
9 years, 2 months
master - man: lvmsystemid: empty string equals no system_id
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=71d97fd88afa0d...
Commit: 71d97fd88afa0d8240569412bb1d3d256e596f6d
Parent: efd7480de3c1be4c0e7fe2508158dce930bc2c7c
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Feb 25 16:55:56 2015 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Feb 25 16:55:56 2015 -0600
man: lvmsystemid: empty string equals no system_id
---
man/lvmsystemid.7.in | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/man/lvmsystemid.7.in b/man/lvmsystemid.7.in
index e188c12..42eee31 100644
--- a/man/lvmsystemid.7.in
+++ b/man/lvmsystemid.7.in
@@ -41,7 +41,7 @@ maximum length of a system_id is 128 characters.
.SS Limitations and warnings
To benefit fully from system_id, all hosts must have system_id set, and
-VGs must have system_id set. A VG on shared storage can be corrupted or
+VGs must have system_id set. A VG on shared storage can be damaged or
destroyed in the following cases which the user must be careful to avoid:
.IP \[bu] 2
@@ -220,8 +220,8 @@ local {
.SS vgcreate
-In vgcreate, a host sets its own system_id in the VG metadata.
-To override this and set another system_id:
+In vgcreate, the host running the command assigns its own system_id to the
+new VG. To override this and set another system_id:
.B vgcreate --systemid
.I SystemID VG Devices
@@ -231,6 +231,9 @@ it may not be able to use. Another host with a system_id matching the one
specified may not recognize the new VG without manually rescanning
devices.
+If the --systemid argument is an empty string (""), the VG is created with
+no system_id, making it accessible to other hosts (see warnings above.)
+
.SS report/display
The system_id of a VG is displayed with the "systemid" reporting option.
@@ -272,6 +275,10 @@ confirmation because the host may lose access to the VG being changed:
.B vgchange --systemid
.I SystemID VG
+The system_id can be removed from a VG by specifying an empty string ("")
+as the new system_id. This makes the VG accessible to other hosts (see
+warnings above.)
+
A host cannot directly change the system_id of a foreign VG.
To move a VG from one host to another, vgexport and vgimport should be
9 years, 2 months
master - tests: add more system_id tests
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=efd7480de3c1be...
Commit: efd7480de3c1be4c0e7fe2508158dce930bc2c7c
Parent: 1248f94a429faa245968a9efe04250f27a53bc18
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Feb 25 16:13:28 2015 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Feb 25 16:13:28 2015 -0600
tests: add more system_id tests
---
test/shell/system_id.sh | 115 ++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 109 insertions(+), 6 deletions(-)
diff --git a/test/shell/system_id.sh b/test/shell/system_id.sh
index 43d1203..3ef3e8b 100644
--- a/test/shell/system_id.sh
+++ b/test/shell/system_id.sh
@@ -443,9 +443,114 @@ lvremove $vg1/$lv1
vgremove $vg1
rm -f $SIDFILE
-
# use extra_system_ids to read a foreign VG
-# TODO
+
+SID1=sidfoofile1
+SID2=sidfoofile2
+SIDFILE=etc/lvm_test.conf
+LVMLOCAL=etc/lvmlocal.conf
+rm -f $LVMLOCAL
+rm -f $SIDFILE
+echo "$SID1" > $SIDFILE
+aux lvmconf "global/system_id_source = file"
+aux lvmconf "global/system_id_file = $SIDFILE"
+# create a vg
+vgcreate $vg1 "$dev1"
+# normal vgs sees the vg
+vgs >err
+grep $vg1 err
+# change the local system_id, making the vg foreign
+echo "$SID2" > $SIDFILE
+# normal vgs doesn't see the vg
+vgs >err
+not grep $vg1 err
+# using --foreign we can see the vg
+vgs --foreign >err
+grep $vg1 err
+# add the first system_id to extra_system_ids so we can see the vg
+echo "local {" > $LVMLOCAL
+echo " extra_system_ids = [ $SID1" ] >> $LVMLOCAL
+echo "}" >> $LVMLOCAL
+vgs >err
+grep $vg1 err
+vgremove $vg1
+rm -f $SIDFILE
+rm -f $LVMLOCAL
+
+# vgcreate --systemid "" creates a vg without a system_id even if source is set
+SID1=sidfoofile1
+SIDFILE=etc/lvm_test.conf
+rm -f $SIDFILE
+echo "$SID1" > $SIDFILE
+aux lvmconf "global/system_id_source = file"
+aux lvmconf "global/system_id_file = $SIDFILE"
+# create a vg
+vgcreate --systemid "" $vg1 "$dev1"
+# normal vgs sees the vg
+vgs >err
+grep $vg1 err
+# our system_id is not displayed for the vg
+vgs -o+systemid >err
+not grep $SID1 err
+vgremove $vg1
+rm -f $SIDFILE
+
+# vgchange --systemid "" clears the system_id on owned vg
+SID1=sidfoofile1
+SIDFILE=etc/lvm_test.conf
+rm -f $SIDFILE
+echo "$SID1" > $SIDFILE
+aux lvmconf "global/system_id_source = file"
+aux lvmconf "global/system_id_file = $SIDFILE"
+# create a vg
+vgcreate $vg1 "$dev1"
+# normal vgs sees the vg
+vgs >err
+grep $vg1 err
+# the vg has our system_id
+vgs -o+systemid >err
+grep $SID1 err
+# clear the system_id
+vgchange --yes --systemid "" $vg1
+# normal vgs sees the vg
+vgs >err
+grep $vg1 err
+# the vg does not have our system_id
+vgs -o+systemid >err
+not grep $SID1 err
+vgremove $vg1
+rm -f $SIDFILE
+
+# vgchange --systemid does not set the system_id on foreign vg
+SID1=sidfoofile1
+SID2=sidfoofile2
+SIDFILE=etc/lvm_test.conf
+rm -f $LVMLOCAL
+rm -f $SIDFILE
+echo "$SID1" > $SIDFILE
+aux lvmconf "global/system_id_source = file"
+aux lvmconf "global/system_id_file = $SIDFILE"
+# create a vg
+vgcreate $vg1 "$dev1"
+# normal vgs sees the vg
+vgs >err
+grep $vg1 err
+# change the local system_id, making the vg foreign
+echo "$SID2" > $SIDFILE
+# normal vgs doesn't see the vg
+vgs >err
+not grep $vg1 err
+# using --foreign we can see the vg
+vgs --foreign >err
+grep $vg1 err
+# cannot clear the system_id of the foreign vg
+not vgchange --yes --systemid "" $vg1
+# cannot set the system_id of the foreign vg
+not vgchange --yes --systemid foo $vg1
+# change our system_id back so we can remove the vg
+echo "$SID1" > $SIDFILE
+vgremove $vg1
+rm -f $SIDFILE
# Test handling of bad system_id source configurations
@@ -473,10 +578,8 @@ rm -f $SIDFILE
# correct output
# . Using vgimport should see that the VG is no longer foreign,
# but has been exported.
-# TODO
-
-
-# --systemid "" equals none
+# . pvscan --cache, vgscan --cache should cause the latest
+# version of a foreign VG to be cached in lvmetad.
# TODO
9 years, 2 months
master - pvscan, vgscan: include foreign vgs with --cache
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1248f94a429faa...
Commit: 1248f94a429faa245968a9efe04250f27a53bc18
Parent: bbaabb8a59980995dfa94948589034c6a93b9f5a
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Feb 25 15:41:15 2015 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Feb 25 15:46:27 2015 -0600
pvscan, vgscan: include foreign vgs with --cache
pvscan --cache and vgscan --cache scan devices to refresh lvmetad,
and they should also refresh the lvmetad copy of foreign vgs.
---
tools/commands.h | 2 +-
tools/pvscan.c | 2 ++
tools/vgscan.c | 2 ++
3 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/tools/commands.h b/tools/commands.h
index 5cd7c2d..719c507 100644
--- a/tools/commands.h
+++ b/tools/commands.h
@@ -616,7 +616,7 @@ xx(lvs,
xx(lvscan,
"List all logical volumes in all volume groups",
- PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT | ENABLE_FOREIGN_VGS,
+ PERMITTED_READ_ONLY | ALL_VGS_IS_DEFAULT,
"lvscan\n"
"\t[-a|--all]\n"
"\t[-b|--blockdevice]\n"
diff --git a/tools/pvscan.c b/tools/pvscan.c
index 4ab2ff7..a04a4b2 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -189,6 +189,8 @@ static int _pvscan_lvmetad(struct cmd_context *cmd, int argc, char **argv)
dev_t devno;
activation_handler handler = NULL;
+ cmd->include_foreign_vgs = 1;
+
/*
* Return here immediately if lvmetad is not used.
* Also return if locking_type=3 (clustered) as we
diff --git a/tools/vgscan.c b/tools/vgscan.c
index b3af9bc..7328a09 100644
--- a/tools/vgscan.c
+++ b/tools/vgscan.c
@@ -47,6 +47,8 @@ int vgscan(struct cmd_context *cmd, int argc, char **argv)
lvmcache_destroy(cmd, 1, 0);
if (arg_count(cmd, cache_long_ARG)) {
+ cmd->include_foreign_vgs = 1;
+
if (lvmetad_active()) {
if (!lvmetad_pvscan_all_devs(cmd, NULL))
return ECMD_FAILED;
9 years, 2 months
master - WHATS_NEW: vgimport with lvmetad
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=bbaabb8a599809...
Commit: bbaabb8a59980995dfa94948589034c6a93b9f5a
Parent: 2c50cbe8cbd5197793abb6f43f42b53980cdc65e
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Feb 25 12:30:00 2015 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Feb 25 14:59:24 2015 -0600
WHATS_NEW: vgimport with lvmetad
---
WHATS_NEW | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/WHATS_NEW b/WHATS_NEW
index c119f3e..f4c4cde 100644
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
Version 2.02.117 -
====================================
+ Rescan devices before vgimport with lvmetad so exported VG is seen.
Fix hang by adjusting cluster mirror regionsize, avoiding CPG msg limit.
Do not crash when --cachepolicy is given without --cachesettings.
Add NEEDS_FOREIGN_VGS flag to vgimport so --foreign is always supplied.
9 years, 2 months
master - tests: fix the system_id tests
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=2c50cbe8cbd519...
Commit: 2c50cbe8cbd5197793abb6f43f42b53980cdc65e
Parent: ebb2205b4c56aa99cb77939eff396665c47f082d
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Feb 25 12:27:49 2015 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Feb 25 14:58:49 2015 -0600
tests: fix the system_id tests
That were broken by yesterday's system_id changes.
---
man/lvmsystemid.7.in | 2 +-
test/shell/system_id.sh | 22 +++++++++++-----------
2 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/man/lvmsystemid.7.in b/man/lvmsystemid.7.in
index 741aafe..e188c12 100644
--- a/man/lvmsystemid.7.in
+++ b/man/lvmsystemid.7.in
@@ -36,7 +36,7 @@ Valid system_id characters are the same as valid VG name characters. If a
system_id contains invalid characters, those characters are omitted and
remaining characters are used. If a system_id is longer than the maximum
name length, the characters up to the maximum length are used. The
-maximum length of a system_id is 127 characters.
+maximum length of a system_id is 128 characters.
.SS Limitations and warnings
diff --git a/test/shell/system_id.sh b/test/shell/system_id.sh
index 5327153..43d1203 100644
--- a/test/shell/system_id.sh
+++ b/test/shell/system_id.sh
@@ -298,15 +298,15 @@ grep $SID1 err
vgremove $vg1
rm -f $SIDFILE
-# Test max system_id length (127) and invalid system_id characters.
-# The 127 length limit is imposed before invalid characters are omitted.
+# Test max system_id length (128) and invalid system_id characters.
+# The 128 length limit is imposed before invalid characters are omitted.
SIDFILE=etc/lvm_test.conf
-# 120 numbers followed by 7 letters (max len)
-SID1=012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789abcdefg
-# 120 numbers followed by 8 letters (too long by 1 character, the last is omitted)
-SID2=012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789abcdefgh
+# 120 numbers followed by 8 letters (max len)
+SID1=012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789abcdefgh
+# 120 numbers followed by 9 letters (too long by 1 character, the last is omitted)
+SID2=012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789abcdefghi
# max len system_id should appear normally
rm -f $SIDFILE
@@ -339,11 +339,11 @@ rm -f $SIDFILE
# max len system_id containing an invalid character should appear without
# the invalid character
-# 120 numbers followed by invalid '#' character followed by 7 letters (too long by 1 character)
-SID1=012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789#abcdefg
+# 120 numbers followed by invalid '%' character followed by 8 letters (too long by 1 character)
+SID1=012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789%abcdefgh
# After the invalid character is omitted from SID1
-# The string is truncated to max length (127) before the invalid character is omitted
-SID2=012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789abcdef
+# The string is truncated to max length (128) before the invalid character is omitted
+SID2=012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789abcdefg
rm -f $SIDFILE
echo "$SID1" > $SIDFILE
aux lvmconf "global/system_id_source = file"
@@ -359,7 +359,7 @@ vgremove $vg1
rm -f $SIDFILE
# contains a bunch of invalid characters
-SID1="?#$&A.@1]"
+SID1="?%$&A.@1]"
# SID1 without the invalid characters
SID2=A.1
9 years, 2 months
master - tests: add more systemid tests
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=ebb2205b4c56aa...
Commit: ebb2205b4c56aa99cb77939eff396665c47f082d
Parent: dd6a2028316febc4a44785c1cacacea0e53f8f76
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Feb 25 12:23:34 2015 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Feb 25 14:58:49 2015 -0600
tests: add more systemid tests
---
test/shell/system_id.sh | 71 +++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 69 insertions(+), 2 deletions(-)
diff --git a/test/shell/system_id.sh b/test/shell/system_id.sh
index 3312ab6..5327153 100644
--- a/test/shell/system_id.sh
+++ b/test/shell/system_id.sh
@@ -380,11 +380,69 @@ rm -f $SIDFILE
# pvs: pv in a foreign vg not reported
# pvs --foreign: pv in a foreign vg is reported
-# TODO
+
+SID1=sidfoofile1
+SID2=sidfoofile2
+SIDFILE=etc/lvm_test.conf
+rm -f $SIDFILE
+echo "$SID1" > $SIDFILE
+aux lvmconf "global/system_id_source = file"
+aux lvmconf "global/system_id_file = $SIDFILE"
+# create a vg
+vgcreate $vg1 "$dev1"
+# normal pvs sees the vg and pv
+pvs >err
+grep $vg1 err
+grep $dev1 err
+# change the local system_id, making the vg foreign
+echo "$SID2" > $SIDFILE
+# normal pvs does not see the vg or pv
+pvs >err
+not grep $vg1 err
+not grep $dev1 err
+# pvs --foreign does see the vg and pv
+pvs --foreign >err
+grep $vg1 err
+grep $dev1 err
+# change the local system_id back so the vg can be removed
+echo "$SID1" > $SIDFILE
+vgremove $vg1
+rm -f $SIDFILE
# lvs: lvs in a foreign vg not reported
# lvs --foreign: lvs in a foreign vg are reported
-# TODO
+
+SID1=sidfoofile1
+SID2=sidfoofile2
+SIDFILE=etc/lvm_test.conf
+rm -f $SIDFILE
+echo "$SID1" > $SIDFILE
+aux lvmconf "global/system_id_source = file"
+aux lvmconf "global/system_id_file = $SIDFILE"
+# create a vg
+vgcreate $vg1 "$dev1"
+lvcreate -n $lv1 -l 2 $vg1
+lvchange -an $vg1/$lv1
+# normal lvs sees the vg and lv
+lvs >err
+grep $vg1 err
+grep $lv1 err
+# change the local system_id, making the vg foreign
+echo "$SID2" > $SIDFILE
+# normal lvs does not see the vg or lv
+lvs >err
+not grep $vg1 err
+not grep $lv1 err
+# lvs --foreign does see the vg and lv
+lvs --foreign >err
+grep $vg1 err
+grep $lv1 err
+# change the local system_id back so the vg can be removed
+echo "$SID1" > $SIDFILE
+lvremove $vg1/$lv1
+vgremove $vg1
+rm -f $SIDFILE
+
# use extra_system_ids to read a foreign VG
# TODO
@@ -418,3 +476,12 @@ rm -f $SIDFILE
# TODO
+# --systemid "" equals none
+# TODO
+
+
+# vgcfgbackup --foreign vg
+# TODO
+
+
+
9 years, 2 months
master - lvchange: deactivate is always possible in foreign vgs
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=dd6a2028316feb...
Commit: dd6a2028316febc4a44785c1cacacea0e53f8f76
Parent: dd0ee35378cc2ff405183fea9a3d970aab96ac63
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Feb 25 11:33:11 2015 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Feb 25 14:58:49 2015 -0600
lvchange: deactivate is always possible in foreign vgs
The only realistic way for a host to have active LVs in a
foreign VG is if the host's system_id (or system_id_source)
is changed while LVs are active.
In this case, the active LVs produce an warning, and access
to the VG is implicitly allowed (without requiring --foreign.)
This allows the active LVs to be deactivated.
In this case, rescanning PVs for the VG offers no benefit.
It is not possible that rescanning would reveal an LV that
is active but wasn't previously in the VG metadata.
---
lib/commands/toolcontext.h | 1 +
lib/metadata/metadata.c | 4 +++-
tools/lvchange.c | 20 +++++++++++++++-----
tools/lvmcmdline.c | 1 +
4 files changed, 20 insertions(+), 6 deletions(-)
diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h
index f491d1c..28f5a2c 100644
--- a/lib/commands/toolcontext.h
+++ b/lib/commands/toolcontext.h
@@ -98,6 +98,7 @@ struct cmd_context {
unsigned independent_metadata_areas:1; /* Active formats have MDAs outside PVs */
unsigned unknown_system_id:1;
unsigned include_foreign_vgs:1;
+ unsigned include_active_foreign_vgs:1;
unsigned error_foreign_vgs:1;
struct dev_types *dev_types;
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
index f011af8..5ae3780 100644
--- a/lib/metadata/metadata.c
+++ b/lib/metadata/metadata.c
@@ -4418,7 +4418,9 @@ static int _access_vg_systemid(struct cmd_context *cmd, struct volume_group *vg)
if (lvs_in_vg_activated(vg)) {
log_warn("WARNING: Found LVs active in VG %s with foreign system ID \"%s\". Possible data corruption.",
vg->name, vg->system_id);
- return 1;
+ if (cmd->include_active_foreign_vgs)
+ return 1;
+ return 0;
}
/*
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 1ed0dd5..b44ef33 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -170,6 +170,18 @@ static int _lvchange_activate(struct cmd_context *cmd, struct logical_volume *lv
activate = (activation_change_t) arg_uint_value(cmd, activate_ARG, CHANGE_AY);
+ /*
+ * We can get here in the odd case where an LV is already active in
+ * a foreign VG, which allows the VG to be accessed by lvchange -a
+ * so the LV can be deactivated.
+ */
+ if (lv->vg->system_id && cmd->system_id &&
+ strcmp(lv->vg->system_id, cmd->system_id) &&
+ is_change_activating(activate)) {
+ log_error("Cannot activate LVs in a foreign VG.");
+ return ECMD_FAILED;
+ }
+
if (lv_activation_skip(lv, activate, arg_count(cmd, ignoreactivationskip_ARG)))
return 1;
@@ -1178,11 +1190,6 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
return EINVALID_CMD_LINE;
}
- if (!update && !arg_count(cmd, refresh_ARG) && !arg_count(cmd, monitor_ARG) && !arg_count(cmd, poll_ARG) &&
- arg_count(cmd, activate_ARG) &&
- !is_change_activating((activation_change_t) arg_uint_value(cmd, activate_ARG, CHANGE_AY)))
- cmd->include_foreign_vgs = 1;
-
/*
* If --sysinit -aay is used and at the same time lvmetad is used,
* we want to rely on autoactivation to take place. Also, we
@@ -1212,6 +1219,9 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
}
}
+ if (arg_is_set(cmd, activate_ARG))
+ cmd->include_active_foreign_vgs = 1;
+
return process_each_lv(cmd, argc, argv,
update ? READ_FOR_UPDATE : 0, NULL,
&_lvchange_single);
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 7a11183..255fa41 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1077,6 +1077,7 @@ static int _get_settings(struct cmd_context *cmd)
cmd->ignore_clustered_vgs = arg_is_set(cmd, ignoreskippedcluster_ARG);
cmd->error_foreign_vgs = cmd->command->flags & ENABLE_FOREIGN_VGS ? 0 : 1;
cmd->include_foreign_vgs = arg_is_set(cmd, foreign_ARG) ? 1 : 0;
+ cmd->include_active_foreign_vgs = cmd->command->flags & ENABLE_FOREIGN_VGS ? 1 : 0;
if (!arg_count(cmd, sysinit_ARG))
lvmetad_connect_or_warn();
9 years, 2 months