Skip to contentSkip to conversation

scsi: scsi_decide_disposition update

PATCH New Mike Anderson 1 participant 14 messages Sep 22, 2008 SCSI

lore
Share & tools
lore
#0 lore raw

cover scsi: scsi_decide_disposition update

This is a re-post of the scsi_decide_disposition_update against scsi-post-merge-2.6 with corrections to the sign off lines.

This patch series has been tested against the scsi-post-merge-2.6 git tree plus the latest updates from the linux-2.6-block for-2.6.28 branch.

Previous post url:
http://thread.gmane.org/gmane.linux.scsi/44412/focus=44463

Previous cover email:

This patch series is an update to a previous set of patches posted by Mike Christie in the thread referenced below.
http://thread.gmane.org/gmane.linux.scsi/44058/focus=4405

This patch series creates new return codes for scsi_decide_disposition and scsi_check_sense so that retry restrictions and disposition can be implied directly from the return code. Retry restrictions have also been moved into the requeue function.

Mike C and I have tested a few of the return code types, but it would be good to have other return types check with different hardware.

Change in behavior.
- dm-mp fast fail on transport errors.
- device busy and host busy limited by wait_for check.
- A few more error cases will return DRIVER_TIMEOUT. Possibly should add more DRIVER_ error codes.

A summary of the current disposition is shown below.

1.) Current disposition policy.
2.6.27 policy + DID_TRANSPORT patches

==============================================================================
scsi_queue_insert
==============================================================================
SCSI_MLQUEUE_EH_RETRY retry
SCSI_MLQUEUE_DEVICE_BUSY retry, set device_blocked
SCSI_MLQUEUE_HOST_BUSY retry, set host_blocked

==============================================================================
scsi_softirq_done
==============================================================================
disposition SUCCESS:
scsi_finish_command
disposition NEEDS_RETRY:
scsi_queue_insert SCSI_MLQUEUE_EH_RETRY
disposition ADD_TO_MLQUEUE:
scsi_queue_insert SCSI_MLQUEUE_DEVICE_BUSY
default:
scsi_eh_scmd_add

==============================================================================
host_byte
==============================================================================

DID_OK goto status_byte
DID_NO_CONNECT SUCCESS
DID_BUS_BUSY allowed && !blk_noretry
DID_TIME_OUT SUCCESS (TUR/INQ) / FAILED
DID_BAD_TARGET SUCCESS
DID_ABORT SUCCESS
DID_PARITY allowed && !blk_noretry
DID_ERROR allowed && !blk_noretry (status for RES)
DID_RESET SUCCESS
DID_BAD_INTR default
DID_PASSTHROUGH SUCCESS
DID_SOFT_ERROR allowed && !blk_noretry
DID_IMM_RETRY NEEDS_RETRY
DID_REQUEUE ADD_TO_MLQUEUE
DID_TRANSPORT_DISRUPTED ADD_TO_MLQUEUE
DID_TRANSPORT_FAILFAST SUCCESS
default FAILED

==============================================================================
status_byte
==============================================================================

QUEUE_FULL ADD_TO_MLQUEUE
BUSY ADD_TO_MLQUEUE
GOOD SUCCESS
COMMAND_TERMINATED SUCCESS
TASK_ABORTED SUCCESS
CHECK_CONDITION SEE SENSE
CONDITION_GOOD SUCCESS
INTERMEDIATE_GOOD SUCCESS
INTERMEDIATE_C_GOOD SUCCESS
ACA_ACTIVE SUCCESS
RESERVATION_CONFLICT SUCCESS
default FAILED

==============================================================================
sense
==============================================================================

!normalize_sense FAILED
scsi_sense_is_deferred NEEDS_RETRY (allowed && !blk_noretry)

scsi_dh->check_sense handler return

FILEMARK, EOM or ILI SUCCESS

NO_SENSE SUCCESS
RECOVERED_ERROR SUCCESS
ABORTED_COMMAND SUCCESS (DIF) / NEEDS_RETRY
NOT_READY NEEDS_RETRY (ua, bc rdy) / FAILED (restart) / SUCCESS
UNIT_ATTENTION NEEDS_RETRY (ua, bc rdy) / FAILED (restart) / SUCCESS
COPY_ABORTED SUCCESS
VOLUME_OVERFLOW SUCCESS
MISCOMPARE SUCCESS
MEDIUM_ERROR SUCCESS (0x11, 0x13, 0x14) / NEEDS_RETRY
HARDWARE_ERROR ADD_TO_MLQUEUE (retry_hwerror) / SUCCESS
ILLEGAL_REQUEST SUCCESS
BLANK_CHECK SUCCESS
DATA_PROTECT SUCCESS
default SUCCESS

#1 lore raw

PATCH 1/13 scsi: Move wait_for check

Move wait_for check to scsi_queue_insert.

---
 drivers/scsi/scsi_lib.c |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)
drivers/scsi/scsi_lib.c +9 -8
index 517fd90..83a8aae 100644
@@ -116,11 +116,20 @@ int scsi_queue_insert(struct scsi_cmnd *cmd, int reason)
 	struct scsi_device *device = cmd->device;
 	struct scsi_target *starget = scsi_target(device);
 	struct request_queue *q = device->request_queue;
+	unsigned long wait_for = (cmd->allowed + 1) * cmd->request->timeout;
 	unsigned long flags;
 
 	SCSI_LOG_MLQUEUE(1,
 		 printk("Inserting command %p into mlqueue\n", cmd));
 
+	if (time_before(cmd->jiffies_at_alloc + wait_for, jiffies)) {
+		sdev_printk(KERN_ERR, cmd->device, "timing out command, "
+			    "waited %lus\n", wait_for/HZ);
+		set_driver_byte(cmd, DRIVER_TIMEOUT);
+		scsi_finish_command(cmd);
+		return 0;
+	}
+
 	/*
 	 * Set the appropriate busy bit for the device/host.
 	 *
@@ -1494,7 +1503,6 @@ static void scsi_kill_request(struct request *req, struct request_queue *q)
 static void scsi_softirq_done(struct request *rq)
 {
 	struct scsi_cmnd *cmd = rq->special;
-	unsigned long wait_for = (cmd->allowed + 1) * rq->timeout;
 	int disposition;
 
 	INIT_LIST_HEAD(&cmd->eh_entry);
@@ -1509,13 +1517,6 @@ static void scsi_softirq_done(struct request *rq)
 		atomic_inc(&cmd->device->ioerr_cnt);
 
 	disposition = scsi_decide_disposition(cmd);
-	if (disposition != SUCCESS &&
-	    time_before(cmd->jiffies_at_alloc + wait_for, jiffies)) {
-		sdev_printk(KERN_ERR, cmd->device,
-			    "timing out command, waited %lus\n",
-			    wait_for/HZ);
-		disposition = SUCCESS;
-	}
 			
 	scsi_log_completion(cmd, disposition);
 
Signature · 1 line
1.5.5.1
#2 lore raw

PATCH 2/13 scsi: Move retries check

In reply to Mike Anderson

Move retries check to scsi_queue_insert.

---
 drivers/scsi/scsi_error.c |    8 ++------
 drivers/scsi/scsi_lib.c   |    7 +++++++
 2 files changed, 9 insertions(+), 6 deletions(-)
drivers/scsi/scsi_error.c +2 -6
index d8000ef..55bf0e5 100644
@@ -1320,8 +1320,6 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 	case DID_SOFT_ERROR:
 		goto maybe_retry;
 	case DID_IMM_RETRY:
-		return NEEDS_RETRY;
-
 	case DID_REQUEUE:
 		return ADD_TO_MLQUEUE;
 	case DID_TRANSPORT_DISRUPTED:
@@ -1429,8 +1427,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 	 * the request was not marked fast fail.  Note that above,
 	 * even if the request is marked fast fail, we still requeue
 	 * for queue congestion conditions (QUEUE_FULL or BUSY) */
-	if ((++scmd->retries) <= scmd->allowed
-	    && !scsi_noretry_cmd(scmd)) {
+	if (!blk_noretry_request(scmd->request)) {
 		return NEEDS_RETRY;
 	} else {
 		/*
@@ -1555,8 +1552,7 @@ void scsi_eh_flush_done_q(struct list_head *done_q)
 	list_for_each_entry_safe(scmd, next, done_q, eh_entry) {
 		list_del_init(&scmd->eh_entry);
 		if (scsi_device_online(scmd->device) &&
-		    !scsi_noretry_cmd(scmd) &&
-		    (++scmd->retries <= scmd->allowed)) {
+		    !blk_noretry_request(scmd->request)) {
 			SCSI_LOG_ERROR_RECOVERY(3, printk("%s: flush"
 							  " retry cmd: %p\n",
 							  current->comm,
drivers/scsi/scsi_lib.c +7 -0
index 83a8aae..557e511 100644
@@ -153,6 +153,13 @@ int scsi_queue_insert(struct scsi_cmnd *cmd, int reason)
 	case SCSI_MLQUEUE_TARGET_BUSY:
 		starget->target_blocked = starget->max_target_blocked;
 		break;
+	case SCSI_MLQUEUE_EH_RETRY:
+		if (++cmd->retries > cmd->allowed) {
+			set_driver_byte(cmd, DRIVER_TIMEOUT);
+			scsi_finish_command(cmd);
+			return 0;
+		}
+		break;
 	}
 
 	/*
Signature · 1 line
1.5.5.1
#5 lore raw

PATCH 5/13 scsi: change return codes in scsi_decide_disposition

In reply to Mike Anderson

Created new return codes for scsi_decide_disposition and scsi_check_sense so that retry restrictions and disposition can be implied directly from the return code.

---
 drivers/scsi/scsi_error.c |   80 +++++++++++++++++++++++----------------------
 drivers/scsi/scsi_lib.c   |   35 ++++++++++---------
 include/scsi/scsi.h       |   33 ++++++++++++++++--
 3 files changed, 88 insertions(+), 60 deletions(-)
drivers/scsi/scsi_error.c +41 -39
index b092089..ae46cb0 100644
@@ -229,7 +229,9 @@ static inline void scsi_eh_prt_fail_stats(struct Scsi_Host *shost,
  * @scmd:	Cmd to have sense checked.
  *
  * Return value:
- * 	SUCCESS or FAILED or NEEDS_RETRY
+ * 	SCSI_MLQUEUE_DIS_FINISH
+ * 	SCSI_MLQUEUE_DIS_RETRY
+ * 	SCSI_MLQUEUE_DIS_FAIL
  *
  * Notes:
  *	When a deferred error is detected the current command has
@@ -241,10 +243,10 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
 	struct scsi_sense_hdr sshdr;
 
 	if (! scsi_command_normalize_sense(scmd, &sshdr))
-		return FAILED;	/* no valid sense data */
+		return SCSI_MLQUEUE_DIS_FAIL;	/* no valid sense data */
 
 	if (scsi_sense_is_deferred(&sshdr))
-		return NEEDS_RETRY;
+		return SCSI_MLQUEUE_DIS_RETRY;
 
 	if (sdev->scsi_dh_data && sdev->scsi_dh_data->scsi_dh &&
 			sdev->scsi_dh_data->scsi_dh->check_sense) {
@@ -263,7 +265,7 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
 	if (sshdr.response_code == 0x70) {
 		/* fixed format */
 		if (scmd->sense_buffer[2] & 0xe0)
-			return SUCCESS;
+			return SCSI_MLQUEUE_DIS_FINISH;
 	} else {
 		/*
 		 * descriptor format: look for "stream commands sense data
@@ -273,20 +275,20 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
 		if ((sshdr.additional_length > 3) &&
 		    (scmd->sense_buffer[8] == 0x4) &&
 		    (scmd->sense_buffer[11] & 0xe0))
-			return SUCCESS;
+			return SCSI_MLQUEUE_DIS_FINISH;
 	}
 
 	switch (sshdr.sense_key) {
 	case NO_SENSE:
-		return SUCCESS;
+		return SCSI_MLQUEUE_DIS_FINISH;
 	case RECOVERED_ERROR:
-		return /* soft_error */ SUCCESS;
+		return /* soft_error */ SCSI_MLQUEUE_DIS_FINISH;
 
 	case ABORTED_COMMAND:
 		if (sshdr.asc == 0x10) /* DIF */
-			return SUCCESS;
+			return SCSI_MLQUEUE_DIS_FINISH;
 
-		return NEEDS_RETRY;
+		return SCSI_MLQUEUE_DIS_RETRY;
 	case NOT_READY:
 	case UNIT_ATTENTION:
 		/*
@@ -297,48 +299,48 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
 		 */
 		if (scmd->device->expecting_cc_ua) {
 			scmd->device->expecting_cc_ua = 0;
-			return NEEDS_RETRY;
+			return SCSI_MLQUEUE_DIS_RETRY;
 		}
 		/*
 		 * if the device is in the process of becoming ready, we 
 		 * should retry.
 		 */
 		if ((sshdr.asc == 0x04) && (sshdr.ascq == 0x01))
-			return NEEDS_RETRY;
+			return SCSI_MLQUEUE_DIS_RETRY;
 		/*
 		 * if the device is not started, we need to wake
 		 * the error handler to start the motor
 		 */
 		if (scmd->device->allow_restart &&
 		    (sshdr.asc == 0x04) && (sshdr.ascq == 0x02))
-			return FAILED;
-		return SUCCESS;
+			return SCSI_MLQUEUE_DIS_FAIL;
+		return SCSI_MLQUEUE_DIS_FINISH;
 
 		/* these three are not supported */
 	case COPY_ABORTED:
 	case VOLUME_OVERFLOW:
 	case MISCOMPARE:
-		return SUCCESS;
+		return SCSI_MLQUEUE_DIS_FINISH;
 
 	case MEDIUM_ERROR:
 		if (sshdr.asc == 0x11 || /* UNRECOVERED READ ERR */
 		    sshdr.asc == 0x13 || /* AMNF DATA FIELD */
 		    sshdr.asc == 0x14) { /* RECORD NOT FOUND */
-			return SUCCESS;
+			return SCSI_MLQUEUE_DIS_FINISH;
 		}
-		return NEEDS_RETRY;
+		return SCSI_MLQUEUE_DIS_RETRY;
 
 	case HARDWARE_ERROR:
 		if (scmd->device->retry_hwerror)
-			return NEEDS_RETRY;
+			return SCSI_MLQUEUE_DIS_RETRY;
 		else
-			return SUCCESS;
+			return SCSI_MLQUEUE_DIS_FINISH;
 
 	case ILLEGAL_REQUEST:
 	case BLANK_CHECK:
 	case DATA_PROTECT:
 	default:
-		return SUCCESS;
+		return SCSI_MLQUEUE_DIS_FINISH;
 	}
 }
 
@@ -1277,7 +1279,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 		SCSI_LOG_ERROR_RECOVERY(5, printk("%s: device offline - report"
 						  " as SUCCESS\n",
 						  __func__));
-		return SUCCESS;
+		return SCSI_MLQUEUE_DIS_FINISH;
 	}
 
 	/*
@@ -1292,7 +1294,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 		 * did_ok.
 		 */
 		scmd->result &= 0xff00ffff;
-		return SUCCESS;
+		return SCSI_MLQUEUE_DIS_FINISH;
 	case DID_OK:
 		/*
 		 * looks good.  drop through, and check the next byte.
@@ -1306,7 +1308,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 		 * to the top level driver, not that we actually think
 		 * that it indicates SUCCESS.
 		 */
-		return SUCCESS;
+		return SCSI_MLQUEUE_DIS_FINISH;
 		/*
 		 * when the low level driver returns did_soft_error,
 		 * it is responsible for keeping an internal retry counter 
@@ -1317,10 +1319,10 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 		 * and not get stuck in a loop.
 		 */
 	case DID_SOFT_ERROR:
-		return NEEDS_RETRY;
+		return SCSI_MLQUEUE_DIS_RETRY;
 	case DID_IMM_RETRY:
 	case DID_REQUEUE:
-		return ADD_TO_MLQUEUE;
+		return SCSI_MLQUEUE_IMM_RETRY;
 	case DID_TRANSPORT_DISRUPTED:
 		/*
 		 * LLD/transport was disrupted during processing of the IO.
@@ -1328,13 +1330,13 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 		 * and the transport will decide what to do with the IO
 		 * based on its timers and recovery capablilities.
 		 */
-		return ADD_TO_MLQUEUE;
+		return SCSI_MLQUEUE_IMM_RETRY;
 	case DID_TRANSPORT_FAILFAST:
 		/*
 		 * The transport decided to failfast the IO (most likely
 		 * the fast io fail tmo fired), so send IO directly upwards.
 		 */
-		return SUCCESS;
+		return SCSI_MLQUEUE_DIS_FINISH;
 	case DID_ERROR:
 		if (msg_byte(scmd->result) == COMMAND_COMPLETE &&
 		    status_byte(scmd->result) == RESERVATION_CONFLICT)
@@ -1347,7 +1349,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 
 	case DID_BUS_BUSY:
 	case DID_PARITY:
-		return NEEDS_RETRY;
+		return SCSI_MLQUEUE_DIS_RETRY;
 	case DID_TIME_OUT:
 		/*
 		 * when we scan the bus, we get timeout messages for
@@ -1356,21 +1358,21 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 		 */
 		if ((scmd->cmnd[0] == TEST_UNIT_READY ||
 		     scmd->cmnd[0] == INQUIRY)) {
-			return SUCCESS;
+			return SCSI_MLQUEUE_DIS_FINISH;
 		} else {
-			return FAILED;
+			return SCSI_MLQUEUE_DIS_FAIL;
 		}
 	case DID_RESET:
-		return SUCCESS;
+		return SCSI_MLQUEUE_DIS_FINISH;
 	default:
-		return FAILED;
+		return SCSI_MLQUEUE_DIS_FAIL;
 	}
 
 	/*
 	 * next, check the message byte.
 	 */
 	if (msg_byte(scmd->result) != COMMAND_COMPLETE)
-		return FAILED;
+		return SCSI_MLQUEUE_DIS_FAIL;
 
 	/*
 	 * check the status byte to see if this indicates anything special.
@@ -1388,11 +1390,11 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 		 * the empty queue handling to trigger a stall in the
 		 * device.
 		 */
-		return ADD_TO_MLQUEUE;
+		return SCSI_MLQUEUE_IMM_RETRY;
 	case GOOD:
 	case COMMAND_TERMINATED:
 	case TASK_ABORTED:
-		return SUCCESS;
+		return SCSI_MLQUEUE_DIS_FINISH;
 	case CHECK_CONDITION:
 		return scsi_check_sense(scmd);
 	case CONDITION_GOOD:
@@ -1402,16 +1404,16 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 		/*
 		 * who knows?  FIXME(eric)
 		 */
-		return SUCCESS;
+		return SCSI_MLQUEUE_DIS_FINISH;
 
 	case RESERVATION_CONFLICT:
 		sdev_printk(KERN_INFO, scmd->device,
 			    "reservation conflict\n");
-		return SUCCESS; /* causes immediate i/o error */
+		return SCSI_MLQUEUE_DIS_FINISH; /* causes immediate i/o error */
 	default:
-		return FAILED;
+		return SCSI_MLQUEUE_DIS_FAIL;
 	}
-	return FAILED;
+	return SCSI_MLQUEUE_DIS_FAIL;
 
 }
 
@@ -1534,7 +1536,7 @@ void scsi_eh_flush_done_q(struct list_head *done_q)
 							  " retry cmd: %p\n",
 							  current->comm,
 							  scmd));
-				scsi_queue_insert(scmd, SCSI_MLQUEUE_EH_RETRY);
+			scsi_queue_insert(scmd, SCSI_MLQUEUE_DIS_RETRY);
 		} else {
 			/*
 			 * If just we got sense for the device (called
drivers/scsi/scsi_lib.c +18 -17
index 2b65167..d78147a 100644
@@ -153,14 +153,22 @@ int scsi_queue_insert(struct scsi_cmnd *cmd, int reason)
 	case SCSI_MLQUEUE_TARGET_BUSY:
 		starget->target_blocked = starget->max_target_blocked;
 		break;
-	case SCSI_MLQUEUE_EH_RETRY:
-		if (blk_noretry_request(cmd->request) ||
-		    ++cmd->retries > cmd->allowed) {
+	}
+
+	if (!scsi_ign_failfast(reason)) {
+		if (blk_noretry_request(cmd->request)) {
+			set_driver_byte(cmd, DRIVER_TIMEOUT);
+			scsi_finish_command(cmd);
+			return 0;
+		}
+	}
+
+	if (!scsi_ign_cmd_retries(reason)) {
+		if (++cmd->retries > cmd->allowed) {
 			set_driver_byte(cmd, DRIVER_TIMEOUT);
 			scsi_finish_command(cmd);
 			return 0;
 		}
-		break;
 	}
 
 	/*
@@ -1528,20 +1536,13 @@ static void scsi_softirq_done(struct request *rq)
 			
 	scsi_log_completion(cmd, disposition);
 
-	switch (disposition) {
-		case SUCCESS:
+	if (scsi_disposition_finish(disposition))
+		scsi_finish_command(cmd);
+	else if (scsi_disposition_retry(disposition))
+		scsi_queue_insert(cmd, disposition);
+	else
+		if (!scsi_eh_scmd_add(cmd, 0))
 			scsi_finish_command(cmd);
-			break;
-		case NEEDS_RETRY:
-			scsi_queue_insert(cmd, SCSI_MLQUEUE_EH_RETRY);
-			break;
-		case ADD_TO_MLQUEUE:
-			scsi_queue_insert(cmd, SCSI_MLQUEUE_DEVICE_BUSY);
-			break;
-		default:
-			if (!scsi_eh_scmd_add(cmd, 0))
-				scsi_finish_command(cmd);
-	}
 }
 
 /*
include/scsi/scsi.h +29 -4
index 0b4d91d..5b4cbf8 100644
@@ -414,10 +414,35 @@ struct scsi_lun {
 /*
  * Midlevel queue return values.
  */
-#define SCSI_MLQUEUE_HOST_BUSY   0x1055
-#define SCSI_MLQUEUE_DEVICE_BUSY 0x1056
-#define SCSI_MLQUEUE_EH_RETRY    0x1057
-#define SCSI_MLQUEUE_TARGET_BUSY 0x1058
+
+enum {
+	/*
+	 * Retry Constraints
+	 *
+	 * SCSI_IGN_ALLOWED		: Ignore cmd retries allowed check
+	 * SCSI_IGN_BLK_FAILFAST	: Ignore blk_failfast check.
+	 */
+	SCSI_IGN_ALLOWED	= 0x01,
+	SCSI_IGN_BLK_FAILFAST	= 0x02,
+
+	SCSI_MLQUEUE_DIS_FINISH	= 0x10,
+	SCSI_MLQUEUE_DIS_RETRY	= 0x20,
+	SCSI_MLQUEUE_DIS_FAIL	= 0x40,
+
+	SCSI_MLQUEUE_HOST_BUSY		= 0x100 | SCSI_MLQUEUE_DIS_RETRY |
+		SCSI_IGN_BLK_FAILFAST | SCSI_IGN_ALLOWED,
+	SCSI_MLQUEUE_DEVICE_BUSY	= 0x101 | SCSI_MLQUEUE_DIS_RETRY |
+		SCSI_IGN_BLK_FAILFAST | SCSI_IGN_ALLOWED,
+	SCSI_MLQUEUE_TARGET_BUSY	= 0x102 | SCSI_MLQUEUE_DIS_RETRY |
+		SCSI_IGN_BLK_FAILFAST | SCSI_IGN_ALLOWED,
+	SCSI_MLQUEUE_IMM_RETRY		= 0x103 | SCSI_MLQUEUE_DIS_RETRY |
+		SCSI_IGN_BLK_FAILFAST | SCSI_IGN_ALLOWED,
+};
+
+#define scsi_disposition_finish(dis) (dis & SCSI_MLQUEUE_DIS_FINISH)
+#define scsi_disposition_retry(dis) (dis & SCSI_MLQUEUE_DIS_RETRY)
+#define scsi_ign_cmd_retries(dis) (dis & SCSI_IGN_ALLOWED)
+#define scsi_ign_failfast(dis) (dis & SCSI_IGN_BLK_FAILFAST)
 
 /*
  *  Use these to separate status msg and our bytes
Signature · 1 line
1.5.5.1
#3 lore raw

PATCH 3/13 scsi: Move blk_noretry_request

In reply to Mike Anderson

Move blk_noretry_request check to scsi_queue_insert.

---
 drivers/scsi/scsi_error.c |   15 +--------------
 drivers/scsi/scsi_lib.c   |    3 ++-
 2 files changed, 3 insertions(+), 15 deletions(-)
drivers/scsi/scsi_error.c +1 -14
index 55bf0e5..4eabb1a 100644
@@ -1422,19 +1422,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 	return FAILED;
 
       maybe_retry:
-
-	/* we requeue for retry because the error was retryable, and
-	 * the request was not marked fast fail.  Note that above,
-	 * even if the request is marked fast fail, we still requeue
-	 * for queue congestion conditions (QUEUE_FULL or BUSY) */
-	if (!blk_noretry_request(scmd->request)) {
 		return NEEDS_RETRY;
-	} else {
-		/*
-		 * no more retries - report this one back to upper level.
-		 */
-		return SUCCESS;
-	}
 }
 
 /**
@@ -1551,8 +1539,7 @@ void scsi_eh_flush_done_q(struct list_head *done_q)
 
 	list_for_each_entry_safe(scmd, next, done_q, eh_entry) {
 		list_del_init(&scmd->eh_entry);
-		if (scsi_device_online(scmd->device) &&
-		    !blk_noretry_request(scmd->request)) {
+		if (scsi_device_online(scmd->device)) {
 			SCSI_LOG_ERROR_RECOVERY(3, printk("%s: flush"
 							  " retry cmd: %p\n",
 							  current->comm,
drivers/scsi/scsi_lib.c +2 -1
index 557e511..2b65167 100644
@@ -154,7 +154,8 @@ int scsi_queue_insert(struct scsi_cmnd *cmd, int reason)
 		starget->target_blocked = starget->max_target_blocked;
 		break;
 	case SCSI_MLQUEUE_EH_RETRY:
-		if (++cmd->retries > cmd->allowed) {
+		if (blk_noretry_request(cmd->request) ||
+		    ++cmd->retries > cmd->allowed) {
 			set_driver_byte(cmd, DRIVER_TIMEOUT);
 			scsi_finish_command(cmd);
 			return 0;
Signature · 1 line
1.5.5.1
#6 lore raw

PATCH 6/13 scsi: rename scsi_queue_insert to scsi_attempt_requeue_command

In reply to Mike Anderson

From: Mike Christie <[email protected]>

This renames scsi_queue_insert to scsi_attempt_requeue_command, because it may not be able to requeue the command if there are not retries left or if failfast is set. The naming is also meant to better match the other requeue function, scsi_requeue_command, which will always requeue a command.

---
 drivers/scsi/scsi.c       |    4 ++--
 drivers/scsi/scsi_error.c |    3 ++-
 drivers/scsi/scsi_lib.c   |   22 ++++++++++++++--------
 drivers/scsi/scsi_priv.h  |    2 +-
 4 files changed, 19 insertions(+), 12 deletions(-)
drivers/scsi/scsi.c +2 -2
index f8b79d4..5c116d9 100644
@@ -678,7 +678,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
 		 * suspend state.
 		 */
 
-		scsi_queue_insert(cmd, SCSI_MLQUEUE_DEVICE_BUSY);
+		scsi_attempt_requeue_command(cmd, SCSI_MLQUEUE_DEVICE_BUSY);
 
 		SCSI_LOG_MLQUEUE(3, printk("queuecommand : device blocked \n"));
 
@@ -758,7 +758,7 @@ int scsi_dispatch_cmd(struct scsi_cmnd *cmd)
 		    rtn != SCSI_MLQUEUE_TARGET_BUSY)
 			rtn = SCSI_MLQUEUE_HOST_BUSY;
 
-		scsi_queue_insert(cmd, rtn);
+		scsi_attempt_requeue_command(cmd, rtn);
 
 		SCSI_LOG_MLQUEUE(3,
 		    printk("queuecommand : request rejected\n"));
drivers/scsi/scsi_error.c +2 -1
index ae46cb0..02f999b 100644
@@ -1536,7 +1536,8 @@ void scsi_eh_flush_done_q(struct list_head *done_q)
 							  " retry cmd: %p\n",
 							  current->comm,
 							  scmd));
-			scsi_queue_insert(scmd, SCSI_MLQUEUE_DIS_RETRY);
+			scsi_attempt_requeue_command(scmd,
+						     SCSI_MLQUEUE_DIS_RETRY);
 		} else {
 			/*
 			 * If just we got sense for the device (called
drivers/scsi/scsi_lib.c +14 -8
index d78147a..34a50e0 100644
@@ -92,9 +92,9 @@ static void scsi_unprep_request(struct request *req)
 }
 
 /*
- * Function:    scsi_queue_insert()
+ * Function:    scsi_attempt_requeue_command()
  *
- * Purpose:     Insert a command in the midlevel queue.
+ * Purpose:     Attempt to insert a command in the midlevel queue.
  *
  * Arguments:   cmd    - command that we are adding to queue.
  *              reason - why we are inserting command to queue.
@@ -103,14 +103,20 @@ static void scsi_unprep_request(struct request *req)
  *
  * Returns:     Nothing.
  *
- * Notes:       We do this for one of two cases.  Either the host is busy
- *              and it cannot accept any more commands for the time being,
- *              or the device returned QUEUE_FULL and can accept no more
- *              commands.
+ * Notes:       We do this for multiple cases.
+ *
+ *		Host or device queueing:
+ *		Either the host or device is busy and it cannot accept any more
+ *		commands for the time being.
+ *
+ * 		SCSI error processing:
+ * 		The scsi-eh has decided to requeue a command after getting
+ * 		a command it believes ir retryable.
+ *
  * Notes:       This could be called either from an interrupt context or a
  *              normal process context.
  */
-int scsi_queue_insert(struct scsi_cmnd *cmd, int reason)
+int scsi_attempt_requeue_command(struct scsi_cmnd *cmd, int reason)
 {
 	struct Scsi_Host *host = cmd->device->host;
 	struct scsi_device *device = cmd->device;
@@ -1539,7 +1545,7 @@ static void scsi_softirq_done(struct request *rq)
 	if (scsi_disposition_finish(disposition))
 		scsi_finish_command(cmd);
 	else if (scsi_disposition_retry(disposition))
-		scsi_queue_insert(cmd, disposition);
+		scsi_attempt_requeue_command(cmd, disposition);
 	else
 		if (!scsi_eh_scmd_add(cmd, 0))
 			scsi_finish_command(cmd);
drivers/scsi/scsi_priv.h +1 -1
index e185090..0de6769 100644
@@ -64,7 +64,7 @@ int scsi_noretry_cmd(struct scsi_cmnd *scmd);
 /* scsi_lib.c */
 extern int scsi_maybe_unblock_host(struct scsi_device *sdev);
 extern void scsi_device_unbusy(struct scsi_device *sdev);
-extern int scsi_queue_insert(struct scsi_cmnd *cmd, int reason);
+extern int scsi_attempt_requeue_command(struct scsi_cmnd *cmd, int reason);
 extern void scsi_next_command(struct scsi_cmnd *cmd);
 extern void scsi_io_completion(struct scsi_cmnd *, unsigned int);
 extern void scsi_run_host_queues(struct Scsi_Host *shost);
Signature · 1 line
1.5.5.1
#7 lore raw

PATCH 7/13 scsi: have device handlers return SCSI_MLQUEUE error value

In reply to Mike Anderson

From: Mike Christie <[email protected]>

This has the scsi device handlers return SCSI_MLQUEUE error values instead of the old values.

One change is that if the handler does not care we return 0 instead of SCSI_RETURN_NOT_HANDLED.

---
 drivers/scsi/device_handler/scsi_dh_alua.c |   16 ++++++++--------
 drivers/scsi/device_handler/scsi_dh_emc.c  |    8 ++++----
 drivers/scsi/device_handler/scsi_dh_rdac.c |   10 +++++-----
 drivers/scsi/scsi_error.c                  |    9 +++++----
 4 files changed, 22 insertions(+), 21 deletions(-)
drivers/scsi/device_handler/scsi_dh_alua.c +8 -8
index 6bc55a6..b98d531 100644
@@ -426,45 +426,45 @@ static int alua_check_sense(struct scsi_device *sdev,
 			/*
 			 * LUN Not Accessible - ALUA state transition
 			 */
-			return NEEDS_RETRY;
+			return SCSI_MLQUEUE_IMM_RETRY;
 		if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x0b)
 			/*
 			 * LUN Not Accessible -- Target port in standby state
 			 */
-			return SUCCESS;
+			return SCSI_MLQUEUE_DIS_FINISH;
 		if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x0c)
 			/*
 			 * LUN Not Accessible -- Target port in unavailable state
 			 */
-			return SUCCESS;
+			return SCSI_MLQUEUE_DIS_FINISH;
 		if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0x12)
 			/*
 			 * LUN Not Ready -- Offline
 			 */
-			return SUCCESS;
+			return SCSI_MLQUEUE_DIS_FINISH;
 		break;
 	case UNIT_ATTENTION:
 		if (sense_hdr->asc == 0x29 && sense_hdr->ascq == 0x00)
 			/*
 			 * Power On, Reset, or Bus Device Reset, just retry.
 			 */
-			return NEEDS_RETRY;
+			return SCSI_MLQUEUE_IMM_RETRY;
 		if (sense_hdr->asc == 0x2a && sense_hdr->ascq == 0x06) {
 			/*
 			 * ALUA state changed
 			 */
-			return NEEDS_RETRY;
+			return SCSI_MLQUEUE_IMM_RETRY;
 		}
 		if (sense_hdr->asc == 0x2a && sense_hdr->ascq == 0x07) {
 			/*
 			 * Implicit ALUA state transition failed
 			 */
-			return NEEDS_RETRY;
+			return SCSI_MLQUEUE_IMM_RETRY;
 		}
 		break;
 	}
 
-	return SCSI_RETURN_NOT_HANDLED;
+	return 0;
 }
 
 /*
drivers/scsi/device_handler/scsi_dh_emc.c +4 -4
index 247b1d1..0721b85 100644
@@ -417,7 +417,7 @@ static int clariion_check_sense(struct scsi_device *sdev,
 			 * Can return FAILED only when we want the error
 			 * recovery process to kick in.
 			 */
-			return SUCCESS;
+			return SCSI_MLQUEUE_DIS_FINISH;
 		break;
 	case ILLEGAL_REQUEST:
 		if (sense_hdr->asc == 0x25 && sense_hdr->ascq == 0x01)
@@ -431,7 +431,7 @@ static int clariion_check_sense(struct scsi_device *sdev,
 			 * Can return FAILED only when we want the error
 			 * recovery process to kick in.
 			 */
-			return SUCCESS;
+			return SCSI_MLQUEUE_DIS_FINISH;
 		break;
 	case UNIT_ATTENTION:
 		if (sense_hdr->asc == 0x29 && sense_hdr->ascq == 0x00)
@@ -439,11 +439,11 @@ static int clariion_check_sense(struct scsi_device *sdev,
 			 * Unit Attention Code. This is the first IO
 			 * to the new path, so just retry.
 			 */
-			return NEEDS_RETRY;
+			return SCSI_MLQUEUE_IMM_RETRY;
 		break;
 	}
 
-	return SCSI_RETURN_NOT_HANDLED;
+	return 0;
 }
 
 static int clariion_prep_fn(struct scsi_device *sdev, struct request *req)
drivers/scsi/device_handler/scsi_dh_rdac.c +5 -5
index 6e31572..1055c62 100644
@@ -544,13 +544,13 @@ static int rdac_check_sense(struct scsi_device *sdev,
 			 *
 			 * Nothing we can do here. Try to bypass the path.
 			 */
-			return SUCCESS;
+			return SCSI_MLQUEUE_DIS_FINISH;
 		if (sense_hdr->asc == 0x04 && sense_hdr->ascq == 0xA1)
 			/* LUN Not Ready - Quiescense in progress
 			 *
 			 * Just retry and wait.
 			 */
-			return NEEDS_RETRY;
+			return SCSI_MLQUEUE_IMM_RETRY;
 		break;
 	case ILLEGAL_REQUEST:
 		if (sense_hdr->asc == 0x94 && sense_hdr->ascq == 0x01) {
@@ -559,7 +559,7 @@ static int rdac_check_sense(struct scsi_device *sdev,
 			 * Fail the path, so that the other path be used.
 			 */
 			h->state = RDAC_STATE_PASSIVE;
-			return SUCCESS;
+			return SCSI_MLQUEUE_DIS_FINISH;
 		}
 		break;
 	case UNIT_ATTENTION:
@@ -567,11 +567,11 @@ static int rdac_check_sense(struct scsi_device *sdev,
 			/*
 			 * Power On, Reset, or Bus Device Reset, just retry.
 			 */
-			return NEEDS_RETRY;
+			return SCSI_MLQUEUE_IMM_RETRY;
 		break;
 	}
 	/* success just means we do not care what scsi-ml does */
-	return SCSI_RETURN_NOT_HANDLED;
+	return 0;
 }
 
 static const struct scsi_dh_devlist rdac_dev_list[] = {
drivers/scsi/scsi_error.c +5 -4
index 02f999b..0505883 100644
@@ -253,7 +253,7 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
 		int rc;
 
 		rc = sdev->scsi_dh_data->scsi_dh->check_sense(sdev, &sshdr);
-		if (rc != SCSI_RETURN_NOT_HANDLED)
+		if (rc)
 			return rc;
 		/* handler does not care. Drop down to default handling */
 	}
@@ -1321,8 +1321,9 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 	case DID_SOFT_ERROR:
 		return SCSI_MLQUEUE_DIS_RETRY;
 	case DID_IMM_RETRY:
-	case DID_REQUEUE:
 		return SCSI_MLQUEUE_IMM_RETRY;
+	case DID_REQUEUE:
+		return SCSI_MLQUEUE_DEVICE_BUSY;
 	case DID_TRANSPORT_DISRUPTED:
 		/*
 		 * LLD/transport was disrupted during processing of the IO.
@@ -1330,7 +1331,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 		 * and the transport will decide what to do with the IO
 		 * based on its timers and recovery capablilities.
 		 */
-		return SCSI_MLQUEUE_IMM_RETRY;
+		return SCSI_MLQUEUE_TARGET_BUSY;
 	case DID_TRANSPORT_FAILFAST:
 		/*
 		 * The transport decided to failfast the IO (most likely
@@ -1390,7 +1391,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 		 * the empty queue handling to trigger a stall in the
 		 * device.
 		 */
-		return SCSI_MLQUEUE_IMM_RETRY;
+		return SCSI_MLQUEUE_DEVICE_BUSY;
 	case GOOD:
 	case COMMAND_TERMINATED:
 	case TASK_ABORTED:
Signature · 1 line
1.5.5.1
#4 lore raw

PATCH 4/13 scsi: remove maybe_retry

In reply to Mike Anderson

Remove maybe_retry from scsi_decide_disposition.

---
 drivers/scsi/scsi_error.c |   16 +++-------------
 1 files changed, 3 insertions(+), 13 deletions(-)
drivers/scsi/scsi_error.c +3 -13
index 4eabb1a..b092089 100644
@@ -1268,7 +1268,6 @@ int scsi_noretry_cmd(struct scsi_cmnd *scmd)
  */
 int scsi_decide_disposition(struct scsi_cmnd *scmd)
 {
-	int rtn;
 
 	/*
 	 * if the device is offline, then we clearly just pass the result back
@@ -1318,7 +1317,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 		 * and not get stuck in a loop.
 		 */
 	case DID_SOFT_ERROR:
-		goto maybe_retry;
+		return NEEDS_RETRY;
 	case DID_IMM_RETRY:
 	case DID_REQUEUE:
 		return ADD_TO_MLQUEUE;
@@ -1348,7 +1347,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 
 	case DID_BUS_BUSY:
 	case DID_PARITY:
-		goto maybe_retry;
+		return NEEDS_RETRY;
 	case DID_TIME_OUT:
 		/*
 		 * when we scan the bus, we get timeout messages for
@@ -1395,14 +1394,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 	case TASK_ABORTED:
 		return SUCCESS;
 	case CHECK_CONDITION:
-		rtn = scsi_check_sense(scmd);
-		if (rtn == NEEDS_RETRY)
-			goto maybe_retry;
-		/* if rtn == FAILED, we have no sense information;
-		 * returning FAILED will wake the error handler thread
-		 * to collect the sense and redo the decide
-		 * disposition */
-		return rtn;
+		return scsi_check_sense(scmd);
 	case CONDITION_GOOD:
 	case INTERMEDIATE_GOOD:
 	case INTERMEDIATE_C_GOOD:
@@ -1421,8 +1413,6 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 	}
 	return FAILED;
 
-      maybe_retry:
-		return NEEDS_RETRY;
 }
 
 /**
Signature · 1 line
1.5.5.1
#8 lore raw

PATCH 8/13 scsi: convert other scsi_check_sense users to new error codes

In reply to Mike Anderson

From: Mike Christie <[email protected]>

scsi_eh_completed_normally are expecting a old style FAILED/SUCCESS type of error code, but scsi_check_sense returns the new SCSI_MLQUEUE ones. This converted scsi_check_sense users to the new codes.

---
 drivers/scsi/scsi_error.c |   27 ++++++++++++---------------
 1 files changed, 12 insertions(+), 15 deletions(-)
drivers/scsi/scsi_error.c +12 -15
index 0505883..9a539dd 100644
@@ -370,13 +370,13 @@ static int scsi_eh_completed_normally(struct scsi_cmnd *scmd)
 		return scsi_check_sense(scmd);
 	}
 	if (host_byte(scmd->result) != DID_OK)
-		return FAILED;
+		return SCSI_MLQUEUE_DIS_FAIL;
 
 	/*
 	 * next, check the message byte.
 	 */
 	if (msg_byte(scmd->result) != COMMAND_COMPLETE)
-		return FAILED;
+		return SCSI_MLQUEUE_DIS_FAIL;
 
 	/*
 	 * now, check the status byte to see if this indicates
@@ -385,7 +385,7 @@ static int scsi_eh_completed_normally(struct scsi_cmnd *scmd)
 	switch (status_byte(scmd->result)) {
 	case GOOD:
 	case COMMAND_TERMINATED:
-		return SUCCESS;
+		return SCSI_MLQUEUE_DIS_FINISH;
 	case CHECK_CONDITION:
 		return scsi_check_sense(scmd);
 	case CONDITION_GOOD:
@@ -394,14 +394,14 @@ static int scsi_eh_completed_normally(struct scsi_cmnd *scmd)
 		/*
 		 * who knows?  FIXME(eric)
 		 */
-		return SUCCESS;
+		return SCSI_MLQUEUE_DIS_FINISH;
 	case BUSY:
 	case QUEUE_FULL:
 	case RESERVATION_CONFLICT:
 	default:
-		return FAILED;
+		return SCSI_MLQUEUE_DIS_FAIL;
 	}
-	return FAILED;
+	return SCSI_MLQUEUE_DIS_FAIL;
 }
 
 /**
@@ -729,15 +729,12 @@ static int scsi_send_eh_cmnd(struct scsi_cmnd *scmd, unsigned char *cmnd,
 			printk("%s: scsi_eh_completed_normally %x\n",
 			       __func__, rtn));
 
-		switch (rtn) {
-		case SUCCESS:
-		case NEEDS_RETRY:
-		case FAILED:
-			break;
-		default:
+		if (scsi_disposition_finish(rtn))
+			rtn = SUCCESS;
+		else if (scsi_disposition_retry(rtn))
+			rtn = NEEDS_RETRY;
+		else
 			rtn = FAILED;
-			break;
-		}
 	} else {
 		scsi_abort_eh_cmnd(scmd);
 		rtn = FAILED;
@@ -965,7 +962,7 @@ static int scsi_eh_stu(struct Scsi_Host *shost,
 		stu_scmd = NULL;
 		list_for_each_entry(scmd, work_q, eh_entry)
 			if (scmd->device == sdev && SCSI_SENSE_VALID(scmd) &&
-			    scsi_check_sense(scmd) == FAILED ) {
+			    scsi_check_sense(scmd) == SCSI_MLQUEUE_DIS_FAIL) {
 				stu_scmd = scmd;
 				break;
 			}
Signature · 1 line
1.5.5.1
#9 lore raw

PATCH 9/13 scsi: fix up SCSI_MLQUEUE defintions and add driver, device and transport ones

In reply to Mike Anderson

From: Mike Christie <[email protected]>

This adds new driver, device and transport errors and fixes up the SCSI_MLQUEUE definitions so there not collisions.

---
 drivers/scsi/scsi_error.c |   22 +++++++++++-----------
 drivers/scsi/scsi_lib.c   |   26 ++++++++++++++++++++------
 include/scsi/scsi.h       |   39 ++++++++++++++++++++++++++-------------
 3 files changed, 57 insertions(+), 30 deletions(-)
drivers/scsi/scsi_error.c +11 -11
index 9a539dd..c0254ec 100644
@@ -246,7 +246,7 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
 		return SCSI_MLQUEUE_DIS_FAIL;	/* no valid sense data */
 
 	if (scsi_sense_is_deferred(&sshdr))
-		return SCSI_MLQUEUE_DIS_RETRY;
+		return SCSI_MLQUEUE_DIS_DEV_RETRY;
 
 	if (sdev->scsi_dh_data && sdev->scsi_dh_data->scsi_dh &&
 			sdev->scsi_dh_data->scsi_dh->check_sense) {
@@ -288,7 +288,7 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
 		if (sshdr.asc == 0x10) /* DIF */
 			return SCSI_MLQUEUE_DIS_FINISH;
 
-		return SCSI_MLQUEUE_DIS_RETRY;
+		return SCSI_MLQUEUE_DIS_DEV_RETRY;
 	case NOT_READY:
 	case UNIT_ATTENTION:
 		/*
@@ -299,14 +299,14 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
 		 */
 		if (scmd->device->expecting_cc_ua) {
 			scmd->device->expecting_cc_ua = 0;
-			return SCSI_MLQUEUE_DIS_RETRY;
+			return SCSI_MLQUEUE_DIS_DEV_RETRY;
 		}
 		/*
 		 * if the device is in the process of becoming ready, we 
 		 * should retry.
 		 */
 		if ((sshdr.asc == 0x04) && (sshdr.ascq == 0x01))
-			return SCSI_MLQUEUE_DIS_RETRY;
+			return SCSI_MLQUEUE_DIS_DEV_RETRY;
 		/*
 		 * if the device is not started, we need to wake
 		 * the error handler to start the motor
@@ -328,11 +328,11 @@ static int scsi_check_sense(struct scsi_cmnd *scmd)
 		    sshdr.asc == 0x14) { /* RECORD NOT FOUND */
 			return SCSI_MLQUEUE_DIS_FINISH;
 		}
-		return SCSI_MLQUEUE_DIS_RETRY;
+		return SCSI_MLQUEUE_DIS_DEV_RETRY;
 
 	case HARDWARE_ERROR:
 		if (scmd->device->retry_hwerror)
-			return SCSI_MLQUEUE_DIS_RETRY;
+			return SCSI_MLQUEUE_DIS_DEV_RETRY;
 		else
 			return SCSI_MLQUEUE_DIS_FINISH;
 
@@ -1316,7 +1316,7 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 		 * and not get stuck in a loop.
 		 */
 	case DID_SOFT_ERROR:
-		return SCSI_MLQUEUE_DIS_RETRY;
+		return SCSI_MLQUEUE_DIS_DRV_RETRY;
 	case DID_IMM_RETRY:
 		return SCSI_MLQUEUE_IMM_RETRY;
 	case DID_REQUEUE:
@@ -1343,11 +1343,11 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 			 * lower down
 			 */
 			break;
-		/* fallthrough */
-
-	case DID_BUS_BUSY:
+		/* fall through */
 	case DID_PARITY:
-		return SCSI_MLQUEUE_DIS_RETRY;
+		return SCSI_MLQUEUE_DIS_DEV_RETRY;
+	case DID_BUS_BUSY:
+		return SCSI_MLQUEUE_DIS_XPT_RETRY;
 	case DID_TIME_OUT:
 		/*
 		 * when we scan the bus, we get timeout messages for
drivers/scsi/scsi_lib.c +20 -6
index 34a50e0..39c5929 100644
@@ -161,14 +161,28 @@ int scsi_attempt_requeue_command(struct scsi_cmnd *cmd, int reason)
 		break;
 	}
 
-	if (!scsi_ign_failfast(reason)) {
-		if (blk_noretry_request(cmd->request)) {
-			set_driver_byte(cmd, DRIVER_TIMEOUT);
-			scsi_finish_command(cmd);
-			return 0;
-		}
+	if (!scsi_ign_failfast(reason) && scsi_disposition_retry(reason)) {
+		if (reason & SCSI_MLQUEUE_DIS_XPT_RETRY) {
+			if (!blk_failfast_transport(cmd->request))
+				goto check_retries;
+		} else if (reason & SCSI_MLQUEUE_DIS_DEV_RETRY) {
+			if (!blk_failfast_dev(cmd->request))
+				goto check_retries;
+		} else if (reason & SCSI_MLQUEUE_DIS_DRV_RETRY) {
+			if (!blk_failfast_driver(cmd->request))
+				goto check_retries;
+		} else if (reason & SCSI_MLQUEUE_DIS_RETRY) {
+			if (!blk_noretry_request(cmd->request))
+				goto check_retries;
+		} else
+			goto check_retries;
+
+		set_driver_byte(cmd, DRIVER_TIMEOUT);
+		scsi_finish_command(cmd);
+		return 0;
 	}
 
+check_retries:
 	if (!scsi_ign_cmd_retries(reason)) {
 		if (++cmd->retries > cmd->allowed) {
 			set_driver_byte(cmd, DRIVER_TIMEOUT);
include/scsi/scsi.h +26 -13
index 5b4cbf8..09751e4 100644
@@ -425,22 +425,35 @@ enum {
 	SCSI_IGN_ALLOWED	= 0x01,
 	SCSI_IGN_BLK_FAILFAST	= 0x02,
 
-	SCSI_MLQUEUE_DIS_FINISH	= 0x10,
-	SCSI_MLQUEUE_DIS_RETRY	= 0x20,
-	SCSI_MLQUEUE_DIS_FAIL	= 0x40,
-
-	SCSI_MLQUEUE_HOST_BUSY		= 0x100 | SCSI_MLQUEUE_DIS_RETRY |
-		SCSI_IGN_BLK_FAILFAST | SCSI_IGN_ALLOWED,
-	SCSI_MLQUEUE_DEVICE_BUSY	= 0x101 | SCSI_MLQUEUE_DIS_RETRY |
-		SCSI_IGN_BLK_FAILFAST | SCSI_IGN_ALLOWED,
-	SCSI_MLQUEUE_TARGET_BUSY	= 0x102 | SCSI_MLQUEUE_DIS_RETRY |
-		SCSI_IGN_BLK_FAILFAST | SCSI_IGN_ALLOWED,
-	SCSI_MLQUEUE_IMM_RETRY		= 0x103 | SCSI_MLQUEUE_DIS_RETRY |
-		SCSI_IGN_BLK_FAILFAST | SCSI_IGN_ALLOWED,
+	SCSI_MLQUEUE_DIS_SHIFT		= 4,
+	SCSI_MLQUEUE_DIS_FINISH		= 0x01 << SCSI_MLQUEUE_DIS_SHIFT,
+	SCSI_MLQUEUE_DIS_RETRY		= 0x02 << SCSI_MLQUEUE_DIS_SHIFT,
+	SCSI_MLQUEUE_DIS_XPT_RETRY	= 0x04 << SCSI_MLQUEUE_DIS_SHIFT,
+	SCSI_MLQUEUE_DIS_DEV_RETRY	= 0x08 << SCSI_MLQUEUE_DIS_SHIFT,
+	SCSI_MLQUEUE_DIS_DRV_RETRY	= 0x10 << SCSI_MLQUEUE_DIS_SHIFT,
+	SCSI_MLQUEUE_DIS_FAIL		= 0x20 << SCSI_MLQUEUE_DIS_SHIFT,
+
+	SCSI_MLQUEUE_BUSY_SHIFT		= 8,
+	SCSI_MLQUEUE_HOST_BUSY		= (0x01 << SCSI_MLQUEUE_BUSY_SHIFT) |
+		SCSI_MLQUEUE_DIS_RETRY | SCSI_IGN_BLK_FAILFAST |
+		SCSI_IGN_ALLOWED,
+	SCSI_MLQUEUE_DEVICE_BUSY	= (0x02 << SCSI_MLQUEUE_BUSY_SHIFT) |
+		SCSI_MLQUEUE_DIS_RETRY | SCSI_IGN_BLK_FAILFAST |
+		SCSI_IGN_ALLOWED,
+	SCSI_MLQUEUE_TARGET_BUSY	= (0x04 << SCSI_MLQUEUE_BUSY_SHIFT) |
+		SCSI_MLQUEUE_DIS_RETRY | SCSI_IGN_BLK_FAILFAST |
+		SCSI_IGN_ALLOWED,
+	SCSI_MLQUEUE_IMM_RETRY		= (0x08 << SCSI_MLQUEUE_BUSY_SHIFT) |
+		SCSI_MLQUEUE_DIS_RETRY | SCSI_IGN_BLK_FAILFAST |
+		SCSI_IGN_ALLOWED,
 };
 
 #define scsi_disposition_finish(dis) (dis & SCSI_MLQUEUE_DIS_FINISH)
-#define scsi_disposition_retry(dis) (dis & SCSI_MLQUEUE_DIS_RETRY)
+#define scsi_disposition_retry(dis)			\
+	((dis & SCSI_MLQUEUE_DIS_RETRY)		||	\
+	 (dis & SCSI_MLQUEUE_DIS_XPT_RETRY)	||	\
+	 (dis & SCSI_MLQUEUE_DIS_DEV_RETRY)	||	\
+	 (dis & SCSI_MLQUEUE_DIS_DRV_RETRY))
 #define scsi_ign_cmd_retries(dis) (dis & SCSI_IGN_ALLOWED)
 #define scsi_ign_failfast(dis) (dis & SCSI_IGN_BLK_FAILFAST)
 
Signature · 1 line
1.5.5.1
#10 lore raw

PATCH 10/13 scsi: move device online check to scsi_attempt_requeue_command

In reply to Mike Anderson

Move the device online check from scsi_eh_flush_done_q to scsi_attempt_requeue_command so that it can be shared by other callers and simplifies scsi_eh_flush_done_q. To provide similar behavior also move the setting of a zero result value to scsi_eh_finish_cmd.

---
 drivers/scsi/scsi_error.c |   26 ++++++--------------------
 drivers/scsi/scsi_lib.c   |    6 ++++++
 2 files changed, 12 insertions(+), 20 deletions(-)
drivers/scsi/scsi_error.c +6 -20
index c0254ec..4fbc28a 100644
@@ -774,6 +774,8 @@ void scsi_eh_finish_cmd(struct scsi_cmnd *scmd, struct list_head *done_q)
 {
 	scmd->device->host->host_failed--;
 	scmd->eh_eflags = 0;
+	if (!scmd->result)
+		scmd->result |= (DRIVER_TIMEOUT << 24);
 	list_move_tail(&scmd->eh_entry, done_q);
 }
 EXPORT_SYMBOL(scsi_eh_finish_cmd);
@@ -1529,26 +1531,10 @@ void scsi_eh_flush_done_q(struct list_head *done_q)
 
 	list_for_each_entry_safe(scmd, next, done_q, eh_entry) {
 		list_del_init(&scmd->eh_entry);
-		if (scsi_device_online(scmd->device)) {
-			SCSI_LOG_ERROR_RECOVERY(3, printk("%s: flush"
-							  " retry cmd: %p\n",
-							  current->comm,
-							  scmd));
-			scsi_attempt_requeue_command(scmd,
-						     SCSI_MLQUEUE_DIS_RETRY);
-		} else {
-			/*
-			 * If just we got sense for the device (called
-			 * scsi_eh_get_sense), scmd->result is already
-			 * set, do not set DRIVER_TIMEOUT.
-			 */
-			if (!scmd->result)
-				scmd->result |= (DRIVER_TIMEOUT << 24);
-			SCSI_LOG_ERROR_RECOVERY(3, printk("%s: flush finish"
-							" cmd: %p\n",
-							current->comm, scmd));
-			scsi_finish_command(scmd);
-		}
+		SCSI_LOG_ERROR_RECOVERY(3, printk("%s: flush"
+						  "attempt retry cmd: %p\n",
+						  current->comm, scmd));
+		scsi_attempt_requeue_command(scmd, SCSI_MLQUEUE_DIS_RETRY);
 	}
 }
 EXPORT_SYMBOL(scsi_eh_flush_done_q);
drivers/scsi/scsi_lib.c +6 -0
index 39c5929..8f09407 100644
@@ -136,6 +136,12 @@ int scsi_attempt_requeue_command(struct scsi_cmnd *cmd, int reason)
 		return 0;
 	}
 
+	if (!scsi_device_online(cmd->device)) {
+		set_driver_byte(cmd, DRIVER_TIMEOUT);
+		scsi_finish_command(cmd);
+		return 0;
+	}
+
 	/*
 	 * Set the appropriate busy bit for the device/host.
 	 *
Signature · 1 line
1.5.5.1
#11 lore raw

PATCH 11/13 scsi: remove scsi_device_online from scsi_decide_disposition

In reply to Mike Anderson

Remove scsi_device_online from scsi_decide_disposition as the check is now performed in scsi_attempt_requeue_command if a retry is attempted.

---
 drivers/scsi/scsi_error.c |   11 -----------
 1 files changed, 0 insertions(+), 11 deletions(-)
drivers/scsi/scsi_error.c +0 -11
index 4fbc28a..a0f4123 100644
@@ -1271,17 +1271,6 @@ int scsi_decide_disposition(struct scsi_cmnd *scmd)
 {
 
 	/*
-	 * if the device is offline, then we clearly just pass the result back
-	 * up to the top level.
-	 */
-	if (!scsi_device_online(scmd->device)) {
-		SCSI_LOG_ERROR_RECOVERY(5, printk("%s: device offline - report"
-						  " as SUCCESS\n",
-						  __func__));
-		return SCSI_MLQUEUE_DIS_FINISH;
-	}
-
-	/*
 	 * first check the host byte, to see if there is anything in there
 	 * that would indicate what we need to do.
 	 */
Signature · 1 line
1.5.5.1
#12 lore raw

PATCH 12/13 scsi: update scsi_log_completion disposition decoding

In reply to Mike Anderson

Update scsi_log_completion to decode new disposition codes.

---
 drivers/scsi/scsi.c |   41 ++++++++++++++++++++++-------------------
 include/scsi/scsi.h |    1 +
 2 files changed, 23 insertions(+), 19 deletions(-)
drivers/scsi/scsi.c +22 -19
index 5c116d9..c0023e3 100644
@@ -577,37 +577,40 @@ void scsi_log_completion(struct scsi_cmnd *cmd, int disposition)
 	if (unlikely(scsi_logging_level)) {
 		level = SCSI_LOG_LEVEL(SCSI_LOG_MLCOMPLETE_SHIFT,
 				       SCSI_LOG_MLCOMPLETE_BITS);
-		if (((level > 0) && (cmd->result || disposition != SUCCESS)) ||
+		if (((level > 0) &&
+		    (cmd->result || !scsi_disposition_finish(disposition))) ||
 		    (level > 1)) {
 			scmd_printk(KERN_INFO, cmd, "Done: ");
 			if (level > 2)
 				printk("0x%p ", cmd);
+
 			/*
 			 * Dump truncated values, so we usually fit within
 			 * 80 chars.
 			 */
-			switch (disposition) {
-			case SUCCESS:
+			if (scsi_disposition_finish(disposition))
 				printk("SUCCESS\n");
-				break;
-			case NEEDS_RETRY:
+			else if (scsi_disposition_retry(disposition))
 				printk("RETRY\n");
-				break;
-			case ADD_TO_MLQUEUE:
-				printk("MLQUEUE\n");
-				break;
-			case FAILED:
+			else if (scsi_disposition_fail(disposition))
 				printk("FAILED\n");
-				break;
-			case TIMEOUT_ERROR:
-				/* 
-				 * If called via scsi_times_out.
-				 */
-				printk("TIMEOUT\n");
-				break;
-			default:
-				printk("UNKNOWN\n");
+			else {
+				switch (disposition) {
+				case SUCCESS:
+					printk("SUCCESS\n");
+					break;
+				case TIMEOUT_ERROR:
+					/*
+					 * If called via scsi_times_out.
+					 */
+					printk("TIMEOUT\n");
+					break;
+				default:
+					printk("UNKNOWN: 0x%x\n",
+					       disposition);
+				}
 			}
+
 			scsi_print_result(cmd);
 			scsi_print_command(cmd);
 			if (status_byte(cmd->result) & CHECK_CONDITION)
include/scsi/scsi.h +1 -0
index 09751e4..2d8f00e 100644
@@ -449,6 +449,7 @@ enum {
 };
 
 #define scsi_disposition_finish(dis) (dis & SCSI_MLQUEUE_DIS_FINISH)
+#define scsi_disposition_fail(dis) (dis & SCSI_MLQUEUE_DIS_FAIL)
 #define scsi_disposition_retry(dis)			\
 	((dis & SCSI_MLQUEUE_DIS_RETRY)		||	\
 	 (dis & SCSI_MLQUEUE_DIS_XPT_RETRY)	||	\
Signature · 1 line
1.5.5.1
#13 lore raw

PATCH 13/13 scsi: remove scsi_noretry_cmd

In reply to Mike Anderson

Remove scsi_noretry_cmd as new method of encoding information in disposition status is being used.

---
 drivers/scsi/scsi_error.c |   34 ----------------------------------
 drivers/scsi/scsi_lib.c   |    2 +-
 drivers/scsi/scsi_priv.h  |    1 -
 3 files changed, 1 insertions(+), 36 deletions(-)
drivers/scsi/scsi_error.c +0 -34
index a0f4123..61b3001 100644
@@ -1220,40 +1220,6 @@ static void scsi_eh_offline_sdevs(struct list_head *work_q,
 }
 
 /**
- * scsi_noretry_cmd - determinte if command should be failed fast
- * @scmd:	SCSI cmd to examine.
- */
-int scsi_noretry_cmd(struct scsi_cmnd *scmd)
-{
-	switch (host_byte(scmd->result)) {
-	case DID_OK:
-		break;
-	case DID_BUS_BUSY:
-		return blk_failfast_transport(scmd->request);
-	case DID_PARITY:
-		return blk_failfast_dev(scmd->request);
-	case DID_ERROR:
-		if (msg_byte(scmd->result) == COMMAND_COMPLETE &&
-		    status_byte(scmd->result) == RESERVATION_CONFLICT)
-			return 0;
-		/* fall through */
-	case DID_SOFT_ERROR:
-		return blk_failfast_driver(scmd->request);
-	}
-
-	switch (status_byte(scmd->result)) {
-	case CHECK_CONDITION:
-		/*
-		 * assume caller has checked sense and determinted
-		 * the check condition was retryable.
-		 */
-		return blk_failfast_dev(scmd->request);
-	}
-
-	return 0;
-}
-
-/**
  * scsi_decide_disposition - Disposition a cmd on return from LLD.
  * @scmd:	SCSI cmd to examine.
  *
drivers/scsi/scsi_lib.c +1 -1
index 8f09407..3553f38 100644
@@ -757,7 +757,7 @@ static struct scsi_cmnd *scsi_end_request(struct scsi_cmnd *cmd, int error,
 			leftover = req->data_len;
 
 		/* kill remainder if no retrys */
-		if (error && scsi_noretry_cmd(cmd))
+		if (error && blk_noretry_request(req))
 			blk_end_request(req, error, leftover);
 		else {
 			if (requeue) {
drivers/scsi/scsi_priv.h +0 -1
index 0de6769..f32ec80 100644
@@ -59,7 +59,6 @@ void scsi_eh_ready_devs(struct Scsi_Host *shost,
 			struct list_head *done_q);
 int scsi_eh_get_sense(struct list_head *work_q,
 		      struct list_head *done_q);
-int scsi_noretry_cmd(struct scsi_cmnd *scmd);
 
 /* scsi_lib.c */
 extern int scsi_maybe_unblock_host(struct scsi_device *sdev);
Signature · 1 line
1.5.5.1