path: root/block
diff options
authorMartin K. Petersen <>2016-02-04 00:52:12 -0500
committerMartin K. Petersen <>2016-02-04 22:42:58 -0500
commit0fb5b1fb30fba3671dd5b1489d78e93e08d62e4e (patch)
tree090ebf83b190bff02e29a43f8611503d066e33c5 /block
parent82c43310508eb19eb41fe7862e89afeb74030b84 (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 <> Suggested-by: Mike Snitzer <> Reviewed-by: Hannes Reinicke <> Reviewed-by: Ewan Milne <> Reviewed-by: Yiwen Jiang <> Signed-off-by: Martin K. Petersen <>
Diffstat (limited to 'block')
1 files changed, 4 insertions, 2 deletions
diff --git a/block/blk-core.c b/block/blk-core.c
index 476244d59309..35607dd0223b 100644
--- a/block/blk-core.c
+++ b/block/blk-core.c
@@ -2447,14 +2447,16 @@ struct request *blk_peek_request(struct request_queue *q)
rq = NULL;
- } else if (ret == BLKPREP_KILL) {
+ } else if (ret == BLKPREP_KILL || ret == BLKPREP_INVALID) {
+ int err = (ret == BLKPREP_INVALID) ? -EREMOTEIO : -EIO;
rq->cmd_flags |= REQ_QUIET;
* Mark this request as started so we don't trigger
* any debug logic in the end I/O path.
- __blk_end_request_all(rq, -EIO);
+ __blk_end_request_all(rq, err);
} else {
printk(KERN_ERR "%s: bad return=%d\n", __func__, ret);