From patchwork Sun Jan 10 20:44:27 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: 7997911 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 619BD9F3F6 for ; Sun, 10 Jan 2016 20:48:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 90CAE20382 for ; Sun, 10 Jan 2016 20:48:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8EAA82037F for ; Sun, 10 Jan 2016 20:48:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757566AbcAJUre (ORCPT ); Sun, 10 Jan 2016 15:47:34 -0500 Received: from mail-oi0-f43.google.com ([209.85.218.43]:33662 "EHLO mail-oi0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757478AbcAJUqs (ORCPT ); Sun, 10 Jan 2016 15:46:48 -0500 Received: by mail-oi0-f43.google.com with SMTP id w75so9716386oie.0 for ; Sun, 10 Jan 2016 12:46: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=iQ4ehHaJHxeEDDkuLVpuIrRY3DC+xiML2J5BKw/hDn8=; b=c1bAiArFSu9GWtBzDCtZVs9VSMAdi09YQD2eLNA7K+70SYykkNO4as6JS4qUSGGQpx 2wjQl+VRiSM6GTDp0un4PKOqifmDpBXFc9CIQHC1DtZSIBIROP5QhD2ijImEzICiZwQX 51yd1i1Rr7MGbV0SqL4qHpLLr79iyDmU0snmDDgWk9IEIalL/iV/T3cHifYy8wwpiGQO xwBhQ/E+CkhKzOHxxvTWUz6yjfXftNfteYf0/rEGk3cv1330/89ThZoSxFn8prXIzEhr t4r0z/za2AZ+fPs9o5HAPyslgYBx7tEGGGpipukN/4e3+8RnuV1cpp2SLRnIe9yM6eFB uFww== 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=iQ4ehHaJHxeEDDkuLVpuIrRY3DC+xiML2J5BKw/hDn8=; b=Zw/GsVkryTNkpgF0C3V/VvtF2bLOEhvUXoQrBRilVqWYHuJRUdUPn7M+pBKrGRJUDf T8zZ/wdVdJlSqvDpUeMJlTbd/W3hocXzI5GS9OghiQrP5pHT/CBBfSe6RAuUGRJ7bvX5 1K5pen6v/eec0MyxhkO77bYciUeldiVgx2V/A8aTqm6QHk1qfr855X2aicSIe1ghjyQK w7RkO+5Fr3UvyIKpperwDGAoX+crivunVVlf5resLznX3g67gNiFAYQXTSwiFmvi7xuN 5zxoIkZH/+pd0z8YzGEu7NMN8/80XCxepKXnqp0baHBZqjPIMXAaqYe9YbjeWScRNe8f tNNQ== X-Gm-Message-State: ALoCoQlamP781Dxf3eBpkLpJvVj/fO14b7a3NLRnGg3qs5qdVvrF9/0XdlHdvM5u9e24860XTzTfVMkQlYZbU3m1ranV+H6YUw== X-Received: by 10.202.48.81 with SMTP id w78mr60189629oiw.2.1452458807632; Sun, 10 Jan 2016 12:46:47 -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.46 (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 10 Jan 2016 12:46:47 -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 5/6] tcm_fc: Convert to target_alloc_session usage Date: Sun, 10 Jan 2016 20:44:27 +0000 Message-Id: <1452458668-11034-6-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=unavailable 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 Cc: Vasu Dev Signed-off-by: Nicholas Bellinger --- drivers/target/tcm_fc/tfc_sess.c | 47 +++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/drivers/target/tcm_fc/tfc_sess.c b/drivers/target/tcm_fc/tfc_sess.c index b3db638..19bfbda 100644 --- a/drivers/target/tcm_fc/tfc_sess.c +++ b/drivers/target/tcm_fc/tfc_sess.c @@ -186,6 +186,20 @@ out: return NULL; } +static int ft_sess_alloc_cb(struct se_portal_group *se_tpg, + struct se_session *se_sess, void *p) +{ + struct ft_sess *sess = p; + struct ft_tport *tport = sess->tport; + struct hlist_head *head = &tport->hash[ft_sess_hash(sess->port_id)]; + + pr_debug("port_id %x sess %p\n", sess->port_id, sess); + hlist_add_head_rcu(&sess->hash, head); + tport->sess_count++; + + return 0; +} + /* * Allocate session and enter it in the hash for the local port. * Caller holds ft_lport_lock. @@ -193,9 +207,10 @@ out: static struct ft_sess *ft_sess_create(struct ft_tport *tport, u32 port_id, struct fc_rport_priv *rdata) { + struct se_portal_group *se_tpg = &tport->tpg->se_tpg; struct ft_sess *sess; - struct ft_node_acl *acl; struct hlist_head *head; + unsigned char iname[TRANSPORT_IQN_LEN]; head = &tport->hash[ft_sess_hash(port_id)]; hlist_for_each_entry_rcu(sess, head, hash) @@ -206,32 +221,20 @@ static struct ft_sess *ft_sess_create(struct ft_tport *tport, u32 port_id, if (!sess) return NULL; - sess->se_sess = transport_init_session_tags(TCM_FC_DEFAULT_TAGS, - sizeof(struct ft_cmd), - TARGET_PROT_NORMAL); - if (IS_ERR(sess->se_sess)) { - kfree(sess); - return NULL; - } + kref_init(&sess->kref); /* ref for table entry */ + sess->tport = tport; + sess->port_id = port_id; + ft_format_wwn(&iname[0], TRANSPORT_IQN_LEN, rdata->ids.port_name); - acl = ft_acl_get(tport->tpg, rdata); - if (!acl) { - transport_free_session(sess->se_sess); + sess->se_sess = target_alloc_session(se_tpg, TCM_FC_DEFAULT_TAGS, + sizeof(struct ft_cmd), + TARGET_PROT_NORMAL, &iname[0], + sess, ft_sess_alloc_cb); + if (IS_ERR(sess->se_sess)) { kfree(sess); return NULL; } - sess->se_sess->se_node_acl = &acl->se_node_acl; - sess->tport = tport; - sess->port_id = port_id; - kref_init(&sess->kref); /* ref for table entry */ - hlist_add_head_rcu(&sess->hash, head); - tport->sess_count++; - - pr_debug("port_id %x sess %p\n", port_id, sess); - - transport_register_session(&tport->tpg->se_tpg, &acl->se_node_acl, - sess->se_sess, sess); return sess; }