Skip to contentSkip to conversation

tracing: Fix handling of TRANSFER LENGTH == 0 for READ(6) and WRITE(6)

PATCH In review Bart Van Assche 3 participants 3 messages Nov 5, 2019 – Nov 7, 2019 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tracing: Fix handling of TRANSFER LENGTH == 0 for READ(6) and WRITE(6)

According to SBC-2 a TRANSFER LENGTH field of zero means that 256 logical blocks must be transferred. Make the SCSI tracing code follow SBC-2.

Cc Christoph Hellwig <[email protected]>
Cc Hannes Reinecke <[email protected]>
Cc Douglas Gilbert <[email protected]>
Fixes bf8162354233 ("[SCSI] add scsi trace core functions and put trace points")
---
 drivers/scsi/scsi_trace.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/scsi/scsi_trace.c +7 -4
index 784ed9a32a0d..ac35c301c792 100644
@@ -18,15 +18,18 @@ static const char *
 scsi_trace_rw6(struct trace_seq *p, unsigned char *cdb, int len)
 {
 	const char *ret = trace_seq_buffer_ptr(p);
-	sector_t lba = 0, txlen = 0;
+	u32 lba = 0, txlen;
 
 	lba |= ((cdb[1] & 0x1F) << 16);
 	lba |=  (cdb[2] << 8);
 	lba |=   cdb[3];
-	txlen = cdb[4];
+	/*
+	 * From SBC-2: a TRANSFER LENGTH field set to zero specifies that 256
+	 * logical blocks shall be read (READ(6)) or written (WRITE(6)).
+	 */
+	txlen = cdb[4] ? cdb[4] : 256;
 
-	trace_seq_printf(p, "lba=%llu txlen=%llu",
-			 (unsigned long long)lba, (unsigned long long)txlen);
+	trace_seq_printf(p, "lba=%u txlen=%u", lba, txlen);
 	trace_seq_putc(p, 0);
 
 	return ret;
Signature · 1 line
2.24.0.rc1.363.gb1bccd3e3d-goog
#1 lore raw
Quoted 4 lines

According to SBC-2 a TRANSFER LENGTH field of zero means that 256 logical blocks must be transferred. Make the SCSI tracing code follow SBC-2.

Thanks, Bart! Applied to 5.5/scsi-queue.

Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering
Reviewed-by on v1 1/1
#2 lore raw
In reply to Bart Van Assche
Quoted 8 lines · Bart Van Assche

According to SBC-2 a TRANSFER LENGTH field of zero means that 256 logical blocks must be transferred. Make the SCSI tracing code follow SBC-2.

Cc Christoph Hellwig <[email protected]>
Cc Hannes Reinecke <[email protected]>
Cc Douglas Gilbert <[email protected]>
Fixes bf8162354233 ("[SCSI] add scsi trace core functions and put trace points")
Quoted 32 lines
---
  drivers/scsi/scsi_trace.c | 11 +++++++----
  1 file changed, 7 insertions(+), 4 deletions(-)
drivers/scsi/scsi_trace.c +7 -4
index 784ed9a32a0d..ac35c301c792 100644
@@ -18,15 +18,18 @@ static const char *
  scsi_trace_rw6(struct trace_seq *p, unsigned char *cdb, int len)
  {
  	const char *ret = trace_seq_buffer_ptr(p);
-	sector_t lba = 0, txlen = 0;
+	u32 lba = 0, txlen;
 
  	lba |= ((cdb[1] & 0x1F) << 16);
  	lba |=  (cdb[2] << 8);
  	lba |=   cdb[3];
-	txlen = cdb[4];
+	/*
+	 * From SBC-2: a TRANSFER LENGTH field set to zero specifies that 256
+	 * logical blocks shall be read (READ(6)) or written (WRITE(6)).
+	 */
+	txlen = cdb[4] ? cdb[4] : 256;
 
-	trace_seq_printf(p, "lba=%llu txlen=%llu",
-			 (unsigned long long)lba, (unsigned long long)txlen);
+	trace_seq_printf(p, "lba=%u txlen=%u", lba, txlen);
  	trace_seq_putc(p, 0);
 
  	return ret;