• Roland Dreier's avatar
    target: Fix error checking for UNMAP commands · bb992e72
    Roland Dreier authored
    SBC-3 (revision 35) says:
    
        The PARAMETER LIST LENGTH field specifies the length in bytes of the
        UNMAP parameter list that is available to be transferred from the
        Data-Out Buffer. If the parameter list length is greater than zero
        and less than 0008h (i.e., eight), then the device server shall
        terminate the command with CHECK CONDITION status with the sense key
        set to ILLEGAL REQUEST and the additional sense code set to
        PARAMETER LIST LENGTH ERROR. A PARAMETER LIST LENGTH set to zero
        specifies that no data shall be sent.
    
    so our sense code for too-short descriptors was wrong, and we were
    incorrectly failing commands that didn't transfer any descriptors.
    
    While we're at it, also handle the UNMAP check:
    
        If the ANCHOR bit is set to one, and the ANC_SUP bit in the Logical
        Block Provisioning VPD page (see 6.6.4) is set to zero, then the
        device server shall terminate the command with CHECK CONDITION
        status with the sense key set to ILLEGAL REQUEST and the additional
        sense code set to INVALID FIELD IN CDB.
    
    (chris boot: Fix wrong cut+paste comment in transport_send_check_condition_and_sense)
    Signed-off-by: default avatarRoland Dreier <roland@purestorage.com>
    Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
    bb992e72
target_core_transport.c 77.9 KB