master - tests: expand lvm-on-md
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6ff1583c1ba58d045fb...
Commit: 6ff1583c1ba58d045fb5c8a198698e0d13f1acee
Parent: 1e9e21a171db49b75e1c7276b05ef2959a340c4e
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri May 3 14:05:40 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri May 3 14:39:42 2019 -0500
tests: expand lvm-on-md
test both md raid0 and raid1
---
test/shell/lvm-on-md.sh | 151 ++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 136 insertions(+), 15 deletions(-)
diff --git a/test/shell/lvm-on-md.sh b/test/shell/lvm-on-md.sh
index 4f4a0c4..4c66431 100644
--- a/test/shell/lvm-on-md.sh
+++ b/test/shell/lvm-on-md.sh
@@ -12,12 +12,30 @@
SKIP_WITH_LVMPOLLD=1
+RUNDIR="/run"
+test -d "$RUNDIR" || RUNDIR="/var/run"
+PVS_ONLINE_DIR="$RUNDIR/lvm/pvs_online"
+VGS_ONLINE_DIR="$RUNDIR/lvm/vgs_online"
+
+_clear_online_files() {
+ # wait till udev is finished
+ aux udev_wait
+ rm -f "$PVS_ONLINE_DIR"/*
+ rm -f "$VGS_ONLINE_DIR"/*
+}
+
. lib/inittest
test -f /proc/mdstat && grep -q raid1 /proc/mdstat || \
modprobe raid1 || skip
aux lvmconf 'devices/md_component_detection = 1'
+
+# This stops lvm from asking udev if a dev is an md component.
+# LVM will ask udev if a dev is an md component, but we don't
+# want to rely on that ability in this test.
+aux lvmconf 'devices/obtain_device_list_from_udev = 0'
+
aux extend_filter_LVMTEST "a|/dev/md|"
aux prepare_devs 2
@@ -26,31 +44,31 @@ aux prepare_devs 2
# by default using metadata format 1.0 with data at the end of device
aux prepare_md_dev 1 64 2 "$dev1" "$dev2"
+cat /proc/mdstat
+
mddev=$(< MD_DEV)
pvdev=$(< MD_DEV_PV)
vgcreate $vg "$mddev"
-lvs $vg
-
lvcreate -n $lv1 -l 2 $vg
lvcreate -n $lv2 -l 2 -an $vg
lvchange -ay $vg/$lv2
+check lv_field $vg/$lv1 lv_active "active"
-lvs $vg
-
-pvs -vvvv 2>&1|tee pvs.out
-
-vgchange -an $vg
-
-vgchange -ay -vvvv $vg 2>&1| tee vgchange.out
-
-lvs $vg
-pvs
+# lvm does not show md components as PVs
+pvs "$mddev"
+not pvs "$dev1"
+not pvs "$dev2"
+sleep 1
vgchange -an $vg
+sleep 1
+# When the md device is started, lvm will see that and know to
+# scan for md components, so stop the md device to remove this
+# advantage so we will test the fallback detection.
mdadm --stop "$mddev"
aux udev_wait
@@ -61,14 +79,114 @@ pvs 2>&1 |tee out
cat out
grep "prefers device" out
-pvs -vvvv 2>&1| tee pvs2.out
+# should not activate from the md legs
+not vgchange -ay $vg
+
+# should not show an active lv
+rm out
+lvs -o active $vg |tee out || true
+not grep "active" out
+
+# should not allow updating vg
+not lvcreate -l1 $vg
# should not activate from the md legs
-not vgchange -ay -vvvv $vg 2>&1|tee vgchange-fail.out
+_clear_online_files
+pvscan --cache -aay "$dev1"
+pvscan --cache -aay "$dev2"
# should not show an active lv
+rm out
+lvs -o active $vg |tee out || true
+not grep "active" out
+
+# start the md dev
+mdadm --assemble "$mddev" "$dev1" "$dev2"
+aux udev_wait
+
+# Now that the md dev is online, pvs can see it and
+# ignore the two legs, so there's no duplicate warning
+
+pvs 2>&1 |tee out
+cat out
+not grep "prefers device" out
+
+vgchange -ay $vg 2>&1 |tee out
+cat out
+not grep "prefers device" out
+
+check lv_field $vg/$lv1 lv_active "active"
+
+vgchange -an $vg
+aux udev_wait
+
+vgremove -f $vg
+
+aux cleanup_md_dev
+
+wipefs -a "$dev1"
+wipefs -a "$dev2"
+
+
+# create 2 disk MD raid0 array
+# by default using metadata format 1.0 with data at the end of device
+# When a raid0 md array is stopped, the components will not look like
+# duplicate PVs as they do with raid1.
+aux prepare_md_dev 0 64 2 "$dev1" "$dev2"
+
+cat /proc/mdstat
+
+mddev=$(< MD_DEV)
+pvdev=$(< MD_DEV_PV)
+
+vgcreate $vg "$mddev"
+
lvs $vg
+lvcreate -n $lv1 -l 2 $vg
+lvcreate -n $lv2 -l 2 -an $vg
+
+lvchange -ay $vg/$lv2
+check lv_field $vg/$lv1 lv_active "active"
+
+# lvm does not show md components as PVs
+pvs "$mddev"
+not pvs "$dev1"
+not pvs "$dev2"
+sleep 1
+
+vgchange -an $vg
+sleep 1
+
+# When the md device is started, lvm will see that and know to
+# scan for md components, so stop the md device to remove this
+# advantage so we will test the fallback detection.
+mdadm --stop "$mddev"
+aux udev_wait
+
+pvs 2>&1 |tee pvs.out
+
+# should not activate from the md legs
+not vgchange -ay $vg
+
+# should not show an active lv
+rm out
+lvs -o active $vg |tee out || true
+not grep "active" out
+
+# should not allow updating vg
+not lvcreate -l1 $vg
+
+# should not activate from the md legs
+_clear_online_files
+pvscan --cache -aay "$dev1"
+pvscan --cache -aay "$dev2"
+
+# should not show an active lv
+rm out
+lvs -o active $vg |tee out || true
+not grep "active" out
+
# start the md dev
mdadm --assemble "$mddev" "$dev1" "$dev2"
aux udev_wait
@@ -84,9 +202,12 @@ vgchange -ay $vg 2>&1 |tee out
cat out
not grep "prefers device" out
+check lv_field $vg/$lv1 lv_active "active"
+
vgchange -an $vg
aux udev_wait
+vgremove -f $vg
+
aux cleanup_md_dev
-# vgremove -f $vg
4 years, 11 months
master - pvscan: don't record PV online after error reading metadata
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1e9e21a171db49b75e1...
Commit: 1e9e21a171db49b75e1c7276b05ef2959a340c4e
Parent: 607858538132a33a27039e0ff4796b1a7d9f4f32
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu May 2 16:54:28 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri May 3 14:39:42 2019 -0500
pvscan: don't record PV online after error reading metadata
---
tools/pvscan.c | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/tools/pvscan.c b/tools/pvscan.c
index d3b2b8e..e389106 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -511,6 +511,7 @@ struct _pvscan_baton {
struct cmd_context *cmd;
struct volume_group *vg;
struct format_instance *fid;
+ int mda_read_errors;
};
static int _online_pvscan_single(struct metadata_area *mda, void *baton)
@@ -518,9 +519,13 @@ static int _online_pvscan_single(struct metadata_area *mda, void *baton)
struct _pvscan_baton *b = baton;
struct volume_group *vg;
- if (mda_is_ignored(mda) ||
- !(vg = mda->ops->vg_read(b->fid, "", mda, NULL, NULL)))
+ if (mda_is_ignored(mda))
return 1;
+ vg = mda->ops->vg_read(b->fid, "", mda, NULL, NULL);
+ if (!vg) {
+ b->mda_read_errors++;
+ return 1;
+ }
/* FIXME Also ensure contents match etc. */
if (!b->vg || vg->seqno > b->vg->seqno)
@@ -586,6 +591,7 @@ static int _online_pvscan_one(struct cmd_context *cmd, struct device *dev,
fmt = lvmcache_fmt(info);
+ memset(&baton, 0, sizeof(baton));
baton.cmd = cmd;
baton.vg = NULL;
baton.fid = fmt->ops->create_instance(fmt, &fic);
@@ -597,6 +603,16 @@ static int _online_pvscan_one(struct cmd_context *cmd, struct device *dev,
lvmcache_foreach_mda(info, _online_pvscan_single, &baton);
+ if (baton.mda_read_errors) {
+ /* Don't record the PV as online if there are errors reading the vg. */
+ log_print("pvscan[%d] PV %s ignore for metadata processing error.", getpid(), dev_name(dev));
+ if (baton.vg)
+ release_vg(baton.vg);
+ else
+ fmt->ops->destroy_instance(baton.fid);
+ return 1;
+ }
+
if (!baton.vg) {
if (pvid_without_metadata)
*pvid_without_metadata = dm_pool_strdup(cmd->mem, dev->pvid);
4 years, 11 months
master - add md component check in vg_read based on size
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=607858538132a33a270...
Commit: 607858538132a33a27039e0ff4796b1a7d9f4f32
Parent: ac627fd1cec77a8334b7e48c3cb8f3efff50fb3c
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu May 2 16:41:42 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri May 3 14:39:42 2019 -0500
add md component check in vg_read based on size
If an md component is not excluded by other means and
vg_read is used to read metadata from it, then this new
check compares the device size with the PV size, and runs
a full md check on the device if the sizes don't match.
---
lib/format_text/import_vsn1.c | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
diff --git a/lib/format_text/import_vsn1.c b/lib/format_text/import_vsn1.c
index c9b9275..79c73ae 100644
--- a/lib/format_text/import_vsn1.c
+++ b/lib/format_text/import_vsn1.c
@@ -292,6 +292,18 @@ static int _read_pv(struct format_instance *fid,
pv->pe_align = 0;
pv->fmt = fid->fmt;
+ /*
+ * It would be nice to check this earlier, e.g. in or after label scan,
+ * but this is first time we get far enough through the vg metadata to
+ * see the PV size, and can finally compare it with the device size.
+ */
+ if (pv->dev && (pv->size != pv->dev->size)) {
+ if (dev_is_md(pv->dev, NULL, 1)) {
+ log_warn("WARNING: device %s is an md component, ignoring PV.", dev_name(pv->dev));
+ return_0;
+ }
+ }
+
/* Fix up pv size if missing or impossibly large */
if ((!pv->size || pv->size > (1ULL << 62)) && pv->dev) {
if (!dev_get_size(pv->dev, &pv->size)) {
4 years, 11 months
master - tests: use luks1 for test
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ac627fd1cec77a8334b...
Commit: ac627fd1cec77a8334b7e48c3cb8f3efff50fb3c
Parent: 8c56e31134baa5e7ddf8881e8a23d5ac5f2459a6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri May 3 13:11:09 2019 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri May 3 13:17:22 2019 +0200
tests: use luks1 for test
Since we do not need anywhere luks2 - pick older format
which does not require password for resize to keep
the rest of test unmodified.
---
test/shell/fsadm-crypt.sh | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/test/shell/fsadm-crypt.sh b/test/shell/fsadm-crypt.sh
index d90413d..9c85edf 100644
--- a/test/shell/fsadm-crypt.sh
+++ b/test/shell/fsadm-crypt.sh
@@ -46,7 +46,14 @@ PWD2="mymJeD8ivEhE"
PWD3="ocMakf3fAcQO"
SKIP_DETACHED=
-which cryptsetup || check_cryptsetup=${check_cryptsetup:-cryptsetup}
+if which cryptsetup ; then
+ # use older format luks1 - otherwise the test would need to pass password everywhere...
+ case $(cryptsetup --version) in
+ "cryptsetup 2"*) FORMAT_PARAMS="$FORMAT_PARAMS --type luks1" ;;
+ esac
+else
+ check_cryptsetup=${check_cryptsetup:-cryptsetup}
+fi
which mkfs.ext2 || check_ext2=${check_ext2:-mkfs.ext2}
which mkfs.ext3 || check_ext3=${check_ext3:-mkfs.ext3}
4 years, 11 months
master - tests: update resize value
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8c56e31134baa5e7ddf...
Commit: 8c56e31134baa5e7ddf8881e8a23d5ac5f2459a6
Parent: d60d59a5f30e7f324eed9605a8c1c925fbce63e1
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Wed Apr 17 16:14:59 2019 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri May 3 13:17:22 2019 +0200
tests: update resize value
Since we now properly extend also _pmspare - there was not enough free
space to add 8extents to both volumes.
---
test/shell/relative-sign-options.sh | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/test/shell/relative-sign-options.sh b/test/shell/relative-sign-options.sh
index 8333998..ac6fe53 100644
--- a/test/shell/relative-sign-options.sh
+++ b/test/shell/relative-sign-options.sh
@@ -73,7 +73,7 @@ lvresize --poolmetadatasize 64 $vg/$lv7
lvresize --poolmetadatasize +8 $vg/$lv7
not lvresize -y --poolmetadatasize -8 $vg/$lv7
-lvextend --poolmetadatasize +8 $vg/$lv7
+lvextend --poolmetadatasize +4 $vg/$lv7
not lvextend -y --poolmetadatasize -8 $vg/$lv7
fi
4 years, 11 months
master - cleanup: use unsigned type
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=d60d59a5f30e7f324ee...
Commit: d60d59a5f30e7f324eed9605a8c1c925fbce63e1
Parent: 7a5ea681fb57cd4bb7ba9db50e57bf2ee4e9ed8c
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri May 3 12:36:16 2019 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri May 3 13:17:22 2019 +0200
cleanup: use unsigned type
---
lib/metadata/raid_manip.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/lib/metadata/raid_manip.c b/lib/metadata/raid_manip.c
index 349d926..183435b 100644
--- a/lib/metadata/raid_manip.c
+++ b/lib/metadata/raid_manip.c
@@ -6471,7 +6471,7 @@ int lv_raid_convert(struct logical_volume *lv,
return_0;
region_size = new_region_size ? : seg->region_size;
- region_size = region_size ? : get_default_region_size(lv->vg->cmd);
+ region_size = region_size ? : (uint32_t)get_default_region_size(lv->vg->cmd);
/*
* Check acceptible options mirrors, region_size,
4 years, 11 months
master - build: fix compilation without lvmlockd
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7a5ea681fb57cd4bb7b...
Commit: 7a5ea681fb57cd4bb7ba9db50e57bf2ee4e9ed8c
Parent: a520b3002c2f31f84324d2f59dd1e156bc45ec65
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri May 3 12:35:22 2019 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri May 3 13:17:22 2019 +0200
build: fix compilation without lvmlockd
---
lib/locking/lvmlockd.h | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/lib/locking/lvmlockd.h b/lib/locking/lvmlockd.h
index 1738192..4393420 100644
--- a/lib/locking/lvmlockd.h
+++ b/lib/locking/lvmlockd.h
@@ -13,6 +13,7 @@
#include "libdaemon/client/config-util.h"
#include "libdaemon/client/daemon-client.h"
+#include "lib/metadata/metadata-exported.h" /* is_lockd_type() */
#define LOCKD_SANLOCK_LV_NAME "lvmlock"
@@ -182,7 +183,7 @@ static inline int lockd_global_create(struct cmd_context *cmd, const char *def_m
return 1;
}
-static inline int lockd_global(struct cmd_context *cmd, const char *def_mode, uint32_t flags)
+static inline int lockd_global(struct cmd_context *cmd, const char *def_mode)
{
return 1;
}
4 years, 11 months
master - locking: validate locking mode
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a520b3002c2f31f8432...
Commit: a520b3002c2f31f84324d2f59dd1e156bc45ec65
Parent: 3c70ae1803b06dea68b2e6e1ec2176b3f3fe9707
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri May 3 13:01:02 2019 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri May 3 13:17:22 2019 +0200
locking: validate locking mode
Ensure 'ret' is always defined and validate 'mode'.
---
lib/locking/locking.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/lib/locking/locking.c b/lib/locking/locking.c
index fd2b975..630a3bc 100644
--- a/lib/locking/locking.c
+++ b/lib/locking/locking.c
@@ -361,6 +361,9 @@ static int _lockf_global(struct cmd_context *cmd, const char *mode, int convert)
} else if (!strcmp(mode, "un")) {
ret = lock_vol(cmd, VG_GLOBAL, LCK_UNLOCK, NULL);
cmd->lockf_global_ex = 0;
+ } else {
+ log_error(INTERNAL_ERROR "Unknown locking mode %s.", mode);
+ return 0;
}
return ret;
4 years, 11 months
master - clean: avoid cleaning iterator on error path
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=3c70ae1803b06dea68b...
Commit: 3c70ae1803b06dea68b2e6e1ec2176b3f3fe9707
Parent: 99de816a1bb6414e4611030c8d83766b1ff3cd65
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Fri May 3 12:01:20 2019 +0200
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Fri May 3 13:17:22 2019 +0200
clean: avoid cleaning iterator on error path
Return error dirrectly instead of using 'out' code path.
---
tools/toollib.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/toollib.c b/tools/toollib.c
index b352839..8e882e9 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -3933,14 +3933,14 @@ static int _get_all_devices(struct cmd_context *cmd,
if (!(dil = dm_pool_alloc(cmd->mem, sizeof(*dil)))) {
log_error("device_id_list alloc failed.");
- goto out;
+ return ECMD_FAILED;
}
strncpy(dil->pvid, hint->pvid, ID_LEN);
dil->dev = dev;
dm_list_add(all_devices, &dil->list);
}
- return 1;
+ return ECMD_PROCESSED;
}
log_debug("Getting list of all devices from system");
4 years, 11 months
master - scan: remove comments about lvmetad
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=99de816a1bb6414e461...
Commit: 99de816a1bb6414e4611030c8d83766b1ff3cd65
Parent: 81735b46d9c7ab8f2dd27835d2a43cc5ad705c86
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Thu May 2 13:32:30 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Thu May 2 13:32:30 2019 -0500
scan: remove comments about lvmetad
---
lib/label/label.c | 18 ++++--------------
1 files changed, 4 insertions(+), 14 deletions(-)
diff --git a/lib/label/label.c b/lib/label/label.c
index 31b290b..b999f87 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -1024,8 +1024,6 @@ int label_scan_devs(struct cmd_context *cmd, struct dev_filter *f, struct dm_lis
{
struct device_list *devl;
- /* FIXME: get rid of this, it's only needed for lvmetad in which
- case we should be setting up bcache in one place. */
if (!scan_bcache) {
if (!_setup_bcache(0))
return 0;
@@ -1227,14 +1225,6 @@ out:
return ret;
}
-/*
- * This is only needed when commands are using lvmetad, in which case they
- * don't do an initial label_scan, but may later need to rescan certain devs
- * from disk and call this function. FIXME: is there some better number to
- * choose here? How should we predict the number of devices that might need
- * scanning when using lvmetad?
- */
-
int label_scan_setup_bcache(void)
{
if (!scan_bcache) {
@@ -1293,7 +1283,7 @@ bool dev_read_bytes(struct device *dev, uint64_t start, size_t len, void *data)
}
if (dev->bcache_fd <= 0) {
- /* This is not often needed, perhaps only with lvmetad. */
+ /* This is not often needed. */
if (!label_scan_open(dev)) {
log_error("Error opening device %s for reading at %llu length %u.",
dev_name(dev), (unsigned long long)start, (uint32_t)len);
@@ -1333,7 +1323,7 @@ bool dev_write_bytes(struct device *dev, uint64_t start, size_t len, void *data)
}
if (dev->bcache_fd <= 0) {
- /* This is not often needed, perhaps only with lvmetad. */
+ /* This is not often needed. */
dev->flags |= DEV_BCACHE_WRITE;
if (!label_scan_open(dev)) {
log_error("Error opening device %s for writing at %llu length %u.",
@@ -1379,7 +1369,7 @@ bool dev_write_zeros(struct device *dev, uint64_t start, size_t len)
}
if (dev->bcache_fd <= 0) {
- /* This is not often needed, perhaps only with lvmetad. */
+ /* This is not often needed. */
dev->flags |= DEV_BCACHE_WRITE;
if (!label_scan_open(dev)) {
log_error("Error opening device %s for writing at %llu length %u.",
@@ -1428,7 +1418,7 @@ bool dev_set_bytes(struct device *dev, uint64_t start, size_t len, uint8_t val)
}
if (dev->bcache_fd <= 0) {
- /* This is not often needed, perhaps only with lvmetad. */
+ /* This is not often needed. */
dev->flags |= DEV_BCACHE_WRITE;
if (!label_scan_open(dev)) {
log_error("Error opening device %s for writing at %llu length %u.",
4 years, 12 months