linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* usb race possible?
@ 2005-06-14 13:35 Andreas Jellinghaus
  2005-06-14 14:22 ` Kay Sievers
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Andreas Jellinghaus @ 2005-06-14 13:35 UTC (permalink / raw)
  To: linux-hotplug

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
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: usb race possible?
  2005-06-14 13:35 usb race possible? Andreas Jellinghaus
@ 2005-06-14 14:22 ` Kay Sievers
  2005-06-15 13:33 ` Andreas Jellinghaus
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Kay Sievers @ 2005-06-14 14:22 UTC (permalink / raw)
  To: linux-hotplug

On Tue, Jun 14, 2005 at 03:35:59PM +0200, Andreas Jellinghaus wrote:
> 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.

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
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: usb race possible?
  2005-06-14 13:35 usb race possible? Andreas Jellinghaus
  2005-06-14 14:22 ` Kay Sievers
@ 2005-06-15 13:33 ` Andreas Jellinghaus
  2005-06-15 14:28 ` Greg KH
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Andreas Jellinghaus @ 2005-06-15 13:33 UTC (permalink / raw)
  To: linux-hotplug

On Tuesday 14 June 2005 16:22, Kay Sievers wrote:
> 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: kay.sievers@vrfy.org, linux-hotplug-devel@lists.sourceforge.net.
For your security, aj@leogic.com
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_id\x16492&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: usb race possible?
  2005-06-14 13:35 usb race possible? Andreas Jellinghaus
  2005-06-14 14:22 ` Kay Sievers
  2005-06-15 13:33 ` Andreas Jellinghaus
@ 2005-06-15 14:28 ` Greg KH
  2005-06-15 14:32 ` Andreas Jellinghaus
  2005-06-15 22:04 ` Greg KH
  4 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2005-06-15 14:28 UTC (permalink / raw)
  To: linux-hotplug

On Wed, Jun 15, 2005 at 03:33:40PM +0200, Andreas Jellinghaus wrote:
> On Tuesday 14 June 2005 16:22, Kay Sievers wrote:
> > 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 :)

> 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_id\x16492&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: usb race possible?
  2005-06-14 13:35 usb race possible? Andreas Jellinghaus
                   ` (2 preceding siblings ...)
  2005-06-15 14:28 ` Greg KH
@ 2005-06-15 14:32 ` Andreas Jellinghaus
  2005-06-15 22:04 ` Greg KH
  4 siblings, 0 replies; 6+ messages in thread
From: Andreas Jellinghaus @ 2005-06-15 14:32 UTC (permalink / raw)
  To: linux-hotplug

On Wednesday 15 June 2005 16:28, Greg KH wrote:
> On Wed, Jun 15, 2005 at 03:33:40PM +0200, Andreas Jellinghaus wrote:
> > On Tuesday 14 June 2005 16:22, Kay Sievers wrote:
> > > 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 :)
>
> > 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: greg@kroah.com, kay.sievers@vrfy.org,
linux-hotplug-devel@lists.sourceforge.net.
For your security, aj@leogic.com
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_id\x16492&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: usb race possible?
  2005-06-14 13:35 usb race possible? Andreas Jellinghaus
                   ` (3 preceding siblings ...)
  2005-06-15 14:32 ` Andreas Jellinghaus
@ 2005-06-15 22:04 ` Greg KH
  4 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2005-06-15 22:04 UTC (permalink / raw)
  To: linux-hotplug

On Wed, Jun 15, 2005 at 04:32:00PM +0200, Andreas Jellinghaus wrote:
> On Wednesday 15 June 2005 16:28, Greg KH wrote:
> > On Wed, Jun 15, 2005 at 03:33:40PM +0200, Andreas Jellinghaus wrote:
> > > On Tuesday 14 June 2005 16:22, Kay Sievers wrote:
> > > > 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 :)
> >
> > > 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?

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_id\x16492&op=click
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-06-15 22:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-06-14 13:35 usb race possible? Andreas Jellinghaus
2005-06-14 14:22 ` Kay Sievers
2005-06-15 13:33 ` Andreas Jellinghaus
2005-06-15 14:28 ` Greg KH
2005-06-15 14:32 ` Andreas Jellinghaus
2005-06-15 22:04 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).