Re: qla2xxx_npiv support (in targetcli)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, May 14, 2015 at 10:21:11AM +0200, Tomasz Charo??ski wrote:
> First of your representation concept seems to be great. Each NPIV has an
> option to set individual acls and luns, so it will be clear. In my
> opinion, also there is no sense in treating qla2xxx_npiv as a separate
> fabric, because it's served from the same driver (qla2xxx). NPIVs have
> to have their physical parent; the first representation give us an
> information about parent in more transparent way.

FYI, this reminds me of the patch below I did a while ago that
splits the configfs from the fabric ops to make this more clear.  I've
rebased it to the latest target/for-next that works for me (without
the RCU changes which will cause some very minor clashes).

After that the next step might be to redo the configfs ops and
move them into common code for both the FC and FC+NPIV cases.

---
>From 39902bf95b59cd01195c70b2ba85242ed040fac1 Mon Sep 17 00:00:00 2001
From: Christoph Hellwig <hch@xxxxxx>
Date: Mon, 18 May 2015 19:06:52 +0200
Subject: target: split fabric ops

The current struct target_core_fabric_ops handles both the direct configfs
interaction and the actual fabric methods, leading to a style where
drivers need to forward declare it and pass it to two different
registration functions.  By splitting it into two separate operation
vectors we can clean this up and lead to a more natural code flow in
most drivers.  It also allows to just have a single fabric operations
vector for the qla2xxx driver instead of needing a separate one for
the npiv case.  It should also allow for sharing the configfs logic
for different fibre channel drivers in the future.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>
---
 Documentation/target/tcm_mod_builder.txt     |   8 +-
 drivers/infiniband/ulp/srpt/ib_srpt.c        |  64 +++++++-------
 drivers/scsi/qla2xxx/qla_target.c            |   2 +-
 drivers/scsi/qla2xxx/tcm_qla2xxx.c           | 122 +++++++++------------------
 drivers/target/iscsi/iscsi_target.c          |   6 +-
 drivers/target/iscsi/iscsi_target.h          |   3 +-
 drivers/target/iscsi/iscsi_target_configfs.c |  11 ++-
 drivers/target/loopback/tcm_loop.c           |  64 +++++++-------
 drivers/target/sbp/sbp_target.c              |  55 ++++++------
 drivers/target/target_core_configfs.c        |  98 ++-------------------
 drivers/target/target_core_pr.c              |  14 +--
 drivers/target/target_core_tpg.c             |  95 ++++++++++++++++++++-
 drivers/target/target_core_transport.c       |   8 +-
 drivers/target/target_core_xcopy.c           |   2 +-
 drivers/target/tcm_fc/tcm_fc.h               |  14 ++-
 drivers/target/tcm_fc/tfc_cmd.c              |  74 ++++++++++++++--
 drivers/target/tcm_fc/tfc_conf.c             |  88 +++----------------
 drivers/usb/gadget/legacy/tcm_usb_gadget.c   |  72 ++++++++--------
 drivers/vhost/scsi.c                         |  59 +++++++------
 drivers/xen/xen-scsiback.c                   |  78 +++++++++--------
 include/target/target_core_base.h            |   4 +-
 include/target/target_core_configfs.h        |   2 +-
 include/target/target_core_fabric.h          |  21 ++---
 23 files changed, 461 insertions(+), 503 deletions(-)

diff --git a/Documentation/target/tcm_mod_builder.txt b/Documentation/target/tcm_mod_builder.txt
index ae22f70..a85d4c6 100644
--- a/Documentation/target/tcm_mod_builder.txt
+++ b/Documentation/target/tcm_mod_builder.txt
@@ -16,7 +16,7 @@ This script will create a new drivers/target/$TCM_NEW_MOD/, and will do the foll
 	   ->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.
+	   using a skeleton struct target_fabric_configfs_ops API template.
 	*) Based on user defined T10 Proto_Ident for the new fabric module being built,
 	   the TransportID / Initiator and Target WWPN related handlers for
 	   SPC-3 persistent reservation are automatically generated in $TCM_NEW_MOD/$TCM_NEW_MOD_fabric.c
@@ -38,7 +38,7 @@ Creating fabric_mod_dir:
 Writing file:
 /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/tcm_nab5000_base.h
 Using tcm_mod_scan_fabric_ops:
-/mnt/sdb/lio-core-2.6.git/Documentation/target/../../include/target/target_core_fabric_ops.h
+/mnt/sdb/lio-core-2.6.git/Documentation/target/../../include/target/target_core_fabric.h
 Writing file:
 /mnt/sdb/lio-core-2.6.git/Documentation/target/../../drivers/target/tcm_nab5000/tcm_nab5000_fabric.c
 Writing file:
@@ -138,8 +138,8 @@ Future TODO items:
 
 	*) Add more T10 proto_idents
 	*) Make tcm_mod_dump_fabric_ops() smarter and generate function pointer
-	   defs directly from include/target/target_core_fabric_ops.h:struct target_core_fabric_ops
-	   structure members.
+	   defs directly from include/target/target_core_fabric.h:
+	   struct target_fabric_configfs_ops structure members.
 
 October 5th, 2010
 Nicholas A. Bellinger <nab@xxxxxxxxxxxxxxx>
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c
index dbad5c6..bb272d0 100644
--- a/drivers/infiniband/ulp/srpt/ib_srpt.c
+++ b/drivers/infiniband/ulp/srpt/ib_srpt.c
@@ -92,7 +92,6 @@ MODULE_PARM_DESC(srpt_service_guid,
 		 " instead of using the node_guid of the first HCA.");
 
 static struct ib_client srpt_client;
-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);
 
@@ -3480,6 +3479,31 @@ static int srpt_get_tcm_cmd_state(struct se_cmd *se_cmd)
 	return srpt_get_cmd_state(ioctx);
 }
 
+static const struct target_fabric_ops srpt_ops = {
+	.node_acl_size			= sizeof(struct srpt_node_acl),
+	.get_fabric_name		= srpt_get_fabric_name,
+	.tpg_get_wwn			= srpt_get_fabric_wwn,
+	.tpg_get_tag			= srpt_get_tag,
+	.tpg_check_demo_mode		= srpt_check_false,
+	.tpg_check_demo_mode_cache	= srpt_check_true,
+	.tpg_check_demo_mode_write_protect = srpt_check_true,
+	.tpg_check_prod_mode_write_protect = srpt_check_false,
+	.tpg_get_inst_index		= srpt_tpg_get_inst_index,
+	.release_cmd			= srpt_release_cmd,
+	.check_stop_free		= srpt_check_stop_free,
+	.shutdown_session		= srpt_shutdown_session,
+	.close_session			= srpt_close_session,
+	.sess_get_index			= srpt_sess_get_index,
+	.write_pending			= srpt_write_pending,
+	.write_pending_status		= srpt_write_pending_status,
+	.set_default_node_attributes	= srpt_set_default_node_attrs,
+	.get_cmd_state			= srpt_get_tcm_cmd_state,
+	.queue_data_in			= srpt_queue_data_in,
+	.queue_status			= srpt_queue_status,
+	.queue_tm_rsp			= srpt_queue_tm_rsp,
+	.aborted_task			= srpt_aborted_task,
+};
+
 /**
  * srpt_parse_i_port_id() - Parse an initiator port ID.
  * @name: ASCII representation of a 128-bit initiator port ID.
@@ -3733,7 +3757,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_template, &sport->port_wwn,
+	res = core_tpg_register(&srpt_ops, &sport->port_wwn,
 			&sport->port_tpg_1, SCSI_PROTOCOL_SRP);
 	if (res)
 		return ERR_PTR(res);
@@ -3801,36 +3825,10 @@ static struct configfs_attribute *srpt_wwn_attrs[] = {
 	NULL,
 };
 
-static const struct target_core_fabric_ops srpt_template = {
+static const struct target_fabric_configfs_ops srpt_configfs_ops = {
 	.module				= THIS_MODULE,
 	.name				= "srpt",
-	.node_acl_size			= sizeof(struct srpt_node_acl),
-	.get_fabric_name		= srpt_get_fabric_name,
-	.tpg_get_wwn			= srpt_get_fabric_wwn,
-	.tpg_get_tag			= srpt_get_tag,
-	.tpg_check_demo_mode		= srpt_check_false,
-	.tpg_check_demo_mode_cache	= srpt_check_true,
-	.tpg_check_demo_mode_write_protect = srpt_check_true,
-	.tpg_check_prod_mode_write_protect = srpt_check_false,
-	.tpg_get_inst_index		= srpt_tpg_get_inst_index,
-	.release_cmd			= srpt_release_cmd,
-	.check_stop_free		= srpt_check_stop_free,
-	.shutdown_session		= srpt_shutdown_session,
-	.close_session			= srpt_close_session,
-	.sess_get_index			= srpt_sess_get_index,
-	.sess_get_initiator_sid		= NULL,
-	.write_pending			= srpt_write_pending,
-	.write_pending_status		= srpt_write_pending_status,
-	.set_default_node_attributes	= srpt_set_default_node_attrs,
-	.get_cmd_state			= srpt_get_tcm_cmd_state,
-	.queue_data_in			= srpt_queue_data_in,
-	.queue_status			= srpt_queue_status,
-	.queue_tm_rsp			= srpt_queue_tm_rsp,
-	.aborted_task			= srpt_aborted_task,
-	/*
-	 * Setup function pointers for generic logic in
-	 * target_core_fabric_configfs.c
-	 */
+
 	.fabric_make_wwn		= srpt_make_tport,
 	.fabric_drop_wwn		= srpt_drop_tport,
 	.fabric_make_tpg		= srpt_make_tpg,
@@ -3871,7 +3869,7 @@ static int __init srpt_init_module(void)
 		goto out;
 	}
 
-	ret = target_register_template(&srpt_template);
+	ret = target_register_template(&srpt_configfs_ops);
 	if (ret)
 		goto out;
 
@@ -3884,7 +3882,7 @@ static int __init srpt_init_module(void)
 	return 0;
 
 out_unregister_target:
-	target_unregister_template(&srpt_template);
+	target_unregister_template(&srpt_configfs_ops);
 out:
 	return ret;
 }
@@ -3892,7 +3890,7 @@ out:
 static void __exit srpt_cleanup_module(void)
 {
 	ib_unregister_client(&srpt_client);
-	target_unregister_template(&srpt_template);
+	target_unregister_template(&srpt_configfs_ops);
 }
 
 module_init(srpt_init_module);
diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c
index e7515069..95d48b5 100644
--- a/drivers/scsi/qla2xxx/qla_target.c
+++ b/drivers/scsi/qla2xxx/qla_target.c
@@ -3063,7 +3063,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;
-	const struct target_core_fabric_ops *tfo;
+	const struct target_fabric_ops *tfo;
 	struct qla_tgt_cmd *cmd;
 
 	if (handle & CTIO_INTERMEDIATE_HANDLE_MARK) {
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index cb53144..94cc5391 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -52,9 +52,6 @@
 static struct workqueue_struct *tcm_qla2xxx_free_wq;
 static struct workqueue_struct *tcm_qla2xxx_cmd_wq;
 
-static const struct target_core_fabric_ops tcm_qla2xxx_ops;
-static const struct target_core_fabric_ops tcm_qla2xxx_npiv_ops;
-
 /*
  * Parse WWN.
  * If strict, we require lower-case hex and colon separators to be sure
@@ -184,11 +181,6 @@ static int tcm_qla2xxx_npiv_parse_wwn(
 	return 0;
 }
 
-static char *tcm_qla2xxx_npiv_get_fabric_name(void)
-{
-	return "qla2xxx_npiv";
-}
-
 static char *tcm_qla2xxx_get_fabric_wwn(struct se_portal_group *se_tpg)
 {
 	struct tcm_qla2xxx_tpg *tpg = container_of(se_tpg,
@@ -271,7 +263,7 @@ static void tcm_qla2xxx_complete_mcmd(struct work_struct *work)
 
 /*
  * Called from qla_target_template->free_mcmd(), and will call
- * tcm_qla2xxx_release_cmd() via normal struct target_core_fabric_ops
+ * tcm_qla2xxx_release_cmd() via normal struct target_fabric_ops
  * release callback.  qla_hw_data->hardware_lock is expected to be held
  */
 static void tcm_qla2xxx_free_mcmd(struct qla_tgt_mgmt_cmd *mcmd)
@@ -294,7 +286,7 @@ static void tcm_qla2xxx_complete_free(struct work_struct *work)
 
 /*
  * Called from qla_target_template->free_cmd(), and will call
- * tcm_qla2xxx_release_cmd via normal struct target_core_fabric_ops
+ * tcm_qla2xxx_release_cmd via normal struct target_fabric_ops
  * release callback.  qla_hw_data->hardware_lock is expected to be held
  */
 static void tcm_qla2xxx_free_cmd(struct qla_tgt_cmd *cmd)
@@ -305,7 +297,7 @@ static void tcm_qla2xxx_free_cmd(struct qla_tgt_cmd *cmd)
 }
 
 /*
- * Called from struct target_core_fabric_ops->check_stop_free() context
+ * Called from struct target_fabric_ops->check_stop_free() context
  */
 static int tcm_qla2xxx_check_stop_free(struct se_cmd *se_cmd)
 {
@@ -700,6 +692,34 @@ static void tcm_qla2xxx_release_session(struct kref *kref)
 	qlt_unreg_sess(se_sess->fabric_sess_ptr);
 }
 
+static const struct target_fabric_ops tcm_qla2xxx_ops = {
+	.get_fabric_name		= tcm_qla2xxx_get_fabric_name,
+	.tpg_get_wwn			= tcm_qla2xxx_get_fabric_wwn,
+	.tpg_get_tag			= tcm_qla2xxx_get_tag,
+	.tpg_check_demo_mode		= tcm_qla2xxx_check_demo_mode,
+	.tpg_check_demo_mode_cache	= tcm_qla2xxx_check_demo_mode_cache,
+	.tpg_check_demo_mode_write_protect =
+					tcm_qla2xxx_check_demo_write_protect,
+	.tpg_check_prod_mode_write_protect =
+					tcm_qla2xxx_check_prod_write_protect,
+	.tpg_check_prot_fabric_only	= tcm_qla2xxx_check_prot_fabric_only,
+	.tpg_check_demo_mode_login_only = tcm_qla2xxx_check_demo_mode_login_only,
+	.tpg_get_inst_index		= tcm_qla2xxx_tpg_get_inst_index,
+	.check_stop_free		= tcm_qla2xxx_check_stop_free,
+	.release_cmd			= tcm_qla2xxx_release_cmd,
+	.shutdown_session		= tcm_qla2xxx_shutdown_session,
+	.close_session			= tcm_qla2xxx_close_session,
+	.sess_get_index			= tcm_qla2xxx_sess_get_index,
+	.write_pending			= tcm_qla2xxx_write_pending,
+	.write_pending_status		= tcm_qla2xxx_write_pending_status,
+	.set_default_node_attributes	= tcm_qla2xxx_set_default_node_attrs,
+	.get_cmd_state			= tcm_qla2xxx_get_cmd_state,
+	.queue_data_in			= tcm_qla2xxx_queue_data_in,
+	.queue_status			= tcm_qla2xxx_queue_status,
+	.queue_tm_rsp			= tcm_qla2xxx_queue_tm_rsp,
+	.aborted_task			= tcm_qla2xxx_aborted_task,
+};
+
 static void tcm_qla2xxx_put_sess(struct qla_tgt_sess *sess)
 {
 	if (!sess)
@@ -1124,7 +1144,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_ops, wwn, &tpg->se_tpg,
+	ret = core_tpg_register(&tcm_qla2xxx_ops, wwn, &tpg->se_tpg,
 				SCSI_PROTOCOL_FCP);
 	if (ret < 0) {
 		kfree(tpg);
@@ -1814,40 +1834,10 @@ static struct configfs_attribute *tcm_qla2xxx_wwn_attrs[] = {
 	NULL,
 };
 
-static const struct target_core_fabric_ops tcm_qla2xxx_ops = {
+static const struct target_fabric_configfs_ops tcm_qla2xxx_configfs_ops = {
 	.module				= THIS_MODULE,
 	.name				= "qla2xxx",
-	.node_acl_size			= sizeof(struct tcm_qla2xxx_nacl),
-	.get_fabric_name		= tcm_qla2xxx_get_fabric_name,
-	.tpg_get_wwn			= tcm_qla2xxx_get_fabric_wwn,
-	.tpg_get_tag			= tcm_qla2xxx_get_tag,
-	.tpg_check_demo_mode		= tcm_qla2xxx_check_demo_mode,
-	.tpg_check_demo_mode_cache	= tcm_qla2xxx_check_demo_mode_cache,
-	.tpg_check_demo_mode_write_protect =
-					tcm_qla2xxx_check_demo_write_protect,
-	.tpg_check_prod_mode_write_protect =
-					tcm_qla2xxx_check_prod_write_protect,
-	.tpg_check_prot_fabric_only	= tcm_qla2xxx_check_prot_fabric_only,
-	.tpg_check_demo_mode_login_only = tcm_qla2xxx_check_demo_mode_login_only,
-	.tpg_get_inst_index		= tcm_qla2xxx_tpg_get_inst_index,
-	.check_stop_free		= tcm_qla2xxx_check_stop_free,
-	.release_cmd			= tcm_qla2xxx_release_cmd,
-	.shutdown_session		= tcm_qla2xxx_shutdown_session,
-	.close_session			= tcm_qla2xxx_close_session,
-	.sess_get_index			= tcm_qla2xxx_sess_get_index,
-	.sess_get_initiator_sid		= NULL,
-	.write_pending			= tcm_qla2xxx_write_pending,
-	.write_pending_status		= tcm_qla2xxx_write_pending_status,
-	.set_default_node_attributes	= tcm_qla2xxx_set_default_node_attrs,
-	.get_cmd_state			= tcm_qla2xxx_get_cmd_state,
-	.queue_data_in			= tcm_qla2xxx_queue_data_in,
-	.queue_status			= tcm_qla2xxx_queue_status,
-	.queue_tm_rsp			= tcm_qla2xxx_queue_tm_rsp,
-	.aborted_task			= tcm_qla2xxx_aborted_task,
-	/*
-	 * Setup function pointers for generic logic in
-	 * target_core_fabric_configfs.c
-	 */
+
 	.fabric_make_wwn		= tcm_qla2xxx_make_lport,
 	.fabric_drop_wwn		= tcm_qla2xxx_drop_lport,
 	.fabric_make_tpg		= tcm_qla2xxx_make_tpg,
@@ -1859,38 +1849,10 @@ static const struct target_core_fabric_ops tcm_qla2xxx_ops = {
 	.tfc_tpg_attrib_attrs		= tcm_qla2xxx_tpg_attrib_attrs,
 };
 
-static const struct target_core_fabric_ops tcm_qla2xxx_npiv_ops = {
+static const struct target_fabric_configfs_ops tcm_qla2xxx_npiv_configfs_ops = {
 	.module				= THIS_MODULE,
 	.name				= "qla2xxx_npiv",
-	.node_acl_size			= sizeof(struct tcm_qla2xxx_nacl),
-	.get_fabric_name		= tcm_qla2xxx_npiv_get_fabric_name,
-	.tpg_get_wwn			= tcm_qla2xxx_get_fabric_wwn,
-	.tpg_get_tag			= tcm_qla2xxx_get_tag,
-	.tpg_check_demo_mode		= tcm_qla2xxx_check_demo_mode,
-	.tpg_check_demo_mode_cache	= tcm_qla2xxx_check_demo_mode_cache,
-	.tpg_check_demo_mode_write_protect = tcm_qla2xxx_check_demo_mode,
-	.tpg_check_prod_mode_write_protect =
-	    tcm_qla2xxx_check_prod_write_protect,
-	.tpg_check_demo_mode_login_only	= tcm_qla2xxx_check_demo_mode_login_only,
-	.tpg_get_inst_index		= tcm_qla2xxx_tpg_get_inst_index,
-	.check_stop_free                = tcm_qla2xxx_check_stop_free,
-	.release_cmd			= tcm_qla2xxx_release_cmd,
-	.shutdown_session		= tcm_qla2xxx_shutdown_session,
-	.close_session			= tcm_qla2xxx_close_session,
-	.sess_get_index			= tcm_qla2xxx_sess_get_index,
-	.sess_get_initiator_sid		= NULL,
-	.write_pending			= tcm_qla2xxx_write_pending,
-	.write_pending_status		= tcm_qla2xxx_write_pending_status,
-	.set_default_node_attributes	= tcm_qla2xxx_set_default_node_attrs,
-	.get_cmd_state			= tcm_qla2xxx_get_cmd_state,
-	.queue_data_in			= tcm_qla2xxx_queue_data_in,
-	.queue_status			= tcm_qla2xxx_queue_status,
-	.queue_tm_rsp			= tcm_qla2xxx_queue_tm_rsp,
-	.aborted_task			= tcm_qla2xxx_aborted_task,
-	/*
-	 * Setup function pointers for generic logic in
-	 * target_core_fabric_configfs.c
-	 */
+
 	.fabric_make_wwn		= tcm_qla2xxx_npiv_make_lport,
 	.fabric_drop_wwn		= tcm_qla2xxx_npiv_drop_lport,
 	.fabric_make_tpg		= tcm_qla2xxx_npiv_make_tpg,
@@ -1909,11 +1871,11 @@ static int tcm_qla2xxx_register_configfs(void)
 	    UTS_RELEASE"\n", TCM_QLA2XXX_VERSION, utsname()->sysname,
 	    utsname()->machine);
 
-	ret = target_register_template(&tcm_qla2xxx_ops);
+	ret = target_register_template(&tcm_qla2xxx_configfs_ops);
 	if (ret)
 		return ret;
 
-	ret = target_register_template(&tcm_qla2xxx_npiv_ops);
+	ret = target_register_template(&tcm_qla2xxx_npiv_configfs_ops);
 	if (ret)
 		goto out_fabric;
 
@@ -1935,9 +1897,9 @@ static int tcm_qla2xxx_register_configfs(void)
 out_free_wq:
 	destroy_workqueue(tcm_qla2xxx_free_wq);
 out_fabric_npiv:
-	target_unregister_template(&tcm_qla2xxx_npiv_ops);
+	target_unregister_template(&tcm_qla2xxx_npiv_configfs_ops);
 out_fabric:
-	target_unregister_template(&tcm_qla2xxx_ops);
+	target_unregister_template(&tcm_qla2xxx_configfs_ops);
 	return ret;
 }
 
@@ -1946,8 +1908,8 @@ static void tcm_qla2xxx_deregister_configfs(void)
 	destroy_workqueue(tcm_qla2xxx_cmd_wq);
 	destroy_workqueue(tcm_qla2xxx_free_wq);
 
-	target_unregister_template(&tcm_qla2xxx_ops);
-	target_unregister_template(&tcm_qla2xxx_npiv_ops);
+	target_unregister_template(&tcm_qla2xxx_configfs_ops);
+	target_unregister_template(&tcm_qla2xxx_npiv_configfs_ops);
 }
 
 static int __init tcm_qla2xxx_init(void)
diff --git a/drivers/target/iscsi/iscsi_target.c b/drivers/target/iscsi/iscsi_target.c
index b2d46ef..7dee354 100644
--- a/drivers/target/iscsi/iscsi_target.c
+++ b/drivers/target/iscsi/iscsi_target.c
@@ -549,7 +549,7 @@ static int __init iscsi_target_init_module(void)
 	idr_init(&tiqn_idr);
 	idr_init(&sess_idr);
 
-	ret = target_register_template(&iscsi_ops);
+	ret = target_register_template(&iscsi_configfs_ops);
 	if (ret)
 		goto out;
 
@@ -617,7 +617,7 @@ configfs_out:
 	/* 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);
+	target_unregister_template(&iscsi_configfs_ops);
 out:
 	kfree(iscsit_global);
 	return -ENOMEM;
@@ -638,7 +638,7 @@ static void __exit iscsi_target_cleanup_module(void)
 	if (iscsit_global->discovery_tpg)
 		iscsit_tpg_disable_portal_group(iscsit_global->discovery_tpg, 1);
 
-	target_unregister_template(&iscsi_ops);
+	target_unregister_template(&iscsi_configfs_ops);
 
 	vfree(iscsit_global->ts_bitmap);
 	kfree(iscsit_global);
diff --git a/drivers/target/iscsi/iscsi_target.h b/drivers/target/iscsi/iscsi_target.h
index 7d0f9c0..b7c5c96 100644
--- a/drivers/target/iscsi/iscsi_target.h
+++ b/drivers/target/iscsi/iscsi_target.h
@@ -35,7 +35,8 @@ extern void iscsit_stop_session(struct iscsi_session *, int, int);
 extern int iscsit_release_sessions_for_tpg(struct iscsi_portal_group *, int);
 
 extern struct iscsit_global *iscsit_global;
-extern const struct target_core_fabric_ops iscsi_ops;
+extern const struct target_fabric_ops iscsi_ops;
+extern const struct target_fabric_configfs_ops iscsi_configfs_ops;
 
 extern struct kmem_cache *lio_dr_cache;
 extern struct kmem_cache *lio_ooo_cache;
diff --git a/drivers/target/iscsi/iscsi_target_configfs.c b/drivers/target/iscsi/iscsi_target_configfs.c
index 523ae55..4d9dd52 100644
--- a/drivers/target/iscsi/iscsi_target_configfs.c
+++ b/drivers/target/iscsi/iscsi_target_configfs.c
@@ -1684,7 +1684,7 @@ static struct configfs_attribute *lio_target_discovery_auth_attrs[] = {
 
 /* End lio_target_discovery_auth_cit */
 
-/* Start functions for target_core_fabric_ops */
+/* Start functions for target_fabric_ops */
 
 static char *iscsi_get_fabric_name(void)
 {
@@ -1904,9 +1904,7 @@ static void lio_release_cmd(struct se_cmd *se_cmd)
 	iscsit_release_cmd(cmd);
 }
 
-const struct target_core_fabric_ops iscsi_ops = {
-	.module				= THIS_MODULE,
-	.name				= "iscsi",
+const struct target_fabric_ops iscsi_ops = {
 	.node_acl_size			= sizeof(struct iscsi_node_acl),
 	.get_fabric_name		= iscsi_get_fabric_name,
 	.tpg_get_wwn			= lio_tpg_get_endpoint_wwn,
@@ -1934,6 +1932,11 @@ const struct target_core_fabric_ops iscsi_ops = {
 	.queue_status			= lio_queue_status,
 	.queue_tm_rsp			= lio_queue_tm_rsp,
 	.aborted_task			= lio_aborted_task,
+};
+
+const struct target_fabric_configfs_ops iscsi_configfs_ops = {
+	.module				= THIS_MODULE,
+	.name				= "iscsi",
 	.fabric_make_wwn		= lio_target_call_coreaddtiqn,
 	.fabric_drop_wwn		= lio_target_call_coredeltiqn,
 	.fabric_make_tpg		= lio_target_tiqn_addtpg,
diff --git a/drivers/target/loopback/tcm_loop.c b/drivers/target/loopback/tcm_loop.c
index b0c1761..59e276d 100644
--- a/drivers/target/loopback/tcm_loop.c
+++ b/drivers/target/loopback/tcm_loop.c
@@ -40,8 +40,6 @@
 
 #define to_tcm_loop_hba(hba)	container_of(hba, struct tcm_loop_hba, dev)
 
-static const struct target_core_fabric_ops loop_ops;
-
 static struct workqueue_struct *tcm_loop_workqueue;
 static struct kmem_cache *tcm_loop_cmd_cache;
 
@@ -49,9 +47,6 @@ static int tcm_loop_hba_no_cnt;
 
 static int tcm_loop_queue_status(struct se_cmd *se_cmd);
 
-/*
- * Called from struct target_core_fabric_ops->check_stop_free()
- */
 static int tcm_loop_check_stop_free(struct se_cmd *se_cmd)
 {
 	/*
@@ -698,6 +693,33 @@ static void tcm_loop_aborted_task(struct se_cmd *se_cmd)
 	return;
 }
 
+static const struct target_fabric_ops loop_ops = {
+	.get_fabric_name		= tcm_loop_get_fabric_name,
+	.tpg_get_wwn			= tcm_loop_get_endpoint_wwn,
+	.tpg_get_tag			= tcm_loop_get_tag,
+	.tpg_check_demo_mode		= tcm_loop_check_demo_mode,
+	.tpg_check_demo_mode_cache	= tcm_loop_check_demo_mode_cache,
+	.tpg_check_demo_mode_write_protect =
+				tcm_loop_check_demo_mode_write_protect,
+	.tpg_check_prod_mode_write_protect =
+				tcm_loop_check_prod_mode_write_protect,
+	.tpg_check_prot_fabric_only	= tcm_loop_check_prot_fabric_only,
+	.tpg_get_inst_index		= tcm_loop_get_inst_index,
+	.check_stop_free		= tcm_loop_check_stop_free,
+	.release_cmd			= tcm_loop_release_cmd,
+	.shutdown_session		= tcm_loop_shutdown_session,
+	.close_session			= tcm_loop_close_session,
+	.sess_get_index			= tcm_loop_sess_get_index,
+	.write_pending			= tcm_loop_write_pending,
+	.write_pending_status		= tcm_loop_write_pending_status,
+	.set_default_node_attributes	= tcm_loop_set_default_node_attributes,
+	.get_cmd_state			= tcm_loop_get_cmd_state,
+	.queue_data_in			= tcm_loop_queue_data_in,
+	.queue_status			= tcm_loop_queue_status,
+	.queue_tm_rsp			= tcm_loop_queue_tm_rsp,
+	.aborted_task			= tcm_loop_aborted_task,
+};
+
 static char *tcm_loop_dump_proto_id(struct tcm_loop_hba *tl_hba)
 {
 	switch (tl_hba->tl_proto_id) {
@@ -1229,39 +1251,17 @@ static struct configfs_attribute *tcm_loop_wwn_attrs[] = {
 
 /* End items for tcm_loop_cit */
 
-static const struct target_core_fabric_ops loop_ops = {
+static const struct target_fabric_configfs_ops loop_configfs_ops = {
 	.module				= THIS_MODULE,
 	.name				= "loopback",
-	.get_fabric_name		= tcm_loop_get_fabric_name,
-	.tpg_get_wwn			= tcm_loop_get_endpoint_wwn,
-	.tpg_get_tag			= tcm_loop_get_tag,
-	.tpg_check_demo_mode		= tcm_loop_check_demo_mode,
-	.tpg_check_demo_mode_cache	= tcm_loop_check_demo_mode_cache,
-	.tpg_check_demo_mode_write_protect =
-				tcm_loop_check_demo_mode_write_protect,
-	.tpg_check_prod_mode_write_protect =
-				tcm_loop_check_prod_mode_write_protect,
-	.tpg_check_prot_fabric_only	= tcm_loop_check_prot_fabric_only,
-	.tpg_get_inst_index		= tcm_loop_get_inst_index,
-	.check_stop_free		= tcm_loop_check_stop_free,
-	.release_cmd			= tcm_loop_release_cmd,
-	.shutdown_session		= tcm_loop_shutdown_session,
-	.close_session			= tcm_loop_close_session,
-	.sess_get_index			= tcm_loop_sess_get_index,
-	.write_pending			= tcm_loop_write_pending,
-	.write_pending_status		= tcm_loop_write_pending_status,
-	.set_default_node_attributes	= tcm_loop_set_default_node_attributes,
-	.get_cmd_state			= tcm_loop_get_cmd_state,
-	.queue_data_in			= tcm_loop_queue_data_in,
-	.queue_status			= tcm_loop_queue_status,
-	.queue_tm_rsp			= tcm_loop_queue_tm_rsp,
-	.aborted_task			= tcm_loop_aborted_task,
+
 	.fabric_make_wwn		= tcm_loop_make_scsi_hba,
 	.fabric_drop_wwn		= tcm_loop_drop_scsi_hba,
 	.fabric_make_tpg		= tcm_loop_make_naa_tpg,
 	.fabric_drop_tpg		= tcm_loop_drop_naa_tpg,
 	.fabric_post_link		= tcm_loop_port_link,
 	.fabric_pre_unlink		= tcm_loop_port_unlink,
+
 	.tfc_wwn_attrs			= tcm_loop_wwn_attrs,
 	.tfc_tpg_base_attrs		= tcm_loop_tpg_attrs,
 	.tfc_tpg_attrib_attrs		= tcm_loop_tpg_attrib_attrs,
@@ -1289,7 +1289,7 @@ static int __init tcm_loop_fabric_init(void)
 	if (ret)
 		goto out_destroy_cache;
 
-	ret = target_register_template(&loop_ops);
+	ret = target_register_template(&loop_configfs_ops);
 	if (ret)
 		goto out_release_core_bus;
 
@@ -1307,7 +1307,7 @@ out:
 
 static void __exit tcm_loop_fabric_exit(void)
 {
-	target_unregister_template(&loop_ops);
+	target_unregister_template(&loop_configfs_ops);
 	tcm_loop_release_core_bus();
 	kmem_cache_destroy(tcm_loop_cmd_cache);
 	destroy_workqueue(tcm_loop_workqueue);
diff --git a/drivers/target/sbp/sbp_target.c b/drivers/target/sbp/sbp_target.c
index 5d7755e..5adb62f 100644
--- a/drivers/target/sbp/sbp_target.c
+++ b/drivers/target/sbp/sbp_target.c
@@ -41,8 +41,6 @@
 
 #include "sbp_target.h"
 
-static const struct target_core_fabric_ops sbp_ops;
-
 /* FireWire address region for management and command block address handlers */
 static const struct fw_address_region sbp_register_region = {
 	.start	= CSR_REGISTER_BASE + 0x10000,
@@ -1824,6 +1822,30 @@ static int sbp_check_stop_free(struct se_cmd *se_cmd)
 	return 1;
 }
 
+static const struct target_fabric_ops sbp_ops = {
+	.get_fabric_name		= sbp_get_fabric_name,
+	.tpg_get_wwn			= sbp_get_fabric_wwn,
+	.tpg_get_tag			= sbp_get_tag,
+	.tpg_check_demo_mode		= sbp_check_true,
+	.tpg_check_demo_mode_cache	= sbp_check_true,
+	.tpg_check_demo_mode_write_protect = sbp_check_false,
+	.tpg_check_prod_mode_write_protect = sbp_check_false,
+	.tpg_get_inst_index		= sbp_tpg_get_inst_index,
+	.release_cmd			= sbp_release_cmd,
+	.shutdown_session		= sbp_shutdown_session,
+	.close_session			= sbp_close_session,
+	.sess_get_index			= sbp_sess_get_index,
+	.write_pending			= sbp_write_pending,
+	.write_pending_status		= sbp_write_pending_status,
+	.set_default_node_attributes	= sbp_set_default_node_attrs,
+	.get_cmd_state			= sbp_get_cmd_state,
+	.queue_data_in			= sbp_queue_data_in,
+	.queue_status			= sbp_queue_status,
+	.queue_tm_rsp			= sbp_queue_tm_rsp,
+	.aborted_task			= sbp_aborted_task,
+	.check_stop_free		= sbp_check_stop_free,
+};
+
 static int sbp_count_se_tpg_luns(struct se_portal_group *tpg)
 {
 	int i, count = 0;
@@ -2351,30 +2373,9 @@ static struct configfs_attribute *sbp_tpg_attrib_attrs[] = {
 	NULL,
 };
 
-static const struct target_core_fabric_ops sbp_ops = {
+static const struct target_fabric_configfs_ops sbp_configfs_ops = {
 	.module				= THIS_MODULE,
 	.name				= "sbp",
-	.get_fabric_name		= sbp_get_fabric_name,
-	.tpg_get_wwn			= sbp_get_fabric_wwn,
-	.tpg_get_tag			= sbp_get_tag,
-	.tpg_check_demo_mode		= sbp_check_true,
-	.tpg_check_demo_mode_cache	= sbp_check_true,
-	.tpg_check_demo_mode_write_protect = sbp_check_false,
-	.tpg_check_prod_mode_write_protect = sbp_check_false,
-	.tpg_get_inst_index		= sbp_tpg_get_inst_index,
-	.release_cmd			= sbp_release_cmd,
-	.shutdown_session		= sbp_shutdown_session,
-	.close_session			= sbp_close_session,
-	.sess_get_index			= sbp_sess_get_index,
-	.write_pending			= sbp_write_pending,
-	.write_pending_status		= sbp_write_pending_status,
-	.set_default_node_attributes	= sbp_set_default_node_attrs,
-	.get_cmd_state			= sbp_get_cmd_state,
-	.queue_data_in			= sbp_queue_data_in,
-	.queue_status			= sbp_queue_status,
-	.queue_tm_rsp			= sbp_queue_tm_rsp,
-	.aborted_task			= sbp_aborted_task,
-	.check_stop_free		= sbp_check_stop_free,
 
 	.fabric_make_wwn		= sbp_make_tport,
 	.fabric_drop_wwn		= sbp_drop_tport,
@@ -2382,8 +2383,6 @@ static const struct target_core_fabric_ops sbp_ops = {
 	.fabric_drop_tpg		= sbp_drop_tpg,
 	.fabric_post_link		= sbp_post_link_lun,
 	.fabric_pre_unlink		= sbp_pre_unlink_lun,
-	.fabric_make_np			= NULL,
-	.fabric_drop_np			= NULL,
 	.fabric_init_nodeacl		= sbp_init_nodeacl,
 
 	.tfc_wwn_attrs			= sbp_wwn_attrs,
@@ -2393,12 +2392,12 @@ static const struct target_core_fabric_ops sbp_ops = {
 
 static int __init sbp_init(void)
 {
-	return target_register_template(&sbp_ops);
+	return target_register_template(&sbp_configfs_ops);
 };
 
 static void __exit sbp_exit(void)
 {
-	target_unregister_template(&sbp_ops);
+	target_unregister_template(&sbp_configfs_ops);
 };
 
 MODULE_DESCRIPTION("FireWire SBP fabric driver");
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index 2768221..057d503 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -294,7 +294,8 @@ EXPORT_SYMBOL(target_undepend_item);
 // Start functions called by external Target Fabrics Modules
 //############################################################################*/
 
-static int target_fabric_tf_ops_check(const struct target_core_fabric_ops *tfo)
+static int
+target_configfs_ops_check(const struct target_fabric_configfs_ops *tfo)
 {
 	if (!tfo->name) {
 		pr_err("Missing tfo->name\n");
@@ -305,91 +306,6 @@ static int target_fabric_tf_ops_check(const struct target_core_fabric_ops *tfo)
 			"_NAME_SIZE\n", tfo->name);
 		return -EINVAL;
 	}
-	if (!tfo->get_fabric_name) {
-		pr_err("Missing tfo->get_fabric_name()\n");
-		return -EINVAL;
-	}
-	if (!tfo->tpg_get_wwn) {
-		pr_err("Missing tfo->tpg_get_wwn()\n");
-		return -EINVAL;
-	}
-	if (!tfo->tpg_get_tag) {
-		pr_err("Missing tfo->tpg_get_tag()\n");
-		return -EINVAL;
-	}
-	if (!tfo->tpg_check_demo_mode) {
-		pr_err("Missing tfo->tpg_check_demo_mode()\n");
-		return -EINVAL;
-	}
-	if (!tfo->tpg_check_demo_mode_cache) {
-		pr_err("Missing tfo->tpg_check_demo_mode_cache()\n");
-		return -EINVAL;
-	}
-	if (!tfo->tpg_check_demo_mode_write_protect) {
-		pr_err("Missing tfo->tpg_check_demo_mode_write_protect()\n");
-		return -EINVAL;
-	}
-	if (!tfo->tpg_check_prod_mode_write_protect) {
-		pr_err("Missing tfo->tpg_check_prod_mode_write_protect()\n");
-		return -EINVAL;
-	}
-	if (!tfo->tpg_get_inst_index) {
-		pr_err("Missing tfo->tpg_get_inst_index()\n");
-		return -EINVAL;
-	}
-	if (!tfo->release_cmd) {
-		pr_err("Missing tfo->release_cmd()\n");
-		return -EINVAL;
-	}
-	if (!tfo->shutdown_session) {
-		pr_err("Missing tfo->shutdown_session()\n");
-		return -EINVAL;
-	}
-	if (!tfo->close_session) {
-		pr_err("Missing tfo->close_session()\n");
-		return -EINVAL;
-	}
-	if (!tfo->sess_get_index) {
-		pr_err("Missing tfo->sess_get_index()\n");
-		return -EINVAL;
-	}
-	if (!tfo->write_pending) {
-		pr_err("Missing tfo->write_pending()\n");
-		return -EINVAL;
-	}
-	if (!tfo->write_pending_status) {
-		pr_err("Missing tfo->write_pending_status()\n");
-		return -EINVAL;
-	}
-	if (!tfo->set_default_node_attributes) {
-		pr_err("Missing tfo->set_default_node_attributes()\n");
-		return -EINVAL;
-	}
-	if (!tfo->get_cmd_state) {
-		pr_err("Missing tfo->get_cmd_state()\n");
-		return -EINVAL;
-	}
-	if (!tfo->queue_data_in) {
-		pr_err("Missing tfo->queue_data_in()\n");
-		return -EINVAL;
-	}
-	if (!tfo->queue_status) {
-		pr_err("Missing tfo->queue_status()\n");
-		return -EINVAL;
-	}
-	if (!tfo->queue_tm_rsp) {
-		pr_err("Missing tfo->queue_tm_rsp()\n");
-		return -EINVAL;
-	}
-	if (!tfo->aborted_task) {
-		pr_err("Missing tfo->aborted_task()\n");
-		return -EINVAL;
-	}
-	/*
-	 * We at least require tfo->fabric_make_wwn(), tfo->fabric_drop_wwn()
-	 * tfo->fabric_make_tpg() and tfo->fabric_drop_tpg() in
-	 * target_core_fabric_configfs.c WWN+TPG group context code.
-	 */
 	if (!tfo->fabric_make_wwn) {
 		pr_err("Missing tfo->fabric_make_wwn()\n");
 		return -EINVAL;
@@ -410,12 +326,12 @@ static int target_fabric_tf_ops_check(const struct target_core_fabric_ops *tfo)
 	return 0;
 }
 
-int target_register_template(const struct target_core_fabric_ops *fo)
+int target_register_template(const struct target_fabric_configfs_ops *fo)
 {
 	struct target_fabric_configfs *tf;
 	int ret;
 
-	ret = target_fabric_tf_ops_check(fo);
+	ret = target_configfs_ops_check(fo);
 	if (ret)
 		return ret;
 
@@ -438,7 +354,7 @@ int target_register_template(const struct target_core_fabric_ops *fo)
 }
 EXPORT_SYMBOL(target_register_template);
 
-void target_unregister_template(const struct target_core_fabric_ops *fo)
+void target_unregister_template(const struct target_fabric_configfs_ops *fo)
 {
 	struct target_fabric_configfs *t;
 
@@ -820,7 +736,7 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_holder_tg_port(
 	struct se_lun *lun;
 	struct se_portal_group *se_tpg;
 	struct t10_pr_registration *pr_reg;
-	const struct target_core_fabric_ops *tfo;
+	const struct target_fabric_ops *tfo;
 	ssize_t len = 0;
 
 	spin_lock(&dev->dev_reservation_lock);
@@ -854,7 +770,7 @@ SE_DEV_PR_ATTR_RO(res_pr_holder_tg_port);
 static ssize_t target_core_dev_pr_show_attr_res_pr_registered_i_pts(
 		struct se_device *dev, char *page)
 {
-	const struct target_core_fabric_ops *tfo;
+	const struct target_fabric_ops *tfo;
 	struct t10_pr_registration *pr_reg;
 	unsigned char buf[384];
 	char i_buf[PR_REG_ISID_ID_LEN];
diff --git a/drivers/target/target_core_pr.c b/drivers/target/target_core_pr.c
index 8052d40..b597035 100644
--- a/drivers/target/target_core_pr.c
+++ b/drivers/target/target_core_pr.c
@@ -679,7 +679,7 @@ static struct t10_pr_registration *__core_scsi3_alloc_registration(
 	struct se_dev_entry *deve_tmp;
 	struct se_node_acl *nacl_tmp;
 	struct se_port *port, *port_tmp;
-	const struct target_core_fabric_ops *tfo = nacl->se_tpg->se_tpg_tfo;
+	const struct target_fabric_ops *tfo = nacl->se_tpg->se_tpg_tfo;
 	struct t10_pr_registration *pr_reg, *pr_reg_atp, *pr_reg_tmp, *pr_reg_tmp_safe;
 	int ret;
 	/*
@@ -978,7 +978,7 @@ int core_scsi3_check_aptpl_registration(
 }
 
 static void __core_scsi3_dump_registration(
-	const struct target_core_fabric_ops *tfo,
+	const struct target_fabric_ops *tfo,
 	struct se_device *dev,
 	struct se_node_acl *nacl,
 	struct t10_pr_registration *pr_reg,
@@ -1019,7 +1019,7 @@ static void __core_scsi3_add_registration(
 	enum register_type register_type,
 	int register_move)
 {
-	const struct target_core_fabric_ops *tfo = nacl->se_tpg->se_tpg_tfo;
+	const struct target_fabric_ops *tfo = nacl->se_tpg->se_tpg_tfo;
 	struct t10_pr_registration *pr_reg_tmp, *pr_reg_tmp_safe;
 	struct t10_reservation *pr_tmpl = &dev->t10_pr;
 
@@ -1238,7 +1238,7 @@ static void __core_scsi3_free_registration(
 	__releases(&pr_tmpl->registration_lock)
 	__acquires(&pr_tmpl->registration_lock)
 {
-	const struct target_core_fabric_ops *tfo =
+	const struct target_fabric_ops *tfo =
 			pr_reg->pr_reg_nacl->se_tpg->se_tpg_tfo;
 	struct t10_reservation *pr_tmpl = &dev->t10_pr;
 	char i_buf[PR_REG_ISID_ID_LEN];
@@ -2397,7 +2397,7 @@ static void __core_scsi3_complete_pro_release(
 	int explicit,
 	int unreg)
 {
-	const struct target_core_fabric_ops *tfo = se_nacl->se_tpg->se_tpg_tfo;
+	const struct target_fabric_ops *tfo = se_nacl->se_tpg->se_tpg_tfo;
 	char i_buf[PR_REG_ISID_ID_LEN];
 	int pr_res_type = 0, pr_res_scope = 0;
 
@@ -2709,7 +2709,7 @@ static void __core_scsi3_complete_pro_preempt(
 	enum preempt_type preempt_type)
 {
 	struct se_node_acl *nacl = pr_reg->pr_reg_nacl;
-	const struct target_core_fabric_ops *tfo = nacl->se_tpg->se_tpg_tfo;
+	const struct target_fabric_ops *tfo = nacl->se_tpg->se_tpg_tfo;
 	char i_buf[PR_REG_ISID_ID_LEN];
 
 	memset(i_buf, 0, PR_REG_ISID_ID_LEN);
@@ -3094,7 +3094,7 @@ core_scsi3_emulate_pro_register_and_move(struct se_cmd *cmd, u64 res_key,
 	struct se_node_acl *pr_res_nacl, *pr_reg_nacl, *dest_node_acl = NULL;
 	struct se_port *se_port;
 	struct se_portal_group *se_tpg, *dest_se_tpg = NULL;
-	const struct target_core_fabric_ops *dest_tf_ops = NULL, *tf_ops;
+	const struct target_fabric_ops *dest_tf_ops = NULL, *tf_ops;
 	struct t10_pr_registration *pr_reg, *pr_res_holder, *dest_pr_reg;
 	struct t10_reservation *pr_tmpl = &dev->t10_pr;
 	unsigned char *buf;
diff --git a/drivers/target/target_core_tpg.c b/drivers/target/target_core_tpg.c
index c0c1f67..12c6c13 100644
--- a/drivers/target/target_core_tpg.c
+++ b/drivers/target/target_core_tpg.c
@@ -630,15 +630,106 @@ static int core_tpg_setup_virtual_lun0(struct se_portal_group *se_tpg)
 	return 0;
 }
 
+static int target_fabric_ops_check(const struct target_fabric_ops *tfo)
+{
+	if (!tfo->get_fabric_name) {
+		pr_err("Missing tfo->get_fabric_name()\n");
+		return -EINVAL;
+	}
+	if (!tfo->tpg_get_wwn) {
+		pr_err("Missing tfo->tpg_get_wwn()\n");
+		return -EINVAL;
+	}
+	if (!tfo->tpg_get_tag) {
+		pr_err("Missing tfo->tpg_get_tag()\n");
+		return -EINVAL;
+	}
+	if (!tfo->tpg_check_demo_mode) {
+		pr_err("Missing tfo->tpg_check_demo_mode()\n");
+		return -EINVAL;
+	}
+	if (!tfo->tpg_check_demo_mode_cache) {
+		pr_err("Missing tfo->tpg_check_demo_mode_cache()\n");
+		return -EINVAL;
+	}
+	if (!tfo->tpg_check_demo_mode_write_protect) {
+		pr_err("Missing tfo->tpg_check_demo_mode_write_protect()\n");
+		return -EINVAL;
+	}
+	if (!tfo->tpg_check_prod_mode_write_protect) {
+		pr_err("Missing tfo->tpg_check_prod_mode_write_protect()\n");
+		return -EINVAL;
+	}
+	if (!tfo->tpg_get_inst_index) {
+		pr_err("Missing tfo->tpg_get_inst_index()\n");
+		return -EINVAL;
+	}
+	if (!tfo->release_cmd) {
+		pr_err("Missing tfo->release_cmd()\n");
+		return -EINVAL;
+	}
+	if (!tfo->shutdown_session) {
+		pr_err("Missing tfo->shutdown_session()\n");
+		return -EINVAL;
+	}
+	if (!tfo->close_session) {
+		pr_err("Missing tfo->close_session()\n");
+		return -EINVAL;
+	}
+	if (!tfo->sess_get_index) {
+		pr_err("Missing tfo->sess_get_index()\n");
+		return -EINVAL;
+	}
+	if (!tfo->write_pending) {
+		pr_err("Missing tfo->write_pending()\n");
+		return -EINVAL;
+	}
+	if (!tfo->write_pending_status) {
+		pr_err("Missing tfo->write_pending_status()\n");
+		return -EINVAL;
+	}
+	if (!tfo->set_default_node_attributes) {
+		pr_err("Missing tfo->set_default_node_attributes()\n");
+		return -EINVAL;
+	}
+	if (!tfo->get_cmd_state) {
+		pr_err("Missing tfo->get_cmd_state()\n");
+		return -EINVAL;
+	}
+	if (!tfo->queue_data_in) {
+		pr_err("Missing tfo->queue_data_in()\n");
+		return -EINVAL;
+	}
+	if (!tfo->queue_status) {
+		pr_err("Missing tfo->queue_status()\n");
+		return -EINVAL;
+	}
+	if (!tfo->queue_tm_rsp) {
+		pr_err("Missing tfo->queue_tm_rsp()\n");
+		return -EINVAL;
+	}
+	if (!tfo->aborted_task) {
+		pr_err("Missing tfo->aborted_task()\n");
+		return -EINVAL;
+	}
+
+	return 0;
+}
+
 int core_tpg_register(
-	const struct target_core_fabric_ops *tfo,
+	const struct target_fabric_ops *tfo,
 	struct se_wwn *se_wwn,
 	struct se_portal_group *se_tpg,
 	int proto_id)
 {
 	struct se_lun *lun;
+	int ret;
 	u32 i;
 
+	ret = target_fabric_ops_check(tfo);
+	if (ret)
+		return ret;
+
 	se_tpg->tpg_lun_list = array_zalloc(TRANSPORT_MAX_LUNS_PER_TPG,
 			sizeof(struct se_lun), GFP_KERNEL);
 	if (!se_tpg->tpg_lun_list) {
@@ -694,7 +785,7 @@ EXPORT_SYMBOL(core_tpg_register);
 
 int core_tpg_deregister(struct se_portal_group *se_tpg)
 {
-	const struct target_core_fabric_ops *tfo = se_tpg->se_tpg_tfo;
+	const struct target_fabric_ops *tfo = se_tpg->se_tpg_tfo;
 	struct se_node_acl *nacl, *nacl_tmp;
 
 	pr_debug("TARGET_CORE[%s]: Deallocating portal_group for endpoint: %s, "
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c
index 6aa6287..b11ea1e 100644
--- a/drivers/target/target_core_transport.c
+++ b/drivers/target/target_core_transport.c
@@ -321,7 +321,7 @@ void __transport_register_session(
 	struct se_session *se_sess,
 	void *fabric_sess_ptr)
 {
-	const struct target_core_fabric_ops *tfo = se_tpg->se_tpg_tfo;
+	const struct target_fabric_ops *tfo = se_tpg->se_tpg_tfo;
 	unsigned char buf[PR_REG_ISID_LEN];
 
 	se_sess->se_tpg = se_tpg;
@@ -495,7 +495,7 @@ EXPORT_SYMBOL(transport_free_session);
 void transport_deregister_session(struct se_session *se_sess)
 {
 	struct se_portal_group *se_tpg = se_sess->se_tpg;
-	const struct target_core_fabric_ops *se_tfo;
+	const struct target_fabric_ops *se_tfo;
 	struct se_node_acl *se_nacl;
 	unsigned long flags;
 	bool comp_nacl = true;
@@ -1152,7 +1152,7 @@ target_cmd_size_check(struct se_cmd *cmd, unsigned int size)
  */
 void transport_init_se_cmd(
 	struct se_cmd *cmd,
-	const struct target_core_fabric_ops *tfo,
+	const struct target_fabric_ops *tfo,
 	struct se_session *se_sess,
 	u32 data_length,
 	int data_direction,
@@ -1401,7 +1401,7 @@ int target_submit_cmd_map_sgls(struct se_cmd *se_cmd, struct se_session *se_sess
 	/*
 	 * Initialize se_cmd for target operation.  From this point
 	 * exceptions are handled by sending exception status via
-	 * target_core_fabric_ops->queue_status() callback
+	 * target_fabric_ops->queue_status() callback
 	 */
 	transport_init_se_cmd(se_cmd, se_tpg->se_tpg_tfo, se_sess,
 				data_length, data_dir, task_attr, sense);
diff --git a/drivers/target/target_core_xcopy.c b/drivers/target/target_core_xcopy.c
index 3556a9d..151481a 100644
--- a/drivers/target/target_core_xcopy.c
+++ b/drivers/target/target_core_xcopy.c
@@ -416,7 +416,7 @@ static int xcopy_pt_queue_status(struct se_cmd *se_cmd)
 	return 0;
 }
 
-static const struct target_core_fabric_ops xcopy_pt_tfo = {
+static const struct target_fabric_ops xcopy_pt_tfo = {
 	.get_fabric_name	= xcopy_pt_get_fabric_name,
 	.get_cmd_state		= xcopy_pt_get_cmd_state,
 	.release_cmd		= xcopy_pt_release_cmd,
diff --git a/drivers/target/tcm_fc/tcm_fc.h b/drivers/target/tcm_fc/tcm_fc.h
index 39909da..6a06a15 100644
--- a/drivers/target/tcm_fc/tcm_fc.h
+++ b/drivers/target/tcm_fc/tcm_fc.h
@@ -101,6 +101,11 @@ struct ft_tpg {
 	struct workqueue_struct *workqueue;
 };
 
+static inline struct ft_tpg *ft_tpg(struct se_portal_group *se_tpg)
+{
+	return container_of(se_tpg, struct ft_tpg, se_tpg);
+}
+
 struct ft_lport_wwn {
 	u64 wwpn;
 	char name[FT_NAMELEN];
@@ -134,6 +139,7 @@ extern unsigned int ft_debug_logging;
 /*
  * Fabric methods.
  */
+extern const struct target_fabric_ops ft_fabric_ops;
 
 /*
  * Session ops.
@@ -151,15 +157,8 @@ int ft_lport_notify(struct notifier_block *, unsigned long, void *);
 /*
  * IO methods.
  */
-int ft_check_stop_free(struct se_cmd *);
-void ft_release_cmd(struct se_cmd *);
 int ft_queue_status(struct se_cmd *);
 int ft_queue_data_in(struct se_cmd *);
-int ft_write_pending(struct se_cmd *);
-int ft_write_pending_status(struct se_cmd *);
-int ft_get_cmd_state(struct se_cmd *);
-void ft_queue_tm_resp(struct se_cmd *);
-void ft_aborted_task(struct se_cmd *);
 
 /*
  * other internal functions.
@@ -169,7 +168,6 @@ struct ft_tpg *ft_lport_find_tpg(struct fc_lport *);
 struct ft_node_acl *ft_acl_get(struct ft_tpg *, struct fc_rport_priv *);
 
 void ft_recv_write_data(struct ft_cmd *, struct fc_frame *);
-void ft_dump_cmd(struct ft_cmd *, const char *caller);
 
 ssize_t ft_format_wwn(char *, size_t, u64);
 
diff --git a/drivers/target/tcm_fc/tfc_cmd.c b/drivers/target/tcm_fc/tfc_cmd.c
index d62282f..717ac8d 100644
--- a/drivers/target/tcm_fc/tfc_cmd.c
+++ b/drivers/target/tcm_fc/tfc_cmd.c
@@ -79,7 +79,7 @@ static void _ft_dump_cmd(struct ft_cmd *cmd, const char *caller)
 	}
 }
 
-void ft_dump_cmd(struct ft_cmd *cmd, const char *caller)
+static void ft_dump_cmd(struct ft_cmd *cmd, const char *caller)
 {
 	if (unlikely(ft_debug_logging))
 		_ft_dump_cmd(cmd, caller);
@@ -103,14 +103,14 @@ static void ft_free_cmd(struct ft_cmd *cmd)
 	ft_sess_put(sess);	/* undo get from lookup at recv */
 }
 
-void ft_release_cmd(struct se_cmd *se_cmd)
+static void ft_release_cmd(struct se_cmd *se_cmd)
 {
 	struct ft_cmd *cmd = container_of(se_cmd, struct ft_cmd, se_cmd);
 
 	ft_free_cmd(cmd);
 }
 
-int ft_check_stop_free(struct se_cmd *se_cmd)
+static int ft_check_stop_free(struct se_cmd *se_cmd)
 {
 	transport_generic_free_cmd(se_cmd, 0);
 	return 1;
@@ -187,7 +187,7 @@ int ft_queue_status(struct se_cmd *se_cmd)
 	return 0;
 }
 
-int ft_write_pending_status(struct se_cmd *se_cmd)
+static int ft_write_pending_status(struct se_cmd *se_cmd)
 {
 	struct ft_cmd *cmd = container_of(se_cmd, struct ft_cmd, se_cmd);
 
@@ -197,7 +197,7 @@ int ft_write_pending_status(struct se_cmd *se_cmd)
 /*
  * Send TX_RDY (transfer ready).
  */
-int ft_write_pending(struct se_cmd *se_cmd)
+static int ft_write_pending(struct se_cmd *se_cmd)
 {
 	struct ft_cmd *cmd = container_of(se_cmd, struct ft_cmd, se_cmd);
 	struct fc_frame *fp;
@@ -246,7 +246,7 @@ int ft_write_pending(struct se_cmd *se_cmd)
 	return 0;
 }
 
-int ft_get_cmd_state(struct se_cmd *se_cmd)
+static int ft_get_cmd_state(struct se_cmd *se_cmd)
 {
 	return 0;
 }
@@ -400,7 +400,7 @@ static void ft_send_tm(struct ft_cmd *cmd)
 /*
  * Send status from completed task management request.
  */
-void ft_queue_tm_resp(struct se_cmd *se_cmd)
+static void ft_queue_tm_resp(struct se_cmd *se_cmd)
 {
 	struct ft_cmd *cmd = container_of(se_cmd, struct ft_cmd, se_cmd);
 	struct se_tmr_req *tmr = se_cmd->se_tmr_req;
@@ -429,11 +429,69 @@ void ft_queue_tm_resp(struct se_cmd *se_cmd)
 	ft_send_resp_code(cmd, code);
 }
 
-void ft_aborted_task(struct se_cmd *se_cmd)
+static void ft_aborted_task(struct se_cmd *se_cmd)
 {
 	return;
 }
 
+static char *ft_get_fabric_name(void)
+{
+	return "fc";
+}
+
+static char *ft_get_fabric_wwn(struct se_portal_group *se_tpg)
+{
+	return ft_tpg(se_tpg)->lport_wwn->name;
+}
+
+static u16 ft_get_tag(struct se_portal_group *se_tpg)
+{
+	/*
+	 * This tag is used when forming SCSI Name identifier in EVPD=1 0x83
+	 * to represent the SCSI Target Port.
+	 */
+	return ft_tpg(se_tpg)->index;
+}
+
+static int ft_check_false(struct se_portal_group *se_tpg)
+{
+	return 0;
+}
+
+static void ft_set_default_node_attr(struct se_node_acl *se_nacl)
+{
+}
+
+static u32 ft_tpg_get_inst_index(struct se_portal_group *se_tpg)
+{
+	return ft_tpg(se_tpg)->index;
+}
+
+const struct target_fabric_ops ft_fabric_ops = {
+	.node_acl_size			= sizeof(struct ft_node_acl),
+	.get_fabric_name =		ft_get_fabric_name,
+	.tpg_get_wwn =			ft_get_fabric_wwn,
+	.tpg_get_tag =			ft_get_tag,
+	.tpg_check_demo_mode =		ft_check_false,
+	.tpg_check_demo_mode_cache =	ft_check_false,
+	.tpg_check_demo_mode_write_protect = ft_check_false,
+	.tpg_check_prod_mode_write_protect = ft_check_false,
+	.tpg_get_inst_index =		ft_tpg_get_inst_index,
+	.check_stop_free =		ft_check_stop_free,
+	.release_cmd =			ft_release_cmd,
+	.shutdown_session =		ft_sess_shutdown,
+	.close_session =		ft_sess_close,
+	.sess_get_index =		ft_sess_get_index,
+	.write_pending =		ft_write_pending,
+	.write_pending_status =		ft_write_pending_status,
+	.set_default_node_attributes =	ft_set_default_node_attr,
+	.get_cmd_state =		ft_get_cmd_state,
+	.queue_data_in =		ft_queue_data_in,
+	.queue_status =			ft_queue_status,
+	.queue_tm_rsp =			ft_queue_tm_resp,
+	.aborted_task =			ft_aborted_task,
+};
+
 static void ft_send_work(struct work_struct *work);
 
 /*
diff --git a/drivers/target/tcm_fc/tfc_conf.c b/drivers/target/tcm_fc/tfc_conf.c
index ee56531..f25ce76 100644
--- a/drivers/target/tcm_fc/tfc_conf.c
+++ b/drivers/target/tcm_fc/tfc_conf.c
@@ -47,8 +47,6 @@
 
 #include "tcm_fc.h"
 
-static const struct target_core_fabric_ops ft_fabric_ops;
-
 static LIST_HEAD(ft_wwn_list);
 DEFINE_MUTEX(ft_lport_lock);
 
@@ -408,79 +406,15 @@ static struct configfs_attribute *ft_wwn_attrs[] = {
 	NULL,
 };
 
-static inline struct ft_tpg *ft_tpg(struct se_portal_group *se_tpg)
-{
-	return container_of(se_tpg, struct ft_tpg, se_tpg);
-}
-
-static char *ft_get_fabric_name(void)
-{
-	return "fc";
-}
-
-static char *ft_get_fabric_wwn(struct se_portal_group *se_tpg)
-{
-	return ft_tpg(se_tpg)->lport_wwn->name;
-}
-
-static u16 ft_get_tag(struct se_portal_group *se_tpg)
-{
-	/*
-	 * This tag is used when forming SCSI Name identifier in EVPD=1 0x83
-	 * to represent the SCSI Target Port.
-	 */
-	return ft_tpg(se_tpg)->index;
-}
-
-static int ft_check_false(struct se_portal_group *se_tpg)
-{
-	return 0;
-}
+static const struct target_fabric_configfs_ops ft_fabric_configfs_ops = {
+	.module				= THIS_MODULE,
+	.name				= "fc",
 
-static void ft_set_default_node_attr(struct se_node_acl *se_nacl)
-{
-}
-
-static u32 ft_tpg_get_inst_index(struct se_portal_group *se_tpg)
-{
-	return ft_tpg(se_tpg)->index;
-}
-
-static const struct target_core_fabric_ops ft_fabric_ops = {
-	.module =			THIS_MODULE,
-	.name =				"fc",
-	.node_acl_size =		sizeof(struct ft_node_acl),
-	.get_fabric_name =		ft_get_fabric_name,
-	.tpg_get_wwn =			ft_get_fabric_wwn,
-	.tpg_get_tag =			ft_get_tag,
-	.tpg_check_demo_mode =		ft_check_false,
-	.tpg_check_demo_mode_cache =	ft_check_false,
-	.tpg_check_demo_mode_write_protect = ft_check_false,
-	.tpg_check_prod_mode_write_protect = ft_check_false,
-	.tpg_get_inst_index =		ft_tpg_get_inst_index,
-	.check_stop_free =		ft_check_stop_free,
-	.release_cmd =			ft_release_cmd,
-	.shutdown_session =		ft_sess_shutdown,
-	.close_session =		ft_sess_close,
-	.sess_get_index =		ft_sess_get_index,
-	.sess_get_initiator_sid =	NULL,
-	.write_pending =		ft_write_pending,
-	.write_pending_status =		ft_write_pending_status,
-	.set_default_node_attributes =	ft_set_default_node_attr,
-	.get_cmd_state =		ft_get_cmd_state,
-	.queue_data_in =		ft_queue_data_in,
-	.queue_status =			ft_queue_status,
-	.queue_tm_rsp =			ft_queue_tm_resp,
-	.aborted_task =			ft_aborted_task,
-	/*
-	 * Setup function pointers for generic logic in
-	 * target_core_fabric_configfs.c
-	 */
-	.fabric_make_wwn =		&ft_add_wwn,
-	.fabric_drop_wwn =		&ft_del_wwn,
-	.fabric_make_tpg =		&ft_add_tpg,
-	.fabric_drop_tpg =		&ft_del_tpg,
-	.fabric_init_nodeacl =		&ft_init_nodeacl,
+	.fabric_make_wwn		= ft_add_wwn,
+	.fabric_drop_wwn		= ft_del_wwn,
+	.fabric_make_tpg		= ft_add_tpg,
+	.fabric_drop_tpg		= ft_del_tpg,
+	.fabric_init_nodeacl		= ft_init_nodeacl,
 
 	.tfc_wwn_attrs			= ft_wwn_attrs,
 	.tfc_tpg_nacl_base_attrs	= ft_nacl_base_attrs,
@@ -494,7 +428,7 @@ static int __init ft_init(void)
 {
 	int ret;
 
-	ret = target_register_template(&ft_fabric_ops);
+	ret = target_register_template(&ft_fabric_configfs_ops);
 	if (ret)
 		goto out;
 
@@ -507,7 +441,7 @@ static int __init ft_init(void)
 	return 0;
 
 out_unregister_template:
-	target_unregister_template(&ft_fabric_ops);
+	target_unregister_template(&ft_fabric_configfs_ops);
 out:
 	return ret;
 }
@@ -518,7 +452,7 @@ static void __exit ft_exit(void)
 					   &ft_notifier);
 	fc_fc4_deregister_provider(FC_TYPE_FCP, &ft_prov);
 	fc_lport_iterate(ft_lport_del, NULL);
-	target_unregister_template(&ft_fabric_ops);
+	target_unregister_template(&ft_fabric_configfs_ops);
 	synchronize_rcu();
 }
 
diff --git a/drivers/usb/gadget/legacy/tcm_usb_gadget.c b/drivers/usb/gadget/legacy/tcm_usb_gadget.c
index 16b9a16..b502eba 100644
--- a/drivers/usb/gadget/legacy/tcm_usb_gadget.c
+++ b/drivers/usb/gadget/legacy/tcm_usb_gadget.c
@@ -28,8 +28,6 @@
 
 USB_GADGET_COMPOSITE_OPTIONS();
 
-static const struct target_core_fabric_ops usbg_ops;
-
 static inline struct f_uas *to_f_uas(struct usb_function *f)
 {
 	return container_of(f, struct f_uas, function);
@@ -1355,6 +1353,39 @@ static void usbg_aborted_task(struct se_cmd *se_cmd)
 	return;
 }
 
+static int usbg_check_stop_free(struct se_cmd *se_cmd)
+{
+	struct usbg_cmd *cmd = container_of(se_cmd, struct usbg_cmd,
+			se_cmd);
+
+	kref_put(&cmd->ref, usbg_cmd_release);
+	return 1;
+}
+
+static const struct target_fabric_ops usbg_ops = {
+	.get_fabric_name		= usbg_get_fabric_name,
+	.tpg_get_wwn			= usbg_get_fabric_wwn,
+	.tpg_get_tag			= usbg_get_tag,
+	.tpg_check_demo_mode		= usbg_check_true,
+	.tpg_check_demo_mode_cache	= usbg_check_false,
+	.tpg_check_demo_mode_write_protect = usbg_check_false,
+	.tpg_check_prod_mode_write_protect = usbg_check_false,
+	.tpg_get_inst_index		= usbg_tpg_get_inst_index,
+	.release_cmd			= usbg_release_cmd,
+	.shutdown_session		= usbg_shutdown_session,
+	.close_session			= usbg_close_session,
+	.sess_get_index			= usbg_sess_get_index,
+	.write_pending			= usbg_send_write_request,
+	.write_pending_status		= usbg_write_pending_status,
+	.set_default_node_attributes	= usbg_set_default_node_attrs,
+	.get_cmd_state			= usbg_get_cmd_state,
+	.queue_data_in			= usbg_send_read_response,
+	.queue_status			= usbg_send_status_response,
+	.queue_tm_rsp			= usbg_queue_tm_rsp,
+	.aborted_task			= usbg_aborted_task,
+	.check_stop_free		= usbg_check_stop_free,
+};
+
 static const char *usbg_check_wwn(const char *name)
 {
 	const char *n;
@@ -1700,40 +1731,9 @@ static void usbg_port_unlink(struct se_portal_group *se_tpg,
 	smp_mb__after_atomic();
 }
 
-static int usbg_check_stop_free(struct se_cmd *se_cmd)
-{
-	struct usbg_cmd *cmd = container_of(se_cmd, struct usbg_cmd,
-			se_cmd);
-
-	kref_put(&cmd->ref, usbg_cmd_release);
-	return 1;
-}
-
-static const struct target_core_fabric_ops usbg_ops = {
+static const struct target_fabric_configfs_ops usbg_configfs_ops = {
 	.module				= THIS_MODULE,
 	.name				= "usb_gadget",
-	.get_fabric_name		= usbg_get_fabric_name,
-	.tpg_get_wwn			= usbg_get_fabric_wwn,
-	.tpg_get_tag			= usbg_get_tag,
-	.tpg_check_demo_mode		= usbg_check_true,
-	.tpg_check_demo_mode_cache	= usbg_check_false,
-	.tpg_check_demo_mode_write_protect = usbg_check_false,
-	.tpg_check_prod_mode_write_protect = usbg_check_false,
-	.tpg_get_inst_index		= usbg_tpg_get_inst_index,
-	.release_cmd			= usbg_release_cmd,
-	.shutdown_session		= usbg_shutdown_session,
-	.close_session			= usbg_close_session,
-	.sess_get_index			= usbg_sess_get_index,
-	.sess_get_initiator_sid		= NULL,
-	.write_pending			= usbg_send_write_request,
-	.write_pending_status		= usbg_write_pending_status,
-	.set_default_node_attributes	= usbg_set_default_node_attrs,
-	.get_cmd_state			= usbg_get_cmd_state,
-	.queue_data_in			= usbg_send_read_response,
-	.queue_status			= usbg_send_status_response,
-	.queue_tm_rsp			= usbg_queue_tm_rsp,
-	.aborted_task			= usbg_aborted_task,
-	.check_stop_free		= usbg_check_stop_free,
 
 	.fabric_make_wwn		= usbg_make_tport,
 	.fabric_drop_wwn		= usbg_drop_tport,
@@ -2253,13 +2253,13 @@ static void usbg_detach(struct usbg_tpg *tpg)
 
 static int __init usb_target_gadget_init(void)
 {
-	return target_register_template(&usbg_ops);
+	return target_register_template(&usbg_configfs_ops);
 }
 module_init(usb_target_gadget_init);
 
 static void __exit usb_target_gadget_exit(void)
 {
-	target_unregister_template(&usbg_ops);
+	target_unregister_template(&usbg_configfs_ops);
 }
 module_exit(usb_target_gadget_exit);
 
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c
index dcd228b..1b79d9a 100644
--- a/drivers/vhost/scsi.c
+++ b/drivers/vhost/scsi.c
@@ -206,7 +206,6 @@ struct vhost_scsi {
 	int vs_events_nr; /* num of pending events, protected by vq->mutex */
 };
 
-static struct target_core_fabric_ops vhost_scsi_ops;
 static struct workqueue_struct *vhost_scsi_workqueue;
 
 /* Global spinlock to protect vhost_scsi TPG list for vhost IOCTL access */
@@ -454,6 +453,31 @@ static int vhost_scsi_check_stop_free(struct se_cmd *se_cmd)
 	return target_put_sess_cmd(se_cmd);
 }
 
+static struct target_fabric_ops vhost_scsi_ops = {
+	.get_fabric_name		= vhost_scsi_get_fabric_name,
+	.tpg_get_wwn			= vhost_scsi_get_fabric_wwn,
+	.tpg_get_tag			= vhost_scsi_get_tpgt,
+	.tpg_check_demo_mode		= vhost_scsi_check_true,
+	.tpg_check_demo_mode_cache	= vhost_scsi_check_true,
+	.tpg_check_demo_mode_write_protect = vhost_scsi_check_false,
+	.tpg_check_prod_mode_write_protect = vhost_scsi_check_false,
+	.tpg_check_prot_fabric_only	= vhost_scsi_check_prot_fabric_only,
+	.tpg_get_inst_index		= vhost_scsi_tpg_get_inst_index,
+	.release_cmd			= vhost_scsi_release_cmd,
+	.check_stop_free		= vhost_scsi_check_stop_free,
+	.shutdown_session		= vhost_scsi_shutdown_session,
+	.close_session			= vhost_scsi_close_session,
+	.sess_get_index			= vhost_scsi_sess_get_index,
+	.write_pending			= vhost_scsi_write_pending,
+	.write_pending_status		= vhost_scsi_write_pending_status,
+	.set_default_node_attributes	= vhost_scsi_set_default_node_attrs,
+	.get_cmd_state			= vhost_scsi_get_cmd_state,
+	.queue_data_in			= vhost_scsi_queue_data_in,
+	.queue_status			= vhost_scsi_queue_status,
+	.queue_tm_rsp			= vhost_scsi_queue_tm_rsp,
+	.aborted_task			= vhost_scsi_aborted_task,
+};
+
 static void
 vhost_scsi_do_evt_work(struct vhost_scsi *vs, struct vhost_scsi_evt *evt)
 {
@@ -2122,35 +2146,10 @@ static struct configfs_attribute *vhost_scsi_wwn_attrs[] = {
 	NULL,
 };
 
-static struct target_core_fabric_ops vhost_scsi_ops = {
+static struct target_fabric_configfs_ops vhost_scsi_configfs_ops = {
 	.module				= THIS_MODULE,
 	.name				= "vhost",
-	.get_fabric_name		= vhost_scsi_get_fabric_name,
-	.tpg_get_wwn			= vhost_scsi_get_fabric_wwn,
-	.tpg_get_tag			= vhost_scsi_get_tpgt,
-	.tpg_check_demo_mode		= vhost_scsi_check_true,
-	.tpg_check_demo_mode_cache	= vhost_scsi_check_true,
-	.tpg_check_demo_mode_write_protect = vhost_scsi_check_false,
-	.tpg_check_prod_mode_write_protect = vhost_scsi_check_false,
-	.tpg_check_prot_fabric_only	= vhost_scsi_check_prot_fabric_only,
-	.tpg_get_inst_index		= vhost_scsi_tpg_get_inst_index,
-	.release_cmd			= vhost_scsi_release_cmd,
-	.check_stop_free		= vhost_scsi_check_stop_free,
-	.shutdown_session		= vhost_scsi_shutdown_session,
-	.close_session			= vhost_scsi_close_session,
-	.sess_get_index			= vhost_scsi_sess_get_index,
-	.sess_get_initiator_sid		= NULL,
-	.write_pending			= vhost_scsi_write_pending,
-	.write_pending_status		= vhost_scsi_write_pending_status,
-	.set_default_node_attributes	= vhost_scsi_set_default_node_attrs,
-	.get_cmd_state			= vhost_scsi_get_cmd_state,
-	.queue_data_in			= vhost_scsi_queue_data_in,
-	.queue_status			= vhost_scsi_queue_status,
-	.queue_tm_rsp			= vhost_scsi_queue_tm_rsp,
-	.aborted_task			= vhost_scsi_aborted_task,
-	/*
-	 * Setup callers for generic logic in target_core_fabric_configfs.c
-	 */
+
 	.fabric_make_wwn		= vhost_scsi_make_tport,
 	.fabric_drop_wwn		= vhost_scsi_drop_tport,
 	.fabric_make_tpg		= vhost_scsi_make_tpg,
@@ -2183,7 +2182,7 @@ static int __init vhost_scsi_init(void)
 	if (ret < 0)
 		goto out_destroy_workqueue;
 
-	ret = target_register_template(&vhost_scsi_ops);
+	ret = target_register_template(&vhost_scsi_configfs_ops);
 	if (ret < 0)
 		goto out_vhost_scsi_deregister;
 
@@ -2199,7 +2198,7 @@ out:
 
 static void vhost_scsi_exit(void)
 {
-	target_unregister_template(&vhost_scsi_ops);
+	target_unregister_template(&vhost_scsi_configfs_ops);
 	vhost_scsi_deregister();
 	destroy_workqueue(vhost_scsi_workqueue);
 };
diff --git a/drivers/xen/xen-scsiback.c b/drivers/xen/xen-scsiback.c
index 8b7dd47..355ef48 100644
--- a/drivers/xen/xen-scsiback.c
+++ b/drivers/xen/xen-scsiback.c
@@ -203,8 +203,6 @@ static LIST_HEAD(scsiback_free_pages);
 static DEFINE_MUTEX(scsiback_mutex);
 static LIST_HEAD(scsiback_list);
 
-static const struct target_core_fabric_ops scsiback_ops;
-
 static void scsiback_get(struct vscsibk_info *info)
 {
 	atomic_inc(&info->nr_unreplied_reqs);
@@ -1439,6 +1437,40 @@ static void scsiback_aborted_task(struct se_cmd *se_cmd)
 {
 }
 
+static int scsiback_check_true(struct se_portal_group *se_tpg)
+{
+	return 1;
+}
+
+static int scsiback_check_false(struct se_portal_group *se_tpg)
+{
+	return 0;
+}
+
+static const struct target_fabric_ops scsiback_ops = {
+	.get_fabric_name		= scsiback_get_fabric_name,
+	.tpg_get_wwn			= scsiback_get_fabric_wwn,
+	.tpg_get_tag			= scsiback_get_tag,
+	.tpg_check_demo_mode		= scsiback_check_true,
+	.tpg_check_demo_mode_cache	= scsiback_check_true,
+	.tpg_check_demo_mode_write_protect = scsiback_check_false,
+	.tpg_check_prod_mode_write_protect = scsiback_check_false,
+	.tpg_get_inst_index		= scsiback_tpg_get_inst_index,
+	.check_stop_free		= scsiback_check_stop_free,
+	.release_cmd			= scsiback_release_cmd,
+	.shutdown_session		= scsiback_shutdown_session,
+	.close_session			= scsiback_close_session,
+	.sess_get_index			= scsiback_sess_get_index,
+	.write_pending			= scsiback_write_pending,
+	.write_pending_status		= scsiback_write_pending_status,
+	.set_default_node_attributes	= scsiback_set_default_node_attrs,
+	.get_cmd_state			= scsiback_get_cmd_state,
+	.queue_data_in			= scsiback_queue_data_in,
+	.queue_status			= scsiback_queue_status,
+	.queue_tm_rsp			= scsiback_queue_tm_rsp,
+	.aborted_task			= scsiback_aborted_task,
+};
+
 static ssize_t scsiback_tpg_param_show_alias(struct se_portal_group *se_tpg,
 					     char *page)
 {
@@ -1794,44 +1826,10 @@ static void scsiback_drop_tpg(struct se_portal_group *se_tpg)
 	kfree(tpg);
 }
 
-static int scsiback_check_true(struct se_portal_group *se_tpg)
-{
-	return 1;
-}
-
-static int scsiback_check_false(struct se_portal_group *se_tpg)
-{
-	return 0;
-}
-
-static const struct target_core_fabric_ops scsiback_ops = {
+static const struct target_fabric_configfs_ops scsiback_configfs_ops = {
 	.module				= THIS_MODULE,
 	.name				= "xen-pvscsi",
-	.get_fabric_name		= scsiback_get_fabric_name,
-	.tpg_get_wwn			= scsiback_get_fabric_wwn,
-	.tpg_get_tag			= scsiback_get_tag,
-	.tpg_check_demo_mode		= scsiback_check_true,
-	.tpg_check_demo_mode_cache	= scsiback_check_true,
-	.tpg_check_demo_mode_write_protect = scsiback_check_false,
-	.tpg_check_prod_mode_write_protect = scsiback_check_false,
-	.tpg_get_inst_index		= scsiback_tpg_get_inst_index,
-	.check_stop_free		= scsiback_check_stop_free,
-	.release_cmd			= scsiback_release_cmd,
-	.shutdown_session		= scsiback_shutdown_session,
-	.close_session			= scsiback_close_session,
-	.sess_get_index			= scsiback_sess_get_index,
-	.sess_get_initiator_sid		= NULL,
-	.write_pending			= scsiback_write_pending,
-	.write_pending_status		= scsiback_write_pending_status,
-	.set_default_node_attributes	= scsiback_set_default_node_attrs,
-	.get_cmd_state			= scsiback_get_cmd_state,
-	.queue_data_in			= scsiback_queue_data_in,
-	.queue_status			= scsiback_queue_status,
-	.queue_tm_rsp			= scsiback_queue_tm_rsp,
-	.aborted_task			= scsiback_aborted_task,
-	/*
-	 * Setup callers for generic logic in target_core_fabric_configfs.c
-	 */
+
 	.fabric_make_wwn		= scsiback_make_tport,
 	.fabric_drop_wwn		= scsiback_drop_tport,
 	.fabric_make_tpg		= scsiback_make_tpg,
@@ -1885,7 +1883,7 @@ static int __init scsiback_init(void)
 	if (ret)
 		goto out_cache_destroy;
 
-	ret = target_register_template(&scsiback_ops);
+	ret = target_register_template(&scsiback_configfs_ops);
 	if (ret)
 		goto out_unregister_xenbus;
 
@@ -1908,7 +1906,7 @@ static void __exit scsiback_exit(void)
 			BUG();
 		gnttab_free_pages(1, &page);
 	}
-	target_unregister_template(&scsiback_ops);
+	target_unregister_template(&scsiback_configfs_ops);
 	xenbus_unregister_driver(&scsiback_driver);
 	kmem_cache_destroy(scsiback_cachep);
 }
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 042a734..39d7f45 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -508,7 +508,7 @@ struct se_cmd {
 	struct list_head	se_cmd_list;
 	struct completion	cmd_wait_comp;
 	struct kref		cmd_kref;
-	const struct target_core_fabric_ops *se_tfo;
+	const struct target_fabric_ops *se_tfo;
 	sense_reason_t		(*execute_cmd)(struct se_cmd *);
 	sense_reason_t		(*execute_rw)(struct se_cmd *, struct scatterlist *,
 					      u32, enum dma_data_direction);
@@ -882,7 +882,7 @@ struct se_portal_group {
 	/* List of TCM sessions associated wth this TPG */
 	struct list_head	tpg_sess_list;
 	/* Pointer to $FABRIC_MOD dependent code */
-	const struct target_core_fabric_ops *se_tpg_tfo;
+	const struct target_fabric_ops *se_tpg_tfo;
 	struct se_wwn		*se_tpg_wwn;
 	struct config_group	tpg_group;
 	struct config_group	*tpg_default_groups[7];
diff --git a/include/target/target_core_configfs.h b/include/target/target_core_configfs.h
index abd063b..f662e98 100644
--- a/include/target/target_core_configfs.h
+++ b/include/target/target_core_configfs.h
@@ -11,7 +11,7 @@ struct target_fabric_configfs {
 	struct config_group	tf_group;
 	struct config_group	tf_disc_group;
 	struct config_group	*tf_default_groups[2];
-	const struct target_core_fabric_ops *tf_ops;
+	const struct target_fabric_configfs_ops *tf_ops;
 
 	struct config_item_type tf_discovery_cit;
 	struct config_item_type	tf_wwn_cit;
diff --git a/include/target/target_core_fabric.h b/include/target/target_core_fabric.h
index 55654c9..c92ed50 100644
--- a/include/target/target_core_fabric.h
+++ b/include/target/target_core_fabric.h
@@ -1,9 +1,7 @@
 #ifndef TARGET_CORE_FABRIC_H
 #define TARGET_CORE_FABRIC_H
 
-struct target_core_fabric_ops {
-	struct module *module;
-	const char *name;
+struct target_fabric_ops {
 	size_t node_acl_size;
 	char *(*get_fabric_name)(void);
 	char *(*tpg_get_wwn)(struct se_portal_group *);
@@ -57,9 +55,12 @@ struct target_core_fabric_ops {
 	int (*queue_status)(struct se_cmd *);
 	void (*queue_tm_rsp)(struct se_cmd *);
 	void (*aborted_task)(struct se_cmd *);
-	/*
-	 * fabric module calls for target_core_fabric_configfs.c
-	 */
+};
+
+struct target_fabric_configfs_ops {
+	struct module *module;
+	const char *name;
+
 	struct se_wwn *(*fabric_make_wwn)(struct target_fabric_configfs *,
 				struct config_group *, const char *);
 	void (*fabric_drop_wwn)(struct se_wwn *);
@@ -89,8 +90,8 @@ struct target_core_fabric_ops {
 	struct configfs_attribute **tfc_tpg_nacl_param_attrs;
 };
 
-int target_register_template(const struct target_core_fabric_ops *fo);
-void target_unregister_template(const struct target_core_fabric_ops *fo);
+int target_register_template(const struct target_fabric_configfs_ops *fo);
+void target_unregister_template(const struct target_fabric_configfs_ops *fo);
 
 int target_depend_item(struct config_item *item);
 void target_undepend_item(struct config_item *item);
@@ -114,7 +115,7 @@ void	transport_deregister_session(struct se_session *);
 
 
 void	transport_init_se_cmd(struct se_cmd *,
-		const struct target_core_fabric_ops *,
+		const struct target_fabric_ops *,
 		struct se_session *, u32, int, int, unsigned char *);
 sense_reason_t transport_lookup_cmd_lun(struct se_cmd *, u32);
 sense_reason_t target_setup_cmd_from_cdb(struct se_cmd *, unsigned char *);
@@ -162,7 +163,7 @@ 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 *,
 		struct se_node_acl *, const char *);
-int	core_tpg_register(const struct target_core_fabric_ops *,
+int	core_tpg_register(const struct target_fabric_ops *,
 		struct se_wwn *, struct se_portal_group *, int);
 int	core_tpg_deregister(struct se_portal_group *);
 
-- 
1.9.1

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux