From patchwork Wed May 31 20:52:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Christie X-Patchwork-Id: 9758105 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 AC0AB603F7 for ; Wed, 31 May 2017 20:53:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9EB85284AF for ; Wed, 31 May 2017 20:53:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93375284C8; Wed, 31 May 2017 20:53:00 +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 E66D7284BB for ; Wed, 31 May 2017 20:52:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751194AbdEaUw7 (ORCPT ); Wed, 31 May 2017 16:52:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:47984 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751159AbdEaUw6 (ORCPT ); Wed, 31 May 2017 16:52:58 -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 C3A2F153; Wed, 31 May 2017 20:52:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com C3A2F153 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mchristi@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com C3A2F153 Received: from rh2.redhat.com (ovpn-126-11.rdu2.redhat.com [10.10.126.11]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E41018EF8; Wed, 31 May 2017 20:52:57 +0000 (UTC) From: Mike Christie To: target-devel@vger.kernel.org, nab@linux-iscsi.org Cc: Mike Christie Subject: [RFC PATCH 07/13] target: merge SCF SENSE flags Date: Wed, 31 May 2017 15:52:44 -0500 Message-Id: <1496263970-7632-8-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.25]); Wed, 31 May 2017 20:52:57 +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 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 --- 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,