Skip to contentSkip to conversation

multipath-tools: kernel module loading improvements

PATCH In review [email protected] 2 participants 16 messages Feb 1, 2022 – Feb 4, 2022

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

cover multipath-tools: kernel module loading improvements

From: Martin Wilck <[email protected]>

Continuation of my previous series with cleanup of systemd services. This series drops the ExecStartPre directive for loading dm-multipath in favor of a modules-load.d entry. That has the advantage to apply also for multipath when called in udev rules, and to be added to the initramfs automatically.

The loading of SCSI device handlers was dropped in the previous series already. Here, too, a modules-load.d file makes more sense than ExecStartPre. Some distributions may be served better with a softdep on scsi_mod, but that's out of scope for upstream. Therefore the list of device handler modules to preload is configurable.

Martin Wilck (6):
multipath/Makefile: use $(udevrulesdir)
multipath-tools: Makefile.inc: delete obsolete comment
multipath-tools: install modules-load.d/multipath.conf multipathd.service: drop ExecStartPre for loading dm-multipath
multipath: Makefile: modules-load.d file for SCSI device handlers README.md: add basic information about building multipath-tools

 Makefile.inc                  | 12 ++++----
 README.md                     | 56 +++++++++++++++++++++++++++++++++++
 multipath/Makefile            | 11 ++++++-
 multipath/modules-load.conf   |  3 ++
 multipathd/multipathd.service |  1 -
 5 files changed, 75 insertions(+), 8 deletions(-)
 create mode 100644 multipath/modules-load.conf
Signature · 7 lines
2.34.1


--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
#1 lore raw

PATCH 1/6 multipath/Makefile: use $(udevrulesdir)

From: Martin Wilck <[email protected]>

---
 multipath/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
multipath/Makefile +1 -1
index 7673553..c690368 100644
@@ -22,7 +22,7 @@ install:
 	$(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)/
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(udevrulesdir)
 	$(INSTALL_PROGRAM) -m 644 11-dm-mpath.rules $(DESTDIR)$(udevrulesdir)
-	$(INSTALL_PROGRAM) -m 644 $(EXEC).rules $(DESTDIR)$(libudevdir)/rules.d/56-multipath.rules
+	$(INSTALL_PROGRAM) -m 644 $(EXEC).rules $(DESTDIR)$(udevrulesdir)/56-multipath.rules
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(man8dir)
 	$(INSTALL_PROGRAM) -m 644 $(EXEC).8 $(DESTDIR)$(man8dir)
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(man5dir)
Signature · 7 lines
2.34.1


--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
maintainer Reviewed-by on v1 1/6
#2 lore raw

Re: [dm-devel] [PATCH 1/6] multipath/Makefile: use $(udevrulesdir)

Quoted 3 lines · On Wed, Feb 02, 2022 at 12:40:19AM +0100, [email protected] wrote:

From: Martin Wilck <[email protected]>

Quoted 19 lines
---
 multipath/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
multipath/Makefile +1 -1
index 7673553..c690368 100644
@@ -22,7 +22,7 @@ install:
 	$(INSTALL_PROGRAM) -m 755 $(EXEC) $(DESTDIR)$(bindir)/
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(udevrulesdir)
 	$(INSTALL_PROGRAM) -m 644 11-dm-mpath.rules $(DESTDIR)$(udevrulesdir)
-	$(INSTALL_PROGRAM) -m 644 $(EXEC).rules $(DESTDIR)$(libudevdir)/rules.d/56-multipath.rules
+	$(INSTALL_PROGRAM) -m 644 $(EXEC).rules $(DESTDIR)$(udevrulesdir)/56-multipath.rules
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(man8dir)
 	$(INSTALL_PROGRAM) -m 644 $(EXEC).8 $(DESTDIR)$(man8dir)
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(man5dir)
Signature · 1 line
2.34.1

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel

#3 lore raw

PATCH 2/6 multipath-tools: Makefile.inc: delete obsolete comment

In reply to [email protected]

From: Martin Wilck <[email protected]>

We haven't used the options since 0.4.5.

---
 Makefile.inc | 6 ------
 1 file changed, 6 deletions(-)
Makefile.inc +0 -6
index a7d16df..c5f1fa5 100644
@@ -2,12 +2,6 @@
 # Copyright (C) 2004 Christophe Varoqui, <[email protected]>
 #
 
-#
-# Allow to force some libraries to be used statically. (Uncomment one of the
-# following lines or define the values when calling make.)
-#
-# WITH_LOCAL_LIBDM	= 1
-# WITH_LOCAL_LIBSYSFS	= 1
 #
 # Uncomment to disable libdmmp support
 # ENABLE_LIBDMMP = 0
Signature · 7 lines
2.34.1


--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
maintainer Reviewed-by on v1 2/6
#4 lore raw

Re: [dm-devel] [PATCH 2/6] multipath-tools: Makefile.inc: delete obsolete comment

Quoted 5 lines · On Wed, Feb 02, 2022 at 12:40:20AM +0100, [email protected] wrote:

From: Martin Wilck <[email protected]>

We haven't used the options since 0.4.5.

Quoted 23 lines
---
 Makefile.inc | 6 ------
 1 file changed, 6 deletions(-)
Makefile.inc +0 -6
index a7d16df..c5f1fa5 100644
@@ -2,12 +2,6 @@
 # Copyright (C) 2004 Christophe Varoqui, <[email protected]>
 #
 
-#
-# Allow to force some libraries to be used statically. (Uncomment one of the
-# following lines or define the values when calling make.)
-#
-# WITH_LOCAL_LIBDM	= 1
-# WITH_LOCAL_LIBSYSFS	= 1
 #
 # Uncomment to disable libdmmp support
 # ENABLE_LIBDMMP = 0
Signature · 1 line
2.34.1

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel

#5 lore raw

PATCH 3/6 multipath-tools: install modules-load.d/multipath.conf

In reply to [email protected]

From: Martin Wilck <[email protected]>

If multipath-tools is installed, we want to load the dm-multipath module early on, because multipath -u might spit out irritating error messages in syslog otherwise.

---
 Makefile.inc                | 1 +
 multipath/Makefile          | 3 +++
 multipath/modules-load.conf | 3 +++
 3 files changed, 7 insertions(+)
 create mode 100644 multipath/modules-load.conf
Makefile.inc +1 -0
index c5f1fa5..5223c96 100644
@@ -73,6 +73,7 @@ usr_prefix	= $(prefix)
 bindir		= $(exec_prefix)/sbin
 libudevdir	= $(prefix)/$(SYSTEMDPATH)/udev
 udevrulesdir	= $(libudevdir)/rules.d
+modulesloaddir  = $(prefix)/$(SYSTEMDPATH)/modules-load.d
 multipathdir	= $(TOPDIR)/libmultipath
 man8dir		= $(prefix)/usr/share/man/man8
 man5dir		= $(prefix)/usr/share/man/man5
multipath/Makefile +3 -0
index c690368..015f73c 100644
@@ -23,6 +23,8 @@ install:
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(udevrulesdir)
 	$(INSTALL_PROGRAM) -m 644 11-dm-mpath.rules $(DESTDIR)$(udevrulesdir)
 	$(INSTALL_PROGRAM) -m 644 $(EXEC).rules $(DESTDIR)$(udevrulesdir)/56-multipath.rules
+	$(INSTALL_PROGRAM) -d $(DESTDIR)$(modulesloaddir)
+	$(INSTALL_PROGRAM) -m 644 modules-load.conf $(DESTDIR)$(modulesloaddir)/multipath.conf
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(man8dir)
 	$(INSTALL_PROGRAM) -m 644 $(EXEC).8 $(DESTDIR)$(man8dir)
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(man5dir)
@@ -31,6 +33,7 @@ install:
 uninstall:
 	$(RM) $(DESTDIR)$(bindir)/$(EXEC)
 	$(RM) $(DESTDIR)$(udevrulesdir)/11-dm-mpath.rules
+	$(RM) $(DESTDIR)$(modulesloaddir)/multipath.conf
 	$(RM) $(DESTDIR)$(libudevdir)/rules.d/56-multipath.rules
 	$(RM) $(DESTDIR)$(man8dir)/$(EXEC).8
 	$(RM) $(DESTDIR)$(man5dir)/$(EXEC).conf.5
multipath/modules-load.conf new file +3 -0
new file mode 100644
index 0000000..b517d32
@@ -0,0 +1,3 @@
+# load dm-multipath early, both multipathd and multipath depend on it
+# (note that multipath may be called from udev rules!)
+dm-multipath
Signature · 7 lines
2.34.1


--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
maintainer Reviewed-by on v1 3/6
#6 lore raw

Re: [dm-devel] [PATCH 3/6] multipath-tools: install modules-load.d/multipath.conf

Quoted 7 lines · On Wed, Feb 02, 2022 at 12:40:21AM +0100, [email protected] wrote:

From: Martin Wilck <[email protected]>

If multipath-tools is installed, we want to load the dm-multipath module early on, because multipath -u might spit out irritating error messages in syslog otherwise.

Quoted 51 lines
---
 Makefile.inc                | 1 +
 multipath/Makefile          | 3 +++
 multipath/modules-load.conf | 3 +++
 3 files changed, 7 insertions(+)
 create mode 100644 multipath/modules-load.conf
Makefile.inc +1 -0
index c5f1fa5..5223c96 100644
@@ -73,6 +73,7 @@ usr_prefix	= $(prefix)
 bindir		= $(exec_prefix)/sbin
 libudevdir	= $(prefix)/$(SYSTEMDPATH)/udev
 udevrulesdir	= $(libudevdir)/rules.d
+modulesloaddir  = $(prefix)/$(SYSTEMDPATH)/modules-load.d
 multipathdir	= $(TOPDIR)/libmultipath
 man8dir		= $(prefix)/usr/share/man/man8
 man5dir		= $(prefix)/usr/share/man/man5
multipath/Makefile +3 -0
index c690368..015f73c 100644
@@ -23,6 +23,8 @@ install:
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(udevrulesdir)
 	$(INSTALL_PROGRAM) -m 644 11-dm-mpath.rules $(DESTDIR)$(udevrulesdir)
 	$(INSTALL_PROGRAM) -m 644 $(EXEC).rules $(DESTDIR)$(udevrulesdir)/56-multipath.rules
+	$(INSTALL_PROGRAM) -d $(DESTDIR)$(modulesloaddir)
+	$(INSTALL_PROGRAM) -m 644 modules-load.conf $(DESTDIR)$(modulesloaddir)/multipath.conf
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(man8dir)
 	$(INSTALL_PROGRAM) -m 644 $(EXEC).8 $(DESTDIR)$(man8dir)
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(man5dir)
@@ -31,6 +33,7 @@ install:
 uninstall:
 	$(RM) $(DESTDIR)$(bindir)/$(EXEC)
 	$(RM) $(DESTDIR)$(udevrulesdir)/11-dm-mpath.rules
+	$(RM) $(DESTDIR)$(modulesloaddir)/multipath.conf
 	$(RM) $(DESTDIR)$(libudevdir)/rules.d/56-multipath.rules
 	$(RM) $(DESTDIR)$(man8dir)/$(EXEC).8
 	$(RM) $(DESTDIR)$(man5dir)/$(EXEC).conf.5
multipath/modules-load.conf new file +3 -0
new file mode 100644
index 0000000..b517d32
@@ -0,0 +1,3 @@
+# load dm-multipath early, both multipathd and multipath depend on it
+# (note that multipath may be called from udev rules!)
+dm-multipath
Signature · 1 line
2.34.1

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel

#7 lore raw

PATCH 4/6 multipathd.service: drop ExecStartPre for loading dm-multipath

In reply to [email protected]

From: Martin Wilck <[email protected]>

As we install a modules-load.d file now, no need to call modprobe in ExecStartPre any more.

---
 multipathd/multipathd.service | 1 -
 1 file changed, 1 deletion(-)
multipathd/multipathd.service +0 -1
index ae98034..aec62db 100644
@@ -16,7 +16,6 @@ ConditionVirtualization=!container
 [Service]
 Type=notify
 NotifyAccess=main
-ExecStartPre=-/sbin/modprobe dm-multipath
 ExecStart=/sbin/multipathd -d -s
 ExecReload=/sbin/multipathd reconfigure
 TasksMax=infinity
Signature · 7 lines
2.34.1


--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
maintainer Reviewed-by on v1 4/6
#8 lore raw

Re: [dm-devel] [PATCH 4/6] multipathd.service: drop ExecStartPre for loading dm-multipath

Quoted 6 lines · On Wed, Feb 02, 2022 at 12:40:22AM +0100, [email protected] wrote:

From: Martin Wilck <[email protected]>

As we install a modules-load.d file now, no need to call modprobe in ExecStartPre any more.

Quoted 18 lines
---
 multipathd/multipathd.service | 1 -
 1 file changed, 1 deletion(-)
multipathd/multipathd.service +0 -1
index ae98034..aec62db 100644
@@ -16,7 +16,6 @@ ConditionVirtualization=!container
 [Service]
 Type=notify
 NotifyAccess=main
-ExecStartPre=-/sbin/modprobe dm-multipath
 ExecStart=/sbin/multipathd -d -s
 ExecReload=/sbin/multipathd reconfigure
 TasksMax=infinity
Signature · 1 line
2.34.1

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel

#9 lore raw

PATCH 5/6 multipath: Makefile: modules-load.d file for SCSI device handlers

In reply to [email protected]

From: Martin Wilck <[email protected]>

The kernel's autoload mechanism for SCSI device handlers doesn't work during SCSI device probing. While it's possible to load and attach device handlers after probing, it has disadvantages: the handlers are useful for error handling even before multipathd has started, and at least up to kernel 5.17, the sysfs "access_state" attribute will remain invisible for already probed devices.

Distributions will therefore want to make sure the handlers are either built-in in the kernel, or loaded early. Add functionality to create and install a modules-load.d file with a list of handlers to load. By default, the list is empty, and no file will be generated. The list can be specified at install-time like this:

make SCSI_DH_MODULES_PRELOAD="scsi_dh_rdac scsi_dh_emc" install

dracut automatically adds modules-load.d files and the modules they reference to the initramfs.

Note: distributions that compile scsi_mod as a module may rather want to use a modprobe.d file with a statement like this:

softdep scsi_mod post: scsi_dh_alua scsi_dh_rdac

---
 Makefile.inc       | 5 +++++
 multipath/Makefile | 6 ++++++
 2 files changed, 11 insertions(+)
Makefile.inc +5 -0
index 5223c96..3342af6 100644
@@ -9,6 +9,11 @@
 # Uncomment to disable dmevents polling support
 # ENABLE_DMEVENTS_POLL = 0
 
+# List of scsi device handler modules to load on boot, e.g.
+# SCSI_DH_MODULES_PRELOAD := scsi_dh_alua scsi_dh_rdac
+SCSI_DH_MODULES_PRELOAD :=
+
+
 PKGCONFIG	?= pkg-config
 
 ifeq ($(TOPDIR),)
multipath/Makefile +6 -0
index 015f73c..c930499 100644
@@ -29,11 +29,17 @@ install:
 	$(INSTALL_PROGRAM) -m 644 $(EXEC).8 $(DESTDIR)$(man8dir)
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(man5dir)
 	$(INSTALL_PROGRAM) -m 644 $(EXEC).conf.5 $(DESTDIR)$(man5dir)
+ifneq ($(SCSI_DH_MODULES_PRELOAD),)
+	$(INSTALL_PROGRAM) -m 644 scsi_dh.conf $(DESTDIR)$(modulesloaddir)/scsi_dh.conf
+	for _x in $(SCSI_DH_MODULES_PRELOAD); do echo "$$_x"; done \
+	    >>$(DESTDIR)$(modulesloaddir)/scsi_dh.conf
+endif
 
 uninstall:
 	$(RM) $(DESTDIR)$(bindir)/$(EXEC)
 	$(RM) $(DESTDIR)$(udevrulesdir)/11-dm-mpath.rules
 	$(RM) $(DESTDIR)$(modulesloaddir)/multipath.conf
+	$(RM) $(DESTDIR)$(modulesloaddir)/scsi_dh.conf
 	$(RM) $(DESTDIR)$(libudevdir)/rules.d/56-multipath.rules
 	$(RM) $(DESTDIR)$(man8dir)/$(EXEC).8
 	$(RM) $(DESTDIR)$(man5dir)/$(EXEC).conf.5
Signature · 7 lines
2.34.1


--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
#10 lore raw

Re: [dm-devel] [PATCH 5/6] multipath: Makefile: modules-load.d file for SCSI device handlers

Quoted 17 lines · On Wed, Feb 02, 2022 at 12:40:23AM +0100, [email protected] wrote:

From: Martin Wilck <[email protected]>

The kernel's autoload mechanism for SCSI device handlers doesn't work during SCSI device probing. While it's possible to load and attach device handlers after probing, it has disadvantages: the handlers are useful for error handling even before multipathd has started, and at least up to kernel 5.17, the sysfs "access_state" attribute will remain invisible for already probed devices.

Distributions will therefore want to make sure the handlers are either built-in in the kernel, or loaded early. Add functionality to create and install a modules-load.d file with a list of handlers to load. By default, the list is empty, and no file will be generated. The list can be specified at install-time like this:

make SCSI_DH_MODULES_PRELOAD="scsi_dh_rdac scsi_dh_emc" install

Quoted 8 lines

dracut automatically adds modules-load.d files and the modules they reference to the initramfs.

Note: distributions that compile scsi_mod as a module may rather want to use a modprobe.d file with a statement like this:

softdep scsi_mod post: scsi_dh_alua scsi_dh_rdac

I think you might need a default scsi_dh.conf file with a comment header or something. install won't install a file that doesn't exist. Or am I missing something here?

-Ben

Quoted 46 lines
---
 Makefile.inc       | 5 +++++
 multipath/Makefile | 6 ++++++
 2 files changed, 11 insertions(+)
Makefile.inc +5 -0
index 5223c96..3342af6 100644
@@ -9,6 +9,11 @@
 # Uncomment to disable dmevents polling support
 # ENABLE_DMEVENTS_POLL = 0
 
+# List of scsi device handler modules to load on boot, e.g.
+# SCSI_DH_MODULES_PRELOAD := scsi_dh_alua scsi_dh_rdac
+SCSI_DH_MODULES_PRELOAD :=
+
+
 PKGCONFIG	?= pkg-config
 
 ifeq ($(TOPDIR),)
multipath/Makefile +6 -0
index 015f73c..c930499 100644
@@ -29,11 +29,17 @@ install:
 	$(INSTALL_PROGRAM) -m 644 $(EXEC).8 $(DESTDIR)$(man8dir)
 	$(INSTALL_PROGRAM) -d $(DESTDIR)$(man5dir)
 	$(INSTALL_PROGRAM) -m 644 $(EXEC).conf.5 $(DESTDIR)$(man5dir)
+ifneq ($(SCSI_DH_MODULES_PRELOAD),)
+	$(INSTALL_PROGRAM) -m 644 scsi_dh.conf $(DESTDIR)$(modulesloaddir)/scsi_dh.conf
+	for _x in $(SCSI_DH_MODULES_PRELOAD); do echo "$$_x"; done \
+	    >>$(DESTDIR)$(modulesloaddir)/scsi_dh.conf
+endif
 
 uninstall:
 	$(RM) $(DESTDIR)$(bindir)/$(EXEC)
 	$(RM) $(DESTDIR)$(udevrulesdir)/11-dm-mpath.rules
 	$(RM) $(DESTDIR)$(modulesloaddir)/multipath.conf
+	$(RM) $(DESTDIR)$(modulesloaddir)/scsi_dh.conf
 	$(RM) $(DESTDIR)$(libudevdir)/rules.d/56-multipath.rules
 	$(RM) $(DESTDIR)$(man8dir)/$(EXEC).8
 	$(RM) $(DESTDIR)$(man5dir)/$(EXEC).conf.5
Signature · 1 line
2.34.1

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel

#11 lore raw

Re: [dm-devel] [PATCH 5/6] multipath: Makefile: modules-load.d file for SCSI device handlers

Quoted 28 lines · Benjamin Marzinski
Quoted 27 lines · On Wed, Feb 02, 2022 at 12:40:23AM +0100, [email protected] wrote:

From: Martin Wilck <[email protected]>

The kernel's autoload mechanism for SCSI device handlers doesn't work during SCSI device probing. While it's possible to load and attach device handlers after probing, it has disadvantages: the handlers are useful for error handling even before multipathd has started, and at least up to kernel 5.17, the sysfs "access_state" attribute
will remain invisible for already probed devices.

Distributions will therefore want to make sure the handlers are either
built-in in the kernel, or loaded early. Add functionality to create and install a modules-load.d file with a list of handlers to load. By default, the list is empty, and no file will be generated.
The list can be specified at install-time like this:

   make SCSI_DH_MODULES_PRELOAD="scsi_dh_rdac scsi_dh_emc" install

dracut automatically adds modules-load.d files and the modules they reference to the initramfs.

Note: distributions that compile scsi_mod as a module may rather want
to use a modprobe.d file with a statement like this:

Quoted 8 lines
Quoted 2 lines

softdep scsi_mod post: scsi_dh_alua scsi_dh_rdac

I think you might need a default scsi_dh.conf file with a comment header
or something. install won't install a file that doesn't exist. Or am I
missing something here?

Yes, you would need a conf file. But we can't construct it in the upstream code. It depends on how the distro compiles the SCSI modules. softdeps don't work with built-in modules, and with current kmod, there can be only one softdep directive per module (no stacking) [1]; thus if the distro (or the admin) needs further softdeps for scsi_mod, the directives would need to be merged into one, which is tricky to automate.

The advantage of the softdep over modules-load.d is that it avoids loading the device handlers for systems without SCSI (like NVMe laptops, or embedded devices). The distro needs to decide whether or not that's worth it.

On the contrary, the modules-load.d file stacks nicely with other packages.

Regards,
Martin

[1] https://www.spinics.net/lists/linux-modules/msg01654.html

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel

#12 lore raw

Re: [dm-devel] [PATCH 5/6] multipath: Makefile: modules-load.d file for SCSI device handlers

Quoted 46 lines · Martin Wilck
Quoted 28 lines · Benjamin Marzinski
Quoted 27 lines · On Wed, Feb 02, 2022 at 12:40:23AM +0100, [email protected] wrote:

From: Martin Wilck <[email protected]>

The kernel's autoload mechanism for SCSI device handlers doesn't work during SCSI device probing. While it's possible to load and attach device handlers after probing, it has disadvantages: the handlers are useful for error handling even before multipathd has started, and at least up to kernel 5.17, the sysfs "access_state" attribute
will remain invisible for already probed devices.

Distributions will therefore want to make sure the handlers are either
built-in in the kernel, or loaded early. Add functionality to create and install a modules-load.d file with a list of handlers to load. By default, the list is empty, and no file will be generated.
The list can be specified at install-time like this:

   make SCSI_DH_MODULES_PRELOAD="scsi_dh_rdac scsi_dh_emc" install

dracut automatically adds modules-load.d files and the modules they reference to the initramfs.

Note: distributions that compile scsi_mod as a module may rather want
to use a modprobe.d file with a statement like this:

Quoted 8 lines
Quoted 2 lines

softdep scsi_mod post: scsi_dh_alua scsi_dh_rdac

I think you might need a default scsi_dh.conf file with a comment header
or something. install won't install a file that doesn't exist. Or am I
missing something here?

Yes, you would need a conf file. But we can't construct it in the upstream code. It depends on how the distro compiles the SCSI modules. softdeps don't work with built-in modules, and with current kmod, there can be only one softdep directive per module (no stacking) [1]; thus if the distro (or the admin) needs further softdeps for scsi_mod, the directives would need to be merged into one, which is tricky to automate.

Quoted 7 lines

The advantage of the softdep over modules-load.d is that it avoids loading the device handlers for systems without SCSI (like NVMe laptops, or embedded devices). The distro needs to decide whether or not that's worth it.

On the contrary, the modules-load.d file stacks nicely with other packages.

Right, but having a default scsi_dh.conf file that just has a comment header explaining what it is won't make anything get installed to modules-load.d by default. You already made that install command conditional. It just means that running

make SCSI_DH_MODULES_PRELOAD="scsi_dh_rdac scsi_dh_emc" install

will succeed, and give you a scsi_dh.conf in the modules-load.d directory that loads those modules, instead of failing because there is no scsi_dh.conf file to install. If you're against having a default scsi_dh.conf for install to work with, I suppose another option would be add the modules to scsi_dh.conf first, and then install it. Something like

ifneq ($(SCSI_DH_MODULES_PRELOAD),)

	> scsi_dh.conf
        for _x in $(SCSI_DH_MODULES_PRELOAD); do echo "$$_x"; done \
            >>scsi_dh.conf
        $(INSTALL_PROGRAM) -m 644 scsi_dh.conf $(DESTDIR)$(modulesloaddir)/scsi_dh.conf

endif

But you have to truncate or remove the local copy of scsi_dh.conf first, otherwise you would just keep adding the same modules on to the end. This would mean that distros can't make their own custom scsi_dh.conf. It would just be generated.

If none of this seems o.k. to you, at the very least you should change the commit message to metion that

make SCSI_DH_MODULES_PRELOAD="scsi_dh_rdac scsi_dh_emc" install

will only work if you've already created a file named scsi_dh.conf in the multipath directory.

-Ben

Quoted 5 lines

Regards,
Martin

[1] https://www.spinics.net/lists/linux-modules/msg01654.html

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel

#13 lore raw

Re: [dm-devel] [PATCH 5/6] multipath: Makefile: modules-load.d file for SCSI device handlers

Quoted 9 lines · Benjamin Marzinski

If none of this seems o.k. to you, at the very least you should change
the commit message to metion that

make SCSI_DH_MODULES_PRELOAD="scsi_dh_rdac scsi_dh_emc" install

will only work if you've already created a file named scsi_dh.conf in the multipath directory.

Ups, I totally misunderstood you, I am sorry. I had an untracked scsi_dh.conf file in my tree which masked this error. I'll resubmit.

Martin

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel

#14 lore raw

PATCH 6/6 README.md: add basic information about building multipath-tools

In reply to [email protected]

From: Martin Wilck <[email protected]>

---
 README.md | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
README.md +56 -0
index b15c265..1547862 100644
@@ -52,6 +52,62 @@ To get latest devel code:
 Github page: https://github.com/opensvc/multipath-tools
 
 
+Building multipath-tools
+========================
+
+Prerequisites: development packages of for `libdevmapper`, `libreadline`,
+`libaio`, `libudev`, `libjson-c`, `liburcu`, and `libsystemd`.
+
+To build multipath-tools, type:
+
+    make
+	make DESTDIR="/my/target/dir" install
+
+To uninstall, type:
+
+    make uninstall
+
+Customizing the build
+---------------------
+
+The following variables can be passed to the `make` command line:
+
+ * `ENABLE_LIBDMMP=0`: disable building libdmmp
+ * `ENABLE_DMEVENTS_POLL=0`: disable support for the device-mapper event
+   polling API. For use with pre-5.0 kernels that don't supprt dmevent polling
+   (but even if you don't use this option, multipath-tools will work with
+   these kernels).
+ * `SCSI_DH_MODULES_PRELOAD="(list)"`: specify a space-separated list of SCSI
+   device handler kernel modules to load early during boot. Some
+   multipath-tools functionality depends on these modules being loaded
+   early. This option causes a *modules-load.d(5)* configuration file to be
+   created, thus it depends on functionality provided by *systemd*.
+   This variable only matters for `make install`.
+
+Note: The usefulness of the preload list depends on the kernel configuration.
+It's especially useful if `scsi_mod` is builtin but `scsi_dh_alua` and
+other device handler modules are built as modules. If `scsi_mod` itself is compiled
+as a module, it might make more sense to use a module softdep for the same
+purpose.
+
+See `Makefile.inc` for additional variables to customize paths and compiler
+flags.
+
+Special Makefile targets
+------------------------
+
+The following targets are intended for developers only.
+
+ * `make test` to build and run the unit tests
+ * `make valgrind-test` to run the unit tests under valgrind
+ * `make abi` to create an XML representation of the ABI of the libraries in
+   the `abi/` subdirectory
+ * `make abi-test` to compare the ABI of a different multipath-tools version,
+   which must be stored in the `reference-abi/` subdirectory. If this test
+   fails, the ABI has changed wrt the reference.
+ * `make compile-commands.json` to create input for [clangd](https://clangd.llvm.org/).
+
+
 Add storage devices
 ===================
 
Signature · 7 lines
2.34.1


--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel
maintainer Reviewed-by on v1 6/6
#15 lore raw

Re: [dm-devel] [PATCH 6/6] README.md: add basic information about building multipath-tools

Quoted 3 lines · On Wed, Feb 02, 2022 at 12:40:24AM +0100, [email protected] wrote:

From: Martin Wilck <[email protected]>

Quoted 73 lines
---
 README.md | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)
README.md +56 -0
index b15c265..1547862 100644
@@ -52,6 +52,62 @@ To get latest devel code:
 Github page: https://github.com/opensvc/multipath-tools
 
 
+Building multipath-tools
+========================
+
+Prerequisites: development packages of for `libdevmapper`, `libreadline`,
+`libaio`, `libudev`, `libjson-c`, `liburcu`, and `libsystemd`.
+
+To build multipath-tools, type:
+
+    make
+	make DESTDIR="/my/target/dir" install
+
+To uninstall, type:
+
+    make uninstall
+
+Customizing the build
+---------------------
+
+The following variables can be passed to the `make` command line:
+
+ * `ENABLE_LIBDMMP=0`: disable building libdmmp
+ * `ENABLE_DMEVENTS_POLL=0`: disable support for the device-mapper event
+   polling API. For use with pre-5.0 kernels that don't supprt dmevent polling
+   (but even if you don't use this option, multipath-tools will work with
+   these kernels).
+ * `SCSI_DH_MODULES_PRELOAD="(list)"`: specify a space-separated list of SCSI
+   device handler kernel modules to load early during boot. Some
+   multipath-tools functionality depends on these modules being loaded
+   early. This option causes a *modules-load.d(5)* configuration file to be
+   created, thus it depends on functionality provided by *systemd*.
+   This variable only matters for `make install`.
+
+Note: The usefulness of the preload list depends on the kernel configuration.
+It's especially useful if `scsi_mod` is builtin but `scsi_dh_alua` and
+other device handler modules are built as modules. If `scsi_mod` itself is compiled
+as a module, it might make more sense to use a module softdep for the same
+purpose.
+
+See `Makefile.inc` for additional variables to customize paths and compiler
+flags.
+
+Special Makefile targets
+------------------------
+
+The following targets are intended for developers only.
+
+ * `make test` to build and run the unit tests
+ * `make valgrind-test` to run the unit tests under valgrind
+ * `make abi` to create an XML representation of the ABI of the libraries in
+   the `abi/` subdirectory
+ * `make abi-test` to compare the ABI of a different multipath-tools version,
+   which must be stored in the `reference-abi/` subdirectory. If this test
+   fails, the ABI has changed wrt the reference.
+ * `make compile-commands.json` to create input for [clangd](https://clangd.llvm.org/).
+
+
 Add storage devices
 ===================
 
Signature · 1 line
2.34.1

--
dm-devel mailing list
[email protected]
https://listman.redhat.com/mailman/listinfo/dm-devel