[dm-devel] [PATCH 3/3] libmultipath: more debug output in alua prioritizer

Benjamin Marzinski bmarzins at redhat.com
Fri Jul 13 19:09:03 UTC 2018


On Tue, Jul 03, 2018 at 09:57:07AM +0200, Martin Wilck wrote:
> Help debug problems with ALUA commands by emitting more
> meaningful error messages.
> 
> Signed-off-by: Martin Wilck <mwilck at suse.com>
Reviewed-by: Benjamin Marzinski <bmarzins at redhat.com>
> ---
>  libmultipath/prioritizers/alua.c      |  5 ++++-
>  libmultipath/prioritizers/alua_rtpg.c | 16 ++++++++++++----
>  2 files changed, 16 insertions(+), 5 deletions(-)
> 
> diff --git a/libmultipath/prioritizers/alua.c b/libmultipath/prioritizers/alua.c
> index 03d0a0e0..b24e2d48 100644
> --- a/libmultipath/prioritizers/alua.c
> +++ b/libmultipath/prioritizers/alua.c
> @@ -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]" : "");
> diff --git a/libmultipath/prioritizers/alua_rtpg.c b/libmultipath/prioritizers/alua_rtpg.c
> index 34b5f3ce..811ce7a2 100644
> --- a/libmultipath/prioritizers/alua_rtpg.c
> +++ b/libmultipath/prioritizers/alua_rtpg.c
> @@ -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;
> -- 
> 2.17.1




More information about the dm-devel mailing list