summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/sd.c
diff options
context:
space:
mode:
authorDamien Le Moal <damien.lemoal@wdc.com>2017-05-08 07:59:02 +0200
committerMartin K. Petersen <martin.petersen@oracle.com>2017-05-12 05:10:03 +0200
commit29f6ca6916e29fc46f1418885374d9ed50430687 (patch)
treef34bd7a4d104c5bc646dd9d6a250db6dc15c033b /drivers/scsi/sd.c
parentscsi: pmcraid: remove redundant check to see if request_size is less than zero (diff)
downloadlinux-29f6ca6916e29fc46f1418885374d9ed50430687.tar.xz
linux-29f6ca6916e29fc46f1418885374d9ed50430687.zip
scsi: sd: Unlock zone in case of error in sd_setup_write_same_cmnd()
scsi_io_init() may fail, leaving a zone of a zoned block device locked. Fix this by properly unlocking the write same request target zone if scsi_io_init() fails. Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi/sd.c')
-rw-r--r--drivers/scsi/sd.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index f9d1432d7cc5..e60a309b26bf 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -948,6 +948,10 @@ static int sd_setup_write_same_cmnd(struct scsi_cmnd *cmd)
rq->__data_len = sdp->sector_size;
ret = scsi_init_io(cmd);
rq->__data_len = nr_bytes;
+
+ if (sd_is_zoned(sdkp) && ret != BLKPREP_OK)
+ sd_zbc_write_unlock_zone(cmd);
+
return ret;
}