libmultipath: avoid frequent messages from filter_property()
authorMartin Wilck <mwilck@suse.com>
Mon, 10 Dec 2018 09:49:41 +0000 (10:49 +0100)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Mon, 10 Dec 2018 23:40:43 +0000 (00:40 +0100)
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
libmultipath/blacklist.h
libmultipath/configure.c
libmultipath/discovery.c
tests/blacklist.c

index 318ec03..709895e 100644 (file)
@@ -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;
 }
 
index 18903b6..4c8ec99 100644 (file)
@@ -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);
index ed3e30f..406cd4c 100644 (file)
@@ -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)
index 3ad3349..1c87277 100644 (file)
@@ -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;
        }
 
index a55c1c0..54d568f 100644 (file)
@@ -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);
 }