Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751531AbdFGBN1 (ORCPT ); Tue, 6 Jun 2017 21:13:27 -0400 Received: from mail-by2nam01on0076.outbound.protection.outlook.com ([104.47.34.76]:14144 "EHLO NAM01-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751436AbdFGBNZ (ORCPT ); Tue, 6 Jun 2017 21:13:25 -0400 From: "Tran, Quinn" To: "Nicholas A. Bellinger" , target-devel CC: linux-scsi , lkml , "Madhani, Himanshu" , Mike Christie , Hannes Reinecke , Christoph Hellwig Subject: Re: [PATCH 2/3] target: Add TARGET_SCF_LOOKUP_LUN_FROM_TAG support for ABORT_TASK Thread-Topic: [PATCH 2/3] target: Add TARGET_SCF_LOOKUP_LUN_FROM_TAG support for ABORT_TASK Thread-Index: AQHS3LXB+s6LFCTUPUmVm1JEHr4zT6IYJ7wA Date: Wed, 7 Jun 2017 01:13:21 +0000 Message-ID: <6591E707-EFE0-407E-A80F-FCFFBE572192@cavium.com> References: <1496527808-28789-1-git-send-email-nab@linux-iscsi.org> <1496527808-28789-3-git-send-email-nab@linux-iscsi.org> In-Reply-To: <1496527808-28789-3-git-send-email-nab@linux-iscsi.org> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: linux-iscsi.org; dkim=none (message not signed) header.d=none;linux-iscsi.org; dmarc=none action=none header.from=cavium.com; x-originating-ip: [198.186.0.2] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MWHPR07MB3454;7:TFrHRmXRKaRnqvpmCZrjwBbYwbUKBMzdfWVV/fgivYMtQWgn5yxiLStyMUX44yUEdnoDFgUXPAl9YmtTGh9+fdF2t9hhjsxUbla6vj9qFbBmfR82n8NMCLDimdvBCn4O2JYJJOEsquVwWkcFefp9kshW0QJldVx/IhbSnnKSgN2sXSGyYysYT4h5vCHuuHWH+8bEMdzyfTlBPhW0PiuW5telYHfC1sMxHnHxHL06fMVS96HWQcVX6UNF6yTNHoxd0wEHoUeNsp6B3lcins2J3OcMw/VSqAPz9PhMO/pedDP+HEHr4/arX/ZYfXea1ZYS2uMQjyF7KVN+4B5xNgpBwg== x-forefront-antispam-report: SFV:SKI;SCL:-1SFV:NSPM;SFS:(10009020)(6009001)(39450400003)(39840400002)(39850400002)(39410400002)(39400400002)(377454003)(13464003)(4326008)(81166006)(3660700001)(53546009)(3280700002)(6506006)(122556002)(2900100001)(25786009)(77096006)(33656002)(3846002)(6486002)(6116002)(5660300001)(305945005)(36756003)(7736002)(6436002)(38730400002)(72206003)(189998001)(478600001)(2906002)(54906002)(66066001)(6246003)(6512007)(99286003)(53936002)(86362001)(14454004)(8676002)(229853002)(83716003)(82746002)(76176999)(54356999)(8936002)(2950100002)(50986999);DIR:OUT;SFP:1101;SCL:1;SRVR:MWHPR07MB3454;H:SN1PR07MB2413.namprd07.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; x-ms-traffictypediagnostic: MWHPR07MB3454: x-ms-office365-filtering-correlation-id: 05266229-de53-47c1-3441-08d4ad426364 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254075)(201703131423075)(201703031133081);SRVR:MWHPR07MB3454; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(9452136761055); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(100000703101)(100105400095)(10201501046)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123564025)(20161123555025)(20161123562025)(20161123560025)(20161123558100)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:MWHPR07MB3454;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:MWHPR07MB3454; x-forefront-prvs: 03319F6FEF spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" Content-ID: <886B4AE3233908429CBBEBC74E201B44@namprd07.prod.outlook.com> MIME-Version: 1.0 X-OriginatorOrg: cavium.com X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Jun 2017 01:13:21.2019 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR07MB3454 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id v571DWXr025580 Content-Length: 4805 Lines: 131 Looks Good. Regards, Quinn Tran -----Original Message----- From: Nicholas Bellinger Date: Saturday, June 3, 2017 at 3:10 PM To: target-devel Cc: linux-scsi , lkml , Nicholas Bellinger , "Madhani, Himanshu" , "Tran, Quinn" , Mike Christie , Hannes Reinecke , Christoph Hellwig Subject: [PATCH 2/3] target: Add TARGET_SCF_LOOKUP_LUN_FROM_TAG support for ABORT_TASK From: Nicholas Bellinger This patch introduces support in target_submit_tmr() for locating a unpacked_lun from an existing se_cmd->tag during ABORT_TASK. When TARGET_SCF_LOOKUP_LUN_FROM_TAG is set, target_submit_tmr() will do the extra lookup via target_lookup_lun_from_tag() and subsequently invoke transport_lookup_tmr_lun() so a proper percpu se_lun->lun_ref is taken before workqueue dispatch into se_device->tmr_wq happens. Aside from the extra target_lookup_lun_from_tag(), the existing code-path remains unchanged. Cc: Himanshu Madhani Cc: Quinn Tran Cc: Mike Christie Cc: Hannes Reinecke Cc: Christoph Hellwig Signed-off-by: Nicholas Bellinger --- drivers/target/target_core_transport.c | 53 ++++++++++++++++++++++++++++------ include/target/target_core_base.h | 3 +- 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 83bfc97..dbb8101 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -1592,6 +1592,29 @@ static void target_complete_tmr_failure(struct work_struct *work) transport_cmd_check_stop_to_fabric(se_cmd); } +static bool target_lookup_lun_from_tag(struct se_session *se_sess, u64 tag, + u64 *unpacked_lun) +{ + struct se_cmd *se_cmd; + unsigned long flags; + bool ret = false; + + spin_lock_irqsave(&se_sess->sess_cmd_lock, flags); + list_for_each_entry(se_cmd, &se_sess->sess_cmd_list, se_cmd_list) { + if (se_cmd->se_cmd_flags & SCF_SCSI_TMR_CDB) + continue; + + if (se_cmd->tag == tag) { + *unpacked_lun = se_cmd->orig_fe_lun; + ret = true; + break; + } + } + spin_unlock_irqrestore(&se_sess->sess_cmd_lock, flags); + + return ret; +} + /** * target_submit_tmr - lookup unpacked lun and submit uninitialized se_cmd * for TMR CDBs @@ -1639,19 +1662,31 @@ int target_submit_tmr(struct se_cmd *se_cmd, struct se_session *se_sess, core_tmr_release_req(se_cmd->se_tmr_req); return ret; } + /* + * If this is ABORT_TASK with no explicit fabric provided LUN, + * go ahead and search active session tags for a match to figure + * out unpacked_lun for the original se_cmd. + */ + if (tm_type == TMR_ABORT_TASK && (flags & TARGET_SCF_LOOKUP_LUN_FROM_TAG)) { + if (!target_lookup_lun_from_tag(se_sess, tag, &unpacked_lun)) + goto failure; + } ret = transport_lookup_tmr_lun(se_cmd, unpacked_lun); - if (ret) { - /* - * For callback during failure handling, push this work off - * to process context with TMR_LUN_DOES_NOT_EXIST status. - */ - INIT_WORK(&se_cmd->work, target_complete_tmr_failure); - schedule_work(&se_cmd->work); - return 0; - } + if (ret) + goto failure; + transport_generic_handle_tmr(se_cmd); return 0; + + /* + * For callback during failure handling, push this work off + * to process context with TMR_LUN_DOES_NOT_EXIST status. + */ +failure: + INIT_WORK(&se_cmd->work, target_complete_tmr_failure); + schedule_work(&se_cmd->work); + return 0; } EXPORT_SYMBOL(target_submit_tmr); diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index db2c7b3..a3af69f 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -188,7 +188,8 @@ enum target_sc_flags_table { TARGET_SCF_BIDI_OP = 0x01, TARGET_SCF_ACK_KREF = 0x02, TARGET_SCF_UNKNOWN_SIZE = 0x04, - TARGET_SCF_USE_CPUID = 0x08, + TARGET_SCF_USE_CPUID = 0x08, + TARGET_SCF_LOOKUP_LUN_FROM_TAG = 0x10, }; /* fabric independent task management function values */ -- 1.9.1