[OpenWrt-Devel] block info and DISK_MEDIA_CHANGE events

Karl Palsson karlp at tweak.net.au
Sat Feb 20 15:08:19 EST 2016


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

John Crispin <blogic at openwrt.org> wrote:
> 
> 
> On 19/02/2016 18:00, Karl Palsson wrote:
> > Hi,
> > 
> > I'm trying to get "block mount" to behave well when a microSD
> > card is removed/inserted from a fixed USB card reader. I've
> > compiled the uevent-hotplug debugger example from
> > https://www.kernel.org/doc/pending/hotplug.txt and running that
> > on my device, I can see that "block info" is somehow triggering
> > the uevent change notifications I hope. (I can't see anywhere in
> > the fstools how the uevent is triggered, but it only happens if I
> > run "block info" manually, "blkid" doesn't trigger any events, so
> > it's something in block info
> > 
> > Example event (unfortuntely it's identical for card inserted ->
> > removed and for removed -> inserted)
> > ```
> > change@/devices/platform/ehci-platform/usb1/1-1/1-1.1/1-1.1:1.0/host0/target0:0:0/0:0:0:0/block/sda
> > ACTION=change
> > DEVPATH=/devices/platform/ehci-platform/usb1/1-1/1-1.1/1-1.1:1.0/host0/target0:0:0/0:0:0:0/block/sda
> > SUBSYSTEM=block DISK_MEDIA_CHANGE=1 MAJOR=8 MINOR=0 DEVNAME=sda
> > DEVTYPE=disk SEQNUM=637
> > ```
> > 
> 
> 
> fstools/libblkid-tiny/libblkid-tiny.c: probe_block()
> 
> does an open() on the device node which will eventually end up
> inside
> 
> drivers/scsi/sd.c: sd_open()
> 
> which will call check_disk_change(bdev);
> 
> and that triggers the uevent.

Ahh, thanks.

> 
> i am not sure how you can get it to automatically send the
> event without polling it.

I can live with that, my real concern is that I want it to be
unmounted/mounted. Should "block hotplug" be handling this to
add/remove? I can work on adding this to handle the change
events, but is that the right way, and would that be accepted, or
should something else be converting them into add/remove events
elsewhere? On desktop linux, I see the change event with
DISK_MEDIA_CHANGE=1, then a subsequent add/remove event.

As for automatically getting the event, I can enable the kernel
event polling, by setting /sys/block/sda/events_poll_msecs to
~500ms or so, and I can then see the SCSI LUN check commands with
usbmon, and I can see the responses change as soon as the card is
inserted/removed, but no events come out. I kinda feel that's
something I should take up upstream, but I'm perfectly ok with
having to poll "block info" at the moment.

Sincerely,
Karl P

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iQIcBAEBAgAGBQJWyMezAAoJEBmotQ/U1cr2xQsP/2nC9BiSIcMwR/2QZg4QvvyR
65+uZ7cRoGutmPd2V7QQu/ZAtwET9lft8CgYh5uY1htNEvVTjEagz1+1yAjrqAau
Uc4uEOmwteXupIIAQeB/nTheAugfvt8+PhzXAAxyHxtV4udyYdM0wp8sDFvw201/
R2n9fgDyz8Oyw+qtf3vNPZcHXHGb7ewM8GTxkjnkeKMTCt307hDjh3uAVBNQvdem
3sQpx13nMgfbT6jVlXya8QMvOozW5P/1w9cOJUPDlAgdeZd3H6WbZ9YI1mivJgUa
F/LTfmheHqwXPj6HTVZ7nuHe10SqXRjrDike88FxjOtyp/gg7tleuWNSzZ8Rq8gj
40JHU9HdUJ5CWKMGjnI10gbj/zW9s+9OiLRWHUHW242WLIe3lTckosyPLoKi2VtB
svqqv3aNnHM0Esf1EKDVFiu0KqP0cZWaE+UOGRm+kp/+4pp35l5mOtzonZtbLWF5
FOR4y/fJmJmpwi9MrNo6e1fPxpr+IxSv6bmNvH2mEvbX9DspH3a8tJX6AsQsVweJ
s6D1N+QQnHNEnIF2gXvGwLAGvItlifJM3p+4v9dUBb5XQtHxzraVkW7ygx5XfOhn
MWc9MxDwlEYJd0DIPWAQ8ORrEfkJ+49oklnGWjxAe48K/A5jx2zs/Ve7YMpATMp7
nDRP9DPTizzcQcHH3gA8
=Hdwm
-----END PGP SIGNATURE-----
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list