[Stgt-devel] [PATCH] read block limits data offset one off

Albert Pauw albert.pauw
Sat Jul 19 19:34:54 CEST 2008


According to SSC-2 Rev 8 the Read Block Limits return data is made up of 
6 bytes, index 0-5:

Byte 0 contains granularity (bits 0-4)
Byte 1-3 contain  Maximum Block Length Limit (MSB first)
Byte 4-5 contain Minimum Block Length Limit (MSB first)

Since all bytes are zeroed first, Byte 1 is zero.

I also added a defined value for the granularity, as defined by the
Read Block Limits command, and calculate the blk_len out of it.
Now you only need to change the GRANULARITY parameter.

So the patch is:

--- ssc.c    2008-07-19 19:29:58.000000000 +0200
+++ ssc.c.new    2008-07-19 19:30:54.000000000 +0200
@@ -35,6 +35,7 @@
 #include "tgtadm_error.h"
 
 #define BLK_SHIFT    9
+#define GRANULARITY    9
 
 
 static int ssc_rw(int host_no, struct scsi_cmd *cmd)
@@ -73,16 +74,16 @@
 {
     uint8_t *data;
     uint8_t buf[256];
-    uint16_t blk_len = 0x200;
+    uint16_t blk_len = 1 << GRANULARITY;
 
     memset(buf, 0, sizeof(buf));
     data = buf;
 
-    data[0] = 9;
+    data[0] = GRANULARITY;
     data[2] = blk_len >> 8;
     data[3] = blk_len & 0x0ff;
-    data[5] = blk_len >> 8;
-    data[6] = blk_len & 0x0ff;
+    data[4] = blk_len >> 8;
+    data[5] = blk_len & 0x0ff;
 
     memcpy(scsi_get_in_buffer(cmd), data, 6);
     eprintf("In ssc_read_block_limit \n");




More information about the stgt mailing list