[arch-projects] [RFC] [PATCH] [mkinitcpio] Cleanly stop udev >= 168 as recommended by upstream.
N0: udev >= 168 is needed. N1: I guess the order is correct (first cleanup then exit). N2: device-mapper/LVM udev rules must be parsed for initramfs creation to add OPTIONS+="db_persist"
From udev NEWS: The running udev daemon can now cleanly shut down with: udevadm control --exit
Udev in initramfs should clean the state of the udev database with: udevadm info --cleanup-db which will remove all state left behind from events/rules in initramfs. If initramfs uses --cleanup-db and device-mapper/LVM, the rules in initramfs need to add OPTIONS+="db_persist" for all dm devices. This will prevent removal of the udev database for these devices. Signed-off-by: Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar> --- init | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-) diff --git a/init b/init index 7b81a1a..f586220 100644 --- a/init +++ b/init @@ -118,15 +118,11 @@ elif [ ! -x "/new_root${init}" ]; then launch_interactive_shell --exec fi -#Special handling if udev is running -udevpid=$(/bin/pidof udevd) -if [ -n "${udevpid}" ]; then - # Settle pending uevents, then kill udev +# Stop udevd if is running +if [ "${udevd_running}" -eq 1 ]; then /sbin/udevadm settle - /bin/kill ${udevpid} > /dev/null 2>&1 - while /bin/pidof udevd >/dev/null; do - sleep 0.1 - done + /sbin/udevadm info --cleanup-db + /sbin/udevadm control --exit fi for d in proc sys dev run; do -- 1.7.5
On 05/02/2011 12:39 AM, Gerardo Exequiel Pozzi wrote:
N0: udev>= 168 is needed. N1: I guess the order is correct (first cleanup then exit). N2: device-mapper/LVM udev rules must be parsed for initramfs creation to add OPTIONS+="db_persist"
From udev NEWS: The running udev daemon can now cleanly shut down with: udevadm control --exit
Udev in initramfs should clean the state of the udev database with: udevadm info --cleanup-db which will remove all state left behind from events/rules in initramfs. If initramfs uses --cleanup-db and device-mapper/LVM, the rules in initramfs need to add OPTIONS+="db_persist" for all dm devices. This will prevent removal of the udev database for these devices.
Signed-off-by: Gerardo Exequiel Pozzi<vmlinuz386@yahoo.com.ar> --- init | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/init b/init index 7b81a1a..f586220 100644 --- a/init +++ b/init @@ -118,15 +118,11 @@ elif [ ! -x "/new_root${init}" ]; then launch_interactive_shell --exec fi
-#Special handling if udev is running -udevpid=$(/bin/pidof udevd) -if [ -n "${udevpid}" ]; then - # Settle pending uevents, then kill udev +# Stop udevd if is running +if [ "${udevd_running}" -eq 1 ]; then /sbin/udevadm settle - /bin/kill ${udevpid}> /dev/null 2>&1 - while /bin/pidof udevd>/dev/null; do - sleep 0.1 - done + /sbin/udevadm info --cleanup-db + /sbin/udevadm control --exit fi
for d in proc sys dev run; do This just keep settle command.
-- Gerardo Exequiel Pozzi \cos^2\alpha + \sin^2\alpha = 1
On Mon, May 02, 2011 at 12:40:14AM -0300, Gerardo Exequiel Pozzi wrote:
On 05/02/2011 12:39 AM, Gerardo Exequiel Pozzi wrote:
N0: udev>= 168 is needed. N1: I guess the order is correct (first cleanup then exit). N2: device-mapper/LVM udev rules must be parsed for initramfs creation to add OPTIONS+="db_persist"
From udev NEWS: The running udev daemon can now cleanly shut down with: udevadm control --exit
Udev in initramfs should clean the state of the udev database with: udevadm info --cleanup-db which will remove all state left behind from events/rules in initramfs. If initramfs uses --cleanup-db and device-mapper/LVM, the rules in initramfs need to add OPTIONS+="db_persist" for all dm devices. This will prevent removal of the udev database for these devices.
Signed-off-by: Gerardo Exequiel Pozzi<vmlinuz386@yahoo.com.ar> --- init | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/init b/init index 7b81a1a..f586220 100644 --- a/init +++ b/init @@ -118,15 +118,11 @@ elif [ ! -x "/new_root${init}" ]; then launch_interactive_shell --exec fi
-#Special handling if udev is running -udevpid=$(/bin/pidof udevd) -if [ -n "${udevpid}" ]; then - # Settle pending uevents, then kill udev +# Stop udevd if is running +if [ "${udevd_running}" -eq 1 ]; then /sbin/udevadm settle - /bin/kill ${udevpid}> /dev/null 2>&1 - while /bin/pidof udevd>/dev/null; do - sleep 0.1 - done + /sbin/udevadm info --cleanup-db + /sbin/udevadm control --exit fi
for d in proc sys dev run; do This just keep settle command.
-- Gerardo Exequiel Pozzi \cos^2\alpha + \sin^2\alpha = 1
The settle is actually unnecessary here, as its called as part of the udev hook. I don't see a need to call it twice. On the other hand, I've notice that dracut makes the call 'udevadm control --stop-exec-queue' prior to shutting down udevd. Perhaps we should be using that instead? dave
On 05/02/2011 01:22 AM, Dave Reisner wrote:
On Mon, May 02, 2011 at 12:40:14AM -0300, Gerardo Exequiel Pozzi wrote:
On 05/02/2011 12:39 AM, Gerardo Exequiel Pozzi wrote:
N0: udev>= 168 is needed. N1: I guess the order is correct (first cleanup then exit). N2: device-mapper/LVM udev rules must be parsed for initramfs creation to add OPTIONS+="db_persist"
From udev NEWS: The running udev daemon can now cleanly shut down with: udevadm control --exit
Udev in initramfs should clean the state of the udev database with: udevadm info --cleanup-db which will remove all state left behind from events/rules in initramfs. If initramfs uses --cleanup-db and device-mapper/LVM, the rules in initramfs need to add OPTIONS+="db_persist" for all dm devices. This will prevent removal of the udev database for these devices.
Signed-off-by: Gerardo Exequiel Pozzi<vmlinuz386@yahoo.com.ar> --- init | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/init b/init index 7b81a1a..f586220 100644 --- a/init +++ b/init @@ -118,15 +118,11 @@ elif [ ! -x "/new_root${init}" ]; then launch_interactive_shell --exec fi
-#Special handling if udev is running -udevpid=$(/bin/pidof udevd) -if [ -n "${udevpid}" ]; then - # Settle pending uevents, then kill udev +# Stop udevd if is running +if [ "${udevd_running}" -eq 1 ]; then /sbin/udevadm settle - /bin/kill ${udevpid}> /dev/null 2>&1 - while /bin/pidof udevd>/dev/null; do - sleep 0.1 - done + /sbin/udevadm info --cleanup-db + /sbin/udevadm control --exit fi
for d in proc sys dev run; do This just keep settle command.
-- Gerardo Exequiel Pozzi \cos^2\alpha + \sin^2\alpha = 1
The settle is actually unnecessary here, as its called as part of the udev hook. I don't see a need to call it twice. On the other hand, I've notice that dracut makes the call 'udevadm control --stop-exec-queue' prior to shutting down udevd. Perhaps we should be using that instead?
dave
sure? I think this: -------------------- launch udevd --daemon [udev] launch triggers settle [/udev] [other hooks] other possible uevents [/other hooks] at this point should wait for all uevents processed (settle) then stop udev (control --exit) ---------------- stop-exec-queue just ignore all events (stop process them) and queue all incomming events. I think this is what do not want to do. -- Gerardo Exequiel Pozzi \cos^2\alpha + \sin^2\alpha = 1
On Mon, May 02, 2011 at 03:16:56AM -0300, Gerardo Exequiel Pozzi wrote:
On 05/02/2011 01:22 AM, Dave Reisner wrote:
On Mon, May 02, 2011 at 12:40:14AM -0300, Gerardo Exequiel Pozzi wrote:
On 05/02/2011 12:39 AM, Gerardo Exequiel Pozzi wrote:
N0: udev>= 168 is needed. N1: I guess the order is correct (first cleanup then exit). N2: device-mapper/LVM udev rules must be parsed for initramfs creation to add OPTIONS+="db_persist"
From udev NEWS: The running udev daemon can now cleanly shut down with: udevadm control --exit
Udev in initramfs should clean the state of the udev database with: udevadm info --cleanup-db which will remove all state left behind from events/rules in initramfs. If initramfs uses --cleanup-db and device-mapper/LVM, the rules in initramfs need to add OPTIONS+="db_persist" for all dm devices. This will prevent removal of the udev database for these devices.
Signed-off-by: Gerardo Exequiel Pozzi<vmlinuz386@yahoo.com.ar> --- init | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/init b/init index 7b81a1a..f586220 100644 --- a/init +++ b/init @@ -118,15 +118,11 @@ elif [ ! -x "/new_root${init}" ]; then launch_interactive_shell --exec fi
-#Special handling if udev is running -udevpid=$(/bin/pidof udevd) -if [ -n "${udevpid}" ]; then - # Settle pending uevents, then kill udev +# Stop udevd if is running +if [ "${udevd_running}" -eq 1 ]; then /sbin/udevadm settle - /bin/kill ${udevpid}> /dev/null 2>&1 - while /bin/pidof udevd>/dev/null; do - sleep 0.1 - done + /sbin/udevadm info --cleanup-db + /sbin/udevadm control --exit fi
for d in proc sys dev run; do This just keep settle command.
-- Gerardo Exequiel Pozzi \cos^2\alpha + \sin^2\alpha = 1
The settle is actually unnecessary here, as its called as part of the udev hook. I don't see a need to call it twice. On the other hand, I've notice that dracut makes the call 'udevadm control --stop-exec-queue' prior to shutting down udevd. Perhaps we should be using that instead?
dave
sure?
I think this:
-------------------- launch udevd --daemon
[udev] launch triggers settle [/udev]
[other hooks] other possible uevents [/other hooks]
at this point should wait for all uevents processed (settle) then stop udev (control --exit) ----------------
stop-exec-queue just ignore all events (stop process them) and queue all incomming events. I think this is what do not want to do.
Not sure I understand the logic here. By the time you're ready to shut down udev, your root is mounted and $init exists. Queued uevents are very likely for hardware that we don't currently have modules for. What other uevents would we be interested in at this point? dave
On Mon, May 02, 2011 at 06:15:15AM -0400, Dave Reisner wrote:
On Mon, May 02, 2011 at 03:16:56AM -0300, Gerardo Exequiel Pozzi wrote:
On 05/02/2011 01:22 AM, Dave Reisner wrote:
On Mon, May 02, 2011 at 12:40:14AM -0300, Gerardo Exequiel Pozzi wrote:
On 05/02/2011 12:39 AM, Gerardo Exequiel Pozzi wrote:
N0: udev>= 168 is needed. N1: I guess the order is correct (first cleanup then exit). N2: device-mapper/LVM udev rules must be parsed for initramfs creation to add OPTIONS+="db_persist"
From udev NEWS: The running udev daemon can now cleanly shut down with: udevadm control --exit
Udev in initramfs should clean the state of the udev database with: udevadm info --cleanup-db which will remove all state left behind from events/rules in initramfs. If initramfs uses --cleanup-db and device-mapper/LVM, the rules in initramfs need to add OPTIONS+="db_persist" for all dm devices. This will prevent removal of the udev database for these devices.
Signed-off-by: Gerardo Exequiel Pozzi<vmlinuz386@yahoo.com.ar> --- init | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/init b/init index 7b81a1a..f586220 100644 --- a/init +++ b/init @@ -118,15 +118,11 @@ elif [ ! -x "/new_root${init}" ]; then launch_interactive_shell --exec fi
-#Special handling if udev is running -udevpid=$(/bin/pidof udevd) -if [ -n "${udevpid}" ]; then - # Settle pending uevents, then kill udev +# Stop udevd if is running +if [ "${udevd_running}" -eq 1 ]; then /sbin/udevadm settle - /bin/kill ${udevpid}> /dev/null 2>&1 - while /bin/pidof udevd>/dev/null; do - sleep 0.1 - done + /sbin/udevadm info --cleanup-db + /sbin/udevadm control --exit fi
for d in proc sys dev run; do This just keep settle command.
-- Gerardo Exequiel Pozzi \cos^2\alpha + \sin^2\alpha = 1
The settle is actually unnecessary here, as its called as part of the udev hook. I don't see a need to call it twice. On the other hand, I've notice that dracut makes the call 'udevadm control --stop-exec-queue' prior to shutting down udevd. Perhaps we should be using that instead?
dave
sure?
I think this:
-------------------- launch udevd --daemon
[udev] launch triggers settle [/udev]
[other hooks] other possible uevents [/other hooks]
at this point should wait for all uevents processed (settle) then stop udev (control --exit) ----------------
stop-exec-queue just ignore all events (stop process them) and queue all incomming events. I think this is what do not want to do.
Not sure I understand the logic here. By the time you're ready to shut down udev, your root is mounted and $init exists. Queued uevents are very likely for hardware that we don't currently have modules for. What other uevents would we be interested in at this point?
dave
Replying to myself to correct myself... I spoke with Kay Sievers on IRC and it seems that the second settle is needed in older versions of udev, but if we're going to be using control --exit, then its not needed. To quote: 09:38 kay » falconindy: yeah, old udev version might leave processes behind for a very short while while udevd was killed 09:38 kay » falconindy: so the second settle was not wrong 09:39 kay » falconindy: but not needed with --exit I also asked him about calling info --cleanup-db 09:35 kay » falconindy: cleanup db only if you need, and keep lvm working 09:36 falconindy » right, i noticed that lvm rules would need adjustment 09:36 falconindy » what would be the need to call cleanup-db? 09:36 kay » falconindy: yeah. otherwise it's nice to have, so you don't confuse the real root with crap left behind from initramfs So it's not imperative that we call this. And as for dracut calling --stop-exec-queue: 09:34 falconindy » i notice dracut calls the stop exec 09:35 kay » falconindy: never do anything with the queue 09:35 kay » falconindy: at least i don't know a valid use case Yay dracut... So, if we're going to be supporting udev>=168, it seems like the ideal way to shutdown udevd is: udevadm info --cleanup-db udevadm control --exit d
Am 02.05.2011 12:15, schrieb Dave Reisner:
Not sure I understand the logic here. By the time you're ready to shut down udev, your root is mounted and $init exists. Queued uevents are very likely for hardware that we don't currently have modules for. What other uevents would we be interested in at this point?
In the past, there were weird bugs: 1) When using break=y, or when mounting root failed, the USB keyboard support might not be loaded, as the uevent could not finish. 2) switch_root might have failed to delete the rootfs contents, as udev processes would still access /dev/.udev. Those are old - we reordered and improved all of that stuff, so this problem should be gone by now. Even right now, settling might be unnecessary.
Am 02.05.2011 06:22, schrieb Dave Reisner:
The settle is actually unnecessary here, as its called as part of the udev hook. I don't see a need to call it twice.
https://projects.archlinux.org/mkinitcpio.git/commit/?id=3c6a2fab7e5a347d92b... It seems I forgot to add an explanation back then, but there were problems when aborting while uevents were still active.
On the other hand, I've notice that dracut makes the call 'udevadm control --stop-exec-queue' prior to shutting down udevd. Perhaps we should be using that instead?
No idea. We need to prevent races here. What we would need is an atomic "settle and shut down" that doesn't queue any further events between settling and the shutdown.
On 05/02/2011 05:51 AM, Thomas Bächler wrote:
Am 02.05.2011 06:22, schrieb Dave Reisner:
The settle is actually unnecessary here, as its called as part of the udev hook. I don't see a need to call it twice. https://projects.archlinux.org/mkinitcpio.git/commit/?id=3c6a2fab7e5a347d92b...
It seems I forgot to add an explanation back then, but there were problems when aborting while uevents were still active.
On the other hand, I've notice that dracut makes the call 'udevadm control --stop-exec-queue' prior to shutting down udevd. Perhaps we should be using that instead? No idea. We need to prevent races here. What we would need is an atomic "settle and shut down" that doesn't queue any further events between settling and the shutdown.
I just Asked to udev author: ---- On 05/02/2011 08:41 AM, Kay Sievers wrote:
On Mon, May 2, 2011 at 05:45, Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar> wrote:
Hello Kay
At initramfs stage: what is the best way / order, to stop udev?.
1) udevadm settle udevadm info --cleanup-db udevadm control --exit
2) udevadm settle udevadm control --exit udevadm info --cleanup-db
3) udevadm control --exit udevadm info --cleanup-db Settle is not needed, it's done with --exit. The --cleanup-db should be after the --exit. So it's 3).
Kay
Thank you! ---- -- Gerardo Exequiel Pozzi \cos^2\alpha + \sin^2\alpha = 1
Am 02.05.2011 15:55, schrieb Gerardo Exequiel Pozzi:
I just Asked to udev author:
Looks like Dave beat you to it.
On Mon, May 02, 2011 at 04:17:15PM +0200, Thomas Bächler wrote:
Am 02.05.2011 15:55, schrieb Gerardo Exequiel Pozzi:
I just Asked to udev author:
Looks like Dave beat you to it.
We both got valuable information though. Kay wasn't so specific about the order when he explained it to me. I just happened to know where to find him (lurking in #systemd). Now we just need udev 168 in testing. Of course, someone will ask, so I'll raise it: are we going to support udev<168? dave
participants (3)
-
Dave Reisner
-
Gerardo Exequiel Pozzi
-
Thomas Bächler