• Martin Wilck's avatar
    block: disk_events: introduce event flags · c92e2f04
    Martin Wilck authored
    Currently, an empty disk->events field tells the block layer not to
    forward media change events to user space. This was done in commit
    7c88a168 ("block: don't propagate unlisted DISK_EVENTs to userland")
    in order to avoid events from "fringe" drivers to be forwarded to user
    space. By doing so, the block layer lost the information which events
    were supported by a particular block device, and most importantly,
    whether or not a given device supports media change events at all.
    
    Prepare for not interpreting the "events" field this way in the future
    any more. This is done by adding an additional field "event_flags" to
    struct gendisk, and two flag bits that can be set to have the device
    treated like one that had the "events" field set to a non-zero value
    before. This applies only to the sd and sr drivers, which are changed to
    set the new flags.
    
    The new flags are DISK_EVENT_FLAG_POLL to enforce polling of the device
    for synchronous events, and DISK_EVENT_FLAG_UEVENT to tell the
    blocklayer to generate udev events from kernel events.
    
    In order to add the event_flags field to struct gendisk, the events
    field is converted to an "unsigned short"; it doesn't need to hold
    values bigger than 2 anyway.
    
    This patch doesn't change behavior.
    Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
    Signed-off-by: default avatarMartin Wilck <mwilck@suse.com>
    Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
    c92e2f04
sr.c 26 KB