All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] multipath-tools: don't discard uevent for NVMe-Fabrics device
@ 2017-07-13  7:47 Guan Junxiong
  2017-07-13 10:04 ` Martin Wilck
  0 siblings, 1 reply; 4+ messages in thread
From: Guan Junxiong @ 2017-07-13  7:47 UTC (permalink / raw)
  To: dm-devel, christophe.varoqui, mwilck, keith.busch
  Cc: philip.yang, zouming.zouming, hege09, guanjunxiong, shenhong09

The devpath of uevent of NVMe-Fabrics device is like this
"../devices/virtual/nvme-fabrics/ctl/nvme0/nvme0n1" which
doesn't contains the "/block/" string. So when new uvents
of such nvme devices arise, the multipathd daemon still ignores
them, which results the DM-multipath doesn't update the table.
This patch fixes this by introducing a new helper to filter
"/block/" and "nvme-fabrics/ctl".

Signed-off-by: Junxiong Guan <guanjunxiong@huawei.com>
---
 libmultipath/uevent.c | 38 ++++++++++++++++++++++++++++++--------
 1 file changed, 30 insertions(+), 8 deletions(-)

diff --git a/libmultipath/uevent.c b/libmultipath/uevent.c
index 4fbd1dfb..09b86be3 100644
--- a/libmultipath/uevent.c
+++ b/libmultipath/uevent.c
@@ -143,25 +143,47 @@ uevent_need_merge(void)
 	return need_merge;
 }
 
+static char *uevent_devpath_filter(const char *devpath, const char *filter_str)
+{
+	char *tmp = strstr(devpath, filter_str);
+
+	if (tmp == NULL) {
+		condlog(4, "no '%s' in '%s'", filter_str, devpath);
+		return NULL;
+	}
+	tmp += strlen(filter_str);
+	if (*tmp == '\0')
+		/* just ".../filter_str/" - discard */
+		return NULL;
+
+	return tmp;
+}
+
 static bool
 uevent_can_discard_by_devpath(const char *devpath)
 {
 	static const char BLOCK[] = "/block/";
-	const char *tmp = strstr(devpath, BLOCK);
+	static const char NVME_FABRICS[] = "/nvme-fabrics/ctl/";
+	int flag_nvmf = 0;
+	char *tmp = NULL;
 
+	tmp = uevent_devpath_filter(devpath, BLOCK);
 	if (tmp == NULL) {
-		condlog(4, "no /block/ in '%s'", devpath);
-		return true;
+		flag_nvmf = 1;
+		tmp = uevent_devpath_filter(devpath, NVME_FABRICS);
 	}
-	tmp += sizeof(BLOCK) - 1;
-	if (*tmp == '\0')
-		/* just ".../block/" - discard */
+
+	if (tmp == NULL)
 		return true;
 	/*
-	 * If there are more path elements after ".../block/xyz",
-	 * it's a partition - discard it; but don't discard ".../block/sda/".
+	 * For BLOCK, if there are more path elements after ".../block/sda",
+	 * it's a partition - discard it; or else keep ".../block/sda/".
+	 * For NVME_FABRICS, don't discard "../nvme-fabrics/ctl/nvme0/nvme0n1".
 	 */
 	tmp = strchr(tmp, '/');
+	if (flag_nvmf && tmp != NULL)
+		tmp = strchr(++tmp, '/');
+
 	return tmp != NULL && *(tmp + 1) != '\0';
 }
 
-- 
2.11.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] multipath-tools: don't discard uevent for NVMe-Fabrics device
  2017-07-13  7:47 [PATCH] multipath-tools: don't discard uevent for NVMe-Fabrics device Guan Junxiong
@ 2017-07-13 10:04 ` Martin Wilck
  2017-07-14 10:49   ` Guan Junxiong
  0 siblings, 1 reply; 4+ messages in thread
From: Martin Wilck @ 2017-07-13 10:04 UTC (permalink / raw)
  To: Guan Junxiong, dm-devel, christophe.varoqui, keith.busch
  Cc: philip.yang, zouming.zouming, hege09, shenhong09

On Thu, 2017-07-13 at 15:47 +0800, Guan Junxiong wrote:
> The devpath of uevent of NVMe-Fabrics device is like this
> "../devices/virtual/nvme-fabrics/ctl/nvme0/nvme0n1" which
> doesn't contains the "/block/" string. So when new uvents
> of such nvme devices arise, the multipathd daemon still ignores
> them, which results the DM-multipath doesn't update the table.
> This patch fixes this by introducing a new helper to filter
> "/block/" and "nvme-fabrics/ctl".
> 
> Signed-off-by: Junxiong Guan <guanjunxiong@huawei.com>

The analysis is correct, but NAK nonetheless for the patch. The whole
uevent_can_discard_by_devpath() approach is broken. I'll send a patch
dropping that function entirely later today.

Martin

-- 
Dr. Martin Wilck <mwilck@suse.com>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] multipath-tools: don't discard uevent for NVMe-Fabrics device
  2017-07-13 10:04 ` Martin Wilck
@ 2017-07-14 10:49   ` Guan Junxiong
  2017-07-14 11:06     ` Martin Wilck
  0 siblings, 1 reply; 4+ messages in thread
From: Guan Junxiong @ 2017-07-14 10:49 UTC (permalink / raw)
  To: Martin Wilck
  Cc: zouming.zouming, g00401709, philip.yang, shenhong09, keith.busch,
	dm-devel, hege09

Hi,Martin:

On 2017/7/13 18:04, Martin Wilck wrote:
> On Thu, 2017-07-13 at 15:47 +0800, Guan Junxiong wrote:
>> The devpath of uevent of NVMe-Fabrics device is like this
>> "../devices/virtual/nvme-fabrics/ctl/nvme0/nvme0n1" which
>> doesn't contains the "/block/" string. So when new uvents
>> of such nvme devices arise, the multipathd daemon still ignores
>> them, which results the DM-multipath doesn't update the table.
>> This patch fixes this by introducing a new helper to filter
>> "/block/" and "nvme-fabrics/ctl".
>>
>> Signed-off-by: Junxiong Guan <guanjunxiong@huawei.com>
> 
> The analysis is correct, but NAK nonetheless for the patch. The whole
> uevent_can_discard_by_devpath() approach is broken. I'll send a patch
> dropping that function entirely later today.
> 
> Martin
> 

I haven't seen your another patch since yesterday.  So I update a new patch
in the following. Does it looks good for you ? If so, I will send it out formally.

--
>From 2a9df3671fbad532f96918f209ddb0f76ffe28c4 Mon Sep 17 00:00:00 2001
From: Junxiong Guan <guanjunxiong@huawei.com>
Date: Fri, 14 Jul 2017 11:19:39 -0400
Subject: [PATCH v2] multipath-tools: don't discard uevent for NVMe-Fabrics device

The devpath of uevent of NVMe-Fabrics device is like this
"../devices/virtual/nvme-fabrics/ctl/nvme0/nvme0n1" which
doesn't contains the "/block/" string. So when new uvents
of such nvme devices arise, the multipathd daemon still ignores
them, which results the DM-multipath doesn't update the table.
This patch fixes this by dropping the uevent_discard_by_devpath()
function and checking whether the device type of the associated
uevent is "disk".

Signed-off-by: Junxiong Guan <guanjunxiong@huawei.com>
---

Changes since v1:
* Dropped uevent_discard_by_devpath function, use __disk__ device
type to filter uevent. (Suggested by Martin Wilck)
* Modify commit comments to keep consistent with the new approach

 libmultipath/uevent.c | 30 +++++++++---------------------
 1 file changed, 9 insertions(+), 21 deletions(-)

diff --git a/libmultipath/uevent.c b/libmultipath/uevent.c
index 4fbd1dfb..1164c982 100644
--- a/libmultipath/uevent.c
+++ b/libmultipath/uevent.c
@@ -143,35 +143,23 @@ uevent_need_merge(void)
 	return need_merge;
 }

-static bool
-uevent_can_discard_by_devpath(const char *devpath)
-{
-	static const char BLOCK[] = "/block/";
-	const char *tmp = strstr(devpath, BLOCK);

-	if (tmp == NULL) {
-		condlog(4, "no /block/ in '%s'", devpath);
-		return true;
-	}
-	tmp += sizeof(BLOCK) - 1;
-	if (*tmp == '\0')
-		/* just ".../block/" - discard */
-		return true;
-	/*
-	 * If there are more path elements after ".../block/xyz",
-	 * it's a partition - discard it; but don't discard ".../block/sda/".
-	 */
-	tmp = strchr(tmp, '/');
-	return tmp != NULL && *(tmp + 1) != '\0';
-}

 bool
 uevent_can_discard(struct uevent *uev)
 {
 	struct config * conf;
+	const char *devtype = NULL;

-	if (uevent_can_discard_by_devpath(uev->devpath))
+	if (uev->devpath == NULL)
 		return true;
+	if (uev->udev)
+		devtype = udev_device_get_devtype(uev->udev);
+	if (!devtype || strncmp(devtype, "disk", 4)) {
+		condlog(4, "discard '%s' , devtype = '%s'",
+			devtype == NULL ? "" : devtype, uev->devpath);
+		return true;
+	}

 	/*
 	 * do not filter dm devices by devnode
-- 
2.11.1


--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] multipath-tools: don't discard uevent for NVMe-Fabrics device
  2017-07-14 10:49   ` Guan Junxiong
@ 2017-07-14 11:06     ` Martin Wilck
  0 siblings, 0 replies; 4+ messages in thread
From: Martin Wilck @ 2017-07-14 11:06 UTC (permalink / raw)
  To: Guan Junxiong
  Cc: zouming.zouming, philip.yang, shenhong09, keith.busch, dm-devel,
	hege09

On Fri, 2017-07-14 at 18:49 +0800, Guan Junxiong wrote:
> 
> I haven't seen your another patch since yesterday.  So I update a new
> patch
> in the following. Does it looks good for you ? If so, I will send it
> out formally.

I've been testing my patch. Will send it ASAP.
-- 
Dr. Martin Wilck <mwilck@suse.com>, Tel. +49 (0)911 74053 2107
SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-07-14 11:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-13  7:47 [PATCH] multipath-tools: don't discard uevent for NVMe-Fabrics device Guan Junxiong
2017-07-13 10:04 ` Martin Wilck
2017-07-14 10:49   ` Guan Junxiong
2017-07-14 11:06     ` Martin Wilck

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.