On 10/30/19 8:18 AM, Hannes Reinecke wrote:
On 10/30/19 4:12 PM, Bart Van Assche wrote:
I do not agree that reporting a residual overflow by calling
scsi_set_resid(..., 0) is acceptable. For reads a residual overflow
means that the length specified in the CDB (scsi_bufflen()) exceeds
the data buffer size (length of scsi_sglist()). I think it's dangerous
to report to the block layer that such requests completed successfully
and with residual zero.
But that is an error on submission, and should be aborted before it even
got send to the drive.
If such a bug ever gets introduced in the SCSI core, I think that SCSI
target code should detect and report it. If the SCSI core receives a
response with a residual overflow it can then take appropriate action,
e.g. call WARN_ON_ONCE().
Users of sg_raw can trigger the residual overflow case easily.
However, this does not relate to the residual, which is handled after
the command completes (and which sparked this entire thread ...).
I'm still waiting for an answer to my question of how SCSI LLDs are
expected to report a residual overflow to the SCSI core.
Thanks,
Bart.