aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2015-04-13 13:51:16 -0400
committerNicholas Bellinger <nab@linux-iscsi.org>2015-05-31 01:42:23 -0400
commit144bc4c2a42a0f42a32c106d53f5bf2724fbf098 (patch)
tree1b1a1a6b0dabea88e6dcef368305c6bac3c33648
parente413f4727037e826c55a639c713a221006b6d61d (diff)
target: move node ACL allocation to core code
Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
-rwxr-xr-xDocumentation/target/tcm_mod_builder.py27
-rw-r--r--drivers/infiniband/ulp/srpt/ib_srpt.c25
-rw-r--r--drivers/infiniband/ulp/srpt/ib_srpt.h4
-rw-r--r--drivers/scsi/qla2xxx/tcm_qla2xxx.c29
-rw-r--r--drivers/scsi/qla2xxx/tcm_qla2xxx.h4
-rw-r--r--drivers/target/iscsi/iscsi_target_configfs.c26
-rw-r--r--drivers/target/loopback/tcm_loop.c15
-rw-r--r--drivers/target/sbp/sbp_target.c14
-rw-r--r--drivers/target/target_core_configfs.c8
-rw-r--r--drivers/target/target_core_tpg.c9
-rw-r--r--drivers/target/target_core_transport.c2
-rw-r--r--drivers/target/tcm_fc/tcm_fc.h2
-rw-r--r--drivers/target/tcm_fc/tfc_conf.c26
-rw-r--r--drivers/usb/gadget/legacy/tcm_usb_gadget.c14
-rw-r--r--drivers/vhost/scsi.c15
-rw-r--r--drivers/xen/xen-scsiback.c15
-rw-r--r--include/target/iscsi/iscsi_target_core.h2
-rw-r--r--include/target/target_core_fabric.h5
18 files changed, 18 insertions, 224 deletions
diff --git a/Documentation/target/tcm_mod_builder.py b/Documentation/target/tcm_mod_builder.py
index 3e54809b3aa1..07e7ef3d7429 100755
--- a/Documentation/target/tcm_mod_builder.py
+++ b/Documentation/target/tcm_mod_builder.py
@@ -313,8 +313,6 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
313 buf += " .tpg_check_demo_mode_cache = " + fabric_mod_name + "_check_true,\n" 313 buf += " .tpg_check_demo_mode_cache = " + fabric_mod_name + "_check_true,\n"
314 buf += " .tpg_check_demo_mode_write_protect = " + fabric_mod_name + "_check_true,\n" 314 buf += " .tpg_check_demo_mode_write_protect = " + fabric_mod_name + "_check_true,\n"
315 buf += " .tpg_check_prod_mode_write_protect = " + fabric_mod_name + "_check_false,\n" 315 buf += " .tpg_check_prod_mode_write_protect = " + fabric_mod_name + "_check_false,\n"
316 buf += " .tpg_alloc_fabric_acl = " + fabric_mod_name + "_alloc_fabric_acl,\n"
317 buf += " .tpg_release_fabric_acl = " + fabric_mod_name + "_release_fabric_acl,\n"
318 buf += " .tpg_get_inst_index = " + fabric_mod_name + "_tpg_get_inst_index,\n" 316 buf += " .tpg_get_inst_index = " + fabric_mod_name + "_tpg_get_inst_index,\n"
319 buf += " .release_cmd = " + fabric_mod_name + "_release_cmd,\n" 317 buf += " .release_cmd = " + fabric_mod_name + "_release_cmd,\n"
320 buf += " .shutdown_session = " + fabric_mod_name + "_shutdown_session,\n" 318 buf += " .shutdown_session = " + fabric_mod_name + "_shutdown_session,\n"
@@ -624,31 +622,6 @@ def tcm_mod_dump_fabric_ops(proto_ident, fabric_mod_dir_var, fabric_mod_name):
624 bufi += "char *" + fabric_mod_name + "_parse_pr_out_transport_id(struct se_portal_group *,\n" 622 bufi += "char *" + fabric_mod_name + "_parse_pr_out_transport_id(struct se_portal_group *,\n"
625 bufi += " const char *, u32 *, char **);\n" 623 bufi += " const char *, u32 *, char **);\n"
626 624
627 if re.search('alloc_fabric_acl\)\(', fo):
628 buf += "struct se_node_acl *" + fabric_mod_name + "_alloc_fabric_acl(struct se_portal_group *se_tpg)\n"
629 buf += "{\n"
630 buf += " struct " + fabric_mod_name + "_nacl *nacl;\n\n"
631 buf += " nacl = kzalloc(sizeof(struct " + fabric_mod_name + "_nacl), GFP_KERNEL);\n"
632 buf += " if (!nacl) {\n"
633 buf += " printk(KERN_ERR \"Unable to allocate struct " + fabric_mod_name + "_nacl\\n\");\n"
634 buf += " return NULL;\n"
635 buf += " }\n\n"
636 buf += " return &nacl->se_node_acl;\n"
637 buf += "}\n\n"
638 bufi += "struct se_node_acl *" + fabric_mod_name + "_alloc_fabric_acl(struct se_portal_group *);\n"
639
640 if re.search('release_fabric_acl\)\(', fo):
641 buf += "void " + fabric_mod_name + "_release_fabric_acl(\n"
642 buf += " struct se_portal_group *se_tpg,\n"
643 buf += " struct se_node_acl *se_nacl)\n"
644 buf += "{\n"
645 buf += " struct " + fabric_mod_name + "_nacl *nacl = container_of(se_nacl,\n"
646 buf += " struct " + fabric_mod_name + "_nacl, se_node_acl);\n"
647 buf += " kfree(nacl);\n"
648 buf += "}\n\n"
649 bufi += "void " + fabric_mod_name + "_release_fabric_acl(struct se_portal_group *,\n"
650 bufi += " struct se_node_acl *);\n"
651
652 if re.search('tpg_get_inst_index\)\(', fo): 625 if re.search('tpg_get_inst_index\)\(', fo):
653 buf += "u32 " + fabric_mod_name + "_tpg_get_inst_index(struct se_portal_group *se_tpg)\n" 626 buf += "u32 " + fabric_mod_name + "_tpg_get_inst_index(struct se_portal_group *se_tpg)\n"
654 buf += "{\n" 627 buf += "{\n"
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index c1f3aa52f42b..38e51f4a17de 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -3447,28 +3447,6 @@ static char *srpt_parse_pr_out_transport_id(struct se_portal_group *se_tpg,
3447 return (char *)tr_id->i_port_id; 3447 return (char *)tr_id->i_port_id;
3448} 3448}
3449 3449
3450static struct se_node_acl *srpt_alloc_fabric_acl(struct se_portal_group *se_tpg)
3451{
3452 struct srpt_node_acl *nacl;
3453
3454 nacl = kzalloc(sizeof(struct srpt_node_acl), GFP_KERNEL);
3455 if (!nacl) {
3456 pr_err("Unable to allocate struct srpt_node_acl\n");
3457 return NULL;
3458 }
3459
3460 return &nacl->nacl;
3461}
3462
3463static void srpt_release_fabric_acl(struct se_portal_group *se_tpg,
3464 struct se_node_acl *se_nacl)
3465{
3466 struct srpt_node_acl *nacl;
3467
3468 nacl = container_of(se_nacl, struct srpt_node_acl, nacl);
3469 kfree(nacl);
3470}
3471
3472static u32 srpt_tpg_get_inst_index(struct se_portal_group *se_tpg) 3450static u32 srpt_tpg_get_inst_index(struct se_portal_group *se_tpg)
3473{ 3451{
3474 return 1; 3452 return 1;
@@ -3883,6 +3861,7 @@ static struct configfs_attribute *srpt_wwn_attrs[] = {
3883static const struct target_core_fabric_ops srpt_template = { 3861static const struct target_core_fabric_ops srpt_template = {
3884 .module = THIS_MODULE, 3862 .module = THIS_MODULE,
3885 .name = "srpt", 3863 .name = "srpt",
3864 .node_acl_size = sizeof(struct srpt_node_acl),
3886 .get_fabric_name = srpt_get_fabric_name, 3865 .get_fabric_name = srpt_get_fabric_name,
3887 .get_fabric_proto_ident = srpt_get_fabric_proto_ident, 3866 .get_fabric_proto_ident = srpt_get_fabric_proto_ident,
3888 .tpg_get_wwn = srpt_get_fabric_wwn, 3867 .tpg_get_wwn = srpt_get_fabric_wwn,
@@ -3894,8 +3873,6 @@ static const struct target_core_fabric_ops srpt_template = {
3894 .tpg_check_demo_mode_cache = srpt_check_true, 3873 .tpg_check_demo_mode_cache = srpt_check_true,
3895 .tpg_check_demo_mode_write_protect = srpt_check_true, 3874 .tpg_check_demo_mode_write_protect = srpt_check_true,
3896 .tpg_check_prod_mode_write_protect = srpt_check_false, 3875 .tpg_check_prod_mode_write_protect = srpt_check_false,
3897 .tpg_alloc_fabric_acl = srpt_alloc_fabric_acl,
3898 .tpg_release_fabric_acl = srpt_release_fabric_acl,
3899 .tpg_get_inst_index = srpt_tpg_get_inst_index, 3876 .tpg_get_inst_index = srpt_tpg_get_inst_index,
3900 .release_cmd = srpt_release_cmd, 3877 .release_cmd = srpt_release_cmd,
3901 .check_stop_free = srpt_check_stop_free, 3878 .check_stop_free = srpt_check_stop_free,
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.h b/drivers/infiniband/ulp/srpt/ib_srpt.h
index 3dae156905de..355f6f5ce8b2 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.h
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.h
@@ -410,15 +410,15 @@ struct srpt_device {
410 410
411/** 411/**
412 * struct srpt_node_acl - Per-initiator ACL data (managed via configfs). 412 * struct srpt_node_acl - Per-initiator ACL data (managed via configfs).
413 * @nacl: Target core node ACL information.
413 * @i_port_id: 128-bit SRP initiator port ID. 414 * @i_port_id: 128-bit SRP initiator port ID.
414 * @sport: port information. 415 * @sport: port information.
415 * @nacl: Target core node ACL information.
416 * @list: Element of the per-HCA ACL list. 416 * @list: Element of the per-HCA ACL list.
417 */ 417 */
418struct srpt_node_acl { 418struct srpt_node_acl {
419 struct se_node_acl nacl;
419 u8 i_port_id[16]; 420 u8 i_port_id[16];
420 struct srpt_port *sport; 421 struct srpt_port *sport;
421 struct se_node_acl nacl;
422 struct list_head list; 422 struct list_head list;
423}; 423};
424 424
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index a7ab689f5524..cb376e5198d0 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -338,29 +338,6 @@ static int tcm_qla2xxx_check_prot_fabric_only(struct se_portal_group *se_tpg)
338 return tpg->tpg_attrib.fabric_prot_type; 338 return tpg->tpg_attrib.fabric_prot_type;
339} 339}
340 340
341static struct se_node_acl *tcm_qla2xxx_alloc_fabric_acl(
342 struct se_portal_group *se_tpg)
343{
344 struct tcm_qla2xxx_nacl *nacl;
345
346 nacl = kzalloc(sizeof(struct tcm_qla2xxx_nacl), GFP_KERNEL);
347 if (!nacl) {
348 pr_err("Unable to allocate struct tcm_qla2xxx_nacl\n");
349 return NULL;
350 }
351
352 return &nacl->se_node_acl;
353}
354
355static void tcm_qla2xxx_release_fabric_acl(
356 struct se_portal_group *se_tpg,
357 struct se_node_acl *se_nacl)
358{
359 struct tcm_qla2xxx_nacl *nacl = container_of(se_nacl,
360 struct tcm_qla2xxx_nacl, se_node_acl);
361 kfree(nacl);
362}
363
364static u32 tcm_qla2xxx_tpg_get_inst_index(struct se_portal_group *se_tpg) 341static u32 tcm_qla2xxx_tpg_get_inst_index(struct se_portal_group *se_tpg)
365{ 342{
366 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg, 343 struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
@@ -1949,6 +1926,7 @@ static struct configfs_attribute *tcm_qla2xxx_wwn_attrs[] = {
1949static const struct target_core_fabric_ops tcm_qla2xxx_ops = { 1926static const struct target_core_fabric_ops tcm_qla2xxx_ops = {
1950 .module = THIS_MODULE, 1927 .module = THIS_MODULE,
1951 .name = "qla2xxx", 1928 .name = "qla2xxx",
1929 .node_acl_size = sizeof(struct tcm_qla2xxx_nacl),
1952 .get_fabric_name = tcm_qla2xxx_get_fabric_name, 1930 .get_fabric_name = tcm_qla2xxx_get_fabric_name,
1953 .get_fabric_proto_ident = tcm_qla2xxx_get_fabric_proto_ident, 1931 .get_fabric_proto_ident = tcm_qla2xxx_get_fabric_proto_ident,
1954 .tpg_get_wwn = tcm_qla2xxx_get_fabric_wwn, 1932 .tpg_get_wwn = tcm_qla2xxx_get_fabric_wwn,
@@ -1964,8 +1942,6 @@ static const struct target_core_fabric_ops tcm_qla2xxx_ops = {
1964 tcm_qla2xxx_check_prod_write_protect, 1942 tcm_qla2xxx_check_prod_write_protect,
1965 .tpg_check_prot_fabric_only = tcm_qla2xxx_check_prot_fabric_only, 1943 .tpg_check_prot_fabric_only = tcm_qla2xxx_check_prot_fabric_only,
1966 .tpg_check_demo_mode_login_only = tcm_qla2xxx_check_demo_mode_login_only, 1944 .tpg_check_demo_mode_login_only = tcm_qla2xxx_check_demo_mode_login_only,
1967 .tpg_alloc_fabric_acl = tcm_qla2xxx_alloc_fabric_acl,
1968 .tpg_release_fabric_acl = tcm_qla2xxx_release_fabric_acl,
1969 .tpg_get_inst_index = tcm_qla2xxx_tpg_get_inst_index, 1945 .tpg_get_inst_index = tcm_qla2xxx_tpg_get_inst_index,
1970 .check_stop_free = tcm_qla2xxx_check_stop_free, 1946 .check_stop_free = tcm_qla2xxx_check_stop_free,
1971 .release_cmd = tcm_qla2xxx_release_cmd, 1947 .release_cmd = tcm_qla2xxx_release_cmd,
@@ -2001,6 +1977,7 @@ static const struct target_core_fabric_ops tcm_qla2xxx_ops = {
2001static const struct target_core_fabric_ops tcm_qla2xxx_npiv_ops = { 1977static const struct target_core_fabric_ops tcm_qla2xxx_npiv_ops = {
2002 .module = THIS_MODULE, 1978 .module = THIS_MODULE,
2003 .name = "qla2xxx_npiv", 1979 .name = "qla2xxx_npiv",
1980 .node_acl_size = sizeof(struct tcm_qla2xxx_nacl),
2004 .get_fabric_name = tcm_qla2xxx_npiv_get_fabric_name, 1981 .get_fabric_name = tcm_qla2xxx_npiv_get_fabric_name,
2005 .get_fabric_proto_ident = tcm_qla2xxx_get_fabric_proto_ident, 1982 .get_fabric_proto_ident = tcm_qla2xxx_get_fabric_proto_ident,
2006 .tpg_get_wwn = tcm_qla2xxx_get_fabric_wwn, 1983 .tpg_get_wwn = tcm_qla2xxx_get_fabric_wwn,
@@ -2014,8 +1991,6 @@ static const struct target_core_fabric_ops tcm_qla2xxx_npiv_ops = {
2014 .tpg_check_prod_mode_write_protect = 1991 .tpg_check_prod_mode_write_protect =
2015 tcm_qla2xxx_check_prod_write_protect, 1992 tcm_qla2xxx_check_prod_write_protect,
2016 .tpg_check_demo_mode_login_only = tcm_qla2xxx_check_demo_mode_login_only, 1993 .tpg_check_demo_mode_login_only = tcm_qla2xxx_check_demo_mode_login_only,
2017 .tpg_alloc_fabric_acl = tcm_qla2xxx_alloc_fabric_acl,
2018 .tpg_release_fabric_acl = tcm_qla2xxx_release_fabric_acl,
2019 .tpg_get_inst_index = tcm_qla2xxx_tpg_get_inst_index, 1994 .tpg_get_inst_index = tcm_qla2xxx_tpg_get_inst_index,
2020 .check_stop_free = tcm_qla2xxx_check_stop_free, 1995 .check_stop_free = tcm_qla2xxx_check_stop_free,
2021 .release_cmd = tcm_qla2xxx_release_cmd, 1996 .release_cmd = tcm_qla2xxx_release_cmd,
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.h b/drivers/scsi/qla2xxx/tcm_qla2xxx.h
index 23295115c9fc..3d805a07061c 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.h
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.h
@@ -13,6 +13,8 @@
13#include "qla_target.h" 13#include "qla_target.h"
14 14
15struct tcm_qla2xxx_nacl { 15struct tcm_qla2xxx_nacl {
16 struct se_node_acl se_node_acl;
17
16 /* From libfc struct fc_rport->port_id */ 18 /* From libfc struct fc_rport->port_id */
17 u32 nport_id; 19 u32 nport_id;
18 /* Binary World Wide unique Node Name for remote FC Initiator Nport */ 20 /* Binary World Wide unique Node Name for remote FC Initiator Nport */
@@ -23,8 +25,6 @@ struct tcm_qla2xxx_nacl {
23 struct qla_tgt_sess *qla_tgt_sess; 25 struct qla_tgt_sess *qla_tgt_sess;
24 /* Pointer to TCM FC nexus */ 26 /* Pointer to TCM FC nexus */
25 struct se_session *nport_nexus; 27 struct se_session *nport_nexus;
26 /* Returned by tcm_qla2xxx_make_nodeacl() */
27 struct se_node_acl se_node_acl;
28}; 28};
29 29
30struct tcm_qla2xxx_tpg_attrib { 30struct tcm_qla2xxx_tpg_attrib {
diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c
index 7d9ff8cbbb5d..643024c1ee8d 100644
--- a/drivers/target/iscsi/iscsi_target_configfs.c
+++ b/drivers/target/iscsi/iscsi_target_configfs.c
@@ -860,20 +860,6 @@ static struct configfs_attribute *lio_target_initiator_attrs[] = {
860 NULL, 860 NULL,
861}; 861};
862 862
863static struct se_node_acl *lio_tpg_alloc_fabric_acl(
864 struct se_portal_group *se_tpg)
865{
866 struct iscsi_node_acl *acl;
867
868 acl = kzalloc(sizeof(struct iscsi_node_acl), GFP_KERNEL);
869 if (!acl) {
870 pr_err("Unable to allocate memory for struct iscsi_node_acl\n");
871 return NULL;
872 }
873
874 return &acl->se_node_acl;
875}
876
877static int lio_target_init_nodeacl(struct se_node_acl *se_nacl, 863static int lio_target_init_nodeacl(struct se_node_acl *se_nacl,
878 const char *name) 864 const char *name)
879{ 865{
@@ -1868,15 +1854,6 @@ static int lio_tpg_check_prot_fabric_only(
1868 return tpg->tpg_attrib.fabric_prot_type; 1854 return tpg->tpg_attrib.fabric_prot_type;
1869} 1855}
1870 1856
1871static void lio_tpg_release_fabric_acl(
1872 struct se_portal_group *se_tpg,
1873 struct se_node_acl *se_acl)
1874{
1875 struct iscsi_node_acl *acl = container_of(se_acl,
1876 struct iscsi_node_acl, se_node_acl);
1877 kfree(acl);
1878}
1879
1880/* 1857/*
1881 * Called with spin_lock_bh(struct se_portal_group->session_lock) held.. 1858 * Called with spin_lock_bh(struct se_portal_group->session_lock) held..
1882 * 1859 *
@@ -1952,6 +1929,7 @@ static void lio_release_cmd(struct se_cmd *se_cmd)
1952const struct target_core_fabric_ops iscsi_ops = { 1929const struct target_core_fabric_ops iscsi_ops = {
1953 .module = THIS_MODULE, 1930 .module = THIS_MODULE,
1954 .name = "iscsi", 1931 .name = "iscsi",
1932 .node_acl_size = sizeof(struct iscsi_node_acl),
1955 .get_fabric_name = iscsi_get_fabric_name, 1933 .get_fabric_name = iscsi_get_fabric_name,
1956 .get_fabric_proto_ident = iscsi_get_fabric_proto_ident, 1934 .get_fabric_proto_ident = iscsi_get_fabric_proto_ident,
1957 .tpg_get_wwn = lio_tpg_get_endpoint_wwn, 1935 .tpg_get_wwn = lio_tpg_get_endpoint_wwn,
@@ -1967,8 +1945,6 @@ const struct target_core_fabric_ops iscsi_ops = {
1967 .tpg_check_prod_mode_write_protect = 1945 .tpg_check_prod_mode_write_protect =
1968 lio_tpg_check_prod_mode_write_protect, 1946 lio_tpg_check_prod_mode_write_protect,
1969 .tpg_check_prot_fabric_only = &lio_tpg_check_prot_fabric_only, 1947 .tpg_check_prot_fabric_only = &lio_tpg_check_prot_fabric_only,
1970 .tpg_alloc_fabric_acl = lio_tpg_alloc_fabric_acl,
1971 .tpg_release_fabric_acl = lio_tpg_release_fabric_acl,
1972 .tpg_get_inst_index = lio_tpg_get_inst_index, 1948 .tpg_get_inst_index = lio_tpg_get_inst_index,
1973 .check_stop_free = lio_check_stop_free, 1949 .check_stop_free = lio_check_stop_free,
1974 .release_cmd = lio_release_cmd, 1950 .release_cmd = lio_release_cmd,
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index 12b85b03e9ae..5a71c9f2ee66 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -698,19 +698,6 @@ static int tcm_loop_check_prot_fabric_only(struct se_portal_group *se_tpg)
698 return tl_tpg->tl_fabric_prot_type; 698 return tl_tpg->tl_fabric_prot_type;
699} 699}
700 700
701static struct se_node_acl *tcm_loop_tpg_alloc_fabric_acl(
702 struct se_portal_group *se_tpg)
703{
704 return kzalloc(sizeof(struct se_node_acl), GFP_KERNEL);
705}
706
707static void tcm_loop_tpg_release_fabric_acl(
708 struct se_portal_group *se_tpg,
709 struct se_node_acl *se_nacl)
710{
711 kfree(se_nacl);
712}
713
714static u32 tcm_loop_get_inst_index(struct se_portal_group *se_tpg) 701static u32 tcm_loop_get_inst_index(struct se_portal_group *se_tpg)
715{ 702{
716 return 1; 703 return 1;
@@ -1383,8 +1370,6 @@ static const struct target_core_fabric_ops loop_ops = {
1383 .tpg_check_prod_mode_write_protect = 1370 .tpg_check_prod_mode_write_protect =
1384 tcm_loop_check_prod_mode_write_protect, 1371 tcm_loop_check_prod_mode_write_protect,
1385 .tpg_check_prot_fabric_only = tcm_loop_check_prot_fabric_only, 1372 .tpg_check_prot_fabric_only = tcm_loop_check_prot_fabric_only,
1386 .tpg_alloc_fabric_acl = tcm_loop_tpg_alloc_fabric_acl,
1387 .tpg_release_fabric_acl = tcm_loop_tpg_release_fabric_acl,
1388 .tpg_get_inst_index = tcm_loop_get_inst_index, 1373 .tpg_get_inst_index = tcm_loop_get_inst_index,
1389 .check_stop_free = tcm_loop_check_stop_free, 1374 .check_stop_free = tcm_loop_check_stop_free,
1390 .release_cmd = tcm_loop_release_cmd, 1375 .release_cmd = tcm_loop_release_cmd,
diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
index 3a47fe46fbca..5df2a61714fb 100644
--- a/drivers/target/sbp/sbp_target.c
+++ b/drivers/target/sbp/sbp_target.c
@@ -1707,18 +1707,6 @@ static u16 sbp_get_tag(struct se_portal_group *se_tpg)
1707 return tpg->tport_tpgt; 1707 return tpg->tport_tpgt;
1708} 1708}
1709 1709
1710static struct se_node_acl *sbp_alloc_fabric_acl(struct se_portal_group *se_tpg)
1711{
1712 return kzalloc(sizeof(struct se_node_acl), GFP_KERNEL);
1713}
1714
1715static void sbp_release_fabric_acl(
1716 struct se_portal_group *se_tpg,
1717 struct se_node_acl *se_nacl)
1718{
1719 kfree(se_nacl);
1720}
1721
1722static u32 sbp_tpg_get_inst_index(struct se_portal_group *se_tpg) 1710static u32 sbp_tpg_get_inst_index(struct se_portal_group *se_tpg)
1723{ 1711{
1724 return 1; 1712 return 1;
@@ -2465,8 +2453,6 @@ static const struct target_core_fabric_ops sbp_ops = {
2465 .tpg_check_demo_mode_cache = sbp_check_true, 2453 .tpg_check_demo_mode_cache = sbp_check_true,
2466 .tpg_check_demo_mode_write_protect = sbp_check_false, 2454 .tpg_check_demo_mode_write_protect = sbp_check_false,
2467 .tpg_check_prod_mode_write_protect = sbp_check_false, 2455 .tpg_check_prod_mode_write_protect = sbp_check_false,
2468 .tpg_alloc_fabric_acl = sbp_alloc_fabric_acl,
2469 .tpg_release_fabric_acl = sbp_release_fabric_acl,
2470 .tpg_get_inst_index = sbp_tpg_get_inst_index, 2456 .tpg_get_inst_index = sbp_tpg_get_inst_index,
2471 .release_cmd = sbp_release_cmd, 2457 .release_cmd = sbp_release_cmd,
2472 .shutdown_session = sbp_shutdown_session, 2458 .shutdown_session = sbp_shutdown_session,
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index c87ca0c50545..2b10499264d3 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -354,14 +354,6 @@ static int target_fabric_tf_ops_check(const struct target_core_fabric_ops *tfo)
354 pr_err("Missing tfo->tpg_check_prod_mode_write_protect()\n"); 354 pr_err("Missing tfo->tpg_check_prod_mode_write_protect()\n");
355 return -EINVAL; 355 return -EINVAL;
356 } 356 }
357 if (!tfo->tpg_alloc_fabric_acl) {
358 pr_err("Missing tfo->tpg_alloc_fabric_acl()\n");
359 return -EINVAL;
360 }
361 if (!tfo->tpg_release_fabric_acl) {
362 pr_err("Missing tfo->tpg_release_fabric_acl()\n");
363 return -EINVAL;
364 }
365 if (!tfo->tpg_get_inst_index) { 357 if (!tfo->tpg_get_inst_index) {
366 pr_err("Missing tfo->tpg_get_inst_index()\n"); 358 pr_err("Missing tfo->tpg_get_inst_index()\n");
367 return -EINVAL; 359 return -EINVAL;
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index 0cd86ff9a792..42f3bd9561c8 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -259,7 +259,8 @@ static struct se_node_acl *target_alloc_node_acl(struct se_portal_group *tpg,
259{ 259{
260 struct se_node_acl *acl; 260 struct se_node_acl *acl;
261 261
262 acl = tpg->se_tpg_tfo->tpg_alloc_fabric_acl(tpg); 262 acl = kzalloc(max(sizeof(*acl), tpg->se_tpg_tfo->node_acl_size),
263 GFP_KERNEL);
263 if (!acl) 264 if (!acl)
264 return NULL; 265 return NULL;
265 266
@@ -290,7 +291,7 @@ static struct se_node_acl *target_alloc_node_acl(struct se_portal_group *tpg,
290out_free_device_list: 291out_free_device_list:
291 core_free_device_list_for_node(acl, tpg); 292 core_free_device_list_for_node(acl, tpg);
292out_free_acl: 293out_free_acl:
293 tpg->se_tpg_tfo->tpg_release_fabric_acl(tpg, acl); 294 kfree(acl);
294 return NULL; 295 return NULL;
295} 296}
296 297
@@ -461,7 +462,7 @@ void core_tpg_del_initiator_node_acl(struct se_node_acl *acl)
461 tpg->se_tpg_tfo->tpg_get_tag(tpg), acl->queue_depth, 462 tpg->se_tpg_tfo->tpg_get_tag(tpg), acl->queue_depth,
462 tpg->se_tpg_tfo->get_fabric_name(), acl->initiatorname); 463 tpg->se_tpg_tfo->get_fabric_name(), acl->initiatorname);
463 464
464 tpg->se_tpg_tfo->tpg_release_fabric_acl(tpg, acl); 465 kfree(acl);
465} 466}
466 467
467/* core_tpg_set_initiator_node_queue_depth(): 468/* core_tpg_set_initiator_node_queue_depth():
@@ -725,7 +726,7 @@ int core_tpg_deregister(struct se_portal_group *se_tpg)
725 726
726 core_tpg_wait_for_nacl_pr_ref(nacl); 727 core_tpg_wait_for_nacl_pr_ref(nacl);
727 core_free_device_list_for_node(nacl, se_tpg); 728 core_free_device_list_for_node(nacl, se_tpg);
728 se_tpg->se_tpg_tfo->tpg_release_fabric_acl(se_tpg, nacl); 729 kfree(nacl);
729 730
730 spin_lock_irq(&se_tpg->acl_node_lock); 731 spin_lock_irq(&se_tpg->acl_node_lock);
731 } 732 }
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 9dc1bd5f0e6b..0fc4f5cb4bea 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -533,7 +533,7 @@ void transport_deregister_session(struct se_session *se_sess)
533 spin_unlock_irqrestore(&se_tpg->acl_node_lock, flags); 533 spin_unlock_irqrestore(&se_tpg->acl_node_lock, flags);
534 core_tpg_wait_for_nacl_pr_ref(se_nacl); 534 core_tpg_wait_for_nacl_pr_ref(se_nacl);
535 core_free_device_list_for_node(se_nacl, se_tpg); 535 core_free_device_list_for_node(se_nacl, se_tpg);
536 se_tfo->tpg_release_fabric_acl(se_tpg, se_nacl); 536 kfree(se_nacl);
537 537
538 comp_nacl = false; 538 comp_nacl = false;
539 spin_lock_irqsave(&se_tpg->acl_node_lock, flags); 539 spin_lock_irqsave(&se_tpg->acl_node_lock, flags);
diff --git a/drivers/target/tcm_fc/tcm_fc.h b/drivers/target/tcm_fc/tcm_fc.h
index 881deb3d499a..4ceaeb9a4b93 100644
--- a/drivers/target/tcm_fc/tcm_fc.h
+++ b/drivers/target/tcm_fc/tcm_fc.h
@@ -80,8 +80,8 @@ struct ft_node_auth {
80 * Node ACL for FC remote port session. 80 * Node ACL for FC remote port session.
81 */ 81 */
82struct ft_node_acl { 82struct ft_node_acl {
83 struct ft_node_auth node_auth;
84 struct se_node_acl se_node_acl; 83 struct se_node_acl se_node_acl;
84 struct ft_node_auth node_auth;
85}; 85};
86 86
87struct ft_lun { 87struct ft_lun {
diff --git a/drivers/target/tcm_fc/tfc_conf.c b/drivers/target/tcm_fc/tfc_conf.c
index e179fdf76ddb..8da159352315 100644
--- a/drivers/target/tcm_fc/tfc_conf.c
+++ b/drivers/target/tcm_fc/tfc_conf.c
@@ -236,29 +236,6 @@ struct ft_node_acl *ft_acl_get(struct ft_tpg *tpg, struct fc_rport_priv *rdata)
236 return found; 236 return found;
237} 237}
238 238
239static struct se_node_acl *ft_tpg_alloc_fabric_acl(struct se_portal_group *se_tpg)
240{
241 struct ft_node_acl *acl;
242
243 acl = kzalloc(sizeof(*acl), GFP_KERNEL);
244 if (!acl) {
245 pr_err("Unable to allocate struct ft_node_acl\n");
246 return NULL;
247 }
248 pr_debug("acl %p\n", acl);
249 return &acl->se_node_acl;
250}
251
252static void ft_tpg_release_fabric_acl(struct se_portal_group *se_tpg,
253 struct se_node_acl *se_acl)
254{
255 struct ft_node_acl *acl = container_of(se_acl,
256 struct ft_node_acl, se_node_acl);
257
258 pr_debug("acl %p\n", acl);
259 kfree(acl);
260}
261
262/* 239/*
263 * local_port port_group (tpg) ops. 240 * local_port port_group (tpg) ops.
264 */ 241 */
@@ -474,6 +451,7 @@ static u32 ft_tpg_get_inst_index(struct se_portal_group *se_tpg)
474static const struct target_core_fabric_ops ft_fabric_ops = { 451static const struct target_core_fabric_ops ft_fabric_ops = {
475 .module = THIS_MODULE, 452 .module = THIS_MODULE,
476 .name = "fc", 453 .name = "fc",
454 .node_acl_size = sizeof(struct ft_node_acl),
477 .get_fabric_name = ft_get_fabric_name, 455 .get_fabric_name = ft_get_fabric_name,
478 .get_fabric_proto_ident = fc_get_fabric_proto_ident, 456 .get_fabric_proto_ident = fc_get_fabric_proto_ident,
479 .tpg_get_wwn = ft_get_fabric_wwn, 457 .tpg_get_wwn = ft_get_fabric_wwn,
@@ -485,8 +463,6 @@ static const struct target_core_fabric_ops ft_fabric_ops = {
485 .tpg_check_demo_mode_cache = ft_check_false, 463 .tpg_check_demo_mode_cache = ft_check_false,
486 .tpg_check_demo_mode_write_protect = ft_check_false, 464 .tpg_check_demo_mode_write_protect = ft_check_false,
487 .tpg_check_prod_mode_write_protect = ft_check_false, 465 .tpg_check_prod_mode_write_protect = ft_check_false,
488 .tpg_alloc_fabric_acl = ft_tpg_alloc_fabric_acl,
489 .tpg_release_fabric_acl = ft_tpg_release_fabric_acl,
490 .tpg_get_inst_index = ft_tpg_get_inst_index, 466 .tpg_get_inst_index = ft_tpg_get_inst_index,
491 .check_stop_free = ft_check_stop_free, 467 .check_stop_free = ft_check_stop_free,
492 .release_cmd = ft_release_cmd, 468 .release_cmd = ft_release_cmd,
diff --git a/drivers/usb/gadget/legacy/tcm_usb_gadget.c b/drivers/usb/gadget/legacy/tcm_usb_gadget.c
index fccb0ccb355a..82f4da8bfe41 100644
--- a/drivers/usb/gadget/legacy/tcm_usb_gadget.c
+++ b/drivers/usb/gadget/legacy/tcm_usb_gadget.c
@@ -1373,18 +1373,6 @@ static char *usbg_parse_pr_out_transport_id(
1373 return tid; 1373 return tid;
1374} 1374}
1375 1375
1376static struct se_node_acl *usbg_alloc_fabric_acl(struct se_portal_group *se_tpg)
1377{
1378 return kzalloc(sizeof(struct se_node_acl), GFP_KERNEL);
1379}
1380
1381static void usbg_release_fabric_acl(
1382 struct se_portal_group *se_tpg,
1383 struct se_node_acl *se_nacl)
1384{
1385 kfree(se_nacl);
1386}
1387
1388static u32 usbg_tpg_get_inst_index(struct se_portal_group *se_tpg) 1376static u32 usbg_tpg_get_inst_index(struct se_portal_group *se_tpg)
1389{ 1377{
1390 return 1; 1378 return 1;
@@ -1825,8 +1813,6 @@ static const struct target_core_fabric_ops usbg_ops = {
1825 .tpg_check_demo_mode_cache = usbg_check_false, 1813 .tpg_check_demo_mode_cache = usbg_check_false,
1826 .tpg_check_demo_mode_write_protect = usbg_check_false, 1814 .tpg_check_demo_mode_write_protect = usbg_check_false,
1827 .tpg_check_prod_mode_write_protect = usbg_check_false, 1815 .tpg_check_prod_mode_write_protect = usbg_check_false,
1828 .tpg_alloc_fabric_acl = usbg_alloc_fabric_acl,
1829 .tpg_release_fabric_acl = usbg_release_fabric_acl,
1830 .tpg_get_inst_index = usbg_tpg_get_inst_index, 1816 .tpg_get_inst_index = usbg_tpg_get_inst_index,
1831 .release_cmd = usbg_release_cmd, 1817 .release_cmd = usbg_release_cmd,
1832 .shutdown_session = usbg_shutdown_session, 1818 .shutdown_session = usbg_shutdown_session,
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index 8faa7f4abf23..b93c03935964 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -425,19 +425,6 @@ static int vhost_scsi_check_prot_fabric_only(struct se_portal_group *se_tpg)
425 return tpg->tv_fabric_prot_type; 425 return tpg->tv_fabric_prot_type;
426} 426}
427 427
428static struct se_node_acl *
429vhost_scsi_alloc_fabric_acl(struct se_portal_group *se_tpg)
430{
431 return kzalloc(sizeof(struct se_node_acl), GFP_KERNEL);
432}
433
434static void
435vhost_scsi_release_fabric_acl(struct se_portal_group *se_tpg,
436 struct se_node_acl *se_nacl)
437{
438 kfree(se_nacl);
439}
440
441static u32 vhost_scsi_tpg_get_inst_index(struct se_portal_group *se_tpg) 428static u32 vhost_scsi_tpg_get_inst_index(struct se_portal_group *se_tpg)
442{ 429{
443 return 1; 430 return 1;
@@ -2268,8 +2255,6 @@ static struct target_core_fabric_ops vhost_scsi_ops = {
2268 .tpg_check_demo_mode_write_protect = vhost_scsi_check_false, 2255 .tpg_check_demo_mode_write_protect = vhost_scsi_check_false,
2269 .tpg_check_prod_mode_write_protect = vhost_scsi_check_false, 2256 .tpg_check_prod_mode_write_protect = vhost_scsi_check_false,
2270 .tpg_check_prot_fabric_only = vhost_scsi_check_prot_fabric_only, 2257 .tpg_check_prot_fabric_only = vhost_scsi_check_prot_fabric_only,
2271 .tpg_alloc_fabric_acl = vhost_scsi_alloc_fabric_acl,
2272 .tpg_release_fabric_acl = vhost_scsi_release_fabric_acl,
2273 .tpg_get_inst_index = vhost_scsi_tpg_get_inst_index, 2258 .tpg_get_inst_index = vhost_scsi_tpg_get_inst_index,
2274 .release_cmd = vhost_scsi_release_cmd, 2259 .release_cmd = vhost_scsi_release_cmd,
2275 .check_stop_free = vhost_scsi_check_stop_free, 2260 .check_stop_free = vhost_scsi_check_stop_free,
diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
index 8a130ab71733..3756953b385b 100644
--- a/drivers/xen/xen-scsiback.c
+++ b/drivers/xen/xen-scsiback.c
@@ -1449,19 +1449,6 @@ static void scsiback_drop_tport(struct se_wwn *wwn)
1449 kfree(tport); 1449 kfree(tport);
1450} 1450}
1451 1451
1452static struct se_node_acl *
1453scsiback_alloc_fabric_acl(struct se_portal_group *se_tpg)
1454{
1455 return kzalloc(sizeof(struct se_node_acl), GFP_KERNEL);
1456}
1457
1458static void
1459scsiback_release_fabric_acl(struct se_portal_group *se_tpg,
1460 struct se_node_acl *se_nacl)
1461{
1462 kfree(se_nacl);
1463}
1464
1465static u32 scsiback_tpg_get_inst_index(struct se_portal_group *se_tpg) 1452static u32 scsiback_tpg_get_inst_index(struct se_portal_group *se_tpg)
1466{ 1453{
1467 return 1; 1454 return 1;
@@ -1952,8 +1939,6 @@ static const struct target_core_fabric_ops scsiback_ops = {
1952 .tpg_check_demo_mode_cache = scsiback_check_true, 1939 .tpg_check_demo_mode_cache = scsiback_check_true,
1953 .tpg_check_demo_mode_write_protect = scsiback_check_false, 1940 .tpg_check_demo_mode_write_protect = scsiback_check_false,
1954 .tpg_check_prod_mode_write_protect = scsiback_check_false, 1941 .tpg_check_prod_mode_write_protect = scsiback_check_false,
1955 .tpg_alloc_fabric_acl = scsiback_alloc_fabric_acl,
1956 .tpg_release_fabric_acl = scsiback_release_fabric_acl,
1957 .tpg_get_inst_index = scsiback_tpg_get_inst_index, 1942 .tpg_get_inst_index = scsiback_tpg_get_inst_index,
1958 .check_stop_free = scsiback_check_stop_free, 1943 .check_stop_free = scsiback_check_stop_free,
1959 .release_cmd = scsiback_release_cmd, 1944 .release_cmd = scsiback_release_cmd,
diff --git a/include/target/iscsi/iscsi_target_core.h b/include/target/iscsi/iscsi_target_core.h
index 39f3d181d39d..f7b16ca67504 100644
--- a/include/target/iscsi/iscsi_target_core.h
+++ b/include/target/iscsi/iscsi_target_core.h
@@ -745,10 +745,10 @@ struct iscsi_node_stat_grps {
745}; 745};
746 746
747struct iscsi_node_acl { 747struct iscsi_node_acl {
748 struct se_node_acl se_node_acl;
748 struct iscsi_node_attrib node_attrib; 749 struct iscsi_node_attrib node_attrib;
749 struct iscsi_node_auth node_auth; 750 struct iscsi_node_auth node_auth;
750 struct iscsi_node_stat_grps node_stat_grps; 751 struct iscsi_node_stat_grps node_stat_grps;
751 struct se_node_acl se_node_acl;
752}; 752};
753 753
754struct iscsi_tpg_attrib { 754struct iscsi_tpg_attrib {
diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h
index 8b570c49f4d1..e5414744bf2d 100644
--- a/include/target/target_core_fabric.h
+++ b/include/target/target_core_fabric.h
@@ -4,6 +4,7 @@
4struct target_core_fabric_ops { 4struct target_core_fabric_ops {
5 struct module *module; 5 struct module *module;
6 const char *name; 6 const char *name;
7 size_t node_acl_size;
7 char *(*get_fabric_name)(void); 8 char *(*get_fabric_name)(void);
8 u8 (*get_fabric_proto_ident)(struct se_portal_group *); 9 u8 (*get_fabric_proto_ident)(struct se_portal_group *);
9 char *(*tpg_get_wwn)(struct se_portal_group *); 10 char *(*tpg_get_wwn)(struct se_portal_group *);
@@ -36,10 +37,6 @@ struct target_core_fabric_ops {
36 * WRITE_STRIP and READ_INSERT operations. 37 * WRITE_STRIP and READ_INSERT operations.
37 */ 38 */
38 int (*tpg_check_prot_fabric_only)(struct se_portal_group *); 39 int (*tpg_check_prot_fabric_only)(struct se_portal_group *);
39 struct se_node_acl *(*tpg_alloc_fabric_acl)(
40 struct se_portal_group *);
41 void (*tpg_release_fabric_acl)(struct se_portal_group *,
42 struct se_node_acl *);
43 u32 (*tpg_get_inst_index)(struct se_portal_group *); 40 u32 (*tpg_get_inst_index)(struct se_portal_group *);
44 /* 41 /*
45 * Optional to release struct se_cmd and fabric dependent allocated 42 * Optional to release struct se_cmd and fabric dependent allocated