Skip to content

Commit 79dd6f2

Browse files
tangwenjiNicholas Bellinger
authored andcommitted
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: tangwenji <[email protected]> Signed-off-by: Nicholas Bellinger <[email protected]>
1 parent e437fa3 commit 79dd6f2

File tree

3 files changed

+24
-8
lines changed

3 files changed

+24
-8
lines changed

drivers/target/target_core_pr.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@ core_scsi3_decode_spec_i_port(
15211521
tidh_new = kzalloc(sizeof(struct pr_transport_id_holder), GFP_KERNEL);
15221522
if (!tidh_new) {
15231523
pr_err("Unable to allocate tidh_new\n");
1524-
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
1524+
return TCM_INSUFFICIENT_REGISTRATION_RESOURCES;
15251525
}
15261526
INIT_LIST_HEAD(&tidh_new->dest_list);
15271527
tidh_new->dest_tpg = tpg;
@@ -1533,7 +1533,7 @@ core_scsi3_decode_spec_i_port(
15331533
sa_res_key, all_tg_pt, aptpl);
15341534
if (!local_pr_reg) {
15351535
kfree(tidh_new);
1536-
return TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
1536+
return TCM_INSUFFICIENT_REGISTRATION_RESOURCES;
15371537
}
15381538
tidh_new->dest_pr_reg = local_pr_reg;
15391539
/*
@@ -1553,7 +1553,7 @@ core_scsi3_decode_spec_i_port(
15531553

15541554
buf = transport_kmap_data_sg(cmd);
15551555
if (!buf) {
1556-
ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
1556+
ret = TCM_INSUFFICIENT_REGISTRATION_RESOURCES;
15571557
goto out;
15581558
}
15591559

@@ -1767,7 +1767,7 @@ core_scsi3_decode_spec_i_port(
17671767
core_scsi3_nodeacl_undepend_item(dest_node_acl);
17681768
core_scsi3_tpg_undepend_item(dest_tpg);
17691769
kfree(tidh_new);
1770-
ret = TCM_INVALID_PARAMETER_LIST;
1770+
ret = TCM_INSUFFICIENT_REGISTRATION_RESOURCES;
17711771
goto out_unmap;
17721772
}
17731773
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,
21032103
register_type, 0)) {
21042104
pr_err("Unable to allocate"
21052105
" struct t10_pr_registration\n");
2106-
return TCM_INVALID_PARAMETER_LIST;
2106+
return TCM_INSUFFICIENT_REGISTRATION_RESOURCES;
21072107
}
21082108
} else {
21092109
/*
@@ -3215,7 +3215,7 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key,
32153215
*/
32163216
buf = transport_kmap_data_sg(cmd);
32173217
if (!buf) {
3218-
ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
3218+
ret = TCM_INSUFFICIENT_REGISTRATION_RESOURCES;
32193219
goto out_put_pr_reg;
32203220
}
32213221

@@ -3267,7 +3267,7 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key,
32673267

32683268
buf = transport_kmap_data_sg(cmd);
32693269
if (!buf) {
3270-
ret = TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE;
3270+
ret = TCM_INSUFFICIENT_REGISTRATION_RESOURCES;
32713271
goto out_put_pr_reg;
32723272
}
32733273
proto_ident = (buf[24] & 0x0f);
@@ -3466,7 +3466,7 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key,
34663466
if (core_scsi3_alloc_registration(cmd->se_dev, dest_node_acl,
34673467
dest_lun, dest_se_deve, dest_se_deve->mapped_lun,
34683468
iport_ptr, sa_res_key, 0, aptpl, 2, 1)) {
3469-
ret = TCM_INVALID_PARAMETER_LIST;
3469+
ret = TCM_INSUFFICIENT_REGISTRATION_RESOURCES;
34703470
goto out;
34713471
}
34723472
spin_lock(&dev->dev_reservation_lock);

drivers/target/target_core_transport.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3145,6 +3145,21 @@ static const struct sense_info sense_info_table[] = {
31453145
.key = NOT_READY,
31463146
.asc = 0x08, /* LOGICAL UNIT COMMUNICATION FAILURE */
31473147
},
3148+
[TCM_INSUFFICIENT_REGISTRATION_RESOURCES] = {
3149+
/*
3150+
* From spc4r22 section5.7.7,5.7.8
3151+
* If a PERSISTENT RESERVE OUT command with a REGISTER service action
3152+
* or a REGISTER AND IGNORE EXISTING KEY service action or
3153+
* REGISTER AND MOVE service actionis attempted,
3154+
* but there are insufficient device server resources to complete the
3155+
* operation, then the command shall be terminated with CHECK CONDITION
3156+
* status, with the sense key set to ILLEGAL REQUEST,and the additonal
3157+
* sense code set to INSUFFICIENT REGISTRATION RESOURCES.
3158+
*/
3159+
.key = ILLEGAL_REQUEST,
3160+
.asc = 0x55,
3161+
.ascq = 0x04, /* INSUFFICIENT REGISTRATION RESOURCES */
3162+
},
31483163
};
31493164

31503165
static int translate_sense_reason(struct se_cmd *cmd, sense_reason_t reason)

include/target/target_core_base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ enum tcm_sense_reason_table {
181181
TCM_UNSUPPORTED_TARGET_DESC_TYPE_CODE = R(0x1a),
182182
TCM_TOO_MANY_SEGMENT_DESCS = R(0x1b),
183183
TCM_UNSUPPORTED_SEGMENT_DESC_TYPE_CODE = R(0x1c),
184+
TCM_INSUFFICIENT_REGISTRATION_RESOURCES = R(0x1d),
184185
#undef R
185186
};
186187

0 commit comments

Comments
 (0)