From patchwork Thu Mar 1 19:29:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10252309 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 B786360365 for ; Thu, 1 Mar 2018 19:30:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A875F28587 for ; Thu, 1 Mar 2018 19:30:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A7301285C4; Thu, 1 Mar 2018 19:30:56 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 4B4D828587 for ; Thu, 1 Mar 2018 19:30:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 068C937E80; Thu, 1 Mar 2018 19:30:54 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B46145D6B4; Thu, 1 Mar 2018 19:30:54 +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 73BE74A471; Thu, 1 Mar 2018 19:30:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w21JUrfJ001887 for ; Thu, 1 Mar 2018 14:30:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id 9CA4F5D9C7; Thu, 1 Mar 2018 19:30:53 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 902145D960 for ; Thu, 1 Mar 2018 19:30:47 +0000 (UTC) Received: from esa3.hgst.iphmx.com (esa3.hgst.iphmx.com [216.71.153.141]) (using TLSv1.2 with cipher RC4-SHA (112/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D056381DF1 for ; Thu, 1 Mar 2018 19:30:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1519932638; x=1551468638; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=Z+8xh0aYQ0YON/H87oKpTiP+xLDFHmnKBQk/r3a+UhU=; b=UHHPGJO/mK9zLJeXHo1uFWKZ5WxkMkEgmj9Mwp26WhYYtnjGTtChoFH3 cIK5ysxTpkkw+t1kC/T5dx6UCSBOfBdIgjSlupEdp+Uc8FvOqHO5RlGK1 GJptdEjvmx3bQaUqGnxInT9OOT+eOparyJxOgfByxfh3IKkBoGf/j9G3J EbXnqr3QXUs6tHWKcxMpRe5LD8POzpVej8Qq7OxnHh8krRlMH058ysv3B fDOsynm79vcEbyWj1biPVixxo7dx4NSOCdUtRKk8yff7tg3x4CHT3eylJ I5hnL+xjnZ7Iy3kbinhqDllDeOp0voEFCzhMRn8KtIlF2L8vbXe9omKPb A==; X-IronPort-AV: E=Sophos;i="5.47,409,1515427200"; d="scan'208";a="73257829" Received: from uls-op-cesaip02.wdc.com (HELO uls-op-cesaep02.wdc.com) ([199.255.45.15]) by ob1.hgst.iphmx.com with ESMTP; 02 Mar 2018 03:29:37 +0800 Received: from uls-op-cesaip01.wdc.com ([10.248.3.36]) by uls-op-cesaep02.wdc.com with ESMTP; 01 Mar 2018 11:22:59 -0800 Received: from thinkpad-bart.sdcorp.global.sandisk.com (HELO thinkpad-bart.int.fusionio.com) ([10.11.171.236]) by uls-op-cesaip01.wdc.com with ESMTP; 01 Mar 2018 11:29:36 -0800 From: Bart Van Assche To: Christophe Varoqui Date: Thu, 1 Mar 2018 11:29:34 -0800 Message-Id: <20180301192935.14643-6-bart.vanassche@wdc.com> In-Reply-To: <20180301192935.14643-1-bart.vanassche@wdc.com> References: <20180301192935.14643-1-bart.vanassche@wdc.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.25]); Thu, 01 Mar 2018 19:30:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 01 Mar 2018 19:30:37 +0000 (UTC) for IP:'216.71.153.141' DOMAIN:'esa3.hgst.iphmx.com' HELO:'esa3.hgst.iphmx.com' FROM:'bart.vanassche@wdc.com' RCPT:'' X-RedHat-Spam-Score: -0.8 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_LOW) 216.71.153.141 esa3.hgst.iphmx.com 216.71.153.141 esa3.hgst.iphmx.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: dm-devel@redhat.com Cc: Bart Van Assche , dm-devel@redhat.com Subject: [dm-devel] [PATCH 5/6] libmultipath: Fix sgio_get_vpd() 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.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 01 Mar 2018 19:30:55 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP Pass the VPD page number to sgio_get_vpd() such that the page needed by the caller is queried instead of page 0x83. Fix the statement that computes the length of the page returned by do_inq(). Fix the return code check in the caller of sgio_get_vpd(). Signed-off-by: Bart Van Assche --- libmultipath/discovery.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index d84715e15db1..780feb253797 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -836,8 +836,9 @@ detect_alua(struct path * pp, struct config *conf) #define DEFAULT_SGIO_LEN 254 +/* Query VPD page @pg. Returns 0 upon success and -1 upon failure. */ static int -sgio_get_vpd (unsigned char * buff, int maxlen, int fd) +sgio_get_vpd (unsigned char * buff, int maxlen, int fd, int pg) { int len = DEFAULT_SGIO_LEN; @@ -846,8 +847,8 @@ sgio_get_vpd (unsigned char * buff, int maxlen, int fd) return -1; } retry: - if (0 == do_inq(fd, 0, 1, 0x83, buff, len)) { - len = buff[3] + (buff[2] << 8); + if (0 == do_inq(fd, 0, 1, pg, buff, len)) { + len = buff[3] + (buff[2] << 8) + 4; if (len >= maxlen) return len; if (len > DEFAULT_SGIO_LEN) @@ -1099,7 +1100,7 @@ get_vpd_sgio (int fd, int pg, char * str, int maxlen) unsigned char buff[4096]; memset(buff, 0x0, 4096); - if (sgio_get_vpd(buff, 4096, fd) <= 0) { + if (sgio_get_vpd(buff, 4096, fd, pg) < 0) { condlog(3, "failed to issue vpd inquiry for pg%02x", pg); return -errno;