* Re: Hotplug bug in Linux 2.4.21?
2003-06-20 17:25 Hotplug bug in Linux 2.4.21? Adrien Beau
@ 2003-06-20 17:51 ` Greg KH
2003-06-20 18:15 ` Duncan Sands
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Greg KH @ 2003-06-20 17:51 UTC (permalink / raw)
To: linux-hotplug
On Fri, Jun 20, 2003 at 07:25:59PM +0200, Adrien Beau wrote:
>
> When I booted my new kernel, I almost immediately noticed that my
> DSL line wasn't up as expected, and so I looked into my logs (my
> hotplug script does a fair amount of logging) and noticed two weird
> things: the first one, is that *three* connection events were fired
> when the modem was detected (plus another one after the seven seconds
> timeout). When I disconnected it, my remover was launched *three*
> times, simultaneously.
Yes, we now call /sbin/hotplug for ever interface of a USB device,
instead of just once. I've talked to the speedtouch kernel driver's
author a bunch about this, and he says that he has a updated hotplug
script to properly handle this. You should contact him.
Hope this helps,
greg k-h
-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
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] 10+ messages in thread* Re: Hotplug bug in Linux 2.4.21?
2003-06-20 17:25 Hotplug bug in Linux 2.4.21? Adrien Beau
2003-06-20 17:51 ` Greg KH
@ 2003-06-20 18:15 ` Duncan Sands
2003-06-20 18:44 ` Adrien Beau
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Duncan Sands @ 2003-06-20 18:15 UTC (permalink / raw)
To: linux-hotplug
> Yes, we now call /sbin/hotplug for ever interface of a USB device,
> instead of just once. I've talked to the speedtouch kernel driver's
> author a bunch about this, and he says that he has a updated hotplug
> script to properly handle this. You should contact him.
Actually I said that it was a pain to write such a script in 2.4 because
there is no easy way to get the interface number, and promised you
a kernel patch to export the interface number, which I never found
time to write...
Duncan.
-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
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] 10+ messages in thread* Re: Hotplug bug in Linux 2.4.21?
2003-06-20 17:25 Hotplug bug in Linux 2.4.21? Adrien Beau
2003-06-20 17:51 ` Greg KH
2003-06-20 18:15 ` Duncan Sands
@ 2003-06-20 18:44 ` Adrien Beau
2003-06-20 19:18 ` Kevin P. Fleming
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Adrien Beau @ 2003-06-20 18:44 UTC (permalink / raw)
To: linux-hotplug
On Friday 20 June 2003 19:51, Greg KH wrote:
>
> On Fri, Jun 20, 2003 at 07:25:59PM +0200, Adrien Beau wrote:
> > three connection events were fired when the modem was detected
> > (...). When I disconnected it, my remover was launched three
> > times, simultaneously.
>
> Yes, we now call /sbin/hotplug for ever interface of a USB
> device, instead of just once. I've talked to the speedtouch
> kernel driver's author a bunch about this, and he says that he
> has a updated hotplug script to properly handle this.
To which Duncan Sands quickly replied:
>
> Actually I said that it was a pain to write such a script in 2.4
> because there is no easy way to get the interface number.
Okay. I guess that if we had that, we could easily react to only
one of the events, and ignore the others. Meanwhile, it seems like
my lockfile approach is the better answer to the issue, if only
there wasn't this strange behavior. If you want to have a look at
it, have put my script there:
http://adrien.beau.free.fr/slackware/hotplug/speedtouch
http://adrien.beau.free.fr/slackware/hotplug/speedtouch.usermap
http://adrien.beau.free.fr/slackware/hotplug/speedtouch.log
It is intended to work with the *usermode* SpeedTouch driver, and
should of course be put under /etc/hotplug/usb. The logfile might
interest you, too.
So, if anybody can help finding why:
* When everything works fine, a second instance of the script is
launched approximately seven seconds after the first one. It looks
like there's a timeout somewhere. Look at the logfile entries on
June 17th for a typical occurence of the problem. This only happens
at boot time. Hotplugging works (worked) fine.
* When two instances of the script are run at a few seconds interval,
the lockfile mechanism works fine (again, see for example June 17th),
but when three instances run at the same time, the mechanism fails
in an impossible manner (see the log entries starting on June 20th,
at 12:15pm for the first occurence of this, and see the entries at
12:55:55pm for an occurence with the timestamps printed in the logs).
... I would be very grateful.
> Hope this helps,
Well, sure, now I know on what problem to work. :-)
--
adrien.beau@free.fr - http://adrien.beau.free.fr/
-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
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] 10+ messages in thread* Re: Hotplug bug in Linux 2.4.21?
2003-06-20 17:25 Hotplug bug in Linux 2.4.21? Adrien Beau
` (2 preceding siblings ...)
2003-06-20 18:44 ` Adrien Beau
@ 2003-06-20 19:18 ` Kevin P. Fleming
2003-06-21 10:12 ` Olaf Hering
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Kevin P. Fleming @ 2003-06-20 19:18 UTC (permalink / raw)
To: linux-hotplug
Adrien Beau wrote:
> * When two instances of the script are run at a few seconds interval,
> the lockfile mechanism works fine (again, see for example June 17th),
> but when three instances run at the same time, the mechanism fails
> in an impossible manner (see the log entries starting on June 20th,
> at 12:15pm for the first occurence of this, and see the entries at
> 12:55:55pm for an occurence with the timestamps printed in the logs).
>
I suspect your problem is that you are using timestamps for this log checking,
and the timestamp granularity is too coarse. When the USB core decides to
generate hotplug events for all three interfaces of a device it just found,
those three /sbin/hotplug invocations are going to happen very quickly,
certainly within a small fraction of a second.
You'll need to find some other way of knowing when a lockfile exists and is
stale... something that can handle more than one process that is started at
identical times (or nearly so).
-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
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] 10+ messages in thread* Re: Hotplug bug in Linux 2.4.21?
2003-06-20 17:25 Hotplug bug in Linux 2.4.21? Adrien Beau
` (3 preceding siblings ...)
2003-06-20 19:18 ` Kevin P. Fleming
@ 2003-06-21 10:12 ` Olaf Hering
2003-06-21 15:56 ` Adrien Beau
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Olaf Hering @ 2003-06-21 10:12 UTC (permalink / raw)
To: linux-hotplug
On Fri, Jun 20, Adrien Beau wrote:
> http://adrien.beau.free.fr/slackware/hotplug/speedtouch.usermap
Maybe I miss the point of this file, but you do not need it if your
driver defines a valid MODULE_DEVICE_TABLE().
Gruss Olaf
--
USB is for mice, FireWire is for men!
-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
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] 10+ messages in thread* Re: Hotplug bug in Linux 2.4.21?
2003-06-20 17:25 Hotplug bug in Linux 2.4.21? Adrien Beau
` (4 preceding siblings ...)
2003-06-21 10:12 ` Olaf Hering
@ 2003-06-21 15:56 ` Adrien Beau
2003-06-21 16:11 ` Adrien Beau
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: Adrien Beau @ 2003-06-21 15:56 UTC (permalink / raw)
To: linux-hotplug
On Saturday 21 June 2003 12:12, Olaf Hering wrote:
>
> On Fri, Jun 20, Adrien Beau wrote:
> > http://adrien.beau.free.fr/slackware/hotplug/speedtouch.usermap
>
> Maybe I miss the point of this file, but you do not need it if
> your driver defines a valid MODULE_DEVICE_TABLE().
I think this is the case for a kernel module, but the driver I use
is 100% usermode.
--
adrien.beau@free.fr - http://adrien.beau.free.fr/
-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
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] 10+ messages in thread* Re: Hotplug bug in Linux 2.4.21?
2003-06-20 17:25 Hotplug bug in Linux 2.4.21? Adrien Beau
` (5 preceding siblings ...)
2003-06-21 15:56 ` Adrien Beau
@ 2003-06-21 16:11 ` Adrien Beau
2003-06-22 6:31 ` Adrien Beau
2003-06-27 15:15 ` Adrien Beau
8 siblings, 0 replies; 10+ messages in thread
From: Adrien Beau @ 2003-06-21 16:11 UTC (permalink / raw)
To: linux-hotplug
On Friday 20 June 2003 21:18, Kevin P. Fleming wrote:
>
> Adrien Beau wrote:
> > * When two instances of the script are run at a few seconds
> > interval, the lockfile mechanism works fine (again, see for
> > example June 17th), but when three instances run at the same
> > time, the mechanism fails in an impossible manner (see the
> > log entries starting on June 20th, at 12:15pm for the first
> > occurence of this, and see the entries at 12:55:55pm for an
> > occurence with the timestamps printed in the logs).
>
> I suspect your problem is that you are using timestamps for
> this log checking, and the timestamp granularity is too coarse.
It is coarse, but it shouldn't matter: if the two timestamps are
equal, or off by one, their difference is obviously less than
60 seconds. The script should then consider there's a fresh
lockfile, and should bail out. This is what it does when two
scripts are run at a few seconds interval.
My problem is that the script manages to find that the lockfile
exists, manages to read the timestamp from the logfile, but
then somehow decides that the difference between the timestamp
and the current time is more than 60 seconds! However, as the
logfile shows, the difference is never more than 1 second.
Something weird is happening behind the scenes.
> When the USB core decides to generate hotplug events for all
> three interfaces of a device it just found, those three
> /sbin/hotplug invocations are going to happen very quickly,
> certainly within a small fraction of a second.
This is what happens indeed.
> You'll need to find some other way of knowing when a lockfile
> exists and is stale... something that can handle more than one
> process that is started at identical times (or nearly so).
Even with the very short interval between them, the scripts find
without error that the lockfile exists, and read it without error.
However, they then go to decide that 1 is greater than 60, and
*that*, I can't understand.
I'm going to put some sleep(1) at appropriate places and see if
this helps.
--
adrien.beau@free.fr - http://adrien.beau.free.fr/
-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
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] 10+ messages in thread* Re: Hotplug bug in Linux 2.4.21?
2003-06-20 17:25 Hotplug bug in Linux 2.4.21? Adrien Beau
` (6 preceding siblings ...)
2003-06-21 16:11 ` Adrien Beau
@ 2003-06-22 6:31 ` Adrien Beau
2003-06-27 15:15 ` Adrien Beau
8 siblings, 0 replies; 10+ messages in thread
From: Adrien Beau @ 2003-06-22 6:31 UTC (permalink / raw)
To: linux-hotplug
On Saturday 21 June 2003 18:11, Adrien Beau wrote:
>
> > You'll need to find some other way of knowing when a lockfile
> > exists and is stale... something that can handle more than
> > one process that is started at identical times (or nearly
> > so).
>
> Even with the very short interval between them, the scripts
> find without error that the lockfile exists, and read it
> without error. However, they then go to decide that 1 is
> greater than 60, and *that*, I can't understand.
>
> I'm going to put some sleep(1) at appropriate places and see if
> this helps.
It quickly turned out that this was a wrong idea, since the scripts
are started at the same time. It only makes things worse, since the
the lockfile then disappears while a script is sleeping.
It doesn't matter any more, though, since I have found a solution to
this problem. I tried to find what made the test fail. It turns out
that
expr $currenttime '-' $timestamp '<' $MAX_LOCK_AGE
returns 1 to stdout, which means that indeed, expr thinks that 0 or 1
are less than 60. The bug is that, when run in "normal" conditions,
at a few seconds interval, the above command has an exit status of 0,
but when run in "stress" conditions, at a few hundredth of seconds
interval, its exit status is 1. That's just weird (a bug in the kernel
or glibc, or what?), but that can be worked around. I ended up using
[ `expr $currenttime '-' $timestamp` -lt $MAX_LOCK_AGE ]
instead, which works fine.
--
adrien.beau@free.fr - http://adrien.beau.free.fr/
-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
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] 10+ messages in thread* Re: Hotplug bug in Linux 2.4.21?
2003-06-20 17:25 Hotplug bug in Linux 2.4.21? Adrien Beau
` (7 preceding siblings ...)
2003-06-22 6:31 ` Adrien Beau
@ 2003-06-27 15:15 ` Adrien Beau
8 siblings, 0 replies; 10+ messages in thread
From: Adrien Beau @ 2003-06-27 15:15 UTC (permalink / raw)
To: linux-hotplug
For the sake of completeness:
On Sunday 22 June 2003 08:31, Adrien Beau wrote:
>
> It doesn't matter any more, though, since I have found a
> solution to this problem.
(...)
> I ended up using
>
> [ `expr $currenttime '-' $timestamp` -lt $MAX_LOCK_AGE ]
>
> instead, which works fine.
Which works better, actually, but sometimes still fails. I've
also had cases where all three tests for the existence of the
lockfile would run at the same time, before it was created.
I've solved this problem by storing the pid in the lockfile,
so a script instance can know if its lockfile got overwritten.
Now it works fine.
--
adrien.beau@free.fr - http://adrien.beau.free.fr/
-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
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] 10+ messages in thread