* udev no longer passes USB device remove events
@ 2007-12-26 22:12 Anthony L. Awtrey
2007-12-29 15:54 ` Anthony L. Awtrey
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Anthony L. Awtrey @ 2007-12-26 22:12 UTC (permalink / raw)
To: linux-hotplug
Hello the list,
I've got a puzzler that I hope someone can help me with. When I upgraded
from Debian Etch to the Debian Lenny pre-release, I noticed that a
simple system tray app to indicate when a device was plugged into my
various USB ports stopped working. It would light up, but never go off.
I dug around and finally discovered that udev-114 no longer passed the
'remove' 'usb' events that udev-105 did without fail. I filed some
additional details with the Debian BTS:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bugE7616
Note that 'udevmonitor --kernel' shows the remove event coming in, but
that 'udevmonitor --udev' never shows the remove event being passed. I
also dialed up the logging and traced an insertion and removal of a USB
drive. The interesting bit is in the removal section:
Dec 23 22:15:13 dhcp-141 udevd[2199]: udev_event_run: seq 2614 forked,
pid [11386], 'remove' 'usb', 0
seconds old
Dec 23 22:15:13 dhcp-141 udevd-event[11386]: udev_db_get_device: found a
symlink as db file
Dec 23 22:15:13 dhcp-141 udevd-event[11386]: name_index: removing index:
... 8< long dev name >8 ...
Dec 23 22:15:13 dhcp-141 udevd-event[11386]: udev_event_run: seq 2614
finished with -1
Dec 23 22:15:13 dhcp-141 udevd[2199]: udev_done: seq 2614, pid [11386]
exit with 1, 0 seconds old
It looks, to my uneducated eye, that the udevd-event function fails.
Note that this is the only time that particular function fails in all
the activity associated with inserting and removing the USB device.
I tried out the latest udev-118 to see if it still has this issue and
found that about 1 in 4 times I inserted/removed the device I would get
a remove event, but the other times it would fail like it does under
udev-114. I noted that the few times it worked, the event happened to
complete last (e.g. there were no other events processed after it) and
every time it failed there were some additional remove events still
processing, particularly 'remove' 'block' events. I found that udev-105
worked very reliably when I tried it with Lenny.
Could this be some kind of timing issue? Does anyone with familiarity
with the code see something that could help me? Thanks in advance.
Tony
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
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] 5+ messages in thread
* Re: udev no longer passes USB device remove events
2007-12-26 22:12 udev no longer passes USB device remove events Anthony L. Awtrey
@ 2007-12-29 15:54 ` Anthony L. Awtrey
2007-12-29 16:40 ` Kay Sievers
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Anthony L. Awtrey @ 2007-12-29 15:54 UTC (permalink / raw)
To: linux-hotplug
Hello again,
I fixed my problem, but not the right way. One thing that tripped me
when I was investigating this issue was that when you issue a
"udevcontrol log_priorityÞbug" you don't actually get dbg() messages
in the syslog. Therefore my log dump looked like silent failure to me.
Once I found the function I suspected to cause the trouble, I changed
the dgb() functions to info() and could see this:
udev_node_remove: device node '/dev/bus/usb/004/007' not found
It looks like udev is failing to remove a non-existant device node and
returning -1. Raw USB devices don't necessarily have device nodes to
remove, so the perfectly reasonable "remove usb" events are failing for
no good reason that I can tell.
I fixed my problem by allowing the function udev_node_remove() to return
0 on device node remove failures:
...
int udev_node_remove(struct udevice *udev)
{
char filename[PATH_SIZE];
char partitionname[PATH_SIZE];
struct stat stats;
int retval = 0;
int num;
strlcpy(filename, udev_root, sizeof(filename));
strlcat(filename, "/", sizeof(filename));
strlcat(filename, udev->name, sizeof(filename));
if (stat(filename, &stats) != 0) {
dbg("device node '%s' not found", filename);
return 0; /* <--- LOOK */
}
...
I don't know the other implications, but it appears to work and does not
cause any other obvious problems in my limited testing. Can anyone
suggest a more appropriate fix?
Tony
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
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] 5+ messages in thread
* Re: udev no longer passes USB device remove events
2007-12-26 22:12 udev no longer passes USB device remove events Anthony L. Awtrey
2007-12-29 15:54 ` Anthony L. Awtrey
@ 2007-12-29 16:40 ` Kay Sievers
2007-12-29 18:40 ` Anthony L. Awtrey
2007-12-29 18:55 ` Kay Sievers
3 siblings, 0 replies; 5+ messages in thread
From: Kay Sievers @ 2007-12-29 16:40 UTC (permalink / raw)
To: linux-hotplug
On Dec 29, 2007 4:54 PM, Anthony L. Awtrey <tony@awtrey.com> wrote:
> I fixed my problem, but not the right way. One thing that tripped me
> when I was investigating this issue was that when you issue a
> "udevcontrol log_priorityÞbug" you don't actually get dbg() messages
> in the syslog. Therefore my log dump looked like silent failure to me.
> Once I found the function I suspected to cause the trouble, I changed
> the dgb() functions to info() and could see this:
The dbg() macro is usually not compiled into the binaries, you have to
enable this at compile-time.
> udev_node_remove: device node '/dev/bus/usb/004/007' not found
>
> It looks like udev is failing to remove a non-existant device node and
> returning -1. Raw USB devices don't necessarily have device nodes to
> remove,
No, every usb_device has a device node. And udev will only try to remove a node
when the kernel passes a major/minor number. Seems there is something strange
going on on your system.
> so the perfectly reasonable "remove usb" events are failing for
> no good reason that I can tell.
Yeah, that should not prevent the RUN execution.
> I fixed my problem by allowing the function udev_node_remove() to return
> 0 on device node remove failures:
> I don't know the other implications, but it appears to work and does not
> cause any other obvious problems in my limited testing. Can anyone
> suggest a more appropriate fix?
Looks fine, we should not fail if it's already gone. I applied the patch:
http://git.kernel.org/?p=linux/hotplug/udev.git;a=commitdiff;h 092d28dbb2c1c75c2fac17303b703343f03a35
Thanks,
Kay
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
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] 5+ messages in thread
* Re: udev no longer passes USB device remove events
2007-12-26 22:12 udev no longer passes USB device remove events Anthony L. Awtrey
2007-12-29 15:54 ` Anthony L. Awtrey
2007-12-29 16:40 ` Kay Sievers
@ 2007-12-29 18:40 ` Anthony L. Awtrey
2007-12-29 18:55 ` Kay Sievers
3 siblings, 0 replies; 5+ messages in thread
From: Anthony L. Awtrey @ 2007-12-29 18:40 UTC (permalink / raw)
To: linux-hotplug
On 12/29/2007 11:40 AM, Kay Sievers wrote:
> No, every usb_device has a device node. And udev will only try to remove a node
> when the kernel passes a major/minor number. Seems there is something strange
> going on on your system.
FYI, this behavior also occurs on stock Debian Lenny pre-release that I
installed on 12-26-2007. I filed the appropriate Debian BTS report, so
Mario should now be aware of it as well. I'll post an update alerting of
your patch for the issue.
Thanks so much for the response, Kay!
Tony
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
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] 5+ messages in thread
* Re: udev no longer passes USB device remove events
2007-12-26 22:12 udev no longer passes USB device remove events Anthony L. Awtrey
` (2 preceding siblings ...)
2007-12-29 18:40 ` Anthony L. Awtrey
@ 2007-12-29 18:55 ` Kay Sievers
3 siblings, 0 replies; 5+ messages in thread
From: Kay Sievers @ 2007-12-29 18:55 UTC (permalink / raw)
To: linux-hotplug
On Dec 29, 2007 7:40 PM, Anthony L. Awtrey <tony@awtrey.com> wrote:
> On 12/29/2007 11:40 AM, Kay Sievers wrote:
> > No, every usb_device has a device node. And udev will only try to remove a node
> > when the kernel passes a major/minor number. Seems there is something strange
> > going on on your system.
>
> FYI, this behavior also occurs on stock Debian Lenny pre-release that I
> installed on 12-26-2007. I filed the appropriate Debian BTS report, so
> Mario should now be aware of it as well. I'll post an update alerting of
> your patch for the issue.
I guess the kernel has the deprecated CONFIG_USB_DEVICE_CLASS set,
and udev has rules for the new and the old devices to create the same
device nodes. Without the fix, the node gets deleted by the other event.
Does commenting out the rule which starts with:
SUBSYSTEM="usb_device", ...
make the problem go away?
Kay
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2005.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
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] 5+ messages in thread
end of thread, other threads:[~2007-12-29 18:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-26 22:12 udev no longer passes USB device remove events Anthony L. Awtrey
2007-12-29 15:54 ` Anthony L. Awtrey
2007-12-29 16:40 ` Kay Sievers
2007-12-29 18:40 ` Anthony L. Awtrey
2007-12-29 18:55 ` Kay Sievers
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).