aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Bellinger <nab@linux-iscsi.org>2016-01-09 23:12:40 -0500
committerNicholas Bellinger <nab@linux-iscsi.org>2016-03-11 00:47:58 -0500
commit9ed5965588603840100fb31e579c2996d81aaea9 (patch)
treea431d6608fb25e375dde3d5c4f9a27dbb83af75b
parent1b655b19e28b70a45db2e30b5a864af503afff89 (diff)
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: Nicholas Bellinger <nab@linux-iscsi.org>
-rw-r--r--drivers/target/tcm_fc/tfc_sess.c44
1 files changed, 22 insertions, 22 deletions
diff --git a/drivers/target/tcm_fc/tfc_sess.c b/drivers/target/tcm_fc/tfc_sess.c
index e19f4c58c6fa..d0c3e1894c61 100644
--- a/drivers/target/tcm_fc/tfc_sess.c
+++ b/drivers/target/tcm_fc/tfc_sess.c
@@ -186,6 +186,20 @@ out:
186 return NULL; 186 return NULL;
187} 187}
188 188
189static int ft_sess_alloc_cb(struct se_portal_group *se_tpg,
190 struct se_session *se_sess, void *p)
191{
192 struct ft_sess *sess = p;
193 struct ft_tport *tport = sess->tport;
194 struct hlist_head *head = &tport->hash[ft_sess_hash(sess->port_id)];
195
196 pr_debug("port_id %x sess %p\n", sess->port_id, sess);
197 hlist_add_head_rcu(&sess->hash, head);
198 tport->sess_count++;
199
200 return 0;
201}
202
189/* 203/*
190 * Allocate session and enter it in the hash for the local port. 204 * Allocate session and enter it in the hash for the local port.
191 * Caller holds ft_lport_lock. 205 * Caller holds ft_lport_lock.
@@ -194,7 +208,6 @@ static struct ft_sess *ft_sess_create(struct ft_tport *tport, u32 port_id,
194 struct fc_rport_priv *rdata) 208 struct fc_rport_priv *rdata)
195{ 209{
196 struct se_portal_group *se_tpg = &tport->tpg->se_tpg; 210 struct se_portal_group *se_tpg = &tport->tpg->se_tpg;
197 struct se_node_acl *se_acl;
198 struct ft_sess *sess; 211 struct ft_sess *sess;
199 struct hlist_head *head; 212 struct hlist_head *head;
200 unsigned char initiatorname[TRANSPORT_IQN_LEN]; 213 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 if (!sess) 223 if (!sess)
211 return NULL; 224 return NULL;
212 225
213 sess->se_sess = transport_init_session_tags(TCM_FC_DEFAULT_TAGS, 226 kref_init(&sess->kref); /* ref for table entry */
214 sizeof(struct ft_cmd), 227 sess->tport = tport;
215 TARGET_PROT_NORMAL); 228 sess->port_id = port_id;
216 if (IS_ERR(sess->se_sess)) {
217 kfree(sess);
218 return NULL;
219 }
220 229
221 se_acl = core_tpg_get_initiator_node_acl(se_tpg, &initiatorname[0]); 230 sess->se_sess = target_alloc_session(se_tpg, TCM_FC_DEFAULT_TAGS,
222 if (!se_acl) { 231 sizeof(struct ft_cmd),
223 transport_free_session(sess->se_sess); 232 TARGET_PROT_NORMAL, &initiatorname[0],
233 sess, ft_sess_alloc_cb);
234 if (IS_ERR(sess->se_sess)) {
224 kfree(sess); 235 kfree(sess);
225 return NULL; 236 return NULL;
226 } 237 }
227 sess->se_sess->se_node_acl = se_acl;
228 sess->tport = tport;
229 sess->port_id = port_id;
230 kref_init(&sess->kref); /* ref for table entry */
231 hlist_add_head_rcu(&sess->hash, head);
232 tport->sess_count++;
233
234 pr_debug("port_id %x sess %p\n", port_id, sess);
235
236 transport_register_session(&tport->tpg->se_tpg, se_acl,
237 sess->se_sess, sess);
238 return sess; 238 return sess;
239} 239}
240 240