[prev in list] [next in list] [prev in thread] [next in thread] 

List:       busybox
Subject:    Re: Receiving two REMOVE actions for the same USB drive
From:       Mason <mpeg.blue () free ! fr>
Date:       2014-04-29 14:49:25
Message-ID: 535FBBF5.80905 () free ! fr
[Download RAW message or body]

Isaac Dunham wrote:
> On Mon, Apr 28, 2014 at 06:03:01PM +0200, Mason wrote:
>> Isaac Dunham wrote:
>>
>>> Mason wrote:
>>>
>>>> Ralf Friedl wrote:
>>>>
>>>>> If you say that simple filtering of the events would be annoying, you 
>>>>> don't want to change the kernel to avoid the double notification.
>>>>
>>>> What do you mean by "you don't want to change the kernel" ?
>>>>
>>>> I am /pretty sure/ that the vanilla kernel does not notify twice,
>>>> and that this bug was introduced by one of the vendor's patches. 
>>>
>>> A normal kernel will generate _tons_ of messages per USB device.
>>
>> You are correct, of course.
>>
>> This mdev is configured to filter out most of the kernel notifications,
>> as we are only interested in block events.
>>
>> # cat /etc/mdev.conf
>> $SUBSYSTEM=block 0:0 660 ! */application/forward_events
>>
>> When a block device is inserted, I receive
>> - one "add" action for the block device itself
>> - then one "add" action for each partition on the block device
>> (e.g. MDEV=sda, MDEV=sda1, MDEV=sda2, etc)
>>
>> when the device is removed, I should receive the "symmetric" events
>> - one "remove" action for each partition
>> - then one remove action for the block device itself
>>
>> Do you disagree?
>>
>>> Just tested with a random USB device, vanilla kernel 3.10.33;
>>> I get 2x ACTION=add, 2x ACTION=remove
>>
>> What SUBSYSTEM is it for?
>> What are the values of MDEV each time?
> 
> That was SUBSYSTEM=usb, logged without mdev.
> Here is inserting and removing U3 usb drive, likewise logged without mdev.
> ...
> Looks like it's not duplicating remove events for the block subsystem.

If I filter for SUBSYSTEM=block, I see
add sr0, change sr0, add sdb, add sdb2, add sdb1
rem sdb2, rem sdb1, rem sdb, rem sr0

So this looks "kosher" :-)

> If you have two "remove" actions when you pull out a "superfloppy" usb
> drive, I'm curious how many you get with a single-partition usb drive.
> 
> (The thought is that it might be something about one for removal of the
> device, one for removal of the partition...except that when the device
> is the partition, it might be sending two events with the same devname
> for that reason.)

That's a good theory, but...

If I insert a "normal" storage device (one with a partition table,
and e.g. two partitions) then I get:

on insert:
add sda, add sda1, add sda2

on remove:
rem sda2, rem sda1, rem sda, rem sda

The only difference between the two "rem sda" is the DEVPATH:

ACTION=remove
NPARTS=0
HOME=/
SEQNUM=297
MAJOR=8
MDEV=sda
DEVPATH=/devices/platform/OEM-ehci-3.2/usb3/3-1/3-1:1.0/host0/target0:0:0/0:0:0:0/block/sda
SUBSYSTEM=block
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MINOR=0
PWD=/dev
DEVTYPE=disk
+++
ACTION=remove
NPARTS=0
HOME=/
SEQNUM=298
MAJOR=8
MDEV=sda
DEVPATH=/sda
SUBSYSTEM=block
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MINOR=0
PWD=/dev
DEVTYPE=disk

-- 
Regards.
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic