libmultipath: dm_is_mpath cleanup
authorBenjamin Marzinski <bmarzins@redhat.com>
Tue, 11 Dec 2018 21:23:04 +0000 (15:23 -0600)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Tue, 8 Jan 2019 12:18:01 +0000 (13:18 +0100)
Add condlog() message in dm_is_mpath() fails and change the
dm_is_mpath() call in watch_dmevents() to check the return value with
the same syntax as all the other callers.

Fixes: 9050cd5a "libmultipath: fix false removes in dmevents polling code"
Reviewed-by: Martin Wilck <mwilck@suse.com>
Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
libmultipath/devmapper.c
multipathd/dmevents.c

index 0e98923..3294bd4 100644 (file)
@@ -709,41 +709,44 @@ int dm_is_mpath(const char *name)
        const char *uuid;
 
        if (!(dmt = libmp_dm_task_create(DM_DEVICE_TABLE)))
-               return -1;
+               goto out;
 
        if (!dm_task_set_name(dmt, name))
-               goto out;
+               goto out_task;
 
        dm_task_no_open_count(dmt);
 
        if (!dm_task_run(dmt))
-               goto out;
+               goto out_task;
 
        if (!dm_task_get_info(dmt, &info))
-               goto out;
+               goto out_task;
 
        r = 0;
 
        if (!info.exists)
-               goto out;
+               goto out_task;
 
        uuid = dm_task_get_uuid(dmt);
 
        if (!uuid || strncmp(uuid, UUID_PREFIX, UUID_PREFIX_LEN) != 0)
-               goto out;
+               goto out_task;
 
        /* Fetch 1st target */
        if (dm_get_next_target(dmt, NULL, &start, &length, &target_type,
                               &params) != NULL)
                /* multiple targets */
-               goto out;
+               goto out_task;
 
        if (!target_type || strcmp(target_type, TGT_MPATH) != 0)
-               goto out;
+               goto out_task;
 
        r = 1;
-out:
+out_task:
        dm_task_destroy(dmt);
+out:
+       if (r < 0)
+               condlog(2, "%s: dm command failed in %s", name, __FUNCTION__);
        return r;
 }
 
index aae7a09..0034892 100644 (file)
@@ -206,7 +206,9 @@ int watch_dmevents(char *name)
        struct dev_event *dev_evt, *old_dev_evt;
        int i;
 
-       if (!dm_is_mpath(name)) {
+       /* We know that this is a multipath device, so only fail if
+        * device-mapper tells us that we're wrong */
+       if (dm_is_mpath(name) == 0) {
                condlog(0, "%s: not a multipath device. can't watch events",
                        name);
                return -1;