tcm_fc: Convert acl lookup to modern get_initiator_node_acl usage
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>
This commit is contained in:
parent
de7ee9a20c
commit
7fbef3d0c2
|
@ -166,7 +166,6 @@ void ft_aborted_task(struct se_cmd *);
|
||||||
*/
|
*/
|
||||||
void ft_recv_req(struct ft_sess *, struct fc_frame *);
|
void ft_recv_req(struct ft_sess *, struct fc_frame *);
|
||||||
struct ft_tpg *ft_lport_find_tpg(struct fc_lport *);
|
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_recv_write_data(struct ft_cmd *, struct fc_frame *);
|
||||||
void ft_dump_cmd(struct ft_cmd *, const char *caller);
|
void ft_dump_cmd(struct ft_cmd *, const char *caller);
|
||||||
|
|
|
@ -220,31 +220,6 @@ static int ft_init_nodeacl(struct se_node_acl *nacl, const char *name)
|
||||||
return 0;
|
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.
|
* local_port port_group (tpg) ops.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -191,10 +191,15 @@ out:
|
||||||
* Caller holds ft_lport_lock.
|
* Caller holds ft_lport_lock.
|
||||||
*/
|
*/
|
||||||
static struct ft_sess *ft_sess_create(struct ft_tport *tport, u32 port_id,
|
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 ft_sess *sess;
|
||||||
struct hlist_head *head;
|
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)];
|
head = &tport->hash[ft_sess_hash(port_id)];
|
||||||
hlist_for_each_entry_rcu(sess, head, hash)
|
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);
|
kfree(sess);
|
||||||
return NULL;
|
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->tport = tport;
|
||||||
sess->port_id = port_id;
|
sess->port_id = port_id;
|
||||||
kref_init(&sess->kref); /* ref for table entry */
|
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);
|
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);
|
sess->se_sess, sess);
|
||||||
return 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_tport *tport;
|
||||||
struct ft_sess *sess;
|
struct ft_sess *sess;
|
||||||
struct ft_node_acl *acl;
|
|
||||||
u32 fcp_parm;
|
u32 fcp_parm;
|
||||||
|
|
||||||
tport = ft_tport_get(rdata->local_port);
|
tport = ft_tport_get(rdata->local_port);
|
||||||
if (!tport)
|
if (!tport)
|
||||||
goto not_target; /* not a target for this local port */
|
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)
|
if (!rspp)
|
||||||
goto fill;
|
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;
|
spp->spp_flags |= FC_SPP_EST_IMG_PAIR;
|
||||||
if (!(fcp_parm & FCP_SPPF_INIT_FCN))
|
if (!(fcp_parm & FCP_SPPF_INIT_FCN))
|
||||||
return FC_SPP_RESP_CONF;
|
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)
|
if (!sess)
|
||||||
return FC_SPP_RESP_RES;
|
return FC_SPP_RESP_RES;
|
||||||
if (!sess->params)
|
if (!sess->params)
|
||||||
|
|
Loading…
Reference in New Issue