From patchwork Sun Jan 10 20:44:23 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: 7997891 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 E69119F3F6 for ; Sun, 10 Jan 2016 20:48:29 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0633520382 for ; Sun, 10 Jan 2016 20:48:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 074AF2037F for ; Sun, 10 Jan 2016 20:48:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757583AbcAJUrh (ORCPT ); Sun, 10 Jan 2016 15:47:37 -0500 Received: from mail-ob0-f182.google.com ([209.85.214.182]:35526 "EHLO mail-ob0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757348AbcAJUql (ORCPT ); Sun, 10 Jan 2016 15:46:41 -0500 Received: by mail-ob0-f182.google.com with SMTP id py5so17099864obc.2 for ; Sun, 10 Jan 2016 12:46:41 -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=OgfANSMQXX57YZCi94OyNpFH16GepFB/0XxaOAzMwaY=; b=XxAS8iiojnq9zaBK4GPKYZ8IoVgXVBXY7oqPUgqU6J7/9lWUNIHTuhtSk8Cmeog5/G mzJHFgHy5TKCI+Kpr9T/mrCMPOya0ffGeZkpYviEXOtJiNZxNu8LGLbdLbK87zJuFbb1 9n5gWizlY50AS4PyIEEOnoj9KddY874qqGfPoMmURAcCkhEmalNa+iqKtNLaozKqwrg6 KSbqswcjXr6cF3KVb9xpuBMVnLW3MpXCJ4ZKaLDqTiAkkhgXm8a+8YUl8ApDG1d1+R1R //4XwPUuavMIm1KZKBto3m8RjE/XL6sS7eKiuVkRWEpEoyvG1Fbf3LCXrUGebf2mCVWD TiQw== 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=OgfANSMQXX57YZCi94OyNpFH16GepFB/0XxaOAzMwaY=; b=gjRXhvGFL+5m43jaazS839CUTdd3iaeHZr8rKhh0K74LRbZwJqxVvdvjIugJC6pK8i OgAuJV+YKOHnDM690PfydakfWmbSJqY0+77fPm7cbeQv5rJxD6EX2v9ckcGKxWnIO+Fs F6SySulzLW0+gPUhsrABNWE09pjFO2gixqmfVxwpooYNdYs3ji/4lvPY6mrs+6vxWrtX JTnJkHBL7kw3urSYT22w9Isah97kUAl+VP+rcNSVpR8GAH+XMeIaKnpc9Z+UdPrx8w0v U7d7eBJxbK7t9IcWFCij9QoDps9POUFFYM3zzueRtBZPvaZP9HKKaq1Bs531TELvkc83 v/Pg== X-Gm-Message-State: ALoCoQm5/OEHESuxSAJCwifFzHfWMEZip1Fc2bY7oosJebqy4oqQ41RprEgJXn+H4vn6LFUi8OHv0/QZsKfrgNdqD8gMBqyAwA== X-Received: by 10.182.20.147 with SMTP id n19mr11130906obe.28.1452458801223; Sun, 10 Jan 2016 12:46:41 -0800 (PST) Received: from localhost.localdomain (mail.linux-iscsi.org. [67.23.28.174]) by smtp.gmail.com with ESMTPSA id a65sm19935004oib.23.2016.01.10.12.46.40 (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 10 Jan 2016 12:46:40 -0800 (PST) From: "Nicholas A. Bellinger" To: target-devel Cc: linux-scsi , lkml , Sagi Grimberg , Christoph Hellwig , Hannes Reinecke , Andy Grover , Vasu Dev , Vu Pham , Nicholas Bellinger Subject: [PATCH-for-4.6 1/6] target: Add target_alloc_session() helper function Date: Sun, 10 Jan 2016 20:44:23 +0000 Message-Id: <1452458668-11034-2-git-send-email-nab@daterainc.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1452458668-11034-1-git-send-email-nab@daterainc.com> References: <1452458668-11034-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 | 55 ++++++++++++++++++++++++++++++++++ include/target/target_core_fabric.h | 6 ++++ 2 files changed, 61 insertions(+) diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index c5035b9..fd4404f6 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c @@ -374,6 +374,61 @@ 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 (tag_num != 0 && !tag_size) { + pr_err("target_alloc_session 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("target_alloc_session called with percpu-ida tag_size:" + " %u, but zero tag_num\n", tag_size); + return ERR_PTR(-EINVAL); + } + /* + * 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 dc6b09e..7d59273 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);