Skip to contentSkip to conversation

Cold plug starting services too soon

DISCUSSION Greg KH 4 participants 13 messages Jan 17, 2006 – Jan 20, 2006

lore
Share & tools
lore

Greg KH

author
#0 lore raw

<dragging in the Debian and SuSE developers responsible for this>

Hi Kay and Marco.

Gentoo has run into the problem that if we load modules for some types of devices (like network devices for example), we can generate hotplug events that want to run things on disks that are not mounted yet, as we havn't even done mounting of the non-root filesystem yet (caused by udev doing the coldplug pretty much the first thing at boot time.)

How has Debian and SuSE kept from having this issue? I think for SuSE we rely on the fact that the initrd/initramfs has loaded the proper modules already for us, right?

thanks,

greg k-h

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

author
#1 lore raw
Quoted 10 lines · Greg KH

<dragging in the Debian and SuSE developers responsible for this>

Hi Kay and Marco.

Gentoo has run into the problem that if we load modules for some types of devices (like network devices for example), we can generate hotplug events that want to run things on disks that are not mounted yet, as we havn't even done mounting of the non-root filesystem yet (caused by udev doing the coldplug pretty much the first thing at boot time.)

Quoted 3 lines

How has Debian and SuSE kept from having this issue? I think for SuSE we rely on the fact that the initrd/initramfs has loaded the proper modules already for us, right?

Oh, and if you both feel this is a Gentoo specific issue, feel free to tell us to go away and deal with it ourselves :)

thanks,

greg k-h

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#2 lore raw
In reply to Greg KH
Quoted 10 lines · Greg KH

<dragging in the Debian and SuSE developers responsible for this>

Hi Kay and Marco.

Gentoo has run into the problem that if we load modules for some types of devices (like network devices for example), we can generate hotplug events that want to run things on disks that are not mounted yet, as we havn't even done mounting of the non-root filesystem yet (caused by udev doing the coldplug pretty much the first thing at boot time.)

Quoted 3 lines

How has Debian and SuSE kept from having this issue? I think for SuSE we rely on the fact that the initrd/initramfs has loaded the proper modules already for us, right?

All running events are exported in /dev/.udev/queue/, events that fail will be moved to /dev/.udev/failed/. Make sure the script return non-zero if it can't run and retry all failed events from /dev/.udev/failed/ after "localfs" is done. If the same event then runs successfully, it will go away from /dev/.udev/failed/. On SUSE I have a second udev boot script that is called /etc/init.d/boot.udev_retry.

Kay

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#3 lore raw
In reply to Greg KH
Quoted 7 lines · Greg KH

Gentoo has run into the problem that if we load modules for some types of devices (like network devices for example), we can generate hotplug events that want to run things on disks that are not mounted yet, as we havn't even done mounting of the non-root filesystem yet (caused by udev doing the coldplug pretty much the first thing at boot time.)

How has Debian and SuSE kept from having this issue? I think for SuSE

On Debian, packages which install RUN rules must either not care if events happening before /usr is mounted are lost or if appropriate use scripts which wait until whatever is needed is available (e.g. the SUBSYSTEM=="net" agent waits for the lo interface to be up). I am not sure if I want to replay failed events, because we don't know why they failed and so far it's not clear if this is needed.

Signature · 2 lines
ciao,
Marco
author
#4 lore raw
In reply to Greg KH
Quoted 15 lines · Kay Sievers
Quoted 10 lines · Greg KH

<dragging in the Debian and SuSE developers responsible for this>

Hi Kay and Marco.

Gentoo has run into the problem that if we load modules for some types of devices (like network devices for example), we can generate hotplug events that want to run things on disks that are not mounted yet, as we havn't even done mounting of the non-root filesystem yet (caused by udev doing the coldplug pretty much the first thing at boot time.)

Quoted 3 lines

How has Debian and SuSE kept from having this issue? I think for SuSE we rely on the fact that the initrd/initramfs has loaded the proper modules already for us, right?

Quoted 6 lines

All running events are exported in /dev/.udev/queue/, events that fail will be moved to /dev/.udev/failed/. Make sure the script return non-zero if it can't run and retry all failed events from /dev/.udev/failed/ after "localfs" is done. If the same event then runs successfully, it will go away from /dev/.udev/failed/. On SUSE I have a second udev boot script that is called /etc/init.d/boot.udev_retry.

Cool, I'll try doing that for Gentoo and see how it works out. Thanks for adding this to udev already.

Roy, do you think this will work out properly?

greg k-h

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#5 lore raw
In reply to Greg KH
Quoted 8 lines · Greg KH
Quoted 6 lines · Kay Sievers

All running events are exported in /dev/.udev/queue/, events that fail will be moved to /dev/.udev/failed/. Make sure the script return non-zero if it can't run and retry all failed events from /dev/.udev/failed/ after "localfs" is done. If the same event then runs successfully, it will go away from /dev/.udev/failed/. On SUSE I have a second udev boot script that is called /etc/init.d/boot.udev_retry.

Quoted 4 lines

Cool, I'll try doing that for Gentoo and see how it works out. Thanks for adding this to udev already.

Roy, do you think this will work out properly?

Yes, this can work out nicely. However, I don't see /dev/.udev/failed when we exit with code 1. Is there something I'm missing?

Currently I have this fairly near the top of runscript.sh

# Ensure that we have completed sysinit
if [[ ${IN_HOTPLUG} == 1 ]] ; then

    for pid in $(pidof bash) ; do
        if [[ "$(cat "/proc/${pid}/cmdline" 2>/dev/null)" \
            == "/bin/bash/sbin/rcsysinit" ]] ; then
            eerror "ERROR:  cannot hotplug ${myservice} until sysinit has 

run."
exit 1
fi
done
unset pid
fi

Now thats very hacky, but the only way I can think of to find out if our rc system has completed its sysinit. A better solution would be this

# Ensure that we have completed sysinit
if [[ ${RC_SYSINIT} == 1 ]] ; then
eerror "ERROR: cannot run ${myservice} until sysinit has completed." exit 1
fi

Obviously this only works if rc can configure udev to export shell variables before triggerring hotplugable events and can change/unset/add it after sysinit. Something like this maybe.

udev_set_env "RC_SYSINIT=1"

do stuff to complete sysinit

udev_sev_env "RC_SYSINIT="

Can we do this Greg?

Signature · 2 lines
Roy Marples <[email protected]>
Gentoo Linux Developer
author
#6 lore raw
In reply to Greg KH
Quoted 45 lines · Roy Marples
Quoted 8 lines · Greg KH
Quoted 6 lines · Kay Sievers

All running events are exported in /dev/.udev/queue/, events that fail will be moved to /dev/.udev/failed/. Make sure the script return non-zero if it can't run and retry all failed events from /dev/.udev/failed/ after "localfs" is done. If the same event then runs successfully, it will go away from /dev/.udev/failed/. On SUSE I have a second udev boot script that is called /etc/init.d/boot.udev_retry.

Quoted 4 lines

Cool, I'll try doing that for Gentoo and see how it works out. Thanks for adding this to udev already.

Roy, do you think this will work out properly?

Yes, this can work out nicely. However, I don't see /dev/.udev/failed when we exit with code 1. Is there something I'm missing?

Currently I have this fairly near the top of runscript.sh

# Ensure that we have completed sysinit
if [[ ${IN_HOTPLUG} = 1 ]] ; then

    for pid in $(pidof bash) ; do
        if [[ "$(cat "/proc/${pid}/cmdline" 2>/dev/null)" \
            = "/bin/bash/sbin/rcsysinit" ]] ; then
            eerror "ERROR:  cannot hotplug ${myservice} until sysinit has 

run."
exit 1
fi
done
unset pid
fi

Now thats very hacky, but the only way I can think of to find out if our rc system has completed its sysinit. A better solution would be this

# Ensure that we have completed sysinit
if [[ ${RC_SYSINIT} = 1 ]] ; then
eerror "ERROR: cannot run ${myservice} until sysinit has completed." exit 1
fi

Obviously this only works if rc can configure udev to export shell variables before triggerring hotplugable events and can change/unset/add it after sysinit. Something like this maybe.

Quoted 7 lines

udev_set_env "RC_SYSINIT=1"

do stuff to complete sysinit

udev_sev_env "RC_SYSINIT="

Can we do this Greg?

Hm, we might be able to mess around with this some, but why not just create a temporary file when we start udev, which the rc scripts can check? When the initial udev startup is done (or whenever you want it), the file can be removed. That should be a lot simpler, right?

thanks,

greg k-h

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#7 lore raw
In reply to Greg KH
Quoted 4 lines · Greg KH

Hm, we might be able to mess around with this some, but why not just create a temporary file when we start udev, which the rc scripts can check? When the initial udev startup is done (or whenever you want it), the file can be removed. That should be a lot simpler, right?

Yes it would, but all disks are mounted read only at this point - the checking and mounting happens during sysinit. At this point we can create temporary files, but udev is already active and doing its thing.

Roy

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

author
#8 lore raw
In reply to Greg KH
Quoted 9 lines · Roy Marples
Quoted 4 lines · Greg KH

Hm, we might be able to mess around with this some, but why not just create a temporary file when we start udev, which the rc scripts can check? When the initial udev startup is done (or whenever you want it), the file can be removed. That should be a lot simpler, right?

Yes it would, but all disks are mounted read only at this point - the checking and mounting happens during sysinit. At this point we can create temporary files, but udev is already active and doing its thing.

In our ramfs/tmpfs? Why can't we use that, as we know we can write there :)

thanks,

greg k-h

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#9 lore raw
In reply to Greg KH
Quoted 7 lines · Greg KH
Quoted 6 lines · Roy Marples
Quoted 4 lines · Greg KH

Hm, we might be able to mess around with this some, but why not just create a temporary file when we start udev, which the rc scripts can check? When the initial udev startup is done (or whenever you want it), the file can be removed. That should be a lot simpler, right?

Quoted 6 lines
Quoted 3 lines

Yes it would, but all disks are mounted read only at this point - the checking and mounting happens during sysinit. At this point we can create temporary files, but udev is already active and doing its thing.

In our ramfs/tmpfs? Why can't we use that, as we know we can write there :)

Is there any guarantee that user has ramfs/tmpfs compiled into kernel? If so, where would we mount? /lib/rcscripts/sysinit ?

Thanks

Signature · 2 lines
Roy Marples <[email protected]>
Gentoo Linux Developer
author
#10 lore raw
In reply to Greg KH
Quoted 12 lines · Roy Marples
Quoted 11 lines · Greg KH
Quoted 9 lines · Roy Marples
Quoted 4 lines · Greg KH

Hm, we might be able to mess around with this some, but why not just create a temporary file when we start udev, which the rc scripts can check? When the initial udev startup is done (or whenever you want it), the file can be removed. That should be a lot simpler, right?

Yes it would, but all disks are mounted read only at this point - the checking and mounting happens during sysinit. At this point we can create temporary files, but udev is already active and doing its thing.

Quoted 5 lines
Quoted 2 lines

In our ramfs/tmpfs? Why can't we use that, as we know we can write there :)

Is there any guarantee that user has ramfs/tmpfs compiled into kernel? If so, where would we mount? /lib/rcscripts/sysinit ?

No, I mean the ramfs/tmpfs that udev uses to hold it's /dev tree and database. I can provide a function that the rc scripts can call to see if udev is still initializing or not to keep them from having to worry about the actual mechanics.

And yes, ramfs is always compiled into the kernel these days.

thanks,

greg k-h

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

#11 lore raw
In reply to Greg KH
Quoted 4 lines · Greg KH

No, I mean the ramfs/tmpfs that udev uses to hold it's /dev tree and database. I can provide a function that the rc scripts can call to see if udev is still initializing or not to keep them from having to worry about the actual mechanics.

So I could touch /dev/.rcsysinit and remove that after sysinit completes? That works for me :)

Quoted 1 line

And yes, ramfs is always compiled into the kernel these days.

Really?
I see CONFIG_RAMFS=y and CONFIG_TMPFS=y in my 2.6.15 kernel config so I was under the impression that they're optional.

Thanks

Signature · 2 lines
Roy Marples <[email protected]>
Gentoo Linux Developer
author
#12 lore raw
In reply to Greg KH
Quoted 8 lines · Roy Marples
Quoted 4 lines · Greg KH

No, I mean the ramfs/tmpfs that udev uses to hold it's /dev tree and database. I can provide a function that the rc scripts can call to see if udev is still initializing or not to keep them from having to worry about the actual mechanics.

So I could touch /dev/.rcsysinit and remove that after sysinit completes? That works for me :)

Yup.

Quoted 5 lines
Quoted 1 line

And yes, ramfs is always compiled into the kernel these days.

Really?
I see CONFIG_RAMFS=y and CONFIG_TMPFS=y in my 2.6.15 kernel config so I was under the impression that they're optional.

Hm, I thought that the build system always forced ramfs on, due to boot issues, but in looking at the Kconfig system, I can't see that dependancy anymore. So you are right.

But udev on Gentoo will not work without that, so we don't really need to worry about this :)

thanks,

greg k-h

-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel