Skip to content

Commit dce5c4a

Browse files
Ye Binmartinkpetersen
authored andcommitted
scsi: core: Clear driver private data when retrying request
After commit 1bad6c4 ("scsi: zero per-cmd private driver data for each MQ I/O"), the xen-scsifront/virtio_scsi/snic drivers all removed code that explicitly zeroed driver-private command data. In combination with commit 464a00c ("scsi: core: Kill DRIVER_SENSE"), after virtio_scsi performs a capacity expansion, the first request will return a unit attention to indicate that the capacity has changed. And then the original command is retried. As driver-private command data was not cleared, the request would return UA again and eventually time out and fail. Zero driver-private command data when a request is retried. Fixes: f7de50d ("scsi: xen-scsifront: Remove code that zeroes driver-private command data") Fixes: c2bb873 ("scsi: virtio_scsi: Remove code that zeroes driver-private command data") Fixes: c3006a9 ("scsi: snic: Remove code that zeroes driver-private command data") Signed-off-by: Ye Bin <yebin10@huawei.com> Reviewed-by: Bart Van Assche <bvanassche@acm.org> Link: https://lore.kernel.org/r/20250217021628.2929248-1-yebin@huaweicloud.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 4fa382b commit dce5c4a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

drivers/scsi/scsi_lib.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1669,13 +1669,6 @@ static blk_status_t scsi_prepare_cmd(struct request *req)
16691669
if (in_flight)
16701670
__set_bit(SCMD_STATE_INFLIGHT, &cmd->state);
16711671

1672-
/*
1673-
* Only clear the driver-private command data if the LLD does not supply
1674-
* a function to initialize that data.
1675-
*/
1676-
if (!shost->hostt->init_cmd_priv)
1677-
memset(cmd + 1, 0, shost->hostt->cmd_size);
1678-
16791672
cmd->prot_op = SCSI_PROT_NORMAL;
16801673
if (blk_rq_bytes(req))
16811674
cmd->sc_data_direction = rq_dma_dir(req);
@@ -1842,6 +1835,13 @@ static blk_status_t scsi_queue_rq(struct blk_mq_hw_ctx *hctx,
18421835
if (!scsi_host_queue_ready(q, shost, sdev, cmd))
18431836
goto out_dec_target_busy;
18441837

1838+
/*
1839+
* Only clear the driver-private command data if the LLD does not supply
1840+
* a function to initialize that data.
1841+
*/
1842+
if (shost->hostt->cmd_size && !shost->hostt->init_cmd_priv)
1843+
memset(cmd + 1, 0, shost->hostt->cmd_size);
1844+
18451845
if (!(req->rq_flags & RQF_DONTPREP)) {
18461846
ret = scsi_prepare_cmd(req);
18471847
if (ret != BLK_STS_OK)

0 commit comments

Comments
 (0)