Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9ac8928e authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Nicholas Bellinger
Browse files

target: simplify the target template registration API



Instead of calling target_fabric_configfs_init() +
target_fabric_configfs_register() / target_fabric_configfs_deregister()
target_fabric_configfs_free() from every target driver, rewrite the API
so that we have simple register/unregister functions that operate on
a const operations vector.

This patch also fixes a memory leak in several target drivers. Several
target drivers namely called target_fabric_configfs_deregister()
without calling target_fabric_configfs_free().

A large part of this patch is based on earlier changes from
Bart Van Assche <bart.vanassche@sandisk.com>.

(v2: Add a new TF_CIT_SETUP_DRV macro so that the core configfs code
can declare attributes as either core only or for drivers)

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarNicholas Bellinger <nab@linux-iscsi.org>
parent 2c336e3a
Loading
Loading
Loading
Loading
+12 −67
Original line number Diff line number Diff line
@@ -237,8 +237,7 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
	buf += "#include \"" + fabric_mod_name + "_base.h\"\n"
	buf += "#include \"" + fabric_mod_name + "_fabric.h\"\n\n"

	buf += "/* Local pointer to allocated TCM configfs fabric module */\n"
	buf += "struct target_fabric_configfs *" + fabric_mod_name + "_fabric_configfs;\n\n"
	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"
@@ -309,8 +308,8 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
	buf += "	}\n"
	buf += "	tpg->" + fabric_mod_port + " = " + fabric_mod_port + ";\n"
	buf += "	tpg->" + fabric_mod_port + "_tpgt = tpgt;\n\n"
	buf += "	ret = core_tpg_register(&" + fabric_mod_name + "_fabric_configfs->tf_ops, wwn,\n"
	buf += "				&tpg->se_tpg, (void *)tpg,\n"
	buf += "	ret = core_tpg_register(&" + fabric_mod_name + "_ops, wwn,\n"
	buf += "				&tpg->se_tpg, tpg,\n"
	buf += "				TRANSPORT_TPG_TYPE_NORMAL);\n"
	buf += "	if (ret < 0) {\n"
	buf += "		kfree(tpg);\n"
@@ -370,7 +369,10 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
	buf += "	NULL,\n"
	buf += "};\n\n"

	buf += "static struct target_core_fabric_ops " + fabric_mod_name + "_ops = {\n"
	buf += "static const struct target_core_fabric_ops " + fabric_mod_name + "_ops = {\n"
	buf += "	.module				= THIS_MODULE\n",
	buf += "	.name				= " + fabric_mod_name + ",\n"
	buf += "	.get_fabric_proto_ident		= " + fabric_mod_name + "_get_fabric_proto_ident,\n"
	buf += "	.get_fabric_name		= " + fabric_mod_name + "_get_fabric_name,\n"
	buf += "	.get_fabric_proto_ident		= " + fabric_mod_name + "_get_fabric_proto_ident,\n"
	buf += "	.tpg_get_wwn			= " + fabric_mod_name + "_get_fabric_wwn,\n"
@@ -413,75 +415,18 @@ def tcm_mod_build_configfs(proto_ident, fabric_mod_dir_var, fabric_mod_name):
	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\n"

	buf += "static int " + fabric_mod_name + "_register_configfs(void)\n"
	buf += "{\n"
	buf += "	struct target_fabric_configfs *fabric;\n"
	buf += "	int ret;\n\n"
	buf += "	printk(KERN_INFO \"" + fabric_mod_name.upper() + " fabric module %s on %s/%s\"\n"
	buf += "		\" on \"UTS_RELEASE\"\\n\"," + fabric_mod_name.upper() + "_VERSION, utsname()->sysname,\n"
	buf += "		utsname()->machine);\n"
	buf += "	/*\n"
	buf += "	 * Register the top level struct config_item_type with TCM core\n"
	buf += "	 */\n"
	buf += "	fabric = target_fabric_configfs_init(THIS_MODULE, \"" + fabric_mod_name + "\");\n"
	buf += "	if (IS_ERR(fabric)) {\n"
	buf += "		printk(KERN_ERR \"target_fabric_configfs_init() failed\\n\");\n"
	buf += "		return PTR_ERR(fabric);\n"
	buf += "	}\n"
	buf += "	/*\n"
	buf += "	 * Setup fabric->tf_ops from our local " + fabric_mod_name + "_ops\n"
	buf += "	 */\n"
	buf += "	fabric->tf_ops = " + fabric_mod_name + "_ops;\n"
	buf += "	/*\n"
	buf += "	 * Setup default attribute lists for various fabric->tf_cit_tmpl\n"
	buf += "	 */\n"
	buf += "	fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = " + fabric_mod_name + "_wwn_attrs;\n"
	buf += "	fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = NULL;\n"
	buf += "	fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = NULL;\n"
	buf += "	fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL;\n"
	buf += "	fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL;\n"
	buf += "	fabric->tf_cit_tmpl.tfc_tpg_nacl_base_cit.ct_attrs = NULL;\n"
	buf += "	fabric->tf_cit_tmpl.tfc_tpg_nacl_attrib_cit.ct_attrs = NULL;\n"
	buf += "	fabric->tf_cit_tmpl.tfc_tpg_nacl_auth_cit.ct_attrs = NULL;\n"
	buf += "	fabric->tf_cit_tmpl.tfc_tpg_nacl_param_cit.ct_attrs = NULL;\n"
	buf += "	/*\n"
	buf += "	 * Register the fabric for use within TCM\n"
	buf += "	 */\n"
	buf += "	ret = target_fabric_configfs_register(fabric);\n"
	buf += "	if (ret < 0) {\n"
	buf += "		printk(KERN_ERR \"target_fabric_configfs_register() failed\"\n"
	buf += "				\" for " + fabric_mod_name.upper() + "\\n\");\n"
	buf += "		return ret;\n"
	buf += "	}\n"
	buf += "	/*\n"
	buf += "	 * Setup our local pointer to *fabric\n"
	buf += "	 */\n"
	buf += "	" + fabric_mod_name + "_fabric_configfs = fabric;\n"
	buf += "	printk(KERN_INFO \"" +  fabric_mod_name.upper() + "[0] - Set fabric -> " + fabric_mod_name + "_fabric_configfs\\n\");\n"
	buf += "	return 0;\n"
	buf += "};\n\n"
	buf += "static void __exit " + fabric_mod_name + "_deregister_configfs(void)\n"
	buf += "{\n"
	buf += "	if (!" + fabric_mod_name + "_fabric_configfs)\n"
	buf += "		return;\n\n"
	buf += "	target_fabric_configfs_deregister(" + fabric_mod_name + "_fabric_configfs);\n"
	buf += "	" + fabric_mod_name + "_fabric_configfs = NULL;\n"
	buf += "	printk(KERN_INFO \"" +  fabric_mod_name.upper() + "[0] - Cleared " + fabric_mod_name + "_fabric_configfs\\n\");\n"
	buf += "\n"
	buf += "	.tfc_wwn_attrs			= " + fabric_mod_name + "_wwn_attrs;\n"
	buf += "};\n\n"

	buf += "static int __init " + fabric_mod_name + "_init(void)\n"
	buf += "{\n"
	buf += "	int ret;\n\n"
	buf += "	ret = " + fabric_mod_name + "_register_configfs();\n"
	buf += "	if (ret < 0)\n"
	buf += "		return ret;\n\n"
	buf += "	return 0;\n"
	buf += "	return target_register_template(" + fabric_mod_name + "_ops);\n"
	buf += "};\n\n"

	buf += "static void __exit " + fabric_mod_name + "_exit(void)\n"
	buf += "{\n"
	buf += "	" + fabric_mod_name + "_deregister_configfs();\n"
	buf += "	target_unregister_template(" + fabric_mod_name + "_ops);\n"
	buf += "};\n\n"

	buf += "MODULE_DESCRIPTION(\"" + fabric_mod_name.upper() + " series fabric driver\");\n"
+13 −36
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ MODULE_PARM_DESC(srpt_service_guid,
		 " instead of using the node_guid of the first HCA.");

static struct ib_client srpt_client;
static struct target_fabric_configfs *srpt_target;
static const struct target_core_fabric_ops srpt_template;
static void srpt_release_channel(struct srpt_rdma_ch *ch);
static int srpt_queue_status(struct se_cmd *cmd);

@@ -3851,7 +3851,7 @@ static struct se_portal_group *srpt_make_tpg(struct se_wwn *wwn,
	int res;

	/* Initialize sport->port_wwn and sport->port_tpg_1 */
	res = core_tpg_register(&srpt_target->tf_ops, &sport->port_wwn,
	res = core_tpg_register(&srpt_template, &sport->port_wwn,
			&sport->port_tpg_1, sport, TRANSPORT_TPG_TYPE_NORMAL);
	if (res)
		return ERR_PTR(res);
@@ -3919,7 +3919,9 @@ static struct configfs_attribute *srpt_wwn_attrs[] = {
	NULL,
};

static struct target_core_fabric_ops srpt_template = {
static const struct target_core_fabric_ops srpt_template = {
	.module				= THIS_MODULE,
	.name				= "srpt",
	.get_fabric_name		= srpt_get_fabric_name,
	.get_fabric_proto_ident		= srpt_get_fabric_proto_ident,
	.tpg_get_wwn			= srpt_get_fabric_wwn,
@@ -3964,6 +3966,10 @@ static struct target_core_fabric_ops srpt_template = {
	.fabric_drop_np			= NULL,
	.fabric_make_nodeacl		= srpt_make_nodeacl,
	.fabric_drop_nodeacl		= srpt_drop_nodeacl,

	.tfc_wwn_attrs			= srpt_wwn_attrs,
	.tfc_tpg_base_attrs		= srpt_tpg_attrs,
	.tfc_tpg_attrib_attrs		= srpt_tpg_attrib_attrs,
};

/**
@@ -3994,33 +4000,9 @@ static int __init srpt_init_module(void)
		goto out;
	}

	srpt_target = target_fabric_configfs_init(THIS_MODULE, "srpt");
	if (IS_ERR(srpt_target)) {
		printk(KERN_ERR "couldn't register\n");
		ret = PTR_ERR(srpt_target);
	ret = target_register_template(&srpt_template);
	if (ret)
		goto out;
	}

	srpt_target->tf_ops = srpt_template;

	/*
	 * Set up default attribute lists.
	 */
	srpt_target->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = srpt_wwn_attrs;
	srpt_target->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = srpt_tpg_attrs;
	srpt_target->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = srpt_tpg_attrib_attrs;
	srpt_target->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL;
	srpt_target->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL;
	srpt_target->tf_cit_tmpl.tfc_tpg_nacl_base_cit.ct_attrs = NULL;
	srpt_target->tf_cit_tmpl.tfc_tpg_nacl_attrib_cit.ct_attrs = NULL;
	srpt_target->tf_cit_tmpl.tfc_tpg_nacl_auth_cit.ct_attrs = NULL;
	srpt_target->tf_cit_tmpl.tfc_tpg_nacl_param_cit.ct_attrs = NULL;

	ret = target_fabric_configfs_register(srpt_target);
	if (ret < 0) {
		printk(KERN_ERR "couldn't register\n");
		goto out_free_target;
	}

	ret = ib_register_client(&srpt_client);
	if (ret) {
@@ -4031,11 +4013,7 @@ static int __init srpt_init_module(void)
	return 0;

out_unregister_target:
	target_fabric_configfs_deregister(srpt_target);
	srpt_target = NULL;
out_free_target:
	if (srpt_target)
		target_fabric_configfs_free(srpt_target);
	target_unregister_template(&srpt_template);
out:
	return ret;
}
@@ -4043,8 +4021,7 @@ static int __init srpt_init_module(void)
static void __exit srpt_cleanup_module(void)
{
	ib_unregister_client(&srpt_client);
	target_fabric_configfs_deregister(srpt_target);
	srpt_target = NULL;
	target_unregister_template(&srpt_template);
}

module_init(srpt_init_module);
+1 −1
Original line number Diff line number Diff line
@@ -3065,7 +3065,7 @@ static void qlt_do_ctio_completion(struct scsi_qla_host *vha, uint32_t handle,
{
	struct qla_hw_data *ha = vha->hw;
	struct se_cmd *se_cmd;
	struct target_core_fabric_ops *tfo;
	const struct target_core_fabric_ops *tfo;
	struct qla_tgt_cmd *cmd;

	if (handle & CTIO_INTERMEDIATE_HANDLE_MARK) {
+26 −92
Original line number Diff line number Diff line
@@ -53,9 +53,8 @@
static struct workqueue_struct *tcm_qla2xxx_free_wq;
static struct workqueue_struct *tcm_qla2xxx_cmd_wq;

/* Local pointer to allocated TCM configfs fabric module */
static struct target_fabric_configfs *tcm_qla2xxx_fabric_configfs;
static struct target_fabric_configfs *tcm_qla2xxx_npiv_fabric_configfs;
static const struct target_core_fabric_ops tcm_qla2xxx_ops;
static const struct target_core_fabric_ops tcm_qla2xxx_npiv_ops;

/*
 * Parse WWN.
@@ -1177,7 +1176,7 @@ static struct se_portal_group *tcm_qla2xxx_make_tpg(
	tpg->tpg_attrib.cache_dynamic_acls = 1;
	tpg->tpg_attrib.demo_mode_login_only = 1;

	ret = core_tpg_register(&tcm_qla2xxx_fabric_configfs->tf_ops, wwn,
	ret = core_tpg_register(&tcm_qla2xxx_ops, wwn,
				&tpg->se_tpg, tpg, TRANSPORT_TPG_TYPE_NORMAL);
	if (ret < 0) {
		kfree(tpg);
@@ -1297,7 +1296,7 @@ static struct se_portal_group *tcm_qla2xxx_npiv_make_tpg(
	tpg->tpg_attrib.cache_dynamic_acls = 1;
	tpg->tpg_attrib.demo_mode_login_only = 1;

	ret = core_tpg_register(&tcm_qla2xxx_npiv_fabric_configfs->tf_ops, wwn,
	ret = core_tpg_register(&tcm_qla2xxx_npiv_ops, wwn,
				&tpg->se_tpg, tpg, TRANSPORT_TPG_TYPE_NORMAL);
	if (ret < 0) {
		kfree(tpg);
@@ -1987,7 +1986,9 @@ static struct configfs_attribute *tcm_qla2xxx_wwn_attrs[] = {
	NULL,
};

static struct target_core_fabric_ops tcm_qla2xxx_ops = {
static const struct target_core_fabric_ops tcm_qla2xxx_ops = {
	.module				= THIS_MODULE,
	.name				= "qla2xxx",
	.get_fabric_name		= tcm_qla2xxx_get_fabric_name,
	.get_fabric_proto_ident		= tcm_qla2xxx_get_fabric_proto_ident,
	.tpg_get_wwn			= tcm_qla2xxx_get_fabric_wwn,
@@ -2037,9 +2038,15 @@ static struct target_core_fabric_ops tcm_qla2xxx_ops = {
	.fabric_drop_np			= NULL,
	.fabric_make_nodeacl		= tcm_qla2xxx_make_nodeacl,
	.fabric_drop_nodeacl		= tcm_qla2xxx_drop_nodeacl,

	.tfc_wwn_attrs			= tcm_qla2xxx_wwn_attrs,
	.tfc_tpg_base_attrs		= tcm_qla2xxx_tpg_attrs,
	.tfc_tpg_attrib_attrs		= tcm_qla2xxx_tpg_attrib_attrs,
};

static struct target_core_fabric_ops tcm_qla2xxx_npiv_ops = {
static const struct target_core_fabric_ops tcm_qla2xxx_npiv_ops = {
	.module				= THIS_MODULE,
	.name				= "qla2xxx_npiv",
	.get_fabric_name		= tcm_qla2xxx_npiv_get_fabric_name,
	.get_fabric_proto_ident		= tcm_qla2xxx_get_fabric_proto_ident,
	.tpg_get_wwn			= tcm_qla2xxx_get_fabric_wwn,
@@ -2087,94 +2094,26 @@ static struct target_core_fabric_ops tcm_qla2xxx_npiv_ops = {
	.fabric_drop_np			= NULL,
	.fabric_make_nodeacl		= tcm_qla2xxx_make_nodeacl,
	.fabric_drop_nodeacl		= tcm_qla2xxx_drop_nodeacl,

	.tfc_wwn_attrs			= tcm_qla2xxx_wwn_attrs,
	.tfc_tpg_base_attrs		= tcm_qla2xxx_npiv_tpg_attrs,
};

static int tcm_qla2xxx_register_configfs(void)
{
	struct target_fabric_configfs *fabric, *npiv_fabric;
	int ret;

	pr_debug("TCM QLOGIC QLA2XXX fabric module %s on %s/%s on "
	    UTS_RELEASE"\n", TCM_QLA2XXX_VERSION, utsname()->sysname,
	    utsname()->machine);
	/*
	 * Register the top level struct config_item_type with TCM core
	 */
	fabric = target_fabric_configfs_init(THIS_MODULE, "qla2xxx");
	if (IS_ERR(fabric)) {
		pr_err("target_fabric_configfs_init() failed\n");
		return PTR_ERR(fabric);
	}
	/*
	 * Setup fabric->tf_ops from our local tcm_qla2xxx_ops
	 */
	fabric->tf_ops = tcm_qla2xxx_ops;
	/*
	 * Setup default attribute lists for various fabric->tf_cit_tmpl
	 */
	fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = tcm_qla2xxx_wwn_attrs;
	fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs = tcm_qla2xxx_tpg_attrs;
	fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs =
						tcm_qla2xxx_tpg_attrib_attrs;
	fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL;
	fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL;
	fabric->tf_cit_tmpl.tfc_tpg_nacl_base_cit.ct_attrs = NULL;
	fabric->tf_cit_tmpl.tfc_tpg_nacl_attrib_cit.ct_attrs = NULL;
	fabric->tf_cit_tmpl.tfc_tpg_nacl_auth_cit.ct_attrs = NULL;
	fabric->tf_cit_tmpl.tfc_tpg_nacl_param_cit.ct_attrs = NULL;
	/*
	 * Register the fabric for use within TCM
	 */
	ret = target_fabric_configfs_register(fabric);
	if (ret < 0) {
		pr_err("target_fabric_configfs_register() failed for TCM_QLA2XXX\n");

	ret = target_register_template(&tcm_qla2xxx_ops);
	if (ret)
		return ret;
	}
	/*
	 * Setup our local pointer to *fabric
	 */
	tcm_qla2xxx_fabric_configfs = fabric;
	pr_debug("TCM_QLA2XXX[0] - Set fabric -> tcm_qla2xxx_fabric_configfs\n");

	/*
	 * Register the top level struct config_item_type for NPIV with TCM core
	 */
	npiv_fabric = target_fabric_configfs_init(THIS_MODULE, "qla2xxx_npiv");
	if (IS_ERR(npiv_fabric)) {
		pr_err("target_fabric_configfs_init() failed\n");
		ret = PTR_ERR(npiv_fabric);
	ret = target_register_template(&tcm_qla2xxx_npiv_ops);
	if (ret)
		goto out_fabric;
	}
	/*
	 * Setup fabric->tf_ops from our local tcm_qla2xxx_npiv_ops
	 */
	npiv_fabric->tf_ops = tcm_qla2xxx_npiv_ops;
	/*
	 * Setup default attribute lists for various npiv_fabric->tf_cit_tmpl
	 */
	npiv_fabric->tf_cit_tmpl.tfc_wwn_cit.ct_attrs = tcm_qla2xxx_wwn_attrs;
	npiv_fabric->tf_cit_tmpl.tfc_tpg_base_cit.ct_attrs =
	    tcm_qla2xxx_npiv_tpg_attrs;
	npiv_fabric->tf_cit_tmpl.tfc_tpg_attrib_cit.ct_attrs = NULL;
	npiv_fabric->tf_cit_tmpl.tfc_tpg_param_cit.ct_attrs = NULL;
	npiv_fabric->tf_cit_tmpl.tfc_tpg_np_base_cit.ct_attrs = NULL;
	npiv_fabric->tf_cit_tmpl.tfc_tpg_nacl_base_cit.ct_attrs = NULL;
	npiv_fabric->tf_cit_tmpl.tfc_tpg_nacl_attrib_cit.ct_attrs = NULL;
	npiv_fabric->tf_cit_tmpl.tfc_tpg_nacl_auth_cit.ct_attrs = NULL;
	npiv_fabric->tf_cit_tmpl.tfc_tpg_nacl_param_cit.ct_attrs = NULL;
	/*
	 * Register the npiv_fabric for use within TCM
	 */
	ret = target_fabric_configfs_register(npiv_fabric);
	if (ret < 0) {
		pr_err("target_fabric_configfs_register() failed for TCM_QLA2XXX\n");
		goto out_fabric;
	}
	/*
	 * Setup our local pointer to *npiv_fabric
	 */
	tcm_qla2xxx_npiv_fabric_configfs = npiv_fabric;
	pr_debug("TCM_QLA2XXX[0] - Set fabric -> tcm_qla2xxx_npiv_fabric_configfs\n");

	tcm_qla2xxx_free_wq = alloc_workqueue("tcm_qla2xxx_free",
						WQ_MEM_RECLAIM, 0);
@@ -2194,9 +2133,9 @@ static int tcm_qla2xxx_register_configfs(void)
out_free_wq:
	destroy_workqueue(tcm_qla2xxx_free_wq);
out_fabric_npiv:
	target_fabric_configfs_deregister(tcm_qla2xxx_npiv_fabric_configfs);
	target_unregister_template(&tcm_qla2xxx_npiv_ops);
out_fabric:
	target_fabric_configfs_deregister(tcm_qla2xxx_fabric_configfs);
	target_unregister_template(&tcm_qla2xxx_ops);
	return ret;
}

@@ -2205,13 +2144,8 @@ static void tcm_qla2xxx_deregister_configfs(void)
	destroy_workqueue(tcm_qla2xxx_cmd_wq);
	destroy_workqueue(tcm_qla2xxx_free_wq);

	target_fabric_configfs_deregister(tcm_qla2xxx_fabric_configfs);
	tcm_qla2xxx_fabric_configfs = NULL;
	pr_debug("TCM_QLA2XXX[0] - Cleared tcm_qla2xxx_fabric_configfs\n");

	target_fabric_configfs_deregister(tcm_qla2xxx_npiv_fabric_configfs);
	tcm_qla2xxx_npiv_fabric_configfs = NULL;
	pr_debug("TCM_QLA2XXX[0] - Cleared tcm_qla2xxx_npiv_fabric_configfs\n");
	target_unregister_template(&tcm_qla2xxx_ops);
	target_unregister_template(&tcm_qla2xxx_npiv_ops);
}

static int __init tcm_qla2xxx_init(void)
+15 −8
Original line number Diff line number Diff line
@@ -33,7 +33,6 @@
#include <target/iscsi/iscsi_target_core.h>
#include "iscsi_target_parameters.h"
#include "iscsi_target_seq_pdu_list.h"
#include "iscsi_target_configfs.h"
#include "iscsi_target_datain_values.h"
#include "iscsi_target_erl0.h"
#include "iscsi_target_erl1.h"
@@ -551,8 +550,8 @@ static int __init iscsi_target_init_module(void)
	idr_init(&tiqn_idr);
	idr_init(&sess_idr);

	ret = iscsi_target_register_configfs();
	if (ret < 0)
	ret = target_register_template(&iscsi_ops);
	if (ret)
		goto out;

	size = BITS_TO_LONGS(ISCSIT_BITMAP_BITS) * sizeof(long);
@@ -616,7 +615,10 @@ static int __init iscsi_target_init_module(void)
bitmap_out:
	vfree(iscsit_global->ts_bitmap);
configfs_out:
	iscsi_target_deregister_configfs();
	/* XXX: this probably wants it to be it's own unwind step.. */
	if (iscsit_global->discovery_tpg)
		iscsit_tpg_disable_portal_group(iscsit_global->discovery_tpg, 1);
	target_unregister_template(&iscsi_ops);
out:
	kfree(iscsit_global);
	return -ENOMEM;
@@ -631,7 +633,13 @@ static void __exit iscsi_target_cleanup_module(void)
	kmem_cache_destroy(lio_ooo_cache);
	kmem_cache_destroy(lio_r2t_cache);

	iscsi_target_deregister_configfs();
	/*
	 * Shutdown discovery sessions and disable discovery TPG
	 */
	if (iscsit_global->discovery_tpg)
		iscsit_tpg_disable_portal_group(iscsit_global->discovery_tpg, 1);

	target_unregister_template(&iscsi_ops);

	vfree(iscsit_global->ts_bitmap);
	kfree(iscsit_global);
@@ -983,7 +991,7 @@ int iscsit_setup_scsi_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
	/*
	 * Initialize struct se_cmd descriptor from target_core_mod infrastructure
	 */
	transport_init_se_cmd(&cmd->se_cmd, &lio_target_fabric_configfs->tf_ops,
	transport_init_se_cmd(&cmd->se_cmd, &iscsi_ops,
			conn->sess->se_sess, be32_to_cpu(hdr->data_length),
			cmd->data_direction, sam_task_attr,
			cmd->sense_buffer + 2);
@@ -1798,8 +1806,7 @@ iscsit_handle_task_mgt_cmd(struct iscsi_conn *conn, struct iscsi_cmd *cmd,
		u8 tcm_function;
		int ret;

		transport_init_se_cmd(&cmd->se_cmd,
				      &lio_target_fabric_configfs->tf_ops,
		transport_init_se_cmd(&cmd->se_cmd, &iscsi_ops,
				      conn->sess->se_sess, 0, DMA_NONE,
				      TCM_SIMPLE_TAG, cmd->sense_buffer + 2);

Loading