From patchwork Tue Feb 14 21:19:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 9572903 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 CADCA60573 for ; Tue, 14 Feb 2017 21:12:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8D9B26D05 for ; Tue, 14 Feb 2017 21:12:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD88828415; Tue, 14 Feb 2017 21:12:16 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) (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 2990326D05 for ; Tue, 14 Feb 2017 21:12:16 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1ELB1Pc058059; Tue, 14 Feb 2017 16:11:01 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1ELB0g5006020 for ; Tue, 14 Feb 2017 16:11:00 -0500 Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1ELB011016100 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO) for ; Tue, 14 Feb 2017 16:11:00 -0500 Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 7662E7FB6F for ; Tue, 14 Feb 2017 21:10:59 +0000 (UTC) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Feb 2017 13:10:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,162,1484035200"; d="scan'208";a="44467007" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.96]) by orsmga002.jf.intel.com with ESMTP; 14 Feb 2017 13:10:56 -0800 From: Keith Busch To: Christophe Varoqui , dm-devel@redhat.com Date: Tue, 14 Feb 2017 16:19:14 -0500 Message-Id: <1487107154-24883-2-git-send-email-keith.busch@intel.com> In-Reply-To: <1487107154-24883-1-git-send-email-keith.busch@intel.com> References: <1487107154-24883-1-git-send-email-keith.busch@intel.com> X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 200 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 14 Feb 2017 21:10:59 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 14 Feb 2017 21:10:59 +0000 (UTC) for IP:'192.55.52.120' DOMAIN:'mga04.intel.com' HELO:'mga04.intel.com' FROM:'keith.busch@intel.com' RCPT:'' X-RedHat-Spam-Score: -1.922 (BAYES_50, DCC_REPUT_00_12, RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, RP_MATCHES_RCVD, SPF_PASS) 192.55.52.120 mga04.intel.com 192.55.52.120 mga04.intel.com X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Scanned-By: MIMEDefang 2.78 on 10.5.110.25 X-loop: dm-devel@redhat.com Cc: Keith Busch Subject: [dm-devel] [PATCH 2/2] Fill NVMe specific path info 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-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Keith Busch --- Pat of this is dependent on udev updates. Pull request sent to systemd here: https://github.com/systemd/systemd/pull/5348 Can always add that line by hand in the mean time. libmultipath/discovery.c | 36 ++++++++++++++++++++++++++++++++++++ libmultipath/hwtable.c | 9 +++++++++ libmultipath/structs.h | 1 + 3 files changed, 46 insertions(+) diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index d1aec31..db7b04a 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -1187,6 +1187,37 @@ scsi_sysfs_pathinfo (struct path * pp, vector hwtable) } static int +nvme_sysfs_pathinfo (struct path * pp, vector hwtable) +{ + struct udev_device *parent, *nvme = NULL; + + parent = pp->udev; + while (parent) { + const char *subsys = udev_device_get_subsystem(parent); + + if (subsys && !strncmp(subsys, "nvme", 4)) { + nvme = parent; + break; + } + parent = udev_device_get_parent(parent); + } + if (!nvme) + return 1; + + snprintf(pp->vendor_id, SCSI_VENDOR_SIZE, "NVME"); + snprintf(pp->product_id, SCSI_PRODUCT_SIZE, "%s", udev_device_get_sysattr_value(nvme, "model")); + snprintf(pp->serial, SERIAL_SIZE, "%s", udev_device_get_sysattr_value(nvme, "serial")); + snprintf(pp->rev, SCSI_REV_SIZE, "%s", udev_device_get_sysattr_value(nvme, "firmware_rev")); + snprintf(pp->wwid, WWID_SIZE, "%s", udev_device_get_sysattr_value(pp->udev, "wwid")); + + condlog(3, "%s: vendor:%s product:%s serial:%s rev:%s wwid:%s", pp->dev, + pp->vendor_id, pp->product_id, pp->serial, pp->rev, pp->wwid); + pp->hwe = find_hwe(hwtable, pp->vendor_id, pp->product_id, NULL); + + return 0; +} + +static int rbd_sysfs_pathinfo (struct path * pp, vector hwtable) { sprintf(pp->vendor_id, "Ceph"); @@ -1405,6 +1436,8 @@ sysfs_pathinfo(struct path * pp, vector hwtable) pp->bus = SYSFS_BUS_SCSI; if (!strncmp(pp->dev,"rbd", 3)) pp->bus = SYSFS_BUS_RBD; + if (!strncmp(pp->dev,"nvme", 4)) + pp->bus = SYSFS_BUS_NVME; if (pp->bus == SYSFS_BUS_UNDEF) return 0; @@ -1420,6 +1453,9 @@ sysfs_pathinfo(struct path * pp, vector hwtable) } else if (pp->bus == SYSFS_BUS_RBD) { if (rbd_sysfs_pathinfo(pp, hwtable)) return 1; + } else if (pp->bus == SYSFS_BUS_NVME) { + if (nvme_sysfs_pathinfo(pp, hwtable)) + return 1; } return 0; } diff --git a/libmultipath/hwtable.c b/libmultipath/hwtable.c index f5a5f7b..c55998a 100644 --- a/libmultipath/hwtable.c +++ b/libmultipath/hwtable.c @@ -1073,6 +1073,15 @@ static struct hwentry default_hw[] = { .prio_name = PRIO_ALUA, .no_path_retry = 30, }, + /* + * Generic NVMe devices + */ + { + .vendor = "NVME", + .product = ".*", + .uid_attribute = "ID_WWN", + .checker_name = DIRECTIO, + }, #if 0 /* * Copy this TEMPLATE to add new hardware. diff --git a/libmultipath/structs.h b/libmultipath/structs.h index 6edd927..dfd65ae 100644 --- a/libmultipath/structs.h +++ b/libmultipath/structs.h @@ -53,6 +53,7 @@ enum sysfs_buses { SYSFS_BUS_CCW, SYSFS_BUS_CCISS, SYSFS_BUS_RBD, + SYSFS_BUS_NVME, }; enum pathstates {