All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Set correct transferred data length for PVSCSI
@ 2021-05-19  9:49 Matt Wang
  2021-05-22  4:40 ` Martin K. Petersen
  0 siblings, 1 reply; 2+ messages in thread
From: Matt Wang @ 2021-05-19  9:49 UTC (permalink / raw)
  To: Vishal Bhakta; +Cc: Elaine Zhao, Pv-drivers, linux-scsi

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(-)

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;

--
2.17.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] Set correct transferred data length for PVSCSI
  2021-05-19  9:49 [PATCH] Set correct transferred data length for PVSCSI Matt Wang
@ 2021-05-22  4:40 ` Martin K. Petersen
  0 siblings, 0 replies; 2+ messages in thread
From: Martin K. Petersen @ 2021-05-22  4:40 UTC (permalink / raw)
  To: Matt Wang, Vishal Bhakta
  Cc: Martin K . Petersen, Pv-drivers, linux-scsi, Elaine Zhao

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

-- 
Martin K. Petersen	Oracle Linux Engineering

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-22  4:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-19  9:49 [PATCH] Set correct transferred data length for PVSCSI Matt Wang
2021-05-22  4:40 ` Martin K. Petersen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.