From patchwork Sat Feb 4 00:25:50 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: 9555377 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 9D26D60424 for ; Sat, 4 Feb 2017 00:25:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89EA12816B for ; Sat, 4 Feb 2017 00:25:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C4C528499; Sat, 4 Feb 2017 00:25:57 +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 D0ACB2816B for ; Sat, 4 Feb 2017 00:25:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753224AbdBDAZ4 (ORCPT ); Fri, 3 Feb 2017 19:25:56 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:58120 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753222AbdBDAZz (ORCPT ); Fri, 3 Feb 2017 19:25:55 -0500 X-IronPort-AV: E=Sophos;i="5.33,331,1477929600"; d="scan'208";a="72519070" Received: from unknown (HELO milsmgep14.sandisk.com) ([63.163.107.225]) by ob1.hgst.iphmx.com with ESMTP; 04 Feb 2017 08:43:00 +0800 Received: from MILHUBIP03.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 A1.00.04292.54D15985; Fri, 3 Feb 2017 16:16:08 -0800 (PST) Received: from milsmgip11.sandisk.com (10.177.8.100) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.319.2; Fri, 3 Feb 2017 16:25:51 -0800 X-AuditID: 0ac94371-0c3ff700000110c4-44-58951d454faf Received: from exp-402881.sandisk.com ( [10.177.8.100]) by (Symantec Messaging Gateway) with SMTP id D0.6B.16817.E8F15985; Fri, 3 Feb 2017 16:25:51 -0800 (PST) Subject: [PATCH v3 09/36] target: Introduce a new workqueue for TMF processing To: Bart Van Assche References: <20170202005853.23456-1-bart.vanassche@sandisk.com> <20170202005853.23456-10-bart.vanassche@sandisk.com> CC: From: Bart Van Assche Message-ID: Date: Fri, 3 Feb 2017 16:25:50 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <20170202005853.23456-10-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrPLMWRmVeSWpSXmKPExsXCddJ5ka6H7NQIg47H7BatS98yOTB6fN4k F8AYxWWTkpqTWZZapG+XwJUxbfFStoKHwhUzn01lbmC8L9DFyMkhIWAiMXPtB1YQW0hgKZPE +clZXYxcQPZ2RokFvRuZYYrenJzFApFYyiixreUXkMPBISzgJ/H0KydIjYiAgcTv3guMEIPK JJbeusAEYjMLKEnsmboMzGYTMJL49n4mC4jNK2AnsfnhPLA4i4CKxK/O/2wgtqhAhMT8p6uY IGoEJU7OfAJWzyngKNG29DorxEwDiSOL5kDZ8hLb385hBrlNQqCPVeL73ztQ36hLnFwyn2kC o/AsJLNmIemfhaR/ASPzKkax3Myc4tz01AJDE73ixLyUzOJsveT83E2MkGAu3MH4+rb3IUYB DkYlHt4Ps6ZECLEmlhVX5h5ilOBgVhLhlQHGghBvSmJlVWpRfnxRaU5q8SFGaQ4WJXHe1tf9 EUIC6YklqdmpqQWpRTBZJg5OqQbGZZd+xGps2Mbj2JgQXCjy9y93lmi36Qujmsmq3SeXeDbW 71i1tvGiLuPKo6pB6bamV5n5DIt39AXZzpmucOLwzEN3zbhMnLjYTWKTPAsj5b3cLx4xbN0q zPPw1k2GJ64LVq2b/8aC59k2l7TrmZ1Llj57oa9xo9XC+cSGgqhgwY5TP523T9dTYinOSDTU Yi4qTgQAV/eFe2ICAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrPJMWRmVeSWpSXmKPExsXCtZEjRbdffmqEQXuLrcXBn22MFq1L3zI5 MHlMW3OeyePzJrkApigum5TUnMyy1CJ9uwSujGmLl7IVPBSumPlsKnMD432BLkZODgkBE4k3 J2exdDFycQgJLGaU6D78ma2LkYNDWMBP4ulXTpAaEQEDid+9FxhBbCGBMomlty4wgdjMAgoS F6fOAouzCRhJfHs/kwXE5hWwk9j8cB5YDYuAisSvzv9sILaoQITE/KermCBqBCVOznwCVs8p 4CjRtvQ6K8RMPYkd139B2fIS29/OYZ7AyDcLScssJGWzkJQtYGRexSiWm5lTnJueWWBoqFec mJeSWZytl5yfu4kRHGSckTsYn040P8TIxMEp1cB4I3jTBSnLf2Y1YlOnr97m07hgp4KD2ARr uQ3rDfJbhCYpdQlpP7FvjH+mx3zguWWN3PGYh7tTThw++O1c8Qu2YLt8z3uKMXb9EqJSUTZx G5SWrTOKaljU6qlS/7VX++82mVdTL/4MOzLjl54kS/ECZ9edJ3sCXimfnf8wc/rlHJc5j66w v9qixFKckWioxVxUnAgA0icEaOIBAAA= 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 Several SCSI transport protocols require that SCSI task management functions are processed in the order in which these have been submitted by the initiator system. Hence introduce a workqueue per session for TMF processing. Do not specify WQ_MEM_RECLAIM since only the tcm_loop driver can queue TMF work from inside the memory allocation path and since the tcm_loop driver is only used to debug the SCSI target code. Signed-off-by: Bart Van Assche Reviewed-by: Christoph Hellwig --- Changes compared to v2 for this patch: test se_sess->tmf_wq before calling destroy_workqueue(). --- drivers/target/target_core_transport.c | 13 ++++++++++++- include/target/target_core_base.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index ab4051fbab95..59aa31983303 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -267,9 +267,18 @@ int transport_alloc_session_tags(struct se_session *se_sess, goto free_cmd_map; } + se_sess->tmf_wq = alloc_workqueue("tmf-%p", WQ_UNBOUND, 1, se_sess); + if (!se_sess->tmf_wq) { + pr_err("%s: workqueue allocation failed\n", __func__); + goto free_tag_pool; + } + out: return rc; +free_tag_pool: + percpu_ida_destroy(&se_sess->sess_tag_pool); + free_cmd_map: kvfree(se_sess->sess_cmd_map); se_sess->sess_cmd_map = NULL; @@ -511,6 +520,8 @@ void transport_free_session(struct se_session *se_sess) se_sess->se_node_acl = NULL; target_put_nacl(se_nacl); } + if (se_sess->tmf_wq) + destroy_workqueue(se_sess->tmf_wq); if (se_sess->sess_cmd_map) { percpu_ida_destroy(&se_sess->sess_tag_pool); kvfree(se_sess->sess_cmd_map); @@ -3133,7 +3144,7 @@ int transport_generic_handle_tmr( spin_unlock_irqrestore(&cmd->t_state_lock, flags); INIT_WORK(&cmd->work, target_tmr_work); - queue_work(cmd->se_dev->tmr_wq, &cmd->work); + queue_work(cmd->se_sess->tmf_wq, &cmd->work); return 0; } EXPORT_SYMBOL(transport_generic_handle_tmr); diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h index c9aada11a30c..f6e5fb22f338 100644 --- a/include/target/target_core_base.h +++ b/include/target/target_core_base.h @@ -606,6 +606,7 @@ struct se_session { spinlock_t sess_cmd_lock; void *sess_cmd_map; struct percpu_ida sess_tag_pool; + struct workqueue_struct *tmf_wq; }; struct se_device;