Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=6ff1583c1ba58d045fb5c…
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
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=607858538132a33a27039…
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)) {
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=ac627fd1cec77a8334b7e…
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}
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=99de816a1bb6414e46110…
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.",