From patchwork Wed Aug 1 20:56:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Marzinski X-Patchwork-Id: 10556061 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-2.web.codeaurora.org (Postfix) with ESMTP id 50083157D for ; Sun, 5 Aug 2018 08:46:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DC2A296EF for ; Sun, 5 Aug 2018 08:46:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3262E29701; Sun, 5 Aug 2018 08:46:42 +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 C7F69296EF for ; Sun, 5 Aug 2018 08:46:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BE0013084029; Sun, 5 Aug 2018 08:46:40 +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 8929657DE2; Sun, 5 Aug 2018 08:46:40 +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 336191841C5C; Sun, 5 Aug 2018 08:46:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w71KvWxE027978 for ; Wed, 1 Aug 2018 16:57:32 -0400 Received: by smtp.corp.redhat.com (Postfix) id BA0272156711; Wed, 1 Aug 2018 20:57:32 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from redhat.com (octiron.msp.redhat.com [10.15.80.209]) by smtp.corp.redhat.com (Postfix) with SMTP id 86B1D215670D; Wed, 1 Aug 2018 20:57:31 +0000 (UTC) Received: by redhat.com (sSMTP sendmail emulation); Wed, 01 Aug 2018 15:57:31 -0500 From: "Benjamin Marzinski" To: device-mapper development Date: Wed, 1 Aug 2018 15:56:52 -0500 Message-Id: <1533157038-3924-7-git-send-email-bmarzins@redhat.com> In-Reply-To: <1533157038-3924-1-git-send-email-bmarzins@redhat.com> References: <1533157038-3924-1-git-send-email-bmarzins@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: dm-devel@redhat.com Cc: Martin Wilck Subject: [dm-devel] [PATCH 06/32] multipathd: add new protocol path wildcard 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Sun, 05 Aug 2018 08:46:41 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP This patch adds a new path wildcard 'P', that will print the path's protocol. For scsi devices, it will additionally print the transport protocol being used. Reviewed-by: Martin Wilck Signed-off-by: Benjamin Marzinski --- libmultipath/print.c | 43 +++++++++++++++++++++++++++++++++++++++++++ libmultipath/print.h | 2 ++ 2 files changed, 45 insertions(+) diff --git a/libmultipath/print.c b/libmultipath/print.c index 222d270..ecfcb48 100644 --- a/libmultipath/print.c +++ b/libmultipath/print.c @@ -638,6 +638,48 @@ snprint_path_failures(char * buff, size_t len, const struct path * pp) return snprint_int(buff, len, pp->failcount); } +/* if you add a protocol string bigger than "scsi:unspec" you must + * also change PROTOCOL_BUF_SIZE */ +int +snprint_path_protocol(char * buff, size_t len, const struct path * pp) +{ + switch (pp->bus) { + case SYSFS_BUS_SCSI: + switch (pp->sg_id.proto_id) { + case SCSI_PROTOCOL_FCP: + return snprintf(buff, len, "scsi:fcp"); + case SCSI_PROTOCOL_SPI: + return snprintf(buff, len, "scsi:spi"); + case SCSI_PROTOCOL_SSA: + return snprintf(buff, len, "scsi:ssa"); + case SCSI_PROTOCOL_SBP: + return snprintf(buff, len, "scsi:sbp"); + case SCSI_PROTOCOL_SRP: + return snprintf(buff, len, "scsi:srp"); + case SCSI_PROTOCOL_ISCSI: + return snprintf(buff, len, "scsi:iscsi"); + case SCSI_PROTOCOL_SAS: + return snprintf(buff, len, "scsi:sas"); + case SCSI_PROTOCOL_ADT: + return snprintf(buff, len, "scsi:adt"); + case SCSI_PROTOCOL_ATA: + return snprintf(buff, len, "scsi:ata"); + case SCSI_PROTOCOL_UNSPEC: + default: + return snprintf(buff, len, "scsi:unspec"); + } + case SYSFS_BUS_CCW: + return snprintf(buff, len, "ccw"); + case SYSFS_BUS_CCISS: + return snprintf(buff, len, "cciss"); + case SYSFS_BUS_NVME: + return snprintf(buff, len, "nvme"); + case SYSFS_BUS_UNDEF: + default: + return snprintf(buff, len, "undef"); + } +} + struct multipath_data mpd[] = { {'n', "name", 0, snprint_name}, {'w', "uuid", 0, snprint_multipath_uuid}, @@ -687,6 +729,7 @@ struct path_data pd[] = { {'a', "host adapter", 0, snprint_host_adapter}, {'G', "foreign", 0, snprint_path_foreign}, {'0', "failures", 0, snprint_path_failures}, + {'P', "protocol", 0, snprint_path_protocol}, {0, NULL, 0 , NULL} }; diff --git a/libmultipath/print.h b/libmultipath/print.h index 608b7d5..e2fb865 100644 --- a/libmultipath/print.h +++ b/libmultipath/print.h @@ -133,6 +133,8 @@ int snprint_host_wwnn (char *, size_t, const struct path *); int snprint_host_wwpn (char *, size_t, const struct path *); int snprint_tgt_wwnn (char *, size_t, const struct path *); int snprint_tgt_wwpn (char *, size_t, const struct path *); +#define PROTOCOL_BUF_SIZE sizeof("scsi:unspec") +int snprint_path_protocol(char *, size_t, const struct path *); void _print_multipath_topology (const struct gen_multipath * gmp, int verbosity);