Skip to contentSkip to conversation

multipath.rules: handle NVME devices

PATCH In review Martin Wilck 2 participants 4 messages Jan 19, 2018 – Feb 7, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 multipath.rules: handle NVME devices

Note: ID_WWN is set in 60-persistent-storage.rules in current systemd. That won't work well together with us installing multipath.rules as 56-multipath.rules - multipath -u won't see ID_WWN.

However, we have strong reasons to run before blkid is invoked. ID_WWN determination for NVMe should be moved to an earlier udev rule. See systemd pull request #7594 on github.

---
 multipath/multipath.rules | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
multipath/multipath.rules +1 -1
index bc1a8529638f..6f8ee2be0a58 100644
@@ -1,7 +1,7 @@
 # Set DM_MULTIPATH_DEVICE_PATH if the device should be handled by multipath
 SUBSYSTEM!="block", GOTO="end_mpath"
 ACTION!="add|change", GOTO="end_mpath"
-KERNEL!="sd*|dasd*", GOTO="end_mpath"
+KERNEL!="sd*|dasd*|nvme*", GOTO="end_mpath"
 
 IMPORT{cmdline}="nompath"
 ENV{nompath}=="?*", GOTO="end_mpath"
Signature · 1 line
2.15.1
#1 lore raw

PATCH 2/3 libmultipath: ignore natively multipathed NVME devices

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

---
 libmultipath/discovery.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
libmultipath/discovery.c +8 -4
index 9b22bd94e491..88fc8d732258 100644
@@ -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",
Signature · 1 line
2.15.1
#2 lore raw

PATCH 3/3 multipath-tools: add dependency tracking to Makefiles

In reply to Martin Wilck
---
 .gitignore                         |  1 +
 Makefile.inc                       |  2 +-
 kpartx/Makefile                    |  7 ++++++-
 libdmmp/Makefile                   |  7 ++++++-
 libdmmp/test/Makefile              |  9 ++++++++-
 libmpathcmd/Makefile               | 10 ++++++++--
 libmpathpersist/Makefile           |  8 +++++++-
 libmultipath/Makefile              |  7 ++++++-
 libmultipath/checkers/Makefile     |  8 +++++++-
 libmultipath/prioritizers/Makefile |  8 +++++++-
 mpathpersist/Makefile              |  7 ++++++-
 multipath/Makefile                 |  7 ++++++-
 multipathd/Makefile                |  7 ++++++-
 tests/Makefile                     |  9 ++++++++-
 14 files changed, 83 insertions(+), 14 deletions(-)
.gitignore +1 -0
index 371b8758c0a1..35c59a7e2d51 100644
@@ -5,6 +5,7 @@
 *.so.0
 *.a
 *.gz
+*.d
 kpartx/kpartx
 multipath/multipath
 multipathd/multipathd
Makefile.inc +1 -1
index d82d3b5df3fe..eb99c36010c1 100644
@@ -91,7 +91,7 @@ OPTFLAGS	= -O2 -g -pipe -Wall -Wextra -Wformat=2 -Werror=implicit-int \
 		  --param=ssp-buffer-size=4
 
 CFLAGS		:= $(OPTFLAGS) -DBIN_DIR=\"$(bindir)\" -DLIB_STRING=\"${LIB}\" -DRUN_DIR=\"${RUN}\" \
-		   $(CFLAGS)
+		   -MMD -MP $(CFLAGS)
 BIN_CFLAGS	= -fPIE -DPIE
 LIB_CFLAGS	= -fPIC
 SHARED_FLAGS	= -shared
kpartx/Makefile +6 -1
index bf7362d95efd..7eb467ee3efb 100644
@@ -44,5 +44,10 @@ uninstall:
 	$(RM) $(DESTDIR)$(libudevdir)/rules.d/67-kpartx-compat.rules
 	$(RM) $(DESTDIR)$(libudevdir)/rules.d/68-del-part-nodes.rules
 
-clean:
+clean: dep_clean
 	$(RM) core *.o $(EXEC) *.gz
+
+include $(wildcard $(OBJS:.o=.d))
+
+dep_clean:
+	$(RM) $(OBJS:.o=.d)
libdmmp/Makefile +6 -1
index bf231ace1a1b..1dd3f34069b9 100644
@@ -56,11 +56,13 @@ uninstall:
 	$(RM) $(DESTDIR)$(man3dir)/libdmmp.h*
 	$(RM) $(DESTDIR)$(pkgconfdir)/$(PKGFILE)
 
-clean:
+clean: dep_clean
 	$(RM) core *.a *.o *.gz *.so *.so.*
 	$(RM) -r docs/man
 	$(MAKE) -C test clean
 
+include $(wildcard $(OBJS:.o=.d))
+
 check: all
 	$(MAKE) -C test check
 
@@ -84,3 +86,6 @@ docs/man/$(EXTRA_MAN_FILES).gz: $(HEADERS)
 		gzip -f $$file; \
 	done
 	find docs/man -type f -name \*[0-9].gz
+
+dep_clean:
+	$(RM) $(OBJS:.o=.d)
libdmmp/test/Makefile +8 -1
index acfb3bffb7f5..20b394587c4a 100644
@@ -26,5 +26,12 @@ speed_test: $(SPD_TEST_EXEC)
 	sudo env LD_LIBRARY_PATH=$(_libdmmpdir):$(_mpathcmddir) \
 		time -p ./$(SPD_TEST_EXEC)
 
-clean:
+clean: dep_clean
 	rm -f $(TEST_EXEC) $(SPD_TEST_EXEC)
+
+OBJS = $(TEST_EXEC).o $(SPD_TEST_EXEC).o
+include $(wildcard $(OBJS:.o=.d))
+
+
+dep_clean:
+	$(RM) $(OBJS:.o=.d)
libmpathcmd/Makefile +8 -2
index 4f321017361d..53c08992420b 100644
@@ -26,5 +26,11 @@ uninstall:
 	$(RM) $(DESTDIR)$(syslibdir)/$(DEVLIB)
 	$(RM) $(DESTDIR)$(includedir)/mpath_cmd.h
 
-clean:
-	$(RM) core *.a *.o *.so *.so.* *.gz
+clean: dep_clean
+	$(RM) core *.a *.o *.so *.so.* *.gz 
+
+include $(wildcard $(OBJS:.o=.d))
+
+
+dep_clean:
+	$(RM) $(OBJS:.o=.d)
libmpathpersist/Makefile +7 -1
index 1b4ec16a18f7..21fdad805f10 100644
@@ -37,5 +37,11 @@ uninstall:
 	$(RM) $(DESTDIR)$(includedir)/mpath_persist.h
 	$(RM) $(DESTDIR)$(syslibdir)/$(DEVLIB)
 
-clean:
+clean: dep_clean
 	$(RM) core *.a *.o *.so *.so.* *.gz
+
+include $(wildcard $(OBJS:.o=.d))
+
+
+dep_clean:
+	$(RM) $(OBJS:.o=.d)
libmultipath/Makefile +6 -1
index 6447d8dafb4f..25b052729d48 100644
@@ -61,5 +61,10 @@ uninstall:
 	$(RM) $(DESTDIR)$(syslibdir)/$(LIBS)
 	$(RM) $(DESTDIR)$(syslibdir)/$(DEVLIB)
 
-clean:
+clean: dep_clean
 	$(RM) core *.a *.o *.so *.so.* *.gz
+
+include $(wildcard $(OBJS:.o=.d))
+
+dep_clean:
+	$(RM) $(OBJS:.o=.d)
libmultipath/checkers/Makefile +7 -1
index bce6b8b7be75..9559038a770d 100644
@@ -36,5 +36,11 @@ install:
 uninstall:
 	for file in $(LIBS); do $(RM) $(DESTDIR)$(libdir)/$$file; done
 
-clean:
+clean: dep_clean
 	$(RM) core *.a *.o *.gz *.so
+
+OBJS := $(LIBS:libcheck%.so=%.o) libsg.o directio.o
+include $(wildcard $(OBJS:.o=.d))
+
+dep_clean:
+	$(RM) $(OBJS:.o=.d)
libmultipath/prioritizers/Makefile +7 -1
index 0c71e6334473..b3cc944c810d 100644
@@ -38,5 +38,11 @@ install: $(LIBS)
 uninstall:
 	for file in $(LIBS); do $(RM) $(DESTDIR)$(libdir)/$$file; done
 
-clean:
+clean: dep_clean
 	$(RM) core *.a *.o *.gz *.so
+
+OBJS = $(LIBS:libprio%.so=%.o) alua_rtpg.o
+include $(wildcard $(OBJS:.o=.d))
+
+dep_clean:
+	$(RM) $(OBJS:.o=.d)
mpathpersist/Makefile +6 -1
index 6e5acd3b751e..51268010b31d 100644
@@ -22,9 +22,14 @@ install:
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(man8dir)
 	$(INSTALL_PROGRAM) -m 644 $(EXEC).8.gz $(DESTDIR)$(man8dir)
 
-clean:
+clean: dep_clean
 	$(RM) core *.o $(EXEC) *.gz
 
+include $(wildcard $(OBJS:.o=.d))
+
 uninstall:
 	$(RM) $(DESTDIR)$(bindir)/$(EXEC)
 	$(RM) $(DESTDIR)$(man8dir)/$(EXEC).8.gz
+
+dep_clean:
+	$(RM) $(OBJS:.o=.d)
multipath/Makefile +6 -1
index 468c056d49d0..654568af3576 100644
@@ -37,5 +37,10 @@ uninstall:
 	$(RM) $(DESTDIR)$(man8dir)/$(EXEC).8.gz
 	$(RM) $(DESTDIR)$(man5dir)/$(EXEC).conf.5.gz
 
-clean:
+clean: dep_clean
 	$(RM) core *.o $(EXEC) *.gz
+
+include $(wildcard $(OBJS:.o=.d))
+
+dep_clean:
+	$(RM) $(OBJS:.o=.d)
multipathd/Makefile +6 -1
index e6f140bf3b91..251690ec5e2a 100644
@@ -49,5 +49,10 @@ uninstall:
 	$(RM) $(DESTDIR)$(unitdir)/$(EXEC).service
 	$(RM) $(DESTDIR)$(unitdir)/$(EXEC).socket
 
-clean:
+clean: dep_clean
 	$(RM) core *.o $(EXEC) *.gz
+
+include $(wildcard $(OBJS:.o=.d))
+
+dep_clean:
+	$(RM) $(OBJS:.o=.d)
tests/Makefile +8 -1
index ff58cb8bb207..f6b55836a434 100644
@@ -17,7 +17,14 @@ TESTS := uevent
 
 all:	$(TESTS:%=%.out)
 
-clean:
+clean: dep_clean
 	rm -f $(TESTS:%=%-test) $(TESTS:%=%.out) $(TESTS:%=%.o)
 
+OBJS = $(TESTS:%=%.o)
+include $(wildcard $(OBJS:.o=.d))
 
+
+
+
+dep_clean:
+	$(RM) $(OBJS:.o=.d)
Signature · 1 line
2.15.1
maintainer Reviewed-by on v1 1/3
#3 lore raw
In reply to Martin Wilck
Quoted 8 lines · Martin Wilck

Note: ID_WWN is set in 60-persistent-storage.rules in current systemd. That won't work well together with us installing multipath.rules as 56-multipath.rules - multipath -u won't see ID_WWN.

However, we have strong reasons to run before blkid is invoked. ID_WWN determination for NVMe should be moved to an earlier udev rule. See systemd pull request #7594 on github.

ACK for all three.

Quoted 20 lines
---
 multipath/multipath.rules | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
multipath/multipath.rules +1 -1
index bc1a8529638f..6f8ee2be0a58 100644
@@ -1,7 +1,7 @@
 # Set DM_MULTIPATH_DEVICE_PATH if the device should be handled by multipath
 SUBSYSTEM!="block", GOTO="end_mpath"
 ACTION!="add|change", GOTO="end_mpath"
-KERNEL!="sd*|dasd*", GOTO="end_mpath"
+KERNEL!="sd*|dasd*|nvme*", GOTO="end_mpath"
 
 IMPORT{cmdline}="nompath"
 ENV{nompath}=="?*", GOTO="end_mpath"
Signature · 1 line
2.15.1