File bug-1163526_suse-special-global-filter-compat.patch of Package device-mapper.18094

diff -Nupr a/lib/config/config_settings.h b/lib/config/config_settings.h
--- a/lib/config/config_settings.h	2020-02-26 14:42:52.145985792 +0800
+++ b/lib/config/config_settings.h	2020-02-26 14:44:30.785268395 +0800
@@ -304,6 +304,15 @@ cfg_array(devices_filter_CFG, "filter",
 	"filter = [ \"a|^/dev/hda8$|\", \"r|.*/|\" ]\n"
 	"#\n")
 
+cfg(devices_global_filter_compat_CFG, "global_filter_compat", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_BOOL, 1, vsn(2, 2, 98), NULL, 0, NULL,
+	"Limit the block devices that are used by LVM system components.\n"
+	"This config item global_filter_compat is SUSE special.\n"
+	"The default value is 1, which means the devices/global_filter\n"
+	"behaviour is same as before. When the value is 0, user should\n"
+	"use global_filter to control system-wide software, e.g. \n"
+	"udev and lvmetad\n"
+	"global_filter_compat are not opened by LVM.\n")
+
 cfg_array(devices_global_filter_CFG, "global_filter", devices_CFG_SECTION, CFG_DEFAULT_COMMENTED, CFG_TYPE_STRING, "#Sa|.*/|", vsn(2, 2, 98), NULL, 0, NULL,
 	"Limit the block devices that are used by LVM system components.\n"
 	"Because devices/filter may be overridden from the command line, it is\n"
diff -Nupr a/lib/label/label.c b/lib/label/label.c
--- a/lib/label/label.c	2020-02-26 14:43:06.657880252 +0800
+++ b/lib/label/label.c	2020-02-26 15:09:16.290464500 +0800
@@ -977,6 +977,7 @@ int label_scan_pvscan_all(struct cmd_con
 	struct dev_iter *iter;
 	struct device_list *devl, *devl2;
 	struct device *dev;
+	struct dev_filter *filter;
 
 	log_debug_devs("Finding devices to scan");
 
@@ -992,7 +993,16 @@ int label_scan_pvscan_all(struct cmd_con
 	 */
 	dev_cache_scan();
 
-	if (!(iter = dev_iter_create(cmd->lvmetad_filter, 0))) {
+	/*
+	 * See bsc#1163526
+	 * stable-2.02 commit c527a0cbfc3 changed filter usage.
+	 */
+	if (find_config_tree_bool(cmd, devices_global_filter_compat_CFG, NULL)) {
+		filter = cmd->full_filter;
+	} else {
+		filter = cmd->lvmetad_filter;
+	}
+	if (!(iter = dev_iter_create(filter, 0))) {
 		log_error("Scanning failed to get devices.");
 		return 0;
 	}
@@ -1030,7 +1040,7 @@ int label_scan_pvscan_all(struct cmd_con
 			return_0;
 	}
 
-	_scan_list(cmd, cmd->lvmetad_filter, &all_devs, NULL);
+	_scan_list(cmd, filter, &all_devs, NULL);
 
 	dm_list_iterate_items_safe(devl, devl2, &all_devs) {
 		dm_list_del(&devl->list);
diff -Nupr a/man/lvmetad.8_main b/man/lvmetad.8_main
--- a/man/lvmetad.8_main	2020-02-26 14:42:41.450063577 +0800
+++ b/man/lvmetad.8_main	2020-02-26 15:29:11.797769716 +0800
@@ -47,6 +47,24 @@ system, or if the global_filter has chan
 This can be done by running pvscan --cache, or it will be done
 automatically by the next LVM command that's run.
 
+The global_filter behaviour had been changed from upstream stable-2.02
+branch patch: c527a0cbfc391645d30407d2dc4a30275c6472f1. Before this patch,
+command like 'pvscan --cache' didn't use devices/global_filter but devices/filter.
+This patch fixed the wrong behaviour. The upstream code change is 
+"technically right", but for compatibility, SUSE introduce a new configure
+item global_filter_compat.  It default value is 1, It means lvm2 uses 
+devices/filter & devices/global_filter as before. When user sets this value 0,
+It will make udev/lvmetad to use devices/global_filter. The code change makes
+lvm2 filter behaviour seem unchange in default. In another word, the customer
+doesn't need to set up anything. This patch is SUSE special, customer can use
+global_filter_compat=0 to make lvm2 filter bahaviour like upstream code.
+
+At last, the lvm.conf in rpm package also added this config item. 
+When system does update, the lvm.conf will be copied to /etc/lvm/lvm.conf.rpmnew.
+It can make customer to notice something different in lvm.conf.new. User
+can use 'lvmconfig -l devices/global_filter_compat' to check if the lvm2
+contains this new item.
+
 When lvmetad is not used, LVM commands revert to scanning disks for LVM
 metadata.
 
openSUSE Build Service is sponsored by