target: refactor init/drop_nodeacl methods
By always allocating and adding, respectively removing and freeing the se_node_acl structure in core code we can remove tons of repeated code in the init_nodeacl and drop_nodeacl routines. Additionally this now respects the get_default_queue_depth method in this code path as well. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
This commit is contained in:
parent
e1750d20e6
commit
c7d6a80392
|
@ -50,15 +50,6 @@ def tcm_mod_build_FC_include(fabric_mod_dir_var, fabric_mod_name):
|
|||
buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n"
|
||||
buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n"
|
||||
buf += "\n"
|
||||
buf += "struct " + fabric_mod_name + "_nacl {\n"
|
||||
buf += " /* Binary World Wide unique Port Name for FC Initiator Nport */\n"
|
||||
buf += " u64 nport_wwpn;\n"
|
||||
buf += " /* ASCII formatted WWPN for FC Initiator Nport */\n"
|
||||
buf += " char nport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n"
|
||||
buf += " /* Returned by " + fabric_mod_name + "_make_nodeacl() */\n"
|
||||
buf += " struct se_node_acl se_node_acl;\n"
|
||||
buf += "};\n"
|
||||
buf += "\n"
|
||||
buf += "struct " + fabric_mod_name + "_tpg {\n"
|
||||
buf += " /* FC lport target portal group tag for TCM */\n"
|
||||
buf += " u16 lport_tpgt;\n"
|
||||
|
@ -105,14 +96,6 @@ def tcm_mod_build_SAS_include(fabric_mod_dir_var, fabric_mod_name):
|
|||
buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n"
|
||||
buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n"
|
||||
buf += "\n"
|
||||
buf += "struct " + fabric_mod_name + "_nacl {\n"
|
||||
buf += " /* Binary World Wide unique Port Name for SAS Initiator port */\n"
|
||||
buf += " u64 iport_wwpn;\n"
|
||||
buf += " /* ASCII formatted WWPN for Sas Initiator port */\n"
|
||||
buf += " char iport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n"
|
||||
buf += " /* Returned by " + fabric_mod_name + "_make_nodeacl() */\n"
|
||||
buf += " struct se_node_acl se_node_acl;\n"
|
||||
buf += "};\n\n"
|
||||
buf += "struct " + fabric_mod_name + "_tpg {\n"
|
||||
buf += " /* SAS port target portal group tag for TCM */\n"
|
||||
buf += " u16 tport_tpgt;\n"
|
||||
|
@ -158,12 +141,6 @@ def tcm_mod_build_iSCSI_include(fabric_mod_dir_var, fabric_mod_name):
|
|||
buf = "#define " + fabric_mod_name.upper() + "_VERSION \"v0.1\"\n"
|
||||
buf += "#define " + fabric_mod_name.upper() + "_NAMELEN 32\n"
|
||||
buf += "\n"
|
||||
buf += "struct " + fabric_mod_name + "_nacl {\n"
|
||||
buf += " /* ASCII formatted InitiatorName */\n"
|
||||
buf += " char iport_name[" + fabric_mod_name.upper() + "_NAMELEN];\n"
|
||||
buf += " /* Returned by " + fabric_mod_name + "_make_nodeacl() */\n"
|
||||
buf += " struct se_node_acl se_node_acl;\n"
|
||||
buf += "};\n\n"
|
||||
buf += "struct " + fabric_mod_name + "_tpg {\n"
|
||||
buf += " /* iSCSI target portal group tag for TCM */\n"
|
||||
buf += " u16 tport_tpgt;\n"
|
||||
|
@ -239,54 +216,6 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
|
|||
|
||||
buf += "static const struct target_core_fabric_ops " + fabric_mod_name + "_ops;\n\n"
|
||||
|
||||
buf += "static struct se_node_acl *" + fabric_mod_name + "_make_nodeacl(\n"
|
||||
buf += " struct se_portal_group *se_tpg,\n"
|
||||
buf += " struct config_group *group,\n"
|
||||
buf += " const char *name)\n"
|
||||
buf += "{\n"
|
||||
buf += " struct se_node_acl *se_nacl, *se_nacl_new;\n"
|
||||
buf += " struct " + fabric_mod_name + "_nacl *nacl;\n"
|
||||
|
||||
if proto_ident == "FC" or proto_ident == "SAS":
|
||||
buf += " u64 wwpn = 0;\n"
|
||||
|
||||
buf += " u32 nexus_depth;\n\n"
|
||||
buf += " /* " + fabric_mod_name + "_parse_wwn(name, &wwpn, 1) < 0)\n"
|
||||
buf += " return ERR_PTR(-EINVAL); */\n"
|
||||
buf += " se_nacl_new = " + fabric_mod_name + "_alloc_fabric_acl(se_tpg);\n"
|
||||
buf += " if (!se_nacl_new)\n"
|
||||
buf += " return ERR_PTR(-ENOMEM);\n"
|
||||
buf += "//#warning FIXME: Hardcoded nexus depth in " + fabric_mod_name + "_make_nodeacl()\n"
|
||||
buf += " nexus_depth = 1;\n"
|
||||
buf += " /*\n"
|
||||
buf += " * se_nacl_new may be released by core_tpg_add_initiator_node_acl()\n"
|
||||
buf += " * when converting a NodeACL from demo mode -> explict\n"
|
||||
buf += " */\n"
|
||||
buf += " se_nacl = core_tpg_add_initiator_node_acl(se_tpg, se_nacl_new,\n"
|
||||
buf += " name, nexus_depth);\n"
|
||||
buf += " if (IS_ERR(se_nacl)) {\n"
|
||||
buf += " " + fabric_mod_name + "_release_fabric_acl(se_tpg, se_nacl_new);\n"
|
||||
buf += " return se_nacl;\n"
|
||||
buf += " }\n"
|
||||
buf += " /*\n"
|
||||
buf += " * Locate our struct " + fabric_mod_name + "_nacl and set the FC Nport WWPN\n"
|
||||
buf += " */\n"
|
||||
buf += " nacl = container_of(se_nacl, struct " + fabric_mod_name + "_nacl, se_node_acl);\n"
|
||||
|
||||
if proto_ident == "FC" or proto_ident == "SAS":
|
||||
buf += " nacl->" + fabric_mod_init_port + "_wwpn = wwpn;\n"
|
||||
|
||||
buf += " /* " + fabric_mod_name + "_format_wwn(&nacl->" + fabric_mod_init_port + "_name[0], " + fabric_mod_name.upper() + "_NAMELEN, wwpn); */\n\n"
|
||||
buf += " return se_nacl;\n"
|
||||
buf += "}\n\n"
|
||||
buf += "static void " + fabric_mod_name + "_drop_nodeacl(struct se_node_acl *se_acl)\n"
|
||||
buf += "{\n"
|
||||
buf += " struct " + fabric_mod_name + "_nacl *nacl = container_of(se_acl,\n"
|
||||
buf += " struct " + fabric_mod_name + "_nacl, se_node_acl);\n"
|
||||
buf += " core_tpg_del_initiator_node_acl(se_acl->se_tpg, se_acl, 1);\n"
|
||||
buf += " kfree(nacl);\n"
|
||||
buf += "}\n\n"
|
||||
|
||||
buf += "static struct se_portal_group *" + fabric_mod_name + "_make_tpg(\n"
|
||||
buf += " struct se_wwn *wwn,\n"
|
||||
buf += " struct config_group *group,\n"
|
||||
|
@ -408,12 +337,6 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
|
|||
buf += " .fabric_drop_wwn = " + fabric_mod_name + "_drop_" + fabric_mod_port + ",\n"
|
||||
buf += " .fabric_make_tpg = " + fabric_mod_name + "_make_tpg,\n"
|
||||
buf += " .fabric_drop_tpg = " + fabric_mod_name + "_drop_tpg,\n"
|
||||
buf += " .fabric_post_link = NULL,\n"
|
||||
buf += " .fabric_pre_unlink = NULL,\n"
|
||||
buf += " .fabric_make_np = NULL,\n"
|
||||
buf += " .fabric_drop_np = NULL,\n"
|
||||
buf += " .fabric_make_nodeacl = " + fabric_mod_name + "_make_nodeacl,\n"
|
||||
buf += " .fabric_drop_nodeacl = " + fabric_mod_name + "_drop_nodeacl,\n"
|
||||
buf += "\n"
|
||||
buf += " .tfc_wwn_attrs = " + fabric_mod_name + "_wwn_attrs;\n"
|
||||
buf += "};\n\n"
|
||||
|
|
|
@ -13,8 +13,8 @@ fabric skeleton, by simply using:
|
|||
This script will create a new drivers/target/$TCM_NEW_MOD/, and will do the following
|
||||
|
||||
*) Generate new API callers for drivers/target/target_core_fabric_configs.c logic
|
||||
->make_nodeacl(), ->drop_nodeacl(), ->make_tpg(), ->drop_tpg()
|
||||
->make_wwn(), ->drop_wwn(). These are created into $TCM_NEW_MOD/$TCM_NEW_MOD_configfs.c
|
||||
->make_tpg(), ->drop_tpg(), ->make_wwn(), ->drop_wwn(). These are created
|
||||
into $TCM_NEW_MOD/$TCM_NEW_MOD_configfs.c
|
||||
*) Generate basic infrastructure for loading/unloading LKMs and TCM/ConfigFS fabric module
|
||||
using a skeleton struct target_core_fabric_ops API template.
|
||||
*) Based on user defined T10 Proto_Ident for the new fabric module being built,
|
||||
|
|
|
@ -3592,40 +3592,19 @@ out:
|
|||
* configfs callback function invoked for
|
||||
* mkdir /sys/kernel/config/target/$driver/$port/$tpg/acls/$i_port_id
|
||||
*/
|
||||
static struct se_node_acl *srpt_make_nodeacl(struct se_portal_group *tpg,
|
||||
struct config_group *group,
|
||||
const char *name)
|
||||
static int srpt_init_nodeacl(struct se_node_acl *se_nacl, const char *name)
|
||||
{
|
||||
struct srpt_port *sport = container_of(tpg, struct srpt_port, port_tpg_1);
|
||||
struct se_node_acl *se_nacl, *se_nacl_new;
|
||||
struct srpt_node_acl *nacl;
|
||||
int ret = 0;
|
||||
u32 nexus_depth = 1;
|
||||
struct srpt_port *sport =
|
||||
container_of(se_nacl->se_tpg, struct srpt_port, port_tpg_1);
|
||||
struct srpt_node_acl *nacl =
|
||||
container_of(se_nacl, struct srpt_node_acl, nacl);
|
||||
u8 i_port_id[16];
|
||||
|
||||
if (srpt_parse_i_port_id(i_port_id, name) < 0) {
|
||||
pr_err("invalid initiator port ID %s\n", name);
|
||||
ret = -EINVAL;
|
||||
goto err;
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
se_nacl_new = srpt_alloc_fabric_acl(tpg);
|
||||
if (!se_nacl_new) {
|
||||
ret = -ENOMEM;
|
||||
goto err;
|
||||
}
|
||||
/*
|
||||
* nacl_new may be released by core_tpg_add_initiator_node_acl()
|
||||
* when converting a node ACL from demo mode to explict
|
||||
*/
|
||||
se_nacl = core_tpg_add_initiator_node_acl(tpg, se_nacl_new, name,
|
||||
nexus_depth);
|
||||
if (IS_ERR(se_nacl)) {
|
||||
ret = PTR_ERR(se_nacl);
|
||||
goto err;
|
||||
}
|
||||
/* Locate our struct srpt_node_acl and set sdev and i_port_id. */
|
||||
nacl = container_of(se_nacl, struct srpt_node_acl, nacl);
|
||||
memcpy(&nacl->i_port_id[0], &i_port_id[0], 16);
|
||||
nacl->sport = sport;
|
||||
|
||||
|
@ -3633,29 +3612,22 @@ static struct se_node_acl *srpt_make_nodeacl(struct se_portal_group *tpg,
|
|||
list_add_tail(&nacl->list, &sport->port_acl_list);
|
||||
spin_unlock_irq(&sport->port_acl_lock);
|
||||
|
||||
return se_nacl;
|
||||
err:
|
||||
return ERR_PTR(ret);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* configfs callback function invoked for
|
||||
* rmdir /sys/kernel/config/target/$driver/$port/$tpg/acls/$i_port_id
|
||||
*/
|
||||
static void srpt_drop_nodeacl(struct se_node_acl *se_nacl)
|
||||
static void srpt_cleanup_nodeacl(struct se_node_acl *se_nacl)
|
||||
{
|
||||
struct srpt_node_acl *nacl;
|
||||
struct srpt_device *sdev;
|
||||
struct srpt_port *sport;
|
||||
struct srpt_node_acl *nacl =
|
||||
container_of(se_nacl, struct srpt_node_acl, nacl);
|
||||
struct srpt_port *sport = nacl->sport;
|
||||
|
||||
nacl = container_of(se_nacl, struct srpt_node_acl, nacl);
|
||||
sport = nacl->sport;
|
||||
sdev = sport->sdev;
|
||||
spin_lock_irq(&sport->port_acl_lock);
|
||||
list_del(&nacl->list);
|
||||
spin_unlock_irq(&sport->port_acl_lock);
|
||||
core_tpg_del_initiator_node_acl(&sport->port_tpg_1, se_nacl, 1);
|
||||
srpt_release_fabric_acl(NULL, se_nacl);
|
||||
}
|
||||
|
||||
static ssize_t srpt_tpg_attrib_show_srp_max_rdma_size(
|
||||
|
@ -3948,12 +3920,8 @@ static const struct target_core_fabric_ops srpt_template = {
|
|||
.fabric_drop_wwn = srpt_drop_tport,
|
||||
.fabric_make_tpg = srpt_make_tpg,
|
||||
.fabric_drop_tpg = srpt_drop_tpg,
|
||||
.fabric_post_link = NULL,
|
||||
.fabric_pre_unlink = NULL,
|
||||
.fabric_make_np = NULL,
|
||||
.fabric_drop_np = NULL,
|
||||
.fabric_make_nodeacl = srpt_make_nodeacl,
|
||||
.fabric_drop_nodeacl = srpt_drop_nodeacl,
|
||||
.fabric_init_nodeacl = srpt_init_nodeacl,
|
||||
.fabric_cleanup_nodeacl = srpt_cleanup_nodeacl,
|
||||
|
||||
.tfc_wwn_attrs = srpt_wwn_attrs,
|
||||
.tfc_tpg_base_attrs = srpt_tpg_attrs,
|
||||
|
|
|
@ -847,53 +847,20 @@ static void tcm_qla2xxx_shutdown_sess(struct qla_tgt_sess *sess)
|
|||
target_sess_cmd_list_set_waiting(sess->se_sess);
|
||||
}
|
||||
|
||||
static struct se_node_acl *tcm_qla2xxx_make_nodeacl(
|
||||
struct se_portal_group *se_tpg,
|
||||
struct config_group *group,
|
||||
const char *name)
|
||||
static int tcm_qla2xxx_init_nodeacl(struct se_node_acl *se_nacl,
|
||||
const char *name)
|
||||
{
|
||||
struct se_node_acl *se_nacl, *se_nacl_new;
|
||||
struct tcm_qla2xxx_nacl *nacl;
|
||||
struct tcm_qla2xxx_nacl *nacl =
|
||||
container_of(se_nacl, struct tcm_qla2xxx_nacl, se_node_acl);
|
||||
u64 wwnn;
|
||||
u32 qla2xxx_nexus_depth;
|
||||
|
||||
if (tcm_qla2xxx_parse_wwn(name, &wwnn, 1) < 0)
|
||||
return ERR_PTR(-EINVAL);
|
||||
return -EINVAL;
|
||||
|
||||
se_nacl_new = tcm_qla2xxx_alloc_fabric_acl(se_tpg);
|
||||
if (!se_nacl_new)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
/* #warning FIXME: Hardcoded qla2xxx_nexus depth in tcm_qla2xxx_make_nodeacl */
|
||||
qla2xxx_nexus_depth = 1;
|
||||
|
||||
/*
|
||||
* se_nacl_new may be released by core_tpg_add_initiator_node_acl()
|
||||
* when converting a NodeACL from demo mode -> explict
|
||||
*/
|
||||
se_nacl = core_tpg_add_initiator_node_acl(se_tpg, se_nacl_new,
|
||||
name, qla2xxx_nexus_depth);
|
||||
if (IS_ERR(se_nacl)) {
|
||||
tcm_qla2xxx_release_fabric_acl(se_tpg, se_nacl_new);
|
||||
return se_nacl;
|
||||
}
|
||||
/*
|
||||
* Locate our struct tcm_qla2xxx_nacl and set the FC Nport WWPN
|
||||
*/
|
||||
nacl = container_of(se_nacl, struct tcm_qla2xxx_nacl, se_node_acl);
|
||||
nacl->nport_wwnn = wwnn;
|
||||
tcm_qla2xxx_format_wwn(&nacl->nport_name[0], TCM_QLA2XXX_NAMELEN, wwnn);
|
||||
|
||||
return se_nacl;
|
||||
}
|
||||
|
||||
static void tcm_qla2xxx_drop_nodeacl(struct se_node_acl *se_acl)
|
||||
{
|
||||
struct se_portal_group *se_tpg = se_acl->se_tpg;
|
||||
struct tcm_qla2xxx_nacl *nacl = container_of(se_acl,
|
||||
struct tcm_qla2xxx_nacl, se_node_acl);
|
||||
|
||||
core_tpg_del_initiator_node_acl(se_tpg, se_acl, 1);
|
||||
kfree(nacl);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Start items for tcm_qla2xxx_tpg_attrib_cit */
|
||||
|
@ -2024,12 +1991,7 @@ static const struct target_core_fabric_ops tcm_qla2xxx_ops = {
|
|||
.fabric_drop_wwn = tcm_qla2xxx_drop_lport,
|
||||
.fabric_make_tpg = tcm_qla2xxx_make_tpg,
|
||||
.fabric_drop_tpg = tcm_qla2xxx_drop_tpg,
|
||||
.fabric_post_link = NULL,
|
||||
.fabric_pre_unlink = NULL,
|
||||
.fabric_make_np = NULL,
|
||||
.fabric_drop_np = NULL,
|
||||
.fabric_make_nodeacl = tcm_qla2xxx_make_nodeacl,
|
||||
.fabric_drop_nodeacl = tcm_qla2xxx_drop_nodeacl,
|
||||
.fabric_init_nodeacl = tcm_qla2xxx_init_nodeacl,
|
||||
|
||||
.tfc_wwn_attrs = tcm_qla2xxx_wwn_attrs,
|
||||
.tfc_tpg_base_attrs = tcm_qla2xxx_tpg_attrs,
|
||||
|
@ -2079,12 +2041,7 @@ static const struct target_core_fabric_ops tcm_qla2xxx_npiv_ops = {
|
|||
.fabric_drop_wwn = tcm_qla2xxx_npiv_drop_lport,
|
||||
.fabric_make_tpg = tcm_qla2xxx_npiv_make_tpg,
|
||||
.fabric_drop_tpg = tcm_qla2xxx_drop_tpg,
|
||||
.fabric_post_link = NULL,
|
||||
.fabric_pre_unlink = NULL,
|
||||
.fabric_make_np = NULL,
|
||||
.fabric_drop_np = NULL,
|
||||
.fabric_make_nodeacl = tcm_qla2xxx_make_nodeacl,
|
||||
.fabric_drop_nodeacl = tcm_qla2xxx_drop_nodeacl,
|
||||
.fabric_init_nodeacl = tcm_qla2xxx_init_nodeacl,
|
||||
|
||||
.tfc_wwn_attrs = tcm_qla2xxx_wwn_attrs,
|
||||
.tfc_tpg_base_attrs = tcm_qla2xxx_npiv_tpg_attrs,
|
||||
|
|
|
@ -874,43 +874,19 @@ static struct se_node_acl *lio_tpg_alloc_fabric_acl(
|
|||
return &acl->se_node_acl;
|
||||
}
|
||||
|
||||
static struct se_node_acl *lio_target_make_nodeacl(
|
||||
struct se_portal_group *se_tpg,
|
||||
struct config_group *group,
|
||||
const char *name)
|
||||
static int lio_target_init_nodeacl(struct se_node_acl *se_nacl,
|
||||
const char *name)
|
||||
{
|
||||
struct config_group *stats_cg;
|
||||
struct iscsi_node_acl *acl;
|
||||
struct se_node_acl *se_nacl_new, *se_nacl;
|
||||
struct iscsi_portal_group *tpg = container_of(se_tpg,
|
||||
struct iscsi_portal_group, tpg_se_tpg);
|
||||
u32 cmdsn_depth;
|
||||
|
||||
se_nacl_new = lio_tpg_alloc_fabric_acl(se_tpg);
|
||||
if (!se_nacl_new)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
cmdsn_depth = tpg->tpg_attrib.default_cmdsn_depth;
|
||||
/*
|
||||
* se_nacl_new may be released by core_tpg_add_initiator_node_acl()
|
||||
* when converting a NdoeACL from demo mode -> explict
|
||||
*/
|
||||
se_nacl = core_tpg_add_initiator_node_acl(se_tpg, se_nacl_new,
|
||||
name, cmdsn_depth);
|
||||
if (IS_ERR(se_nacl))
|
||||
return se_nacl;
|
||||
|
||||
acl = container_of(se_nacl, struct iscsi_node_acl, se_node_acl);
|
||||
stats_cg = &se_nacl->acl_fabric_stat_group;
|
||||
struct iscsi_node_acl *acl =
|
||||
container_of(se_nacl, struct iscsi_node_acl, se_node_acl);
|
||||
struct config_group *stats_cg = &se_nacl->acl_fabric_stat_group;
|
||||
|
||||
stats_cg->default_groups = kmalloc(sizeof(struct config_group *) * 2,
|
||||
GFP_KERNEL);
|
||||
if (!stats_cg->default_groups) {
|
||||
pr_err("Unable to allocate memory for"
|
||||
" stats_cg->default_groups\n");
|
||||
core_tpg_del_initiator_node_acl(se_tpg, se_nacl, 1);
|
||||
kfree(acl);
|
||||
return ERR_PTR(-ENOMEM);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
stats_cg->default_groups[0] = &acl->node_stat_grps.iscsi_sess_stats_group;
|
||||
|
@ -918,13 +894,11 @@ static struct se_node_acl *lio_target_make_nodeacl(
|
|||
config_group_init_type_name(&acl->node_stat_grps.iscsi_sess_stats_group,
|
||||
"iscsi_sess_stats", &iscsi_stat_sess_cit);
|
||||
|
||||
return se_nacl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void lio_target_drop_nodeacl(
|
||||
struct se_node_acl *se_nacl)
|
||||
static void lio_target_cleanup_nodeacl( struct se_node_acl *se_nacl)
|
||||
{
|
||||
struct se_portal_group *se_tpg = se_nacl->se_tpg;
|
||||
struct iscsi_node_acl *acl = container_of(se_nacl,
|
||||
struct iscsi_node_acl, se_node_acl);
|
||||
struct config_item *df_item;
|
||||
|
@ -938,9 +912,6 @@ static void lio_target_drop_nodeacl(
|
|||
config_item_put(df_item);
|
||||
}
|
||||
kfree(stats_cg->default_groups);
|
||||
|
||||
core_tpg_del_initiator_node_acl(se_tpg, se_nacl, 1);
|
||||
kfree(acl);
|
||||
}
|
||||
|
||||
/* End items for lio_target_acl_cit */
|
||||
|
@ -2020,8 +1991,8 @@ const struct target_core_fabric_ops iscsi_ops = {
|
|||
.fabric_drop_tpg = lio_target_tiqn_deltpg,
|
||||
.fabric_make_np = lio_target_call_addnptotpg,
|
||||
.fabric_drop_np = lio_target_call_delnpfromtpg,
|
||||
.fabric_make_nodeacl = lio_target_make_nodeacl,
|
||||
.fabric_drop_nodeacl = lio_target_drop_nodeacl,
|
||||
.fabric_init_nodeacl = lio_target_init_nodeacl,
|
||||
.fabric_cleanup_nodeacl = lio_target_cleanup_nodeacl,
|
||||
|
||||
.tfc_discovery_attrs = lio_target_discovery_auth_attrs,
|
||||
.tfc_wwn_attrs = lio_target_wwn_attrs,
|
||||
|
|
|
@ -2085,40 +2085,13 @@ static ssize_t sbp_format_wwn(char *buf, size_t len, u64 wwn)
|
|||
return snprintf(buf, len, "%016llx", wwn);
|
||||
}
|
||||
|
||||
static struct se_node_acl *sbp_make_nodeacl(
|
||||
struct se_portal_group *se_tpg,
|
||||
struct config_group *group,
|
||||
const char *name)
|
||||
static int sbp_init_nodeacl(struct se_node_acl *se_nacl, const char *name)
|
||||
{
|
||||
struct se_node_acl *se_nacl, *se_nacl_new;
|
||||
u64 guid = 0;
|
||||
u32 nexus_depth = 1;
|
||||
|
||||
if (sbp_parse_wwn(name, &guid) < 0)
|
||||
return ERR_PTR(-EINVAL);
|
||||
|
||||
se_nacl_new = sbp_alloc_fabric_acl(se_tpg);
|
||||
if (!se_nacl_new)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
/*
|
||||
* se_nacl_new may be released by core_tpg_add_initiator_node_acl()
|
||||
* when converting a NodeACL from demo mode -> explict
|
||||
*/
|
||||
se_nacl = core_tpg_add_initiator_node_acl(se_tpg, se_nacl_new,
|
||||
name, nexus_depth);
|
||||
if (IS_ERR(se_nacl)) {
|
||||
sbp_release_fabric_acl(se_tpg, se_nacl_new);
|
||||
return se_nacl;
|
||||
}
|
||||
|
||||
return se_nacl;
|
||||
}
|
||||
|
||||
static void sbp_drop_nodeacl(struct se_node_acl *se_acl)
|
||||
{
|
||||
core_tpg_del_initiator_node_acl(se_acl->se_tpg, se_acl, 1);
|
||||
kfree(se_acl);
|
||||
return -EINVAL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sbp_post_link_lun(
|
||||
|
@ -2518,8 +2491,7 @@ static const struct target_core_fabric_ops sbp_ops = {
|
|||
.fabric_pre_unlink = sbp_pre_unlink_lun,
|
||||
.fabric_make_np = NULL,
|
||||
.fabric_drop_np = NULL,
|
||||
.fabric_make_nodeacl = sbp_make_nodeacl,
|
||||
.fabric_drop_nodeacl = sbp_drop_nodeacl,
|
||||
.fabric_init_nodeacl = sbp_init_nodeacl,
|
||||
|
||||
.tfc_wwn_attrs = sbp_wwn_attrs,
|
||||
.tfc_tpg_base_attrs = sbp_tpg_base_attrs,
|
||||
|
|
|
@ -458,10 +458,11 @@ static void target_fabric_nacl_base_release(struct config_item *item)
|
|||
{
|
||||
struct se_node_acl *se_nacl = container_of(to_config_group(item),
|
||||
struct se_node_acl, acl_group);
|
||||
struct se_portal_group *se_tpg = se_nacl->se_tpg;
|
||||
struct target_fabric_configfs *tf = se_tpg->se_tpg_wwn->wwn_tf;
|
||||
struct target_fabric_configfs *tf = se_nacl->se_tpg->se_tpg_wwn->wwn_tf;
|
||||
|
||||
tf->tf_ops.fabric_drop_nodeacl(se_nacl);
|
||||
if (tf->tf_ops.fabric_cleanup_nodeacl)
|
||||
tf->tf_ops.fabric_cleanup_nodeacl(se_nacl);
|
||||
core_tpg_del_initiator_node_acl(se_nacl);
|
||||
}
|
||||
|
||||
static struct configfs_item_operations target_fabric_nacl_base_item_ops = {
|
||||
|
@ -501,15 +502,18 @@ static struct config_group *target_fabric_make_nodeacl(
|
|||
struct se_node_acl *se_nacl;
|
||||
struct config_group *nacl_cg;
|
||||
|
||||
if (!tf->tf_ops.fabric_make_nodeacl) {
|
||||
pr_err("tf->tf_ops.fabric_make_nodeacl is NULL\n");
|
||||
return ERR_PTR(-ENOSYS);
|
||||
}
|
||||
|
||||
se_nacl = tf->tf_ops.fabric_make_nodeacl(se_tpg, group, name);
|
||||
se_nacl = core_tpg_add_initiator_node_acl(se_tpg, name);
|
||||
if (IS_ERR(se_nacl))
|
||||
return ERR_CAST(se_nacl);
|
||||
|
||||
if (tf->tf_ops.fabric_init_nodeacl) {
|
||||
int ret = tf->tf_ops.fabric_init_nodeacl(se_nacl, name);
|
||||
if (ret) {
|
||||
core_tpg_del_initiator_node_acl(se_nacl);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
}
|
||||
|
||||
nacl_cg = &se_nacl->acl_group;
|
||||
nacl_cg->default_groups = se_nacl->acl_default_groups;
|
||||
nacl_cg->default_groups[0] = &se_nacl->acl_attrib_group;
|
||||
|
|
|
@ -59,6 +59,9 @@ struct se_lun *core_tpg_alloc_lun(struct se_portal_group *, u32);
|
|||
int core_tpg_add_lun(struct se_portal_group *, struct se_lun *,
|
||||
u32, struct se_device *);
|
||||
void core_tpg_remove_lun(struct se_portal_group *, struct se_lun *);
|
||||
struct se_node_acl *core_tpg_add_initiator_node_acl(struct se_portal_group *tpg,
|
||||
const char *initiatorname);
|
||||
void core_tpg_del_initiator_node_acl(struct se_node_acl *acl);
|
||||
|
||||
/* target_core_transport.c */
|
||||
extern struct kmem_cache *se_tmr_req_cache;
|
||||
|
|
|
@ -353,17 +353,11 @@ void core_tpg_clear_object_luns(struct se_portal_group *tpg)
|
|||
}
|
||||
EXPORT_SYMBOL(core_tpg_clear_object_luns);
|
||||
|
||||
/* core_tpg_add_initiator_node_acl():
|
||||
*
|
||||
*
|
||||
*/
|
||||
struct se_node_acl *core_tpg_add_initiator_node_acl(
|
||||
struct se_portal_group *tpg,
|
||||
struct se_node_acl *se_nacl,
|
||||
const char *initiatorname,
|
||||
u32 queue_depth)
|
||||
const char *initiatorname)
|
||||
{
|
||||
struct se_node_acl *acl = NULL;
|
||||
struct se_node_acl *acl;
|
||||
|
||||
spin_lock_irq(&tpg->acl_node_lock);
|
||||
acl = __core_tpg_get_initiator_node_acl(tpg, initiatorname);
|
||||
|
@ -374,14 +368,6 @@ struct se_node_acl *core_tpg_add_initiator_node_acl(
|
|||
" for %s\n", tpg->se_tpg_tfo->get_fabric_name(),
|
||||
tpg->se_tpg_tfo->tpg_get_tag(tpg), initiatorname);
|
||||
spin_unlock_irq(&tpg->acl_node_lock);
|
||||
/*
|
||||
* Release the locally allocated struct se_node_acl
|
||||
* because * core_tpg_add_initiator_node_acl() returned
|
||||
* a pointer to an existing demo mode node ACL.
|
||||
*/
|
||||
if (se_nacl)
|
||||
tpg->se_tpg_tfo->tpg_release_fabric_acl(tpg,
|
||||
se_nacl);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -394,16 +380,11 @@ struct se_node_acl *core_tpg_add_initiator_node_acl(
|
|||
}
|
||||
spin_unlock_irq(&tpg->acl_node_lock);
|
||||
|
||||
if (!se_nacl) {
|
||||
acl = tpg->se_tpg_tfo->tpg_alloc_fabric_acl(tpg);
|
||||
if (!acl) {
|
||||
pr_err("struct se_node_acl pointer is NULL\n");
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
/*
|
||||
* For v4.x logic the se_node_acl_s is hanging off a fabric
|
||||
* dependent structure allocated via
|
||||
* struct target_core_fabric_ops->fabric_make_nodeacl()
|
||||
*/
|
||||
acl = se_nacl;
|
||||
|
||||
INIT_LIST_HEAD(&acl->acl_list);
|
||||
INIT_LIST_HEAD(&acl->acl_sess_list);
|
||||
|
@ -412,7 +393,10 @@ struct se_node_acl *core_tpg_add_initiator_node_acl(
|
|||
spin_lock_init(&acl->device_list_lock);
|
||||
spin_lock_init(&acl->nacl_sess_lock);
|
||||
atomic_set(&acl->acl_pr_ref_count, 0);
|
||||
acl->queue_depth = queue_depth;
|
||||
if (tpg->se_tpg_tfo->tpg_get_default_depth)
|
||||
acl->queue_depth = tpg->se_tpg_tfo->tpg_get_default_depth(tpg);
|
||||
else
|
||||
acl->queue_depth = 1;
|
||||
snprintf(acl->initiatorname, TRANSPORT_IQN_LEN, "%s", initiatorname);
|
||||
acl->se_tpg = tpg;
|
||||
acl->acl_index = scsi_get_new_index(SCSI_AUTH_INTR_INDEX);
|
||||
|
@ -443,17 +427,10 @@ done:
|
|||
|
||||
return acl;
|
||||
}
|
||||
EXPORT_SYMBOL(core_tpg_add_initiator_node_acl);
|
||||
|
||||
/* core_tpg_del_initiator_node_acl():
|
||||
*
|
||||
*
|
||||
*/
|
||||
int core_tpg_del_initiator_node_acl(
|
||||
struct se_portal_group *tpg,
|
||||
struct se_node_acl *acl,
|
||||
int force)
|
||||
void core_tpg_del_initiator_node_acl(struct se_node_acl *acl)
|
||||
{
|
||||
struct se_portal_group *tpg = acl->se_tpg;
|
||||
LIST_HEAD(sess_list);
|
||||
struct se_session *sess, *sess_tmp;
|
||||
unsigned long flags;
|
||||
|
@ -505,9 +482,8 @@ int core_tpg_del_initiator_node_acl(
|
|||
tpg->se_tpg_tfo->tpg_get_tag(tpg), acl->queue_depth,
|
||||
tpg->se_tpg_tfo->get_fabric_name(), acl->initiatorname);
|
||||
|
||||
return 0;
|
||||
tpg->se_tpg_tfo->tpg_release_fabric_acl(tpg, acl);
|
||||
}
|
||||
EXPORT_SYMBOL(core_tpg_del_initiator_node_acl);
|
||||
|
||||
/* core_tpg_set_initiator_node_queue_depth():
|
||||
*
|
||||
|
|
|
@ -198,48 +198,17 @@ static struct configfs_attribute *ft_nacl_base_attrs[] = {
|
|||
* Add ACL for an initiator. The ACL is named arbitrarily.
|
||||
* The port_name and/or node_name are attributes.
|
||||
*/
|
||||
static struct se_node_acl *ft_add_acl(
|
||||
struct se_portal_group *se_tpg,
|
||||
struct config_group *group,
|
||||
const char *name)
|
||||
static int ft_init_nodeacl(struct se_node_acl *nacl, const char *name)
|
||||
{
|
||||
struct ft_node_acl *acl;
|
||||
struct ft_tpg *tpg;
|
||||
struct ft_node_acl *acl =
|
||||
container_of(nacl, struct ft_node_acl, se_node_acl);
|
||||
u64 wwpn;
|
||||
u32 q_depth;
|
||||
|
||||
pr_debug("add acl %s\n", name);
|
||||
tpg = container_of(se_tpg, struct ft_tpg, se_tpg);
|
||||
|
||||
if (ft_parse_wwn(name, &wwpn, 1) < 0)
|
||||
return ERR_PTR(-EINVAL);
|
||||
return -EINVAL;
|
||||
|
||||
acl = kzalloc(sizeof(struct ft_node_acl), GFP_KERNEL);
|
||||
if (!acl)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
acl->node_auth.port_name = wwpn;
|
||||
|
||||
q_depth = 32; /* XXX bogus default - get from tpg? */
|
||||
return core_tpg_add_initiator_node_acl(&tpg->se_tpg,
|
||||
&acl->se_node_acl, name, q_depth);
|
||||
}
|
||||
|
||||
static void ft_del_acl(struct se_node_acl *se_acl)
|
||||
{
|
||||
struct se_portal_group *se_tpg = se_acl->se_tpg;
|
||||
struct ft_tpg *tpg;
|
||||
struct ft_node_acl *acl = container_of(se_acl,
|
||||
struct ft_node_acl, se_node_acl);
|
||||
|
||||
pr_debug("del acl %s\n",
|
||||
config_item_name(&se_acl->acl_group.cg_item));
|
||||
|
||||
tpg = container_of(se_tpg, struct ft_tpg, se_tpg);
|
||||
pr_debug("del acl %p se_acl %p tpg %p se_tpg %p\n",
|
||||
acl, se_acl, tpg, &tpg->se_tpg);
|
||||
|
||||
core_tpg_del_initiator_node_acl(&tpg->se_tpg, se_acl, 1);
|
||||
kfree(acl);
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct ft_node_acl *ft_acl_get(struct ft_tpg *tpg, struct fc_rport_priv *rdata)
|
||||
|
@ -542,12 +511,7 @@ static const struct target_core_fabric_ops ft_fabric_ops = {
|
|||
.fabric_drop_wwn = &ft_del_wwn,
|
||||
.fabric_make_tpg = &ft_add_tpg,
|
||||
.fabric_drop_tpg = &ft_del_tpg,
|
||||
.fabric_post_link = NULL,
|
||||
.fabric_pre_unlink = NULL,
|
||||
.fabric_make_np = NULL,
|
||||
.fabric_drop_np = NULL,
|
||||
.fabric_make_nodeacl = &ft_add_acl,
|
||||
.fabric_drop_nodeacl = &ft_del_acl,
|
||||
.fabric_init_nodeacl = &ft_init_nodeacl,
|
||||
|
||||
.tfc_wwn_attrs = ft_wwn_attrs,
|
||||
.tfc_tpg_nacl_base_attrs = ft_nacl_base_attrs,
|
||||
|
|
|
@ -1476,40 +1476,11 @@ static const char *usbg_check_wwn(const char *name)
|
|||
return n;
|
||||
}
|
||||
|
||||
static struct se_node_acl *usbg_make_nodeacl(
|
||||
struct se_portal_group *se_tpg,
|
||||
struct config_group *group,
|
||||
const char *name)
|
||||
static int usbg_init_nodeacl(struct se_node_acl *se_nacl, const char *name)
|
||||
{
|
||||
struct se_node_acl *se_nacl, *se_nacl_new;
|
||||
u32 nexus_depth;
|
||||
const char *wnn_name;
|
||||
|
||||
wnn_name = usbg_check_wwn(name);
|
||||
if (!wnn_name)
|
||||
return ERR_PTR(-EINVAL);
|
||||
se_nacl_new = usbg_alloc_fabric_acl(se_tpg);
|
||||
if (!(se_nacl_new))
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
nexus_depth = 1;
|
||||
/*
|
||||
* se_nacl_new may be released by core_tpg_add_initiator_node_acl()
|
||||
* when converting a NodeACL from demo mode -> explict
|
||||
*/
|
||||
se_nacl = core_tpg_add_initiator_node_acl(se_tpg, se_nacl_new,
|
||||
name, nexus_depth);
|
||||
if (IS_ERR(se_nacl)) {
|
||||
usbg_release_fabric_acl(se_tpg, se_nacl_new);
|
||||
return se_nacl;
|
||||
}
|
||||
return se_nacl;
|
||||
}
|
||||
|
||||
static void usbg_drop_nodeacl(struct se_node_acl *se_acl)
|
||||
{
|
||||
core_tpg_del_initiator_node_acl(se_acl->se_tpg, se_acl, 1);
|
||||
kfree(se_acl);
|
||||
if (!usbg_check_wwn(name))
|
||||
return -EINVAL;
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct usbg_tpg *the_only_tpg_I_currently_have;
|
||||
|
@ -1879,10 +1850,7 @@ static const struct target_core_fabric_ops usbg_ops = {
|
|||
.fabric_drop_tpg = usbg_drop_tpg,
|
||||
.fabric_post_link = usbg_port_link,
|
||||
.fabric_pre_unlink = usbg_port_unlink,
|
||||
.fabric_make_np = NULL,
|
||||
.fabric_drop_np = NULL,
|
||||
.fabric_make_nodeacl = usbg_make_nodeacl,
|
||||
.fabric_drop_nodeacl = usbg_drop_nodeacl,
|
||||
.fabric_init_nodeacl = usbg_init_nodeacl,
|
||||
|
||||
.tfc_wwn_attrs = usbg_wwn_attrs,
|
||||
.tfc_tpg_base_attrs = usbg_base_attrs,
|
||||
|
|
|
@ -1798,41 +1798,6 @@ static void vhost_scsi_port_unlink(struct se_portal_group *se_tpg,
|
|||
mutex_unlock(&vhost_scsi_mutex);
|
||||
}
|
||||
|
||||
static struct se_node_acl *
|
||||
vhost_scsi_make_nodeacl(struct se_portal_group *se_tpg,
|
||||
struct config_group *group,
|
||||
const char *name)
|
||||
{
|
||||
struct se_node_acl *se_nacl, *se_nacl_new;
|
||||
u32 nexus_depth;
|
||||
|
||||
/* vhost_scsi_parse_wwn(name, &wwpn, 1) < 0)
|
||||
return ERR_PTR(-EINVAL); */
|
||||
se_nacl_new = vhost_scsi_alloc_fabric_acl(se_tpg);
|
||||
if (!se_nacl_new)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
nexus_depth = 1;
|
||||
/*
|
||||
* se_nacl_new may be released by core_tpg_add_initiator_node_acl()
|
||||
* when converting a NodeACL from demo mode -> explict
|
||||
*/
|
||||
se_nacl = core_tpg_add_initiator_node_acl(se_tpg, se_nacl_new,
|
||||
name, nexus_depth);
|
||||
if (IS_ERR(se_nacl)) {
|
||||
vhost_scsi_release_fabric_acl(se_tpg, se_nacl_new);
|
||||
return se_nacl;
|
||||
}
|
||||
|
||||
return se_nacl;
|
||||
}
|
||||
|
||||
static void vhost_scsi_drop_nodeacl(struct se_node_acl *se_acl)
|
||||
{
|
||||
core_tpg_del_initiator_node_acl(se_acl->se_tpg, se_acl, 1);
|
||||
kfree(se_acl);
|
||||
}
|
||||
|
||||
static void vhost_scsi_free_cmd_map_res(struct vhost_scsi_nexus *nexus,
|
||||
struct se_session *se_sess)
|
||||
{
|
||||
|
@ -2330,10 +2295,6 @@ static struct target_core_fabric_ops vhost_scsi_ops = {
|
|||
.fabric_drop_tpg = vhost_scsi_drop_tpg,
|
||||
.fabric_post_link = vhost_scsi_port_link,
|
||||
.fabric_pre_unlink = vhost_scsi_port_unlink,
|
||||
.fabric_make_np = NULL,
|
||||
.fabric_drop_np = NULL,
|
||||
.fabric_make_nodeacl = vhost_scsi_make_nodeacl,
|
||||
.fabric_drop_nodeacl = vhost_scsi_drop_nodeacl,
|
||||
|
||||
.tfc_wwn_attrs = vhost_scsi_wwn_attrs,
|
||||
.tfc_tpg_base_attrs = vhost_scsi_tpg_attrs,
|
||||
|
|
|
@ -1980,12 +1980,6 @@ static const struct target_core_fabric_ops scsiback_ops = {
|
|||
.fabric_drop_tpg = scsiback_drop_tpg,
|
||||
.fabric_post_link = scsiback_port_link,
|
||||
.fabric_pre_unlink = scsiback_port_unlink,
|
||||
.fabric_make_np = NULL,
|
||||
.fabric_drop_np = NULL,
|
||||
#if 0
|
||||
.fabric_make_nodeacl = scsiback_make_nodeacl,
|
||||
.fabric_drop_nodeacl = scsiback_drop_nodeacl,
|
||||
#endif
|
||||
|
||||
.tfc_wwn_attrs = scsiback_wwn_attrs,
|
||||
.tfc_tpg_base_attrs = scsiback_tpg_attrs,
|
||||
|
|
|
@ -88,9 +88,8 @@ struct target_core_fabric_ops {
|
|||
struct se_tpg_np *(*fabric_make_np)(struct se_portal_group *,
|
||||
struct config_group *, const char *);
|
||||
void (*fabric_drop_np)(struct se_tpg_np *);
|
||||
struct se_node_acl *(*fabric_make_nodeacl)(struct se_portal_group *,
|
||||
struct config_group *, const char *);
|
||||
void (*fabric_drop_nodeacl)(struct se_node_acl *);
|
||||
int (*fabric_init_nodeacl)(struct se_node_acl *, const char *);
|
||||
void (*fabric_cleanup_nodeacl)(struct se_node_acl *);
|
||||
|
||||
struct configfs_attribute **tfc_discovery_attrs;
|
||||
struct configfs_attribute **tfc_wwn_attrs;
|
||||
|
@ -174,10 +173,6 @@ struct se_node_acl *core_tpg_get_initiator_node_acl(struct se_portal_group *tpg,
|
|||
struct se_node_acl *core_tpg_check_initiator_node_acl(struct se_portal_group *,
|
||||
unsigned char *);
|
||||
void core_tpg_clear_object_luns(struct se_portal_group *);
|
||||
struct se_node_acl *core_tpg_add_initiator_node_acl(struct se_portal_group *,
|
||||
struct se_node_acl *, const char *, u32);
|
||||
int core_tpg_del_initiator_node_acl(struct se_portal_group *,
|
||||
struct se_node_acl *, int);
|
||||
int core_tpg_set_initiator_node_queue_depth(struct se_portal_group *,
|
||||
unsigned char *, u32, int);
|
||||
int core_tpg_set_initiator_node_tag(struct se_portal_group *,
|
||||
|
|
Loading…
Reference in a new issue