diff mbox

scsi: implement READ (16) command

Message ID 1475044674-12910-1-git-send-email-nikunj@linux.vnet.ibm.com
State Superseded
Headers show

Commit Message

Nikunj A Dadhania Sept. 28, 2016, 6:37 a.m. UTC
For disks bigger than 2TB(512B sector size), read-10 would fail as it is
limited by the block address(4bytes). Add and use SCSI command READ(16)
which has 8bytes block address.

Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
---
 slof/fs/scsi-disk.fs    |  2 +-
 slof/fs/scsi-support.fs | 29 +++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)

Comments

Thomas Huth Sept. 28, 2016, 6:52 a.m. UTC | #1
On 28.09.2016 08:37, Nikunj A Dadhania wrote:
> For disks bigger than 2TB(512B sector size), read-10 would fail as it is
> limited by the block address(4bytes). Add and use SCSI command READ(16)
> which has 8bytes block address.
> 
> Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
> ---
>  slof/fs/scsi-disk.fs    |  2 +-
>  slof/fs/scsi-support.fs | 29 +++++++++++++++++++++++++++++
>  2 files changed, 30 insertions(+), 1 deletion(-)
> 
> diff --git a/slof/fs/scsi-disk.fs b/slof/fs/scsi-disk.fs
> index 2f7d740..83aab89 100644
> --- a/slof/fs/scsi-disk.fs
> +++ b/slof/fs/scsi-disk.fs
> @@ -82,7 +82,7 @@ CREATE cdb 10 allot
>      >r rot r> 			                ( block# #blocks addr len )
>      2swap                                       ( addr len block# #blocks )
>      dup >r
> -    cdb scsi-build-read-10                      ( addr len )
> +    cdb scsi-build-read-16                      ( addr len )
>      r> -rot                                     ( #blocks addr len )
>      scsi-dir-read cdb scsi-param-size 10
>      retry-scsi-command

I'm feeling a little bit uneasy about using READ-16 here
unconditionally... IIRC, the scsi stack is also used for USB devices,
and these often used to only implement the bare minimum of SCSI
commands, i.e. things like READ-16 are likely not supported there.
Could you maybe add a check if the block address can not be stored in 4
bytes anymore, and only use the READ-16 in that case?

 Thanks,
  Thomas
Nikunj A Dadhania Sept. 28, 2016, 7:03 a.m. UTC | #2
Thomas Huth <thuth@redhat.com> writes:

> On 28.09.2016 08:37, Nikunj A Dadhania wrote:
>> For disks bigger than 2TB(512B sector size), read-10 would fail as it is
>> limited by the block address(4bytes). Add and use SCSI command READ(16)
>> which has 8bytes block address.
>> 
>> Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
>> ---
>>  slof/fs/scsi-disk.fs    |  2 +-
>>  slof/fs/scsi-support.fs | 29 +++++++++++++++++++++++++++++
>>  2 files changed, 30 insertions(+), 1 deletion(-)
>> 
>> diff --git a/slof/fs/scsi-disk.fs b/slof/fs/scsi-disk.fs
>> index 2f7d740..83aab89 100644
>> --- a/slof/fs/scsi-disk.fs
>> +++ b/slof/fs/scsi-disk.fs
>> @@ -82,7 +82,7 @@ CREATE cdb 10 allot
>>      >r rot r> 			                ( block# #blocks addr len )
>>      2swap                                       ( addr len block# #blocks )
>>      dup >r
>> -    cdb scsi-build-read-10                      ( addr len )
>> +    cdb scsi-build-read-16                      ( addr len )
>>      r> -rot                                     ( #blocks addr len )
>>      scsi-dir-read cdb scsi-param-size 10
>>      retry-scsi-command
>
> I'm feeling a little bit uneasy about using READ-16 here
> unconditionally... IIRC, the scsi stack is also used for USB devices,
> and these often used to only implement the bare minimum of SCSI
> commands, i.e. things like READ-16 are likely not supported there.
> Could you maybe add a check if the block address can not be stored in 4
> bytes anymore, and only use the READ-16 in that case?

Yeah sure, that can be done. How about this:

    cdb                                         ( addr len block# #blocks cdb )
    max-block-num FFFFFFFF > IF
        scsi-build-read-16                      ( addr len )
    ELSE
        scsi-build-read-10                      ( addr len )
    THEN
    r> -rot                                     ( #blocks addr len )

Regards,
Nikunj
Thomas Huth Sept. 28, 2016, 7:15 a.m. UTC | #3
On 28.09.2016 09:03, Nikunj A Dadhania wrote:
> Thomas Huth <thuth@redhat.com> writes:
> 
>> On 28.09.2016 08:37, Nikunj A Dadhania wrote:
>>> For disks bigger than 2TB(512B sector size), read-10 would fail as it is
>>> limited by the block address(4bytes). Add and use SCSI command READ(16)
>>> which has 8bytes block address.
>>>
>>> Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
>>> ---
>>>  slof/fs/scsi-disk.fs    |  2 +-
>>>  slof/fs/scsi-support.fs | 29 +++++++++++++++++++++++++++++
>>>  2 files changed, 30 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/slof/fs/scsi-disk.fs b/slof/fs/scsi-disk.fs
>>> index 2f7d740..83aab89 100644
>>> --- a/slof/fs/scsi-disk.fs
>>> +++ b/slof/fs/scsi-disk.fs
>>> @@ -82,7 +82,7 @@ CREATE cdb 10 allot
>>>      >r rot r> 			                ( block# #blocks addr len )
>>>      2swap                                       ( addr len block# #blocks )
>>>      dup >r
>>> -    cdb scsi-build-read-10                      ( addr len )
>>> +    cdb scsi-build-read-16                      ( addr len )
>>>      r> -rot                                     ( #blocks addr len )
>>>      scsi-dir-read cdb scsi-param-size 10
>>>      retry-scsi-command
>>
>> I'm feeling a little bit uneasy about using READ-16 here
>> unconditionally... IIRC, the scsi stack is also used for USB devices,
>> and these often used to only implement the bare minimum of SCSI
>> commands, i.e. things like READ-16 are likely not supported there.
>> Could you maybe add a check if the block address can not be stored in 4
>> bytes anymore, and only use the READ-16 in that case?
> 
> Yeah sure, that can be done. How about this:
> 
>     cdb                                         ( addr len block# #blocks cdb )
>     max-block-num FFFFFFFF > IF
>         scsi-build-read-16                      ( addr len )
>     ELSE
>         scsi-build-read-10                      ( addr len )
>     THEN
>     r> -rot                                     ( #blocks addr len )

Sounds good!

 Thomas
Alexey Kardashevskiy Oct. 12, 2016, 12:48 a.m. UTC | #4
On 28/09/16 17:03, Nikunj A Dadhania wrote:
> Thomas Huth <thuth@redhat.com> writes:
> 
>> On 28.09.2016 08:37, Nikunj A Dadhania wrote:
>>> For disks bigger than 2TB(512B sector size), read-10 would fail as it is
>>> limited by the block address(4bytes). Add and use SCSI command READ(16)
>>> which has 8bytes block address.
>>>
>>> Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
>>> ---
>>>  slof/fs/scsi-disk.fs    |  2 +-
>>>  slof/fs/scsi-support.fs | 29 +++++++++++++++++++++++++++++
>>>  2 files changed, 30 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/slof/fs/scsi-disk.fs b/slof/fs/scsi-disk.fs
>>> index 2f7d740..83aab89 100644
>>> --- a/slof/fs/scsi-disk.fs
>>> +++ b/slof/fs/scsi-disk.fs
>>> @@ -82,7 +82,7 @@ CREATE cdb 10 allot
>>>      >r rot r> 			                ( block# #blocks addr len )
>>>      2swap                                       ( addr len block# #blocks )
>>>      dup >r
>>> -    cdb scsi-build-read-10                      ( addr len )
>>> +    cdb scsi-build-read-16                      ( addr len )
>>>      r> -rot                                     ( #blocks addr len )
>>>      scsi-dir-read cdb scsi-param-size 10
>>>      retry-scsi-command
>>
>> I'm feeling a little bit uneasy about using READ-16 here
>> unconditionally... IIRC, the scsi stack is also used for USB devices,
>> and these often used to only implement the bare minimum of SCSI
>> commands, i.e. things like READ-16 are likely not supported there.
>> Could you maybe add a check if the block address can not be stored in 4
>> bytes anymore, and only use the READ-16 in that case?
> 
> Yeah sure, that can be done. How about this:
> 
>     cdb                                         ( addr len block# #blocks cdb )
>     max-block-num FFFFFFFF > IF
>         scsi-build-read-16                      ( addr len )
>     ELSE
>         scsi-build-read-10                      ( addr len )
>     THEN
>     r> -rot                                     ( #blocks addr len )


You'll repost the patch, right?
Nikunj A Dadhania Oct. 12, 2016, 3:41 a.m. UTC | #5
Alexey Kardashevskiy <aik@ozlabs.ru> writes:

> On 28/09/16 17:03, Nikunj A Dadhania wrote:
>> Thomas Huth <thuth@redhat.com> writes:
>> 
>>> On 28.09.2016 08:37, Nikunj A Dadhania wrote:
>>>> For disks bigger than 2TB(512B sector size), read-10 would fail as it is
>>>> limited by the block address(4bytes). Add and use SCSI command READ(16)
>>>> which has 8bytes block address.
>>>>
>>>> Signed-off-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>
>>>> ---
>>>>  slof/fs/scsi-disk.fs    |  2 +-
>>>>  slof/fs/scsi-support.fs | 29 +++++++++++++++++++++++++++++
>>>>  2 files changed, 30 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/slof/fs/scsi-disk.fs b/slof/fs/scsi-disk.fs
>>>> index 2f7d740..83aab89 100644
>>>> --- a/slof/fs/scsi-disk.fs
>>>> +++ b/slof/fs/scsi-disk.fs
>>>> @@ -82,7 +82,7 @@ CREATE cdb 10 allot
>>>>      >r rot r> 			                ( block# #blocks addr len )
>>>>      2swap                                       ( addr len block# #blocks )
>>>>      dup >r
>>>> -    cdb scsi-build-read-10                      ( addr len )
>>>> +    cdb scsi-build-read-16                      ( addr len )
>>>>      r> -rot                                     ( #blocks addr len )
>>>>      scsi-dir-read cdb scsi-param-size 10
>>>>      retry-scsi-command
>>>
>>> I'm feeling a little bit uneasy about using READ-16 here
>>> unconditionally... IIRC, the scsi stack is also used for USB devices,
>>> and these often used to only implement the bare minimum of SCSI
>>> commands, i.e. things like READ-16 are likely not supported there.
>>> Could you maybe add a check if the block address can not be stored in 4
>>> bytes anymore, and only use the READ-16 in that case?
>> 
>> Yeah sure, that can be done. How about this:
>> 
>>     cdb                                         ( addr len block# #blocks cdb )
>>     max-block-num FFFFFFFF > IF
>>         scsi-build-read-16                      ( addr len )
>>     ELSE
>>         scsi-build-read-10                      ( addr len )
>>     THEN
>>     r> -rot                                     ( #blocks addr len )
>
>
> You'll repost the patch, right?

Oops, I thought I did :(

Regards,
Nikunj
diff mbox

Patch

diff --git a/slof/fs/scsi-disk.fs b/slof/fs/scsi-disk.fs
index 2f7d740..83aab89 100644
--- a/slof/fs/scsi-disk.fs
+++ b/slof/fs/scsi-disk.fs
@@ -82,7 +82,7 @@  CREATE cdb 10 allot
     >r rot r> 			                ( block# #blocks addr len )
     2swap                                       ( addr len block# #blocks )
     dup >r
-    cdb scsi-build-read-10                      ( addr len )
+    cdb scsi-build-read-16                      ( addr len )
     r> -rot                                     ( #blocks addr len )
     scsi-dir-read cdb scsi-param-size 10
     retry-scsi-command
diff --git a/slof/fs/scsi-support.fs b/slof/fs/scsi-support.fs
index 3e65c87..202d43f 100644
--- a/slof/fs/scsi-support.fs
+++ b/slof/fs/scsi-support.fs
@@ -525,6 +525,35 @@  CONSTANT scsi-length-read-12
 ;
 
 \ ***************************************************************************
+\ SCSI-Command: READ (16)
+\         Type: Block Command
+\ ***************************************************************************
+\ Forth Word:   scsi-build-read-16  ( block# #blocks cdb -- )
+\ ***************************************************************************
+\ command code
+88 CONSTANT scsi-cmd-read-16
+
+\ CDB structure
+STRUCT
+   /c FIELD read-16>operation-code     \ code: 88
+   /c FIELD read-16>protect            \ RDPROTECT, DPO, FUA, FUA_NV
+   /n	FIELD read-16>block-address      \ lba
+   /l FIELD read-16>length             \ transfer length (32bits)
+   /c FIELD read-16>group              \ group number
+   /c FIELD read-16>control
+CONSTANT scsi-length-read-16
+
+: scsi-build-read-16                         ( block# #blocks cdb -- )
+   >r                                        ( block# #blocks )  ( R: -- cdb )
+   r@ scsi-length-read-16 erase              \ 16 bytes CDB
+	scsi-cmd-read-16 r@ read-16>operation-code c! ( block# #blocks )
+   r@ read-16>length l!                      ( block# )
+   r@ read-16>block-address !                (  )
+   scsi-param-control r> read-16>control c!  ( R: cdb -- )
+   scsi-length-read-16 to scsi-param-size    \ update CDB length
+;
+
+\ ***************************************************************************
 \ SCSI-Command: READ with autodetection of required command
 \               read(10) or read(12) depending on parameter size
 \               (read(6) removed because obsolete in some cases (USB))