mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 03:27:44 -04:00
scsi: sd: Implement blacklist option for WRITE SAME w/ UNMAP
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. Cc: <[email protected]> Reported-by: Bill Kuzeja <[email protected]> Reported-by: Ewan D. Milne <[email protected]> Reviewed-by: Ewan D. Milne <[email protected]> Tested-by: Laurence Oberman <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
This commit is contained in:
parent
d0b7a9095c
commit
28a0bc4120
4 changed files with 17 additions and 4 deletions
|
|
@ -956,6 +956,9 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
|
|||
if (*bflags & BLIST_NO_DIF)
|
||||
sdev->no_dif = 1;
|
||||
|
||||
if (*bflags & BLIST_UNMAP_LIMIT_WS)
|
||||
sdev->unmap_limit_for_ws = 1;
|
||||
|
||||
sdev->eh_timeout = SCSI_DEFAULT_EH_TIMEOUT;
|
||||
|
||||
if (*bflags & BLIST_TRY_VPD_PAGES)
|
||||
|
|
|
|||
|
|
@ -715,13 +715,21 @@ static void sd_config_discard(struct scsi_disk *sdkp, unsigned int mode)
|
|||
break;
|
||||
|
||||
case SD_LBP_WS16:
|
||||
max_blocks = min_not_zero(sdkp->max_ws_blocks,
|
||||
(u32)SD_MAX_WS16_BLOCKS);
|
||||
if (sdkp->device->unmap_limit_for_ws)
|
||||
max_blocks = sdkp->max_unmap_blocks;
|
||||
else
|
||||
max_blocks = sdkp->max_ws_blocks;
|
||||
|
||||
max_blocks = min_not_zero(max_blocks, (u32)SD_MAX_WS16_BLOCKS);
|
||||
break;
|
||||
|
||||
case SD_LBP_WS10:
|
||||
max_blocks = min_not_zero(sdkp->max_ws_blocks,
|
||||
(u32)SD_MAX_WS10_BLOCKS);
|
||||
if (sdkp->device->unmap_limit_for_ws)
|
||||
max_blocks = sdkp->max_unmap_blocks;
|
||||
else
|
||||
max_blocks = sdkp->max_ws_blocks;
|
||||
|
||||
max_blocks = min_not_zero(max_blocks, (u32)SD_MAX_WS10_BLOCKS);
|
||||
break;
|
||||
|
||||
case SD_LBP_ZERO:
|
||||
|
|
|
|||
Loading…
Reference in a new issue