summaryrefslogtreecommitdiffstats
path: root/drivers/target
diff options
context:
space:
mode:
authorNicholas Bellinger <nab@linux-iscsi.org>2016-01-08 01:17:16 -0500
committerNicholas Bellinger <nab@linux-iscsi.org>2016-01-13 02:17:51 -0500
commit7fbef3d0c2f6063ed12e7f3d74ba2a49111154f9 (patch)
treec80ab6948b21393c2e03239e913ecc2b601acda3 /drivers/target
parentde7ee9a20c7f617cbc5091e84855afcdeb19ba60 (diff)
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>
Diffstat (limited to 'drivers/target')
-rw-r--r--drivers/target/tcm_fc/tcm_fc.h1
-rw-r--r--drivers/target/tcm_fc/tfc_conf.c25
-rw-r--r--drivers/target/tcm_fc/tfc_sess.c25
3 files changed, 16 insertions, 35 deletions
diff --git a/drivers/target/tcm_fc/tcm_fc.h b/drivers/target/tcm_fc/tcm_fc.h
index 39909dadef3e..c30003bd4ff0 100644
--- a/drivers/target/tcm_fc/tcm_fc.h
+++ b/drivers/target/tcm_fc/tcm_fc.h
@@ -166,7 +166,6 @@ void ft_aborted_task(struct se_cmd *);
166 */ 166 */
167void ft_recv_req(struct ft_sess *, struct fc_frame *); 167void ft_recv_req(struct ft_sess *, struct fc_frame *);
168struct ft_tpg *ft_lport_find_tpg(struct fc_lport *); 168struct ft_tpg *ft_lport_find_tpg(struct fc_lport *);
169struct ft_node_acl *ft_acl_get(struct ft_tpg *, struct fc_rport_priv *);
170 169
171void ft_recv_write_data(struct ft_cmd *, struct fc_frame *); 170void ft_recv_write_data(struct ft_cmd *, struct fc_frame *);
172void ft_dump_cmd(struct ft_cmd *, const char *caller); 171void ft_dump_cmd(struct ft_cmd *, const char *caller);
diff --git a/drivers/target/tcm_fc/tfc_conf.c b/drivers/target/tcm_fc/tfc_conf.c
index 9cdb2acfd626..4d375e95841b 100644
--- a/drivers/target/tcm_fc/tfc_conf.c
+++ b/drivers/target/tcm_fc/tfc_conf.c
@@ -220,31 +220,6 @@ static int ft_init_nodeacl(struct se_node_acl *nacl, const char *name)
220 return 0; 220 return 0;
221} 221}
222 222
223struct ft_node_acl *ft_acl_get(struct ft_tpg *tpg, struct fc_rport_priv *rdata)
224{
225 struct ft_node_acl *found = NULL;
226 struct ft_node_acl *acl;
227 struct se_portal_group *se_tpg = &tpg->se_tpg;
228 struct se_node_acl *se_acl;
229
230 mutex_lock(&se_tpg->acl_node_mutex);
231 list_for_each_entry(se_acl, &se_tpg->acl_node_list, acl_list) {
232 acl = container_of(se_acl, struct ft_node_acl, se_node_acl);
233 pr_debug("acl %p port_name %llx\n",
234 acl, (unsigned long long)acl->node_auth.port_name);
235 if (acl->node_auth.port_name == rdata->ids.port_name ||
236 acl->node_auth.node_name == rdata->ids.node_name) {
237 pr_debug("acl %p port_name %llx matched\n", acl,
238 (unsigned long long)rdata->ids.port_name);
239 found = acl;
240 /* XXX need to hold onto ACL */
241 break;
242 }
243 }
244 mutex_unlock(&se_tpg->acl_node_mutex);
245 return found;
246}
247
248/* 223/*
249 * local_port port_group (tpg) ops. 224 * local_port port_group (tpg) ops.
250 */ 225 */
diff --git a/drivers/target/tcm_fc/tfc_sess.c b/drivers/target/tcm_fc/tfc_sess.c
index 45947e2b6512..e19f4c58c6fa 100644
--- a/drivers/target/tcm_fc/tfc_sess.c
+++ b/drivers/target/tcm_fc/tfc_sess.c
@@ -191,10 +191,15 @@ out:
191 * Caller holds ft_lport_lock. 191 * Caller holds ft_lport_lock.
192 */ 192 */
193static struct ft_sess *ft_sess_create(struct ft_tport *tport, u32 port_id, 193static struct ft_sess *ft_sess_create(struct ft_tport *tport, u32 port_id,
194 struct ft_node_acl *acl) 194 struct fc_rport_priv *rdata)
195{ 195{
196 struct se_portal_group *se_tpg = &tport->tpg->se_tpg;
197 struct se_node_acl *se_acl;
196 struct ft_sess *sess; 198 struct ft_sess *sess;
197 struct hlist_head *head; 199 struct hlist_head *head;
200 unsigned char initiatorname[TRANSPORT_IQN_LEN];
201
202 ft_format_wwn(&initiatorname[0], TRANSPORT_IQN_LEN, rdata->ids.port_name);
198 203
199 head = &tport->hash[ft_sess_hash(port_id)]; 204 head = &tport->hash[ft_sess_hash(port_id)];
200 hlist_for_each_entry_rcu(sess, head, hash) 205 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,
212 kfree(sess); 217 kfree(sess);
213 return NULL; 218 return NULL;
214 } 219 }
215 sess->se_sess->se_node_acl = &acl->se_node_acl; 220
221 se_acl = core_tpg_get_initiator_node_acl(se_tpg, &initiatorname[0]);
222 if (!se_acl) {
223 transport_free_session(sess->se_sess);
224 kfree(sess);
225 return NULL;
226 }
227 sess->se_sess->se_node_acl = se_acl;
216 sess->tport = tport; 228 sess->tport = tport;
217 sess->port_id = port_id; 229 sess->port_id = port_id;
218 kref_init(&sess->kref); /* ref for table entry */ 230 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,
221 233
222 pr_debug("port_id %x sess %p\n", port_id, sess); 234 pr_debug("port_id %x sess %p\n", port_id, sess);
223 235
224 transport_register_session(&tport->tpg->se_tpg, &acl->se_node_acl, 236 transport_register_session(&tport->tpg->se_tpg, se_acl,
225 sess->se_sess, sess); 237 sess->se_sess, sess);
226 return sess; 238 return sess;
227} 239}
@@ -349,17 +361,12 @@ static int ft_prli_locked(struct fc_rport_priv *rdata, u32 spp_len,
349{ 361{
350 struct ft_tport *tport; 362 struct ft_tport *tport;
351 struct ft_sess *sess; 363 struct ft_sess *sess;
352 struct ft_node_acl *acl;
353 u32 fcp_parm; 364 u32 fcp_parm;
354 365
355 tport = ft_tport_get(rdata->local_port); 366 tport = ft_tport_get(rdata->local_port);
356 if (!tport) 367 if (!tport)
357 goto not_target; /* not a target for this local port */ 368 goto not_target; /* not a target for this local port */
358 369
359 acl = ft_acl_get(tport->tpg, rdata);
360 if (!acl)
361 goto not_target; /* no target for this remote */
362
363 if (!rspp) 370 if (!rspp)
364 goto fill; 371 goto fill;
365 372
@@ -381,7 +388,7 @@ static int ft_prli_locked(struct fc_rport_priv *rdata, u32 spp_len,
381 spp->spp_flags |= FC_SPP_EST_IMG_PAIR; 388 spp->spp_flags |= FC_SPP_EST_IMG_PAIR;
382 if (!(fcp_parm & FCP_SPPF_INIT_FCN)) 389 if (!(fcp_parm & FCP_SPPF_INIT_FCN))
383 return FC_SPP_RESP_CONF; 390 return FC_SPP_RESP_CONF;
384 sess = ft_sess_create(tport, rdata->ids.port_id, acl); 391 sess = ft_sess_create(tport, rdata->ids.port_id, rdata);
385 if (!sess) 392 if (!sess)
386 return FC_SPP_RESP_RES; 393 return FC_SPP_RESP_RES;
387 if (!sess->params) 394 if (!sess->params)