From patchwork Wed Feb 15 00:25:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 9573127 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 76EAF6045F for ; Wed, 15 Feb 2017 00:27:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 682BF205D6 for ; Wed, 15 Feb 2017 00:27:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5AE5628438; Wed, 15 Feb 2017 00:27:31 +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 B418A205D6 for ; Wed, 15 Feb 2017 00:27:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751464AbdBOA13 (ORCPT ); Tue, 14 Feb 2017 19:27:29 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:10192 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751452AbdBOA10 (ORCPT ); Tue, 14 Feb 2017 19:27:26 -0500 X-IronPort-AV: E=Sophos;i="5.35,163,1483977600"; d="scan'208";a="81774852" Received: from unknown (HELO milsmgep15.sandisk.com) ([63.163.107.21]) by ob1.hgst.iphmx.com with ESMTP; 15 Feb 2017 08:43:11 +0800 Received: from MILHUBIP04.sdcorp.global.sandisk.com (Unknown_Domain [10.201.67.162]) (using TLS with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by (Symantec Messaging Gateway) with SMTP id 98.E4.57638.B20A3A85; Tue, 14 Feb 2017 16:26:19 -0800 (PST) Received: from milsmgip11.sandisk.com (10.177.8.100) by MILHUBIP04.sdcorp.global.sandisk.com (10.177.9.97) with Microsoft SMTP Server id 14.3.319.2; Tue, 14 Feb 2017 16:26:15 -0800 X-AuditID: 0ac94369-26dee9800001e126-6d-58a3a02b9617 Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id BA.7D.11415.720A3A85; Tue, 14 Feb 2017 16:26:15 -0800 (PST) From: Bart Van Assche To: "Nicholas A . Bellinger" CC: , Bart Van Assche , Himanshu Madhani , Quinn Tran Subject: [PATCH v6 10/33] tcm_qla2xxx: Let the target core look up the LUN of the aborted cmd Date: Tue, 14 Feb 2017 16:25:49 -0800 Message-ID: <20170215002612.14566-11-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170215002612.14566-1-bart.vanassche@sandisk.com> References: <20170215002612.14566-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrILMWRmVeSWpSXmKPExsXCddJ5ka72gsURBvefCllc2NPNaNG2+gyj xc/214wWrUvfMjmweMz4vYjF4/72I0wenzfJBTBHcdmkpOZklqUW6dslcGVM/nWPueCHXsWG xrVsDYyP1LoYOTkkBEwklm++ztLFyMUhJLCUSaJrRQsjhLODUaJ/YScjTNXkT+uZIBIbGSXe bTrDDJJgEzCS+PZ+JguILQJkr+5ZBlbELLCCUeJRyxSwbmGBWIkd/zcwgdgsAqoS866sY+1i 5ODgFXCQWNKRD7FAXmJX20VWEJsTKDxjx0kWkBIhAXuJR2esQUZKCPxjkbh/6Dw7SA2vgKDE yZlPwPYyC0hIHHzxAuweIQF1iZNL5jNNYBSahaRsFpKyBYxMqxjFcjNzinPTUwsMTfWKE/NS Mouz9ZLzczcxQgI6cwfj3SfehxgFOBiVeHhPyC6OEGJNLCuuzD3EKMHBrCTCy1YPFOJNSays Si3Kjy8qzUktPsQozcGiJM57TmZqhJBAemJJanZqakFqEUyWiYNTqoExeH/Hsyj+CzzWUwUO 1DT2OtWvvSJc67b+Xk35Ol37XXcFmD4v9PgdwRrM8T3k1O9TJ06yH1O8l/kyUVXXJGReo0rc yyylsx/s0vTsb/0In811xGWf/Hz1b7uWsv30W+YRuiOG40H6bW1R0fCDWz3uzTlxJW9pm7JU dp5zy4c9ItNmK1u/cOVQYinOSDTUYi4qTgQAbEKz4mQCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrIJMWRmVeSWpSXmKPExsXCtZGTTVd9weIIg9cXRSwO/mxjtLiwp5vR om31GUaLn+2vGS1al75lcmD1mPF7EYvH/e1HmDymrTnP5PF5k1wASxSXTUpqTmZZapG+XQJX xuRf95gLfuhVbGhcy9bA+Eiti5GTQ0LARGLyp/VMXYxcHEIC6xkldqyaxQiSYBMwkvj2fiYL iC0CZK/uWQZWxCywglFi3ZI3bCAJYYFYiR3/NzCB2CwCqhLzrqxjBbF5BRwk/v/+yQyxQV5i V9tFsDgnUHzGjpNAQzmAttlLPDpjPYGRewEjwypGsdzMnOLc9MwCQ0O94sS8lMzibL3k/NxN jJBAiNzB+HSi+SFGJg5OqQbGyvLypFWx12QWb5uaMZ3NRWjCrb6LW1YasjMK96scbbmolFnE LL9+59EE53vXvurVxilrreq9IHnw68WGxzkSTPMOiCg+/qTSa5E9geu15q7jZm1XP7w9rD/F 2lyHRasyqX7D1Id6H8+zaCcEBj7Wb5k74RCj9JJVnyXvz/dUz7tev5ZpW7ehEktxRqKhFnNR cSIAhPBxYbQBAAA= MIME-Version: 1.0 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 Use the new flag TARGET_SCF_IGNORE_TMR_LUN instead of letting the qla2xxx target driver look up the LUN of the command that has to be aborted. Signed-off-by: Bart Van Assche Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Cc: Himanshu Madhani Cc: Quinn Tran --- drivers/scsi/qla2xxx/qla_target.c | 66 +++++++++++++------------------------- drivers/scsi/qla2xxx/qla_target.h | 2 +- drivers/scsi/qla2xxx/tcm_qla2xxx.c | 8 +++-- 3 files changed, 30 insertions(+), 46 deletions(-) diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index 3ffa99a4daff..e8c7d0fc547b 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c @@ -1811,39 +1811,8 @@ static int __qlt_24xx_handle_abts(struct scsi_qla_host *vha, struct abts_recv_from_24xx *abts, struct fc_port *sess) { struct qla_hw_data *ha = vha->hw; - struct se_session *se_sess = sess->se_sess; struct qla_tgt_mgmt_cmd *mcmd; - struct se_cmd *se_cmd; - u32 lun = 0; int rc; - bool found_lun = false; - unsigned long flags; - - spin_lock_irqsave(&se_sess->sess_cmd_lock, flags); - list_for_each_entry(se_cmd, &se_sess->sess_cmd_list, se_cmd_list) { - struct qla_tgt_cmd *cmd = - container_of(se_cmd, struct qla_tgt_cmd, se_cmd); - if (se_cmd->tag == abts->exchange_addr_to_abort) { - lun = cmd->unpacked_lun; - found_lun = true; - break; - } - } - spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); - - /* cmd not in LIO lists, look in qla list */ - if (!found_lun) { - if (abort_cmd_for_tag(vha, abts->exchange_addr_to_abort)) { - /* send TASK_ABORT response immediately */ - qlt_24xx_send_abts_resp(vha, abts, FCP_TMF_CMPL, false); - return 0; - } else { - ql_dbg(ql_dbg_tgt_mgt, vha, 0xf081, - "unable to find cmd in driver or LIO for tag 0x%x\n", - abts->exchange_addr_to_abort); - return -ENOENT; - } - } ql_dbg(ql_dbg_tgt_mgt, vha, 0xf00f, "qla_target(%d): task abort (tag=%d)\n", @@ -1863,17 +1832,27 @@ static int __qlt_24xx_handle_abts(struct scsi_qla_host *vha, mcmd->reset_count = vha->hw->chip_reset; mcmd->tmr_func = QLA_TGT_ABTS; - rc = ha->tgt.tgt_ops->handle_tmr(mcmd, lun, mcmd->tmr_func, - abts->exchange_addr_to_abort); - if (rc != 0) { - ql_dbg(ql_dbg_tgt_mgt, vha, 0xf052, - "qla_target(%d): tgt_ops->handle_tmr()" - " failed: %d", vha->vp_idx, rc); - mempool_free(mcmd, qla_tgt_mgmt_cmd_mempool); - return -EFAULT; + rc = ha->tgt.tgt_ops->handle_tmr(mcmd, -1, mcmd->tmr_func, + abts->exchange_addr_to_abort, false); + if (rc == 0) + return 0; + + ql_dbg(ql_dbg_tgt_mgt, vha, 0xf052, + "qla_target(%d): tgt_ops->handle_tmr() failed: %d", + vha->vp_idx, rc); + mempool_free(mcmd, qla_tgt_mgmt_cmd_mempool); + + /* cmd not in LIO lists, look in qla list */ + if (abort_cmd_for_tag(vha, abts->exchange_addr_to_abort)) { + /* send TASK_ABORT response immediately */ + qlt_24xx_send_abts_resp(vha, abts, FCP_TMF_CMPL, false); + return 0; } - return 0; + ql_dbg(ql_dbg_tgt_mgt, vha, 0xf081, + "unable to find cmd in driver or LIO for tag 0x%x\n", + abts->exchange_addr_to_abort); + return -ENOENT; } /* @@ -4130,7 +4109,7 @@ static int qlt_issue_task_mgmt(struct fc_port *sess, u64 lun, break; } - res = ha->tgt.tgt_ops->handle_tmr(mcmd, lun, mcmd->tmr_func, 0); + res = ha->tgt.tgt_ops->handle_tmr(mcmd, lun, mcmd->tmr_func, 0, true); if (res != 0) { ql_dbg(ql_dbg_tgt_tmr, vha, 0x1000b, "qla_target(%d): tgt.tgt_ops->handle_tmr() failed: %d\n", @@ -4207,8 +4186,9 @@ static int __qlt_abort_task(struct scsi_qla_host *vha, mcmd->reset_count = vha->hw->chip_reset; mcmd->tmr_func = QLA_TGT_2G_ABORT_TASK; - rc = ha->tgt.tgt_ops->handle_tmr(mcmd, unpacked_lun, mcmd->tmr_func, - le16_to_cpu(iocb->u.isp2x.seq_id)); + rc = ha->tgt.tgt_ops->handle_tmr(mcmd, unpacked_lun, TMR_ABORT_TASK, + le16_to_cpu(iocb->u.isp2x.seq_id), + true); if (rc != 0) { ql_dbg(ql_dbg_tgt_mgt, vha, 0xf060, "qla_target(%d): tgt_ops->handle_tmr() failed: %d\n", diff --git a/drivers/scsi/qla2xxx/qla_target.h b/drivers/scsi/qla2xxx/qla_target.h index edf548621cb2..c3ea6d3e0c50 100644 --- a/drivers/scsi/qla2xxx/qla_target.h +++ b/drivers/scsi/qla2xxx/qla_target.h @@ -669,7 +669,7 @@ struct qla_tgt_func_tmpl { void (*handle_data)(struct qla_tgt_cmd *); void (*handle_dif_err)(struct qla_tgt_cmd *); int (*handle_tmr)(struct qla_tgt_mgmt_cmd *, uint32_t, uint16_t, - uint32_t); + uint32_t, bool); void (*free_cmd)(struct qla_tgt_cmd *); void (*free_session)(struct fc_port *); diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index a8d1da62e6bd..ba02bef1abf4 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c @@ -553,10 +553,12 @@ static void tcm_qla2xxx_handle_dif_err(struct qla_tgt_cmd *cmd) * Called from qla_target.c:qlt_issue_task_mgmt() */ static int tcm_qla2xxx_handle_tmr(struct qla_tgt_mgmt_cmd *mcmd, uint32_t lun, - uint16_t tmr_func, uint32_t tag) + uint16_t tmr_func, uint32_t tag, + bool use_lun) { struct fc_port *sess = mcmd->sess; struct se_cmd *se_cmd = &mcmd->se_cmd; + unsigned int flags = TARGET_SCF_ACK_KREF; int transl_tmr_func = 0; switch (tmr_func) { @@ -594,8 +596,10 @@ static int tcm_qla2xxx_handle_tmr(struct qla_tgt_mgmt_cmd *mcmd, uint32_t lun, return -ENOSYS; } + if (!use_lun) + flags |= TARGET_SCF_IGNORE_TMR_LUN; return target_submit_tmr(se_cmd, sess->se_sess, NULL, lun, mcmd, - transl_tmr_func, GFP_ATOMIC, tag, TARGET_SCF_ACK_KREF); + transl_tmr_func, GFP_ATOMIC, tag, flags); } static int tcm_qla2xxx_queue_data_in(struct se_cmd *se_cmd)