multipath-tools: don't discard uevent for NVMe-Fabrics device
PATCH 1/1 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 introducing a new helper to filter "/block/" and "nvme-fabrics/ctl".
--- libmultipath/uevent.c | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-)
libmultipath/uevent.c +30 -8
@@ -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' ; }
Signature · 1 line
2.11.1
Quoted 9 lines · Guan Junxiong
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 <[email protected]>
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
Signature · 8 lines
Dr. Martin Wilck <[email protected]>, 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 [email protected] https://www.redhat.com/mailman/listinfo/dm-devel
Hi,Martin:
Quoted 9 lines · Martin Wilck
Quoted 8 lines · Guan Junxiong
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".
Quoted 8 lines
Quoted 1 line
Signed-off-by Junxiong Guan <[email protected]>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.
--
Quoted 1 line
From
2a9df3671fbad532f96918f209ddb0f76ffe28c4Mon Sep 17 00:00:00 2001
From: Junxiong Guan <[email protected]>
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".
---
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(-)
libmultipath/uevent.c +9 -21
@@ -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
Signature · 7 lines
2.11.1 -- dm-devel mailing list [email protected] https://www.redhat.com/mailman/listinfo/dm-devel
Quoted 5 lines · Guan Junxiong
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.
Signature · 8 lines
Dr. Martin Wilck <[email protected]>, 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 [email protected] https://www.redhat.com/mailman/listinfo/dm-devel