An error occurred fetching the project authors.
  1. 20 Jul, 2012 1 commit
  2. 23 Jun, 2012 1 commit
    • Alan Stern's avatar
      SCSI & usb-storage: add try_rc_10_first flag · 6a0bdffa
      Alan Stern authored
      Several bug reports have been received recently for USB mass-storage
      devices that don't handle READ CAPACITY(16) commands properly.  They
      report bogus sizes, in some cases becoming unusable as a result.
      
      The bugs were triggered by commit
      09b6b51b (SCSI & usb-storage: add
      flags for VPD pages and REPORT LUNS), which caused usb-storage to stop
      overriding the SCSI level reported by devices.  By default, the sd
      driver will try READ CAPACITY(16) first for any device whose level is
      above SCSI_SPC_2.
      
      It seems likely that any device large enough to require the use of
      READ CAPACITY(16) (i.e., 2 TB or more) would be able to handle READ
      CAPACITY(10) commands properly.  Indeed, I don't know of any devices
      that don't handle READ CAPACITY(10) properly.
      
      Therefore this patch (as1559) adds a new flag telling the sd driver
      to try READ CAPACITY(10) before READ CAPACITY(16), and sets this flag
      for every USB mass-storage device.  If a device really is larger than
      2 TB, sd will fall back to READ CAPACITY(16) just as it used to.
      
      This fixes Bugzilla #43391.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Acked-by: default avatarHans de Goede <hdegoede@redhat.com>
      CC: "James E.J. Bottomley" <JBottomley@parallels.com>
      CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
      Cc: stable <stable@vger.kernel.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      6a0bdffa
  3. 17 May, 2012 1 commit
    • Dan Williams's avatar
      [SCSI] sd: limit the scope of the async probe domain · a7a20d10
      Dan Williams authored
      sd injects and synchronizes probe work on the global kernel-wide domain.
      This runs into conflict with PM that wants to perform resume actions in
      async context:
      
      [  494.237079] INFO: task kworker/u:3:554 blocked for more than 120 seconds.
      [  494.294396] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      [  494.360809] kworker/u:3     D 0000000000000000     0   554      2 0x00000000
      [  494.420739]  ffff88012e4d3af0 0000000000000046 ffff88013200c160 ffff88012e4d3fd8
      [  494.484392]  ffff88012e4d3fd8 0000000000012500 ffff8801394ea0b0 ffff88013200c160
      [  494.548038]  ffff88012e4d3ae0 00000000000001e3 ffffffff81a249e0 ffff8801321c5398
      [  494.611685] Call Trace:
      [  494.632649]  [<ffffffff8149dd25>] schedule+0x5a/0x5c
      [  494.674687]  [<ffffffff8104b968>] async_synchronize_cookie_domain+0xb6/0x112
      [  494.734177]  [<ffffffff810461ff>] ? __init_waitqueue_head+0x50/0x50
      [  494.787134]  [<ffffffff8131a224>] ? scsi_remove_target+0x48/0x48
      [  494.837900]  [<ffffffff8104b9d9>] async_synchronize_cookie+0x15/0x17
      [  494.891567]  [<ffffffff8104ba49>] async_synchronize_full+0x54/0x70  <-- here we wait for async contexts to complete
      [  494.943783]  [<ffffffff8104b9f5>] ? async_synchronize_full_domain+0x1a/0x1a
      [  495.002547]  [<ffffffffa00114b1>] sd_remove+0x2c/0xa2 [sd_mod]
      [  495.051861]  [<ffffffff812fe94f>] __device_release_driver+0x86/0xcf
      [  495.104807]  [<ffffffff812fe9bd>] device_release_driver+0x25/0x32  <-- here we take device_lock()
      
      [  853.511341] INFO: task kworker/u:4:549 blocked for more than 120 seconds.
      [  853.568693] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
      [  853.635119] kworker/u:4     D ffff88013097b5d0     0   549      2 0x00000000
      [  853.695129]  ffff880132773c40 0000000000000046 ffff880130790000 ffff880132773fd8
      [  853.758990]  ffff880132773fd8 0000000000012500 ffff88013288a0b0 ffff880130790000
      [  853.822796]  0000000000000246 0000000000000040 ffff88013097b5c8 ffff880130790000
      [  853.886633] Call Trace:
      [  853.907631]  [<ffffffff8149dd25>] schedule+0x5a/0x5c
      [  853.949670]  [<ffffffff8149cc44>] __mutex_lock_common+0x220/0x351
      [  854.001225]  [<ffffffff81304bd7>] ? device_resume+0x58/0x1c4
      [  854.049082]  [<ffffffff81304bd7>] ? device_resume+0x58/0x1c4
      [  854.097011]  [<ffffffff8149ce48>] mutex_lock_nested+0x2f/0x36   <-- here we wait for device_lock()
      [  854.145591]  [<ffffffff81304bd7>] device_resume+0x58/0x1c4
      [  854.192066]  [<ffffffff81304d61>] async_resume+0x1e/0x45
      [  854.237019]  [<ffffffff8104bc93>] async_run_entry_fn+0xc6/0x173  <-- ...while running in async context
      
      Provide a 'scsi_sd_probe_domain' so that async probe actions actions can
      be flushed without regard for the state of PM, and allow for the resume
      path to handle devices that have transitioned from SDEV_QUIESCE to
      SDEV_DEL prior to resume.
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      [alan: uplevel scsi_sd_probe_domain, clarify scsi_device_resume]
      Signed-off-by: default avatarDan Williams <dan.j.williams@intel.com>
      [jejb: remove unneeded config guards in include file]
      Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
      a7a20d10
  4. 27 Mar, 2012 1 commit
  5. 19 Mar, 2012 1 commit
    • Lan Tianyu's avatar
      [SCSI] sd: Add runtime pm in the sd_check_events() · 4e2247b2
      Lan Tianyu authored
      The sd_check_event() will be called periodly even when the device is in the
      suspended status to check media event. The scsi_test_unit_ready() in the
      sd_check_event() will issue scsi cmd request. Issuing scsi request when the
      device is in the suspeneded status will cause problem. For example, when a usb
      flash disk in the suspended status, scsi_test_unit_ready() issues a scsi
      request. The request will be returned as failed because the usb device is not
      active. The patch adds scsi_autopm_get_device() and scsi_autopm_put_device()
      around scsi_test_unit_ready() in the sd_check_event() to resolve such problem.
      Signed-off-by: default avatarLan Tianyu <tianyu.lan@intel.com>
      Acked-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
      4e2247b2
  6. 19 Feb, 2012 2 commits
  7. 09 Feb, 2012 1 commit
    • Alan Stern's avatar
      SCSI & usb-storage: add flags for VPD pages and REPORT LUNS · 09b6b51b
      Alan Stern authored
      This patch (as1507) adds a skip_vpd_pages flag to struct scsi_device
      and a no_report_luns flag to struct scsi_target.  The first is used to
      control whether sd will look at VPD pages for information on block
      provisioning, limits, and characteristics.  The second prevents
      scsi_report_lun_scan() from issuing a REPORT LUNS command.
      
      The patch also modifies usb-storage to set the new flag bits for all
      USB devices and targets, and to stop adjusting the scsi_level value.
      
      Historically we have seen that USB mass-storage devices often don't
      support VPD pages or REPORT LUNS properly.  Until now we have avoided
      these things by setting the scsi_level to SCSI_2 for all USB devices.
      But this has the side effect of storing the LUN bits into the second
      byte of each CDB, and now we have a report of a device which doesn't
      like that.  The best solution is to stop abusing scsi_level and
      instead have separate flags for VPD pages and REPORT LUNS.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Reported-by: default avatarPerry Wagle <wagle@mac.com>
      CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
      Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      09b6b51b
  8. 14 Jan, 2012 2 commits
    • Paolo Bonzini's avatar
      block: fail SCSI passthrough ioctls on partition devices · 0bfc96cb
      Paolo Bonzini authored
      Linux allows executing the SG_IO ioctl on a partition or LVM volume, and
      will pass the command to the underlying block device.  This is
      well-known, but it is also a large security problem when (via Unix
      permissions, ACLs, SELinux or a combination thereof) a program or user
      needs to be granted access only to part of the disk.
      
      This patch lets partitions forward a small set of harmless ioctls;
      others are logged with printk so that we can see which ioctls are
      actually sent.  In my tests only CDROM_GET_CAPABILITY actually occurred.
      Of course it was being sent to a (partition on a) hard disk, so it would
      have failed with ENOTTY and the patch isn't changing anything in
      practice.  Still, I'm treating it specially to avoid spamming the logs.
      
      In principle, this restriction should include programs running with
      CAP_SYS_RAWIO.  If for example I let a program access /dev/sda2 and
      /dev/sdb, it still should not be able to read/write outside the
      boundaries of /dev/sda2 independent of the capabilities.  However, for
      now programs with CAP_SYS_RAWIO will still be allowed to send the
      ioctls.  Their actions will still be logged.
      
      This patch does not affect the non-libata IDE driver.  That driver
      however already tests for bd != bd->bd_contains before issuing some
      ioctl; it could be restricted further to forbid these ioctls even for
      programs running with CAP_SYS_ADMIN/CAP_SYS_RAWIO.
      
      Cc: linux-scsi@vger.kernel.org
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: James Bottomley <JBottomley@parallels.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      [ Make it also print the command name when warning - Linus ]
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      0bfc96cb
    • Paolo Bonzini's avatar
      block: add and use scsi_blk_cmd_ioctl · 577ebb37
      Paolo Bonzini authored
      Introduce a wrapper around scsi_cmd_ioctl that takes a block device.
      
      The function will then be enhanced to detect partition block devices
      and, in that case, subject the ioctls to whitelisting.
      
      Cc: linux-scsi@vger.kernel.org
      Cc: Jens Axboe <axboe@kernel.dk>
      Cc: James Bottomley <JBottomley@parallels.com>
      Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      577ebb37
  9. 09 Jan, 2012 1 commit
  10. 30 Oct, 2011 1 commit
  11. 29 Aug, 2011 1 commit
  12. 24 May, 2011 2 commits
    • Luben Tuikov's avatar
      [SCSI] Retrieve the Caching mode page (version 2) · 0bcaa111
      Luben Tuikov authored
      Some kernel transport drivers unconditionally disable
      retrieval of the Caching mode page. One such for example is
      the BBB/CBI transport over USB. Such a restraint is too
      harsh as some devices do support the Caching mode
      page. Unconditionally enabling the retrieval of this mode
      page over those transports at their transport code level may
      result in some devices failing and becoming unusable.
      
      This patch implements a method of retrieving the Caching
      mode page without unconditionally enabling it in the
      transports which unconditionally disable it. The idea is to
      ask for all supported pages, page code 0x3F, and then search
      for the Caching mode page in the mode parameter data
      returned. The sd driver already asks for all the mode pages
      supported by the attached device by setting the page code to
      0x3F in order to find out if the media is write protected by
      reading the WP bit in the Device Specific Parameter
      field. It then attempts to retrieve only the Caching mode
      page by setting the page code to 8 and actually attempting
      to retrieve it if and only if the transport allows it.
      
      The method implemented here is that if the transport doesn't
      allow retrieval of the Caching mode page and the device is
      not RBC, then we ask for all pages supported by setting the
      page code to 0x3F (similarly to how the WP bit is retrieved
      above), and then we search for the Caching mode page in the
      mode parameter data returned.
      
      With this patch, devices over SATA, report this (no change):
      
      Oct 22 18:45:58 localhost kernel: sd 0:0:0:0: [sda] 976773168 512-byte logical blocks: (500 GB/465 GiB)
      Oct 22 18:45:58 localhost kernel: sd 0:0:0:0: Attached scsi generic sg0 type 0
      Oct 22 18:45:58 localhost kernel: sd 0:0:0:0: [sda] Write Protect is off
      Oct 22 18:45:58 localhost kernel: sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
      Oct 22 18:45:58 localhost kernel: sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
      
      Smart devices report their Caching mode page. This is a
      change where we'd previously see the kernel making
      assumption about the device's cache being write-through:
      
      Oct 22 18:45:58 localhost kernel: sd 6:0:0:0: Attached scsi generic sg2 type 0
      Oct 22 18:45:58 localhost kernel: sd 6:0:0:0: [sdb] 610472646 4096-byte logical blocks: (2.50 TB/2.27 TiB)
      Oct 22 18:45:58 localhost kernel: sd 6:0:0:0: [sdb] Write Protect is off
      Oct 22 18:45:58 localhost kernel: sd 6:0:0:0: [sdb] Mode Sense: 47 00 10 08
      Oct 22 18:45:58 localhost kernel: sd 6:0:0:0: [sdb] Write cache: enabled, read cache: enabled, supports DPO and FUA
      
      And "dumb" devices over BBB, are correctly shown not to
      support reporting the Caching mode page:
      
      Oct 22 18:49:06 localhost kernel: sd 7:0:0:0: [sdc] 15663104 512-byte logical blocks: (8.01 GB/7.46 GiB)
      Oct 22 18:49:06 localhost kernel: sd 7:0:0:0: [sdc] Write Protect is off
      Oct 22 18:49:06 localhost kernel: sd 7:0:0:0: [sdc] Mode Sense: 23 00 00 00
      Oct 22 18:49:06 localhost kernel: sd 7:0:0:0: [sdc] No Caching mode page present
      Oct 22 18:49:06 localhost kernel: sd 7:0:0:0: [sdc] Assuming drive cache: write through
      
      Version 2 adds this:
      
      Some devices don't support page code 0x3F, and others require a
      fixed transfer length of 192 bytes. This single commit includes a
      patch by Alan Stern which fixes this.
      Reported-and-tested-by: default avatarRichard Senior <richard@r-senior.demon.co.uk>
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarLuben Tuikov <ltuikov@yahoo.com>
      Signed-off-by: default avatarJames Bottomley <jbottomley@parallels.com>
      0bcaa111
    • Martin K. Petersen's avatar
      [SCSI] sd: Unmap discard alignment needs to be converted to bytes · 2a8cfad0
      Martin K. Petersen authored
      The block layer discard alignment is reported in bytes, not in units of
      the logical block size.
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarJames Bottomley <jbottomley@parallels.com>
      2a8cfad0
  13. 31 Mar, 2011 1 commit
  14. 23 Mar, 2011 1 commit
  15. 22 Mar, 2011 1 commit
  16. 14 Mar, 2011 1 commit
    • Martin K. Petersen's avatar
      [SCSI] sd: Logical Block Provisioning update · c98a0eb0
      Martin K. Petersen authored
      SBC3r26 contains many changes to the Logical Block Provisioning
      interfaces (formerly known as Thin Provisioning ditto). This patch
      implements support for both the old and new schemes using the same
      heuristic as before (whether the LBP VPD page is present).
      
      The new code also allows the provisioning mode (i.e. choice of command)
      to be overridden on a per-device basis via sysfs. Two additional modes
      are supported in this version:
      
       - WRITE SAME(10) with the UNMAP bit set
      
       - WRITE SAME(10) without the UNMAP bit set. This allows us to support
         devices that predate the TP/LBP enhancements in SBC3 and which work
         by way zero-detection
      
      Switching between modes has been consolidated in a helper function that
      also updates the block layer topology according to the limitations of
      the chosen command.
      
      I experimented with trying WRITE SAME(16) if UNMAP fails, WRITE SAME(10)
      if WRITE SAME(16) fails, etc. but found several devices that got
      cranky. So for now we'll disable discard if one of the commands
      fail. The user still has the option of selecting a different mode in
      sysfs.
      Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
      c98a0eb0
  17. 14 Jan, 2011 2 commits
    • Tejun Heo's avatar
      [SCSI] sd,sr: kill compat SDEV_MEDIA_CHANGE event · f4013c38
      Tejun Heo authored
      SDEV_MEDIA_CHANGE event was first added by commit a341cd0f (SCSI: add
      asynchronous event notification API) for SATA AN support and then
      extended to cover generic media change events by commit 285e9670
      ([SCSI] sr,sd: send media state change modification events).
      
      This event was mapped to block device in userland with all properties
      stripped to simulate CHANGE event on the block device, which, in turn,
      was used to trigger further userspace action on media change.
      
      The recent addition of disk event framework kept this event for
      backward compatibility but it turns out to be unnecessary and causes
      erratic and inefficient behavior.  The new disk event generates proper
      events on the block devices and the compat events are mapped to block
      device with all properties stripped, so the block device ends up
      generating multiple duplicate events for single actual event.
      
      This patch removes the compat event generation from both sr and sd as
      suggested by Kay Sievers.  Both existing and newer versions of udev
      and the associated tools will behave better with the removal of these
      events as they from the beginning were expecting events on the block
      devices.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Acked-by: default avatarKay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
      f4013c38
    • Tejun Heo's avatar
      [SCSI] sd: implement sd_check_events() · 2bae0093
      Tejun Heo authored
      Replace sd_media_change() with sd_check_events().
      
      * Move media removed logic into set_media_not_present() and
        media_not_present() and set sdev->changed iff an existing media is
        removed or the device indicates UNIT_ATTENTION.
      
      * Make sd_check_events() sets sdev->changed if previously missing
        media becomes present.
      
      * Event is reported only if sdev->changed is set.
      
      This makes media presence event reported if scsi_disk->media_present
      actually changed or the device indicated UNIT_ATTENTION.  For backward
      compatibility, SDEV_EVT_MEDIA_CHANGE is generated each time
      sd_check_events() detects media change event.
      
      [jejb: fix boot failure]
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Acked-by: default avatarJens Axboe <jaxboe@fusionio.com>
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
      2bae0093
  18. 04 Jan, 2011 1 commit
    • Tejun Heo's avatar
      [SCSI] sd,sr: kill compat SDEV_MEDIA_CHANGE event · 140e3008
      Tejun Heo authored
      SDEV_MEDIA_CHANGE event was first added by commit a341cd0f (SCSI: add
      asynchronous event notification API) for SATA AN support and then
      extended to cover generic media change events by commit 285e9670
      ([SCSI] sr,sd: send media state change modification events).
      
      This event was mapped to block device in userland with all properties
      stripped to simulate CHANGE event on the block device, which, in turn,
      was used to trigger further userspace action on media change.
      
      The recent addition of disk event framework kept this event for
      backward compatibility but it turns out to be unnecessary and causes
      erratic and inefficient behavior.  The new disk event generates proper
      events on the block devices and the compat events are mapped to block
      device with all properties stripped, so the block device ends up
      generating multiple duplicate events for single actual event.
      
      This patch removes the compat event generation from both sr and sd as
      suggested by Kay Sievers.  Both existing and newer versions of udev
      and the associated tools will behave better with the removal of these
      events as they from the beginning were expecting events on the block
      devices.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Acked-by: default avatarKay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
      140e3008
  19. 28 Dec, 2010 1 commit
    • Tejun Heo's avatar
      [SCSI] sd: implement sd_check_events() · eface65c
      Tejun Heo authored
      Replace sd_media_change() with sd_check_events().
      
      * Move media removed logic into set_media_not_present() and
        media_not_present() and set sdev->changed iff an existing media is
        removed or the device indicates UNIT_ATTENTION.
      
      * Make sd_check_events() sets sdev->changed if previously missing
        media becomes present.
      
      * Event is reported only if sdev->changed is set.
      
      This makes media presence event reported if scsi_disk->media_present
      actually changed or the device indicated UNIT_ATTENTION.  For backward
      compatibility, SDEV_EVT_MEDIA_CHANGE is generated each time
      sd_check_events() detects media change event.
      
      [jejb: fix boot failure]
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Acked-by: default avatarJens Axboe <jaxboe@fusionio.com>
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
      eface65c
  20. 23 Dec, 2010 1 commit
    • James Bottomley's avatar
      [SCSI] fix medium error problems with some arrays which can cause data corruption · a8733c7b
      James Bottomley authored
      Our current handling of medium error assumes that data is returned up
      to the bad sector.  This assumption holds good for all disk devices,
      all DIF arrays and most ordinary arrays.  However, an LSI array engine
      was recently discovered which reports a medium error without returning
      any data.  This means that when we report good data up to the medium
      error, we've reported junk originally in the buffer as good.  Worse,
      if the read consists of requested data plus a readahead, and the error
      occurs in readahead, we'll just strip off the readahead and report
      junk up to userspace as good data with no error.
      
      The fix for this is to have the error position computation take into
      account the amount of data returned by the driver using the scsi
      residual data.  Unfortunately, not every driver fills in this data,
      but for those who don't, it's set to zero, which means we'll think a
      full set of data was transferred and the behaviour will be identical
      to the prior behaviour of the code (believe the buffer up to the error
      sector).  All modern drivers seem to set the residual, so that should
      fix up the LSI failure/corruption case.
      Reported-by: default avatarDouglas Gilbert <dgilbert@interlog.com>
      Cc: Stable Tree <stable@kernel.org>
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
      a8733c7b
  21. 22 Dec, 2010 1 commit
  22. 21 Dec, 2010 2 commits
    • Luben Tuikov's avatar
      [SCSI] Retrieve the Caching mode page · 24d720b7
      Luben Tuikov authored
      Some kernel transport drivers unconditionally disable
      retrieval of the Caching mode page. One such for example is
      the BBB/CBI transport over USB.  Such a restraint is too
      harsh as some devices do support the Caching mode
      page. Unconditionally enabling the retrieval of this mode
      page over those transports at their transport code level may
      result in some devices failing and becoming unusable.
      
      This patch implements a method of retrieving the Caching
      mode page without unconditionally enabling it in the
      transports which unconditionally disable it. The idea is to
      ask for all supported pages, page code 0x3F, and then search
      for the Caching mode page in the mode parameter data
      returned. The sd driver already asks for all the mode pages
      supported by the attached device by setting the page code to
      0x3F in order to find out if the media is write protected by
      reading the WP bit in the Device Specific Parameter
      field. It then attempts to retrieve only the Caching mode
      page by setting the page code to 8 and actually attempting
      to retrieve it if and only if the transport allows it.
      
      The method implemented here is that if the transport doesn't
      allow retrieval of the Caching mode page and the device is
      not RBC, then we ask for all pages supported by setting the
      page code to 0x3F (similarly to how the WP bit is retrieved
      above), and then we search for the Caching mode page in the
      mode parameter data returned.
      
      With this patch, devices over SATA, report this (no change):
      
      Oct 22 18:45:58 localhost kernel: sd 0:0:0:0: [sda] 976773168 512-byte logical blocks: (500 GB/465 GiB)
      Oct 22 18:45:58 localhost kernel: sd 0:0:0:0: Attached scsi generic sg0 type 0
      Oct 22 18:45:58 localhost kernel: sd 0:0:0:0: [sda] Write Protect is off
      Oct 22 18:45:58 localhost kernel: sd 0:0:0:0: [sda] Mode Sense: 00 3a 00 00
      Oct 22 18:45:58 localhost kernel: sd 0:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
      
      Smart devices report their Caching mode page. This is a
      change where we'd previously see the kernel making
      assumption about the device's cache being write-through:
      
      Oct 22 18:45:58 localhost kernel: sd 6:0:0:0: Attached scsi generic sg2 type 0
      Oct 22 18:45:58 localhost kernel: sd 6:0:0:0: [sdb] 610472646 4096-byte logical blocks: (2.50 TB/2.27 TiB)
      Oct 22 18:45:58 localhost kernel: sd 6:0:0:0: [sdb] Write Protect is off
      Oct 22 18:45:58 localhost kernel: sd 6:0:0:0: [sdb] Mode Sense: 47 00 10 08
      Oct 22 18:45:58 localhost kernel: sd 6:0:0:0: [sdb] Write cache: enabled, read cache: enabled, supports DPO and FUA
      
      And "dumb" devices over BBB, are correctly shown not to
      support reporting the Caching mode page:
      
      Oct 22 18:49:06 localhost kernel: sd 7:0:0:0: [sdc] 15663104 512-byte logical blocks: (8.01 GB/7.46 GiB)
      Oct 22 18:49:06 localhost kernel: sd 7:0:0:0: [sdc] Write Protect is off
      Oct 22 18:49:06 localhost kernel: sd 7:0:0:0: [sdc] Mode Sense: 23 00 00 00
      Oct 22 18:49:06 localhost kernel: sd 7:0:0:0: [sdc] No Caching mode page present
      Oct 22 18:49:06 localhost kernel: sd 7:0:0:0: [sdc] Assuming drive cache: write through
      Signed-off-by: default avatarLuben Tuikov <ltuikov@yahoo.com>
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
      24d720b7
    • Alan Stern's avatar
      [SCSI] sd: improve logic and efficiecy of media-change detection · 3ff5588d
      Alan Stern authored
      This patch (as1415) improves the formerly incomprehensible logic in
      sd_media_changed() (the current code refers to "changed" as a state,
      whereas in fact it is a relation between two states).  It also adds a
      big comment so that everyone can understand what is really going on.
      
      The patch also improves efficiency by not reporting a media change
      when no medium was ever present.  If no medium was present the last
      time we checked and there's still no medium, it's not necessary to
      tell the caller that a change occurred.  Doing so merely causes the
      caller to attempt to revalidate a non-existent disk, which is a waste
      of time.
      Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
      3ff5588d
  23. 16 Dec, 2010 2 commits
    • Tejun Heo's avatar
      sd: implement sd_check_events() · c8d2e937
      Tejun Heo authored
      Replace sd_media_change() with sd_check_events().  sd used to set the
      changed state whenever the device is not ready, which can cause event
      loop while the device is not ready.  Media presence handling code is
      changed such that the changed state is set iff the media presence
      actually changes.  UA still always sets the changed state and
      NOT_READY always (at least where it used to set ->changed) clears
      media presence, so no event is lost.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Kay Sievers <kay.sievers@vrfy.org>
      Signed-off-by: default avatarJens Axboe <jaxboe@fusionio.com>
      c8d2e937
    • 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
  24. 17 Nov, 2010 1 commit
  25. 25 Oct, 2010 1 commit
  26. 22 Oct, 2010 1 commit
    • Hans de Goede's avatar
      scsi/sd: add a no_read_capacity_16 scsi_device flag · 5ce524bd
      Hans de Goede authored
      I seem to have a knack for digging up buggy usb devices which don't work
      with Linux, and I'm crazy enough to try to make them work.  So this time a
      friend of mine asked me to get an mp4 player (an mp3 player which can play
      videos on a small screen) to work with Linux.
      
      It is based on the well known rockbox chipset for which we already have an
      unusual devs entries to work around some of its bugs.  But this model
      comes with an additional twist.
      
      This model chokes on read_capacity_16 calls.  Now normally we don't make
      those calls, but this model comes with an sdcard slot and when there is no
      card in there (and shipped from the factory there is none), it reports a
      size of 0.  However this time the programmers actually got the
      read_capacity_10 response right!  So they substract one from the size as
      stored internally in the mp3 player before reporting it back, resulting in
      an answer of ...  0xffffffff sectors, causing sd.c to try a
      read_capacity_16, on which the device crashes.
      
      This patch adds a flag to scsi_device to indicate that a a device cannot
      handle read_capacity_16, and when this flag is set if a device reports an
      lba of 0xffffffff as answer to a read_capacity_10, assumes it tries to
      report a size of 0.
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Cc: James Bottomley <James.Bottomley@HansenPartnership.com>
      Cc: Alan Stern <stern@rowland.harvard.edu>
      Cc: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
      5ce524bd
  27. 11 Oct, 2010 1 commit
  28. 07 Oct, 2010 1 commit
    • Michael Reed's avatar
      [SCSI] sd name space exhaustion causes system hang · 1a03ae0f
      Michael Reed authored
      Following a site power outage which re-enabled all the ports on my FC
      switches, my system subsequently booted with far too many luns!  I had
      let it run hoping it would make multi-user.  It didn't.  :(  It hung solid
      after exhausting the last sd device, sdzzz, and attempting to create sdaaaa
      and beyond.  I was unable to get a dump.
      
      Discovered using a 2.6.32.13 based system.
      
      correct this by detecting when the last index is utilized and failing
      the sd probe of the device.  Patch applies to scsi-misc-2.6.
      Signed-off-by: default avatarMichael Reed <mdr@sgi.com>
      Cc: Stable Tree <stable@kernel.org>
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
      1a03ae0f
  29. 17 Sep, 2010 1 commit
  30. 10 Sep, 2010 2 commits
    • Tejun Heo's avatar
      block: deprecate barrier and replace blk_queue_ordered() with blk_queue_flush() · 4913efe4
      Tejun Heo authored
      Barrier is deemed too heavy and will soon be replaced by FLUSH/FUA
      requests.  Deprecate barrier.  All REQ_HARDBARRIERs are failed with
      -EOPNOTSUPP and blk_queue_ordered() is replaced with simpler
      blk_queue_flush().
      
      blk_queue_flush() takes combinations of REQ_FLUSH and FUA.  If a
      device has write cache and can flush it, it should set REQ_FLUSH.  If
      the device can handle FUA writes, it should also set REQ_FUA.
      
      All blk_queue_ordered() users are converted.
      
      * ORDERED_DRAIN is mapped to 0 which is the default value.
      * ORDERED_DRAIN_FLUSH is mapped to REQ_FLUSH.
      * ORDERED_DRAIN_FLUSH_FUA is mapped to REQ_FLUSH | REQ_FUA.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Acked-by: default avatarBoaz Harrosh <bharrosh@panasas.com>
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Nick Piggin <npiggin@kernel.dk>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
      Cc: Chris Wright <chrisw@sous-sol.org>
      Cc: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
      Cc: Geert Uytterhoeven <Geert.Uytterhoeven@sonycom.com>
      Cc: David S. Miller <davem@davemloft.net>
      Cc: Alasdair G Kergon <agk@redhat.com>
      Cc: Pierre Ossman <drzeus@drzeus.cx>
      Cc: Stefan Weinhuber <wein@de.ibm.com>
      Signed-off-by: default avatarJens Axboe <jaxboe@fusionio.com>
      4913efe4
    • Tejun Heo's avatar
      block: kill QUEUE_ORDERED_BY_TAG · 6958f145
      Tejun Heo authored
      Nobody is making meaningful use of ORDERED_BY_TAG now and queue
      draining for barrier requests will be removed soon which will render
      the advantage of tag ordering moot.  Kill ORDERED_BY_TAG.  The
      following users are affected.
      
      * brd: converted to ORDERED_DRAIN.
      * virtio_blk: ORDERED_TAG path was already marked deprecated.  Removed.
      * xen-blkfront: ORDERED_TAG case dropped.
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      Cc: Christoph Hellwig <hch@infradead.org>
      Cc: Nick Piggin <npiggin@kernel.dk>
      Cc: Michael S. Tsirkin <mst@redhat.com>
      Cc: Jeremy Fitzhardinge <jeremy@xensource.com>
      Cc: Chris Wright <chrisw@sous-sol.org>
      Signed-off-by: default avatarJens Axboe <jaxboe@fusionio.com>
      6958f145
  31. 07 Sep, 2010 1 commit
  32. 05 Sep, 2010 1 commit
    • Mike Christie's avatar
      [SCSI] scsi/block: increase flush/sync timeout · e3b3e624
      Mike Christie authored
      We have been seeing the flush request timeout with a wide
      range of hardware from tgt+iser to FC targets from a major vendor.
      
      After discussions about if the value should be configurable and
      what the best value should be, this patch just increases the flush/sync
      cache timeout to 1 minute. 2 minutes was determined to be too long, and
      making it configurable was troublesome for users.
      
      This patch was made over Linus's tree. It is not made over scsi-misc
      or scsi-rc-fixes, because Linus's had block layer changes that my
      patch was built over.
      Signed-off-by: default avatarMike Christie <michaelc@cs.wisc.edu>
      Acked-by: default avatarJens Axboe <jaxboe@fusionio.com>
      Signed-off-by: default avatarJames Bottomley <James.Bottomley@suse.de>
      e3b3e624
  33. 02 Sep, 2010 1 commit