From patchwork Wed Nov 21 10:18:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10692307 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B081E13BB for ; Wed, 21 Nov 2018 10:19:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9E2392B4FD for ; Wed, 21 Nov 2018 10:19:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9229B2B571; Wed, 21 Nov 2018 10:19:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E44702B4FD for ; Wed, 21 Nov 2018 10:19:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F03E081DEA; Wed, 21 Nov 2018 10:19:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BD1CE17F4B; Wed, 21 Nov 2018 10:19:48 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 895FA181B9E3; Wed, 21 Nov 2018 10:19:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id wALAJdoC014847 for ; Wed, 21 Nov 2018 05:19:39 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4082E272C8; Wed, 21 Nov 2018 10:19:39 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx20.extmail.prod.ext.phx2.redhat.com [10.5.110.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2D4B1272D5; Wed, 21 Nov 2018 10:19:37 +0000 (UTC) Received: from smtp2.provo.novell.com (smtp2.provo.novell.com [137.65.250.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C91DF308123E; Wed, 21 Nov 2018 10:19:35 +0000 (UTC) Received: from apollon.suse.de.de (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (TLS encrypted); Wed, 21 Nov 2018 03:19:29 -0700 From: Martin Wilck To: Christophe Varoqui Date: Wed, 21 Nov 2018 11:18:26 +0100 Message-Id: <20181121101839.30784-7-mwilck@suse.com> In-Reply-To: <20181121101839.30784-1-mwilck@suse.com> References: <20181121101839.30784-1-mwilck@suse.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 216 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 21 Nov 2018 10:19:36 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Wed, 21 Nov 2018 10:19:36 +0000 (UTC) for IP:'137.65.250.81' DOMAIN:'smtp2.provo.novell.com' HELO:'smtp2.provo.novell.com' FROM:'mwilck@suse.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 137.65.250.81 smtp2.provo.novell.com 137.65.250.81 smtp2.provo.novell.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.49 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH 06/19] libmultipath: avoid frequent messages from filter_property() X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Wed, 21 Nov 2018 10:19:49 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP 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(). Signed-off-by: Martin Wilck --- 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); }