Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1bfae5bf8e5905a72f716…
Commit: 1bfae5bf8e5905a72f7168562e1bbc074f23b791
Parent: f836fe3836e990e41b2c2b59c2af7ef6b979097f
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Sep 27 14:18:35 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Sep 30 11:38:10 2019 -0500
tests: update duplicate md tests
adjust to recent improvements in duplicate handling
---
test/shell/duplicate-pvs-md1.sh | 39 ++++++++++++++-------------------------
1 files changed, 14 insertions(+), 25 deletions(-)
diff --git a/test/shell/duplicate-pvs-md1.sh b/test/shell/duplicate-pvs-md1.sh
index 626c55c..334ac41 100644
--- a/test/shell/duplicate-pvs-md1.sh
+++ b/test/shell/duplicate-pvs-md1.sh
@@ -190,18 +190,17 @@ lvs -o active $vg |tee out || true
grep "active" out
vgchange -an $vg
-# N.B. when the md dev (which is started) has not been scanned by
-# pvscan, then pvscan --cache on the md component does not detect it's
-# an md component, and marks the PVID online, then does activation,
-# but the activation using the component fails because the component
-# device is busy from being used in the md dev, and activation fails.
-# The default behavior in auto mode is preferrable.
+# The dev name and device_hint don't match so pvscan
+# skips quick activation and scans all devs during
+# activation. This means it sees the component and
+# the mddev as duplicates and chooses to use the mddev
+# for activation.
_clear_online_files
-not pvscan --cache -aay "$dev1"
+pvscan --cache -aay "$dev1"
ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
ls "$RUNDIR/lvm/vgs_online/$vg"
lvs -o active $vg |tee out || true
-not grep "active" out
+grep "active" out
# pvscan activation from mddev first, then try from component which fails
_clear_online_files
@@ -332,27 +331,17 @@ pvscan --cache -aay
not ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
not ls "$RUNDIR/lvm/vgs_online/$vg"
+# component dev name does not match device_hint in metadata so
+# quick activation is skipped and activation scans all devs.
+# this leads it to see both components as duplicates which
+# triggers full md check which means we see both devs are
+# md components and drop them, leaving no remaining devs
+# on which this vg is seen.
_clear_online_files
-pvscan --cache -aay "$dev1"
+not pvscan --cache -aay "$dev1"
ls "$RUNDIR/lvm/pvs_online/$PVIDMD"
ls "$RUNDIR/lvm/vgs_online/$vg"
-# N.B. not good to activate from component, but result of "start" setting
-# Other commands will not see the vg at this point because they'll
-# recognize the md components and ignore them (where pvscan is special due
-# to it not scanning all devs and not seeing the duplicates and not
-# detecting the components.)
-# disable dev2 so other cmds don't see dups and we can deactivate the vg
-aux disable_dev "$dev2"
-vgchange -an $vg
-
-aux enable_dev "$dev2"
-aux udev_wait
-cat /proc/mdstat
-# for some reason enabling dev2 starts an odd md dev
-mdadm --stop "$mddev" || true
-mdadm --stop --scan
-cat /proc/mdstat
wipefs -a "$dev1" || true
wipefs -a "$dev2" || true
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=0c23d3fc8402e49e61c9c…
Commit: 0c23d3fc8402e49e61c9c490d9c2c9c2d58596e8
Parent: 3a8e41a67b3f0edb0fcb27302351f7d58b6ef8c5
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Sep 4 15:59:49 2019 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Mon Sep 30 11:38:10 2019 -0500
pvscan: use quick activation only with matching PV device names
When the PV device names in the VG metadata do not match the
current PV device names seen on the system, do not use the
optimized activation function (that avoids extra device scanning.)
When the device names do not match, it's a clue that there could
be duplicate PVs, in which case we want to scan all devicess to
find any duplicates and stop the activation if found.
This does not prevent autoactivating a VG from the incorrect
duplicate PV, because the incorrect duplicate may appear by itself
first. At that point its duplicate PV does not exist to be seen.
(A future enhancement could use the WWID to strengthen this
detection.)
---
tools/pvscan.c | 30 ++++++++++++++++++++++--------
1 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/tools/pvscan.c b/tools/pvscan.c
index b025ae3..96ef438 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -929,17 +929,19 @@ static int _online_vg_file_create(struct cmd_context *cmd, const char *vgname)
* scan/read in order to process/activate the VG.
*/
-static int _get_devs_from_saved_vg(struct cmd_context *cmd, char *vgname,
+static int _get_devs_from_saved_vg(struct cmd_context *cmd, const char *vgname,
struct dm_list *saved_vgs,
struct dm_list *devs)
{
char path[PATH_MAX];
char file_vgname[NAME_LEN];
+ char uuidstr[64] __attribute__((aligned(8)));
struct pv_list *pvl;
struct device_list *devl;
struct device *dev;
struct volume_group *vg;
const char *pvid;
+ const char *name1, *name2;
dev_t devno;
int file_major = 0, file_minor = 0;
@@ -978,6 +980,16 @@ static int _get_devs_from_saved_vg(struct cmd_context *cmd, char *vgname,
return 0;
}
+ name1 = dev_name(dev);
+ name2 = pvl->pv->device_hint;
+
+ if (strcmp(name1, name2)) {
+ if (!id_write_format((const struct id *)pvid, uuidstr, sizeof(uuidstr)))
+ uuidstr[0] = '\0';
+ log_print("PVID %s read from %s last written to %s.", uuidstr, name1, name2);
+ return 0;
+ }
+
if (!(devl = zalloc(sizeof(*devl))))
return_0;
@@ -1024,8 +1036,8 @@ static int _get_devs_from_saved_vg(struct cmd_context *cmd, char *vgname,
* is important when there are many devs.
*/
-static int _pvscan_aa_direct(struct cmd_context *cmd, struct pvscan_aa_params *pp, char *vgname,
- struct dm_list *saved_vgs)
+static int _pvscan_aa_quick(struct cmd_context *cmd, struct pvscan_aa_params *pp, const char *vgname,
+ struct dm_list *saved_vgs, int *no_quick)
{
struct dm_list devs; /* device_list */
struct volume_group *vg;
@@ -1044,7 +1056,8 @@ static int _pvscan_aa_direct(struct cmd_context *cmd, struct pvscan_aa_params *p
* The dev_cache gives us struct devices from the devnums.
*/
if (!_get_devs_from_saved_vg(cmd, vgname, saved_vgs, &devs)) {
- log_error("pvscan activation for VG %s failed to find devices.", vgname);
+ log_print("pvscan[%d] VG %s not using quick activation.", getpid(), vgname);
+ *no_quick = 1;
return ECMD_FAILED;
}
@@ -1132,6 +1145,7 @@ static int _pvscan_aa(struct cmd_context *cmd, struct pvscan_aa_params *pp,
{
struct processing_handle *handle = NULL;
struct dm_str_list *sl, *sl2;
+ int no_quick = 0;
int ret;
if (dm_list_empty(vgnames)) {
@@ -1169,12 +1183,12 @@ static int _pvscan_aa(struct cmd_context *cmd, struct pvscan_aa_params *pp,
if (dm_list_size(vgnames) == 1) {
dm_list_iterate_items(sl, vgnames)
- ret = _pvscan_aa_direct(cmd, pp, (char *)sl->str, saved_vgs);
- } else {
- /* FIXME: suppress label scan in process_each if label scan already done? */
- ret = process_each_vg(cmd, 0, NULL, NULL, vgnames, READ_FOR_ACTIVATE, 0, handle, _pvscan_aa_single);
+ ret = _pvscan_aa_quick(cmd, pp, sl->str, saved_vgs, &no_quick);
}
+ if ((dm_list_size(vgnames) > 1) || no_quick)
+ ret = process_each_vg(cmd, 0, NULL, NULL, vgnames, READ_FOR_ACTIVATE, 0, handle, _pvscan_aa_single);
+
destroy_processing_handle(cmd, handle);
return ret;
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=1f970f590f969d5a3d8b9…
Commit: 1f970f590f969d5a3d8b9d458ae257bf93c00432
Parent: 61358d92cbf202dbb483d63a63d5adf0463bb934
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Mon Sep 30 17:10:05 2019 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Mon Sep 30 17:12:21 2019 +0100
dmsetup: do not treat no groups as an error in dmstats list --group
Analogous to the case of a device with no regions, it is not an
error to attempt to list the stats groups on a device that has no
configured groups: just return success and continue.
---
tools/dmsetup.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 60e0638..15a09c6 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -941,10 +941,12 @@ static int _display_info_cols(struct dm_task *dmt, struct dm_info *info)
}
}
- /* group report with no groups? */
+ /* Group report with no groups is not an error */
if ((walk_flags == DM_STATS_WALK_GROUP)
- && !dm_stats_get_nr_groups(obj.stats))
+ && !dm_stats_get_nr_groups(obj.stats)) {
+ r = 1;
goto out;
+ }
dm_stats_walk_init(obj.stats, walk_flags);
dm_stats_walk_do(obj.stats) {
Gitweb: https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=8f02f8dcd72571ce3bc65…
Commit: 8f02f8dcd72571ce3bc6538f1cd23807e2b6a64d
Parent: 5c0264d68954e5677f21459bb18d50704b2b9d77
Author: Bryn M. Reeves <bmr(a)redhat.com>
AuthorDate: Mon Sep 30 17:10:05 2019 +0100
Committer: Bryn M. Reeves <bmr(a)redhat.com>
CommitterDate: Mon Sep 30 17:10:05 2019 +0100
dmsetup: do not treat no groups as an error in dmstats list --group
Analogous to the case of a device with no regions, it is not an
error to attempt to list the stats groups on a device that has no
configured groups: just return success and continue.
---
libdm/dm-tools/dmsetup.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/libdm/dm-tools/dmsetup.c b/libdm/dm-tools/dmsetup.c
index 2f8a1be..7267d0d 100644
--- a/libdm/dm-tools/dmsetup.c
+++ b/libdm/dm-tools/dmsetup.c
@@ -942,10 +942,12 @@ static int _display_info_cols(struct dm_task *dmt, struct dm_info *info)
}
}
- /* group report with no groups? */
+ /* Group report with no groups is not an error */
if ((walk_flags == DM_STATS_WALK_GROUP)
- && !dm_stats_get_nr_groups(obj.stats))
+ && !dm_stats_get_nr_groups(obj.stats)) {
+ r = 1;
goto out;
+ }
dm_stats_walk_init(obj.stats, walk_flags);
dm_stats_walk_do(obj.stats) {