From patchwork Tue Jul 3 07:57:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Wilck X-Patchwork-Id: 10503405 X-Patchwork-Delegate: christophe.varoqui@free.fr Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 39750601D3 for ; Tue, 3 Jul 2018 08:01:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B76A28928 for ; Tue, 3 Jul 2018 08:01:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20034289D4; Tue, 3 Jul 2018 08:01:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A00C728928 for ; Tue, 3 Jul 2018 08:01:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6086530E6848; Tue, 3 Jul 2018 08:01:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 32CDB30012A6; Tue, 3 Jul 2018 08:01:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A577818037ED; Tue, 3 Jul 2018 08:01:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w637vff8004403 for ; Tue, 3 Jul 2018 03:57:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 157F75B680; Tue, 3 Jul 2018 07:57:41 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx18.extmail.prod.ext.phx2.redhat.com [10.5.110.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 436615D76F; Tue, 3 Jul 2018 07:57:37 +0000 (UTC) Received: from smtp2.provo.novell.com (smtp2.provo.novell.com [137.65.250.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 62D3E30820E1; Tue, 3 Jul 2018 07:57:35 +0000 (UTC) Received: from apollon.suse.de.de (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by smtp2.provo.novell.com with ESMTP (TLS encrypted); Tue, 03 Jul 2018 01:57:30 -0600 From: Martin Wilck To: Christophe Varoqui Date: Tue, 3 Jul 2018 09:57:05 +0200 Message-Id: <20180703075707.834-1-mwilck@suse.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 207 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Tue, 03 Jul 2018 07:57:35 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Tue, 03 Jul 2018 07:57:35 +0000 (UTC) for IP:'137.65.250.81' DOMAIN:'smtp2.provo.novell.com' HELO:'smtp2.provo.novell.com' FROM:'mwilck@suse.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (RCVD_IN_DNSWL_MED, SPF_PASS) 137.65.250.81 smtp2.provo.novell.com 137.65.250.81 smtp2.provo.novell.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.47 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: dm-devel@redhat.com Cc: dm-devel@redhat.com, Martin Wilck Subject: [dm-devel] [PATCH 1/3] libmultipath: alua_rtpg: use condlog for error messages X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Tue, 03 Jul 2018 08:01:55 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Map the PRINT_DEBUG macro of the ALUA code to a condlog call, to be able to better debug SCSI error conditions. Signed-off-by: Martin Wilck Reviewed-by: Benjamin Marzinski --- libmultipath/prioritizers/alua_rtpg.c | 34 +++++++++++---------------- 1 file changed, 14 insertions(+), 20 deletions(-) diff --git a/libmultipath/prioritizers/alua_rtpg.c b/libmultipath/prioritizers/alua_rtpg.c index e4315020..ce405b55 100644 --- a/libmultipath/prioritizers/alua_rtpg.c +++ b/libmultipath/prioritizers/alua_rtpg.c @@ -27,20 +27,14 @@ #include "../prio.h" #include "../discovery.h" #include "../unaligned.h" +#include "../debug.h" #include "alua_rtpg.h" #define SENSE_BUFF_LEN 32 #define SGIO_TIMEOUT 60000 -/* - * Macro used to print debug messaged. - */ -#if DEBUG > 0 #define PRINT_DEBUG(f, a...) \ - fprintf(stderr, "DEBUG: " f, ##a) -#else -#define PRINT_DEBUG(f, a...) -#endif + condlog(4, "alua: " f, ##a) /* * Optionally print the commands sent and the data received a hex dump. @@ -144,12 +138,12 @@ do_inquiry(int fd, int evpd, unsigned int codepage, hdr.timeout = get_prio_timeout(timeout, SGIO_TIMEOUT); if (ioctl(fd, SG_IO, &hdr) < 0) { - PRINT_DEBUG("do_inquiry: IOCTL failed!\n"); + PRINT_DEBUG("do_inquiry: IOCTL failed!"); return -RTPG_INQUIRY_FAILED; } if (scsi_error(&hdr)) { - PRINT_DEBUG("do_inquiry: SCSI error!\n"); + PRINT_DEBUG("do_inquiry: SCSI error!"); return -RTPG_INQUIRY_FAILED; } PRINT_HEX((unsigned char *) resp, resplen); @@ -189,7 +183,7 @@ get_sysfs_pg83(struct path *pp, unsigned char *buff, int buflen) } if (!parent || sysfs_get_vpd(parent, 0x83, buff, buflen) <= 0) { - PRINT_DEBUG("failed to read sysfs vpd pg83\n"); + PRINT_DEBUG("failed to read sysfs vpd pg83"); return -1; } return 0; @@ -208,7 +202,7 @@ get_target_port_group(struct path * pp, unsigned int timeout) buf = (unsigned char *)malloc(buflen); if (!buf) { PRINT_DEBUG("malloc failed: could not allocate" - "%u bytes\n", buflen); + "%u bytes", buflen); return -RTPG_RTPG_FAILED; } @@ -230,7 +224,7 @@ get_target_port_group(struct path * pp, unsigned int timeout) buf = (unsigned char *)malloc(scsi_buflen); if (!buf) { PRINT_DEBUG("malloc failed: could not allocate" - "%u bytes\n", scsi_buflen); + "%u bytes", scsi_buflen); return -RTPG_RTPG_FAILED; } buflen = scsi_buflen; @@ -248,7 +242,7 @@ get_target_port_group(struct path * pp, unsigned int timeout) struct vpd83_tpg_dscr *p; if (rc != -RTPG_NO_TPG_IDENTIFIER) { PRINT_DEBUG("get_target_port_group: more " - "than one TPG identifier found!\n"); + "than one TPG identifier found!"); continue; } p = (struct vpd83_tpg_dscr *)dscr->data; @@ -258,7 +252,7 @@ get_target_port_group(struct path * pp, unsigned int timeout) if (rc == -RTPG_NO_TPG_IDENTIFIER) { PRINT_DEBUG("get_target_port_group: " - "no TPG identifier found!\n"); + "no TPG identifier found!"); } out: free(buf); @@ -293,7 +287,7 @@ do_rtpg(int fd, void* resp, long resplen, unsigned int timeout) return -RTPG_RTPG_FAILED; if (scsi_error(&hdr)) { - PRINT_DEBUG("do_rtpg: SCSI error!\n"); + PRINT_DEBUG("do_rtpg: SCSI error!"); return -RTPG_RTPG_FAILED; } PRINT_HEX(resp, resplen); @@ -315,7 +309,7 @@ get_asymmetric_access_state(int fd, unsigned int tpg, unsigned int timeout) buf = (unsigned char *)malloc(buflen); if (!buf) { PRINT_DEBUG ("malloc failed: could not allocate" - "%u bytes\n", buflen); + "%u bytes", buflen); return -RTPG_RTPG_FAILED; } memset(buf, 0, buflen); @@ -330,7 +324,7 @@ get_asymmetric_access_state(int fd, unsigned int tpg, unsigned int timeout) buf = (unsigned char *)malloc(scsi_buflen); if (!buf) { PRINT_DEBUG ("malloc failed: could not allocate" - "%u bytes\n", scsi_buflen); + "%u bytes", scsi_buflen); return -RTPG_RTPG_FAILED; } buflen = scsi_buflen; @@ -347,9 +341,9 @@ get_asymmetric_access_state(int fd, unsigned int tpg, unsigned int timeout) if (rc != -RTPG_TPG_NOT_FOUND) { PRINT_DEBUG("get_asymmetric_access_state: " "more than one entry with same port " - "group.\n"); + "group."); } else { - PRINT_DEBUG("pref=%i\n", dscr->b0); + condlog(5, "pref=%i", dscr->b0); rc = rtpg_tpg_dscr_get_aas(dscr); } }