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

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