diff options
author | Martin K. Petersen <martin.petersen@oracle.com> | 2016-02-04 00:52:12 -0500 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2016-02-04 22:42:58 -0500 |
commit | 0fb5b1fb30fba3671dd5b1489d78e93e08d62e4e (patch) | |
tree | 090ebf83b190bff02e29a43f8611503d066e33c5 /drivers/scsi | |
parent | 82c43310508eb19eb41fe7862e89afeb74030b84 (diff) |
block/sd: Return -EREMOTEIO when WRITE SAME and DISCARD are disabled
When a storage device rejects a WRITE SAME command we will disable write
same functionality for the device and return -EREMOTEIO to the block
layer. -EREMOTEIO will in turn prevent DM from retrying the I/O and/or
failing the path.
Yiwen Jiang discovered a small race where WRITE SAME requests issued
simultaneously would cause -EIO to be returned. This happened because
any requests being prepared after WRITE SAME had been disabled for the
device caused us to return BLKPREP_KILL. The latter caused the block
layer to return -EIO upon completion.
To overcome this we introduce BLKPREP_INVALID which indicates that this
is an invalid request for the device. blk_peek_request() is modified to
return -EREMOTEIO in that case.
Reported-by: Yiwen Jiang <jiangyiwen@huawei.com>
Suggested-by: Mike Snitzer <snitzer@redhat.com>
Reviewed-by: Hannes Reinicke <hare@suse.de>
Reviewed-by: Ewan Milne <emilne@redhat.com>
Reviewed-by: Yiwen Jiang <jiangyiwen@huawei.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/sd.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index ec163d08f6c3..6e841c6da632 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c | |||
@@ -761,7 +761,7 @@ static int sd_setup_discard_cmnd(struct scsi_cmnd *cmd) | |||
761 | break; | 761 | break; |
762 | 762 | ||
763 | default: | 763 | default: |
764 | ret = BLKPREP_KILL; | 764 | ret = BLKPREP_INVALID; |
765 | goto out; | 765 | goto out; |
766 | } | 766 | } |
767 | 767 | ||
@@ -839,7 +839,7 @@ static int sd_setup_write_same_cmnd(struct scsi_cmnd *cmd) | |||
839 | int ret; | 839 | int ret; |
840 | 840 | ||
841 | if (sdkp->device->no_write_same) | 841 | if (sdkp->device->no_write_same) |
842 | return BLKPREP_KILL; | 842 | return BLKPREP_INVALID; |
843 | 843 | ||
844 | BUG_ON(bio_offset(bio) || bio_iovec(bio).bv_len != sdp->sector_size); | 844 | BUG_ON(bio_offset(bio) || bio_iovec(bio).bv_len != sdp->sector_size); |
845 | 845 | ||