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

FUJITA Tomonori fujita.tomonori
Sun Jul 20 02:29:31 CEST 2008


On Sat, 19 Jul 2008 19:34:54 +0200
Albert Pauw <albert.pauw at gmail.com> wrote:

> 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

Thanks, few comments.

> @@ -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;

For the future changes, can we add:

data[1] = (blk_len >> 16) & 0xff

>      data[2] = blk_len >> 8;
>      data[3] = blk_len & 0x0ff;

Let's do:

data[2] = (blk_len >> 8) & 0xff;
data[3] = blk_len & 0xff;

> -    data[5] = blk_len >> 8;
> -    data[6] = blk_len & 0x0ff;
> +    data[4] = blk_len >> 8;
> +    data[5] = blk_len & 0x0ff;

dito.

>      memcpy(scsi_get_in_buffer(cmd), data, 6);
>      eprintf("In ssc_read_block_limit \n");

We should check the buffer length but it would be better to do that
with a different patch.



More information about the stgt mailing list