libmultipath: more debug output in alua prioritizer
authorMartin Wilck <mwilck@suse.com>
Tue, 3 Jul 2018 07:57:07 +0000 (09:57 +0200)
committerChristophe Varoqui <christophe.varoqui@opensvc.com>
Tue, 7 Aug 2018 13:24:55 +0000 (15:24 +0200)
Help debug problems with ALUA commands by emitting more
meaningful error messages.

Signed-off-by: Martin Wilck <mwilck@suse.com>
libmultipath/prioritizers/alua.c
libmultipath/prioritizers/alua_rtpg.c

index 03d0a0e..b24e2d4 100644 (file)
@@ -67,8 +67,11 @@ get_alua_info(struct path * pp, unsigned int timeout)
        }
        condlog(3, "%s: reported target port group is %i", pp->dev, tpg);
        rc = get_asymmetric_access_state(pp->fd, tpg, timeout);
-       if (rc < 0)
+       if (rc < 0) {
+               condlog(2, "%s: get_asymmetric_access_state returned %d",
+                       __func__, rc);
                return -ALUA_PRIO_GETAAS_FAILED;
+       }
 
        condlog(3, "%s: aas = %02x [%s]%s", pp->dev, rc, aas_print_string(rc),
                (rc & 0x80) ? " [preferred]" : "");
index 34b5f3c..811ce7a 100644 (file)
@@ -19,6 +19,7 @@
 #include <sys/ioctl.h>
 #include <inttypes.h>
 #include <libudev.h>
+#include <errno.h>
 
 #define __user
 #include <scsi/sg.h>
@@ -318,8 +319,11 @@ retry:
        hdr.sbp                 = sense;
        hdr.timeout             = get_prio_timeout(timeout, SGIO_TIMEOUT);
 
-       if (ioctl(fd, SG_IO, &hdr) < 0)
+       if (ioctl(fd, SG_IO, &hdr) < 0) {
+               condlog(2, "%s: sg ioctl failed: %s",
+                       __func__, strerror(errno));
                return -RTPG_RTPG_FAILED;
+       }
 
        rc = scsi_error(&hdr, OPERATION_CODE_RTPG);
        if (rc == SCSI_ERROR) {
@@ -355,8 +359,10 @@ get_asymmetric_access_state(int fd, unsigned int tpg, unsigned int timeout)
        }
        memset(buf, 0, buflen);
        rc = do_rtpg(fd, buf, buflen, timeout);
-       if (rc < 0)
+       if (rc < 0) {
+               PRINT_DEBUG("%s: do_rtpg returned %d", __func__, rc);
                goto out;
+       }
        scsi_buflen = get_unaligned_be32(&buf[0]) + 4;
        if (scsi_buflen > UINT_MAX)
                scsi_buflen = UINT_MAX;
@@ -364,8 +370,8 @@ get_asymmetric_access_state(int fd, unsigned int tpg, unsigned int timeout)
                free(buf);
                buf = (unsigned char *)malloc(scsi_buflen);
                if (!buf) {
-                       PRINT_DEBUG ("malloc failed: could not allocate"
-                               "%u bytes", scsi_buflen);
+                       PRINT_DEBUG("malloc failed: could not allocate %"
+                                   PRIu64 " bytes", scsi_buflen);
                        return -RTPG_RTPG_FAILED;
                }
                buflen = scsi_buflen;
@@ -389,6 +395,8 @@ get_asymmetric_access_state(int fd, unsigned int tpg, unsigned int timeout)
                        }
                }
        }
+       if (rc == -RTPG_TPG_NOT_FOUND)
+               condlog(2, "%s: port group %d not found", __func__, tpg);
 out:
        free(buf);
        return rc;