From patchwork Mon Jan 25 08:10:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Nicholas A. Bellinger" X-Patchwork-Id: 8104341 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3B4119F6DA for ; Mon, 25 Jan 2016 08:14:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 420D520328 for ; Mon, 25 Jan 2016 08:14:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F06CB2034F for ; Mon, 25 Jan 2016 08:14:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755345AbcAYIOK (ORCPT ); Mon, 25 Jan 2016 03:14:10 -0500 Received: from mail-oi0-f43.google.com ([209.85.218.43]:33356 "EHLO mail-oi0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750904AbcAYINu (ORCPT ); Mon, 25 Jan 2016 03:13:50 -0500 Received: by mail-oi0-f43.google.com with SMTP id w75so82740079oie.0 for ; Mon, 25 Jan 2016 00:13:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=daterainc-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=eMp3HUbLvEyChrDBDRgcCHvSGjJG51JSA17eTxgpAAg=; b=IpcnIdKIcJjQk7bNVNNGEyOLSyQ1i/iVjEORdZaAQn2nuOGliNIjh2RiB2EttYS9jy j4YWgtEeaNxluc2hhqE3dOX33Kf/cxAiLyF9/KGarHHm3nZzHmKifkZ8/bmuXbhfzW6z r1xhr49743HBCubJq8IeHRTcpJhK3TixlWzOEpp/Xfy6VLa/gVvKxs9jWvq8qR647jeK YQlcKSqnUG/HYGX22znnjxx3PkO1mdFGFgkTRYTAZVHeIPmpvnnIDbKHckHtewXeNFb0 7VYkPhDhnBOZKkLd0zynubNI4NtFO42oC1wUJ/NAowEyHawLba6So19o++gtTxsbyT4G I1Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=eMp3HUbLvEyChrDBDRgcCHvSGjJG51JSA17eTxgpAAg=; b=B0F1vZxWfvpLPJ5nJmhnm1UEloh78HotZfeB/y5KTnwPlqcW3i89Jei/34Nl4xi2OS DpLr61GQNYECPLCxSMplznFcceTTIR47uTlx3ZNWs8+zvO79eEUxVn1LaJ2hdEq+3YdM IDNJgIPk/0U7wD2Gfq2iQaQQOqHvTYxPmVdBVs4/NnHgHmln20bhK1bgRGa1NwwBZ3z/ RbOHiI2i16VaagwUDrTlVdM/9If7HOu7XlaLSjGOCagcVhpJF0ySaxVbUWVGDi8ONEjI OLbUNnmYMlZtmovE5z3EALcJFAjXJyvf9mn8o0odvAEOl1Bg9m7nkFO8ihzSeRYg5RKh La9w== X-Gm-Message-State: AG10YOTpCGuE0n9qyL0o4c9FJY3x2wIkYeJem+Z3tlKN1W5iAYzyobm/pjeN2WnbaxSvFw== X-Received: by 10.202.71.147 with SMTP id u141mr11560860oia.45.1453709628948; Mon, 25 Jan 2016 00:13:48 -0800 (PST) Received: from localhost.localdomain (mail.linux-iscsi.org. [67.23.28.174]) by smtp.gmail.com with ESMTPSA id v142sm9939087oie.28.2016.01.25.00.13.48 (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 25 Jan 2016 00:13:48 -0800 (PST) From: "Nicholas A. Bellinger" To: target-devel Cc: linux-scsi , Christoph Hellwig , Hannes Reinecke , Mike Christie , Sagi Grimberg , Andy Grover , Sebastian Andrzej Siewior , Juergen Gross , Andrzej Pietrasiewicz , Chris Boot , Nicholas Bellinger Subject: [PATCH-v2 01/12] target: Add target_alloc_session() helper function Date: Mon, 25 Jan 2016 08:10:55 +0000 Message-Id: <1453709466-6308-2-git-send-email-nab@daterainc.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1453709466-6308-1-git-send-email-nab@daterainc.com> References: <1453709466-6308-1-git-send-email-nab@daterainc.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Nicholas Bellinger Based on HCH's original patch, this adds a full version to support percpu-ida tag pre-allocation and callback function pointer into fabric driver code to complete session setup. Reported-by: Christoph Hellwig Cc: Sagi Grimberg Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: Andy Grover Signed-off-by: Nicholas Bellinger --- drivers/target/target_core_transport.c | 56 ++++++++++++++++++++++++++++++++++ include/target/target_core_fabric.h | 6 ++++ 2 files changed, 62 insertions(+) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index 6235067..5609f91 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -281,6 +281,17 @@ struct se_session *transport_init_session_tags(unsigned int tag_num, struct se_session *se_sess; int rc; + if (tag_num != 0 && !tag_size) { + pr_err("init_session_tags called with percpu-ida tag_num:" + " %u, but zero tag_size\n", tag_num); + return ERR_PTR(-EINVAL); + } + if (!tag_num && tag_size) { + pr_err("init_session_tags called with percpu-ida tag_size:" + " %u, but zero tag_num\n", tag_size); + return ERR_PTR(-EINVAL); + } + se_sess = transport_init_session(sup_prot_ops); if (IS_ERR(se_sess)) return se_sess; @@ -374,6 +385,51 @@ void transport_register_session( } EXPORT_SYMBOL(transport_register_session); +struct se_session * +target_alloc_session(struct se_portal_group *tpg, + unsigned int tag_num, unsigned int tag_size, + enum target_prot_op prot_op, + const char *initiatorname, void *private, + int (*callback)(struct se_portal_group *, + struct se_session *, void *)) +{ + struct se_session *sess; + + /* + * If the fabric driver is using percpu-ida based pre allocation + * of I/O descriptor tags, go ahead and perform that setup now.. + */ + if (tag_num != 0) + sess = transport_init_session_tags(tag_num, tag_size, prot_op); + else + sess = transport_init_session(prot_op); + + if (IS_ERR(sess)) + return sess; + + sess->se_node_acl = core_tpg_check_initiator_node_acl(tpg, + (unsigned char *)initiatorname); + if (!sess->se_node_acl) { + transport_free_session(sess); + return ERR_PTR(-EACCES); + } + /* + * Go ahead and perform any remaining fabric setup that is + * required before transport_register_session(). + */ + if (callback != NULL) { + int rc = callback(tpg, sess, private); + if (rc) { + transport_free_session(sess); + return ERR_PTR(rc); + } + } + + transport_register_session(tpg, sess->se_node_acl, sess, private); + return sess; +} +EXPORT_SYMBOL(target_alloc_session); + static void target_release_session(struct kref *kref) { struct se_session *se_sess = container_of(kref, diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h index 5665340..685a51a 100644 --- a/include/target/target_core_fabric.h +++ b/include/target/target_core_fabric.h @@ -108,6 +108,12 @@ void target_unregister_template(const struct target_core_fabric_ops *fo); int target_depend_item(struct config_item *item); void target_undepend_item(struct config_item *item); +struct se_session *target_alloc_session(struct se_portal_group *, + unsigned int, unsigned int, enum target_prot_op prot_op, + const char *, void *, + int (*callback)(struct se_portal_group *, + struct se_session *, void *)); + struct se_session *transport_init_session(enum target_prot_op); int transport_alloc_session_tags(struct se_session *, unsigned int, unsigned int);