scsi: target: pscsi: Set SCF_TREAT_READ_AS_NORMAL flag only if there is valid data
authorDavid Jeffery <djeffery@redhat.com>
Wed, 27 Apr 2022 18:32:50 +0000 (14:32 -0400)
committerMartin K. Petersen <martin.petersen@oracle.com>
Thu, 28 Apr 2022 02:40:09 +0000 (22:40 -0400)
commit8be70a842f70c0fe8e00fd488b1966344fa10ff4
tree6556e5cbfa4572a8849649aee72b80a66a77e3df
parentfaad6cebded8e0fd902b672f220449b93db479eb
scsi: target: pscsi: Set SCF_TREAT_READ_AS_NORMAL flag only if there is valid data

With tape devices, the SCF_TREAT_READ_AS_NORMAL flag is used by the target
subsystem to mark commands which have both data to return as well as sense
data. But with pscsi, SCF_TREAT_READ_AS_NORMAL can be set even if there is
no data to return. The SCF_TREAT_READ_AS_NORMAL flag causes the target core
to call iscsit data-in callbacks even if there is no data, which iscsit
does not support. This results in iscsit going into an error state
requiring recovery and being unable to complete the command to the
initiator.

This issue can be resolved by fixing pscsi to only set
SCF_TREAT_READ_AS_NORMAL if there is valid data to return alongside the
sense data.

Link: https://lore.kernel.org/r/20220427183250.291881-1-djeffery@redhat.com
Fixes: bd81372065fa ("scsi: target: transport should handle st FM/EOM/ILI reads")
Reported-by: Scott Hamilton <scott.hamilton@atos.net>
Tested-by: Laurence Oberman <loberman@redhat.com>
Reviewed-by: Laurence Oberman <loberman@redhat.com>
Signed-off-by: David Jeffery <djeffery@redhat.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/target/target_core_pscsi.c