All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bernd Schubert <bs@q-leap.de>
To: linux-scsi@vger.kernel.org
Cc: James Bottomley <James.Bottomley@hansenpartnership.com>
Subject: [PATCH 5/7] time needs to be adjusted when eh was running
Date: Wed, 26 Nov 2008 19:29:25 +0100	[thread overview]
Message-ID: <200811261929.25959.bs@q-leap.de> (raw)
In-Reply-To: <200811261840.45360.bs@q-leap.de>

If the error handler was active and we use the normal command timeout,
the command will probably fail, even though the error handler may have
succeeded to recover the device.

Signed-off-by: Bernd Schubert <bs@q-leap.de>


 drivers/scsi/scsi_error.c |    3 +++
 drivers/scsi/scsi_lib.c   |   13 ++++++++++++-
 include/scsi/scsi_host.h  |    2 ++
 3 files changed, 17 insertions(+), 1 deletion(-)

Index: linux-2.6/drivers/scsi/scsi_lib.c
===================================================================
--- linux-2.6.orig/drivers/scsi/scsi_lib.c
+++ linux-2.6/drivers/scsi/scsi_lib.c
@@ -1537,7 +1537,9 @@ static void scsi_softirq_done(struct req
 {
 	struct scsi_cmnd *cmd = rq->special;
 	unsigned long wait_for = (cmd->allowed + 1) * rq->timeout;
+	unsigned long cmd_start;
 	int disposition;
+	struct Scsi_Host *shost = cmd->device->host;
 
 	INIT_LIST_HEAD(&cmd->eh_entry);
 
@@ -1550,9 +1552,18 @@ static void scsi_softirq_done(struct req
 	if (cmd->result)
 		atomic_inc(&cmd->device->ioerr_cnt);
 
+	/*
+	 * If the error handler was active, the command will need more time,
+	 * of course.
+	 */
+	if (shost->last_recovery > cmd->jiffies_at_alloc)
+		cmd_start = shost->last_recovery;
+	else
+		cmd_start = cmd->jiffies_at_alloc;
+
 	disposition = scsi_decide_disposition(cmd);
 	if (disposition != SUCCESS &&
-	    time_before(cmd->jiffies_at_alloc + wait_for, jiffies)) {
+	    time_before(cmd_start + wait_for, jiffies)) {
 		sdev_printk(KERN_ERR, cmd->device,
 			    "timing out command, waited %lus\n",
 			    wait_for/HZ);
Index: linux-2.6/include/scsi/scsi_host.h
===================================================================
--- linux-2.6.orig/include/scsi/scsi_host.h
+++ linux-2.6/include/scsi/scsi_host.h
@@ -521,6 +521,8 @@ struct Scsi_Host {
 	struct task_struct    * ehandler;  /* Error recovery thread. */
 	struct completion     * eh_action; /* Wait for specific actions on the
 					      host. */
+	unsigned long		last_recovery;  /* last time eh completed */
+
 	wait_queue_head_t       host_wait;
 	struct scsi_host_template *hostt;
 	struct scsi_transport_template *transportt;
Index: linux-2.6/drivers/scsi/scsi_error.c
===================================================================
--- linux-2.6.orig/drivers/scsi/scsi_error.c
+++ linux-2.6/drivers/scsi/scsi_error.c
@@ -1559,6 +1559,9 @@ static void scsi_restart_operations(stru
 			BUG_ON(scsi_host_set_state(shost, SHOST_DEL));
 	spin_unlock_irqrestore(shost->host_lock, flags);
 
+	/* before starting the queues save the time of recovery */
+	shost->last_recovery = jiffies;
+
 	wake_up(&shost->host_wait);
 
 	/*


-- 
Bernd Schubert
Q-Leap Networks GmbH

  parent reply	other threads:[~2008-11-26 18:29 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-26 17:40 [PATCH 0/7] scsi error handler improvements Bernd Schubert
2008-11-26 17:44 ` [PATCH 1/7] print eh activation Bernd Schubert
2008-11-26 18:47   ` James Bottomley
2008-12-03 11:19     ` Bernd Schubert
2008-12-03 15:16       ` James Bottomley
2008-12-03 15:52         ` Bernd Schubert
2008-11-26 17:46 ` [PATCH 2/7] Allow requeuement on DID_SOFT_ERROR Bernd Schubert
2008-11-26 18:47   ` James Bottomley
2008-12-03 12:17     ` Bernd Schubert
2008-12-03 15:16       ` James Bottomley
2008-12-03 16:00         ` Bernd Schubert
2008-12-03 16:29           ` James Bottomley
2008-12-03 17:06             ` Bernd Schubert
2008-11-26 18:25 ` [PATCH 03/07] Don't online offlined devices in scsi_target_quiesce() Bernd Schubert
2008-11-26 18:26 ` [PATCH 4/7] allow activation of eh on DID_NO_CONNECT Bernd Schubert
2008-11-26 18:29 ` Bernd Schubert [this message]
2009-01-07 18:09   ` [PATCH 5/7] time needs to be adjusted when eh was running Bernd Schubert
2008-11-26 18:31 ` [PATCH 6/7] SYNCHRONIZE_CACHE command used fixed value Bernd Schubert
2008-11-26 18:32 ` [PATCH 0/7] trivial: move a variable from function to if-scope Bernd Schubert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200811261929.25959.bs@q-leap.de \
    --to=bs@q-leap.de \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.