diff mbox series

[1/1] libmultipath: dm_is_mpath cleanup

Message ID 1544563384-9721-2-git-send-email-bmarzins@redhat.com (mailing list archive)
State Not Applicable, archived
Delegated to: christophe varoqui
Headers show
Series update to v2 Fix false removes | expand

Commit Message

Benjamin Marzinski Dec. 11, 2018, 9:23 p.m. UTC
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 | 21 ++++++++++++---------
 multipathd/dmevents.c    |  4 +++-
 2 files changed, 15 insertions(+), 10 deletions(-)

Comments

Martin Wilck Jan. 8, 2019, 11:26 a.m. UTC | #1
Hi Christophe,

you missed the patch below in your last merge.

Thanks,
Martin

On Tue, 2018-12-11 at 15:23 -0600,  Benjamin Marzinski  wrote:
> 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 | 21 ++++++++++++---------
>  multipathd/dmevents.c    |  4 +++-
>  2 files changed, 15 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/libmultipath/devmapper.c b/libmultipath/devmapper.c
index 0e98923..3294bd4 100644
--- a/libmultipath/devmapper.c
+++ b/libmultipath/devmapper.c
@@ -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;
 }
 
diff --git a/multipathd/dmevents.c b/multipathd/dmevents.c
index aae7a09..0034892 100644
--- a/multipathd/dmevents.c
+++ b/multipathd/dmevents.c
@@ -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;