scsi: sd: Unlock zone in case of error in sd_setup_write_same_cmnd()
authorDamien Le Moal <damien.lemoal@wdc.com>
Mon, 8 May 2017 05:59:02 +0000 (14:59 +0900)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 12 May 2017 03:10:03 +0000 (23:10 -0400)
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>
drivers/scsi/sd.c

index f9d1432d7cc589360354c9d3fdbe4c0967e23ee6..e60a309b26bf407c4cc965c47c61ac72ab6450a5 100644 (file)
@@ -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;
 }