All of lore.kernel.org
 help / color / mirror / Atom feed
From: Martin Wilck <mwilck@suse.com>
To: Christophe Varoqui <christophe.varoqui@opensvc.com>, dm-devel@redhat.com
Cc: Xose Vazquez Perez <xose.vazquez@gmail.com>,
	Martin Wilck <mwilck@suse.com>
Subject: [PATCH 2/3] libmultipath: ignore natively multipathed NVME devices
Date: Fri, 19 Jan 2018 01:19:43 +0100	[thread overview]
Message-ID: <20180119001944.9565-2-mwilck@suse.com> (raw)
In-Reply-To: <20180119001944.9565-1-mwilck@suse.com>

Such devices have a parent with SUBSYSTEM="nvme-subsystem", not "nvme".
Furthermore, avoid a possible segfaults NULL checks.

Signed-off-by: Martin Wilck <mwilck@suse.com>
---
 libmultipath/discovery.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/libmultipath/discovery.c b/libmultipath/discovery.c
index 9b22bd94e491..88fc8d732258 100644
--- a/libmultipath/discovery.c
+++ b/libmultipath/discovery.c
@@ -1200,6 +1200,7 @@ nvme_sysfs_pathinfo (struct path * pp, vector hwtable)
 {
 	struct udev_device *parent;
 	const char *attr_path = NULL;
+	const char *attr;
 
 	attr_path = udev_device_get_sysname(pp->udev);
 	if (!attr_path)
@@ -1209,14 +1210,17 @@ nvme_sysfs_pathinfo (struct path * pp, vector hwtable)
 		   &pp->sg_id.host_no,
 		   &pp->sg_id.scsi_id) != 2)
 		return 1;
-	pp->sg_id.channel = 0;
-	pp->sg_id.lun = atoi(udev_device_get_sysattr_value(pp->udev, "nsid"));
 
-	parent = udev_device_get_parent(pp->udev);
+	parent = udev_device_get_parent_with_subsystem_devtype(pp->udev,
+							       "nvme", NULL);
 	if (!parent)
 		return 1;
 
-	pp->sg_id.channel = atoi(udev_device_get_sysattr_value(parent, "cntlid"));
+	attr = udev_device_get_sysattr_value(pp->udev, "nsid");
+	pp->sg_id.lun = attr ? atoi(attr) : 0;
+
+	attr = udev_device_get_sysattr_value(parent, "cntlid");
+	pp->sg_id.channel = attr ? atoi(attr) : 0;
 
 	snprintf(pp->vendor_id, SCSI_VENDOR_SIZE, "NVME");
 	snprintf(pp->product_id, SCSI_PRODUCT_SIZE, "%s",
-- 
2.15.1

  reply	other threads:[~2018-01-19  0:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-19  0:19 [PATCH 1/3] multipath.rules: handle NVME devices Martin Wilck
2018-01-19  0:19 ` Martin Wilck [this message]
2018-01-19  0:19 ` [PATCH 3/3] multipath-tools: add dependency tracking to Makefiles Martin Wilck
2018-02-07 18:37 ` [PATCH 1/3] multipath.rules: handle NVME devices Benjamin Marzinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180119001944.9565-2-mwilck@suse.com \
    --to=mwilck@suse.com \
    --cc=christophe.varoqui@opensvc.com \
    --cc=dm-devel@redhat.com \
    --cc=xose.vazquez@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.