summaryrefslogtreecommitdiff
path: root/drivers/scsi/sd.c
diff options
context:
space:
mode:
authorDamien Le Moal <damien.lemoal@wdc.com>2017-05-08 08:59:02 +0300
committerMartin K. Petersen <martin.petersen@oracle.com>2017-05-12 06:10:03 +0300
commit29f6ca6916e29fc46f1418885374d9ed50430687 (patch)
treef34bd7a4d104c5bc646dd9d6a250db6dc15c033b /drivers/scsi/sd.c
parentb77b36cb7272ec5b9fb000e2ff18e947d9586a22 (diff)
downloadlinux-29f6ca6916e29fc46f1418885374d9ed50430687.tar.xz
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;
}