Lines Matching full:disk
3 * Disk events - monitor disk events like media change and eject request.
12 struct gendisk *disk; /* the associated disk */ member
41 static unsigned long disk_events_poll_jiffies(struct gendisk *disk) in disk_events_poll_jiffies() argument
43 struct disk_events *ev = disk->ev; in disk_events_poll_jiffies()
52 else if (disk->event_flags & DISK_EVENT_FLAG_POLL) in disk_events_poll_jiffies()
59 * disk_block_events - block and flush disk event checking
60 * @disk: disk to block events for
73 void disk_block_events(struct gendisk *disk) in disk_block_events() argument
75 struct disk_events *ev = disk->ev; in disk_block_events()
93 cancel_delayed_work_sync(&disk->ev->dwork); in disk_block_events()
98 static void __disk_unblock_events(struct gendisk *disk, bool check_now) in __disk_unblock_events() argument
100 struct disk_events *ev = disk->ev; in __disk_unblock_events()
112 intv = disk_events_poll_jiffies(disk); in __disk_unblock_events()
124 * disk_unblock_events - unblock disk event checking
125 * @disk: disk to unblock events for
133 void disk_unblock_events(struct gendisk *disk) in disk_unblock_events() argument
135 if (disk->ev) in disk_unblock_events()
136 __disk_unblock_events(disk, false); in disk_unblock_events()
141 * @disk: disk to check and flush events for
144 * Schedule immediate event checking on @disk if not blocked. Events in
146 * doesn't clear the events from @disk->ev.
149 * If @mask is non-zero must be called with disk->open_mutex held.
151 void disk_flush_events(struct gendisk *disk, unsigned int mask) in disk_flush_events() argument
153 struct disk_events *ev = disk->ev; in disk_flush_events()
167 * Tell userland about new events. Only the events listed in @disk->events are
171 static void disk_event_uevent(struct gendisk *disk, unsigned int events) in disk_event_uevent() argument
177 if (events & disk->events & (1 << i)) in disk_event_uevent()
181 kobject_uevent_env(&disk_to_dev(disk)->kobj, KOBJ_CHANGE, envp); in disk_event_uevent()
187 struct gendisk *disk = ev->disk; in disk_check_events() local
193 events = disk->fops->check_events(disk, clearing); in disk_check_events()
202 intv = disk_events_poll_jiffies(disk); in disk_check_events()
210 inc_diskseq(disk); in disk_check_events()
212 if (disk->event_flags & DISK_EVENT_FLAG_UEVENT) in disk_check_events()
213 disk_event_uevent(disk, events); in disk_check_events()
218 * @disk: disk to fetch and clear events from
221 * Disk events are synchronously checked and pending events in @mask
227 static unsigned int disk_clear_events(struct gendisk *disk, unsigned int mask) in disk_clear_events() argument
229 struct disk_events *ev = disk->ev; in disk_clear_events()
236 disk_block_events(disk); in disk_clear_events()
253 __disk_unblock_events(disk, ev->clearing ? true : false); in disk_clear_events()
294 * @disk: the disk which will raise the event
297 * Generate uevents for the disk. If DISK_EVENT_MEDIA_CHANGE is present,
303 bool disk_force_media_change(struct gendisk *disk, unsigned int events) in disk_force_media_change() argument
305 disk_event_uevent(disk, events); in disk_force_media_change()
310 if (__invalidate_device(disk->part0, true)) in disk_force_media_change()
312 disk->disk_name); in disk_force_media_change()
313 set_bit(GD_NEED_PART_SCAN, &disk->state); in disk_force_media_change()
331 * A disk events enabled device has the following sysfs nodes under
359 struct gendisk *disk = dev_to_disk(dev); in disk_events_show() local
361 if (!(disk->event_flags & DISK_EVENT_FLAG_UEVENT)) in disk_events_show()
363 return __disk_events_show(disk->events, buf); in disk_events_show()
376 struct gendisk *disk = dev_to_disk(dev); in disk_events_poll_msecs_show() local
378 if (!disk->ev) in disk_events_poll_msecs_show()
380 return sprintf(buf, "%ld\n", disk->ev->poll_msecs); in disk_events_poll_msecs_show()
387 struct gendisk *disk = dev_to_disk(dev); in disk_events_poll_msecs_store() local
396 if (!disk->ev) in disk_events_poll_msecs_store()
399 disk_block_events(disk); in disk_events_poll_msecs_store()
400 disk->ev->poll_msecs = intv; in disk_events_poll_msecs_store()
401 __disk_unblock_events(disk, true); in disk_events_poll_msecs_store()
428 disk_flush_events(ev->disk, 0); in disk_events_set_dfl_poll_msecs()
447 int disk_alloc_events(struct gendisk *disk) in disk_alloc_events() argument
451 if (!disk->fops->check_events || !disk->events) in disk_alloc_events()
456 pr_warn("%s: failed to initialize events\n", disk->disk_name); in disk_alloc_events()
461 ev->disk = disk; in disk_alloc_events()
468 disk->ev = ev; in disk_alloc_events()
472 void disk_add_events(struct gendisk *disk) in disk_add_events() argument
474 if (!disk->ev) in disk_add_events()
478 list_add_tail(&disk->ev->node, &disk_events); in disk_add_events()
485 __disk_unblock_events(disk, true); in disk_add_events()
488 void disk_del_events(struct gendisk *disk) in disk_del_events() argument
490 if (disk->ev) { in disk_del_events()
491 disk_block_events(disk); in disk_del_events()
494 list_del_init(&disk->ev->node); in disk_del_events()
499 void disk_release_events(struct gendisk *disk) in disk_release_events() argument
502 WARN_ON_ONCE(disk->ev && disk->ev->block != 1); in disk_release_events()
503 kfree(disk->ev); in disk_release_events()