diff --git a/scst/include/scst.h b/scst/include/scst.h index af3afebc0..f8393a340 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -1951,6 +1951,9 @@ struct scst_cmd { /* Set if cmd is queued as hw pending */ unsigned int cmd_hw_pending:1; + /* Set if cmd has NACA bit set in CDB */ + unsigned int cmd_naca:1; + /* * Set if the target driver wants to alloc data buffers on its own. * In this case tgt_alloc_data_buf() must be provided in the target @@ -2030,6 +2033,9 @@ struct scst_cmd { /* Set if scst_cmd_set_write_not_received_data_len() was called */ unsigned int write_not_received_set:1; + /* Set if cmd has LINK bit set in CDB */ + unsigned int cmd_linked:1; + /**************************************************************/ /* cmd's async flags */ diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 5f065b067..fb9210385 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -6825,7 +6825,6 @@ int scst_get_cdb_info(struct scst_cmd *cmd) int dev_type = cmd->dev->type; int i, res = 0; uint8_t op; - uint8_t control; const struct scst_sdbops *ptr = NULL; TRACE_ENTRY(); @@ -6871,7 +6870,8 @@ int scst_get_cdb_info(struct scst_cmd *cmd) } cmd->cdb_len = SCST_GET_CDB_LEN(op); - control = cmd->cdb[cmd->cdb_len - 1]; + cmd->cmd_naca = (cmd->cdb[cmd->cdb_len - 1] & CONTROL_BYTE_NACA_BIT); + cmd->cmd_linked = (cmd->cdb[cmd->cdb_len - 1] & CONTROL_BYTE_LINK_BIT); cmd->op_name = ptr->info_op_name; cmd->data_direction = ptr->info_data_direction; cmd->op_flags = ptr->info_op_flags | SCST_INFO_VALID; @@ -6881,24 +6881,6 @@ int scst_get_cdb_info(struct scst_cmd *cmd) cmd->len_len = ptr->info_len_len; res = (*ptr->get_cdb_info)(cmd, ptr); - if (unlikely(control & CONTROL_BYTE_NACA_BIT)) { - PRINT_ERROR("NACA bit in control byte CDB is not supported " - "(opcode 0x%02x)", cmd->cdb[0]); - scst_set_cmd_error(cmd, - SCST_LOAD_SENSE(scst_sense_invalid_message)); - res = 1; /* command invalid */ - goto out; - } - - if (unlikely(control & CONTROL_BYTE_LINK_BIT)) { - PRINT_ERROR("Linked commands are not supported " - "(opcode 0x%02x)", cmd->cdb[0]); - scst_set_invalid_field_in_cdb(cmd, cmd->cdb_len-1, - SCST_INVAL_FIELD_BIT_OFFS_VALID | 0); - res = 1; /* command invalid */ - goto out; - } - out: TRACE_EXIT_RES(res); return res; diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 793aa3b88..bf8e641f6 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -744,6 +744,22 @@ static int scst_parse_cmd(struct scst_cmd *cmd) cmd->op_flags &= ~SCST_UNKNOWN_LENGTH; } + if (unlikely(cmd->cmd_naca)) { + PRINT_ERROR("NACA bit in control byte CDB is not supported " + "(opcode 0x%02x)", cmd->cdb[0]); + scst_set_cmd_error(cmd, + SCST_LOAD_SENSE(scst_sense_invalid_message)); + goto out_done; + } + + if (unlikely(cmd->cmd_linked)) { + PRINT_ERROR("Linked commands are not supported " + "(opcode 0x%02x)", cmd->cdb[0]); + scst_set_invalid_field_in_cdb(cmd, cmd->cdb_len-1, + SCST_INVAL_FIELD_BIT_OFFS_VALID | 0); + goto out_done; + } + if (cmd->dh_data_buf_alloced && unlikely((orig_bufflen > cmd->bufflen))) { PRINT_ERROR("Dev handler supplied data buffer (size %d), "