diff mbox

Fix "Unsupported PQ" problems in the scsi-disk open function

Message ID 1491307071-19895-1-git-send-email-thuth@redhat.com
State Accepted
Headers show

Commit Message

Thomas Huth April 4, 2017, 11:57 a.m. UTC
The open function of the scsi-disk code has a bug: If it encounters
a Peripheral Qualifier != 0, it does not clean up the pointer to the
INQUIRY buffer before exiting, so the stack is messed up afterwards
and you get an ugly "Unknown Exception" before getting to the SLOF
prompt.
Also it's not a real error if the byte is set to 0x7f - this simply
means that the "SCSI target device is not capable of supporting a
peripheral device connected to this logical unit" (according to the
SPC-3 standard). So in this case, we should not issue an error
message, thus let's use the pointer to the INQUIRY buffer to check
whether the PQ/PDT byte is 0x7f to fix both problems.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 slof/fs/scsi-disk.fs | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

Comments

Nikunj A Dadhania April 5, 2017, 5:05 a.m. UTC | #1
Thomas Huth <thuth@redhat.com> writes:

> The open function of the scsi-disk code has a bug: If it encounters
> a Peripheral Qualifier != 0, it does not clean up the pointer to the
> INQUIRY buffer before exiting, so the stack is messed up afterwards
> and you get an ugly "Unknown Exception" before getting to the SLOF
> prompt.
> Also it's not a real error if the byte is set to 0x7f - this simply
> means that the "SCSI target device is not capable of supporting a
> peripheral device connected to this logical unit" (according to the
> SPC-3 standard). So in this case, we should not issue an error
> message, thus let's use the pointer to the INQUIRY buffer to check
> whether the PQ/PDT byte is 0x7f to fix both problems.
>
> Signed-off-by: Thomas Huth <thuth@redhat.com>

Reviewed-by: Nikunj A Dadhania <nikunj@linux.vnet.ibm.com>

> ---
>  slof/fs/scsi-disk.fs | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/slof/fs/scsi-disk.fs b/slof/fs/scsi-disk.fs
> index 9c0a9c1..97d9892 100644
> --- a/slof/fs/scsi-disk.fs
> +++ b/slof/fs/scsi-disk.fs
> @@ -323,8 +323,12 @@ CREATE cdb 10 allot
>  
>      \ Skip devices with PQ != 0
>      dup inquiry-data>peripheral c@ e0 and 0 <> IF
> -        ." SCSI-DISK: Unsupported PQ != 0" cr
> -	false EXIT
> +        \ Ignore 7f, since this simply means that the target
> +        \ is not supporting a peripheral device at this LUN.
> +        inquiry-data>peripheral c@ 7f <> IF
> +            ." SCSI-DISK: Unsupported PQ != 0" cr
> +        THEN
> +        false EXIT
>      THEN
>  
>      inquiry-data>peripheral c@ CASE
> -- 
> 1.8.3.1
>
> _______________________________________________
> SLOF mailing list
> SLOF@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/slof
Alexey Kardashevskiy April 6, 2017, 5:57 a.m. UTC | #2
On 04/04/17 21:57, Thomas Huth wrote:
> The open function of the scsi-disk code has a bug: If it encounters
> a Peripheral Qualifier != 0, it does not clean up the pointer to the
> INQUIRY buffer before exiting, so the stack is messed up afterwards
> and you get an ugly "Unknown Exception" before getting to the SLOF
> prompt.
> Also it's not a real error if the byte is set to 0x7f - this simply
> means that the "SCSI target device is not capable of supporting a
> peripheral device connected to this logical unit" (according to the
> SPC-3 standard). So in this case, we should not issue an error
> message, thus let's use the pointer to the INQUIRY buffer to check
> whether the PQ/PDT byte is 0x7f to fix both problems.
> 
> Signed-off-by: Thomas Huth <thuth@redhat.com>

Thanks, applied.

> ---
>  slof/fs/scsi-disk.fs | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
> 
> diff --git a/slof/fs/scsi-disk.fs b/slof/fs/scsi-disk.fs
> index 9c0a9c1..97d9892 100644
> --- a/slof/fs/scsi-disk.fs
> +++ b/slof/fs/scsi-disk.fs
> @@ -323,8 +323,12 @@ CREATE cdb 10 allot
>  
>      \ Skip devices with PQ != 0
>      dup inquiry-data>peripheral c@ e0 and 0 <> IF
> -        ." SCSI-DISK: Unsupported PQ != 0" cr
> -	false EXIT
> +        \ Ignore 7f, since this simply means that the target
> +        \ is not supporting a peripheral device at this LUN.
> +        inquiry-data>peripheral c@ 7f <> IF
> +            ." SCSI-DISK: Unsupported PQ != 0" cr
> +        THEN
> +        false EXIT
>      THEN
>  
>      inquiry-data>peripheral c@ CASE
>
diff mbox

Patch

diff --git a/slof/fs/scsi-disk.fs b/slof/fs/scsi-disk.fs
index 9c0a9c1..97d9892 100644
--- a/slof/fs/scsi-disk.fs
+++ b/slof/fs/scsi-disk.fs
@@ -323,8 +323,12 @@  CREATE cdb 10 allot
 
     \ Skip devices with PQ != 0
     dup inquiry-data>peripheral c@ e0 and 0 <> IF
-        ." SCSI-DISK: Unsupported PQ != 0" cr
-	false EXIT
+        \ Ignore 7f, since this simply means that the target
+        \ is not supporting a peripheral device at this LUN.
+        inquiry-data>peripheral c@ 7f <> IF
+            ." SCSI-DISK: Unsupported PQ != 0" cr
+        THEN
+        false EXIT
     THEN
 
     inquiry-data>peripheral c@ CASE