Commit 12f66e4a authored by Jiang Yi's avatar Jiang Yi Committed by Nicholas Bellinger

target: reject COMPARE_AND_WRITE if emulate_caw is not set

In struct se_dev_attrib, there is a field emulate_caw exposed
as a /sys/kernel/config/target/core/$HBA/$DEV/attrib/.

If this field is set zero, it means the corresponding struct se_device
does not support the scsi cmd COMPARE_AND_WRITE

In function sbc_parse_cdb(), go ahead and reject scsi COMPARE_AND_WRITE
if emulate_caw is not set, because it has been explicitly disabled
from user-space.

(Make pr_err ratelimited - nab)
Signed-off-by: default avatarJiang Yi <jiangyilism@gmail.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent eceb4459
......@@ -1005,6 +1005,12 @@ sbc_parse_cdb(struct se_cmd *cmd, struct sbc_ops *ops)
break;
}
case COMPARE_AND_WRITE:
if (!dev->dev_attrib.emulate_caw) {
pr_err_ratelimited("se_device %s/%s (vpd_unit_serial %s) reject"
" COMPARE_AND_WRITE\n", dev->se_hba->backend->ops->name,
dev->dev_group.cg_item.ci_name, dev->t10_wwn.unit_serial);
return TCM_UNSUPPORTED_SCSI_OPCODE;
}
sectors = cdb[13];
/*
* Currently enforce COMPARE_AND_WRITE for a single sector
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment