aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi
diff options
context:
space:
mode:
authorEiichi Tsukata <eiichi.tsukata.xh@hitachi.com>2014-02-11 00:29:52 -0500
committerJames Bottomley <JBottomley@Parallels.com>2014-03-15 13:19:19 -0400
commitee60b2c52ec8ecdcbcd2f85cc117b525f649441f (patch)
tree6303d3553a35c5f42351f8042d9fd0dda4e6b71a /drivers/scsi
parenteee2b5c840d93f704554f4a2884cef72742f22e2 (diff)
[SCSI] Add timeout to avoid infinite command retry
Currently, scsi error handling in scsi_io_completion() tries to unconditionally requeue scsi command when device keeps some error state. For example, UNIT_ATTENTION causes infinite retry with action == ACTION_RETRY. This is because retryable errors are thought to be temporary and the scsi device will soon recover from those errors. Normally, such retry policy is appropriate because the device will soon recover from temporary error state. But there is no guarantee that device is able to recover from error state immediately. Some hardware error can prevent device from recovering. This patch adds timeout in scsi_io_completion() to avoid infinite command retry in scsi_io_completion(). Once scsi command retry time is longer than this timeout, the command is treated as failure. Signed-off-by: Eiichi Tsukata <eiichi.tsukata.xh@hitachi.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Diffstat (limited to 'drivers/scsi')
-rw-r--r--drivers/scsi/scsi_lib.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 62ec84b42e31..f97a1a609ad0 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -788,6 +788,7 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
788 enum {ACTION_FAIL, ACTION_REPREP, ACTION_RETRY, 788 enum {ACTION_FAIL, ACTION_REPREP, ACTION_RETRY,
789 ACTION_DELAYED_RETRY} action; 789 ACTION_DELAYED_RETRY} action;
790 char *description = NULL; 790 char *description = NULL;
791 unsigned long wait_for = (cmd->allowed + 1) * req->timeout;
791 792
792 if (result) { 793 if (result) {
793 sense_valid = scsi_command_normalize_sense(cmd, &sshdr); 794 sense_valid = scsi_command_normalize_sense(cmd, &sshdr);
@@ -989,6 +990,12 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes)
989 action = ACTION_FAIL; 990 action = ACTION_FAIL;
990 } 991 }
991 992
993 if (action != ACTION_FAIL &&
994 time_before(cmd->jiffies_at_alloc + wait_for, jiffies)) {
995 action = ACTION_FAIL;
996 description = "Command timed out";
997 }
998
992 switch (action) { 999 switch (action) {
993 case ACTION_FAIL: 1000 case ACTION_FAIL:
994 /* Give up and fail the remainder of the request */ 1001 /* Give up and fail the remainder of the request */