]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
tcm_fc: Convert acl lookup to modern get_initiator_node_acl usage
authorNicholas Bellinger <nab@linux-iscsi.org>
Fri, 8 Jan 2016 06:17:16 +0000 (22:17 -0800)
committerNicholas Bellinger <nab@linux-iscsi.org>
Wed, 13 Jan 2016 07:17:51 +0000 (23:17 -0800)
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.

As per HCH, go ahead and fold ft_acl_get() into original
caller.

Cc: Vasu Dev <vasu.dev@linux.intel.com>
Cc: Sagi Grimberg <sagig@mellanox.com>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Hannes Reinecke <hare@suse.de>
Cc: Andy Grover <agrover@redhat.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/tcm_fc/tcm_fc.h
drivers/target/tcm_fc/tfc_conf.c
drivers/target/tcm_fc/tfc_sess.c

index 39909dadef3e82476ad2747aa42974ee6647162d..c30003bd4ff07979fd6c65b6de830e79a5743a92 100644 (file)
@@ -166,7 +166,6 @@ void ft_aborted_task(struct se_cmd *);
  */
 void ft_recv_req(struct ft_sess *, struct fc_frame *);
 struct ft_tpg *ft_lport_find_tpg(struct fc_lport *);
-struct ft_node_acl *ft_acl_get(struct ft_tpg *, struct fc_rport_priv *);
 
 void ft_recv_write_data(struct ft_cmd *, struct fc_frame *);
 void ft_dump_cmd(struct ft_cmd *, const char *caller);
index 9cdb2acfd6261523f10a85b109d1d1642c783c74..4d375e95841bc56bc1d10f9c154241aedab30df1 100644 (file)
@@ -220,31 +220,6 @@ static int ft_init_nodeacl(struct se_node_acl *nacl, const char *name)
        return 0;
 }
 
-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;
-
-       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;
-}
-
 /*
  * local_port port_group (tpg) ops.
  */
index 45947e2b6512cff7f6d28731b688d52e52498c55..e19f4c58c6fa569b8390d38f710055db9810bd6f 100644 (file)
@@ -191,10 +191,15 @@ 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 se_portal_group *se_tpg = &tport->tpg->se_tpg;
+       struct se_node_acl *se_acl;
        struct ft_sess *sess;
        struct hlist_head *head;
+       unsigned char initiatorname[TRANSPORT_IQN_LEN];
+
+       ft_format_wwn(&initiatorname[0], TRANSPORT_IQN_LEN, rdata->ids.port_name);
 
        head = &tport->hash[ft_sess_hash(port_id)];
        hlist_for_each_entry_rcu(sess, head, hash)
@@ -212,7 +217,14 @@ static struct ft_sess *ft_sess_create(struct ft_tport *tport, u32 port_id,
                kfree(sess);
                return NULL;
        }
-       sess->se_sess->se_node_acl = &acl->se_node_acl;
+
+       se_acl = core_tpg_get_initiator_node_acl(se_tpg, &initiatorname[0]);
+       if (!se_acl) {
+               transport_free_session(sess->se_sess);
+               kfree(sess);
+               return NULL;
+       }
+       sess->se_sess->se_node_acl = se_acl;
        sess->tport = tport;
        sess->port_id = port_id;
        kref_init(&sess->kref); /* ref for table entry */
@@ -221,7 +233,7 @@ static struct ft_sess *ft_sess_create(struct ft_tport *tport, u32 port_id,
 
        pr_debug("port_id %x sess %p\n", port_id, sess);
 
-       transport_register_session(&tport->tpg->se_tpg, &acl->se_node_acl,
+       transport_register_session(&tport->tpg->se_tpg, se_acl,
                                   sess->se_sess, sess);
        return sess;
 }
@@ -349,17 +361,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 +388,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)