]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
target: Fix MAINTENANCE_IN service action CDB checks to use lower 5 bits
authorNicholas Bellinger <nab@linux-iscsi.org>
Thu, 17 May 2012 04:52:10 +0000 (21:52 -0700)
committerBen Hutchings <ben@decadent.org.uk>
Thu, 25 Apr 2013 19:25:37 +0000 (20:25 +0100)
commit ba539743b70cd160c84bab1c82910d0789b820f8 upstream.

This patch fixes the MAINTENANCE_IN service action type checks to only
look at the proper lower 5 bits of cdb byte 1.  This addresses the case
where MI_REPORT_TARGET_PGS w/ extended header using the upper three bits of
cdb byte 1 was not processed correctly in transport_generic_cmd_sequencer,
as well as the three cases for standby, unavailable, and transition ALUA
primary access state checks.

Also add MAINTENANCE_IN to the excluded list in transport_generic_prepare_cdb()
to prevent the PARAMETER DATA FORMAT bits from being cleared.

Cc: Hannes Reinecke <hare@suse.de>
Cc: Rob Evers <revers@redhat.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Roland Dreier <roland@purestorage.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
drivers/target/target_core_alua.c
drivers/target/target_core_transport.c

index 0364ca2d42ec26102bcd43fb01959c2ec129e64c..93ffb0359dfc58bb6ec60728783486250f4bbc3c 100644 (file)
@@ -394,7 +394,7 @@ static inline int core_alua_state_standby(
        case RECEIVE_DIAGNOSTIC:
        case SEND_DIAGNOSTIC:
        case MAINTENANCE_IN:
-               switch (cdb[1]) {
+               switch (cdb[1] & 0x1f) {
                case MI_REPORT_TARGET_PGS:
                        return 0;
                default:
@@ -436,7 +436,7 @@ static inline int core_alua_state_unavailable(
        case INQUIRY:
        case REPORT_LUNS:
        case MAINTENANCE_IN:
-               switch (cdb[1]) {
+               switch (cdb[1] & 0x1f) {
                case MI_REPORT_TARGET_PGS:
                        return 0;
                default:
@@ -476,7 +476,7 @@ static inline int core_alua_state_transition(
        case INQUIRY:
        case REPORT_LUNS:
        case MAINTENANCE_IN:
-               switch (cdb[1]) {
+               switch (cdb[1] & 0x1f) {
                case MI_REPORT_TARGET_PGS:
                        return 0;
                default:
index 9176b2e4ed3dae0f9f5035aefe1f920aff23f8ab..898c1de1a56be67a7ca72874ad722c1f2f9e3370 100644 (file)
@@ -1445,6 +1445,7 @@ static inline void transport_generic_prepare_cdb(
        case VERIFY_16: /* SBC - VRProtect */
        case WRITE_VERIFY: /* SBC - VRProtect */
        case WRITE_VERIFY_12: /* SBC - VRProtect */
+       case MAINTENANCE_IN: /* SPC - Parameter Data Format for SA RTPG */
                break;
        default:
                cdb[1] &= 0x1f; /* clear logical unit number */
@@ -2683,7 +2684,7 @@ static int transport_generic_cmd_sequencer(
                        /*
                         * Check for emulated MI_REPORT_TARGET_PGS.
                         */
-                       if (cdb[1] == MI_REPORT_TARGET_PGS &&
+                       if ((cdb[1] & 0x1f) == MI_REPORT_TARGET_PGS &&
                            su_dev->t10_alua.alua_type == SPC3_ALUA_EMULATED) {
                                cmd->execute_task =
                                        target_emulate_report_target_port_groups;