This patch attempts to simplify the SENSE flags, by merging the emulated and transport ones. For the fabric drivers, it looks like it does not matter if SCF_TRANSPORT_TASK_SENSE or if SCF_EMULATED_TASK_SENSE is set. If either is set, they will want to handle/send the sense info. For the core code like target_complete_cmd we will not have a case where this is called and there is both emulated and transport sense. The iscsi drivers do have a check for only SCF_TRANSPORT_TASK_SENSE, but it seems queue_data_will never be called with emulated sense so having a common flag would be ok. If BIDI is ever supported in iscsi checking for both cases would be needed, so a common flag would again be ok. Signed-off-by: Mike Christie <mchristi@xxxxxxxxxx> --- drivers/infiniband/ulp/isert/ib_isert.c | 3 +-- drivers/infiniband/ulp/srpt/ib_srpt.c | 3 +-- drivers/target/iscsi/cxgbit/cxgbit_target.c | 2 +- drivers/target/iscsi/iscsi_target.c | 8 +++----- drivers/target/loopback/tcm_loop.c | 5 +---- drivers/target/target_core_transport.c | 12 ++++++------ drivers/xen/xen-scsiback.c | 4 +--- include/target/target_core_base.h | 3 +-- 8 files changed, 15 insertions(+), 25 deletions(-) diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c index fcbed35..8e271e5 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c @@ -1853,8 +1853,7 @@ * Attach SENSE DATA payload to iSCSI Response PDU */ if (cmd->se_cmd.sense_buffer && - ((cmd->se_cmd.se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) || - (cmd->se_cmd.se_cmd_flags & SCF_EMULATED_TASK_SENSE))) { + (cmd->se_cmd.se_cmd_flags & SCF_TASK_SENSE)) { struct isert_device *device = isert_conn->device; struct ib_device *ib_dev = device->ib_device; struct ib_sge *tx_dsg = &isert_cmd->tx_desc.tx_sg[1]; diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index 1ced073..5197efb 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -2389,8 +2389,7 @@ static int srpt_queue_status(struct se_cmd *cmd) ioctx = container_of(cmd, struct srpt_send_ioctx, cmd); BUG_ON(ioctx->sense_data != cmd->sense_buffer); - if (cmd->se_cmd_flags & - (SCF_TRANSPORT_TASK_SENSE | SCF_EMULATED_TASK_SENSE)) + if (cmd->se_cmd_flags & SCF_TASK_SENSE) WARN_ON(cmd->scsi_status != SAM_STAT_CHECK_CONDITION); ioctx->queue_status_only = true; srpt_queue_response(cmd); diff --git a/drivers/target/iscsi/cxgbit/cxgbit_target.c b/drivers/target/iscsi/cxgbit/cxgbit_target.c index bdcc8b4..8c31839 100644 --- a/drivers/target/iscsi/cxgbit/cxgbit_target.c +++ b/drivers/target/iscsi/cxgbit/cxgbit_target.c @@ -422,7 +422,7 @@ static int cxgbit_queue_skb(struct cxgbit_sock *csk, struct sk_buff *skb) u32 mrdsl = conn->conn_ops->MaxRecvDataSegmentLength; u32 num_pdu, plen, tx_data = 0; bool task_sense = !!(cmd->se_cmd.se_cmd_flags & - SCF_TRANSPORT_TASK_SENSE); + SCF_TASK_SENSE); bool set_statsn = false; int ret = -1; diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 26a9bcd..30aceae 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -2821,7 +2821,7 @@ static int iscsit_send_datain(struct iscsi_cmd *cmd, struct iscsi_conn *conn) * and Sense Data. */ if ((datain.flags & ISCSI_FLAG_DATA_STATUS) && - (cmd->se_cmd.se_cmd_flags & SCF_TRANSPORT_TASK_SENSE)) + (cmd->se_cmd.se_cmd_flags & SCF_TASK_SENSE)) datain.flags &= ~ISCSI_FLAG_DATA_STATUS; else { if ((dr->dr_complete == DATAIN_COMPLETE_NORMAL) || @@ -2841,8 +2841,7 @@ static int iscsit_send_datain(struct iscsi_cmd *cmd, struct iscsi_conn *conn) return ret; if (dr->dr_complete) { - eodr = (cmd->se_cmd.se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) ? - 2 : 1; + eodr = (cmd->se_cmd.se_cmd_flags & SCF_TASK_SENSE) ? 2 : 1; iscsit_free_datain_req(cmd, dr); } @@ -3213,8 +3212,7 @@ static int iscsit_send_response(struct iscsi_cmd *cmd, struct iscsi_conn *conn) * Attach SENSE DATA payload to iSCSI Response PDU */ if (cmd->se_cmd.sense_buffer && - ((cmd->se_cmd.se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) || - (cmd->se_cmd.se_cmd_flags & SCF_EMULATED_TASK_SENSE))) { + (cmd->se_cmd.se_cmd_flags & SCF_TASK_SENSE)) { put_unaligned_be16(cmd->se_cmd.scsi_sense_length, cmd->sense_buffer); cmd->se_cmd.scsi_sense_length += sizeof (__be16); diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c index 5091b31..599dfe4 100644 --- a/drivers/target/loopback/tcm_loop.c +++ b/drivers/target/loopback/tcm_loop.c @@ -648,10 +648,7 @@ static int tcm_loop_queue_status(struct se_cmd *se_cmd) pr_debug("tcm_loop_queue_status() called for scsi_cmnd: %p" " cdb: 0x%02x\n", sc, sc->cmnd[0]); - if (se_cmd->sense_buffer && - ((se_cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) || - (se_cmd->se_cmd_flags & SCF_EMULATED_TASK_SENSE))) { - + if (se_cmd->sense_buffer && (se_cmd->se_cmd_flags & SCF_TASK_SENSE)) { memcpy(sc->sense_buffer, se_cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE); sc->result = SAM_STAT_CHECK_CONDITION; diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 09b6e96..62937cf 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -713,7 +713,7 @@ void transport_copy_sense_to_cmd(struct se_cmd *cmd, unsigned char *sense) return; } - cmd->se_cmd_flags |= SCF_TRANSPORT_TASK_SENSE; + cmd->se_cmd_flags |= SCF_TASK_SENSE; memcpy(cmd_sense_buf, sense, cmd->scsi_sense_length); spin_unlock_irqrestore(&cmd->t_state_lock, flags); } @@ -729,7 +729,7 @@ void target_complete_cmd(struct se_cmd *cmd, u8 scsi_status) spin_lock_irqsave(&cmd->t_state_lock, flags); switch (cmd->scsi_status) { case SAM_STAT_CHECK_CONDITION: - if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) + if (cmd->se_cmd_flags & SCF_TASK_SENSE) success = 1; else success = 0; @@ -2023,14 +2023,14 @@ static void transport_complete_qf(struct se_cmd *cmd) if (cmd->scsi_status) goto queue_status; - cmd->se_cmd_flags |= SCF_EMULATED_TASK_SENSE; + cmd->se_cmd_flags |= SCF_TASK_SENSE; cmd->scsi_status = SAM_STAT_CHECK_CONDITION; cmd->scsi_sense_length = TRANSPORT_SENSE_BUFFER; translate_sense_reason(cmd, TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE); goto queue_status; } - if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) + if (cmd->se_cmd_flags & SCF_TASK_SENSE) goto queue_status; switch (cmd->data_direction) { @@ -2142,7 +2142,7 @@ static void target_complete_ok_work(struct work_struct *work) * Check if we need to send a sense buffer from * the struct se_cmd in question. */ - if (cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) { + if (cmd->se_cmd_flags & SCF_TASK_SENSE) { WARN_ON(!cmd->scsi_status); ret = transport_send_check_condition_and_sense( cmd, 0, 1); @@ -3053,7 +3053,7 @@ static int translate_sense_reason(struct se_cmd *cmd, sense_reason_t reason) if (!from_transport) { int rc; - cmd->se_cmd_flags |= SCF_EMULATED_TASK_SENSE; + cmd->se_cmd_flags |= SCF_TASK_SENSE; cmd->scsi_status = SAM_STAT_CHECK_CONDITION; cmd->scsi_sense_length = TRANSPORT_SENSE_BUFFER; rc = translate_sense_reason(cmd, reason); diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c index d6950e0..286ac1b 100644 --- a/drivers/xen/xen-scsiback.c +++ b/drivers/xen/xen-scsiback.c @@ -1441,9 +1441,7 @@ static int scsiback_queue_status(struct se_cmd *se_cmd) struct vscsibk_pend *pending_req = container_of(se_cmd, struct vscsibk_pend, se_cmd); - if (se_cmd->sense_buffer && - ((se_cmd->se_cmd_flags & SCF_TRANSPORT_TASK_SENSE) || - (se_cmd->se_cmd_flags & SCF_EMULATED_TASK_SENSE))) + if (se_cmd->sense_buffer && (se_cmd->se_cmd_flags & SCF_TASK_SENSE)) pending_req->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION; else diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index 0c1dce2..49a5d25 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -123,8 +123,7 @@ enum transport_state_table { /* Used for struct se_cmd->se_cmd_flags */ enum se_cmd_flags_table { SCF_SUPPORTED_SAM_OPCODE = 0x00000001, - SCF_TRANSPORT_TASK_SENSE = 0x00000002, - SCF_EMULATED_TASK_SENSE = 0x00000004, + SCF_TASK_SENSE = 0x00000002, SCF_SCSI_DATA_CDB = 0x00000008, SCF_SCSI_TMR_CDB = 0x00000010, SCF_FUA = 0x00000080, -- 1.8.3.1 -- To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html