Skip to content

Commit e662502

Browse files
Matt Wangmartinkpetersen
authored andcommitted
scsi: vmw_pvscsi: Set correct residual data length
Some commands (such as INQUIRY) may return less data than the initiator requested. To avoid conducting useless information, set the 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 ................ [mkp: clarified description] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Matt Wang <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 122c81c commit e662502

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/scsi/vmw_pvscsi.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -585,7 +585,13 @@ static void pvscsi_complete_request(struct pvscsi_adapter *adapter,
585585
case BTSTAT_SUCCESS:
586586
case BTSTAT_LINKED_COMMAND_COMPLETED:
587587
case BTSTAT_LINKED_COMMAND_COMPLETED_WITH_FLAG:
588-
/* If everything went fine, let's move on.. */
588+
/*
589+
* Commands like INQUIRY may transfer less data than
590+
* requested by the initiator via bufflen. Set residual
591+
* count to make upper layer aware of the actual amount
592+
* of data returned.
593+
*/
594+
scsi_set_resid(cmd, scsi_bufflen(cmd) - e->dataLen);
589595
cmd->result = (DID_OK << 16);
590596
break;
591597

0 commit comments

Comments
 (0)