usb race possible?
Hi,
if a new usb device is added the kernel
generates a hotplug event including the
path to the usb device.
does the kernel guarantee that the device
in the usb device filesystem is available
when the hotplug script is called?
I have one user here where it seems that
sometimes the process started via hotplug
is too fast, i.e. open on the usb device
fails. manualy running lsusb shows the
device. linux kernel 2.6.11 (-gentoo,
not sure what they changed).
so could this be a race condition? any other
idea how I can debug the issue? for now I added
a "sleep 1" to the hotplug handler before the
open and it seems to cure the problem.
Regards, Andreas
-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games. How far can you shotput a projector? How fast can you ride your desk chair down the office luge track? If you want to score the big prize, get to know the little guy. Play to win an NEC 61" plasma display: http://www.necitguy.com/?r
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 17 lines · Andreas Jellinghaus
Hi,
if a new usb device is added the kernel generates a hotplug event including the path to the usb device.
does the kernel guarantee that the device in the usb device filesystem is available when the hotplug script is called?
I have one user here where it seems that sometimes the process started via hotplug is too fast, i.e. open on the usb device fails. manualy running lsusb shows the device. linux kernel 2.6.11 (-gentoo, not sure what they changed).
Quoted 4 lines
so could this be a race condition? any other idea how I can debug the issue? for now I added a "sleep 1" to the hotplug handler before the open and it seems to cure the problem.
That is ok, you need to wait in userspace for the files to show up. It's not easy to fix in the kernel. Maybe we will get there some day...
Kay
-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games. How far can you shotput a projector? How fast can you ride your desk chair down the office luge track? If you want to score the big prize, get to know the little guy. Play to win an NEC 61" plasma display: http://www.necitguy.com/?r
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 2 lines · Kay Sievers
That is ok, you need to wait in userspace for the files to show up. It's not easy to fix in the kernel. Maybe we will get there some day...
do you think "sleep 1" is good enough?
or do I need to implement a full scale
open&retry solution?
Andreas
--
------------------------ [ SECURITY NOTICE ] ------------------------
To: [email protected], [email protected]. For your security, [email protected]
digitally signed this message on 15 June 2005 at 13:33:45 UTC. Verify this digital signature at http://www.ciphire.com/verify.
------------------- [ CIPHIRE DIGITAL SIGNATURE ] ------------------- Q2lwaGlyZSBTaWcuAVdrYXkuc2lldmVyc0B2cmZ5Lm9yZywgbGludXgtaG90cGx1Zy1kZ XZlbEBsaXN0cy5zb3VyY2Vmb3JnZS5uZXQAYWpAbGVvZ2ljLmNvbQBlbWFpbCBib2R5AP AAAAB8AHwAAAABAAAAOS6wQvAAAADGAgACAAIAAgAgh2srQgvyNciX0llE7hAjDcMGhp6 lHML351NzR441w+EBAEM7cGrcszyE8ngGU14oj2aV9oLJZb1Xm86QEBwPKvsxUSf39U/Z M7mmuj+rk4yMsIDI5O0dvTvBaD+dlPhcEZDPU2lnRW5k --------------------- [ END DIGITAL SIGNATURE ] ---------------------
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 5 lines · Andreas Jellinghaus
Quoted 2 lines · Kay Sievers
That is ok, you need to wait in userspace for the files to show up. It's not easy to fix in the kernel. Maybe we will get there some day...
do you think "sleep 1" is good enough?
Try it and find out :)
Quoted 2 lines
or do I need to implement a full scale
open&retry solution?
If you want it to always work on all machines, yes.
Good luck,
greg k-h
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 5 lines · Greg KH
Quoted 4 lines · Andreas Jellinghaus
Quoted 2 lines · Kay Sievers
That is ok, you need to wait in userspace for the files to show up. It's not easy to fix in the kernel. Maybe we will get there some day...
Quoted 8 lines
Quoted 1 line
do you think "sleep 1" is good enough?
Try it and find out :)
Quoted 2 lines
or do I need to implement a full scale
open&retry solution?If you want it to always work on all machines, yes.
ok thanks.
<evil question>
but wouldn't it be better if the hotplug system did that, instead of putting the same code into every application?
my app is simply called with the device path to handle, so I feel like it shouldn't do such retry stuff, but rather the caller should make sure, that the file given as argument exists...
so maybe put the sleep/wait functionality into the hotplug core?
</evil>
Regards, Andreas
--
------------------------ [ SECURITY NOTICE ] ------------------------
To: [email protected], [email protected], [email protected].
For your security, [email protected]
digitally signed this message on 15 June 2005 at 14:32:07 UTC. Verify this digital signature at http://www.ciphire.com/verify.
------------------- [ CIPHIRE DIGITAL SIGNATURE ] ------------------- Q2lwaGlyZSBTaWcuAVdncmVnQGtyb2FoLmNvbSwga2F5LnNpZXZlcnNAdnJmeS5vcmcsI GxpbnV4LWhvdHBsdWctZGV2ZWxAbGlzdHMuc291cmNlZm9yZ2UubmV0AGFqQGxlb2dpYy 5jb20AZW1haWwgYm9keQDzAgAAfAB8AAAAAQAAAOc7sELzAgAAhgMAAgACAAIAIIdrK0I L8jXIl9JZRO4QIw3DBoaepRzC9+dTc0eONcPhAQBDO3Bq3LM8hPJ4BlNeKI9mlfaCyWW9 V5vOkBAcDyr7MTyEa3i17zyCBA6wCMcBhyJ2c5ttUQJl962knNoRGPhjzwgBU2lnRW5k --------------------- [ END DIGITAL SIGNATURE ] ---------------------
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Quoted 13 lines · Andreas Jellinghaus
Quoted 12 lines · Greg KH
Quoted 5 lines · Andreas Jellinghaus
Quoted 2 lines · Kay Sievers
That is ok, you need to wait in userspace for the files to show up. It's not easy to fix in the kernel. Maybe we will get there some day...
do you think "sleep 1" is good enough?
Try it and find out :)
Quoted 2 lines
or do I need to implement a full scale
open&retry solution?
Quoted 7 lines
Quoted 1 line
If you want it to always work on all machines, yes.
ok thanks.
<evil question>
but wouldn't it be better if the hotplug system did that, instead of putting the same code into every application?
We used to have code that did that, look at the old udev releases. "wait_for_sysfs" was what it was called. Turned out that just putting that logic into udev was easier :)
So, just put yourself into /etc/dev.d/ or in a udev rule and you should be fine and not have to do the hotplug wait logic.
hope this helps,
greg k-h
-------------------------------------------------------
SF.Net email is sponsored by: Discover Easy Linux Migration Strategies from IBM. Find simple to follow Roadmaps, straightforward articles, informative Webcasts and more! Get everything you need to get up to speed, fast. http://ads.osdn.com/?ad_idt77&alloc_id492&op=click
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel