linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Takahiro Yasui <tyasui@redhat.com>
To: linux-scsi@vger.kernel.org
Cc: mchristi@redhat.com, mbarrow@redhat.com
Subject: [RFC][PATCH] limit state change to SDEV_BLOCK devices in scsi_internal_device_unblock
Date: Mon, 27 Apr 2009 13:09:57 -0400	[thread overview]
Message-ID: <49F5E6E5.20904@redhat.com> (raw)

Hi,

This is a patch to fix SCSI timeout error recovery issue which
I posted about one week ago.

  [RFC] SCSI timeout error recovery issue
  http://marc.info/?l=linux-scsi&m=124042136915970&w=2

scsi timeout on two or more devices may cause extremely long execution
time for user applications because SDEV_OFFLINE state is changed to
SDEV_RUNNING state during scsi error recovery procedures triggered by
a bus reset or a host reset of LLD, and scsi timeout can happens on
the same devices many times.

This happens because scsi_internal_device_unblock() changes device's state
to SDEV_RUNNING even if a device in other states than SDEV_BLOCK, but
scsi_internal_device_block() is a pair with scsi_internal_device_unblock()
and only devices in SDEV_BLOCK state are needed to be changed. This patch
adds a check of the current device state so that state change and queue
activation is not executed for devices in SDEV_BLOCK state.

This patch is based on the idea that devices in SDEV_OFFLINE state need to
stay in SDEV_OFFLINE because SDEV_OFFLINE state is done by:

 - All recovery procedures, bus reset and host reset, has already failed
   for devices in SDEV_OFFLINE state.
   (There is no (or rare?) chance to be recovered.)

 - A user has changed the device's state to SDEV_OFFLINE intentionally
   by an interface such as sysfs.
   (A user needs to enable devices in SDEV_OFFLINE state before using
    them again.)

I appreciate any comments and suggestions on this patch.

Regards,
---
Takahiro Yasui
Hitachi Computer Products (America), Inc.


Signed-off-by: Takahiro Yasui <tyasui@redhat.com>
---
 drivers/scsi/scsi_lib.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

Index: linux-2.6.29/drivers/scsi/scsi_lib.c
===================================================================
--- linux-2.6.29.orig/drivers/scsi/scsi_lib.c
+++ linux-2.6.29/drivers/scsi/scsi_lib.c
@@ -2633,9 +2633,12 @@ scsi_internal_device_unblock(struct scsi
 	unsigned long flags;
 	
 	/* 
-	 * Try to transition the scsi device to SDEV_RUNNING
-	 * and goose the device queue if successful.  
+	 * Try to transition the scsi device to SDEV_RUNNING if it is
+	 * SDEV_BLOCK and goose the device queue if successful.
 	 */
+	if (sdev->sdev_state != SDEV_BLOCK)
+		return 0;
+
 	err = scsi_device_set_state(sdev, SDEV_RUNNING);
 	if (err) {
 		err = scsi_device_set_state(sdev, SDEV_CREATED);





             reply	other threads:[~2009-04-27 17:09 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-27 17:09 Takahiro Yasui [this message]
2009-04-27 18:03 ` [RFC][PATCH] limit state change to SDEV_BLOCK devices in scsi_internal_device_unblock Matthew Wilcox
2009-04-27 19:43   ` Takahiro Yasui
2009-04-27 20:08 ` James Bottomley
2009-04-27 23:52   ` Takahiro Yasui
2009-04-28  2:31     ` Matthew Wilcox
2009-04-28  2:51       ` Takahiro Yasui
2009-04-28  3:27         ` Takahiro Yasui

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=49F5E6E5.20904@redhat.com \
    --to=tyasui@redhat.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mbarrow@redhat.com \
    --cc=mchristi@redhat.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;
as well as URLs for NNTP newsgroup(s).