No need to pass in from_transport to transport_send_check_condition_and_sense. If it is being called from the target_complete_ok_work path and modules like pscsi/tcmu have setup sense we can detect it by checking if SCF_TASK_SENSE is already set. Signed-off-by: Mike Christie <mchristi@xxxxxxxxxx> --- drivers/infiniband/ulp/srpt/ib_srpt.c | 2 +- drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c | 2 +- drivers/target/iscsi/iscsi_target.c | 2 +- drivers/target/iscsi/iscsi_target_erl0.c | 4 ++-- drivers/target/iscsi/iscsi_target_erl1.c | 2 +- drivers/target/iscsi/iscsi_target_util.c | 6 +++--- drivers/target/target_core_transport.c | 16 +++++++--------- drivers/vhost/scsi.c | 2 +- drivers/xen/xen-scsiback.c | 2 +- include/target/target_core_fabric.h | 2 +- 10 files changed, 19 insertions(+), 21 deletions(-) diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index 5197efb..298dcf2 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c @@ -1454,7 +1454,7 @@ static void srpt_handle_tsk_mgmt(struct srpt_rdma_ch *ch, } return; fail: - transport_send_check_condition_and_sense(cmd, 0, 0); // XXX: + transport_send_check_condition_and_sense(cmd, 0); // XXX: } /** diff --git a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c index abf6026..38173eb 100644 --- a/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c +++ b/drivers/scsi/ibmvscsi_tgt/ibmvscsi_tgt.c @@ -2703,7 +2703,7 @@ static void ibmvscsis_parse_task(struct scsi_info *vscsi, } if (rc) - transport_send_check_condition_and_sense(&cmd->se_cmd, 0, 0); + transport_send_check_condition_and_sense(&cmd->se_cmd, 0); } static void ibmvscsis_scheduler(struct work_struct *work) diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c index 30aceae..de20bfc 100644 --- a/drivers/target/iscsi/iscsi_target.c +++ b/drivers/target/iscsi/iscsi_target.c @@ -1466,7 +1466,7 @@ static void iscsit_do_crypto_hash_buf( pr_err("Received unexpected unsolicited data" " while InitialR2T=Yes, protocol error.\n"); transport_send_check_condition_and_sense(&cmd->se_cmd, - TCM_UNEXPECTED_UNSOLICITED_DATA, 0); + TCM_UNEXPECTED_UNSOLICITED_DATA); return -1; } /* diff --git a/drivers/target/iscsi/iscsi_target_erl0.c b/drivers/target/iscsi/iscsi_target_erl0.c index 9a96e17..8cef8bb 100644 --- a/drivers/target/iscsi/iscsi_target_erl0.c +++ b/drivers/target/iscsi/iscsi_target_erl0.c @@ -163,7 +163,7 @@ static int iscsit_dataout_check_unsolicited_sequence( " for this Unsolicited DataOut Burst.\n", first_burst_len, conn->sess->sess_ops->FirstBurstLength); transport_send_check_condition_and_sense(&cmd->se_cmd, - TCM_INCORRECT_AMOUNT_OF_DATA, 0); + TCM_INCORRECT_AMOUNT_OF_DATA); return DATAOUT_CANNOT_RECOVER; } @@ -188,7 +188,7 @@ static int iscsit_dataout_check_unsolicited_sequence( conn->sess->sess_ops->FirstBurstLength, cmd->se_cmd.data_length); transport_send_check_condition_and_sense(&cmd->se_cmd, - TCM_INCORRECT_AMOUNT_OF_DATA, 0); + TCM_INCORRECT_AMOUNT_OF_DATA); return DATAOUT_CANNOT_RECOVER; } } else { diff --git a/drivers/target/iscsi/iscsi_target_erl1.c b/drivers/target/iscsi/iscsi_target_erl1.c index fe9b7f1..8f3bdbb 100644 --- a/drivers/target/iscsi/iscsi_target_erl1.c +++ b/drivers/target/iscsi/iscsi_target_erl1.c @@ -959,7 +959,7 @@ int iscsit_execute_cmd(struct iscsi_cmd *cmd, int ooo) * exception */ return transport_send_check_condition_and_sense(se_cmd, - cmd->sense_reason, 0); + cmd->sense_reason); } /* * Special case for delayed CmdSN with Immediate diff --git a/drivers/target/iscsi/iscsi_target_util.c b/drivers/target/iscsi/iscsi_target_util.c index 7d3e2fc..ab87528 100644 --- a/drivers/target/iscsi/iscsi_target_util.c +++ b/drivers/target/iscsi/iscsi_target_util.c @@ -338,7 +338,7 @@ int iscsit_check_unsolicited_dataout(struct iscsi_cmd *cmd, unsigned char *buf) pr_err("Received unexpected unsolicited data" " while InitialR2T=Yes, protocol error.\n"); transport_send_check_condition_and_sense(se_cmd, - TCM_UNEXPECTED_UNSOLICITED_DATA, 0); + TCM_UNEXPECTED_UNSOLICITED_DATA); return -1; } @@ -349,7 +349,7 @@ int iscsit_check_unsolicited_dataout(struct iscsi_cmd *cmd, unsigned char *buf) (cmd->first_burst_len + payload_length), conn->sess->sess_ops->FirstBurstLength); transport_send_check_condition_and_sense(se_cmd, - TCM_INCORRECT_AMOUNT_OF_DATA, 0); + TCM_INCORRECT_AMOUNT_OF_DATA); return -1; } @@ -365,7 +365,7 @@ int iscsit_check_unsolicited_dataout(struct iscsi_cmd *cmd, unsigned char *buf) (cmd->first_burst_len + payload_length), conn->sess->sess_ops->FirstBurstLength, cmd->se_cmd.data_length); transport_send_check_condition_and_sense(se_cmd, - TCM_INCORRECT_AMOUNT_OF_DATA, 0); + TCM_INCORRECT_AMOUNT_OF_DATA); return -1; } return 0; diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index ad2132e..8f6a058 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -1496,7 +1496,7 @@ int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess */ rc = transport_lookup_cmd_lun(se_cmd, unpacked_lun); if (rc) { - transport_send_check_condition_and_sense(se_cmd, rc, 0); + transport_send_check_condition_and_sense(se_cmd, rc); target_put_sess_cmd(se_cmd); return 0; } @@ -1763,7 +1763,7 @@ void transport_generic_request_failure(struct se_cmd *cmd, break; } - ret = transport_send_check_condition_and_sense(cmd, sense_reason, 0); + ret = transport_send_check_condition_and_sense(cmd, sense_reason); if (ret) goto queue_full; @@ -2144,8 +2144,7 @@ static void target_complete_ok_work(struct work_struct *work) */ if (cmd->se_cmd_flags & SCF_TASK_SENSE) { WARN_ON(!cmd->scsi_status); - ret = transport_send_check_condition_and_sense( - cmd, 0, 1); + ret = transport_send_check_condition_and_sense(cmd, 0); if (ret) goto queue_full; @@ -2170,8 +2169,7 @@ static void target_complete_ok_work(struct work_struct *work) return; } else if (rc) { - ret = transport_send_check_condition_and_sense(cmd, - rc, 0); + ret = transport_send_check_condition_and_sense(cmd, rc); if (ret) goto queue_full; @@ -2196,7 +2194,7 @@ static void target_complete_ok_work(struct work_struct *work) */ if (target_read_prot_action(cmd)) { ret = transport_send_check_condition_and_sense(cmd, - cmd->pi_err, 0); + cmd->pi_err); if (ret) goto queue_full; @@ -3047,7 +3045,7 @@ int transport_setup_sense(struct se_cmd *cmd, sense_reason_t reason) int transport_send_check_condition_and_sense(struct se_cmd *cmd, - sense_reason_t reason, int from_transport) + sense_reason_t reason) { unsigned long flags; @@ -3059,7 +3057,7 @@ int transport_setup_sense(struct se_cmd *cmd, sense_reason_t reason) cmd->se_cmd_flags |= SCF_SENT_CHECK_CONDITION; spin_unlock_irqrestore(&cmd->t_state_lock, flags); - if (!from_transport) { + if (!(cmd->se_cmd_flags & SCF_TASK_SENSE)) { int rc; rc = transport_setup_sense(cmd, reason); diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index fd6c8b6..2039ea9 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c @@ -809,7 +809,7 @@ static void vhost_scsi_submission_work(struct work_struct *work) cmd->tvc_prot_sgl_count); if (rc < 0) { transport_send_check_condition_and_sense(se_cmd, - TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0); + TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE); transport_generic_free_cmd(se_cmd, 0); } } diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c index 286ac1b..66a814a 100644 --- a/drivers/xen/xen-scsiback.c +++ b/drivers/xen/xen-scsiback.c @@ -412,7 +412,7 @@ static void scsiback_cmd_exec(struct vscsibk_pend *pending_req) NULL, 0, NULL, 0); if (rc < 0) { transport_send_check_condition_and_sense(se_cmd, - TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE, 0); + TCM_LOGICAL_UNIT_COMMUNICATION_FAILURE); transport_generic_free_cmd(se_cmd, 0); } } diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h index f0153dc..668b19e 100644 --- a/include/target/target_core_fabric.h +++ b/include/target/target_core_fabric.h @@ -156,7 +156,7 @@ int target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess, int transport_check_aborted_status(struct se_cmd *, int); int transport_setup_sense(struct se_cmd *, sense_reason_t); int transport_send_check_condition_and_sense(struct se_cmd *, - sense_reason_t, int); + sense_reason_t); int target_get_sess_cmd(struct se_cmd *, bool); int target_put_sess_cmd(struct se_cmd *); void target_sess_cmd_list_set_waiting(struct se_session *); -- 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