All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Wilck <mwilck@suse.com>
To: Christophe Varoqui <christophe.varoqui@opensvc.com>
Cc: dm-devel@redhat.com, Martin Wilck <mwilck@suse.com>
Subject: [PATCH v3 06/24] libmultipath: avoid frequent messages from filter_property()
Date: Mon, 10 Dec 2018 10:49:41 +0100	[thread overview]
Message-ID: <20181210094959.11338-7-mwilck@suse.com> (raw)
In-Reply-To: <20181210094959.11338-1-mwilck@suse.com>

Unlike the other filter functions, filter_property() is called
on every pathinfo() call, and prints a message with -v3 every
time. Avoid that by using a lower log priority for the call
from pathinfo().

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 libmultipath/blacklist.c | 54 ++++++++++++++++++++--------------------
 libmultipath/blacklist.h |  2 +-
 libmultipath/configure.c |  6 ++---
 libmultipath/discovery.c |  2 +-
 tests/blacklist.c        |  7 +++---
 5 files changed, 36 insertions(+), 35 deletions(-)

diff --git a/libmultipath/blacklist.c b/libmultipath/blacklist.c
index 318ec03f..709895e2 100644
--- a/libmultipath/blacklist.c
+++ b/libmultipath/blacklist.c
@@ -232,24 +232,24 @@ setup_default_blist (struct config * conf)
 	return 0;
 }
 
-#define LOG_BLIST(M,S)							\
+#define LOG_BLIST(M, S, lvl)						\
 	if (vendor && product)						\
-		condlog(3, "%s: (%s:%s) %s %s",				\
+		condlog(lvl, "%s: (%s:%s) %s %s",			\
 			dev, vendor, product, (M), (S));		\
 	else if (wwid && !dev)						\
-		condlog(3, "%s: %s %s", wwid, (M), (S));		\
+		condlog(lvl, "%s: %s %s", wwid, (M), (S));		\
 	else if (wwid)							\
-		condlog(3, "%s: %s %s %s", dev, (M), wwid, (S));	\
+		condlog(lvl, "%s: %s %s %s", dev, (M), wwid, (S));	\
 	else if (env)							\
-		condlog(3, "%s: %s %s %s", dev, (M), env, (S));		\
+		condlog(lvl, "%s: %s %s %s", dev, (M), env, (S));	\
 	else if (protocol)						\
-		condlog(3, "%s: %s %s %s", dev, (M), protocol, (S));	\
+		condlog(lvl, "%s: %s %s %s", dev, (M), protocol, (S));	\
 	else								\
-		condlog(3, "%s: %s %s", dev, (M), (S))
+		condlog(lvl, "%s: %s %s", dev, (M), (S))
 
-void
+static void
 log_filter (const char *dev, char *vendor, char *product, char *wwid,
-	    const char *env, const char *protocol, int r)
+	    const char *env, const char *protocol, int r, int lvl)
 {
 	/*
 	 * Try to sort from most likely to least.
@@ -258,37 +258,37 @@ log_filter (const char *dev, char *vendor, char *product, char *wwid,
 	case MATCH_NOTHING:
 		break;
 	case MATCH_DEVICE_BLIST:
-		LOG_BLIST("vendor/product", "blacklisted");
+		LOG_BLIST("vendor/product", "blacklisted", lvl);
 		break;
 	case MATCH_WWID_BLIST:
-		LOG_BLIST("wwid", "blacklisted");
+		LOG_BLIST("wwid", "blacklisted", lvl);
 		break;
 	case MATCH_DEVNODE_BLIST:
-		LOG_BLIST("device node name", "blacklisted");
+		LOG_BLIST("device node name", "blacklisted", lvl);
 		break;
 	case MATCH_PROPERTY_BLIST:
-		LOG_BLIST("udev property", "blacklisted");
+		LOG_BLIST("udev property", "blacklisted", lvl);
 		break;
 	case MATCH_PROTOCOL_BLIST:
-		LOG_BLIST("protocol", "blacklisted");
+		LOG_BLIST("protocol", "blacklisted", lvl);
 		break;
 	case MATCH_DEVICE_BLIST_EXCEPT:
-		LOG_BLIST("vendor/product", "whitelisted");
+		LOG_BLIST("vendor/product", "whitelisted", lvl);
 		break;
 	case MATCH_WWID_BLIST_EXCEPT:
-		LOG_BLIST("wwid", "whitelisted");
+		LOG_BLIST("wwid", "whitelisted", lvl);
 		break;
 	case MATCH_DEVNODE_BLIST_EXCEPT:
-		LOG_BLIST("device node name", "whitelisted");
+		LOG_BLIST("device node name", "whitelisted", lvl);
 		break;
 	case MATCH_PROPERTY_BLIST_EXCEPT:
-		LOG_BLIST("udev property", "whitelisted");
+		LOG_BLIST("udev property", "whitelisted", lvl);
 		break;
 	case MATCH_PROPERTY_BLIST_MISSING:
-		LOG_BLIST("blacklisted,", "udev property missing");
+		LOG_BLIST("blacklisted,", "udev property missing", lvl);
 		break;
 	case MATCH_PROTOCOL_BLIST_EXCEPT:
-		LOG_BLIST("protocol", "whitelisted");
+		LOG_BLIST("protocol", "whitelisted", lvl);
 		break;
 	}
 }
@@ -306,7 +306,7 @@ filter_device (vector blist, vector elist, char * vendor, char * product,
 			r = MATCH_DEVICE_BLIST;
 	}
 
-	log_filter(dev, vendor, product, NULL, NULL, NULL, r);
+	log_filter(dev, vendor, product, NULL, NULL, NULL, r, 3);
 	return r;
 }
 
@@ -322,7 +322,7 @@ filter_devnode (vector blist, vector elist, char * dev)
 			r = MATCH_DEVNODE_BLIST;
 	}
 
-	log_filter(dev, NULL, NULL, NULL, NULL, NULL, r);
+	log_filter(dev, NULL, NULL, NULL, NULL, NULL, r, 3);
 	return r;
 }
 
@@ -338,7 +338,7 @@ filter_wwid (vector blist, vector elist, char * wwid, char * dev)
 			r = MATCH_WWID_BLIST;
 	}
 
-	log_filter(dev, NULL, NULL, wwid, NULL, NULL, r);
+	log_filter(dev, NULL, NULL, wwid, NULL, NULL, r, 3);
 	return r;
 }
 
@@ -357,7 +357,7 @@ filter_protocol(vector blist, vector elist, struct path * pp)
 			r = MATCH_PROTOCOL_BLIST;
 	}
 
-	log_filter(pp->dev, NULL, NULL, NULL, NULL, buf, r);
+	log_filter(pp->dev, NULL, NULL, NULL, NULL, buf, r, 3);
 	return r;
 }
 
@@ -366,7 +366,7 @@ filter_path (struct config * conf, struct path * pp)
 {
 	int r;
 
-	r = filter_property(conf, pp->udev);
+	r = filter_property(conf, pp->udev, 3);
 	if (r > 0)
 		return r;
 	r = filter_devnode(conf->blist_devnode, conf->elist_devnode, pp->dev);
@@ -384,7 +384,7 @@ filter_path (struct config * conf, struct path * pp)
 }
 
 int
-filter_property(struct config * conf, struct udev_device * udev)
+filter_property(struct config *conf, struct udev_device *udev, int lvl)
 {
 	const char *devname = udev_device_get_sysname(udev);
 	struct udev_list_entry *list_entry;
@@ -415,7 +415,7 @@ filter_property(struct config * conf, struct udev_device * udev)
 		}
 	}
 
-	log_filter(devname, NULL, NULL, NULL, env, NULL, r);
+	log_filter(devname, NULL, NULL, NULL, env, NULL, r, lvl);
 	return r;
 }
 
diff --git a/libmultipath/blacklist.h b/libmultipath/blacklist.h
index 18903b6b..4c8ec99e 100644
--- a/libmultipath/blacklist.h
+++ b/libmultipath/blacklist.h
@@ -37,7 +37,7 @@ int filter_devnode (vector, vector, char *);
 int filter_wwid (vector, vector, char *, char *);
 int filter_device (vector, vector, char *, char *, char *);
 int filter_path (struct config *, struct path *);
-int filter_property(struct config *, struct udev_device *);
+int filter_property(struct config *, struct udev_device *, int);
 int filter_protocol(vector, vector, struct path *);
 int store_ble (vector, char *, int);
 int set_ble_device (vector, char *, char *, int);
diff --git a/libmultipath/configure.c b/libmultipath/configure.c
index ed3e30f5..406cd4c9 100644
--- a/libmultipath/configure.c
+++ b/libmultipath/configure.c
@@ -1289,7 +1289,7 @@ int get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type,
 		conf = get_multipath_config();
 		pthread_cleanup_push(put_multipath_config, conf);
 		if (pp->udev && pp->uid_attribute &&
-		    filter_property(conf, pp->udev) > 0)
+		    filter_property(conf, pp->udev, 3) > 0)
 			invalid = 1;
 		pthread_cleanup_pop(1);
 		if (invalid)
@@ -1329,7 +1329,7 @@ int get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type,
 		conf = get_multipath_config();
 		pthread_cleanup_push(put_multipath_config, conf);
 		if (pp->udev && pp->uid_attribute &&
-		    filter_property(conf, pp->udev) > 0)
+		    filter_property(conf, pp->udev, 3) > 0)
 			invalid = 1;
 		pthread_cleanup_pop(1);
 		if (invalid)
@@ -1358,7 +1358,7 @@ int get_refwwid(enum mpath_cmds cmd, char *dev, enum devtypes dev_type,
 		conf = get_multipath_config();
 		pthread_cleanup_push(put_multipath_config, conf);
 		if (pp->udev && pp->uid_attribute &&
-		    filter_property(conf, pp->udev) > 0)
+		    filter_property(conf, pp->udev, 3) > 0)
 			invalid = 1;
 		pthread_cleanup_pop(1);
 		if (invalid)
diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 3ad33492..1c87277f 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -1869,7 +1869,7 @@ int pathinfo(struct path *pp, struct config *conf, int mask)
 			return PATHINFO_SKIPPED;
 		}
 		if (is_claimed_by_foreign(pp->udev) ||
-			 filter_property(conf, pp->udev) > 0)
+		    filter_property(conf, pp->udev, 4) > 0)
 			return PATHINFO_SKIPPED;
 	}
 
diff --git a/tests/blacklist.c b/tests/blacklist.c
index a55c1c07..54d568f5 100644
--- a/tests/blacklist.c
+++ b/tests/blacklist.c
@@ -267,7 +267,8 @@ static void test_property_blacklist(void **state)
 	static struct udev_device udev = { "sdb", { "ID_FOO", "ID_WWN", "ID_BAR", NULL } };
 	conf.blist_property = blist_property_wwn;
 	expect_condlog(3, "sdb: udev property ID_WWN blacklisted\n");
-	assert_int_equal(filter_property(&conf, &udev), MATCH_PROPERTY_BLIST);
+	assert_int_equal(filter_property(&conf, &udev, 3),
+			 MATCH_PROPERTY_BLIST);
 }
 
 /* the property check works different in that you check all the property
@@ -280,7 +281,7 @@ static void test_property_whitelist(void **state)
 	static struct udev_device udev = { "sdb", { "ID_FOO", "ID_WWN", "ID_BAR", NULL } };
 	conf.elist_property = blist_property_wwn;
 	expect_condlog(3, "sdb: udev property ID_WWN whitelisted\n");
-	assert_int_equal(filter_property(&conf, &udev),
+	assert_int_equal(filter_property(&conf, &udev, 3),
 			 MATCH_PROPERTY_BLIST_EXCEPT);
 }
 
@@ -289,7 +290,7 @@ static void test_property_missing(void **state)
 	static struct udev_device udev = { "sdb", { "ID_FOO", "ID_BAZ", "ID_BAR", NULL } };
 	conf.blist_property = blist_property_wwn;
 	expect_condlog(3, "sdb: blacklisted, udev property missing\n");
-	assert_int_equal(filter_property(&conf, &udev),
+	assert_int_equal(filter_property(&conf, &udev, 3),
 			 MATCH_PROPERTY_BLIST_MISSING);
 }
 
-- 
2.19.2

  parent reply	other threads:[~2018-12-10  9:49 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-10  9:49 [PATCH v3 00/24] multipath-tools: improve logging at -v3 Martin Wilck
2018-12-10  9:49 ` [PATCH v3 01/24] tests/hwtable: set multipath_dir in local configuration Martin Wilck
2018-12-10  9:49 ` [PATCH v3 02/24] tests/hwtable: adjust to new checker API Martin Wilck
2018-12-10  9:49 ` [PATCH v3 03/24] multipath-tools: decrease verbosity of state messages Martin Wilck
2018-12-10  9:49 ` [PATCH v3 04/24] libmultipath: decrease verbosity of pathinfo messages Martin Wilck
2018-12-10  9:49 ` [PATCH v3 05/24] libmultipath: decrease verbosity of TUR checker messages Martin Wilck
2018-12-10  9:49 ` Martin Wilck [this message]
2018-12-10  9:49 ` [PATCH v3 07/24] libmultipath: decrease log level of "disassembled" messages Martin Wilck
2018-12-10  9:49 ` [PATCH v3 08/24] libmultipath: decrease log level of word splitting Martin Wilck
2018-12-10  9:49 ` [PATCH v3 09/24] libmultipath: increase log level of map removal Martin Wilck
2018-12-10  9:49 ` [PATCH v3 10/24] multipathd: decrease log level of checker timing Martin Wilck
2018-12-10  9:49 ` [PATCH v3 11/24] libmultipath: decrease log level of "prioritizer refcount" message Martin Wilck
2018-12-10  9:49 ` [PATCH v3 12/24] libmpathpersist/update_map_pr: decrease log level for nop Martin Wilck
2018-12-10  9:49 ` [PATCH v3 13/24] libmultipath: simplify devt2devname() Martin Wilck
2018-12-10  9:49 ` [PATCH v3 14/24] libmultipath: decrease log level for failed VPD c9 Martin Wilck
2018-12-10  9:49 ` [PATCH v3 15/24] libmultipath: adopt_paths: check for size match Martin Wilck
2018-12-10  9:49 ` [PATCH v3 16/24] libmultipath: coalesce_paths: fix size mismatch handling Martin Wilck
2018-12-10  9:49 ` [PATCH v3 17/24] tests: add unit tests for bitmask functions Martin Wilck
2018-12-10  9:49 ` [PATCH v3 18/24] multipathd: uev_remove_path: remove redundant orphan_paths call Martin Wilck
2018-12-10  9:49 ` [PATCH v3 19/24] libmultipath: improve logging from orphan_paths Martin Wilck
2018-12-10  9:49 ` [PATCH v3 20/24] libmultipath: avoid syslog loglevel > LOG_DEBUG Martin Wilck
2018-12-10  9:49 ` [PATCH v3 21/24] coalesce_paths(): use symbolic return value Martin Wilck
2018-12-10  9:49 ` [PATCH v3 22/24] domap(): " Martin Wilck
2018-12-10  9:49 ` [PATCH v3 23/24] multipathd: simplify retry logic in ev_add_path() Martin Wilck
2018-12-10  9:49 ` [PATCH v3 24/24] multipath: use symbolic return value and exit code Martin Wilck
2018-12-11 17:43 ` [PATCH v3 00/24] multipath-tools: improve logging at -v3 Benjamin Marzinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181210094959.11338-7-mwilck@suse.com \
    --to=mwilck@suse.com \
    --cc=christophe.varoqui@opensvc.com \
    --cc=dm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.