File bug-1145231_pvscan-lvmetad-use-full-md-filter-when-md-1.0-device.patch of Package lvm2.13365

From a01e1fec0fe7c2fa61577c0e636e907cde7279ea Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Thu, 29 Nov 2018 14:06:20 -0600
Subject: [PATCH] pvscan lvmetad: use full md filter when md 1.0 devices are
 present

Apply the same logic to pvscan/lvmetad that was added to
the non-lvmetad label_scan in commit 3fd75d1b:
  scan: use full md filter when md 1.0 devices are present

Before scanning, check if any of the devs on the system are
md 0.90/1.0, and if so make the scan read both the start and
the end of the device so that the components of those md
versions can be ignored.
---
 tools/pvscan.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/tools/pvscan.c b/tools/pvscan.c
index 2915db599..3755684d2 100644
--- a/tools/pvscan.c
+++ b/tools/pvscan.c
@@ -18,6 +18,8 @@
 #include "lvmetad.h"
 #include "lvmcache.h"
 
+extern int use_full_md_check;
+
 struct pvscan_params {
 	int new_pvs_found;
 	int pvs_found;
@@ -302,6 +304,7 @@ static int _pvscan_cache(struct cmd_context *cmd, int argc, char **argv)
 	struct dm_list found_vgnames;
 	struct device *dev;
 	struct device_list *devl;
+	struct dev_iter *iter;
 	const char *pv_name;
 	const char *reason = NULL;
 	int32_t major = -1;
@@ -443,6 +446,22 @@ static int _pvscan_cache(struct cmd_context *cmd, int argc, char **argv)
 	/* Creates a list of dev names from /dev, sysfs, etc; does not read any. */
 	dev_cache_scan();
 
+	/* See the same check in label_scan() to handle md 0.9/1.0 components. */
+	if (!(iter = dev_iter_create(cmd->full_filter, 0))) {
+		log_error("Scanning failed to get devices.");
+		return 0;
+	}
+	while ((dev = dev_iter_get(iter))) {
+		if (dev_is_md_with_end_superblock(cmd->dev_types, dev)) {
+			cmd->use_full_md_check = 1;
+			use_full_md_check = 1;
+			log_debug("Found md with end superblock %s", dev_name(dev));
+		}
+	}
+	dev_iter_destroy(iter);
+	if (!use_full_md_check)
+		log_debug("No md devs with end superblock");
+
 	dm_list_init(&single_devs);
 
 	while (argc--) {
-- 
2.12.3

openSUSE Build Service is sponsored by