From patchwork Tue Feb 21 22:12:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keith Busch X-Patchwork-Id: 9585811 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 CF9406042F for ; Tue, 21 Feb 2017 22:06:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B543728644 for ; Tue, 21 Feb 2017 22:06:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A79572864C; Tue, 21 Feb 2017 22:06:00 +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 mx6-phx2.redhat.com (mx6-phx2.redhat.com [209.132.183.39]) (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 0751928644 for ; Tue, 21 Feb 2017 22:05:59 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v1LM4Ioo056635; Tue, 21 Feb 2017 17:04:19 -0500 Received: from smtp.corp.redhat.com (int-mx16.intmail.prod.int.phx2.redhat.com [10.5.11.28]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v1LM4HIh002954 for ; Tue, 21 Feb 2017 17:04:17 -0500 Received: by smtp.corp.redhat.com (Postfix) id 6F66C97788; Tue, 21 Feb 2017 22:04:17 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 69223723A5 for ; Tue, 21 Feb 2017 22:04:17 +0000 (UTC) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 8C23C86647 for ; Tue, 21 Feb 2017 22:04:16 +0000 (UTC) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP; 21 Feb 2017 14:04:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,191,1484035200"; d="scan'208";a="936595092" Received: from unknown (HELO localhost.lm.intel.com) ([10.232.112.96]) by orsmga003.jf.intel.com with ESMTP; 21 Feb 2017 14:04:14 -0800 From: Keith Busch To: dm-devel@redhat.com, linux-nvme@lists.infradead.org Date: Tue, 21 Feb 2017 17:12:31 -0500 Message-Id: <1487715151-1179-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.26]); Tue, 21 Feb 2017 22:04:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Tue, 21 Feb 2017 22:04:16 +0000 (UTC) for IP:'134.134.136.31' DOMAIN:'mga06.intel.com' HELO:'mga06.intel.com' FROM:'keith.busch@intel.com' RCPT:'' X-RedHat-Spam-Score: -1.902 (BAYES_50, DCC_REPUT_00_12, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, SPF_PASS) 134.134.136.31 mga06.intel.com 134.134.136.31 mga06.intel.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.74 on 10.5.11.28 X-loop: dm-devel@redhat.com Cc: Keith Busch Subject: [dm-devel] [PATCHv2] 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 --- v1->v2: Removed explicitly setting the wwid path information. We get that with through exported udev attributes. Added default retain_hwhandler to off for NVME devices. This has the kernel not call into scsi specific APIs that don't exist for NVMe. libmultipath/discovery.c | 35 +++++++++++++++++++++++++++++++++++ libmultipath/hwtable.c | 10 ++++++++++ libmultipath/structs.h | 1 + 3 files changed, 46 insertions(+) diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c index d1aec31..39dd92a 100644 --- a/libmultipath/discovery.c +++ b/libmultipath/discovery.c @@ -1187,6 +1187,36 @@ 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")); + + condlog(3, "%s: vendor:%s product:%s serial:%s rev:%s", pp->dev, + pp->vendor_id, pp->product_id, pp->serial, pp->rev); + 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 +1435,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 +1452,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..8409261 100644 --- a/libmultipath/hwtable.c +++ b/libmultipath/hwtable.c @@ -1073,6 +1073,16 @@ 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, + .retain_hwhandler = RETAIN_HWHANDLER_OFF, + }, #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 {