Skip to content

Commit e4aae5a

Browse files
Christoph HellwigNicholas Bellinger
authored andcommitted
target: change core_tpg_register prototype
Remove the unneeded fabric_ptr argument, and change the type argument to pass in a SPC protocol identifier. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
1 parent 3868e43 commit e4aae5a

14 files changed

Lines changed: 38 additions & 50 deletions

File tree

‎Documentation/target/tcm_mod_builder.py‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,7 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
238238
buf += " tpg->" + fabric_mod_port + " = " + fabric_mod_port + ";\n"
239239
buf += " tpg->" + fabric_mod_port + "_tpgt = tpgt;\n\n"
240240
buf += " ret = core_tpg_register(&" + fabric_mod_name + "_ops, wwn,\n"
241-
buf += " &tpg->se_tpg, tpg,\n"
242-
buf += " TRANSPORT_TPG_TYPE_NORMAL);\n"
241+
buf += " &tpg->se_tpg, SCSI_PROTOCOL_SAS);\n"
243242
buf += " if (ret < 0) {\n"
244243
buf += " kfree(tpg);\n"
245244
buf += " return NULL;\n"

‎drivers/infiniband/ulp/srpt/ib_srpt.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3791,7 +3791,7 @@ static struct se_portal_group *srpt_make_tpg(struct se_wwn *wwn,
37913791

37923792
/* Initialize sport->port_wwn and sport->port_tpg_1 */
37933793
res = core_tpg_register(&srpt_template, &sport->port_wwn,
3794-
&sport->port_tpg_1, sport, TRANSPORT_TPG_TYPE_NORMAL);
3794+
&sport->port_tpg_1, SCSI_PROTOCOL_SRP);
37953795
if (res)
37963796
return ERR_PTR(res);
37973797

‎drivers/scsi/qla2xxx/tcm_qla2xxx.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,8 +1113,8 @@ static struct se_portal_group *tcm_qla2xxx_make_tpg(
11131113
tpg->tpg_attrib.cache_dynamic_acls = 1;
11141114
tpg->tpg_attrib.demo_mode_login_only = 1;
11151115

1116-
ret = core_tpg_register(&tcm_qla2xxx_ops, wwn,
1117-
&tpg->se_tpg, tpg, TRANSPORT_TPG_TYPE_NORMAL);
1116+
ret = core_tpg_register(&tcm_qla2xxx_ops, wwn, &tpg->se_tpg,
1117+
SCSI_PROTOCOL_FCP);
11181118
if (ret < 0) {
11191119
kfree(tpg);
11201120
return NULL;
@@ -1233,8 +1233,8 @@ static struct se_portal_group *tcm_qla2xxx_npiv_make_tpg(
12331233
tpg->tpg_attrib.cache_dynamic_acls = 1;
12341234
tpg->tpg_attrib.demo_mode_login_only = 1;
12351235

1236-
ret = core_tpg_register(&tcm_qla2xxx_npiv_ops, wwn,
1237-
&tpg->se_tpg, tpg, TRANSPORT_TPG_TYPE_NORMAL);
1236+
ret = core_tpg_register(&tcm_qla2xxx_npiv_ops, wwn, &tpg->se_tpg,
1237+
SCSI_PROTOCOL_FCP);
12381238
if (ret < 0) {
12391239
kfree(tpg);
12401240
return NULL;

‎drivers/target/iscsi/iscsi_target_configfs.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,7 @@ static struct se_portal_group *lio_target_tiqn_addtpg(
14211421
return NULL;
14221422

14231423
ret = core_tpg_register(&iscsi_ops, wwn, &tpg->tpg_se_tpg,
1424-
tpg, TRANSPORT_TPG_TYPE_NORMAL);
1424+
SCSI_PROTOCOL_ISCSI);
14251425
if (ret < 0)
14261426
return NULL;
14271427

‎drivers/target/iscsi/iscsi_target_tpg.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ int iscsit_load_discovery_tpg(void)
6868
return -1;
6969
}
7070

71-
ret = core_tpg_register(&iscsi_ops, NULL, &tpg->tpg_se_tpg,
72-
tpg, TRANSPORT_TPG_TYPE_DISCOVERY);
71+
ret = core_tpg_register(&iscsi_ops, NULL, &tpg->tpg_se_tpg, -1);
7372
if (ret < 0) {
7473
kfree(tpg);
7574
return -1;

‎drivers/target/loopback/tcm_loop.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1204,8 +1204,8 @@ static struct se_portal_group *tcm_loop_make_naa_tpg(
12041204
/*
12051205
* Register the tl_tpg as a emulated SAS TCM Target Endpoint
12061206
*/
1207-
ret = core_tpg_register(&loop_ops, wwn, &tl_tpg->tl_se_tpg, tl_tpg,
1208-
TRANSPORT_TPG_TYPE_NORMAL);
1207+
ret = core_tpg_register(&loop_ops, wwn, &tl_tpg->tl_se_tpg,
1208+
tl_hba->tl_proto_id);
12091209
if (ret < 0)
12101210
return ERR_PTR(-ENOMEM);
12111211

‎drivers/target/sbp/sbp_target.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2152,8 +2152,7 @@ static struct se_portal_group *sbp_make_tpg(
21522152
goto out_free_tpg;
21532153
}
21542154

2155-
ret = core_tpg_register(&sbp_ops, wwn, &tpg->se_tpg, tpg,
2156-
TRANSPORT_TPG_TYPE_NORMAL);
2155+
ret = core_tpg_register(&sbp_ops, wwn, &tpg->se_tpg, SCSI_PROTOCOL_SBP);
21572156
if (ret < 0)
21582157
goto out_unreg_mgt_agt;
21592158

‎drivers/target/target_core_tpg.c‎

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -634,8 +634,7 @@ int core_tpg_register(
634634
const struct target_core_fabric_ops *tfo,
635635
struct se_wwn *se_wwn,
636636
struct se_portal_group *se_tpg,
637-
void *tpg_fabric_ptr,
638-
int se_tpg_type)
637+
int proto_id)
639638
{
640639
struct se_lun *lun;
641640
u32 i;
@@ -661,8 +660,7 @@ int core_tpg_register(
661660
init_completion(&lun->lun_ref_comp);
662661
}
663662

664-
se_tpg->se_tpg_type = se_tpg_type;
665-
se_tpg->se_tpg_fabric_ptr = tpg_fabric_ptr;
663+
se_tpg->proto_id = proto_id;
666664
se_tpg->se_tpg_tfo = tfo;
667665
se_tpg->se_tpg_wwn = se_wwn;
668666
atomic_set(&se_tpg->tpg_pr_ref_count, 0);
@@ -673,7 +671,7 @@ int core_tpg_register(
673671
spin_lock_init(&se_tpg->session_lock);
674672
spin_lock_init(&se_tpg->tpg_lun_lock);
675673

676-
if (se_tpg->se_tpg_type == TRANSPORT_TPG_TYPE_NORMAL) {
674+
if (se_tpg->proto_id >= 0) {
677675
if (core_tpg_setup_virtual_lun0(se_tpg) < 0) {
678676
array_free(se_tpg->tpg_lun_list,
679677
TRANSPORT_MAX_LUNS_PER_TPG);
@@ -685,26 +683,24 @@ int core_tpg_register(
685683
list_add_tail(&se_tpg->se_tpg_node, &tpg_list);
686684
spin_unlock_bh(&tpg_lock);
687685

688-
pr_debug("TARGET_CORE[%s]: Allocated %s struct se_portal_group for"
689-
" endpoint: %s, Portal Tag: %u\n", tfo->get_fabric_name(),
690-
(se_tpg->se_tpg_type == TRANSPORT_TPG_TYPE_NORMAL) ?
691-
"Normal" : "Discovery", (tfo->tpg_get_wwn(se_tpg) == NULL) ?
692-
"None" : tfo->tpg_get_wwn(se_tpg), tfo->tpg_get_tag(se_tpg));
686+
pr_debug("TARGET_CORE[%s]: Allocated portal_group for endpoint: %s, "
687+
"Proto: %d, Portal Tag: %u\n", tfo->get_fabric_name(),
688+
tfo->tpg_get_wwn(se_tpg) ? tfo->tpg_get_wwn(se_tpg) : NULL,
689+
se_tpg->proto_id, tfo->tpg_get_tag(se_tpg));
693690

694691
return 0;
695692
}
696693
EXPORT_SYMBOL(core_tpg_register);
697694

698695
int core_tpg_deregister(struct se_portal_group *se_tpg)
699696
{
697+
const struct target_core_fabric_ops *tfo = se_tpg->se_tpg_tfo;
700698
struct se_node_acl *nacl, *nacl_tmp;
701699

702-
pr_debug("TARGET_CORE[%s]: Deallocating %s struct se_portal_group"
703-
" for endpoint: %s Portal Tag %u\n",
704-
(se_tpg->se_tpg_type == TRANSPORT_TPG_TYPE_NORMAL) ?
705-
"Normal" : "Discovery", se_tpg->se_tpg_tfo->get_fabric_name(),
706-
se_tpg->se_tpg_tfo->tpg_get_wwn(se_tpg),
707-
se_tpg->se_tpg_tfo->tpg_get_tag(se_tpg));
700+
pr_debug("TARGET_CORE[%s]: Deallocating portal_group for endpoint: %s, "
701+
"Proto: %d, Portal Tag: %u\n", tfo->get_fabric_name(),
702+
tfo->tpg_get_wwn(se_tpg) ? tfo->tpg_get_wwn(se_tpg) : NULL,
703+
se_tpg->proto_id, tfo->tpg_get_tag(se_tpg));
708704

709705
spin_lock_bh(&tpg_lock);
710706
list_del(&se_tpg->se_tpg_node);
@@ -732,10 +728,9 @@ int core_tpg_deregister(struct se_portal_group *se_tpg)
732728
}
733729
spin_unlock_irq(&se_tpg->acl_node_lock);
734730

735-
if (se_tpg->se_tpg_type == TRANSPORT_TPG_TYPE_NORMAL)
731+
if (se_tpg->proto_id >= 0)
736732
core_tpg_remove_lun(se_tpg, &se_tpg->tpg_virt_lun0);
737733

738-
se_tpg->se_tpg_fabric_ptr = NULL;
739734
array_free(se_tpg->tpg_lun_list, TRANSPORT_MAX_LUNS_PER_TPG);
740735
return 0;
741736
}

‎drivers/target/tcm_fc/tfc_conf.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ static struct se_portal_group *ft_add_tpg(
284284
}
285285

286286
ret = core_tpg_register(&ft_fabric_ops, wwn, &tpg->se_tpg,
287-
tpg, TRANSPORT_TPG_TYPE_NORMAL);
287+
SCSI_PROTOCOL_FCP);
288288
if (ret < 0) {
289289
destroy_workqueue(wq);
290290
kfree(tpg);

‎drivers/usb/gadget/legacy/tcm_usb_gadget.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,8 +1508,8 @@ static struct se_portal_group *usbg_make_tpg(
15081508
tpg->tport = tport;
15091509
tpg->tport_tpgt = tpgt;
15101510

1511-
ret = core_tpg_register(&usbg_ops, wwn, &tpg->se_tpg, tpg,
1512-
TRANSPORT_TPG_TYPE_NORMAL);
1511+
ret = core_tpg_register(&usbg_ops, wwn, &tpg->se_tpg,
1512+
tport->tport_proto_id);
15131513
if (ret < 0) {
15141514
destroy_workqueue(tpg->workqueue);
15151515
kfree(tpg);

0 commit comments

Comments
 (0)