Files
kernel-tenderloin-3.0/include/linux
Tejun Heo 77ea887e43 implement in-kernel gendisk events handling
Currently, media presence polling for removeable block devices is done
from userland.  There are several issues with this.

* Polling is done by periodically opening the device.  For SCSI
  devices, the command sequence generated by such action involves a
  few different commands including TEST_UNIT_READY.  This behavior,
  while perfectly legal, is different from Windows which only issues
  single command, GET_EVENT_STATUS_NOTIFICATION.  Unfortunately, some
  ATAPI devices lock up after being periodically queried such command
  sequences.

* There is no reliable and unintrusive way for a userland program to
  tell whether the target device is safe for media presence polling.
  For example, polling for media presence during an on-going burning
  session can make it fail.  The polling program can avoid this by
  opening the device with O_EXCL but then it risks making a valid
  exclusive user of the device fail w/ -EBUSY.

* Userland polling is unnecessarily heavy and in-kernel implementation
  is lighter and better coordinated (workqueue, timer slack).

This patch implements framework for in-kernel disk event handling,
which includes media presence polling.

* bdops->check_events() is added, which supercedes ->media_changed().
  It should check whether there's any pending event and return if so.
  Currently, two events are defined - DISK_EVENT_MEDIA_CHANGE and
  DISK_EVENT_EJECT_REQUEST.  ->check_events() is guaranteed not to be
  called parallelly.

* gendisk->events and ->async_events are added.  These should be
  initialized by block driver before passing the device to add_disk().
  The former contains the mask of all supported events and the latter
  the mask of all events which the device can report without polling.
  /sys/block/*/events[_async] export these to userland.

* Kernel parameter block.events_dfl_poll_msecs controls the system
  polling interval (default is 0 which means disable) and
  /sys/block/*/events_poll_msecs control polling intervals for
  individual devices (default is -1 meaning use system setting).  Note
  that if a device can report all supported events asynchronously and
  its polling interval isn't explicitly set, the device won't be
  polled regardless of the system polling interval.

* If a device is opened exclusively with write access, event checking
  is automatically disabled until all write exclusive accesses are
  released.

* There are event 'clearing' events.  For example, both of currently
  defined events are cleared after the device has been successfully
  opened.  This information is passed to ->check_events() callback
  using @clearing argument as a hint.

* Event checking is always performed from system_nrt_wq and timer
  slack is set to 25% for polling.

* Nothing changes for drivers which implement ->media_changed() but
  not ->check_events().  Going forward, all drivers will be converted
  to ->check_events() and ->media_change() will be dropped.

Signed-off-by: Tejun Heo <tj@kernel.org>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
2010-12-16 17:53:38 +01:00
..
2010-10-30 08:31:35 -07:00
2010-08-12 06:38:24 +10:00
2010-10-15 21:18:59 +02:00
2010-10-26 14:51:00 -04:00
2010-09-23 14:33:39 -07:00
2010-10-30 08:45:43 -04:00
2010-11-10 14:54:09 +01:00
2010-11-10 14:54:09 +01:00
2010-10-25 21:18:20 -04:00
2010-10-25 08:02:40 -07:00
2010-08-06 15:36:47 -05:00
2010-08-19 17:18:00 -07:00
2010-08-12 04:14:05 +01:00
2010-10-22 15:55:22 +02:00
2010-10-21 14:47:59 +02:00
2010-09-23 14:33:39 -07:00
2010-10-28 17:22:16 -04:00
2010-08-19 17:18:03 -07:00
2010-08-18 08:35:46 -04:00
2010-09-09 20:46:30 +02:00
2010-10-25 14:11:37 -07:00
2010-10-23 22:49:32 +02:00
2010-10-12 16:53:37 +02:00
2010-08-11 09:23:22 +02:00
2010-11-15 22:40:38 +01:00
2010-11-15 22:40:38 +01:00
2010-09-21 18:04:47 -07:00
2010-08-29 21:57:55 -07:00
2010-08-19 17:16:23 -07:00
2010-09-30 21:16:05 -07:00
2010-10-26 16:52:08 -07:00
2010-08-09 20:45:05 -07:00
2010-10-07 14:08:55 +01:00
2010-08-10 11:49:21 -07:00
2010-08-18 10:19:52 +02:00
2010-08-12 11:27:58 +02:00
2010-10-28 17:22:13 -04:00
2010-10-22 15:34:12 -05:00
2010-08-19 17:18:00 -07:00
2010-09-09 18:57:24 -07:00
2010-11-12 07:55:32 -08:00
2010-10-21 21:18:54 -04:00
2010-10-25 21:24:15 -04:00
2010-10-28 09:08:47 -05:00
2010-08-09 16:48:45 -04:00
2010-10-26 16:52:05 -07:00
2010-08-11 00:29:47 -04:00
2010-10-12 16:53:34 +02:00
2010-10-04 21:10:52 +02:00
2010-10-04 21:10:52 +02:00
2010-10-01 17:18:59 -04:00
2010-10-07 18:48:49 -04:00
2010-08-19 17:18:02 -07:00
2010-10-15 12:45:44 +02:00
2010-10-17 20:03:03 -07:00
2010-10-17 20:03:06 -07:00
2010-10-24 15:07:11 -07:00
2010-08-21 23:40:14 -07:00
2010-11-12 07:55:32 -08:00
2010-10-29 04:16:31 -04:00
2010-09-08 18:16:55 -07:00
2010-08-09 16:47:27 -04:00
2010-10-25 21:18:20 -04:00
2010-10-27 18:03:16 -07:00
2010-10-05 00:29:48 -07:00
2010-10-30 12:12:50 +02:00
2010-10-20 03:02:23 -07:00
2010-10-21 15:44:13 +02:00
2010-10-27 17:28:36 +01:00
2010-10-07 14:08:55 +01:00
2010-08-09 16:48:44 -04:00
2010-09-24 21:27:41 -07:00
2010-08-30 13:23:33 -07:00
2010-10-21 04:11:07 -07:00
2010-09-09 20:41:20 +02:00
2010-10-22 10:20:04 -07:00
2010-11-09 14:36:23 -08:00
2010-10-26 16:52:03 -07:00
2010-10-22 10:16:43 -07:00
2010-11-08 12:28:32 -08:00
2010-10-26 16:52:14 -07:00