scsi: target: core: Add emulate_rsoc attribute
Allow support for RSOC to be turned off via the emulate_rsoc attibute. This is just for testing purposes. Reviewed-by: Roman Bolshakov <r.bolshakov@yadro.com> Signed-off-by: Dmitry Bogdanov <d.bogdanov@yadro.com> Link: https://lore.kernel.org/r/20220906103421.22348-5-d.bogdanov@yadro.com Reviewed-by: Mike Christie <michael.christie@oracle.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
parent
553b08d9b3
commit
bd217b8c3a
@ -547,6 +547,7 @@ DEF_CONFIGFS_ATTRIB_SHOW(unmap_granularity);
|
|||||||
DEF_CONFIGFS_ATTRIB_SHOW(unmap_granularity_alignment);
|
DEF_CONFIGFS_ATTRIB_SHOW(unmap_granularity_alignment);
|
||||||
DEF_CONFIGFS_ATTRIB_SHOW(unmap_zeroes_data);
|
DEF_CONFIGFS_ATTRIB_SHOW(unmap_zeroes_data);
|
||||||
DEF_CONFIGFS_ATTRIB_SHOW(max_write_same_len);
|
DEF_CONFIGFS_ATTRIB_SHOW(max_write_same_len);
|
||||||
|
DEF_CONFIGFS_ATTRIB_SHOW(emulate_rsoc);
|
||||||
|
|
||||||
#define DEF_CONFIGFS_ATTRIB_STORE_U32(_name) \
|
#define DEF_CONFIGFS_ATTRIB_STORE_U32(_name) \
|
||||||
static ssize_t _name##_store(struct config_item *item, const char *page,\
|
static ssize_t _name##_store(struct config_item *item, const char *page,\
|
||||||
@ -1186,6 +1187,23 @@ static ssize_t pgr_support_store(struct config_item *item,
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ssize_t emulate_rsoc_store(struct config_item *item,
|
||||||
|
const char *page, size_t count)
|
||||||
|
{
|
||||||
|
struct se_dev_attrib *da = to_attrib(item);
|
||||||
|
bool flag;
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = strtobool(page, &flag);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
da->emulate_rsoc = flag;
|
||||||
|
pr_debug("dev[%p]: SE Device REPORT_SUPPORTED_OPERATION_CODES_EMULATION flag: %d\n",
|
||||||
|
da->da_dev, flag);
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
CONFIGFS_ATTR(, emulate_model_alias);
|
CONFIGFS_ATTR(, emulate_model_alias);
|
||||||
CONFIGFS_ATTR(, emulate_dpo);
|
CONFIGFS_ATTR(, emulate_dpo);
|
||||||
CONFIGFS_ATTR(, emulate_fua_write);
|
CONFIGFS_ATTR(, emulate_fua_write);
|
||||||
@ -1198,6 +1216,7 @@ CONFIGFS_ATTR(, emulate_tpws);
|
|||||||
CONFIGFS_ATTR(, emulate_caw);
|
CONFIGFS_ATTR(, emulate_caw);
|
||||||
CONFIGFS_ATTR(, emulate_3pc);
|
CONFIGFS_ATTR(, emulate_3pc);
|
||||||
CONFIGFS_ATTR(, emulate_pr);
|
CONFIGFS_ATTR(, emulate_pr);
|
||||||
|
CONFIGFS_ATTR(, emulate_rsoc);
|
||||||
CONFIGFS_ATTR(, pi_prot_type);
|
CONFIGFS_ATTR(, pi_prot_type);
|
||||||
CONFIGFS_ATTR_RO(, hw_pi_prot_type);
|
CONFIGFS_ATTR_RO(, hw_pi_prot_type);
|
||||||
CONFIGFS_ATTR(, pi_prot_format);
|
CONFIGFS_ATTR(, pi_prot_format);
|
||||||
@ -1261,6 +1280,7 @@ struct configfs_attribute *sbc_attrib_attrs[] = {
|
|||||||
&attr_max_write_same_len,
|
&attr_max_write_same_len,
|
||||||
&attr_alua_support,
|
&attr_alua_support,
|
||||||
&attr_pgr_support,
|
&attr_pgr_support,
|
||||||
|
&attr_emulate_rsoc,
|
||||||
NULL,
|
NULL,
|
||||||
};
|
};
|
||||||
EXPORT_SYMBOL(sbc_attrib_attrs);
|
EXPORT_SYMBOL(sbc_attrib_attrs);
|
||||||
|
@ -785,6 +785,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
|
|||||||
dev->dev_attrib.emulate_caw = DA_EMULATE_CAW;
|
dev->dev_attrib.emulate_caw = DA_EMULATE_CAW;
|
||||||
dev->dev_attrib.emulate_3pc = DA_EMULATE_3PC;
|
dev->dev_attrib.emulate_3pc = DA_EMULATE_3PC;
|
||||||
dev->dev_attrib.emulate_pr = DA_EMULATE_PR;
|
dev->dev_attrib.emulate_pr = DA_EMULATE_PR;
|
||||||
|
dev->dev_attrib.emulate_rsoc = DA_EMULATE_RSOC;
|
||||||
dev->dev_attrib.pi_prot_type = TARGET_DIF_TYPE0_PROT;
|
dev->dev_attrib.pi_prot_type = TARGET_DIF_TYPE0_PROT;
|
||||||
dev->dev_attrib.enforce_pr_isids = DA_ENFORCE_PR_ISIDS;
|
dev->dev_attrib.enforce_pr_isids = DA_ENFORCE_PR_ISIDS;
|
||||||
dev->dev_attrib.force_pr_aptpl = DA_FORCE_PR_APTPL;
|
dev->dev_attrib.force_pr_aptpl = DA_FORCE_PR_APTPL;
|
||||||
|
@ -1889,6 +1889,14 @@ static struct target_opcode_descriptor tcm_opcode_report_target_pgs = {
|
|||||||
0xff, 0xff, 0x00, SCSI_CONTROL_MASK},
|
0xff, 0xff, 0x00, SCSI_CONTROL_MASK},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static bool spc_rsoc_enabled(struct se_cmd *cmd)
|
||||||
|
{
|
||||||
|
struct se_device *dev = cmd->se_dev;
|
||||||
|
|
||||||
|
return dev->dev_attrib.emulate_rsoc;
|
||||||
|
}
|
||||||
|
|
||||||
static struct target_opcode_descriptor tcm_opcode_report_supp_opcodes = {
|
static struct target_opcode_descriptor tcm_opcode_report_supp_opcodes = {
|
||||||
.support = SCSI_SUPPORT_FULL,
|
.support = SCSI_SUPPORT_FULL,
|
||||||
.serv_action_valid = 1,
|
.serv_action_valid = 1,
|
||||||
@ -1899,6 +1907,7 @@ static struct target_opcode_descriptor tcm_opcode_report_supp_opcodes = {
|
|||||||
0x87, 0xff,
|
0x87, 0xff,
|
||||||
0xff, 0xff, 0xff, 0xff,
|
0xff, 0xff, 0xff, 0xff,
|
||||||
0xff, 0xff, 0x00, SCSI_CONTROL_MASK},
|
0xff, 0xff, 0x00, SCSI_CONTROL_MASK},
|
||||||
|
.enabled = spc_rsoc_enabled,
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool tcm_is_set_tpg_enabled(struct se_cmd *cmd)
|
static bool tcm_is_set_tpg_enabled(struct se_cmd *cmd)
|
||||||
@ -2135,6 +2144,9 @@ spc_emulate_report_supp_op_codes(struct se_cmd *cmd)
|
|||||||
sense_reason_t ret = 0;
|
sense_reason_t ret = 0;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
if (!cmd->se_dev->dev_attrib.emulate_rsoc)
|
||||||
|
return TCM_UNSUPPORTED_SCSI_OPCODE;
|
||||||
|
|
||||||
rbuf = transport_kmap_data_sg(cmd);
|
rbuf = transport_kmap_data_sg(cmd);
|
||||||
if (cmd->data_length && !rbuf) {
|
if (cmd->data_length && !rbuf) {
|
||||||
ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
|
ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
|
||||||
|
@ -91,6 +91,8 @@
|
|||||||
#define DA_EMULATE_ALUA 0
|
#define DA_EMULATE_ALUA 0
|
||||||
/* Emulate SCSI2 RESERVE/RELEASE and Persistent Reservations by default */
|
/* Emulate SCSI2 RESERVE/RELEASE and Persistent Reservations by default */
|
||||||
#define DA_EMULATE_PR 1
|
#define DA_EMULATE_PR 1
|
||||||
|
/* Emulation for REPORT SUPPORTED OPERATION CODES */
|
||||||
|
#define DA_EMULATE_RSOC 1
|
||||||
/* Enforce SCSI Initiator Port TransportID with 'ISID' for PR */
|
/* Enforce SCSI Initiator Port TransportID with 'ISID' for PR */
|
||||||
#define DA_ENFORCE_PR_ISIDS 1
|
#define DA_ENFORCE_PR_ISIDS 1
|
||||||
/* Force SPC-3 PR Activate Persistence across Target Power Loss */
|
/* Force SPC-3 PR Activate Persistence across Target Power Loss */
|
||||||
@ -690,6 +692,7 @@ struct se_dev_attrib {
|
|||||||
bool emulate_caw;
|
bool emulate_caw;
|
||||||
bool emulate_3pc;
|
bool emulate_3pc;
|
||||||
bool emulate_pr;
|
bool emulate_pr;
|
||||||
|
bool emulate_rsoc;
|
||||||
enum target_prot_type pi_prot_type;
|
enum target_prot_type pi_prot_type;
|
||||||
enum target_prot_type hw_pi_prot_type;
|
enum target_prot_type hw_pi_prot_type;
|
||||||
bool pi_prot_verify;
|
bool pi_prot_verify;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user