public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@steeleye.com>
To: Luben Tuikov <luben_tuikov@adaptec.com>
Cc: Mike Anderson <andmike@us.ibm.com>,
	SCSI Mailing List <linux-scsi@vger.kernel.org>
Subject: Re: [PATCH]: Flexible timeout infrastructure
Date: 16 Jun 2004 10:58:36 -0500	[thread overview]
Message-ID: <1087401518.1747.21.camel@mulgrave> (raw)
In-Reply-To: <40D06BD7.1050605@adaptec.com>

On Wed, 2004-06-16 at 10:48, Luben Tuikov wrote:
> Anyway, do we have a patch for *this* solution?

Here's a sketch of the implementation (without all the comments etc that
would need to be done) so people can visualise it

James

===== drivers/scsi/scsi.c 1.143 vs edited =====
--- 1.143/drivers/scsi/scsi.c	2004-04-28 11:32:09 -05:00
+++ edited/drivers/scsi/scsi.c	2004-06-16 10:47:05 -05:00
@@ -689,8 +689,6 @@
  */
 void scsi_done(struct scsi_cmnd *cmd)
 {
-	unsigned long flags;
-
 	/*
 	 * We don't have to worry about this one timing out any more.
 	 * If we are unable to remove the timer, then the command
@@ -701,6 +699,14 @@
 	 */
 	if (!scsi_delete_timer(cmd))
 		return;
+	__scsi_done(cmd);
+}
+
+/* Private entry to scsi_done() to complete a command when the timer
+ * isn't running --- used by scsi_times_out */
+void __scsi_done(struct scsi_cmnd *cmd)
+{
+	unsigned long flags;
 
 	/*
 	 * Set the serial numbers back to zero
===== drivers/scsi/scsi_error.c 1.77 vs edited =====
--- 1.77/drivers/scsi/scsi_error.c	2004-06-06 06:19:15 -05:00
+++ edited/drivers/scsi/scsi_error.c	2004-06-16 10:53:02 -05:00
@@ -162,6 +162,24 @@
 void scsi_times_out(struct scsi_cmnd *scmd)
 {
 	scsi_log_completion(scmd, TIMEOUT_ERROR);
+
+	if (scmd->device->host->hostt->eh_timed_out)
+		switch (scmd->device->host->hostt->eh_timed_out(scmd)) {
+		case EH_HANDLED:
+			__scsi_done(scmd);
+			return;
+		case EH_RESET_TIMER:
+			/* This allows a single retry even of a command
+			 * with allowed == 0 */
+			if (scmd->retries++ > scmd->allowed)
+				break;
+			scsi_add_timer(scmd, scmd->timeout_per_command,
+				       scsi_times_out);
+			return;
+		case EH_NOT_HANDLED:
+			break;
+		}
+
 	if (unlikely(!scsi_eh_scmd_add(scmd, SCSI_EH_CANCEL_CMD))) {
 		panic("Error handler thread not present at %p %p %s %d",
 		      scmd, scmd->device->host, __FILE__, __LINE__);
===== drivers/scsi/scsi_priv.h 1.32 vs edited =====
--- 1.32/drivers/scsi/scsi_priv.h	2004-03-10 22:20:08 -06:00
+++ edited/drivers/scsi/scsi_priv.h	2004-06-16 10:45:44 -05:00
@@ -82,6 +82,7 @@
 extern void scsi_init_cmd_from_req(struct scsi_cmnd *cmd,
 		struct scsi_request *sreq);
 extern void __scsi_release_request(struct scsi_request *sreq);
+extern void __scsi_done(struct scsi_cmnd *cmd);
 #ifdef CONFIG_SCSI_LOGGING
 void scsi_log_send(struct scsi_cmnd *cmd);
 void scsi_log_completion(struct scsi_cmnd *cmd, int disposition);
===== include/scsi/scsi_host.h 1.17 vs edited =====
--- 1.17/include/scsi/scsi_host.h	2004-06-04 11:51:31 -05:00
+++ edited/include/scsi/scsi_host.h	2004-06-16 10:36:23 -05:00
@@ -30,6 +30,12 @@
 #define DISABLE_CLUSTERING 0
 #define ENABLE_CLUSTERING 1
 
+enum scsi_eh_timer_return {
+	EH_NOT_HANDLED,
+	EH_HANDLED,
+	EH_RESET_TIMER,
+};
+
 
 struct scsi_host_template {
 	struct module *module;
@@ -124,6 +130,8 @@
 	int (* eh_device_reset_handler)(struct scsi_cmnd *);
 	int (* eh_bus_reset_handler)(struct scsi_cmnd *);
 	int (* eh_host_reset_handler)(struct scsi_cmnd *);
+
+	enum scsi_eh_timer_return (* eh_timed_out)(struct scsi_cmnd *);
 
 	/*
 	 * Old EH handlers, no longer used. Make them warn the user of old


  reply	other threads:[~2004-06-16 15:58 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-15 15:02 [PATCH]: Flexible timeout infrastructure Luben Tuikov
2004-06-15 15:08 ` Signed-off-by: added [Re: [PATCH]: Flexible timeout infrastructure] Luben Tuikov
2004-06-15 15:24   ` Matthew Wilcox
2004-06-15 15:27 ` [PATCH]: Flexible timeout infrastructure Arjan van de Ven
2004-06-15 15:40   ` Luben Tuikov
2004-06-15 15:42     ` Christoph Hellwig
2004-06-15 15:46       ` Luben Tuikov
2004-06-15 15:49         ` Christoph Hellwig
2004-06-15 15:43     ` Arjan van de Ven
2004-06-15 15:48       ` Luben Tuikov
2004-06-15 15:57         ` Christoph Hellwig
2004-06-15 16:07           ` Arjan van de Ven
2004-06-15 16:24           ` Doug Ledford
2004-06-15 16:27           ` Luben Tuikov
2004-06-15 16:33             ` Arjan van de Ven
2004-06-15 18:07               ` Luben Tuikov
2004-06-15 15:31 ` James Bottomley
2004-06-15 18:15   ` Mike Anderson
2004-06-15 18:37     ` Luben Tuikov
2004-06-15 19:20       ` Mike Anderson
2004-06-15 19:52         ` Luben Tuikov
2004-06-15 20:57           ` Mike Anderson
2004-06-15 22:00             ` Luben Tuikov
2004-06-15 22:31               ` Luben Tuikov
2004-06-15 22:13             ` Doug Ledford
2004-06-15 19:12   ` Luben Tuikov
2004-06-15 19:54     ` James Bottomley
2004-06-16 15:27       ` Mike Anderson
2004-06-16 15:37         ` James Bottomley
2004-06-16 15:48           ` Luben Tuikov
2004-06-16 15:58             ` James Bottomley [this message]
  -- strict thread matches above, loose matches on Subject: below --
2004-06-16 16:58 Smart, James
2004-06-16 17:04 ` James Bottomley
2004-06-16 18:58   ` Luben Tuikov
2004-06-16 19:17     ` James Bottomley
2004-06-16 17:10 Smart, James
2004-06-16 17:21 ` James Bottomley
2004-06-16 17:33 Smart, James
2004-06-16 17:38 ` James Bottomley
2004-06-16 18:05 Smart, James

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=1087401518.1747.21.camel@mulgrave \
    --to=james.bottomley@steeleye.com \
    --cc=andmike@us.ibm.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=luben_tuikov@adaptec.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox