Commit ead0ffc9 authored by Anastasia Kovaleva's avatar Anastasia Kovaleva Committed by Martin K. Petersen

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/20201203082035.54566-4-a.kovaleva@yadro.comSigned-off-by: default avatarAnastasia Kovaleva <a.kovaleva@yadro.com>
Signed-off-by: default avatarRoman Bolshakov <r.bolshakov@yadro.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent cc0b6ad7
...@@ -1338,7 +1338,7 @@ target_cmd_size_check(struct se_cmd *cmd, unsigned int size) ...@@ -1338,7 +1338,7 @@ target_cmd_size_check(struct se_cmd *cmd, unsigned int size)
if (cmd->se_cmd_flags & SCF_SCSI_DATA_CDB) { if (cmd->se_cmd_flags & SCF_SCSI_DATA_CDB) {
pr_err_ratelimited("Rejecting underflow/overflow" pr_err_ratelimited("Rejecting underflow/overflow"
" for WRITE data CDB\n"); " for WRITE data CDB\n");
return TCM_INVALID_CDB_FIELD; return TCM_INVALID_FIELD_IN_COMMAND_IU;
} }
/* /*
* Some fabric drivers like iscsi-target still expect to * Some fabric drivers like iscsi-target still expect to
...@@ -1877,6 +1877,7 @@ void transport_generic_request_failure(struct se_cmd *cmd, ...@@ -1877,6 +1877,7 @@ void transport_generic_request_failure(struct se_cmd *cmd,
case TCM_UNSUPPORTED_TARGET_DESC_TYPE_CODE: case TCM_UNSUPPORTED_TARGET_DESC_TYPE_CODE:
case TCM_TOO_MANY_SEGMENT_DESCS: case TCM_TOO_MANY_SEGMENT_DESCS:
case TCM_UNSUPPORTED_SEGMENT_DESC_TYPE_CODE: case TCM_UNSUPPORTED_SEGMENT_DESC_TYPE_CODE:
case TCM_INVALID_FIELD_IN_COMMAND_IU:
break; break;
case TCM_OUT_OF_RESOURCES: case TCM_OUT_OF_RESOURCES:
cmd->scsi_status = SAM_STAT_TASK_SET_FULL; cmd->scsi_status = SAM_STAT_TASK_SET_FULL;
...@@ -3203,6 +3204,11 @@ static const struct sense_detail sense_detail_table[] = { ...@@ -3203,6 +3204,11 @@ static const struct sense_detail sense_detail_table[] = {
.asc = 0x55, .asc = 0x55,
.ascq = 0x04, /* INSUFFICIENT REGISTRATION RESOURCES */ .ascq = 0x04, /* INSUFFICIENT REGISTRATION RESOURCES */
}, },
[TCM_INVALID_FIELD_IN_COMMAND_IU] = {
.key = ILLEGAL_REQUEST,
.asc = 0x0e,
.ascq = 0x03, /* INVALID FIELD IN COMMAND INFORMATION UNIT */
},
}; };
/** /**
......
...@@ -187,6 +187,7 @@ enum tcm_sense_reason_table { ...@@ -187,6 +187,7 @@ enum tcm_sense_reason_table {
TCM_UNSUPPORTED_SEGMENT_DESC_TYPE_CODE = R(0x1c), TCM_UNSUPPORTED_SEGMENT_DESC_TYPE_CODE = R(0x1c),
TCM_INSUFFICIENT_REGISTRATION_RESOURCES = R(0x1d), TCM_INSUFFICIENT_REGISTRATION_RESOURCES = R(0x1d),
TCM_LUN_BUSY = R(0x1e), TCM_LUN_BUSY = R(0x1e),
TCM_INVALID_FIELD_IN_COMMAND_IU = R(0x1f),
#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