Commit 1b8d2620 authored by Mike Christie's avatar Mike Christie Committed by James Bottomley

[SCSI] add new SDEV_TRANSPORT_OFFLINE state

This patch adds a new state SDEV_TRANSPORT_OFFLINE. It will
be used by transport classes to offline devices for cases like
when the fast_io_fail/recovery_tmo fires. In those cases we
want all IO to fail, and we have not yet escalated to dev_loss_tmo
behavior where we are removing the devices.

Currently to handle this state, transport classes are setting
the scsi_device's state to running, setting their internal
session/port structs state to something that indicates failed,
and then failing IO from some transport check in the queuecommand.

The reason for the new value is so that users can distinguish
between a device failure that is a result of a transport problem
vs the wide range of errors that devices get offlined for
when a scsi command times out and we offline the devices there.
It also fixes the confusion as to why the transport class is
failing IO, but has set the device state from blocked to running.
Signed-off-by: default avatarMike Christie <michaelc@cs.wisc.edu>
Signed-off-by: default avatarJames Bottomley <JBottomley@Parallels.com>
parent 87098bdd
...@@ -1173,6 +1173,7 @@ int scsi_prep_state_check(struct scsi_device *sdev, struct request *req) ...@@ -1173,6 +1173,7 @@ int scsi_prep_state_check(struct scsi_device *sdev, struct request *req)
if (unlikely(sdev->sdev_state != SDEV_RUNNING)) { if (unlikely(sdev->sdev_state != SDEV_RUNNING)) {
switch (sdev->sdev_state) { switch (sdev->sdev_state) {
case SDEV_OFFLINE: case SDEV_OFFLINE:
case SDEV_TRANSPORT_OFFLINE:
/* /*
* If the device is offline we refuse to process any * If the device is offline we refuse to process any
* commands. The device must be brought online * commands. The device must be brought online
...@@ -2081,6 +2082,7 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state) ...@@ -2081,6 +2082,7 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state)
switch (oldstate) { switch (oldstate) {
case SDEV_CREATED: case SDEV_CREATED:
case SDEV_OFFLINE: case SDEV_OFFLINE:
case SDEV_TRANSPORT_OFFLINE:
case SDEV_QUIESCE: case SDEV_QUIESCE:
case SDEV_BLOCK: case SDEV_BLOCK:
break; break;
...@@ -2093,6 +2095,7 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state) ...@@ -2093,6 +2095,7 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state)
switch (oldstate) { switch (oldstate) {
case SDEV_RUNNING: case SDEV_RUNNING:
case SDEV_OFFLINE: case SDEV_OFFLINE:
case SDEV_TRANSPORT_OFFLINE:
break; break;
default: default:
goto illegal; goto illegal;
...@@ -2100,6 +2103,7 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state) ...@@ -2100,6 +2103,7 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state)
break; break;
case SDEV_OFFLINE: case SDEV_OFFLINE:
case SDEV_TRANSPORT_OFFLINE:
switch (oldstate) { switch (oldstate) {
case SDEV_CREATED: case SDEV_CREATED:
case SDEV_RUNNING: case SDEV_RUNNING:
...@@ -2136,6 +2140,7 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state) ...@@ -2136,6 +2140,7 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state)
case SDEV_RUNNING: case SDEV_RUNNING:
case SDEV_QUIESCE: case SDEV_QUIESCE:
case SDEV_OFFLINE: case SDEV_OFFLINE:
case SDEV_TRANSPORT_OFFLINE:
case SDEV_BLOCK: case SDEV_BLOCK:
break; break;
default: default:
...@@ -2148,6 +2153,7 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state) ...@@ -2148,6 +2153,7 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state)
case SDEV_CREATED: case SDEV_CREATED:
case SDEV_RUNNING: case SDEV_RUNNING:
case SDEV_OFFLINE: case SDEV_OFFLINE:
case SDEV_TRANSPORT_OFFLINE:
case SDEV_CANCEL: case SDEV_CANCEL:
break; break;
default: default:
......
...@@ -35,6 +35,7 @@ static const struct { ...@@ -35,6 +35,7 @@ static const struct {
{ SDEV_DEL, "deleted" }, { SDEV_DEL, "deleted" },
{ SDEV_QUIESCE, "quiesce" }, { SDEV_QUIESCE, "quiesce" },
{ SDEV_OFFLINE, "offline" }, { SDEV_OFFLINE, "offline" },
{ SDEV_TRANSPORT_OFFLINE, "transport-offline" },
{ SDEV_BLOCK, "blocked" }, { SDEV_BLOCK, "blocked" },
{ SDEV_CREATED_BLOCK, "created-blocked" }, { SDEV_CREATED_BLOCK, "created-blocked" },
}; };
......
...@@ -42,6 +42,7 @@ enum scsi_device_state { ...@@ -42,6 +42,7 @@ enum scsi_device_state {
* originate in the mid-layer) */ * originate in the mid-layer) */
SDEV_OFFLINE, /* Device offlined (by error handling or SDEV_OFFLINE, /* Device offlined (by error handling or
* user request */ * user request */
SDEV_TRANSPORT_OFFLINE, /* Offlined by transport class error handler */
SDEV_BLOCK, /* Device blocked by scsi lld. No SDEV_BLOCK, /* Device blocked by scsi lld. No
* scsi commands from user or midlayer * scsi commands from user or midlayer
* should be issued to the scsi * should be issued to the scsi
...@@ -421,6 +422,7 @@ static inline unsigned int sdev_id(struct scsi_device *sdev) ...@@ -421,6 +422,7 @@ static inline unsigned int sdev_id(struct scsi_device *sdev)
static inline int scsi_device_online(struct scsi_device *sdev) static inline int scsi_device_online(struct scsi_device *sdev)
{ {
return (sdev->sdev_state != SDEV_OFFLINE && return (sdev->sdev_state != SDEV_OFFLINE &&
sdev->sdev_state != SDEV_TRANSPORT_OFFLINE &&
sdev->sdev_state != SDEV_DEL); sdev->sdev_state != SDEV_DEL);
} }
static inline int scsi_device_blocked(struct scsi_device *sdev) static inline int scsi_device_blocked(struct scsi_device *sdev)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment