scsi: sd: Implement blacklist option for WRITE SAME w/ UNMAP
authorMartin K. Petersen <martin.petersen@oracle.com>
Thu, 28 Sep 2017 01:35:12 +0000 (21:35 -0400)
committerBen Hutchings <ben@decadent.org.uk>
Mon, 1 Jan 2018 20:50:55 +0000 (20:50 +0000)
commita75a0b71bc065dc42701e7708a8e6b368ea01864
tree31a17ef1725c2c81b3e0aa14cdb514c0bc6b448d
parent89c0c6643aac2443b3a53104c1adbaccd2919d34
scsi: sd: Implement blacklist option for WRITE SAME w/ UNMAP

commit 28a0bc4120d38a394499382ba21d6965a67a3703 upstream.

SBC-4 states:

  "A MAXIMUM UNMAP LBA COUNT field set to a non-zero value indicates the
   maximum number of LBAs that may be unmapped by an UNMAP command"

  "A MAXIMUM WRITE SAME LENGTH field set to a non-zero value indicates
   the maximum number of contiguous logical blocks that the device server
   allows to be unmapped or written in a single WRITE SAME command."

Despite the spec being clear on the topic, some devices incorrectly
expect WRITE SAME commands with the UNMAP bit set to be limited to the
value reported in MAXIMUM UNMAP LBA COUNT in the Block Limits VPD.

Implement a blacklist option that can be used to accommodate devices
with this behavior.

Reported-by: Bill Kuzeja <William.Kuzeja@stratus.com>
Reported-by: Ewan D. Milne <emilne@redhat.com>
Reviewed-by: Ewan D. Milne <emilne@redhat.com>
Tested-by: Laurence Oberman <loberman@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
[bwh: Backported to 3.2:
 - Keep using literals for SD_MAX_WS{16,10}_BLOCKS
 - Adjust context]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/scsi/scsi_scan.c
drivers/scsi/sd.c
include/scsi/scsi_device.h
include/scsi/scsi_devinfo.h