On Wed, 2019-01-16 at 08:35 +0100, Hannes Reinecke wrote: > If the device is _not_ removable we should not start the event > poller as the media will not go away. Having the event poller running > will block the open() call as it will try to flush outstanding > events, > which it can't if the device is in state 'BLOCKED'. So the open() > call > will be stalled until the device state changed, which might be quite > some time depending on the transport. > > Signed-off-by: Hannes Reinecke <hare@xxxxxxxx> I've pondered this some more. Meanwhile I think we should rather fix the generic event handling code in genhd.c. The problem is that this code schedules the check_events() function in some situations (notably, on close(2) via blkdev_put()), even for devices which don't report any supported events in the (struct gendisk)->events field (the sd driver correctly sets the events field depending on the "removable" attribute, but the that only influences the polling behavior, not the call upon close()). It looks weird to me that devices that don't report any supported events would be checked for such events. The reason for this is 7c88a168da80 and follow-ups (7eec77a1, 9fd097b1). For the sake of not confusing userland, these commits sacrificed the information in the generic block layer whether or not a given device actually supports media change events. I'm working on a patch to fix that. Regards, Martin