From patchwork Fri Jun 5 05:33:22 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dave Chiluk X-Patchwork-Id: 481027 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) by ozlabs.org (Postfix) with ESMTP id AFA4D14027F; Fri, 5 Jun 2015 15:33:43 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1Z0kG9-0005ec-V9; Fri, 05 Jun 2015 05:33:37 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtp (Exim 4.76) (envelope-from ) id 1Z0kG2-0005eF-MV for kernel-team@lists.ubuntu.com; Fri, 05 Jun 2015 05:33:30 +0000 Received: from [10.172.65.168] (helo=beastly.buildd) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1Z0kG2-00020d-Bw for kernel-team@lists.ubuntu.com; Fri, 05 Jun 2015 05:33:30 +0000 From: Dave Chiluk To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/2] [Trusty][SRU](upstream)[SCSI] Add timeout to avoid infinite command retry Date: Fri, 5 Jun 2015 00:33:22 -0500 Message-Id: <1433482403-9214-2-git-send-email-chiluk@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1433482403-9214-1-git-send-email-chiluk@canonical.com> References: <1433482403-9214-1-git-send-email-chiluk@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.14 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: kernel-team-bounces@lists.ubuntu.com From: Eiichi Tsukata BugLink: http://bugs.launchpad.net/bugs/1449372 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 Signed-off-by: James Bottomley (cherry picked from commit ee60b2c52ec8ecdcbcd2f85cc117b525f649441f) Signed-off-by: Dave Chiluk --- drivers/scsi/scsi_lib.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 719bd82..17da5c7 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) enum {ACTION_FAIL, ACTION_REPREP, ACTION_RETRY, ACTION_DELAYED_RETRY} action; char *description = NULL; + unsigned long wait_for = (cmd->allowed + 1) * req->timeout; if (result) { sense_valid = scsi_command_normalize_sense(cmd, &sshdr); @@ -997,6 +998,12 @@ void scsi_io_completion(struct scsi_cmnd *cmd, unsigned int good_bytes) action = ACTION_FAIL; } + if (action != ACTION_FAIL && + time_before(cmd->jiffies_at_alloc + wait_for, jiffies)) { + action = ACTION_FAIL; + description = "Command timed out"; + } + switch (action) { case ACTION_FAIL: /* Give up and fail the remainder of the request */