diff options
author | Christoph Hellwig <hch@lst.de> | 2017-04-05 19:21:12 +0200 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2017-04-08 11:25:38 -0600 |
commit | e4b878371b85ddcd3e00eb68fa45e61793c37af0 (patch) | |
tree | 973d561198d920205e9ab694c7e6805cc95ea0aa /drivers/scsi/sd.c | |
parent | 34045129b128fb3c0237b6af7c5a84b1ca9c0bf5 (diff) | |
download | linux-e4b878371b85ddcd3e00eb68fa45e61793c37af0.tar.bz2 |
sd: implement unmapping Write Zeroes
Try to use a write same with unmap bit variant if the device supports it
and the caller allows for it.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'drivers/scsi/sd.c')
-rw-r--r-- | drivers/scsi/sd.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index d8d9c0bdd93c..001593ed0444 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -803,6 +803,15 @@ static int sd_setup_write_zeroes_cmnd(struct scsi_cmnd *cmd) u64 sector = blk_rq_pos(rq) >> (ilog2(sdp->sector_size) - 9); u32 nr_sectors = blk_rq_sectors(rq) >> (ilog2(sdp->sector_size) - 9); + if (!(rq->cmd_flags & REQ_NOUNMAP)) { + switch (sdkp->provisioning_mode) { + case SD_LBP_WS16: + return sd_setup_write_same16_cmnd(cmd, true); + case SD_LBP_WS10: + return sd_setup_write_same10_cmnd(cmd, true); + } + } + if (sdp->no_write_same) return BLKPREP_INVALID; if (sdkp->ws16 || sector > 0xffffffff || nr_sectors > 0xffff) |