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>
This commit is contained in:
Damien Le Moal 2017-05-08 14:59:02 +09:00 committed by Martin K. Petersen
parent b77b36cb72
commit 29f6ca6916
1 changed files with 4 additions and 0 deletions

View 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;
}