[SLOF] [PATCH] scsi: implement read-capacity-16

Thomas Huth thuth at redhat.com
Wed Sep 28 00:00:42 AEST 2016


On 22.09.2016 20:13, Nikunj A Dadhania wrote:
> For disks bigger than 2TB(512B sector size), read-capacity-10 would fail
> and return FFFFFFFF, as it only has 4byte block address field. Detect
> this and use read-capacity-16 which returns 8byte block address.
> 
> Signed-off-by: Nikunj A Dadhania <nikunj at linux.vnet.ibm.com>
> ---
>  slof/fs/scsi-disk.fs | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/slof/fs/scsi-disk.fs b/slof/fs/scsi-disk.fs
> index 1978471..d4a774b 100644
> --- a/slof/fs/scsi-disk.fs
> +++ b/slof/fs/scsi-disk.fs
> @@ -121,6 +121,20 @@ CREATE cdb 10 allot
>      drop scratch scsi-get-capacity-10 1 +
>  ;
>  
> +: read-capacity-16 ( -- blocksize #blocks )
> +    \ Now issue the read-capacity-16 command
> +    scsi-disk-debug? IF
> +        ." SCSI-DISK: read-capacity-16 " .s cr
> +    THEN
> +    \ Make sure that there are zeros in the buffer in case something goes wrong:
> +    scratch 20 erase

I think you could use scsi-length-read-cap-16-data instead of the magic
value 20 here?

> +    cdb scsi-build-read-cap-16 scratch scsi-length-read-cap-16-data scsi-dir-read
> +    cdb scsi-param-size 1 retry-scsi-command
> +    \ Success ?
> +    dup 0<> IF " read-capacity-16" dump-scsi-error 0 0 EXIT THEN
> +    drop scratch scsi-get-capacity-16 1 +
> +;
> +
>  100 CONSTANT test-unit-retries
>  
>  \ SCSI test-unit-read
> @@ -293,6 +307,11 @@ CREATE cdb 10 allot
>      " max-transfer" $call-parent to max-transfer
>  
>      read-capacity to max-block-num to block-size
> +    \ Check if read-capacity-10 hit the maximum value 0xFFFF.FFFF
> +    max-block-num 100000000 = IF
> +        read-capacity-16 to max-block-num to block-size
> +    THEN
> +
>      max-block-num 0= block-size 0= OR IF
>         ." SCSI-DISK: Failed to get disk capacity!" cr
>         FALSE EXIT

With s/20/scsi-length-read-cap-16-data/ :

Reviewed-by: Thomas Huth <thuth at redhat.com>



More information about the SLOF mailing list