scsi: zero per-cmd driver data before each I/O
authorChristoph Hellwig <hch@lst.de>
Tue, 21 Feb 2017 09:04:55 +0000 (10:04 +0100)
committerJens Axboe <axboe@fb.com>
Tue, 21 Feb 2017 19:51:54 +0000 (12:51 -0700)
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.

Fixes: e9c787e6 ("scsi: allocate scsi_cmnd structures as part of struct request")
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reported-by: Dexuan Cui <decui@microsoft.com>
Tested-by: Dexuan Cui <decui@microsoft.com>
Reviewed-by: Bart Van Assche <bart.vanassche@sandisk.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/scsi/scsi_lib.c

index 912fbc3b4543dd5e87b04341862293d46fd57f30..3e32dc954c3c8c6b05d5883615afc1b21864e401 100644 (file)
@@ -1167,7 +1167,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;