Every now and then someone asks how it is avoided that the SCSI error
handler and the SCSI completion handler are invoked concurrently for
the same SCSI command. Add a few WARN_ON_ONCE() statements that make
it clear how this is avoided.

Signed-off-by: Bart Van Assche <bvanass...@acm.org>
Cc: Hannes Reinecke <h...@suse.de>
Cc: Paolo Bonzini <pbonz...@redhat.com>
Cc: Christoph Hellwig <h...@infradead.org>
Cc: Jens Axboe <ax...@fb.com>
Cc: Joe Lawrence <joe.lawre...@stratus.com>
---
 drivers/scsi/scsi_error.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 5232583..aee0dc0 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -120,6 +120,8 @@ scmd_eh_abort_handler(struct work_struct *work)
        struct scsi_device *sdev = scmd->device;
        int rtn;
 
+       WARN_ON_ONCE(!blk_rq_completed(scmd->request));
+
        if (scsi_host_eh_past_deadline(sdev->host)) {
                SCSI_LOG_ERROR_RECOVERY(3,
                        scmd_printk(KERN_INFO, scmd,
@@ -185,6 +187,8 @@ scsi_abort_command(struct scsi_cmnd *scmd)
        struct Scsi_Host *shost = sdev->host;
        unsigned long flags;
 
+       WARN_ON_ONCE(!blk_rq_completed(scmd->request));
+
        if (scmd->eh_eflags & SCSI_EH_ABORT_SCHEDULED) {
                /*
                 * Retry after abort failed, escalate to next level.
@@ -237,6 +241,8 @@ int scsi_eh_scmd_add(struct scsi_cmnd *scmd, int eh_flag)
        unsigned long flags;
        int ret = 0;
 
+       WARN_ON_ONCE(!blk_rq_completed(scmd->request));
+
        if (!shost->ehandler)
                return 0;
 
-- 
1.8.4.5

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to