target: support zero allocation length in REQUEST SENSE
authorPaolo Bonzini <pbonzini@redhat.com>
Fri, 7 Sep 2012 15:30:36 +0000 (17:30 +0200)
committerNicholas Bellinger <nab@linux-iscsi.org>
Fri, 7 Sep 2012 18:14:21 +0000 (11:14 -0700)
commit32a8811ff164f882712c17946e58e52444f464a7
treef7af9ff41cd4f4e6c61a831c4e14fb1d57ebe05d
parent3717ef0c63e90686d959158e9728a13a49229be6
target: support zero allocation length in REQUEST SENSE

Similar to INQUIRY and MODE SENSE, construct the sense data in a
buffer and later copy it to the scatterlist.  Do not do anything,
but still clear a pending unit attention condition, if the allocation
length is zero.

However, SPC tells us that "If a REQUEST SENSE command is terminated with
CHECK CONDITION status [and] the REQUEST SENSE command was received on
an I_T nexus with a pending unit attention condition (i.e., before the
device server reports CHECK CONDITION status), then the device server
shall not clear the pending unit attention condition."  Do the
transport_kmap_data_sg early to detect this case.

It also tells us "Device servers shall not adjust the additional sense
length to reflect truncation if the allocation length is less than the
sense data available", so do not do that!  Note that the err variable
is write-only.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_spc.c
include/target/target_core_base.h