summaryrefslogtreecommitdiff
path: root/drivers/target/target_core_sbc.c
diff options
context:
space:
mode:
authorNicholas Bellinger <nab@linux-iscsi.org>2015-04-14 11:57:43 -0700
committerNicholas Bellinger <nab@linux-iscsi.org>2015-04-15 22:47:17 -0700
commitd7a463b0acc3fecf9d01cd5d518bf46578658ff3 (patch)
tree9a7c3c8ce23ea4b4c20ba32f4be8a3a276d8fa4e /drivers/target/target_core_sbc.c
parentcceca4a638708c7f62e60f9f99684a8d57358dd0 (diff)
target/sbc: Make internal DIF emulation honor ->prot_checks
The internal DIF emulation was not honoring se_cmd->prot_checks for the WRPROTECT/RDPROTECT == 0x3 case, so sbc_dif_v1_verify() has been updated to follow which checks have been calculated based on WRPROTECT/RDPROTECT in sbc_set_prot_op_checks(). Reviewed-by: Martin Petersen <martin.petersen@oracle.com> Reviewed-by: Sagi Grimberg <sagig@mellanox.com> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Diffstat (limited to 'drivers/target/target_core_sbc.c')
-rw-r--r--drivers/target/target_core_sbc.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c
index 7006c95586e3..38d7c33bbc99 100644
--- a/drivers/target/target_core_sbc.c
+++ b/drivers/target/target_core_sbc.c
@@ -1230,6 +1230,9 @@ sbc_dif_v1_verify(struct se_cmd *cmd, struct se_dif_v1_tuple *sdt,
int block_size = dev->dev_attrib.block_size;
__be16 csum;
+ if (!(cmd->prot_checks & TARGET_DIF_CHECK_GUARD))
+ goto check_ref;
+
csum = cpu_to_be16(crc_t10dif(p, block_size));
if (sdt->guard_tag != csum) {
@@ -1239,6 +1242,10 @@ sbc_dif_v1_verify(struct se_cmd *cmd, struct se_dif_v1_tuple *sdt,
return TCM_LOGICAL_BLOCK_GUARD_CHECK_FAILED;
}
+check_ref:
+ if (!(cmd->prot_checks & TARGET_DIF_CHECK_REFTAG))
+ return 0;
+
if (cmd->prot_type == TARGET_DIF_TYPE1_PROT &&
be32_to_cpu(sdt->ref_tag) != (sector & 0xffffffff)) {
pr_err("DIFv1 Type 1 reference failed on sector: %llu tag: 0x%08x"