1. 16 Dec, 2010 6 commits
    • Tejun Heo's avatar
      scsi: replace sr_test_unit_ready() with scsi_test_unit_ready() · 9f8a2c23
      Tejun Heo authored
      The usage of TUR has been confusing involving several different
      commits updating different parts over time.  Currently, the only
      differences between scsi_test_unit_ready() and sr_test_unit_ready()
      are,
      
      * scsi_test_unit_ready() also sets sdev->changed on NOT_READY.
      
      * scsi_test_unit_ready() returns 0 if TUR ended with UNIT_ATTENTION or
        NOT_READY.
      
      Due to the above two differences, sr is using its own
      sr_test_unit_ready(), but sd - the sole user of the above extra
      handling - doesn't even need them.
      
      Where scsi_test_unit_ready() is used in sd_media_changed(), the code
      is looking for device ready w/ media present state which is true iff
      TUR succeeds w/o sense data or UA, and when the device is not ready
      for whatever reason sd_media_changed() explicitly marks media as
      missing so there's no reason to set sdev->changed automatically from
      scsi_test_unit_ready() on NOT_READY.
      
      Drop both special handlings from scsi_test_unit_ready(), which makes
      it equivalant to sr_test_unit_ready(), and replace
      sr_test_unit_ready() with scsi_test_unit_ready().  Also, drop the
      unnecessary explicit NOT_READY check from sd_media_changed().
      Checking return value is enough for testing device readiness.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJens Axboe <jaxboe@fusionio.com>
      9f8a2c23
    • Tejun Heo's avatar
      scsi: fix TUR error handling in sr_media_change() · 638428ec
      Tejun Heo authored
      sr_test_unit_ready() returns 0 iff TUR succeeded - IOW, when media is
      present and the device is actually ready, so the return value wouldn't
      be zero when TUR ends with sense data. sr_media_change() incorrectly
      tests (retval || (scsi_sense_valid(sshdr)...)) when it tries to test
      whether TUR failed without sense data or with sense data indicating
      media-not-present.
      
      Fix the test using scsi_status_is_good() and update comments.
      
      - Fixed a comment typo spotted by Eike.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Rolf Eike Beer <eike-kernel@sf-tec.de>
      Signed-off-by: default avatarJens Axboe <jaxboe@fusionio.com>
      638428ec
    • Tejun Heo's avatar
      cdrom: add ->check_events() support · 2d921729
      Tejun Heo authored
      In principle, cdrom just needs to pass through ->check_events() but
      CDROM_MEDIA_CHANGED ioctl makes things a bit more complex.  Just as
      with ->media_changed() support, cdrom code needs to buffer the events
      and serve them to ioctl and vfs as requested.
      
      As the code has to deal with both ->check_events() and
      ->media_changed(), and vfs and ioctl event buffering, this patch adds
      check_events caching on top of the existing cdi->mc_flags buffering.
      
      It may be a good idea to deprecate CDROM_MEDIA_CHANGED ioctl and
      remove all this mess.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJens Axboe <jaxboe@fusionio.com>
      2d921729
    • Tejun Heo's avatar
      implement in-kernel gendisk events handling · 77ea887e
      Tejun Heo authored
      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: default avatarTejun Heo <tj@kernel.org>
      Cc: Kay Sievers <kay.sievers@vrfy.org>
      Cc: Jan Kara <jack@suse.cz>
      Signed-off-by: default avatarJens Axboe <jaxboe@fusionio.com>
      77ea887e
    • Tejun Heo's avatar
      block: move register_disk() and del_gendisk() to block/genhd.c · d2bf1b67
      Tejun Heo authored
      There's no reason for register_disk() and del_gendisk() to be in
      fs/partitions/check.c.  Move both to genhd.c.  While at it, collapse
      unlink_gendisk(), which was artificially in a separate function due to
      genhd.c / check.c split, into del_gendisk().
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJens Axboe <jaxboe@fusionio.com>
      d2bf1b67
    • Tejun Heo's avatar
      block: kill genhd_media_change_notify() · dddd9dc3
      Tejun Heo authored
      There's no user of the facility.  Kill it.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Signed-off-by: default avatarJens Axboe <jaxboe@fusionio.com>
      dddd9dc3
  2. 13 Dec, 2010 1 commit
  3. 30 Nov, 2010 2 commits
  4. 27 Nov, 2010 1 commit
  5. 16 Nov, 2010 4 commits
  6. 15 Nov, 2010 26 commits