target: Add extra TYPE_DISK + protection checks for INQUIRY SPT
authorNicholas Bellinger <nab@linux-iscsi.org>
Mon, 6 Jul 2015 22:26:37 +0000 (15:26 -0700)
committerNicholas Bellinger <nab@linux-iscsi.org>
Tue, 7 Jul 2015 01:07:17 +0000 (18:07 -0700)
Cc: Sagi Grimberg <sagig@mellanox.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_spc.c

index 5df4d9b097dc13f8afb43c8eacdc58ee416279c1..b5ba1ec3c35476361103d7dca47a1934cdd3289f 100644 (file)
@@ -454,12 +454,16 @@ spc_emulate_evpd_86(struct se_cmd *cmd, unsigned char *buf)
                    cmd->se_sess->sess_prot_type == TARGET_DIF_TYPE1_PROT)
                        buf[4] = 0x5;
                else if (dev->dev_attrib.pi_prot_type == TARGET_DIF_TYPE3_PROT ||
-                       cmd->se_sess->sess_prot_type == TARGET_DIF_TYPE3_PROT)
+                        cmd->se_sess->sess_prot_type == TARGET_DIF_TYPE3_PROT)
                        buf[4] = 0x4;
        }
 
        /* logical unit supports type 1 and type 3 protection */
-       buf[4] |= (0x3 << 3);
+       if ((dev->transport->get_device_type(dev) == TYPE_DISK) &&
+           (sess->sup_prot_ops & (TARGET_PROT_DIN_PASS | TARGET_PROT_DOUT_PASS)) &&
+           (dev->dev_attrib.pi_prot_type || cmd->se_sess->sess_prot_type)) {
+               buf[4] |= (0x3 << 3);
+       }
 
        /* Set HEADSUP, ORDSUP, SIMPSUP */
        buf[5] = 0x07;