multipathd: fix hang during shutdown with queuing maps
PATCH 1/1 multipathd: fix hang during shutdown with queuing maps
Since c9689b6 ("multipathd: Remove dependency on systemd-udev-settle.service"), multipathd.service starts very early during boot, which in systemd's service ordering logic means that it is stopped late. While this is generally a good thing, it means that, when systemd unmounts file systems and tears down the block device stack, multipathd is still running. Therefore our "queue_without_daemon" logic, which disables queuing when multipathd exits, isn't effective yet. If there are any multipath maps that are in queueing state at this point in time, the system may hang indefinitely.
To fix that, add a new service which starts later (and thus stops earlier) and disables queueing on all multipath maps during shutdown. Similar to lvm2's blk-availability.service, the service does nothing when started.
--- multipathd/Makefile | 6 ++++-- multipathd/multipathd-queueing.service.in | 9 +++++++++ multipathd/multipathd.service.in | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 multipathd/multipathd-queueing.service.in
multipathd/Makefile +4 -2
@@ -41,7 +41,7 @@ ifeq ($(FPIN_SUPPORT),1) OBJS += fpin_handlers.o endif -all : $(EXEC) $(CLI) $(MANPAGES) $(EXEC).service $(EXEC).socket +all : $(EXEC) $(CLI) $(MANPAGES) $(EXEC).service $(EXEC).socket $(EXEC)-queueing.service $(EXEC): $(OBJS) $(multipathdir)/libmultipath.so $(mpathcmddir)/libmpathcmd.so @echo building $@ because of $?
@@ -64,6 +64,7 @@ install: ifdef SYSTEMD $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(unitdir) $(Q)$(INSTALL_PROGRAM) -m 644 $(EXEC).service $(DESTDIR)$(unitdir) + $(Q)$(INSTALL_PROGRAM) -m 644 $(EXEC)-queueing.service $(DESTDIR)$(unitdir) $(Q)$(INSTALL_PROGRAM) -m 644 $(EXEC).socket $(DESTDIR)$(unitdir) endif $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(mandir)/man8
@@ -74,11 +75,12 @@ uninstall: $(Q)$(RM) $(DESTDIR)$(bindir)/$(EXEC) $(DESTDIR)$(bindir)/$(CLI) $(Q)$(RM) $(DESTDIR)$(mandir)/man8/$(EXEC).8 $(Q)$(RM) $(DESTDIR)$(mandir)/man8/$(CLI).8 + $(Q)$(RM) $(DESTDIR)$(unitdir)/$(EXEC)-queueing.service $(Q)$(RM) $(DESTDIR)$(unitdir)/$(EXEC).service $(Q)$(RM) $(DESTDIR)$(unitdir)/$(EXEC).socket clean: dep_clean - $(Q)$(RM) core *.o $(EXEC) $(CLI) $(MANPAGES) $(EXEC).service $(EXEC).socket + $(Q)$(RM) core *.o $(EXEC) $(CLI) $(MANPAGES) $(EXEC).service $(EXEC)-queueing.service $(EXEC).socket include $(wildcard $(OBJS:.o=.d) $(CLI_OBJS:.o=.d))
multipathd/multipathd-queueing.service.in new file +9 -0
@@ -0,0 +1,9 @@ +[Unit] +Description=Enable queuing for multipath maps +After=local-fs.target remote-fs.target multipathd.service + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/bin/true +ExecStop=@BINDIR@/multipathd disablequeueing maps
multipathd/multipathd.service.in +1 -1
@@ -2,7 +2,7 @@ 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 @MODPROBE_UNIT@ +Wants=systemd-udevd-kernel.socket multipathd-queueing.service @MODPROBE_UNIT@ After=systemd-udevd-kernel.socket @MODPROBE_UNIT@ After=multipathd.socket systemd-remount-fs.service Before=initrd-cleanup.service
Signature · 1 line
2.48.1
Quoted 10 lines · Martin Wilck
Since c9689b6 ("multipathd: Remove dependency on systemd-udev-settle.service"), multipathd.service starts very early during boot, which in systemd's service ordering logic means that it is stopped late. While this is generally a good thing, it means that, when systemd unmounts file systems and tears down the block device stack, multipathd is still running. Therefore our "
queue_without_daemon" logic, which disables queuing when multipathd exits, isn't effective yet. If there are any multipath maps that are in queueing state at this point in time, the system may hang indefinitely.
Quoted 5 lines
To fix that, add a new service which starts later (and thus stops earlier) and disables queueing on all multipath maps during shutdown. Similar to lvm2's blk-availability.service, the service does nothing when started.
Fixes c9689b6 ("multipathd: Remove dependency on systemd-udev-settle.service")
Quoted 74 lines
Signed-off-by Martin Wilck <[email protected]>--- multipathd/Makefile | 6 ++++-- multipathd/multipathd-queueing.service.in | 9 +++++++++ multipathd/multipathd.service.in | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 multipathd/multipathd-queueing.service.inmultipathd/Makefile +4
-2@@ -41,7 +41,7 @@ ifeq ($(FPIN_SUPPORT),1) OBJS += fpin_handlers.o endif -all : $(EXEC) $(CLI) $(MANPAGES) $(EXEC).service $(EXEC).socket +all : $(EXEC) $(CLI) $(MANPAGES) $(EXEC).service $(EXEC).socket $(EXEC)-queueing.service $(EXEC): $(OBJS) $(multipathdir)/libmultipath.so $(mpathcmddir)/libmpathcmd.so @echo building $@ because of $?@@ -64,6 +64,7 @@ install: ifdef SYSTEMD $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(unitdir) $(Q)$(INSTALL_PROGRAM) -m 644 $(EXEC).service $(DESTDIR)$(unitdir) + $(Q)$(INSTALL_PROGRAM) -m 644 $(EXEC)-queueing.service $(DESTDIR)$(unitdir) $(Q)$(INSTALL_PROGRAM) -m 644 $(EXEC).socket $(DESTDIR)$(unitdir) endif $(Q)$(INSTALL_PROGRAM) -d $(DESTDIR)$(mandir)/man8@@ -74,11 +75,12 @@ uninstall: $(Q)$(RM) $(DESTDIR)$(bindir)/$(EXEC) $(DESTDIR)$(bindir)/$(CLI) $(Q)$(RM) $(DESTDIR)$(mandir)/man8/$(EXEC).8 $(Q)$(RM) $(DESTDIR)$(mandir)/man8/$(CLI).8 + $(Q)$(RM) $(DESTDIR)$(unitdir)/$(EXEC)-queueing.service $(Q)$(RM) $(DESTDIR)$(unitdir)/$(EXEC).service $(Q)$(RM) $(DESTDIR)$(unitdir)/$(EXEC).socket clean: dep_clean - $(Q)$(RM) core *.o $(EXEC) $(CLI) $(MANPAGES) $(EXEC).service $(EXEC).socket + $(Q)$(RM) core *.o $(EXEC) $(CLI) $(MANPAGES) $(EXEC).service $(EXEC)-queueing.service $(EXEC).socket include $(wildcard $(OBJS:.o=.d) $(CLI_OBJS:.o=.d))multipathd/multipathd-queueing.service.in new file +9
-0@@ -0,0 +1,9 @@ +[Unit] +Description=Enable queuing for multipath maps +After=local-fs.target remote-fs.target multipathd.service + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/bin/true +ExecStop=@BINDIR@/multipathd disablequeueing mapsmultipathd/multipathd.service.in +1
-1@@ -2,7 +2,7 @@ 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 @MODPROBE_UNIT@ +Wants=systemd-udevd-kernel.socket multipathd-queueing.service @MODPROBE_UNIT@ After=systemd-udevd-kernel.socket @MODPROBE_UNIT@ After=multipathd.socket systemd-remount-fs.service Before=initrd-cleanup.serviceSignature · 1 line
2.48.1
Quoted 24 lines · Benjamin Marzinski
Quoted 23 lines · Martin Wilck
Since c9689b6 ("multipathd: Remove dependency on systemd-udev-settle.service"), multipathd.service starts very early during
boot, which in systemd's service ordering logic means that it is stopped
late. While this is generally a good thing, it means that, when systemd
unmounts file systems and tears down the block device stack, multipathd
is still running. Therefore our "queue_without_daemon" logic, which disables
queuing when multipathd exits, isn't effective yet. If there are any
multipath maps that are in queueing state at this point in time, the system
may hang indefinitely.To fix that, add a new service which starts later (and thus stops earlier) and
disables queueing on all multipath maps during shutdown. Similar to lvm2's
blk-availability.service, the service does nothing when started.
Quoted 4 lines
Quoted 2 lines
Fixes c9689b6 ("multipathd: Remove dependency on systemd-udev-settle.service")
Reviewed-by Benjamin Marzinski <[email protected]>
Thanks - do you reckon this is suitable for the stable tree? There is not much of a regression risk, but it requires shipping another file, so it's non-trivial for packagers.
Personally I'm inclined to add it to stable (also because I'll need to backport it anyway).
Martin
Benjamin Marzinski
maintainerQuoted 28 lines · Martin Wilck
Quoted 27 lines · Benjamin Marzinski
Quoted 25 lines · Martin Wilck
Since c9689b6 ("multipathd: Remove dependency on systemd-udev-settle.service"), multipathd.service starts very early during
boot, which in systemd's service ordering logic means that it is stopped
late. While this is generally a good thing, it means that, when systemd
unmounts file systems and tears down the block device stack, multipathd
is still running. Therefore our "queue_without_daemon" logic, which disables
queuing when multipathd exits, isn't effective yet. If there are any
multipath maps that are in queueing state at this point in time, the system
may hang indefinitely.To fix that, add a new service which starts later (and thus stops earlier) and
disables queueing on all multipath maps during shutdown. Similar to lvm2's
blk-availability.service, the service does nothing when started.Fixes c9689b6 ("multipathd: Remove dependency on systemd-udev-settle.service")
Quoted 8 lines
Quoted 1 line
Reviewed-by Benjamin Marzinski <[email protected]>Thanks - do you reckon this is suitable for the stable tree? There is not much of a regression risk, but it requires shipping another file, so it's non-trivial for packagers.
Personally I'm inclined to add it to stable (also because I'll need to backport it anyway).
I on the fence about this one. It does fix a bug, but adding a new service is kinda feature-y. But your right that there's not much risk of it breaking things, so it doesn't really matter much to me either way.
-Ben
Quoted 2 lines
Martin