From patchwork Sat Jan 30 07:05:45 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: 8169831 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0852FBEEE5 for ; Sat, 30 Jan 2016 07:08:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0FF4A20396 for ; Sat, 30 Jan 2016 07:08:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0D28620395 for ; Sat, 30 Jan 2016 07:08:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756278AbcA3HIu (ORCPT ); Sat, 30 Jan 2016 02:08:50 -0500 Received: from mail-oi0-f46.google.com ([209.85.218.46]:34003 "EHLO mail-oi0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756252AbcA3HIs (ORCPT ); Sat, 30 Jan 2016 02:08:48 -0500 Received: by mail-oi0-f46.google.com with SMTP id k206so61231659oia.1 for ; Fri, 29 Jan 2016 23:08:48 -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=LN6c8vWNkHIG1ZT1lwRQUvgNuk4AZ9GHMw/5lDe+nVM=; b=DSpYDyQPVYH2Q3QCFl/zAhp2gnemN6zpKgUnneD5h36IJ7aKztfosL2gpCaQhIvR4W cgfa2Gmd6/fCzkC10Tq025rzYQZwOTU2hj0fSO+dOa6Nj1KXoOrjeOmnUG7YTKWJUewU hJWQO1286FHxWyy2/1yWEpWWsGMAThCKb0XkHqDJcU83Mf/EyL/HIttNyqbA9VGRxi7a igYpPeg8j613mXSDJeA0rhvXTQU4jt1I46gVdJlPf6Cl/vNWKBOAKqXKEd01XXBpoIbS drDhC3OfCyFcRFyXY33uG0WCi6Nvn3RkVNnvNazdqos1iYuAewhu1OEGoKCGjo3f/ky+ DxLQ== 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=LN6c8vWNkHIG1ZT1lwRQUvgNuk4AZ9GHMw/5lDe+nVM=; b=XyCU/FlccPrga2WItcGNTih63OsRg3ll0q+h0KEwavqgv5K9TQdRKyCOGV17kXVvyR R72dcRhWH3C/QEAasJh0DLOaprel91GlVylBerM7/0JlhtxQrV/o8FWdNo//BCsFMVH3 esswS3ClbF4TStp7YOLV3e7h8NwrmtfTEXkt1ewm3+JlrSElRS5aKJ5u1d7JVsfMNk95 Nt5YUq+yvFC/cvwdQCsysknWvMQvwhqUEWS84XNmfE24wbK/QRJr3awMHNE/VQkWWtRH AFxZ6Tjd0tuuP9NYFom3Af8SLodx+8HewgNhjJsjzPnf2+6ZAz/yVedHPKgsGpCDvKYD GbpQ== X-Gm-Message-State: AG10YOT7H1Jitbt75qkbxyMugnTrNzSfxWMH36ZcN2keJfspT7HSlLEH/m9zDfgNu8rTPQ== X-Received: by 10.202.182.198 with SMTP id g189mr9469358oif.76.1454137727922; Fri, 29 Jan 2016 23:08:47 -0800 (PST) Received: from localhost.localdomain (mail.linux-iscsi.org. [67.23.28.174]) by smtp.gmail.com with ESMTPSA id f8sm8655678obs.3.2016.01.29.23.08.47 (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 29 Jan 2016 23:08:47 -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-v3 01/14] target: Add target_alloc_session() helper function Date: Sat, 30 Jan 2016 07:05:45 +0000 Message-Id: <1454137558-30396-2-git-send-email-nab@daterainc.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1454137558-30396-1-git-send-email-nab@daterainc.com> References: <1454137558-30396-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 9f3608e..6becc94 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);