From patchwork Wed May 31 20:52:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 9758109 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BD30160390 for ; Wed, 31 May 2017 20:53:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AF52C284C7 for ; Wed, 31 May 2017 20:53:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3B0F284CF; Wed, 31 May 2017 20:53:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 02A8A284C7 for ; Wed, 31 May 2017 20:53:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751159AbdEaUxB (ORCPT ); Wed, 31 May 2017 16:53:01 -0400 Received: from mx1.redhat.com ([209.132.183.28]:42450 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751195AbdEaUxA (ORCPT ); Wed, 31 May 2017 16:53:00 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 24B43E711A; Wed, 31 May 2017 20:53:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 24B43E711A Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mchristi@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 24B43E711A Received: from rh2.redhat.com (ovpn-126-11.rdu2.redhat.com [10.10.126.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8343917F54; Wed, 31 May 2017 20:52:59 +0000 (UTC) From: Mike Christie To: target-devel@vger.kernel.org, nab@linux-iscsi.org Cc: Mike Christie Subject: [RFC PATCH 10/13] target: drop from_transport in transport_send_check_condition_and_sense Date: Wed, 31 May 2017 15:52:47 -0500 Message-Id: <1496263970-7632-11-git-send-email-mchristi@redhat.com> In-Reply-To: <1496263970-7632-1-git-send-email-mchristi@redhat.com> References: <1496263970-7632-1-git-send-email-mchristi@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 31 May 2017 20:53:00 +0000 (UTC) Sender: target-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: target-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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 *);