Commit 9ed59655 authored by Nicholas Bellinger's avatar Nicholas Bellinger

tcm_fc: Convert to target_alloc_session usage

This patch converts tcm_fc target mode addition of tf_sess->hash to
port_id hlist_head using the new alloc_session callback().

Cc: Vasu Dev <vasu.dev@linux.intel.com>
Cc: Mark Rustad <mark.d.rustad@intel.com>
Cc: Robert Love <robert.w.love@intel.com>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent 1b655b19
...@@ -186,6 +186,20 @@ static struct ft_sess *ft_sess_get(struct fc_lport *lport, u32 port_id) ...@@ -186,6 +186,20 @@ static struct ft_sess *ft_sess_get(struct fc_lport *lport, u32 port_id)
return NULL; 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. * Allocate session and enter it in the hash for the local port.
* Caller holds ft_lport_lock. * Caller holds ft_lport_lock.
...@@ -194,7 +208,6 @@ static struct ft_sess *ft_sess_create(struct ft_tport *tport, u32 port_id, ...@@ -194,7 +208,6 @@ static struct ft_sess *ft_sess_create(struct ft_tport *tport, u32 port_id,
struct fc_rport_priv *rdata) struct fc_rport_priv *rdata)
{ {
struct se_portal_group *se_tpg = &tport->tpg->se_tpg; 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]; unsigned char initiatorname[TRANSPORT_IQN_LEN];
...@@ -210,31 +223,18 @@ static struct ft_sess *ft_sess_create(struct ft_tport *tport, u32 port_id, ...@@ -210,31 +223,18 @@ static struct ft_sess *ft_sess_create(struct ft_tport *tport, u32 port_id,
if (!sess) if (!sess)
return NULL; return NULL;
sess->se_sess = transport_init_session_tags(TCM_FC_DEFAULT_TAGS, kref_init(&sess->kref); /* ref for table entry */
sizeof(struct ft_cmd), sess->tport = tport;
TARGET_PROT_NORMAL); sess->port_id = port_id;
if (IS_ERR(sess->se_sess)) {
kfree(sess);
return NULL;
}
se_acl = core_tpg_get_initiator_node_acl(se_tpg, &initiatorname[0]); sess->se_sess = target_alloc_session(se_tpg, TCM_FC_DEFAULT_TAGS,
if (!se_acl) { sizeof(struct ft_cmd),
transport_free_session(sess->se_sess); TARGET_PROT_NORMAL, &initiatorname[0],
sess, ft_sess_alloc_cb);
if (IS_ERR(sess->se_sess)) {
kfree(sess); kfree(sess);
return NULL; 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 */
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, se_acl,
sess->se_sess, sess);
return sess; return sess;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment