Message ID | 03C41093-B62E-43A2-913E-CFC92F1C70C3@vmware.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
Series | Set correct transferred data length for PVSCSI | expand |
On Wed, 19 May 2021 09:49:32 +0000, Matt Wang wrote: > Some commands like INQUIRY VPD pages may return bytes less than > commands data buffer. To avoid conducting useless information, set right > residual count to make upper layer aware of this. > > Before (INQUIRY PAGE 0xB0 with 128B buffer): > sg_raw -r 128 /dev/sda 12 01 B0 00 80 00 > SCSI Status: Good > > [...] Applied to 5.13/scsi-fixes, thanks! [1/1] Set correct transferred data length for PVSCSI https://git.kernel.org/mkp/scsi/c/e662502b3a78
diff --git a/drivers/scsi/vmw_pvscsi.c b/drivers/scsi/vmw_pvscsi.c index 8a79605d9652..73cba0ec41ae 100644 --- a/drivers/scsi/vmw_pvscsi.c +++ b/drivers/scsi/vmw_pvscsi.c @@ -585,7 +585,13 @@ static void pvscsi_complete_request(struct pvscsi_adapter *adapter, case BTSTAT_SUCCESS: case BTSTAT_LINKED_COMMAND_COMPLETED: case BTSTAT_LINKED_COMMAND_COMPLETED_WITH_FLAG: - /* If everything went fine, let's move on.. */ + /* + * If everything went fine, let's move on. + * Some commands like INQUIRY VPD pages may transfer + * less bytes than bufflen, set residual count + * correspondingly to make upper layer aware of this. + */ + scsi_set_resid(cmd, scsi_bufflen(cmd) - e->dataLen); cmd->result = (DID_OK << 16); break;
Some commands like INQUIRY VPD pages may return bytes less than commands data buffer. To avoid conducting useless information, set right residual count to make upper layer aware of this. Before (INQUIRY PAGE 0xB0 with 128B buffer): sg_raw -r 128 /dev/sda 12 01 B0 00 80 00 SCSI Status: Good Received 128 bytes of data: 00 00 b0 00 3c 01 00 00 00 00 00 00 00 00 00 00 00 ...<............ 10 00 00 00 00 00 01 00 00 00 00 00 40 00 00 08 00 ...........@.... 20 80 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 .......... ..... 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 40 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 60 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ 70 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ................ After: sg_raw -r 128 /dev/sda 12 01 B0 00 80 00 SCSI Status: Good Received 64 bytes of data: 00 00 b0 00 3c 01 00 00 00 00 00 00 00 00 00 00 00 ...<............ 10 00 00 00 00 00 01 00 00 00 00 00 40 00 00 08 00 ...........@.... 20 80 00 00 00 00 00 00 00 00 00 20 00 00 00 00 00 .......... ..... 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ……………. Signed-off-by: Matt Wang <wwentao@vmware.com> --- drivers/scsi/vmw_pvscsi.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) -- 2.17.1