From patchwork Sun Jan 10 20:28:41 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: 7997781 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 A42C5BEEED for ; Sun, 10 Jan 2016 20:31:13 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6AE8B20386 for ; Sun, 10 Jan 2016 20:31:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5C65320383 for ; Sun, 10 Jan 2016 20:31:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757479AbcAJUbD (ORCPT ); Sun, 10 Jan 2016 15:31:03 -0500 Received: from mail-oi0-f44.google.com ([209.85.218.44]:33546 "EHLO mail-oi0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757387AbcAJUa4 (ORCPT ); Sun, 10 Jan 2016 15:30:56 -0500 Received: by mail-oi0-f44.google.com with SMTP id w75so9597547oie.0 for ; Sun, 10 Jan 2016 12:30:56 -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=/evp5FTUWzz/J14VOqGcpH2IDGVhnEH5EQ7WOOlzi7s=; b=UHI9TT2wDvW1C7KZD+d8TI7lClapeLJ4DnxiqlaBGa1xgm+vMR26A9FnH+ugSPdn+s B8ijDtP4bN47JXHTD7/118QErNzRZ5AsjSR31qvSSldtj9w3wSvAbp/Q8vIIZNAcCLxf +005zu9kxJq4E3Q+FaOfJ1q/1rRqL48/VbJsF9fj7o5nJg8CiGdnTDyZygCTyO10mLAv sCCBZzcONmqaWqDlzLorX1ouhBgH2CKZU7oORgtlK576uliDyoEvLaSM/oCVp7jYFlm0 6Spa+/txvBkFGFyfkkPSBf05b73r1yScsjWUaYNqfsZf+IO5HWVImpgaM1bMlp1u9Tzb aMZQ== 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=/evp5FTUWzz/J14VOqGcpH2IDGVhnEH5EQ7WOOlzi7s=; b=U8ZINRKe9ORUk+CQ1/HvvjGAUcs1m9M+O+QDdm2w8hvq7zK5KtOg/6JIseYQxVyfxO 5/+Jza5AkJTvxTNgWaNNKP2TPT0W++p49Ij7vzHZAg09J+TYHupwPSHd12tYj5n5DldJ vktdZSzAuciw1WRKv4Q55l4Oi4TtPzv6aNekzsjT2ZTWjUhNeIB95YORJyOif6FdKS6x a0fWWHNVmDmX54L9vREpwWQ3QzAbCobi11Y75VZcKfJhxNcGaYjuQFwNXAp25F1+Yv8k nFP5phonVvm0Fgl3+/XvN+DsLlO4jTAb0qCM5ThpSqzdT7NEOri57mgG9C31yNNmfHB7 8jbw== X-Gm-Message-State: ALoCoQlZxM+sW0x6OEZ4d492tIULe92gS0Nj8JJkoMuCjWkKxemcgdAixnT3ZyCiP3m95v9Urj0ZukCoxPqXm2wYo9UP+ad/iw== X-Received: by 10.202.87.201 with SMTP id l192mr89317700oib.81.1452457856114; Sun, 10 Jan 2016 12:30:56 -0800 (PST) Received: from localhost.localdomain (mail.linux-iscsi.org. [67.23.28.174]) by smtp.gmail.com with ESMTPSA id co3sm8026500obb.15.2016.01.10.12.30.55 (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 10 Jan 2016 12:30:55 -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-v2 1/4] tcm_fc: Convert acl lookup to modern get_initiator_node_acl usage Date: Sun, 10 Jan 2016 20:28:41 +0000 Message-Id: <1452457724-10629-2-git-send-email-nab@daterainc.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1452457724-10629-1-git-send-email-nab@daterainc.com> References: <1452457724-10629-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 This patch does a simple conversion of tcm_fc code to use proper modern core_tpg_get_initiator_node_acl() lookup using se_node_acl->acl_kref, and drops the legacy list walk from ft_acl_get(). Note the original lookup also took node_name into account, but since ft_init_nodeacl() only ever sets port_name for se_node_acl->acl_group within configfs, this is purely a mechanical change. Cc: Vasu Dev Cc: Sagi Grimberg Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: Andy Grover Signed-off-by: Nicholas Bellinger --- drivers/target/tcm_fc/tfc_conf.c | 26 ++++++++------------------ drivers/target/tcm_fc/tfc_sess.c | 18 +++++++++++------- 2 files changed, 19 insertions(+), 25 deletions(-) diff --git a/drivers/target/tcm_fc/tfc_conf.c b/drivers/target/tcm_fc/tfc_conf.c index 9cdb2ac..9389ba3 100644 --- a/drivers/target/tcm_fc/tfc_conf.c +++ b/drivers/target/tcm_fc/tfc_conf.c @@ -222,27 +222,17 @@ static int ft_init_nodeacl(struct se_node_acl *nacl, const char *name) struct ft_node_acl *ft_acl_get(struct ft_tpg *tpg, struct fc_rport_priv *rdata) { - struct ft_node_acl *found = NULL; - struct ft_node_acl *acl; struct se_portal_group *se_tpg = &tpg->se_tpg; struct se_node_acl *se_acl; + unsigned char initiatorname[TRANSPORT_IQN_LEN]; - mutex_lock(&se_tpg->acl_node_mutex); - list_for_each_entry(se_acl, &se_tpg->acl_node_list, acl_list) { - acl = container_of(se_acl, struct ft_node_acl, se_node_acl); - pr_debug("acl %p port_name %llx\n", - acl, (unsigned long long)acl->node_auth.port_name); - if (acl->node_auth.port_name == rdata->ids.port_name || - acl->node_auth.node_name == rdata->ids.node_name) { - pr_debug("acl %p port_name %llx matched\n", acl, - (unsigned long long)rdata->ids.port_name); - found = acl; - /* XXX need to hold onto ACL */ - break; - } - } - mutex_unlock(&se_tpg->acl_node_mutex); - return found; + ft_format_wwn(&initiatorname[0], TRANSPORT_IQN_LEN, rdata->ids.port_name); + + se_acl = core_tpg_get_initiator_node_acl(se_tpg, &initiatorname[0]); + if (!se_acl) + return NULL; + + return container_of(se_acl, struct ft_node_acl, se_node_acl); } /* diff --git a/drivers/target/tcm_fc/tfc_sess.c b/drivers/target/tcm_fc/tfc_sess.c index 45947e2..b3db638 100644 --- a/drivers/target/tcm_fc/tfc_sess.c +++ b/drivers/target/tcm_fc/tfc_sess.c @@ -191,9 +191,10 @@ out: * Caller holds ft_lport_lock. */ static struct ft_sess *ft_sess_create(struct ft_tport *tport, u32 port_id, - struct ft_node_acl *acl) + struct fc_rport_priv *rdata) { struct ft_sess *sess; + struct ft_node_acl *acl; struct hlist_head *head; head = &tport->hash[ft_sess_hash(port_id)]; @@ -212,6 +213,14 @@ static struct ft_sess *ft_sess_create(struct ft_tport *tport, u32 port_id, kfree(sess); return NULL; } + + acl = ft_acl_get(tport->tpg, rdata); + if (!acl) { + transport_free_session(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; @@ -349,17 +358,12 @@ static int ft_prli_locked(struct fc_rport_priv *rdata, u32 spp_len, { struct ft_tport *tport; struct ft_sess *sess; - struct ft_node_acl *acl; u32 fcp_parm; tport = ft_tport_get(rdata->local_port); if (!tport) goto not_target; /* not a target for this local port */ - acl = ft_acl_get(tport->tpg, rdata); - if (!acl) - goto not_target; /* no target for this remote */ - if (!rspp) goto fill; @@ -381,7 +385,7 @@ static int ft_prli_locked(struct fc_rport_priv *rdata, u32 spp_len, spp->spp_flags |= FC_SPP_EST_IMG_PAIR; if (!(fcp_parm & FCP_SPPF_INIT_FCN)) return FC_SPP_RESP_CONF; - sess = ft_sess_create(tport, rdata->ids.port_id, acl); + sess = ft_sess_create(tport, rdata->ids.port_id, rdata); if (!sess) return FC_SPP_RESP_RES; if (!sess->params)