multipathd: fix version check for DM_DEV_ARM_POLL ioctl
authorMartin Wilck <mwilck@suse.com>
Fri, 14 Sep 2018 12:51:02 +0000 (14:51 +0200)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Sun, 7 Oct 2018 07:52:16 +0000 (09:52 +0200)
Make sure the checks in dmevent_poll_supported() and
arm_dm_event_poll() use the same logic. Currently, the
version check check fails in arm_dm_event_poll() if
libdevmapper's DM_VERSION is newer than the kernel's.

Signed-off-by: Martin Wilck <mwilck@suse.com>
multipathd/dmevents.c

index e98a974..31e64a7 100644 (file)
@@ -50,16 +50,20 @@ struct dmevent_waiter {
 };
 
 static struct dmevent_waiter *waiter;
+/*
+ * DM_VERSION_MINOR hasn't been updated when DM_DEV_ARM_POLL
+ * was added in kernel 4.13. 4.37.0 (4.14) has it, safely.
+ */
+static const unsigned int DM_VERSION_FOR_ARM_POLL[] = {4, 37, 0};
 
 int dmevent_poll_supported(void)
 {
-       unsigned int minv[3] = {4, 37, 0};
        unsigned int v[3];
 
        if (dm_drv_version(v))
                return 0;
 
-       if (VERSION_GE(v, minv))
+       if (VERSION_GE(v, DM_VERSION_FOR_ARM_POLL))
                return 1;
        return 0;
 }
@@ -120,9 +124,9 @@ static int arm_dm_event_poll(int fd)
 {
        struct dm_ioctl dmi;
        memset(&dmi, 0, sizeof(dmi));
-       dmi.version[0] = DM_VERSION_MAJOR;
-       dmi.version[1] = DM_VERSION_MINOR;
-       dmi.version[2] = DM_VERSION_PATCHLEVEL;
+       dmi.version[0] = DM_VERSION_FOR_ARM_POLL[0];
+       dmi.version[1] = DM_VERSION_FOR_ARM_POLL[1];
+       dmi.version[2] = DM_VERSION_FOR_ARM_POLL[2];
        /* This flag currently does nothing. It simply exists to
         * duplicate the behavior of libdevmapper */
        dmi.flags = 0x4;