summaryrefslogtreecommitdiff
path: root/include/linux/genhd.h
diff options
context:
space:
mode:
authorMartin Wilck <mwilck@suse.com>2019-03-27 16:51:02 +0300
committerJens Axboe <axboe@kernel.dk>2019-04-12 22:35:24 +0300
commitc92e2f04b35938da23eb9a7f7101cbdd5ac7cdc4 (patch)
treef9ec276b627115f704333935e96787c35e1eb4a1 /include/linux/genhd.h
parent673387a930059fc4ad8060847a1d46f94e702281 (diff)
downloadlinux-c92e2f04b35938da23eb9a7f7101cbdd5ac7cdc4.tar.xz
block: disk_events: introduce event flags
Currently, an empty disk->events field tells the block layer not to forward media change events to user space. This was done in commit 7c88a168da80 ("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: Christoph Hellwig <hch@lst.de> Signed-off-by: Martin Wilck <mwilck@suse.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'include/linux/genhd.h')
-rw-r--r--include/linux/genhd.h10
1 files changed, 9 insertions, 1 deletions
diff --git a/include/linux/genhd.h b/include/linux/genhd.h
index a65d9fc17369..6547c9256d5c 100644
--- a/include/linux/genhd.h
+++ b/include/linux/genhd.h
@@ -150,6 +150,13 @@ enum {
DISK_EVENT_EJECT_REQUEST = 1 << 1, /* eject requested */
};
+enum {
+ /* Poll even if events_poll_msecs is unset */
+ DISK_EVENT_FLAG_POLL = 1 << 0,
+ /* Forward events to udev */
+ DISK_EVENT_FLAG_UEVENT = 1 << 1,
+};
+
struct disk_part_tbl {
struct rcu_head rcu_head;
int len;
@@ -184,7 +191,8 @@ struct gendisk {
char disk_name[DISK_NAME_LEN]; /* name of major driver */
char *(*devnode)(struct gendisk *gd, umode_t *mode);
- unsigned int events; /* supported events */
+ unsigned short events; /* supported events */
+ unsigned short event_flags; /* flags related to event processing */
/* Array of pointers to partitions indexed by partno.
* Protected with matching bdev lock but stat and other