* [PATCH 0/2] Fix system resume for SCSI devices
@ 2024-08-07 20:32 Bart Van Assche
2024-08-07 20:32 ` [PATCH 1/2] scsi: core: Retry passthrough commands if SCMD_RETRY_PASST_ON_UA is set Bart Van Assche
2024-08-07 20:32 ` [PATCH 2/2] sd: Retry START STOP UNIT commands in case of a unit attention Bart Van Assche
0 siblings, 2 replies; 5+ messages in thread
From: Bart Van Assche @ 2024-08-07 20:32 UTC (permalink / raw)
To: Martin K . Petersen; +Cc: linux-scsi, Bart Van Assche
Hi Martin,
This patch series fixes a particular type of system resume failure for
SCSI devices. Please consider this patch series for the next merge window.
Thanks,
Bart.
Bart Van Assche (2):
scsi: core: Retry passthrough commands if SCMD_RETRY_PASST_ON_UA is
set
sd: Retry START STOP UNIT commands in case of a unit attention
drivers/scsi/scsi_error.c | 5 ++++-
drivers/scsi/sd.c | 1 +
include/scsi/scsi_cmnd.h | 5 ++++-
3 files changed, 9 insertions(+), 2 deletions(-)
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] scsi: core: Retry passthrough commands if SCMD_RETRY_PASST_ON_UA is set
2024-08-07 20:32 [PATCH 0/2] Fix system resume for SCSI devices Bart Van Assche
@ 2024-08-07 20:32 ` Bart Van Assche
2024-08-09 15:40 ` Damien Le Moal
2024-08-07 20:32 ` [PATCH 2/2] sd: Retry START STOP UNIT commands in case of a unit attention Bart Van Assche
1 sibling, 1 reply; 5+ messages in thread
From: Bart Van Assche @ 2024-08-07 20:32 UTC (permalink / raw)
To: Martin K . Petersen
Cc: linux-scsi, Bart Van Assche, Damien Le Moal, Mike Christie,
James E.J. Bottomley
The SCSI core does not retry passthrough commands even if the SCSI device
reports a retryable unit attention condition. Support retrying in this case
by introducing the SCMD_RETRY_PASST_ON_UA flag.
Cc: Damien Le Moal <dlemoal@kernel.org>
Cc: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/scsi/scsi_error.c | 5 ++++-
include/scsi/scsi_cmnd.h | 5 ++++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
index 612489afe8d2..38e3ea85e381 100644
--- a/drivers/scsi/scsi_error.c
+++ b/drivers/scsi/scsi_error.c
@@ -1855,7 +1855,10 @@ 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))
+ if (req->cmd_flags & REQ_FAILFAST_DEV)
+ return true;
+ if (blk_rq_is_passthrough(req) &&
+ !(scmd->flags & SCMD_RETRY_PASST_ON_UA))
return true;
return false;
diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
index 45c40d200154..43c584fbeaca 100644
--- a/include/scsi/scsi_cmnd.h
+++ b/include/scsi/scsi_cmnd.h
@@ -58,8 +58,11 @@ struct scsi_pointer {
*/
#define SCMD_FORCE_EH_SUCCESS (1 << 3)
#define SCMD_FAIL_IF_RECOVERING (1 << 4)
+/* If set, retry a passthrough command in case of a unit attention. */
+#define SCMD_RETRY_PASST_ON_UA (1 << 5)
/* flags preserved across unprep / reprep */
-#define SCMD_PRESERVED_FLAGS (SCMD_INITIALIZED | SCMD_FAIL_IF_RECOVERING)
+#define SCMD_PRESERVED_FLAGS \
+ (SCMD_INITIALIZED | SCMD_FAIL_IF_RECOVERING | SCMD_RETRY_PASST_ON_UA)
/* for scmd->state */
#define SCMD_STATE_COMPLETE 0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] sd: Retry START STOP UNIT commands in case of a unit attention
2024-08-07 20:32 [PATCH 0/2] Fix system resume for SCSI devices Bart Van Assche
2024-08-07 20:32 ` [PATCH 1/2] scsi: core: Retry passthrough commands if SCMD_RETRY_PASST_ON_UA is set Bart Van Assche
@ 2024-08-07 20:32 ` Bart Van Assche
1 sibling, 0 replies; 5+ messages in thread
From: Bart Van Assche @ 2024-08-07 20:32 UTC (permalink / raw)
To: Martin K . Petersen
Cc: linux-scsi, Bart Van Assche, Damien Le Moal, Mike Christie,
James E.J. Bottomley
During system resume, sd_start_stop_device() submits a START STOP UNIT
command to the SCSI device that is being resumed. That command is not
retried in case of a unit attention and hence may fail. An example:
[16575.983359] sd 0:0:0:3: [sdd] Starting disk
[16575.983693] sd 0:0:0:3: [sdd] Start/Stop Unit failed: Result: hostbyte=0x00 driverbyte=DRIVER_OK
[16575.983712] sd 0:0:0:3: [sdd] Sense Key : 0x6
[16575.983730] sd 0:0:0:3: [sdd] ASC=0x29 ASCQ=0x0
[16575.983738] sd 0:0:0:3: PM: dpm_run_callback(): scsi_bus_resume+0x0/0xa0 returns -5
[16575.983783] sd 0:0:0:3: PM: failed to resume async: error -5
Make the SCSI core retry the START STOP UNIT command if the device
reports a unit attention.
Cc: Damien Le Moal <dlemoal@kernel.org>
Cc: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/scsi/sd.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 718eb91ba9a5..1b6996b48c8b 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -4093,6 +4093,7 @@ static int sd_start_stop_device(struct scsi_disk *sdkp, int start)
const struct scsi_exec_args exec_args = {
.sshdr = &sshdr,
.req_flags = BLK_MQ_REQ_PM,
+ .scmd_flags = SCMD_RETRY_PASST_ON_UA,
};
struct scsi_device *sdp = sdkp->device;
int res;
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] scsi: core: Retry passthrough commands if SCMD_RETRY_PASST_ON_UA is set
2024-08-07 20:32 ` [PATCH 1/2] scsi: core: Retry passthrough commands if SCMD_RETRY_PASST_ON_UA is set Bart Van Assche
@ 2024-08-09 15:40 ` Damien Le Moal
2024-08-09 19:35 ` Bart Van Assche
0 siblings, 1 reply; 5+ messages in thread
From: Damien Le Moal @ 2024-08-09 15:40 UTC (permalink / raw)
To: Bart Van Assche, Martin K . Petersen
Cc: linux-scsi, Mike Christie, James E.J. Bottomley
On 2024/08/07 13:32, Bart Van Assche wrote:
> The SCSI core does not retry passthrough commands even if the SCSI device
> reports a retryable unit attention condition. Support retrying in this case
> by introducing the SCMD_RETRY_PASST_ON_UA flag.
This flag is badly named since nowhere it is checked that the retry happens on
UNIT ATTENTION. The retry may happen with other sense key as well, no ?
So what about simply calling this: SCMD_RETRY_PASSTHROUGH ?
>
> Cc: Damien Le Moal <dlemoal@kernel.org>
> Cc: Mike Christie <michael.christie@oracle.com>
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> drivers/scsi/scsi_error.c | 5 ++++-
> include/scsi/scsi_cmnd.h | 5 ++++-
> 2 files changed, 8 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c
> index 612489afe8d2..38e3ea85e381 100644
> --- a/drivers/scsi/scsi_error.c
> +++ b/drivers/scsi/scsi_error.c
> @@ -1855,7 +1855,10 @@ 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))
> + if (req->cmd_flags & REQ_FAILFAST_DEV)
> + return true;
> + if (blk_rq_is_passthrough(req) &&
> + !(scmd->flags & SCMD_RETRY_PASST_ON_UA))
> return true;
>
> return false;
> diff --git a/include/scsi/scsi_cmnd.h b/include/scsi/scsi_cmnd.h
> index 45c40d200154..43c584fbeaca 100644
> --- a/include/scsi/scsi_cmnd.h
> +++ b/include/scsi/scsi_cmnd.h
> @@ -58,8 +58,11 @@ struct scsi_pointer {
> */
> #define SCMD_FORCE_EH_SUCCESS (1 << 3)
> #define SCMD_FAIL_IF_RECOVERING (1 << 4)
> +/* If set, retry a passthrough command in case of a unit attention. */
> +#define SCMD_RETRY_PASST_ON_UA (1 << 5)
> /* flags preserved across unprep / reprep */
> -#define SCMD_PRESERVED_FLAGS (SCMD_INITIALIZED | SCMD_FAIL_IF_RECOVERING)
> +#define SCMD_PRESERVED_FLAGS \
> + (SCMD_INITIALIZED | SCMD_FAIL_IF_RECOVERING | SCMD_RETRY_PASST_ON_UA)
>
> /* for scmd->state */
> #define SCMD_STATE_COMPLETE 0
>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 1/2] scsi: core: Retry passthrough commands if SCMD_RETRY_PASST_ON_UA is set
2024-08-09 15:40 ` Damien Le Moal
@ 2024-08-09 19:35 ` Bart Van Assche
0 siblings, 0 replies; 5+ messages in thread
From: Bart Van Assche @ 2024-08-09 19:35 UTC (permalink / raw)
To: Damien Le Moal, Martin K . Petersen
Cc: linux-scsi, Mike Christie, James E.J. Bottomley
On 8/9/24 8:40 AM, Damien Le Moal wrote:
> On 2024/08/07 13:32, Bart Van Assche wrote:
>> The SCSI core does not retry passthrough commands even if the SCSI device
>> reports a retryable unit attention condition. Support retrying in this case
>> by introducing the SCMD_RETRY_PASST_ON_UA flag.
>
> This flag is badly named since nowhere it is checked that the retry happens on
> UNIT ATTENTION. The retry may happen with other sense key as well, no ?
>
> So what about simply calling this: SCMD_RETRY_PASSTHROUGH ?
That sounds good to me. See also v2 of this patch series.
Thanks,
Bart.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-08-09 19:36 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-07 20:32 [PATCH 0/2] Fix system resume for SCSI devices Bart Van Assche
2024-08-07 20:32 ` [PATCH 1/2] scsi: core: Retry passthrough commands if SCMD_RETRY_PASST_ON_UA is set Bart Van Assche
2024-08-09 15:40 ` Damien Le Moal
2024-08-09 19:35 ` Bart Van Assche
2024-08-07 20:32 ` [PATCH 2/2] sd: Retry START STOP UNIT commands in case of a unit attention 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