scsi: zero per-cmd driver data before each I/O
Subsystems (2)
PATCH v2 1/1 scsi: zero per-cmd driver data before each I/O
Without this drivers that don't clear the state themselves can see off effects. For example Hyper-V VMs using the storvsc driver will often hang during boot due to uncleared Test Unit Ready failures.
---
Changes since V1:
- use a single memset as suggested by Bart
drivers/scsi/scsi_lib.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/scsi/scsi_lib.c +1 -1
@@ -1166,7 +1166,7 @@ void scsi_init_command(struct scsi_device *dev, struct scsi_cmnd *cmd)/* zero out the cmd, except for the embedded scsi_request */ memset ((char *)cmd +sizeof (cmd->req),0 , -sizeof (*cmd) -sizeof (cmd->req)); +sizeof (*cmd) -sizeof (cmd->req) + dev->host->hostt->cmd_size); cmd->device = dev; cmd->sense_buffer = buf;
Signature · 1 line
2.11.0
On 02/21/2017 01:29 AM, Christoph Hellwig wrote:=0A=
Quoted 5 lines
Without this drivers that don't clear the state themselves can see off=0A= effects. For example Hyper-V VMs using the storvsc driver will often=0A= hang during boot due to uncleared Test Unit Ready failures.=0A= =0A=
Fixes e9c787e6 ("scsi: allocate scsi_cmnd structures as part of struct r=
equest")=0A=
drivers/scsi/scsi_lib.c=0A= void scsi_init_command(struct scsi_device *dev, str=
Quoted 16 lines
Signed-off-by Christoph Hellwig <[email protected]>=0A=Reported-by Dexuan Cui <[email protected]>=0A=Tested-by Dexuan Cui <[email protected]>=0A=---=0A=
=0A=
Changes since V1:=0A=
- use a single memset as suggested by Bart=0A=
=0A=
drivers/scsi/scsi_lib.c| 2 +-=0A=1 file changed, 1 insertion(+), 1 deletion(-)=0A==0A=
drivers/scsi/scsi_lib.c=0A= +0
-0@@ -1166,7 +1166,7 @@ void scsi_init_command(struct scsi_device *dev, str=
uct scsi_cmnd *cmd)=0A=
drivers/scsi/scsi_lib.c=0A= void scsi_init_command(struct scsi_device *dev, str= · line 1172
Quoted 8 lines
drivers/scsi/scsi_lib.c=0A= +1
-1=0A= /* zero out the cmd, except for the embedded scsi_request */=0A= memset((char *)cmd + sizeof(cmd->req), 0,=0A= - sizeof(*cmd) - sizeof(cmd->req));=0A= + sizeof(*cmd) - sizeof(cmd->req) + dev->host->hostt->cmd_size);=0A= =0A= cmd->device =3D dev;=0A= cmd->sense_buffer =3D buf;=0A=
=0A=
=0A=
=0A=
Jens Axboe
maintainerQuoted 4 lines · Christoph Hellwig
Without this drivers that don't clear the state themselves can see off effects. For example Hyper-V VMs using the storvsc driver will often hang during boot due to uncleared Test Unit Ready failures.
Quoted 8 lines
Fixes e9c787e6 ("scsi: allocate scsi_cmnd structures as part of struct request")Signed-off-by Christoph Hellwig <[email protected]>Reported-by Dexuan Cui <[email protected]>Tested-by Dexuan Cui <[email protected]>---
Changes since V1:
- use a single memset as suggested by Bart
That's much better. I'll queue this up for the next pull in this merge window.
Signature · 1 line
Jens Axboe