[PATCH] [scsi]: Add offline state checking while dispatch a scsi cmd

From: Joe Jin
Date: Thu Mar 08 2007 - 04:24:29 EST


While a scsi device hw error occured, device's status maybe setting
to SDEV_OFFLINE, So at scsi_dispatch_cmd function, we should checking
if device have offline, if yes, do nothing and just return error to
user directly.


Signed-off-by: Joe Jin <lkmaillist@xxxxxxxxx>
--
--- linux-2.6.21-rc2/drivers/scsi/scsi.c.orig 2007-03-08 16:50:14.000000000 +0800
+++ linux-2.6.21-rc2/drivers/scsi/scsi.c 2007-03-08 16:52:45.000000000 +0800
@@ -486,10 +486,12 @@
int rtn = 0;

/* check if the device is still usable */
- if (unlikely(cmd->device->sdev_state == SDEV_DEL)) {
- /* in SDEV_DEL we error all commands. DID_NO_CONNECT
- * returns an immediate error upwards, and signals
- * that the device is no longer present */
+ if (unlikely(cmd->device->sdev_state == SDEV_DEL ||
+ cmd->device->sdev_state == SDEV_OFFLINE)) {
+ /* in SDEV_DEL or SDEV_OFFLINE we error all commands.
+ * DID_NO_CONNECT returns an immediate error upwards,
+ * and signals that the device is no longer present
+ */
cmd->result = DID_NO_CONNECT << 16;
atomic_inc(&cmd->device->iorequest_cnt);
__scsi_done(cmd);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/