1. 15 Sep, 2016 1 commit
  2. 02 Jun, 2016 1 commit
  3. 01 Apr, 2016 1 commit
  4. 26 Nov, 2015 1 commit
    • Martin K. Petersen's avatar
      block/sd: Fix device-imposed transfer length limits · ca369d51
      Martin K. Petersen authored
      Commit 4f258a46 ("sd: Fix maximum I/O size for BLOCK_PC requests")
      had the unfortunate side-effect of removing an implicit clamp to
      BLK_DEF_MAX_SECTORS for REQ_TYPE_FS requests in the block layer
      code. This caused problems for some SMR drives.
      
      Debugging this issue revealed a few problems with the existing
      infrastructure since the block layer didn't know how to deal with
      device-imposed limits, only limits set by the I/O controller.
      
       - Introduce a new queue limit, max_dev_sectors, which is used by the
         ULD to signal the maximum sectors for a REQ_TYPE_FS request.
      
       - Ensure that max_dev_sectors is correctly stacked and taken into
         account when overriding max_sectors through sysfs.
      
       - Rework sd_read_block_limits() so it saves the max_xfer and opt_xfer
         values for later processing.
      
       - In sd_revalidate() set the queue's max_dev_sectors based on the
         MAXIMUM TRANSFER LENGTH value in the Block Limits VPD. If this value
         is not reported, fall back to a cap based on the CDB TRANSFER LENGTH
         field size.
      
       - In sd_revalidate(), use OPTIMAL TRANSFER LENGTH from the Block Limits
         VPD--if reported and sane--to signal the preferred device transfer
         size for FS requests. Otherwise use BLK_DEF_MAX_SECTORS.
      
       - blk_limits_max_hw_sectors() is no longer used and can be removed.
      Signed-off-by: Martin K. Petersen's avatarMartin K. Petersen <[email protected]>
      Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=93581Reviewed-by: default avatarChristoph Hellwig <[email protected]>
      Tested-by: [email protected]
      Tested-by: Anatol Pomozov's avatarArzeets <[email protected]>
      Tested-by: David Eisner's avatarDavid Eisner <[email protected]>
      Tested-by: default avatarMario Kicherer <[email protected]>
      Signed-off-by: Martin K. Petersen's avatarMartin K. Petersen <[email protected]>
      ca369d51
  5. 12 Nov, 2014 1 commit
  6. 30 Sep, 2014 1 commit
  7. 17 Jul, 2014 1 commit
    • Martin K. Petersen's avatar
      sd: Limit transfer length · bcdb247c
      Martin K. Petersen authored
      Until now the per-command transfer length has exclusively been gated by
      the max_sectors parameter in the scsi_host template. Given that the size
      of this parameter has been bumped to an unsigned int we have to be
      careful not to exceed the target device's capabilities.
      
      If the if the device specifies a Maximum Transfer Length in the Block
      Limits VPD we'll use that value. Otherwise we'll use 0xffffffff for
      devices that have use_16_for_rw set and 0xffff for the rest. We then
      combine the chosen disk limit with max_sectors in the host template. The
      smaller of the two will be used to set the max_hw_sectors queue limit.
      Signed-off-by: Martin K. Petersen's avatarMartin K. Petersen <[email protected]>
      Reviewed-by: default avatarEwan D. Milne <[email protected]>
      Signed-off-by: default avatarChristoph Hellwig <[email protected]>
      bcdb247c
  8. 27 Mar, 2014 1 commit
  9. 25 Oct, 2013 1 commit
  10. 27 Jun, 2013 1 commit
    • Martin K. Petersen's avatar
      [SCSI] sd: Update WRITE SAME heuristics · 66c28f97
      Martin K. Petersen authored
      SATA drives located behind a SAS controller would incorrectly receive
      WRITE SAME commands. Tweak the heuristics so that:
      
       - If REPORT SUPPORTED OPERATION CODES is provided we will use that to
         choose between WRITE SAME(16), WRITE SAME(10) and disabled. This also
         fixes an issue with the old code which would issue WRITE SAME(10)
         despite the command not being whitelisted in REPORT SUPPORTED
         OPERATION CODES.
      
       - If REPORT SUPPORTED OPERATION CODES is not provided we will fall back
         to WRITE SAME(10) unless the device has an ATA Information VPD page.
         The assumption is that a SATL which is smart enough to implement
         WRITE SAME would also provide REPORT SUPPORTED OPERATION CODES.
      
      To facilitate the new heuristics scsi_report_opcode() has been modified
      to so we can distinguish between "operation not supported" and "RSOC not
      supported".
      Reported-by: default avatarH. Peter Anvin <[email protected]>
      Tested-by: default avatarBernd Schubert <[email protected]>
      Signed-off-by: Martin K. Petersen's avatarMartin K. Petersen <[email protected]>
      Cc: <[email protected]>
      Signed-off-by: default avatarJames Bottomley <[email protected]>
      66c28f97
  11. 02 May, 2013 1 commit
    • James Bottomley's avatar
      [SCSI] sd: fix array cache flushing bug causing performance problems · 39c60a09
      James Bottomley authored
      Some arrays synchronize their full non volatile cache when the sd driver sends
      a SYNCHRONIZE CACHE command.  Unfortunately, they can have Terrabytes of this
      and we send a SYNCHRONIZE CACHE for every barrier if an array reports it has a
      writeback cache.  This leads to massive slowdowns on journalled filesystems.
      
      The fix is to allow userspace to turn off the writeback cache setting as a
      temporary measure (i.e. without doing the MODE SELECT to write it back to the
      device), so even though the device reported it has a writeback cache, the
      user, knowing that the cache is non volatile and all they care about is
      filesystem correctness, can turn that bit off in the kernel and avoid the
      performance ruinous (and safety irrelevant) SYNCHRONIZE CACHE commands.
      
      The way you do this is add a 'temporary' prefix when performing the usual
      cache setting operations, so
      
      echo temporary write through > /sys/class/scsi_disk/<disk>/cache_type
      Reported-by: default avatarRic Wheeler <[email protected]>
      Cc: <[email protected]>
      Signed-off-by: default avatarJames Bottomley <[email protected]>
      39c60a09
  12. 14 Nov, 2012 1 commit
    • Martin K. Petersen's avatar
      [SCSI] sd: Implement support for WRITE SAME · 5db44863
      Martin K. Petersen authored
      Implement support for WRITE SAME(10) and WRITE SAME(16) in the SCSI disk
      driver.
      
       - We set the default maximum to 0xFFFF because there are several
         devices out there that only support two-byte block counts even with
         WRITE SAME(16). We only enable transfers bigger than 0xFFFF if the
         device explicitly reports MAXIMUM WRITE SAME LENGTH in the BLOCK
         LIMITS VPD.
      
       - max_write_same_blocks can be overriden per-device basis in sysfs.
      
       - The UNMAP discovery heuristics remain unchanged but the discard
         limits are tweaked to match the "real" WRITE SAME commands.
      
       - In the error handling logic we now distinguish between WRITE SAME
         with and without UNMAP set.
      
      The discovery process heuristics are:
      
       - If the device reports a SCSI level of SPC-3 or greater we'll issue
         READ SUPPORTED OPERATION CODES to find out whether WRITE SAME(16) is
         supported. If that's the case we will use it.
      
       - If the device supports the block limits VPD and reports a MAXIMUM
         WRITE SAME LENGTH bigger than 0xFFFF we will use WRITE SAME(16).
      
       - Otherwise we will use WRITE SAME(10) unless the target LBA is beyond
         0xFFFFFFFF or the block count exceeds 0xFFFF.
      
       - no_write_same is set for ATA, FireWire and USB.
      Signed-off-by: Martin K. Petersen's avatarMartin K. Petersen <[email protected]>
      Reviewed-by: default avatarMike Snitzer <[email protected]>
      Reviewed-by: default avatarJeff Garzik <[email protected]>
      Signed-off-by: default avatarJames Bottomley <[email protected]>
      5db44863
  13. 24 Sep, 2012 1 commit
  14. 19 Feb, 2012 1 commit
    • Martin K. Petersen's avatar
      [SCSI] Handle disk devices which can not process medium access commands · 18a4d0a2
      Martin K. Petersen authored
      We have experienced several devices which fail in a fashion we do not
      currently handle gracefully in SCSI. After a failure these devices will
      respond to the SCSI primary command set (INQUIRY, TEST UNIT READY, etc.)
      but any command accessing the storage medium will time out.
      
      The following patch adds an callback that can be used by upper level
      drivers to inspect the results of an error handling command. This in
      turn has been used to implement additional checking in the SCSI disk
      driver.
      
      If a medium access command fails twice but TEST UNIT READY succeeds both
      times in the subsequent error handling we will offline the device. The
      maximum number of failed commands required to take a device offline can
      be tweaked in sysfs.
      
      Also add a new error flag to scsi_debug which allows this scenario to be
      easily reproduced.
      
      [jejb: fix up integer parsing to use kstrtouint]
      Signed-off-by: Martin K. Petersen's avatarMartin K. Petersen <[email protected]>
      Signed-off-by: default avatarJames Bottomley <[email protected]>
      18a4d0a2
  15. 30 Oct, 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: Martin K. Petersen's avatarMartin K. Petersen <[email protected]>
      Signed-off-by: default avatarJames Bottomley <[email protected]>
      c98a0eb0
  17. 14 Jan, 2011 1 commit
    • 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 <[email protected]>
      Acked-by: default avatarJens Axboe <[email protected]>
      Signed-off-by: default avatarJames Bottomley <[email protected]>
      2bae0093
  18. 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 <[email protected]>
      Acked-by: default avatarJens Axboe <[email protected]>
      Signed-off-by: default avatarJames Bottomley <[email protected]>
      eface65c
  19. 22 Dec, 2010 1 commit
  20. 16 Dec, 2010 1 commit
    • 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 <[email protected]>
      Cc: Kay Sievers <[email protected]>
      Signed-off-by: default avatarJens Axboe <[email protected]>
      c8d2e937
  21. 11 Oct, 2010 1 commit
  22. 17 Sep, 2010 1 commit
  23. 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 <[email protected]>
      Acked-by: default avatarJens Axboe <[email protected]>
      Signed-off-by: default avatarJames Bottomley <[email protected]>
      e3b3e624
  24. 07 Aug, 2010 1 commit
  25. 10 Dec, 2009 1 commit
  26. 02 Oct, 2009 2 commits
  27. 21 Jun, 2009 1 commit
  28. 18 Mar, 2009 1 commit
  29. 15 Oct, 2008 1 commit
  30. 13 Oct, 2008 1 commit
  31. 06 Aug, 2008 1 commit
  32. 04 Aug, 2008 1 commit
  33. 27 Jul, 2008 1 commit
    • Alan Jenkins's avatar
      [SCSI] extend the last_sector_bug flag to cover more sectors · 2b142900
      Alan Jenkins authored
      The last_sector_bug flag was added to work around a bug in certain usb
      cardreaders, where they would crash if a multiple sector read included the
      last sector. The original implementation avoids this by e.g. splitting an 8
      sector read which includes the last sector into a 7 sector read, and a single
      sector read for the last sector.  The flag is enabled for all USB devices.
      
      This revealed a second bug in other usb cardreaders, which crash when they
      get a multiple sector read which stops 1 sector short of the last sector.
      Affected hardware includes the Kingston "MobileLite" external USB cardreader
      and the internal USB cardreader on the Asus EeePC.
      
      Extend the last_sector_bug workaround to ensure that any access which touches
      the last 8 hardware sectors of the device is a single sector long.  Requests
      are shrunk as necessary to meet this constraint.
      
      This gives us a safety margin against potential unknown or future bugs
      affecting multi-sector access to the end of the device.  The two known bugs
      only affect the last 2 sectors.  However, they suggest that these devices
      are prone to fencepost errors and that multi-sector access to the end of the
      device is not well tested.  Popular OS's use multi-sector accesses, but they
      rarely read the last few sectors.  Linux (with udev & vol_id) automatically
      reads sectors from the end of the device on insertion.  It is assumed that
      single sector accesses are more thoroughly tested during development.
      Signed-off-by: default avatarAlan Jenkins <[email protected]>
      Tested-by: default avatarAlan Jenkins <[email protected]>
      Signed-off-by: default avatarJames Bottomley <[email protected]>
      2b142900
  34. 26 Jul, 2008 2 commits
  35. 12 Jul, 2008 2 commits
  36. 20 Apr, 2008 1 commit
  37. 12 Jan, 2008 1 commit
    • Kay Sievers's avatar
      [SCSI] sr,sd: send media state change modification events · 285e9670
      Kay Sievers authored
      This will send for a card reader slot (remove/add media):
        UEVENT[1187091572.155884] change   /devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/host7/target7:0:0/7:0:0:0 (scsi)
        UEVENT[1187091572.162314] remove   /block/sdb/sdb1 (block)
        UEVENT[1187091572.172464] add      /block/sdb/sdb1 (block)
        UEVENT[1187091572.175408] change   /devices/pci0000:00/0000:00:1d.7/usb5/5-2/5-2:1.0/host7/target7:0:0/7:0:0:0 (scsi)
      
      and for a DVD drive (add/eject media):
        UEVENT[1187091590.189159] change   /devices/pci0000:00/0000:00:1f.1/host4/target4:0:0/4:0:0:0 (scsi)
        UEVENT[1187091590.957124] add      /module/isofs (module)
        UEVENT[1187091604.468207] change   /devices/pci0000:00/0000:00:1f.1/host4/target4:0:0/4:0:0:0 (scsi)
      
      Userspace gets events, even for unpartitioned media. This unifies
      the event handling for asynchronoous events (AN) and events caused by
      perodical polling the device from userspace.
      Signed-off-by: default avatarKay Sievers <[email protected]>
      
      [jejb: modified for new event API]
      Signed-off-by: default avatarJames Bottomley <[email protected]>
      285e9670