Commit 79dd6f2f authored by tangwenji's avatar tangwenji Committed by Nicholas Bellinger

target: add sense code INSUFFICIENT REGISTRATION RESOURCES

If a PERSISTENT RESERVE OUT command with a REGISTER service action or a
REGISTER AND IGNORE EXISTING KEY service action or REGISTER AND MOVE
service action is attempted, but there are insufficient device server
resources to complete the operation, then the command shall be terminated
with CHECK CONDITION status, with the sense key set to ILLEGAL REQUEST,and
the additonal sense code set to INSUFFICIENT REGISTRATION RESOURCES.
Signed-off-by: default avatartangwenji <tang.wenji@zte.com.cn>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent e437fa3e
...@@ -1521,7 +1521,7 @@ core_scsi3_decode_spec_i_port( ...@@ -1521,7 +1521,7 @@ core_scsi3_decode_spec_i_port(
tidh_new = kzalloc(sizeof(struct pr_transport_id_holder), GFP_KERNEL); tidh_new = kzalloc(sizeof(struct pr_transport_id_holder), GFP_KERNEL);
if (!tidh_new) { if (!tidh_new) {
pr_err("Unable to allocate tidh_new\n"); pr_err("Unable to allocate tidh_new\n");
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; return TCM_INSUFFICIENT_REGISTRATION_RESOURCES;
} }
INIT_LIST_HEAD(&tidh_new->dest_list); INIT_LIST_HEAD(&tidh_new->dest_list);
tidh_new->dest_tpg = tpg; tidh_new->dest_tpg = tpg;
...@@ -1533,7 +1533,7 @@ core_scsi3_decode_spec_i_port( ...@@ -1533,7 +1533,7 @@ core_scsi3_decode_spec_i_port(
sa_res_key, all_tg_pt, aptpl); sa_res_key, all_tg_pt, aptpl);
if (!local_pr_reg) { if (!local_pr_reg) {
kfree(tidh_new); kfree(tidh_new);
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; return TCM_INSUFFICIENT_REGISTRATION_RESOURCES;
} }
tidh_new->dest_pr_reg = local_pr_reg; tidh_new->dest_pr_reg = local_pr_reg;
/* /*
...@@ -1553,7 +1553,7 @@ core_scsi3_decode_spec_i_port( ...@@ -1553,7 +1553,7 @@ core_scsi3_decode_spec_i_port(
buf = transport_kmap_data_sg(cmd); buf = transport_kmap_data_sg(cmd);
if (!buf) { if (!buf) {
ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; ret = TCM_INSUFFICIENT_REGISTRATION_RESOURCES;
goto out; goto out;
} }
...@@ -1767,7 +1767,7 @@ core_scsi3_decode_spec_i_port( ...@@ -1767,7 +1767,7 @@ core_scsi3_decode_spec_i_port(
core_scsi3_nodeacl_undepend_item(dest_node_acl); core_scsi3_nodeacl_undepend_item(dest_node_acl);
core_scsi3_tpg_undepend_item(dest_tpg); core_scsi3_tpg_undepend_item(dest_tpg);
kfree(tidh_new); kfree(tidh_new);
ret = TCM_INVALID_PARAMETER_LIST; ret = TCM_INSUFFICIENT_REGISTRATION_RESOURCES;
goto out_unmap; goto out_unmap;
} }
tidh_new->dest_pr_reg = dest_pr_reg; tidh_new->dest_pr_reg = dest_pr_reg;
...@@ -2103,7 +2103,7 @@ core_scsi3_emulate_pro_register(struct se_cmd *cmd, u64 res_key, u64 sa_res_key, ...@@ -2103,7 +2103,7 @@ core_scsi3_emulate_pro_register(struct se_cmd *cmd, u64 res_key, u64 sa_res_key,
register_type, 0)) { register_type, 0)) {
pr_err("Unable to allocate" pr_err("Unable to allocate"
" struct t10_pr_registration\n"); " struct t10_pr_registration\n");
return TCM_INVALID_PARAMETER_LIST; return TCM_INSUFFICIENT_REGISTRATION_RESOURCES;
} }
} else { } else {
/* /*
...@@ -3215,7 +3215,7 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key, ...@@ -3215,7 +3215,7 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key,
*/ */
buf = transport_kmap_data_sg(cmd); buf = transport_kmap_data_sg(cmd);
if (!buf) { if (!buf) {
ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; ret = TCM_INSUFFICIENT_REGISTRATION_RESOURCES;
goto out_put_pr_reg; goto out_put_pr_reg;
} }
...@@ -3267,7 +3267,7 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key, ...@@ -3267,7 +3267,7 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key,
buf = transport_kmap_data_sg(cmd); buf = transport_kmap_data_sg(cmd);
if (!buf) { if (!buf) {
ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE; ret = TCM_INSUFFICIENT_REGISTRATION_RESOURCES;
goto out_put_pr_reg; goto out_put_pr_reg;
} }
proto_ident = (buf[24] & 0x0f); proto_ident = (buf[24] & 0x0f);
...@@ -3466,7 +3466,7 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key, ...@@ -3466,7 +3466,7 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key,
if (core_scsi3_alloc_registration(cmd->se_dev, dest_node_acl, if (core_scsi3_alloc_registration(cmd->se_dev, dest_node_acl,
dest_lun, dest_se_deve, dest_se_deve->mapped_lun, dest_lun, dest_se_deve, dest_se_deve->mapped_lun,
iport_ptr, sa_res_key, 0, aptpl, 2, 1)) { iport_ptr, sa_res_key, 0, aptpl, 2, 1)) {
ret = TCM_INVALID_PARAMETER_LIST; ret = TCM_INSUFFICIENT_REGISTRATION_RESOURCES;
goto out; goto out;
} }
spin_lock(&dev->dev_reservation_lock); spin_lock(&dev->dev_reservation_lock);
......
...@@ -3145,6 +3145,21 @@ static const struct sense_info sense_info_table[] = { ...@@ -3145,6 +3145,21 @@ static const struct sense_info sense_info_table[] = {
.key = NOT_READY, .key = NOT_READY,
.asc = 0x08, /* LOGICAL UNIT COMMUNICATION FAILURE */ .asc = 0x08, /* LOGICAL UNIT COMMUNICATION FAILURE */
}, },
[TCM_INSUFFICIENT_REGISTRATION_RESOURCES] = {
/*
* From spc4r22 section5.7.7,5.7.8
* If a PERSISTENT RESERVE OUT command with a REGISTER service action
* or a REGISTER AND IGNORE EXISTING KEY service action or
* REGISTER AND MOVE service actionis attempted,
* but there are insufficient device server resources to complete the
* operation, then the command shall be terminated with CHECK CONDITION
* status, with the sense key set to ILLEGAL REQUEST,and the additonal
* sense code set to INSUFFICIENT REGISTRATION RESOURCES.
*/
.key = ILLEGAL_REQUEST,
.asc = 0x55,
.ascq = 0x04, /* INSUFFICIENT REGISTRATION RESOURCES */
},
}; };
static int translate_sense_reason(struct se_cmd *cmd, sense_reason_t reason) static int translate_sense_reason(struct se_cmd *cmd, sense_reason_t reason)
......
...@@ -181,6 +181,7 @@ enum tcm_sense_reason_table { ...@@ -181,6 +181,7 @@ enum tcm_sense_reason_table {
TCM_UNSUPPORTED_TARGET_DESC_TYPE_CODE = R(0x1a), TCM_UNSUPPORTED_TARGET_DESC_TYPE_CODE = R(0x1a),
TCM_TOO_MANY_SEGMENT_DESCS = R(0x1b), TCM_TOO_MANY_SEGMENT_DESCS = R(0x1b),
TCM_UNSUPPORTED_SEGMENT_DESC_TYPE_CODE = R(0x1c), TCM_UNSUPPORTED_SEGMENT_DESC_TYPE_CODE = R(0x1c),
TCM_INSUFFICIENT_REGISTRATION_RESOURCES = R(0x1d),
#undef R #undef R
}; };
......
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