Message ID | 1474567987-31607-1-git-send-email-nikunj@linux.vnet.ibm.com |
---|---|
State | Accepted |
Headers | show |
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@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@redhat.com>
On 23/09/16 04: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@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 Thanks, applied the version from https://patchwork.ozlabs.org/patch/675736/ , somehow it have not received it in my mailbox :-/ > + 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 >
Alexey Kardashevskiy <aik@ozlabs.ru> writes: > On 23/09/16 04: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@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 > > > Thanks, applied the version from https://patchwork.ozlabs.org/patch/675736/ > , somehow it have not received it in my mailbox :-/ Hmm.. that is strange, will cc you next time onwards. Regards Nikunj
On 10/10/16 15:21, Nikunj A Dadhania wrote: > Alexey Kardashevskiy <aik@ozlabs.ru> writes: > >> On 23/09/16 04: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@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 >> >> >> Thanks, applied the version from https://patchwork.ozlabs.org/patch/675736/ >> , somehow it have not received it in my mailbox :-/ > > Hmm.. that is strange, will cc you next time onwards. No need, false alarm, found it :)
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 + 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
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@linux.vnet.ibm.com> --- slof/fs/scsi-disk.fs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)