]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
scsi: make eh_eflags persistent
authorHannes Reinecke <hare@suse.de>
Thu, 6 Apr 2017 13:36:33 +0000 (15:36 +0200)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 6 Apr 2017 17:07:33 +0000 (13:07 -0400)
If a failed command is retried and fails again we need
to enter SCSI EH, otherwise we will never be able to
recover the command.
To detect this situation we must not clear scmd->eh_eflags
when EH finishes but rather make it persistent throughout
the lifetime of the command.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Benjamin Block <bblock@linux.vnet.ibm.com>
Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Documentation/scsi/scsi_eh.txt
drivers/scsi/libsas/sas_scsi_host.c
drivers/scsi/scsi_error.c
include/scsi/scsi_eh.h

index 37eca00796eeebf805afbbf1504753c1a0febec0..4edb9c1cbef52a2692fccf120a58e888f72d8d6e 100644 (file)
@@ -105,11 +105,14 @@ function
 
  2. If the host supports asynchronous completion (as indicated by the
     no_async_abort setting in the host template) scsi_abort_command()
-    is invoked to schedule an asynchrous abort. If that fails
-    Step #3 is taken.
+    is invoked to schedule an asynchrous abort.
+    Asynchronous abort are not invoked for commands which the
+    SCSI_EH_ABORT_SCHEDULED flag is set (this indicates that the command
+    already had been aborted once, and this is a retry which failed),
+    or when the EH deadline is expired. In these case Step #3 is taken.
 
2. scsi_eh_scmd_add(scmd, SCSI_EH_CANCEL_CMD) is invoked for the
-    command.  See [1-3] for more information.
3. scsi_eh_scmd_add(scmd, SCSI_EH_CANCEL_CMD) is invoked for the
+    command.  See [1-4] for more information.
 
 [1-3] Asynchronous command aborts
 
@@ -263,7 +266,6 @@ scmd->allowed.
 
  3. scmd recovered
     ACTION: scsi_eh_finish_cmd() is invoked to EH-finish scmd
-       - clear scmd->eh_eflags
        - scsi_setup_cmd_retry()
        - move from local eh_work_q to local eh_done_q
     LOCKING: none
@@ -456,8 +458,6 @@ except for #1 must be implemented by eh_strategy_handler().
 
  - shost->host_failed is zero.
 
- - Each scmd's eh_eflags field is cleared.
-
  - Each scmd is in such a state that scsi_setup_cmd_retry() on the
    scmd doesn't make any difference.
 
index ee6b39a1db69b41d2bdb6d92a5a92572eb081177..87e5079d816b949c253487f764d349a39354ae4a 100644 (file)
@@ -613,8 +613,6 @@ static void sas_eh_handle_sas_errors(struct Scsi_Host *shost, struct list_head *
                SAS_DPRINTK("trying to find task 0x%p\n", task);
                res = sas_scsi_find_task(task);
 
-               cmd->eh_eflags = 0;
-
                switch (res) {
                case TASK_IS_DONE:
                        SAS_DPRINTK("%s: task 0x%p is done\n", __func__,
index cff7d9de79f2b70e1379202bc109dbed5883b6af..4d26ff215c74e8f83ea15567cd4aec013c96e02c 100644 (file)
@@ -188,7 +188,6 @@ scsi_abort_command(struct scsi_cmnd *scmd)
                /*
                 * Retry after abort failed, escalate to next level.
                 */
-               scmd->eh_eflags &= ~SCSI_EH_ABORT_SCHEDULED;
                SCSI_LOG_ERROR_RECOVERY(3,
                        scmd_printk(KERN_INFO, scmd,
                                    "previous abort failed\n"));
@@ -937,6 +936,7 @@ void scsi_eh_prep_cmnd(struct scsi_cmnd *scmd, struct scsi_eh_save *ses,
        ses->result = scmd->result;
        ses->underflow = scmd->underflow;
        ses->prot_op = scmd->prot_op;
+       ses->eh_eflags = scmd->eh_eflags;
 
        scmd->prot_op = SCSI_PROT_NORMAL;
        scmd->eh_eflags = 0;
@@ -1000,6 +1000,7 @@ void scsi_eh_restore_cmnd(struct scsi_cmnd* scmd, struct scsi_eh_save *ses)
        scmd->result = ses->result;
        scmd->underflow = ses->underflow;
        scmd->prot_op = ses->prot_op;
+       scmd->eh_eflags = ses->eh_eflags;
 }
 EXPORT_SYMBOL(scsi_eh_restore_cmnd);
 
@@ -1132,7 +1133,6 @@ static int scsi_eh_action(struct scsi_cmnd *scmd, int rtn)
  */
 void scsi_eh_finish_cmd(struct scsi_cmnd *scmd, struct list_head *done_q)
 {
-       scmd->eh_eflags = 0;
        list_move_tail(&scmd->eh_entry, done_q);
 }
 EXPORT_SYMBOL(scsi_eh_finish_cmd);
index 98d366b5577069201815ac77e0827fa6f32f664b..a25b3285dd6f95406412095a8af0ef56323ea133 100644 (file)
@@ -31,6 +31,7 @@ extern int scsi_ioctl_reset(struct scsi_device *, int __user *);
 struct scsi_eh_save {
        /* saved state */
        int result;
+       int eh_eflags;
        enum dma_data_direction data_direction;
        unsigned underflow;
        unsigned char cmd_len;