aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKeith Busch <keith.busch@intel.com>2018-07-23 10:37:51 -0400
committerJens Axboe <axboe@kernel.dk>2018-07-24 16:41:52 -0400
commit065990bd198e0e67417c2c34e5e80140d4b8cef7 (patch)
tree599953a4f653a4091f05074bb7e7cfa94cac2a9b
parent0fc09f920983f61be625658c62cc40ac25a7b3a5 (diff)
scsi: set timed out out mq requests to complete
The scsi block layer requires requests claimed by the error handling be completed by the error handler. A previous commit allowed completions to proceed for blk-mq, breaking that assumption. This patch prevents completions that may race with the timeout handler by marking the state to complete, restoring the previous behavior. Fixes: 12f5b931 ("blk-mq: Remove generation seqeunce") Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Keith Busch <keith.busch@intel.com> Signed-off-by: Jens Axboe <axboe@kernel.dk>
-rw-r--r--drivers/scsi/scsi_error.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 8932ae81a15a..2715cdaa669c 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -296,6 +296,20 @@ enum blk_eh_timer_return scsi_times_out(struct request *req)
296 rtn = host->hostt->eh_timed_out(scmd); 296 rtn = host->hostt->eh_timed_out(scmd);
297 297
298 if (rtn == BLK_EH_DONE) { 298 if (rtn == BLK_EH_DONE) {
299 /*
300 * For blk-mq, we must set the request state to complete now
301 * before sending the request to the scsi error handler. This
302 * will prevent a use-after-free in the event the LLD manages
303 * to complete the request before the error handler finishes
304 * processing this timed out request.
305 *
306 * If the request was already completed, then the LLD beat the
307 * time out handler from transferring the request to the scsi
308 * error handler. In that case we can return immediately as no
309 * further action is required.
310 */
311 if (req->q->mq_ops && !blk_mq_mark_complete(req))
312 return rtn;
299 if (scsi_abort_command(scmd) != SUCCESS) { 313 if (scsi_abort_command(scmd) != SUCCESS) {
300 set_host_byte(scmd, DID_TIME_OUT); 314 set_host_byte(scmd, DID_TIME_OUT);
301 scsi_eh_scmd_add(scmd); 315 scsi_eh_scmd_add(scmd);