From patchwork Wed Feb 8 22:24:37 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: 9563689 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 77C476020F for ; Wed, 8 Feb 2017 22:29:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AE68284F2 for ; Wed, 8 Feb 2017 22:29:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3FC872852C; Wed, 8 Feb 2017 22:29:54 +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 DAA1B284F2 for ; Wed, 8 Feb 2017 22:29:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751307AbdBHW3x (ORCPT ); Wed, 8 Feb 2017 17:29:53 -0500 Received: from esa2.hgst.iphmx.com ([68.232.143.124]:11128 "EHLO esa2.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751092AbdBHW3w (ORCPT ); Wed, 8 Feb 2017 17:29:52 -0500 X-IronPort-AV: E=Sophos;i="5.35,348,1483977600"; d="scan'208";a="76618125" Received: from unknown (HELO milsmgep15.sandisk.com) ([63.163.107.21]) by ob1.hgst.iphmx.com with ESMTP; 09 Feb 2017 06:28:17 +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 D2.54.57638.8CA9B985; Wed, 8 Feb 2017 14:25:12 -0800 (PST) Received: from milsmgip12.sandisk.com (10.177.9.6) by MILHUBIP03.sdcorp.global.sandisk.com (10.177.9.96) with Microsoft SMTP Server id 14.3.319.2; Wed, 8 Feb 2017 14:25:11 -0800 X-AuditID: 0ac94369-26dee9800001e126-ef-589b9ac80618 Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id AF.32.18148.7CA9B985; Wed, 8 Feb 2017 14:25:11 -0800 (PST) From: Bart Van Assche To: Bart Van Assche CC: , Christoph Hellwig , Hannes Reinecke , David Disseldorp Subject: [PATCH v4 07/37] target: Introduce a new workqueue for TMF processing Date: Wed, 8 Feb 2017 14:24:37 -0800 Message-ID: <20170208222507.25715-8-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170208222507.25715-1-bart.vanassche@sandisk.com> References: <20170208222507.25715-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrCLMWRmVeSWpSXmKPExsXCddJ5ke6JWbMjDF7dMbb4+n86i8WCN3vZ LFauPspk0br0LZMDi8fumw1sHuu3XGXx2Hy62uPzJrkAligum5TUnMyy1CJ9uwSujMVfnrMU XBau6D3cy9zA+Fygi5GTQ0LARGLxn0lMXYxcHEICS5kkjl5vZAJJCAlsZZQ4tdsTpujd7w42 iKKNjBK/9txjA0mwCRhJfHs/kwXEFhEwkPjde4ERpIhZoJ1R4mXvE7BJwgJ+EmuP3mUFsVkE VCQuHnoH1MDBwStgL/GlVQ1igbzErraLYCWcAg4SE14+Y4Q4wl7i1YEvjBA1bawSS4+Wg9i8 AoISJ2c+AdvLLCAhcfDFC2aIenWJk0vmM01gFJqFpGwWkrIFjEyrGMVyM3OKc9NTCwxN9YoT 81Iyi7P1kvNzNzFCwjpzB+PdJ96HGAU4GJV4eCssZ0cIsSaWFVfmHmKU4GBWEuFNmQYU4k1J rKxKLcqPLyrNSS0+xCjNwaIkzntOZmqEkEB6YklqdmpqQWoRTJaJg1OqgXHywcA5Sz9WBKd/ YCiKP3IvTKz11O2P/Yw8R7M0uLQkL3yZdWnDlYKA/5qV07JjM0wqmGM/1934cKKfSXtpX+fZ rq+V3Y0sXWU1N/g+rTmhvF/PMjgwxqmodr6J0Ltf03yjFeMKX2/M08jcsfaTl9U+falGp1nb ju8WFvgw5+mq14b9luyXpZVYijMSDbWYi4oTAS8TYXBnAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrGJMWRmVeSWpSXmKPExsXCtZGTTff4rNkRBssXylsc/NnGaPH1/3QW iwVv9rJZrFx9lMmidelbJgdWj903G9g8pq05z+SxfstVFo/Np6s9Pm+SC2CN4rJJSc3JLEst 0rdL4MpY/OU5S8Fl4Yrew73MDYzPBboYOTkkBEwk3v3uYOti5OIQEljPKLFk1XVmkASbgJHE t/czWUBsEQEDid+9FxhBipgFOhklNh0+zQaSEBbwk1h79C4riM0ioCpx48JeMJtXwF7i+7Y3 TBAb5CV2tV0Ei3MKOEhMePmMEcQWAqp5deAL4wRG7gWMDKsYxXIzc4pz0zMLDI30ihPzUjKL s/WS83M3MUJCImoH4/WJ5ocYmTg4pRoY/WJDLjBGNfC23aqObT4hvneS9tst28Snz+aSXXTw rZFDzTRhtVB/+wsp5S7LpzAfOh4vITqV4bVEKnO75oufb8/Elsz9b8F17vy+GdIcGywfbNow TabgquntlzqxRqG3f+zmNOrsaLWduvH1pLq7VZbZd5Oes1ieF19acT3hjkTKuw2/ZjgUKbEU ZyQaajEXFScCAI524rm5AQAA 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 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 Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: David Disseldorp Reviewed-by: Hannes Reinecke --- drivers/target/target_core_transport.c | 11 ++++++++++- include/target/target_core_base.h | 1 + 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 1cadc9eefa21..084a7fbfc72e 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -241,6 +241,13 @@ struct se_session *transport_init_session(enum target_prot_op sup_prot_ops) spin_lock_init(&se_sess->sess_cmd_lock); se_sess->sup_prot_ops = sup_prot_ops; + 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__); + kfree(se_sess); + return ERR_PTR(-ENOMEM); + } + return se_sess; } EXPORT_SYMBOL(transport_init_session); @@ -507,6 +514,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); @@ -3129,7 +3138,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;