Commit 709c75b5 authored by jiang.biao2@zte.com.cn's avatar jiang.biao2@zte.com.cn Committed by James Bottomley

scsi_error: should not get sense for timeout IO in scsi error handler

scsi_error: should not get sense for timeout IO in scsi error handler

When an IO timeout occurs, the IO will be aborted in
scsi_abort_command() and SCSI_EH_ABORT_SCHEDULED will be set. Because
of that, the SCSI_EH_CANCEL_CMD will be clear in scsi_eh_scmd_add().
So when scsi error handler starts, it will get sense for this
timeout IO and the scmd of the IO request will be reused. In that
case, the scmd may be double released when racing with io_done(),
which will result in crash.
SO SCSI_EH_ABORT_SCHEDULED should also be checked when getting sense.
The bug maybe reproduced when the link between host and disk is
unstable.
Signed-off-by: default avatarJiang Biao <jiang.biao2@zte.com.cn>
Signed-off-by: default avatarLong Chun <long.chun@zte.com.cn>
Reviewed-by: default avatarTan Hu <tan.hu@zte.com.cn>
Reviewed-by: default avatarChen Donghai <chen.donghai@zte.com.cn>
Reviewed-by: default avatarCai Qu <cai.qu@zte.com.cn>
Signed-off-by: default avatarJames Bottomley <JBottomley@Odin.com>
parent 1cd12991
...@@ -1160,8 +1160,13 @@ int scsi_eh_get_sense(struct list_head *work_q, ...@@ -1160,8 +1160,13 @@ int scsi_eh_get_sense(struct list_head *work_q,
struct Scsi_Host *shost; struct Scsi_Host *shost;
int rtn; int rtn;
/*
* If SCSI_EH_ABORT_SCHEDULED has been set, it is timeout IO,
* should not get sense.
*/
list_for_each_entry_safe(scmd, next, work_q, eh_entry) { list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
if ((scmd->eh_eflags & SCSI_EH_CANCEL_CMD) || if ((scmd->eh_eflags & SCSI_EH_CANCEL_CMD) ||
(scmd->eh_eflags & SCSI_EH_ABORT_SCHEDULED) ||
SCSI_SENSE_VALID(scmd)) SCSI_SENSE_VALID(scmd))
continue; continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment