master - pvck: fix previous commit
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=63169594385ed4b02d9...
Commit: 63169594385ed4b02d93c2e8f422bbeb0b8225af
Parent: 125da10d47f4c1f72d3df99f2451c1eb031b9f3a
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Oct 28 16:50:47 2020 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Oct 28 16:50:47 2020 -0500
pvck: fix previous commit
line to setup bcache was misplaced in
commit 5a94126e7a28
---
tools/pvck.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tools/pvck.c b/tools/pvck.c
index 06fd01733..c36e18216 100644
--- a/tools/pvck.c
+++ b/tools/pvck.c
@@ -3064,11 +3064,11 @@ int pvck(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED;
}
+ label_scan_setup_bcache();
+
if (dev) {
char buf[4096];
- label_scan_setup_bcache();
-
/*
* This buf is not used, but bcache data is used for subsequent
* reads in the filters and by _read_bytes for other disk structs.
2 years, 11 months
master - Revert "tests: revert lvm shell use in pvck-dump"
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=125da10d47f4c1f72d3...
Commit: 125da10d47f4c1f72d3df99f2451c1eb031b9f3a
Parent: 05d23b2dd80919ebd2239cfd7f8e08d5de9ebace
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Oct 28 16:45:04 2020 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Oct 28 16:45:04 2020 -0500
Revert "tests: revert lvm shell use in pvck-dump"
This reverts commit 05d23b2dd80919ebd2239cfd7f8e08d5de9ebace.
this required enabling editline in configure
---
test/shell/pvck-dump.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/shell/pvck-dump.sh b/test/shell/pvck-dump.sh
index 80a01a214..c27fcc471 100644
--- a/test/shell/pvck-dump.sh
+++ b/test/shell/pvck-dump.sh
@@ -145,7 +145,7 @@ pvcreate --pvmetadatacopies 2 --metadatasize 32M "$dev1"
vgcreate $SHARED -s 64K --metadatasize 32M $vg "$dev1" "$dev2" "$dev3" "$dev4"
-for i in $(seq 1 500); do lvcreate -an -n lv$i -l1 $vg; done
+for i in $(seq 1 500); do echo "lvcreate -an -n lv$i -l1 $vg"; done | lvm
pvck --dump headers "$dev1" > h1
2 years, 11 months
master - tests: revert lvm shell use in pvck-dump
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=05d23b2dd80919ebd22...
Commit: 05d23b2dd80919ebd2239cfd7f8e08d5de9ebace
Parent: 5a94126e7a2824387c36d87f5ede97702a82cdda
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Oct 27 15:44:56 2020 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Oct 27 15:44:56 2020 -0500
tests: revert lvm shell use in pvck-dump
doesn't work on my machine
---
test/shell/pvck-dump.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/test/shell/pvck-dump.sh b/test/shell/pvck-dump.sh
index c27fcc471..80a01a214 100644
--- a/test/shell/pvck-dump.sh
+++ b/test/shell/pvck-dump.sh
@@ -145,7 +145,7 @@ pvcreate --pvmetadatacopies 2 --metadatasize 32M "$dev1"
vgcreate $SHARED -s 64K --metadatasize 32M $vg "$dev1" "$dev2" "$dev3" "$dev4"
-for i in $(seq 1 500); do echo "lvcreate -an -n lv$i -l1 $vg"; done | lvm
+for i in $(seq 1 500); do lvcreate -an -n lv$i -l1 $vg; done
pvck --dump headers "$dev1" > h1
2 years, 11 months
master - pvck: fix dev filtering
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=5a94126e7a2824387c3...
Commit: 5a94126e7a2824387c36d87f5ede97702a82cdda
Parent: c96645781ceb88c625dfae73e5baa08f1ce0e07e
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Oct 27 15:42:08 2020 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Oct 27 15:43:15 2020 -0500
pvck: fix dev filtering
filters needing io weren't being run because bcache
wasn't set up. Read the first 4k of the device
before doing filtering or reading ondisk structs to
reduce reads.
---
tools/pvck.c | 31 +++++++++++++++++++++----------
1 file changed, 21 insertions(+), 10 deletions(-)
diff --git a/tools/pvck.c b/tools/pvck.c
index 39692e3de..06fd01733 100644
--- a/tools/pvck.c
+++ b/tools/pvck.c
@@ -1039,13 +1039,6 @@ static int _dump_label_and_pv_header(struct cmd_context *cmd, uint64_t labelsect
return 0;
}
- /*
- * Not invalidating this range can cause an error reading
- * a larger range that overlaps this.
- */
- if (dev && !dev_invalidate_bytes(dev, lh_offset, 512))
- stack;
-
lh = (struct label_header *)buf;
if (print_fields) {
@@ -3040,7 +3033,7 @@ int pvck(struct cmd_context *cmd, int argc, char **argv)
clear_hint_file(cmd);
- if (!(dev = dev_cache_get(cmd, pv_name, cmd->filter))) {
+ if (!(dev = dev_cache_get(cmd, pv_name, NULL))) {
log_error("Cannot use %s: %s.", pv_name, devname_error_reason(pv_name));
return ECMD_FAILED;
}
@@ -3049,7 +3042,7 @@ int pvck(struct cmd_context *cmd, int argc, char **argv)
if (arg_is_set(cmd, dump_ARG)) {
pv_name = argv[0];
- dev = dev_cache_get(cmd, pv_name, cmd->filter);
+ dev = dev_cache_get(cmd, pv_name, NULL);
if (!dev)
def = get_devicefile(pv_name);
@@ -3071,7 +3064,25 @@ int pvck(struct cmd_context *cmd, int argc, char **argv)
return ECMD_FAILED;
}
- label_scan_setup_bcache();
+ if (dev) {
+ char buf[4096];
+
+ label_scan_setup_bcache();
+
+ /*
+ * This buf is not used, but bcache data is used for subsequent
+ * reads in the filters and by _read_bytes for other disk structs.
+ */
+ if (!dev_read_bytes(dev, 0, 4096, buf)) {
+ log_error("Failed to read the first 4096 bytes of device %s.", dev_name(dev));
+ return ECMD_FAILED;
+ }
+
+ if (!cmd->filter->passes_filter(cmd, cmd->filter, dev, NULL)) {
+ log_error("Cannot use %s: %s.", pv_name, dev_filtered_reason(dev));
+ return ECMD_FAILED;
+ }
+ }
if ((dump = arg_str_value(cmd, dump_ARG, NULL))) {
cmd->use_hints = 0;
2 years, 11 months
master - pvck: handle first mda at non-4096 offset
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c96645781ceb88c625d...
Commit: c96645781ceb88c625dfae73e5baa08f1ce0e07e
Parent: 020d1edaa06e5e05b58e8d39530408f86a22d1b8
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Oct 27 14:28:54 2020 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Oct 27 14:28:54 2020 -0500
pvck: handle first mda at non-4096 offset
It's possible for a machine with a non-4k page size
to create a PV with an mda_header at an offset other
than 4k. Fix pvck --dump to work with these other
mda offsets. pvck --repair will write a new first
mda at 4096 but lvm with other page sizes will work
with this.
---
tools/pvck.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/tools/pvck.c b/tools/pvck.c
index 7ae4976e5..39692e3de 100644
--- a/tools/pvck.c
+++ b/tools/pvck.c
@@ -1406,9 +1406,10 @@ static int _dump_headers(struct cmd_context *cmd, const char *dump, struct setti
}
/*
- * The first mda is always 4096 bytes from the start of the device.
+ * The first mda is usually 4096 bytes from the start of the device.
+ * (If created by a machine with larger pages it could be 8k/16k/64k.)
*/
- if (!_dump_mda_header(cmd, set, 1, 0, 0, NULL, dev, def, 4096, mda1_size, &mda1_checksum, NULL))
+ if (!_dump_mda_header(cmd, set, 1, 0, 0, NULL, dev, def, mda1_offset, mda1_size, &mda1_checksum, NULL))
bad++;
if (mda2_offset) {
@@ -1463,7 +1464,7 @@ static int _dump_metadata(struct cmd_context *cmd, const char *dump, struct sett
* The first mda is always 4096 bytes from the start of the device.
*/
if (mda_num == 1) {
- if (!_dump_mda_header(cmd, set, 0, print_metadata, print_area, tofile, dev, def, 4096, mda1_size, &mda1_checksum, NULL))
+ if (!_dump_mda_header(cmd, set, 0, print_metadata, print_area, tofile, dev, def, mda1_offset, mda1_size, &mda1_checksum, NULL))
bad++;
} else if (mda_num == 2) {
if (!mda2_offset) {
@@ -1497,7 +1498,7 @@ static int _dump_found(struct cmd_context *cmd, struct settings *set, uint64_t l
bad++;
if (found_label && mda1_offset) {
- if (!_dump_mda_header(cmd, set, 0, 0, 0, NULL, dev, NULL, 4096, mda1_size, &mda1_checksum, &found_header1))
+ if (!_dump_mda_header(cmd, set, 0, 0, 0, NULL, dev, NULL, mda1_offset, mda1_size, &mda1_checksum, &found_header1))
bad++;
}
@@ -1681,7 +1682,7 @@ static int _dump_search(struct cmd_context *cmd, const char *dump, struct settin
*/
if ((mda_num == 1) && found_label && mda1_offset && mda1_size) {
/* use header values when available */
- mda_offset = 4096;
+ mda_offset = mda1_offset;
mda_size = mda1_size;
} else if (mda_num == 1) {
2 years, 11 months
master - writecache: disallow partial or degraded activation
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=020d1edaa06e5e05b58...
Commit: 020d1edaa06e5e05b58e8d39530408f86a22d1b8
Parent: 830c20d33cc8253c397e927291d51c249c2c0eb3
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Oct 26 15:35:23 2020 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Oct 26 15:48:58 2020 -0500
writecache: disallow partial or degraded activation
when either main or fast lvs are incomplete
---
lib/activate/activate.c | 8 ++++++++
test/shell/writecache-misc.sh | 29 +++++++++++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/lib/activate/activate.c b/lib/activate/activate.c
index 311d33a52..7ed644113 100644
--- a/lib/activate/activate.c
+++ b/lib/activate/activate.c
@@ -2530,6 +2530,14 @@ static int _lv_activate(struct cmd_context *cmd, const char *lvid_s,
}
}
+ if ((cmd->partial_activation || cmd->degraded_activation) && lv_is_writecache(lv)) {
+ struct logical_volume *lv_fast = first_seg(lv)->writecache;
+ if (lv_is_partial(lv) || (lv_fast && lv_is_partial(lv_fast))) {
+ log_error("Cannot use partial or degraded activation with writecache.");
+ goto out;
+ }
+ }
+
if (lv_has_unknown_segments(lv)) {
log_error("Refusing activation of LV %s containing "
"an unrecognised segment.", display_lvname(lv));
diff --git a/test/shell/writecache-misc.sh b/test/shell/writecache-misc.sh
index 75364e5b3..80b793256 100644
--- a/test/shell/writecache-misc.sh
+++ b/test/shell/writecache-misc.sh
@@ -77,5 +77,34 @@ pvmove -n $vg/$lv1 "$dev3" "$dev1"
mount_umount $lv1
lvchange -an $vg/$lv1
+lvremove -y $vg/$lv1
+
+
+#
+# Test partial and degraded activation
+#
+
+lvcreate -n $lv1 -l 16 -an $vg "$dev1" "$dev2"
+lvcreate -n $lv2 -l 16 -an $vg "$dev3" "$dev4"
+
+lvconvert -y --type writecache --cachevol $lv2 $vg/$lv1
+lvs -a -o+devices $vg
+lvchange -an $vg/$lv1
+
+aux hide_dev "$dev1"
+not lvchange -ay $vg/$lv1
+not lvchange -ay --partial $vg/$lv1
+not lvchange -ay --activationmode degraded $vg/$lv1
+aux unhide_dev "$dev1"
+lvchange -ay $vg/$lv1
+lvchange -an $vg/$lv1
+
+aux hide_dev "$dev3"
+not lvchange -ay $vg/$lv1
+not lvchange -ay --partial $vg/$lv1
+not lvchange -ay --activationmode degraded $vg/$lv1
+aux unhide_dev "$dev3"
+lvchange -ay $vg/$lv1
+lvchange -an $vg/$lv1
vgremove -ff $vg
2 years, 11 months
master - lvchange: allow syncaction check with integrity
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=830c20d33cc8253c397...
Commit: 830c20d33cc8253c397e927291d51c249c2c0eb3
Parent: 2c319398274b930a38278e635e9171ce663f2bab
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Mon Oct 26 12:27:18 2020 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Oct 26 14:16:33 2020 -0500
lvchange: allow syncaction check with integrity
syncaction check will detect and correct integrity checksum mismatches.
---
test/shell/integrity.sh | 151 ++++++++++++++++++++++++++++++++++++++++++++----
tools/lvchange.c | 8 ++-
2 files changed, 146 insertions(+), 13 deletions(-)
diff --git a/test/shell/integrity.sh b/test/shell/integrity.sh
index 7b119965b..7dd237b93 100644
--- a/test/shell/integrity.sh
+++ b/test/shell/integrity.sh
@@ -96,7 +96,7 @@ _test_fs_with_error() {
umount $mnt
}
-_test_fs_with_raid() {
+_test_fs_with_read_repair() {
mkfs.xfs -f -s size=4096 "$DM_DEV_DIR/$vg/$lv1"
mount "$DM_DEV_DIR/$vg/$lv1" $mnt
@@ -143,6 +143,56 @@ _test_fs_with_raid() {
umount $mnt
}
+_test_fs_with_syncaction_check() {
+ mkfs.xfs -f -s size=4096 "$DM_DEV_DIR/$vg/$lv1"
+
+ mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+
+ # add original data
+ cp fileA $mnt
+ cp fileB $mnt
+ cp fileC $mnt
+
+ umount $mnt
+ lvchange -an $vg/$lv1
+
+ # FIXME: this is only finding/corrupting the bit with raid1
+ # other raid levels may require looking at a different dev.
+ # (Attempt this xxd/tac/sed/xxd on each dev in the LV?)
+
+ xxd "$dev1" > dev1.txt
+ tac dev1.txt > dev1.rev
+ rm -f dev1.txt
+ sed -e '0,/4242 4242 4242 4242 4242 4242 4242 4242/ s/4242 4242 4242 4242 4242 4242 4242 4242/4242 4242 4242 4242 4242 4242 4242 4243/' dev1.rev > dev1.rev.bad
+ rm -f dev1.rev
+ tac dev1.rev.bad > dev1.bad
+ rm -f dev1.rev.bad
+ xxd -r dev1.bad > "$dev1"
+ rm -f dev1.bad
+
+ lvchange -ay $vg/$lv1
+
+ lvchange --syncaction check $vg/$lv1
+
+ mount "$DM_DEV_DIR/$vg/$lv1" $mnt
+
+ # read complete fileA which was not corrupted
+ dd if=$mnt/fileA of=tmp bs=1k
+ ls -l tmp
+ stat -c %s tmp | grep 16384
+ cmp -b fileA tmp
+ rm tmp
+
+ # read complete fileB
+ dd if=$mnt/fileB of=tmp bs=1k
+ ls -l tmp
+ stat -c %s tmp | grep 16384
+ cmp -b fileB tmp
+ rm tmp
+
+ umount $mnt
+}
+
_add_new_data_to_mnt() {
mkfs.xfs -f -s size=4096 "$DM_DEV_DIR/$vg/$lv1"
@@ -235,7 +285,7 @@ _prepare_vg
lvcreate --type raid1 -m1 --raidintegrity y -n $lv1 -l 8 $vg
_wait_recalc $vg/${lv1}_rimage_0
_wait_recalc $vg/${lv1}_rimage_1
-_test_fs_with_raid
+_test_fs_with_read_repair
lvs -o integritymismatches $vg/${lv1}_rimage_0
lvs -o integritymismatches $vg/${lv1}_rimage_1
lvchange -an $vg/$lv1
@@ -248,10 +298,89 @@ lvcreate --type raid1 -m2 --raidintegrity y -n $lv1 -l 8 $vg
_wait_recalc $vg/${lv1}_rimage_0
_wait_recalc $vg/${lv1}_rimage_1
_wait_recalc $vg/${lv1}_rimage_2
-_test_fs_with_raid
+_test_fs_with_read_repair
+lvs -o integritymismatches $vg/${lv1}_rimage_0
+lvs -o integritymismatches $vg/${lv1}_rimage_1
+lvs -o integritymismatches $vg/${lv1}_rimage_2
+lvchange -an $vg/$lv1
+lvconvert --raidintegrity n $vg/$lv1
+lvremove $vg/$lv1
+vgremove -ff $vg
+
+_prepare_vg
+lvcreate --type raid4 --raidintegrity y -n $lv1 -l 8 $vg
+_wait_recalc $vg/${lv1}_rimage_0
+_wait_recalc $vg/${lv1}_rimage_1
+_wait_recalc $vg/${lv1}_rimage_2
+_test_fs_with_read_repair
+lvs -o integritymismatches $vg/${lv1}_rimage_0
+lvs -o integritymismatches $vg/${lv1}_rimage_1
+lvs -o integritymismatches $vg/${lv1}_rimage_2
+lvchange -an $vg/$lv1
+lvconvert --raidintegrity n $vg/$lv1
+lvremove $vg/$lv1
+vgremove -ff $vg
+
+_prepare_vg
+lvcreate --type raid5 --raidintegrity y -n $lv1 -l 8 $vg
+_wait_recalc $vg/${lv1}_rimage_0
+_wait_recalc $vg/${lv1}_rimage_1
+_wait_recalc $vg/${lv1}_rimage_2
+_test_fs_with_read_repair
+lvs -o integritymismatches $vg/${lv1}_rimage_0
+lvs -o integritymismatches $vg/${lv1}_rimage_1
+lvs -o integritymismatches $vg/${lv1}_rimage_2
+lvchange -an $vg/$lv1
+lvconvert --raidintegrity n $vg/$lv1
+lvremove $vg/$lv1
+vgremove -ff $vg
+
+_prepare_vg
+lvcreate --type raid6 --raidintegrity y -n $lv1 -l 8 $vg
+_wait_recalc $vg/${lv1}_rimage_0
+_wait_recalc $vg/${lv1}_rimage_1
+_wait_recalc $vg/${lv1}_rimage_2
+_wait_recalc $vg/${lv1}_rimage_3
+_wait_recalc $vg/${lv1}_rimage_4
+_test_fs_with_read_repair
lvs -o integritymismatches $vg/${lv1}_rimage_0
lvs -o integritymismatches $vg/${lv1}_rimage_1
lvs -o integritymismatches $vg/${lv1}_rimage_2
+lvs -o integritymismatches $vg/${lv1}_rimage_3
+lvs -o integritymismatches $vg/${lv1}_rimage_4
+lvchange -an $vg/$lv1
+lvconvert --raidintegrity n $vg/$lv1
+lvremove $vg/$lv1
+vgremove -ff $vg
+
+_prepare_vg
+lvcreate --type raid10 --raidintegrity y -n $lv1 -l 8 $vg
+_wait_recalc $vg/${lv1}_rimage_0
+_wait_recalc $vg/${lv1}_rimage_1
+_wait_recalc $vg/${lv1}_rimage_2
+_wait_recalc $vg/${lv1}_rimage_3
+_test_fs_with_read_repair
+lvs -o integritymismatches $vg/${lv1}_rimage_0
+lvs -o integritymismatches $vg/${lv1}_rimage_1
+lvs -o integritymismatches $vg/${lv1}_rimage_2
+lvs -o integritymismatches $vg/${lv1}_rimage_3
+lvchange -an $vg/$lv1
+lvconvert --raidintegrity n $vg/$lv1
+lvremove $vg/$lv1
+vgremove -ff $vg
+
+# Test corrupting data on an image and verifying that
+# it is detected and corrected using syncaction check
+
+_prepare_vg
+lvcreate --type raid1 -m1 --raidintegrity y -n $lv1 -l 8 $vg
+_wait_recalc $vg/${lv1}_rimage_0
+_wait_recalc $vg/${lv1}_rimage_1
+_test_fs_with_syncaction_check
+lvs -o integritymismatches $vg/${lv1}_rimage_0
+lvs -o integritymismatches $vg/${lv1}_rimage_1
+check lv_field $vg/${lv1}_rimage_0 integritymismatches "1"
+check lv_field $vg/${lv1}_rimage_1 integritymismatches "0"
lvchange -an $vg/$lv1
lvconvert --raidintegrity n $vg/$lv1
lvremove $vg/$lv1
@@ -262,10 +391,13 @@ lvcreate --type raid4 --raidintegrity y -n $lv1 -l 8 $vg
_wait_recalc $vg/${lv1}_rimage_0
_wait_recalc $vg/${lv1}_rimage_1
_wait_recalc $vg/${lv1}_rimage_2
-_test_fs_with_raid
+_test_fs_with_syncaction_check
lvs -o integritymismatches $vg/${lv1}_rimage_0
lvs -o integritymismatches $vg/${lv1}_rimage_1
lvs -o integritymismatches $vg/${lv1}_rimage_2
+check lv_field $vg/${lv1}_rimage_0 integritymismatches "2"
+check lv_field $vg/${lv1}_rimage_1 integritymismatches "0"
+check lv_field $vg/${lv1}_rimage_2 integritymismatches "0"
lvchange -an $vg/$lv1
lvconvert --raidintegrity n $vg/$lv1
lvremove $vg/$lv1
@@ -276,7 +408,7 @@ lvcreate --type raid5 --raidintegrity y -n $lv1 -l 8 $vg
_wait_recalc $vg/${lv1}_rimage_0
_wait_recalc $vg/${lv1}_rimage_1
_wait_recalc $vg/${lv1}_rimage_2
-_test_fs_with_raid
+_test_fs_with_syncaction_check
lvs -o integritymismatches $vg/${lv1}_rimage_0
lvs -o integritymismatches $vg/${lv1}_rimage_1
lvs -o integritymismatches $vg/${lv1}_rimage_2
@@ -292,7 +424,7 @@ _wait_recalc $vg/${lv1}_rimage_1
_wait_recalc $vg/${lv1}_rimage_2
_wait_recalc $vg/${lv1}_rimage_3
_wait_recalc $vg/${lv1}_rimage_4
-_test_fs_with_raid
+_test_fs_with_syncaction_check
lvs -o integritymismatches $vg/${lv1}_rimage_0
lvs -o integritymismatches $vg/${lv1}_rimage_1
lvs -o integritymismatches $vg/${lv1}_rimage_2
@@ -309,7 +441,7 @@ _wait_recalc $vg/${lv1}_rimage_0
_wait_recalc $vg/${lv1}_rimage_1
_wait_recalc $vg/${lv1}_rimage_2
_wait_recalc $vg/${lv1}_rimage_3
-_test_fs_with_raid
+_test_fs_with_syncaction_check
lvs -o integritymismatches $vg/${lv1}_rimage_0
lvs -o integritymismatches $vg/${lv1}_rimage_1
lvs -o integritymismatches $vg/${lv1}_rimage_2
@@ -621,7 +753,6 @@ _add_new_data_to_mnt
not lvconvert -y -m-1 $vg/$lv1
not lvconvert --splitmirrors 1 -n tmp -y $vg/$lv1
not lvconvert --splitmirrors 1 --trackchanges -y $vg/$lv1
-not lvchange --syncaction check $vg/$lv1
not lvchange --syncaction repair $vg/$lv1
not lvreduce -L4M $vg/$lv1
not lvcreate -s -n snap -L4M $vg/$lv1
@@ -638,7 +769,7 @@ vgremove -ff $vg
_prepare_vg
lvcreate --type raid1 -m1 --raidintegrity y --raidintegritymode bitmap -n $lv1 -l 8 $vg
-_test_fs_with_raid
+_test_fs_with_read_repair
lvs -o integritymismatches $vg/${lv1}_rimage_0
lvs -o integritymismatches $vg/${lv1}_rimage_1
lvchange -an $vg/$lv1
@@ -648,7 +779,7 @@ vgremove -ff $vg
_prepare_vg
lvcreate --type raid6 --raidintegrity y --raidintegritymode bitmap -n $lv1 -l 8 $vg
-_test_fs_with_raid
+_test_fs_with_read_repair
lvs -o integritymismatches $vg/${lv1}_rimage_0
lvs -o integritymismatches $vg/${lv1}_rimage_1
lvs -o integritymismatches $vg/${lv1}_rimage_2
diff --git a/tools/lvchange.c b/tools/lvchange.c
index c0adadf8d..f9a0b54e3 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -1658,8 +1658,10 @@ static int _lvchange_syncaction_single(struct cmd_context *cmd,
struct logical_volume *lv,
struct processing_handle *handle)
{
- if (lv_raid_has_integrity(lv)) {
- log_error("Integrity must be removed to use syncaction commands.");
+ const char *msg = arg_str_value(cmd, syncaction_ARG, NULL);
+
+ if (lv_raid_has_integrity(lv) && !strcmp(msg, "repair")) {
+ log_error("Use syncaction check to detect and correct integrity checksum mismatches.");
return_ECMD_FAILED;
}
@@ -1667,7 +1669,7 @@ static int _lvchange_syncaction_single(struct cmd_context *cmd,
if (!lockd_lv(cmd, lv, "ex", 0))
return_ECMD_FAILED;
- if (!lv_raid_message(lv, arg_str_value(cmd, syncaction_ARG, NULL)))
+ if (!lv_raid_message(lv, msg))
return_ECMD_FAILED;
return ECMD_PROCESSED;
2 years, 11 months
master - pvcreate: clean up opening and filtering of args
by David Teigland
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=2c319398274b930a382...
Commit: 2c319398274b930a38278e635e9171ce663f2bab
Parent: 7bafae48bb7b7bf1e7adc420bf83d0c5acaf0aac
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Oct 23 13:53:52 2020 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Oct 26 11:13:27 2020 -0500
pvcreate: clean up opening and filtering of args
The args for pvcreate/pvremove (and vgcreate/vgextend
when applicable) were not efficiently opened, scanned,
and filtered. This change reorganizes the opening
and filtering in the following steps:
- label scan and filter all devs
. open ro
. standard label scan at the start of command
- label scan and filter dev args
. open ro
. uses full md component check
. typically the first scan and filter of pvcreate devs
- close and reopen dev args
. open rw and excl
- repeat label scan and filter dev args
. using reopened rw excl fd
- wipe and write new headers
. using reopened rw excl fd
---
lib/label/label.c | 24 ++++++-----
lib/label/label.h | 2 +-
tools/lvmcmdline.c | 9 +---
tools/toollib.c | 124 ++++++++++++++++++++++++++++++++++++++++++++---------
4 files changed, 120 insertions(+), 39 deletions(-)
diff --git a/lib/label/label.c b/lib/label/label.c
index 36eab19f3..e067a6bed 100644
--- a/lib/label/label.c
+++ b/lib/label/label.c
@@ -669,7 +669,7 @@ static void _invalidate_di(struct bcache *cache, int di)
*/
static int _scan_list(struct cmd_context *cmd, struct dev_filter *f,
- struct dm_list *devs, int *failed)
+ struct dm_list *devs, int want_other_devs, int *failed)
{
struct dm_list wait_devs;
struct dm_list done_devs;
@@ -759,9 +759,11 @@ static int _scan_list(struct cmd_context *cmd, struct dev_filter *f,
* Keep the bcache block of lvm devices we have processed so
* that the vg_read phase can reuse it. If bcache failed to
* read the block, or the device does not belong to lvm, then
- * drop it from bcache.
+ * drop it from bcache. When "want_other_devs" is set, it
+ * means the caller wants to scan and keep open non-lvm devs,
+ * e.g. to pvcreate them.
*/
- if (!is_lvm_device) {
+ if (!is_lvm_device && !want_other_devs) {
_invalidate_di(scan_bcache, devl->dev->bcache_di);
_scan_dev_close(devl->dev);
}
@@ -1146,7 +1148,7 @@ int label_scan(struct cmd_context *cmd)
/*
* Do the main scan.
*/
- _scan_list(cmd, cmd->filter, &scan_devs, NULL);
+ _scan_list(cmd, cmd->filter, &scan_devs, 0, NULL);
/*
* Metadata could be larger than total size of bcache, and bcache
@@ -1193,7 +1195,7 @@ int label_scan(struct cmd_context *cmd)
if (using_hints) {
if (!validate_hints(cmd, &hints_list)) {
log_debug("Will scan %d remaining devices", dm_list_size(&all_devs));
- _scan_list(cmd, cmd->filter, &all_devs, NULL);
+ _scan_list(cmd, cmd->filter, &all_devs, 0, NULL);
free_hints(&hints_list);
using_hints = 0;
create_hints = 0;
@@ -1312,7 +1314,7 @@ int label_scan_devs_cached(struct cmd_context *cmd, struct dev_filter *f, struct
if (!scan_bcache)
return 0;
- _scan_list(cmd, f, devs, NULL);
+ _scan_list(cmd, f, devs, 0, NULL);
return 1;
}
@@ -1339,7 +1341,7 @@ int label_scan_devs(struct cmd_context *cmd, struct dev_filter *f, struct dm_lis
_invalidate_di(scan_bcache, devl->dev->bcache_di);
}
- _scan_list(cmd, f, devs, NULL);
+ _scan_list(cmd, f, devs, 0, NULL);
return 1;
}
@@ -1359,12 +1361,12 @@ int label_scan_devs_rw(struct cmd_context *cmd, struct dev_filter *f, struct dm_
devl->dev->flags |= DEV_BCACHE_WRITE;
}
- _scan_list(cmd, f, devs, NULL);
+ _scan_list(cmd, f, devs, 0, NULL);
return 1;
}
-int label_scan_devs_excl(struct dm_list *devs)
+int label_scan_devs_excl(struct cmd_context *cmd, struct dev_filter *f, struct dm_list *devs)
{
struct device_list *devl;
int failed = 0;
@@ -1379,7 +1381,7 @@ int label_scan_devs_excl(struct dm_list *devs)
devl->dev->flags |= DEV_BCACHE_WRITE;
}
- _scan_list(NULL, NULL, devs, &failed);
+ _scan_list(cmd, f, devs, 1, &failed);
if (failed)
return 0;
@@ -1472,7 +1474,7 @@ int label_scan_dev(struct device *dev)
label_scan_invalidate(dev);
- _scan_list(NULL, NULL, &one_dev, &failed);
+ _scan_list(NULL, NULL, &one_dev, 0, &failed);
free(devl);
diff --git a/lib/label/label.h b/lib/label/label.h
index a98ba32e3..78724c1ce 100644
--- a/lib/label/label.h
+++ b/lib/label/label.h
@@ -106,7 +106,7 @@ int label_scan(struct cmd_context *cmd);
int label_scan_devs(struct cmd_context *cmd, struct dev_filter *f, struct dm_list *devs);
int label_scan_devs_cached(struct cmd_context *cmd, struct dev_filter *f, struct dm_list *devs);
int label_scan_devs_rw(struct cmd_context *cmd, struct dev_filter *f, struct dm_list *devs);
-int label_scan_devs_excl(struct dm_list *devs);
+int label_scan_devs_excl(struct cmd_context *cmd, struct dev_filter *f, struct dm_list *devs);
int label_scan_dev(struct device *dev);
void label_scan_invalidate(struct device *dev);
void label_scan_invalidate_lv(struct cmd_context *cmd, struct logical_volume *lv);
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 3a2ce93b5..b84a9a014 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -2900,13 +2900,8 @@ static void _init_md_checks(struct cmd_context *cmd)
if (!strcmp(cmd->md_component_checks, "full"))
cmd->use_full_md_check = 1;
- else if (!strcmp(cmd->md_component_checks, "auto")) {
- /* use_full_md_check can also be set later */
- if (!strcmp(cmd->name, "pvcreate") ||
- !strcmp(cmd->name, "vgcreate") ||
- !strcmp(cmd->name, "vgextend"))
- cmd->use_full_md_check = 1;
- }
+
+ /* use_full_md_check can also be set later */
log_debug("Using md_component_checks %s use_full_md_check %d",
cmd->md_component_checks, cmd->use_full_md_check);
diff --git a/tools/toollib.c b/tools/toollib.c
index 0fbb0b6ec..d9295bb82 100644
--- a/tools/toollib.c
+++ b/tools/toollib.c
@@ -4884,16 +4884,6 @@ static int _pvcreate_check_used(struct cmd_context *cmd,
log_debug("Checking %s for pvcreate %.32s.",
dev_name(pd->dev), pd->dev->pvid[0] ? pd->dev->pvid : "");
- /*
- * Since the device is likely not a PV yet, it was probably not
- * scanned by label_scan at the start of the command, so that
- * needs to be done first to find if there's a PV label or metadata
- * on it. If there's a PV label, it sets dev->pvid.
- * If a VG is using the dev, it adds basic VG info for it to
- * lvmcache.
- */
- label_scan_dev(pd->dev);
-
if (!pd->dev->pvid[0]) {
log_debug("Check pvcreate arg %s no PVID found", dev_name(pd->dev));
pd->is_not_pv = 1;
@@ -5189,6 +5179,31 @@ fail:
* This function returns 1 (success) if the caller requires all specified
* devices to be created, and all are created, or if the caller does not
* require all specified devices to be created and one or more were created.
+ *
+ * Process of opening, scanning and filtering:
+ *
+ * - label scan and filter all devs
+ * . open ro
+ * . standard label scan at the start of command
+ * . done prior to this function
+ *
+ * - label scan and filter dev args
+ * . label_scan_devs(&scan_devs) in this function
+ * . open ro
+ * . uses full md component check
+ * . typically the first scan and filter of pvcreate devs
+ *
+ * - close and reopen dev args
+ * . open rw and excl
+ * . done by label_scan_devs_excl
+ *
+ * - repeat label scan and filter dev args
+ * . using reopened rw excl fd
+ * . since something could have used dev
+ * in the small window between close and reopen
+ *
+ * - wipe and write new headers
+ * . using reopened rw excl fd
*/
int pvcreate_each_device(struct cmd_context *cmd,
@@ -5201,6 +5216,7 @@ int pvcreate_each_device(struct cmd_context *cmd,
struct volume_group *orphan_vg;
struct dm_list remove_duplicates;
struct dm_list arg_sort;
+ struct dm_list scan_devs;
struct dm_list rescan_devs;
struct pv_list *pvl;
struct pv_list *vgpvl;
@@ -5217,6 +5233,7 @@ int pvcreate_each_device(struct cmd_context *cmd,
dm_list_init(&remove_duplicates);
dm_list_init(&arg_sort);
+ dm_list_init(&scan_devs);
dm_list_init(&rescan_devs);
handle->custom_handle = pp;
@@ -5244,10 +5261,60 @@ int pvcreate_each_device(struct cmd_context *cmd,
/*
* Translate arg names into struct device's.
+ *
+ * lvmcache_label_scan has already been run by the caller.
+ * It has likely found and filtered pvremove args, but often
+ * not pvcreate args, since pvcreate args are not typically PVs
+ * yet (but may be.)
+ *
+ * We call label_scan_devs on the args, using the full
+ * md filter (the previous scan likely did not use the
+ * full md filter - we really only need to check the
+ * command args to ensure they are not md components.)
*/
+
dm_list_iterate_items_safe(pd, pd2, &pp->arg_devices) {
- pd->dev = dev_cache_get(cmd, pd->name, cmd->filter);
- if (!pd->dev) {
+ struct device *dev;
+
+ /* No filter used here */
+ if (!(dev = dev_cache_get(cmd, pd->name, NULL))) {
+ log_error("No device found for %s.", pd->name);
+ dm_list_del(&pd->list);
+ dm_list_add(&pp->arg_fail, &pd->list);
+ continue;
+ }
+
+ if (!(devl = dm_pool_zalloc(cmd->mem, sizeof(*devl))))
+ goto bad;
+
+ devl->dev = dev;
+ pd->dev = dev;
+
+ dm_list_add(&scan_devs, &devl->list);
+ }
+
+ if (dm_list_empty(&pp->arg_devices))
+ goto_bad;
+
+ /*
+ * Clear the filtering results from lvmcache_label_scan because we are
+ * going to rerun the filters and don't want to get the results saved
+ * by the prior filtering. The filtering in label scan will use full
+ * md filter.
+ */
+ dm_list_iterate_items(devl, &scan_devs)
+ cmd->filter->wipe(cmd, cmd->filter, devl->dev, NULL);
+
+ cmd->use_full_md_check = 1;
+
+ log_debug("Scanning and filtering device args.");
+ label_scan_devs(cmd, cmd->filter, &scan_devs);
+
+ /*
+ * Check if the filtering done by label scan excluded any devices.
+ */
+ dm_list_iterate_items_safe(pd, pd2, &pp->arg_devices) {
+ if (!cmd->filter->passes_filter(cmd, cmd->filter, pd->dev, NULL)) {
log_error("Cannot use %s: %s", pd->name, devname_error_reason(pd->name));
dm_list_del(&pd->list);
dm_list_add(&pp->arg_fail, &pd->list);
@@ -5455,12 +5522,35 @@ do_command:
dm_list_add(&rescan_devs, &devl->list);
}
- log_debug("Rescanning devices with exclusive open");
- if (!label_scan_devs_excl(&rescan_devs)) {
+ /*
+ * We want label_scan excl to repeat the filter check in case something
+ * changed to filter out a dev before we were able to get exclusive.
+ */
+ dm_list_iterate_items(devl, &rescan_devs)
+ cmd->filter->wipe(cmd, cmd->filter, devl->dev, NULL);
+
+ log_debug("Rescanning and filtering device args with exclusive open");
+ if (!label_scan_devs_excl(cmd, cmd->filter, &rescan_devs)) {
log_debug("Failed to rescan devs excl");
goto bad;
}
+ dm_list_iterate_items_safe(pd, pd2, &pp->arg_process) {
+ if (!cmd->filter->passes_filter(cmd, cmd->filter, pd->dev, NULL)) {
+ log_error("Cannot use %s: %s", pd->name, devname_error_reason(pd->name));
+ dm_list_del(&pd->list);
+ dm_list_add(&pp->arg_fail, &pd->list);
+ }
+ }
+
+ if (dm_list_empty(&pp->arg_process) && dm_list_empty(&remove_duplicates)) {
+ log_debug("No devices to process.");
+ goto bad;
+ }
+
+ if (!dm_list_empty(&pp->arg_fail) && must_use_all)
+ goto_bad;
+
/*
* If the global lock was unlocked to wait for prompts, then
* devs could have changed while unlocked, so confirm that
@@ -5498,9 +5588,6 @@ do_command:
* Wipe signatures on devices being created.
*/
dm_list_iterate_items_safe(pd, pd2, &pp->arg_create) {
- /* FIXME: won't all already be open excl from label_scan_devs_excl above? */
- label_scan_open_excl(pd->dev);
-
log_verbose("Wiping signatures on new PV %s.", pd->name);
if (!wipe_known_signatures(cmd, pd->dev, pd->name, TYPE_LVM1_MEMBER | TYPE_LVM2_MEMBER,
@@ -5578,9 +5665,6 @@ do_command:
pv_name = pd->name;
- /* FIXME: won't all already be open excl from label_scan_devs_excl above? */
- label_scan_open_excl(pd->dev);
-
log_debug("Creating a new PV on %s.", pv_name);
if (!(pv = pv_create(cmd, pd->dev, &pp->pva))) {
2 years, 11 months
master - gcc: cleanup warns from older gcc
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=7bafae48bb7b7bf1e7a...
Commit: 7bafae48bb7b7bf1e7adc420bf83d0c5acaf0aac
Parent: e793f34eb73bd4be5a37ed641f9fe11ad1a6d578
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Oct 25 21:56:02 2020 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 26 13:06:53 2020 +0100
gcc: cleanup warns from older gcc
---
lib/display/display.c | 4 ++--
lib/metadata/lv_manip.c | 2 +-
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/display/display.c b/lib/display/display.c
index 6ef46f1e8..c0224edfb 100644
--- a/lib/display/display.c
+++ b/lib/display/display.c
@@ -407,9 +407,9 @@ int lvdisplay_full(struct cmd_context *cmd,
int lvm1compat;
dm_percent_t snap_percent;
int thin_pool_active = 0;
- dm_percent_t thin_data_percent, thin_metadata_percent;
+ dm_percent_t thin_data_percent = 0, thin_metadata_percent = 0;
int thin_active = 0;
- dm_percent_t thin_percent;
+ dm_percent_t thin_percent = 0;
struct lv_status_thin *thin_status = NULL;
struct lv_status_thin_pool *thin_pool_status = NULL;
struct lv_status_cache *cache_status = NULL;
diff --git a/lib/metadata/lv_manip.c b/lib/metadata/lv_manip.c
index e66342022..70464362e 100644
--- a/lib/metadata/lv_manip.c
+++ b/lib/metadata/lv_manip.c
@@ -8022,7 +8022,7 @@ static struct logical_volume *_lv_create_an_lv(struct volume_group *vg,
struct logical_volume *lv, *origin_lv = NULL;
struct logical_volume *pool_lv = NULL;
struct logical_volume *tmp_lv;
- struct lv_segment *seg, *pool_seg;
+ struct lv_segment *seg = NULL, *pool_seg;
int thin_pool_was_active = -1; /* not scanned, inactive, active */
int historical;
uint64_t transaction_id;
2 years, 11 months
master - tests: minor update
by Zdenek Kabelac
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=e793f34eb73bd4be5a3...
Commit: e793f34eb73bd4be5a37ed641f9fe11ad1a6d578
Parent: b0333841352b76ce13464b82cb1876ea82b80351
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Sun Oct 25 20:23:41 2020 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Mon Oct 26 13:06:52 2020 +0100
tests: minor update
---
test/shell/fsadm.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/test/shell/fsadm.sh b/test/shell/fsadm.sh
index 3e7f9083c..910edddd8 100644
--- a/test/shell/fsadm.sh
+++ b/test/shell/fsadm.sh
@@ -54,8 +54,8 @@ test ! -d "$mount_space_dir" && mkdir "$mount_space_dir"
cleanup_mounted_and_teardown()
{
- umount "$mount_dir" || true
- umount "$mount_space_dir" || true
+ umount "$mount_dir" 2>/dev/null || true
+ umount "$mount_space_dir" 2>/dev/null || true
aux teardown
}
2 years, 11 months