mrc0mmand / rpms / lvm2

Forked from rpms/lvm2 2 years ago
Clone

Blame SOURCES/lvm2-2_03_06-md-component-detection-for-differing-PV-and-device-s.patch

26e710
 lib/metadata/metadata.c | 26 ++++++++++++++++++++++++--
26e710
 1 file changed, 24 insertions(+), 2 deletions(-)
26e710
26e710
diff --git a/lib/metadata/metadata.c b/lib/metadata/metadata.c
26e710
index dc1b501..f7eeb52 100644
26e710
--- a/lib/metadata/metadata.c
26e710
+++ b/lib/metadata/metadata.c
26e710
@@ -3504,19 +3504,41 @@ static void _set_pv_device(struct format_instance *fid,
26e710
 			   struct physical_volume *pv)
26e710
 {
26e710
 	char buffer[64] __attribute__((aligned(8)));
26e710
+	struct cmd_context *cmd = fid->fmt->cmd;
26e710
+	struct device *dev;
26e710
 	uint64_t size;
26e710
 
26e710
-	if (!(pv->dev = lvmcache_device_from_pvid(fid->fmt->cmd, &pv->id, &pv->label_sector))) {
26e710
+	if (!(dev = lvmcache_device_from_pvid(cmd, &pv->id, &pv->label_sector))) {
26e710
 		if (!id_write_format(&pv->id, buffer, sizeof(buffer)))
26e710
 			buffer[0] = '\0';
26e710
 
26e710
-		if (fid->fmt->cmd && !fid->fmt->cmd->pvscan_cache_single)
26e710
+		if (cmd && !cmd->pvscan_cache_single)
26e710
 			log_warn("WARNING: Couldn't find device with uuid %s.", buffer);
26e710
 		else
26e710
 			log_debug_metadata("Couldn't find device with uuid %s.", buffer);
26e710
 	}
26e710
 
26e710
 	/*
26e710
+	 * If the device and PV are not the size, it's a clue that we might
26e710
+	 * be reading an MD component (but not necessarily). Skip this check:
26e710
+	 * . if md component detection is disabled
26e710
+	 * . if we are already doing full a md check in label scan
26e710
+	 * . if md_component_checks is auto, not none (full means use_full_md_check is set)
26e710
+	 */
26e710
+	if (dev && (pv->size != dev->size) && cmd &&
26e710
+	    cmd->md_component_detection &&
26e710
+	    !cmd->use_full_md_check &&
26e710
+	    !strcmp(cmd->md_component_checks, "auto")) {
26e710
+		if (dev_is_md_component(dev, NULL, 1)) {
26e710
+			log_warn("WARNING: device %s is an md component, not setting device for PV.",
26e710
+				 dev_name(dev));
26e710
+			dev = NULL;
26e710
+		}
26e710
+	}
26e710
+
26e710
+	pv->dev = dev;
26e710
+
26e710
+	/*
26e710
 	 * A previous command wrote the VG while this dev was missing, so
26e710
 	 * the MISSING flag was included in the PV.
26e710
 	 */