History

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.

Martin Wilck committed 7 years ago

Commit c92e2f01 parent 673387a4 files · +20 −5Browse files

Showing the changes to include/linux (1 of 4 files). Show all

Unified · Split

include/linux/genhd.h+9−1
@@ -150,6 +150,13 @@ enum { · 149 unmodified lines
150 DISK_EVENT_EJECT_REQUEST = 1 << 1, /* eject requested */150 DISK_EVENT_EJECT_REQUEST = 1 << 1, /* eject requested */
151};151};
152 152
153enum {
154 /* Poll even if events_poll_msecs is unset */
155 DISK_EVENT_FLAG_POLL = 1 << 0,
156 /* Forward events to udev */
157 DISK_EVENT_FLAG_UEVENT = 1 << 1,
158};
159
153struct disk_part_tbl {160struct disk_part_tbl {
154 struct rcu_head rcu_head;161 struct rcu_head rcu_head;
155 int len;162 int len;
@@ -184,7 +191,8 @@ struct gendisk { · 28 unmodified lines
184 char disk_name[DISK_NAME_LEN]; /* name of major driver */191 char disk_name[DISK_NAME_LEN]; /* name of major driver */
185 char *(*devnode)(struct gendisk *gd, umode_t *mode);192 char *(*devnode)(struct gendisk *gd, umode_t *mode);
186 193
187 unsigned int events; /* supported events */194 unsigned short events; /* supported events */
195 unsigned short event_flags; /* flags related to event processing */
188 196
189 /* Array of pointers to partitions indexed by partno.197 /* Array of pointers to partitions indexed by partno.
190 * Protected with matching bdev lock but stat and other198 * Protected with matching bdev lock but stat and other

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t