Bug#791944: /etc/init.d/sendsigs kills systemd-udevd upon shutdown, causing dmsetup to hang

Pali Rohár pali.rohar at gmail.com
Wed Jun 7 08:58:55 BST 2017


On Tuesday 06 June 2017 11:56:45 Felipe Sateler wrote:
> On Mon, Jun 5, 2017 at 2:32 PM, Pali Rohár <pali.rohar at gmail.com> wrote:
> > On Monday 05 June 2017 20:23:52 Michael Biebl wrote:
> >> Am 05.06.2017 um 13:12 schrieb Pali Rohár:
> >> >> Am 05.06.2017 um 09:59 schrieb Pali Rohár:
> >> >>> /etc/rc0.d/K08cryptdisks
> >> >>> /etc/rc0.d/K09cryptdisks-early
> >> >>> /etc/rc0.d/K10udev
> >> >
> >> > Problem is that in K08 and K09 phase is udev not running, but
> >> > socket is present. udev is probably killed by
> >> > /etc/rc0.d/K03sendsigs which is before K08 and K09. Above patch
> >> > modify K10 which is *after* K08 and K09, therefore it has
> >> > absolutely no effect on fixing this issue.
> >>
> >> Ah, ok. The info about sendsigs being ordered before udev on shutdown
> >> was missing.
> >
> > Anyway, if you are patching K10udev and whole freeze happens in
> > K08cryptdisks and K09cryptdisks-early, then such patch is noop as whole
> > freeze happens before patch line is executed. sendsigs does not change
> > behaviour of patch.
> >
> >> I guess we need both then:
> >> - udev using the sendsigs.omit.d interface to avoid being killed by
> >> /etc/init.d/sendsigs
> >> and
> >> - removing the socket on stop and making sure udev is stopped in 0 /
> >> 6.
> >>
> >> Anyone willing to work on a patch?
> >
> > I think the first thing which needs to be done is to define order
> > sendsigs, cryptdisks and udev. Should be udev really stopped after
> > cryptdisks? Or not? If not, then udev should be stopped *before*
> > sendsigs. Otherwise sendsigs needs to be patched to not kill udev.
> 
> 
> If the udev pid is added to sendsigs.omit.d as noted by Michael then
> sendsigs should stop killing udev. So no need to patch sendsigs.

Yes, this seems to work.

> >
> > But other question is what happens in system when udev is still running
> > even after unmounting filesystem and when basically all other remaining
> > services were already killed by sendsigs...
> 
> Udev would still be stopped, just later. I note that under systemd
> udev is not stopped until the final killing spree, so hopefully this
> delay in stopping will not introduce problems.

See attached patch for /etc/init.d/udev. I tested it and it fixed
problem this problem with freezing computer at reboot.

I need to use --background --make-pidfile because udev itself cannot
create pidfile.

-- 
Pali Rohár
pali.rohar at gmail.com
-------------- next part --------------
--- /etc/init.d/udev	2017-01-23 14:52:46.000000000 +0100
+++ /etc/init.d/udev	2017-06-07 09:49:20.699394566 +0200
@@ -4,7 +4,7 @@
 # Required-Start:    mountkernfs
 # Required-Stop:
 # Default-Start:     S
-# Default-Stop:
+# Default-Stop:      0 6
 # Short-Description: Start systemd-udevd, populate /dev and load drivers.
 ### END INIT INFO
 
@@ -101,6 +101,7 @@ make_static_nodes() {
 PATH="/sbin:/bin"
 NAME="systemd-udevd"
 DAEMON="/lib/systemd/systemd-udevd"
+PIDFILE="/run/udev.pid"
 DESC="the hotplug events dispatcher"
 
 [ -x $DAEMON ] || exit 0
@@ -179,7 +180,10 @@ case "$1" in
     [ -x /sbin/restorecon ] && /sbin/restorecon -R /dev
 
     log_daemon_msg "Starting $DESC" "$NAME"
-    if $DAEMON --daemon; then
+#    if $DAEMON --daemon; then
+    if start-stop-daemon --start --name $NAME --user root --quiet --pidfile $PIDFILE --exec $DAEMON --background --make-pidfile; then
+        mkdir -p /run/sendsigs.omit.d
+        ln -s $PIDFILE /run/sendsigs.omit.d/udev
 	log_end_msg $?
     else
 	log_warning_msg $?
@@ -207,7 +211,9 @@ case "$1" in
 
     stop)
     log_daemon_msg "Stopping $DESC" "$NAME"
-    if start-stop-daemon --stop --name $NAME --user root --quiet --oknodo --retry 5; then
+    if start-stop-daemon --stop --name $NAME --user root --quiet --pidfile $PIDFILE --oknodo --retry 5; then
+	rm -f /run/udev/control
+	rm -f /run/sendsigs.omit.d/udev
 	log_end_msg $?
     else
 	log_end_msg $?
@@ -219,14 +225,19 @@ case "$1" in
 	exit 1
     fi
     log_daemon_msg "Stopping $DESC" "$NAME"
-    if start-stop-daemon --stop --name $NAME --user root --quiet --oknodo --retry 5; then
+    if start-stop-daemon --stop --name $NAME --user root --quiet --pidfile $PIDFILE --oknodo --retry 5; then
+	rm -f /run/sendsigs.omit.d/udev
+	rm -f /run/udev/control
 	log_end_msg $?
     else
 	log_end_msg $? || true
     fi
 
     log_daemon_msg "Starting $DESC" "$NAME"
-    if $DAEMON --daemon; then
+#    if $DAEMON --daemon; then
+    if start-stop-daemon --start --name $NAME --user root --quiet --pidfile $PIDFILE --exec $DAEMON --background --make-pidfile; then
+        mkdir -p /run/sendsigs.omit.d
+        ln -s $PIDFILE /run/sendsigs.omit.d/udev
 	log_end_msg $?
     else
 	log_end_msg $?


More information about the Pkg-systemd-maintainers mailing list