Skip to content

Commit ead0ffc

Browse files
nastya-nizharadzemartinkpetersen
authored andcommitted
scsi: target: core: Change ASCQ for residual write
According to FCP-4 (9.4.2): If the command requested that data beyond the length specified by the FCP_DL field be transferred, then the device server shall set the FCP_RESID_OVER bit (see 9.5.8) to one in the FCP_RSP IU and: a) process the command normally except that data beyond the FCP_DL count shall not be requested or transferred; b) transfer no data and return CHECK CONDITION status with the sense key set to ILLEGAL REQUEST and the additional sense code set to INVALID FIELD IN COMMAND INFORMATION UNIT; or c) may transfer data and return CHECK CONDITION status with the sense key set to ABORTED COMMAND and the additional sense code set to INVALID FIELD IN COMMAND INFORMATION UNIT. TCM follows b) and transfers no data for residual writes but returns INVALID FIELD IN CDB instead of INVALID FIELD IN COMMAND INFORMATION UNIT. Change the ASCQ to INVALID FIELD IN COMMAND INFORMATION UNIT to meet the standard. Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Anastasia Kovaleva <[email protected]> Signed-off-by: Roman Bolshakov <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent cc0b6ad commit ead0ffc

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

drivers/target/target_core_transport.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1338,7 +1338,7 @@ target_cmd_size_check(struct se_cmd *cmd, unsigned int size)
13381338
if (cmd->se_cmd_flags & SCF_SCSI_DATA_CDB) {
13391339
pr_err_ratelimited("Rejecting underflow/overflow"
13401340
" for WRITE data CDB\n");
1341-
return TCM_INVALID_CDB_FIELD;
1341+
return TCM_INVALID_FIELD_IN_COMMAND_IU;
13421342
}
13431343
/*
13441344
* Some fabric drivers like iscsi-target still expect to
@@ -1877,6 +1877,7 @@ void transport_generic_request_failure(struct se_cmd *cmd,
18771877
case TCM_UNSUPPORTED_TARGET_DESC_TYPE_CODE:
18781878
case TCM_TOO_MANY_SEGMENT_DESCS:
18791879
case TCM_UNSUPPORTED_SEGMENT_DESC_TYPE_CODE:
1880+
case TCM_INVALID_FIELD_IN_COMMAND_IU:
18801881
break;
18811882
case TCM_OUT_OF_RESOURCES:
18821883
cmd->scsi_status = SAM_STAT_TASK_SET_FULL;
@@ -3203,6 +3204,11 @@ static const struct sense_detail sense_detail_table[] = {
32033204
.asc = 0x55,
32043205
.ascq = 0x04, /* INSUFFICIENT REGISTRATION RESOURCES */
32053206
},
3207+
[TCM_INVALID_FIELD_IN_COMMAND_IU] = {
3208+
.key = ILLEGAL_REQUEST,
3209+
.asc = 0x0e,
3210+
.ascq = 0x03, /* INVALID FIELD IN COMMAND INFORMATION UNIT */
3211+
},
32063212
};
32073213

32083214
/**

include/target/target_core_base.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ enum tcm_sense_reason_table {
187187
TCM_UNSUPPORTED_SEGMENT_DESC_TYPE_CODE = R(0x1c),
188188
TCM_INSUFFICIENT_REGISTRATION_RESOURCES = R(0x1d),
189189
TCM_LUN_BUSY = R(0x1e),
190+
TCM_INVALID_FIELD_IN_COMMAND_IU = R(0x1f),
190191
#undef R
191192
};
192193

0 commit comments

Comments
 (0)