mrc0mmand / rpms / lvm2

Forked from rpms/lvm2 2 years ago
Clone

Blame SOURCES/lvm2-2_02_182-scan-enable-full-md-filter-when-md-1.0-devices-are-p.patch

3a5d46
 lib/filters/filter-md.c | 33 +++++++--------------------------
3a5d46
 lib/label/label.c       | 13 ++++++++++++-
3a5d46
 2 files changed, 19 insertions(+), 27 deletions(-)
3a5d46
3a5d46
diff --git a/lib/filters/filter-md.c b/lib/filters/filter-md.c
3a5d46
index ad5b8e4..e03ff50 100644
3a5d46
--- a/lib/filters/filter-md.c
3a5d46
+++ b/lib/filters/filter-md.c
3a5d46
@@ -16,6 +16,9 @@
3a5d46
 #include "lib.h"
3a5d46
 #include "filter.h"
3a5d46
 
3a5d46
+/* See label.c comment about this hack. */
3a5d46
+extern int use_full_md_check;
3a5d46
+
3a5d46
 #ifdef __linux__
3a5d46
 
3a5d46
 #define MSG_SKIPPING "%s: Skipping md component device"
3a5d46
@@ -80,7 +83,7 @@
3a5d46
  * that will not pass.
3a5d46
  */
3a5d46
 
3a5d46
-static int _passes_md_filter(struct device *dev, int full)
3a5d46
+static int _passes_md_filter(struct dev_filter *f, struct device *dev)
3a5d46
 {
3a5d46
 	int ret;
3a5d46
 
3a5d46
@@ -91,7 +94,7 @@ static int _passes_md_filter(struct device *dev, int full)
3a5d46
 	if (!md_filtering())
3a5d46
 		return 1;
3a5d46
 
3a5d46
-	ret = dev_is_md(dev, NULL, full);
3a5d46
+	ret = dev_is_md(dev, NULL, use_full_md_check);
3a5d46
 
3a5d46
 	if (ret == -EAGAIN) {
3a5d46
 		/* let pass, call again after scan */
3a5d46
@@ -104,6 +107,7 @@ static int _passes_md_filter(struct device *dev, int full)
3a5d46
 		return 1;
3a5d46
 
3a5d46
 	if (ret == 1) {
3a5d46
+		log_debug_devs("md filter full %d excluding md component %s", use_full_md_check, dev_name(dev));
3a5d46
 		if (dev->ext.src == DEV_EXT_NONE)
3a5d46
 			log_debug_devs(MSG_SKIPPING, dev_name(dev));
3a5d46
 		else
3a5d46
@@ -121,18 +125,6 @@ static int _passes_md_filter(struct device *dev, int full)
3a5d46
 	return 1;
3a5d46
 }
3a5d46
 
3a5d46
-static int _passes_md_filter_lite(struct dev_filter *f __attribute__((unused)),
3a5d46
-				  struct device *dev)
3a5d46
-{
3a5d46
-	return _passes_md_filter(dev, 0);
3a5d46
-}
3a5d46
-
3a5d46
-static int _passes_md_filter_full(struct dev_filter *f __attribute__((unused)),
3a5d46
-				  struct device *dev)
3a5d46
-{
3a5d46
-	return _passes_md_filter(dev, 1);
3a5d46
-}
3a5d46
-
3a5d46
 static void _destroy(struct dev_filter *f)
3a5d46
 {
3a5d46
 	if (f->use_count)
3a5d46
@@ -150,18 +142,7 @@ struct dev_filter *md_filter_create(struct cmd_context *cmd, struct dev_types *d
3a5d46
 		return NULL;
3a5d46
 	}
3a5d46
 
3a5d46
-	/*
3a5d46
-	 * FIXME: for commands that want a full md check (pvcreate, vgcreate,
3a5d46
-	 * vgextend), we do an extra read at the end of every device that the
3a5d46
-	 * filter looks at.  This isn't necessary; we only need to do the full
3a5d46
-	 * md check on the PVs that these commands are trying to use.
3a5d46
-	 */
3a5d46
-
3a5d46
-	if (cmd->use_full_md_check)
3a5d46
-		f->passes_filter = _passes_md_filter_full;
3a5d46
-	else
3a5d46
-		f->passes_filter = _passes_md_filter_lite;
3a5d46
-
3a5d46
+	f->passes_filter = _passes_md_filter;
3a5d46
 	f->destroy = _destroy;
3a5d46
 	f->use_count = 0;
3a5d46
 	f->private = dt;
3a5d46
diff --git a/lib/label/label.c b/lib/label/label.c
3a5d46
index 6fb35ff..03726d0 100644
3a5d46
--- a/lib/label/label.c
3a5d46
+++ b/lib/label/label.c
3a5d46
@@ -27,6 +27,7 @@
3a5d46
 #include <unistd.h>
3a5d46
 #include <sys/time.h>
3a5d46
 
3a5d46
+int use_full_md_check;
3a5d46
 
3a5d46
 /* FIXME Allow for larger labels?  Restricted to single sector currently */
3a5d46
 
3a5d46
@@ -884,8 +885,18 @@ int label_scan(struct cmd_context *cmd)
3a5d46
 		 * devs in 'pvs', which is a pretty harmless effect from a
3a5d46
 		 * pretty uncommon situation.
3a5d46
 		 */
3a5d46
-		if (dev_is_md_with_end_superblock(cmd->dev_types, dev))
3a5d46
+		if (dev_is_md_with_end_superblock(cmd->dev_types, dev)) {
3a5d46
 			cmd->use_full_md_check = 1;
3a5d46
+
3a5d46
+			/* This is a hack because 'cmd' is not passed
3a5d46
+			   into the filters so we can't check the flag
3a5d46
+			   in the cmd struct.  The master branch has
3a5d46
+			   changed the filters in commit 8eab37593eccb
3a5d46
+			   to accept cmd, but it's a complex change
3a5d46
+			   that I'm trying to avoid in the stable branch. */
3a5d46
+
3a5d46
+			use_full_md_check = 1;
3a5d46
+		}
3a5d46
 	};
3a5d46
 	dev_iter_destroy(iter);
3a5d46