public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* RFC: Retrying SCSI pass-through commands
@ 2024-07-31 20:22 Bart Van Assche
  2024-08-01  3:33 ` Damien Le Moal
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Bart Van Assche @ 2024-07-31 20:22 UTC (permalink / raw)
  To: Martin K . Petersen, Damien Le Moal, Hannes Reinecke,
	Mike Christie
  Cc: James E . J . Bottomley, Jaegeuk Kim, Christoph Hellwig,
	linux-scsi@vger.kernel.org

Hi,

Recently I noticed that a particular UFS-based device does not resume
correctly. The logs of the device show that sd_start_stop_device() does
not retry the START STOP UNIT command if the device reports a unit
attention. I think that's a bug in the SCSI core. The following hack
makes resume work again. I think this confirms my understanding of this
issue (sd_start_stop_device() sets RQF_PM):

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index da7dac77f8cd..e21becc5bcf9 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -1816,6 +1816,8 @@ bool scsi_noretry_cmd(struct scsi_cmnd *scmd)
          * assume caller has checked sense and determined
          * the check condition was retryable.
          */
+       if (req->rq_flags & RQF_PM)
+               return false;
         if (req->cmd_flags & REQ_FAILFAST_DEV || blk_rq_is_passthrough(req))
                 return true;

My understanding is that SCSI pass-through commands submitted from
user space must not be retried. Are there any objections against
modifying the behavior of the SCSI core such that it retries
REQ_OP_DRV_* operations submitted by the SCSI core, as illustrated
by the pseudo-code below?

diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index da7dac77f8cd..e21becc5bcf9 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -1816,6 +1816,12 @@ bool scsi_noretry_cmd(struct scsi_cmnd *scmd)
          * assume caller has checked sense and determined
          * the check condition was retryable.
          */
-       if (req->cmd_flags & REQ_FAILFAST_DEV || blk_rq_is_passthrough(req))
-               return true;
+       if (req->cmd_flags & REQ_FAILFAST_DEV)
+               return true;
+       if (/* submitted by the SCSI core */)
+               return false;
+       if (blk_rq_is_passthrough(req))
+               return true;

Thanks,

Bart.

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2024-08-05 17:56 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-31 20:22 RFC: Retrying SCSI pass-through commands Bart Van Assche
2024-08-01  3:33 ` Damien Le Moal
2024-08-01 20:12   ` Bart Van Assche
2024-08-02  0:47     ` Damien Le Moal
2024-08-02 16:52       ` Bart Van Assche
2024-08-01  7:04 ` Damien Le Moal
2024-08-01 18:00   ` Bart Van Assche
2024-08-03 20:42 ` Mike Christie
2024-08-05 17:47   ` Damien Le Moal
2024-08-05 17:56     ` Bart Van Assche

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox