Message ID | 20231026174153.1133-9-mwilck@suse.com (mailing list archive) |
---|---|
State | Not Applicable, archived |
Delegated to: | christophe varoqui |
Headers | show |
Series | multipath: aio, systemd, and documentation improvements | expand |
On Thu, Oct 26, 2023 at 07:41:47PM +0200, mwilck@suse.com wrote: > From: Martin Wilck <mwilck@suse.com> > > systemd v245 and newer provides the modprobe@.service unit, which > can be used to pull in modules via systemd. This is cleaner than > loading dm-multipath unconditionally via modules-load.d. Use it > if the detected systemd version support it. > > Signed-off-by: Martin Wilck <mwilck@suse.com> Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com> > --- > Makefile.inc | 4 +++- > multipath/Makefile | 6 ++++-- > multipathd/Makefile | 4 ++-- > multipathd/{multipathd.service => multipathd.service.in} | 4 ++-- > 4 files changed, 11 insertions(+), 7 deletions(-) > rename multipathd/{multipathd.service => multipathd.service.in} (85%) > > diff --git a/Makefile.inc b/Makefile.inc > index 04bfa56..8655cba 100644 > --- a/Makefile.inc > +++ b/Makefile.inc > @@ -90,6 +90,8 @@ ORIG_LDFLAGS := $(LDFLAGS) > > SYSTEMD_CPPFLAGS := $(if $(SYSTEMD),-DUSE_SYSTEMD=$(SYSTEMD)) > SYSTEMD_LIBDEPS := $(if $(SYSTEMD),$(if $(shell test $(SYSTEMD) -gt 209 && echo 1),-lsystemd,-lsystemd-daemon)) > +MODPROBE_UNIT := $(shell test "0$(SYSTEMD)" -lt 245 2>/dev/null || \ > + echo "modprobe@dm_multipath.service") > > OPTFLAGS := -O2 -g $(STACKPROT) --param=ssp-buffer-size=4 > WARNFLAGS := -Werror -Wall -Wextra -Wformat=2 $(WFORMATOVERFLOW) -Werror=implicit-int \ > @@ -144,4 +146,4 @@ NV_VERSION_SCRIPT = $(DEVLIB:%.so=%-nv.version) > > %: %.in > @echo creating $@ > - $(Q)sed 's:@CONFIGFILE@:'$(configfile)':g;s:@CONFIGDIR@:'$(configdir)':g;s:@STATE_DIR@:'$(statedir)':g;s:@RUNTIME_DIR@:'$(runtimedir)':g' $< >$@ > + $(Q)sed 's:@CONFIGFILE@:'$(configfile)':g;s:@CONFIGDIR@:'$(configdir)':g;s:@STATE_DIR@:'$(statedir)':g;s:@RUNTIME_DIR@:'$(runtimedir)':g;s/@MODPROBE_UNIT@/'$(MODPROBE_UNIT)'/g' $< >$@ > diff --git a/multipath/Makefile b/multipath/Makefile > index 68cb5ce..0efb9b2 100644 > --- a/multipath/Makefile > +++ b/multipath/Makefile > @@ -27,14 +27,16 @@ install: > $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(udevrulesdir) > $(Q)$(INSTALL_PROGRAM) -m 644 11-dm-mpath.rules $(DESTDIR)$(udevrulesdir) > $(Q)$(INSTALL_PROGRAM) -m 644 multipath.rules $(DESTDIR)$(udevrulesdir)/56-multipath.rules > - $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(modulesloaddir) > - $(Q)$(INSTALL_PROGRAM) -m 644 modules-load.conf $(DESTDIR)$(modulesloaddir)/multipath.conf > $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(tmpfilesdir) > $(Q)$(INSTALL_PROGRAM) -m 644 tmpfiles.conf $(DESTDIR)$(tmpfilesdir)/multipath.conf > $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(mandir)/man8 > $(Q)$(INSTALL_PROGRAM) -m 644 $(EXEC).8 $(DESTDIR)$(mandir)/man8 > $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(mandir)/man5 > $(Q)$(INSTALL_PROGRAM) -m 644 $(EXEC).conf.5 $(DESTDIR)$(mandir)/man5 > + $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(modulesloaddir) > +ifeq ($(MODPROBE_UNIT),) > + $(Q)$(INSTALL_PROGRAM) -m 644 modules-load.conf $(DESTDIR)$(modulesloaddir)/multipath.conf > +endif > ifneq ($(SCSI_DH_MODULES_PRELOAD),) > $(Q)$(INSTALL_PROGRAM) -m 644 scsi_dh.conf $(DESTDIR)$(modulesloaddir)/scsi_dh.conf > $(Q)for _x in $(SCSI_DH_MODULES_PRELOAD); do echo "$$_x"; done \ > diff --git a/multipathd/Makefile b/multipathd/Makefile > index 0ba6ecb..997b40c 100644 > --- a/multipathd/Makefile > +++ b/multipathd/Makefile > @@ -41,7 +41,7 @@ ifeq ($(FPIN_SUPPORT),1) > OBJS += fpin_handlers.o > endif > > -all : $(EXEC) $(CLI) $(MANPAGES) > +all : $(EXEC) $(CLI) $(MANPAGES) $(EXEC).service > > $(EXEC): $(OBJS) $(multipathdir)/libmultipath.so $(mpathcmddir)/libmpathcmd.so > @echo building $@ because of $? > @@ -78,7 +78,7 @@ uninstall: > $(Q)$(RM) $(DESTDIR)$(unitdir)/$(EXEC).socket > > clean: dep_clean > - $(Q)$(RM) core *.o $(EXEC) $(CLI) $(MANPAGES) > + $(Q)$(RM) core *.o $(EXEC) $(CLI) $(MANPAGES) $(EXEC).service > > include $(wildcard $(OBJS:.o=.d) $(CLI_OBJS:.o=.d)) > > diff --git a/multipathd/multipathd.service b/multipathd/multipathd.service.in > similarity index 85% > rename from multipathd/multipathd.service > rename to multipathd/multipathd.service.in > index 5a9cde1..6d03ff7 100644 > --- a/multipathd/multipathd.service > +++ b/multipathd/multipathd.service.in > @@ -2,8 +2,8 @@ > Description=Device-Mapper Multipath Device Controller > Before=lvm2-activation-early.service > Before=local-fs-pre.target blk-availability.service shutdown.target > -Wants=systemd-udevd-kernel.socket > -After=systemd-udevd-kernel.socket > +Wants=systemd-udevd-kernel.socket @MODPROBE_UNIT@ > +After=systemd-udevd-kernel.socket @MODPROBE_UNIT@ > After=multipathd.socket systemd-remount-fs.service > Before=initrd-cleanup.service > DefaultDependencies=no > -- > 2.42.0
On Thu, Oct 26, 2023 at 07:41:47PM +0200, mwilck@suse.com wrote: > From: Martin Wilck <mwilck@suse.com> > > systemd v245 and newer provides the modprobe@.service unit, which > can be used to pull in modules via systemd. This is cleaner than > loading dm-multipath unconditionally via modules-load.d. Use it > if the detected systemd version support it. > > Signed-off-by: Martin Wilck <mwilck@suse.com> I just realized that this should also add multipathd.service to .gitignore -Ben > --- > Makefile.inc | 4 +++- > multipath/Makefile | 6 ++++-- > multipathd/Makefile | 4 ++-- > multipathd/{multipathd.service => multipathd.service.in} | 4 ++-- > 4 files changed, 11 insertions(+), 7 deletions(-) > rename multipathd/{multipathd.service => multipathd.service.in} (85%) > > diff --git a/Makefile.inc b/Makefile.inc > index 04bfa56..8655cba 100644 > --- a/Makefile.inc > +++ b/Makefile.inc > @@ -90,6 +90,8 @@ ORIG_LDFLAGS := $(LDFLAGS) > > SYSTEMD_CPPFLAGS := $(if $(SYSTEMD),-DUSE_SYSTEMD=$(SYSTEMD)) > SYSTEMD_LIBDEPS := $(if $(SYSTEMD),$(if $(shell test $(SYSTEMD) -gt 209 && echo 1),-lsystemd,-lsystemd-daemon)) > +MODPROBE_UNIT := $(shell test "0$(SYSTEMD)" -lt 245 2>/dev/null || \ > + echo "modprobe@dm_multipath.service") > > OPTFLAGS := -O2 -g $(STACKPROT) --param=ssp-buffer-size=4 > WARNFLAGS := -Werror -Wall -Wextra -Wformat=2 $(WFORMATOVERFLOW) -Werror=implicit-int \ > @@ -144,4 +146,4 @@ NV_VERSION_SCRIPT = $(DEVLIB:%.so=%-nv.version) > > %: %.in > @echo creating $@ > - $(Q)sed 's:@CONFIGFILE@:'$(configfile)':g;s:@CONFIGDIR@:'$(configdir)':g;s:@STATE_DIR@:'$(statedir)':g;s:@RUNTIME_DIR@:'$(runtimedir)':g' $< >$@ > + $(Q)sed 's:@CONFIGFILE@:'$(configfile)':g;s:@CONFIGDIR@:'$(configdir)':g;s:@STATE_DIR@:'$(statedir)':g;s:@RUNTIME_DIR@:'$(runtimedir)':g;s/@MODPROBE_UNIT@/'$(MODPROBE_UNIT)'/g' $< >$@ > diff --git a/multipath/Makefile b/multipath/Makefile > index 68cb5ce..0efb9b2 100644 > --- a/multipath/Makefile > +++ b/multipath/Makefile > @@ -27,14 +27,16 @@ install: > $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(udevrulesdir) > $(Q)$(INSTALL_PROGRAM) -m 644 11-dm-mpath.rules $(DESTDIR)$(udevrulesdir) > $(Q)$(INSTALL_PROGRAM) -m 644 multipath.rules $(DESTDIR)$(udevrulesdir)/56-multipath.rules > - $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(modulesloaddir) > - $(Q)$(INSTALL_PROGRAM) -m 644 modules-load.conf $(DESTDIR)$(modulesloaddir)/multipath.conf > $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(tmpfilesdir) > $(Q)$(INSTALL_PROGRAM) -m 644 tmpfiles.conf $(DESTDIR)$(tmpfilesdir)/multipath.conf > $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(mandir)/man8 > $(Q)$(INSTALL_PROGRAM) -m 644 $(EXEC).8 $(DESTDIR)$(mandir)/man8 > $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(mandir)/man5 > $(Q)$(INSTALL_PROGRAM) -m 644 $(EXEC).conf.5 $(DESTDIR)$(mandir)/man5 > + $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(modulesloaddir) > +ifeq ($(MODPROBE_UNIT),) > + $(Q)$(INSTALL_PROGRAM) -m 644 modules-load.conf $(DESTDIR)$(modulesloaddir)/multipath.conf > +endif > ifneq ($(SCSI_DH_MODULES_PRELOAD),) > $(Q)$(INSTALL_PROGRAM) -m 644 scsi_dh.conf $(DESTDIR)$(modulesloaddir)/scsi_dh.conf > $(Q)for _x in $(SCSI_DH_MODULES_PRELOAD); do echo "$$_x"; done \ > diff --git a/multipathd/Makefile b/multipathd/Makefile > index 0ba6ecb..997b40c 100644 > --- a/multipathd/Makefile > +++ b/multipathd/Makefile > @@ -41,7 +41,7 @@ ifeq ($(FPIN_SUPPORT),1) > OBJS += fpin_handlers.o > endif > > -all : $(EXEC) $(CLI) $(MANPAGES) > +all : $(EXEC) $(CLI) $(MANPAGES) $(EXEC).service > > $(EXEC): $(OBJS) $(multipathdir)/libmultipath.so $(mpathcmddir)/libmpathcmd.so > @echo building $@ because of $? > @@ -78,7 +78,7 @@ uninstall: > $(Q)$(RM) $(DESTDIR)$(unitdir)/$(EXEC).socket > > clean: dep_clean > - $(Q)$(RM) core *.o $(EXEC) $(CLI) $(MANPAGES) > + $(Q)$(RM) core *.o $(EXEC) $(CLI) $(MANPAGES) $(EXEC).service > > include $(wildcard $(OBJS:.o=.d) $(CLI_OBJS:.o=.d)) > > diff --git a/multipathd/multipathd.service b/multipathd/multipathd.service.in > similarity index 85% > rename from multipathd/multipathd.service > rename to multipathd/multipathd.service.in > index 5a9cde1..6d03ff7 100644 > --- a/multipathd/multipathd.service > +++ b/multipathd/multipathd.service.in > @@ -2,8 +2,8 @@ > Description=Device-Mapper Multipath Device Controller > Before=lvm2-activation-early.service > Before=local-fs-pre.target blk-availability.service shutdown.target > -Wants=systemd-udevd-kernel.socket > -After=systemd-udevd-kernel.socket > +Wants=systemd-udevd-kernel.socket @MODPROBE_UNIT@ > +After=systemd-udevd-kernel.socket @MODPROBE_UNIT@ > After=multipathd.socket systemd-remount-fs.service > Before=initrd-cleanup.service > DefaultDependencies=no > -- > 2.42.0
On Fri, 2023-10-27 at 16:05 -0400, Benjamin Marzinski wrote: > On Thu, Oct 26, 2023 at 07:41:47PM +0200, mwilck@suse.com wrote: > > From: Martin Wilck <mwilck@suse.com> > > > > systemd v245 and newer provides the modprobe@.service unit, which > > can be used to pull in modules via systemd. This is cleaner than > > loading dm-multipath unconditionally via modules-load.d. Use it > > if the detected systemd version support it. > > > > Signed-off-by: Martin Wilck <mwilck@suse.com> > > I just realized that this should also add multipathd.service to > .gitignore I'll fix this up and keep your Reviewed-by. Martin
diff --git a/Makefile.inc b/Makefile.inc index 04bfa56..8655cba 100644 --- a/Makefile.inc +++ b/Makefile.inc @@ -90,6 +90,8 @@ ORIG_LDFLAGS := $(LDFLAGS) SYSTEMD_CPPFLAGS := $(if $(SYSTEMD),-DUSE_SYSTEMD=$(SYSTEMD)) SYSTEMD_LIBDEPS := $(if $(SYSTEMD),$(if $(shell test $(SYSTEMD) -gt 209 && echo 1),-lsystemd,-lsystemd-daemon)) +MODPROBE_UNIT := $(shell test "0$(SYSTEMD)" -lt 245 2>/dev/null || \ + echo "modprobe@dm_multipath.service") OPTFLAGS := -O2 -g $(STACKPROT) --param=ssp-buffer-size=4 WARNFLAGS := -Werror -Wall -Wextra -Wformat=2 $(WFORMATOVERFLOW) -Werror=implicit-int \ @@ -144,4 +146,4 @@ NV_VERSION_SCRIPT = $(DEVLIB:%.so=%-nv.version) %: %.in @echo creating $@ - $(Q)sed 's:@CONFIGFILE@:'$(configfile)':g;s:@CONFIGDIR@:'$(configdir)':g;s:@STATE_DIR@:'$(statedir)':g;s:@RUNTIME_DIR@:'$(runtimedir)':g' $< >$@ + $(Q)sed 's:@CONFIGFILE@:'$(configfile)':g;s:@CONFIGDIR@:'$(configdir)':g;s:@STATE_DIR@:'$(statedir)':g;s:@RUNTIME_DIR@:'$(runtimedir)':g;s/@MODPROBE_UNIT@/'$(MODPROBE_UNIT)'/g' $< >$@ diff --git a/multipath/Makefile b/multipath/Makefile index 68cb5ce..0efb9b2 100644 --- a/multipath/Makefile +++ b/multipath/Makefile @@ -27,14 +27,16 @@ install: $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(udevrulesdir) $(Q)$(INSTALL_PROGRAM) -m 644 11-dm-mpath.rules $(DESTDIR)$(udevrulesdir) $(Q)$(INSTALL_PROGRAM) -m 644 multipath.rules $(DESTDIR)$(udevrulesdir)/56-multipath.rules - $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(modulesloaddir) - $(Q)$(INSTALL_PROGRAM) -m 644 modules-load.conf $(DESTDIR)$(modulesloaddir)/multipath.conf $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(tmpfilesdir) $(Q)$(INSTALL_PROGRAM) -m 644 tmpfiles.conf $(DESTDIR)$(tmpfilesdir)/multipath.conf $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(mandir)/man8 $(Q)$(INSTALL_PROGRAM) -m 644 $(EXEC).8 $(DESTDIR)$(mandir)/man8 $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(mandir)/man5 $(Q)$(INSTALL_PROGRAM) -m 644 $(EXEC).conf.5 $(DESTDIR)$(mandir)/man5 + $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(modulesloaddir) +ifeq ($(MODPROBE_UNIT),) + $(Q)$(INSTALL_PROGRAM) -m 644 modules-load.conf $(DESTDIR)$(modulesloaddir)/multipath.conf +endif ifneq ($(SCSI_DH_MODULES_PRELOAD),) $(Q)$(INSTALL_PROGRAM) -m 644 scsi_dh.conf $(DESTDIR)$(modulesloaddir)/scsi_dh.conf $(Q)for _x in $(SCSI_DH_MODULES_PRELOAD); do echo "$$_x"; done \ diff --git a/multipathd/Makefile b/multipathd/Makefile index 0ba6ecb..997b40c 100644 --- a/multipathd/Makefile +++ b/multipathd/Makefile @@ -41,7 +41,7 @@ ifeq ($(FPIN_SUPPORT),1) OBJS += fpin_handlers.o endif -all : $(EXEC) $(CLI) $(MANPAGES) +all : $(EXEC) $(CLI) $(MANPAGES) $(EXEC).service $(EXEC): $(OBJS) $(multipathdir)/libmultipath.so $(mpathcmddir)/libmpathcmd.so @echo building $@ because of $? @@ -78,7 +78,7 @@ uninstall: $(Q)$(RM) $(DESTDIR)$(unitdir)/$(EXEC).socket clean: dep_clean - $(Q)$(RM) core *.o $(EXEC) $(CLI) $(MANPAGES) + $(Q)$(RM) core *.o $(EXEC) $(CLI) $(MANPAGES) $(EXEC).service include $(wildcard $(OBJS:.o=.d) $(CLI_OBJS:.o=.d)) diff --git a/multipathd/multipathd.service b/multipathd/multipathd.service.in similarity index 85% rename from multipathd/multipathd.service rename to multipathd/multipathd.service.in index 5a9cde1..6d03ff7 100644 --- a/multipathd/multipathd.service +++ b/multipathd/multipathd.service.in @@ -2,8 +2,8 @@ Description=Device-Mapper Multipath Device Controller Before=lvm2-activation-early.service Before=local-fs-pre.target blk-availability.service shutdown.target -Wants=systemd-udevd-kernel.socket -After=systemd-udevd-kernel.socket +Wants=systemd-udevd-kernel.socket @MODPROBE_UNIT@ +After=systemd-udevd-kernel.socket @MODPROBE_UNIT@ After=multipathd.socket systemd-remount-fs.service Before=initrd-cleanup.service DefaultDependencies=no