Skip to contentSkip to conversation

SCSI: usage of DID_REQUEUE vs DID_RESET for returning SCSI commands to be retried

PATCH Sumit Saxena 3 participants 4 messages Dec 13, 2016 – Dec 14, 2016

Subsystems (2)
lore
Share & tools
lore

Sumit Saxena

author maintainer
#0 lore raw

Hi all,

I have query regarding usage of host_byte DID_REQUEUE vs DID_RESET returned by LLD to SCSI mid layer.

Let me give some background here.
I am using megaraid_sas controller. megaraid_sas driver returns all outstanding SCSI commands back to SCSI layer with DID_RESET host_byte before resetting controller.
The intent is- all these commands returned with DID_RESET before controller reset should be retried by SCSI.

In few distros, I have observed that if SYNCHRONIZE_CACHE command(should be applicable for all non Read write commands) is outstanding before resetting controller and driver returns those commands back with DID_RESET then SYNCHRONIZE_CACHE command not retried but failed to upper layer
but other READ/WRITE commands were not failed but retried. I was running filesystem IOs and SYNHRONIZE_CACHE returned with error cause filesystem to go in READ only mode.

Later I checked and realized below commit was missing in that distro kernel and seems to cause the problem-

a621bac scsi_lib: correctly retry failed zero length REQ_TYPE_FS commands

But distro kernel has below commit-

89fb4cd scsi: handle flush errors properly

Issue does not hit on the kernels which don't have both commits but hits when commit- "89fb4cd scsi: handle flush errors properly " is there but commit- "a621bac scsi_lib: correctly retry failed zero length REQ_TYPE_FS commands" is missing.

This issue is observed with mpt3sas driver as well and should be applicable to all LLDs returning non read write commands with DID_RESET.

Returning DID_REQUEUE instead of DID_RESET from driver solves the problem irrespective of whether these above mentioned commits are there or not in kernel.
So I am thinking to use DID_REQUEUE instead of DID_RESET in megaraid_sas driver for all SCSI commands(not only limited to SYNCHRONIZE_CACHE or non read write commands)
before resetting controller. As I mentioned intent is those outstanding commands returned by driver before doing controller reset should be retried and as soon as reset is complete,
driver will be processing those commands. There is no sense key associated with SCSI commands returned.

I browsed SCSI code and get to know DID_REQUEUE causes command to be retried by calling- scsi_queue_insert(cmd, SCSI_MLQUEUE_DEVICE_BUSY). This seems to be good enough for our requirement of commands to be re-tried by SCSI layer.

Please provide feedback if anyone forsee any issue with using DID_REQUEUE for this use case.
I will be doing some testing with DID_REQUEUE in place of DID_RESET in megaraid_sas driver.

I have attached here a proposed patch for megaraid_sas driver. If there are no concerns, I will send this patch to SCSI mailing list.

Thanks,
Sumit

Driver returns outstanding SCSI commands to SCSI layer with host_byte set to DID_RESET before resetting controller so that SCSI layer should retry
those commands.
Sending DID_RESET for non RW commands(e.g SYNCHRONIZE_CACHE) may cause those commands getting failed and returning I/O erros on few distros which has included commit- 89fb4cd scsi: handle flush errors properly but missed commit- a621bac scsi_lib: correctly retry failed zero length REQ_TYPE_FS commands.
However Read write commands returned with DID_RESET are not failed but retried.

DID_REQUEUE seems safer to use instead of DID_RESET for all outstanding commands before doing chip reset as it serves purpose of getting all commands
to be retried by SCSI layer.

---
 drivers/scsi/megaraid/megaraid_sas_base.c   | 4 ++--
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/drivers/scsi/megaraid/megaraid_sas_base.c
index 6484c38..959ce3e 100644

drivers/scsi/megaraid/megaraid_sas_base.c +0 -0
@@ -1662,7 +1662,7 @@ megasas_queue_command(struct Scsi_Host *shost,

struct scsi_cmnd *scmd)
/* Check for an mpio path and adjust behavior */
if (atomic_read(&instance->adprecovery) ==
MEGASAS_ADPRESET_SM_INFAULT) {
if (megasas_check_mpio_paths(instance, scmd) ==
- (DID_RESET << 16)) {
+ (DID_REQUEUE << 16)) {
return SCSI_MLQUEUE_HOST_BUSY;
} else {
scmd->result = DID_NO_CONNECT << 16;
@@ -2483,7 +2483,7 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance)
struct megasas_cmd, list);
list_del_init(&reset_cmd->list);
if (reset_cmd->scmd) {
- reset_cmd->scmd->result = DID_RESET << 16;
+ reset_cmd->scmd->result = DID_REQUEUE <<
16;
dev_notice(&instance->pdev->dev, "%d:%p
reset [%02x]\n",
reset_index, reset_cmd, reset_cmd->scmd->cmnd[0]);

(quoted diff) +0 -0

b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 24778ba..58cbe30 100644

drivers/scsi/megaraid/megaraid_sas_fusion.c +0 -0
@@ -3362,7 +3362,7 @@ int megasas_check_mpio_paths(struct megasas_instance

*instance,
struct scsi_cmnd *scmd)
{
struct megasas_instance *peer_instance = NULL;
- int retval = (DID_RESET << 16);
+ int retval = (DID_REQUEUE << 16);

if (instance->peerIsPresent) {
peer_instance = megasas_get_peer_instance(instance);

Signature · 1 line
2.4.11
author maintainer
#1 lore raw

Adding direct email addresses of few people to avoid any filters.

Hannes/Martin/James/Tomas/Christoph,

Can you please comment on this?

Thanks,
Sumit

Quoted 10 lines

-----Original Message-----
From: Sumit Saxena [mailto:[email protected]]
Sent: Tuesday, December 13, 2016 6:50 PM
To: 'linux-scsi'
Subject: SCSI: usage of DID_REQUEUE vs DID_RESET for returning SCSI commands to be retried

Hi all,

I have query regarding usage of host_byte DID_REQUEUE vs DID_RESET

returned

Quoted 4 lines

by LLD to SCSI mid layer.

Let me give some background here.
I am using megaraid_sas controller. megaraid_sas driver returns all

outstanding

Quoted 1 line

SCSI commands back to SCSI layer with DID_RESET host_byte before

resetting

Quoted 2 lines

controller.
The intent is- all these commands returned with DID_RESET before

controller

Quoted 3 lines

reset should be retried by SCSI.

In few distros, I have observed that if SYNCHRONIZE_CACHE command(should

be

Quoted 1 line

applicable for all non Read write commands) is outstanding before

resetting

Quoted 3 lines

controller and driver returns those commands back with DID_RESET then SYNCHRONIZE_CACHE command not retried but failed to upper layer but other READ/WRITE commands were not failed but retried. I was running filesystem

IOs

Quoted 1 line

and SYNHRONIZE_CACHE returned with error cause filesystem to go in READ

only

Quoted 3 lines

mode.

Later I checked and realized below commit was missing in that distro

kernel and

Quoted 9 lines

seems to cause the problem-

a621bac scsi_lib: correctly retry failed zero length REQ_TYPE_FS commands

But distro kernel has below commit-

89fb4cd scsi: handle flush errors properly

Issue does not hit on the kernels which don't have both commits but hits

when

Quoted 1 line

commit- "89fb4cd scsi: handle flush errors properly " is there but

commit-

Quoted 1 line

"a621bac scsi_lib: correctly retry failed zero length REQ_TYPE_FS

commands" is

Quoted 3 lines

missing.

This issue is observed with mpt3sas driver as well and should be

applicable to all

Quoted 8 lines

LLDs returning non read write commands with DID_RESET.

Returning DID_REQUEUE instead of DID_RESET from driver solves the problem irrespective of whether these above mentioned commits are there or not in kernel.
So I am thinking to use DID_REQUEUE instead of DID_RESET in megaraid_sas driver for all SCSI commands(not only limited to SYNCHRONIZE_CACHE or non read write commands) before resetting controller. As I mentioned intent

is those

Quoted 1 line

outstanding commands returned by driver before doing controller reset

should be

Quoted 6 lines

retried and as soon as reset is complete, driver will be processing those commands. There is no sense key associated with SCSI commands returned.

I browsed SCSI code and get to know DID_REQUEUE causes command to be retried by calling- scsi_queue_insert(cmd, SCSI_MLQUEUE_DEVICE_BUSY). This seems to be good enough for our requirement of commands to be

re-tried

Quoted 3 lines

by SCSI layer.

Please provide feedback if anyone forsee any issue with using DID_REQUEUE

for

Quoted 9 lines

this use case.
I will be doing some testing with DID_REQUEUE in place of DID_RESET in megaraid_sas driver.

I have attached here a proposed patch for megaraid_sas driver. If there are no concerns, I will send this patch to SCSI mailing list.

Thanks,
Sumit

Driver returns outstanding SCSI commands to SCSI layer with host_byte set to DID_RESET before resetting controller so that SCSI layer should retry
those commands.
Sending DID_RESET for non RW commands(e.g SYNCHRONIZE_CACHE) may cause those commands getting failed and returning I/O erros on few distros which has included commit- 89fb4cd scsi: handle flush errors properly but missed commit- a621bac scsi_lib: correctly retry failed zero length REQ_TYPE_FS commands.
However Read write commands returned with DID_RESET are not failed but retried.

DID_REQUEUE seems safer to use instead of DID_RESET for all outstanding commands before doing chip reset as it serves purpose of getting all commands
to be retried by SCSI layer.

---
 drivers/scsi/megaraid/megaraid_sas_base.c   | 4 ++--
 drivers/scsi/megaraid/megaraid_sas_fusion.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/drivers/scsi/megaraid/megaraid_sas_base.c
index 6484c38..959ce3e 100644

drivers/scsi/megaraid/megaraid_sas_base.c +0 -0
@@ -1662,7 +1662,7 @@ megasas_queue_command(struct Scsi_Host *shost,

struct scsi_cmnd *scmd)
/* Check for an mpio path and adjust behavior */
if (atomic_read(&instance->adprecovery) ==
MEGASAS_ADPRESET_SM_INFAULT) {
if (megasas_check_mpio_paths(instance, scmd) ==
- (DID_RESET << 16)) {
+ (DID_REQUEUE << 16)) {
return SCSI_MLQUEUE_HOST_BUSY;
} else {
scmd->result = DID_NO_CONNECT << 16;
@@ -2483,7 +2483,7 @@ static int megasas_wait_for_outstanding(struct megasas_instance *instance)
struct megasas_cmd, list);
list_del_init(&reset_cmd->list);
if (reset_cmd->scmd) {
- reset_cmd->scmd->result = DID_RESET << 16;
+ reset_cmd->scmd->result = DID_REQUEUE <<
16;
dev_notice(&instance->pdev->dev, "%d:%p
reset [%02x]\n",
reset_index, reset_cmd, reset_cmd->scmd->cmnd[0]);

(quoted diff) +0 -0

b/drivers/scsi/megaraid/megaraid_sas_fusion.c
index 24778ba..58cbe30 100644

drivers/scsi/megaraid/megaraid_sas_fusion.c +0 -0
@@ -3362,7 +3362,7 @@ int megasas_check_mpio_paths(struct megasas_instance

*instance,
struct scsi_cmnd *scmd)
{
struct megasas_instance *peer_instance = NULL;
- int retval = (DID_RESET << 16);
+ int retval = (DID_REQUEUE << 16);

if (instance->peerIsPresent) {
peer_instance = megasas_get_peer_instance(instance);

Signature · 1 line
2.4.11
#2 lore raw
In reply to Sumit Saxena
Quoted 55 lines · Sumit Saxena

Hi all,

I have query regarding usage of host_byte DID_REQUEUE vs DID_RESET returned by LLD to SCSI mid layer.

Let me give some background here.
I am using megaraid_sas controller. megaraid_sas driver returns all outstanding SCSI commands back to SCSI layer with DID_RESET host_byte before resetting controller.
The intent is- all these commands returned with DID_RESET before controller reset should be retried by SCSI.

In few distros, I have observed that if SYNCHRONIZE_CACHE command(should be applicable for all non Read write commands) is outstanding before resetting controller and driver returns those commands back with DID_RESET then SYNCHRONIZE_CACHE command not retried but failed to upper layer
but other READ/WRITE commands were not failed but retried. I was running filesystem IOs and SYNHRONIZE_CACHE returned with error cause filesystem to go in READ only mode.

Later I checked and realized below commit was missing in that distro kernel and seems to cause the problem-

a621bac scsi_lib: correctly retry failed zero length REQ_TYPE_FS commands

But distro kernel has below commit-

89fb4cd scsi: handle flush errors properly

Issue does not hit on the kernels which don't have both commits but hits when commit- "89fb4cd scsi: handle flush errors properly " is there but commit- "a621bac scsi_lib: correctly retry failed zero length REQ_TYPE_FS commands" is missing.

This issue is observed with mpt3sas driver as well and should be applicable to all LLDs returning non read write commands with DID_RESET.

Returning DID_REQUEUE instead of DID_RESET from driver solves the problem irrespective of whether these above mentioned commits are there or not in kernel.
So I am thinking to use DID_REQUEUE instead of DID_RESET in megaraid_sas driver for all SCSI commands(not only limited to SYNCHRONIZE_CACHE or non read write commands)
before resetting controller. As I mentioned intent is those outstanding commands returned by driver before doing controller reset should be retried and as soon as reset is complete,
driver will be processing those commands. There is no sense key associated with SCSI commands returned.

I browsed SCSI code and get to know DID_REQUEUE causes command to be retried by calling- scsi_queue_insert(cmd, SCSI_MLQUEUE_DEVICE_BUSY). This seems to be good enough for our requirement of commands to be re-tried by SCSI layer.

Quoted 8 lines

Please provide feedback if anyone forsee any issue with using DID_REQUEUE for this use case.
I will be doing some testing with DID_REQUEUE in place of DID_RESET in megaraid_sas driver.

I have attached here a proposed patch for megaraid_sas driver. If there are no concerns, I will send this patch to SCSI mailing list.

Hmm.

DID_RESET is meant to be an indicator to the SCSI midlayer that the host / device was reset, and the command _should_ be retried. DID_REQUEUE OTOH is an indicator to the SCSI midlayer to retry the command.

The problem with DID_RESET is that it's slightly underspecified; there is no indication if the command has been processed (and if so, up to which parts?) DID_REQUEUE, OTOH, will always cause a retry.

So yeah, I guess DID_REQUEUE is a better choice here.

Cheers,

Hannes

Signature · 5 lines
Dr. Hannes Reinecke		   Teamlead Storage & Networking
[email protected]			               +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
maintainer
#3 lore raw
Quoted 80 lines

-----Original Message-----
From: [email protected] [mailto:linux-scsi- [email protected]] On Behalf Of Hannes Reinecke
Sent: Wednesday, December 14, 2016 9:07 PM
To: Sumit Saxena; linux-scsi
Subject: Re: SCSI: usage of DID_REQUEUE vs DID_RESET for returning SCSI commands to be retried

Quoted 56 lines · Sumit Saxena

Hi all,

I have query regarding usage of host_byte DID_REQUEUE vs DID_RESET returned by LLD to SCSI mid layer.

Let me give some background here.
I am using megaraid_sas controller. megaraid_sas driver returns all outstanding SCSI commands back to SCSI layer with DID_RESET host_byte before resetting controller.
The intent is- all these commands returned with DID_RESET before controller reset should be retried by SCSI.

In few distros, I have observed that if SYNCHRONIZE_CACHE command(should be applicable for all non Read write commands) is outstanding before resetting controller and driver returns those commands back with DID_RESET then SYNCHRONIZE_CACHE command not retried but failed to upper layer but other READ/WRITE commands were not failed but retried. I was running filesystem IOs and SYNHRONIZE_CACHE returned with error cause filesystem to go in READ only mode.

Later I checked and realized below commit was missing in that distro kernel and seems to cause the problem-

a621bac scsi_lib: correctly retry failed zero length REQ_TYPE_FS commands

But distro kernel has below commit-

89fb4cd scsi: handle flush errors properly

Issue does not hit on the kernels which don't have both commits but hits when commit- "89fb4cd scsi: handle flush errors properly " is there but commit- "a621bac scsi_lib: correctly retry failed zero length REQ_TYPE_FS commands" is missing.

This issue is observed with mpt3sas driver as well and should be applicable to all LLDs returning non read write commands with DID_RESET.

Returning DID_REQUEUE instead of DID_RESET from driver solves the problem irrespective of whether these above mentioned commits are there or not in kernel.
So I am thinking to use DID_REQUEUE instead of DID_RESET in megaraid_sas driver for all SCSI commands(not only limited to SYNCHRONIZE_CACHE or non read write commands) before resetting controller. As I mentioned intent is those outstanding commands returned by driver before doing controller reset should be retried and as soon as reset is complete, driver will be processing those commands. There is no sense key associated with SCSI commands returned.

I browsed SCSI code and get to know DID_REQUEUE causes command to be retried by calling- scsi_queue_insert(cmd, SCSI_MLQUEUE_DEVICE_BUSY). This seems to be good enough for our requirement of commands to be re-tried by SCSI layer.

Quoted 8 lines

Please provide feedback if anyone forsee any issue with using DID_REQUEUE for this use case.
I will be doing some testing with DID_REQUEUE in place of DID_RESET in megaraid_sas driver.

I have attached here a proposed patch for megaraid_sas driver. If there are no concerns, I will send this patch to SCSI mailing list.

Hmm.

DID_RESET is meant to be an indicator to the SCSI midlayer that the host / device was reset, and the command _should_ be retried. DID_REQUEUE OTOH is an indicator to the SCSI midlayer to retry the command.

Quoted 7 lines

The problem with DID_RESET is that it's slightly underspecified; there is no
indication if the command has been processed (and if so, up to which parts?)
DID_REQUEUE, OTOH, will always cause a retry.

So yeah, I guess DID_REQUEUE is a better choice here.

Thanks Hannes. We thought DID_REQUEUE functionality will be a better choice and we are planning to move that with proposed patch.

Thanks for your feedback. We will be sending the final patch to upstream. Now, queuing this change for internal testing.

Quoted 16 lines

Cheers,

Hannes
--
Dr. Hannes Reinecke Teamlead Storage & Networking
[email protected] +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton HRB 21284 (AG
Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of
a message to [email protected] More majordomo info at
http://vger.kernel.org/majordomo-info.html