]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/target/target_core_configfs.c
target: simplify backend driver registration
[karo-tx-linux.git] / drivers / target / target_core_configfs.c
index 75d89adfccc025f7fa862c5c7aba157113b001ea..57c099dd9da5bef860f6d2af478a973fd10eb4d1 100644 (file)
 #include "target_core_xcopy.h"
 
 #define TB_CIT_SETUP(_name, _item_ops, _group_ops, _attrs)             \
-static void target_core_setup_##_name##_cit(struct se_subsystem_api *sa) \
+static void target_core_setup_##_name##_cit(struct target_backend *tb) \
 {                                                                      \
-       struct target_backend_cits *tbc = &sa->tb_cits;                 \
-       struct config_item_type *cit = &tbc->tb_##_name##_cit;          \
+       struct config_item_type *cit = &tb->tb_##_name##_cit;           \
                                                                        \
        cit->ct_item_ops = _item_ops;                                   \
        cit->ct_group_ops = _group_ops;                                 \
        cit->ct_attrs = _attrs;                                         \
-       cit->ct_owner = sa->owner;                                      \
+       cit->ct_owner = tb->ops->owner;                                 \
+       pr_debug("Setup generic %s\n", __stringify(_name));             \
+}
+
+#define TB_CIT_SETUP_DRV(_name, _item_ops, _group_ops)                 \
+static void target_core_setup_##_name##_cit(struct target_backend *tb) \
+{                                                                      \
+       struct config_item_type *cit = &tb->tb_##_name##_cit;           \
+                                                                       \
+       cit->ct_item_ops = _item_ops;                                   \
+       cit->ct_group_ops = _group_ops;                                 \
+       cit->ct_attrs = tb->ops->tb_##_name##_attrs;                    \
+       cit->ct_owner = tb->ops->owner;                                 \
        pr_debug("Setup generic %s\n", __stringify(_name));             \
 }
 
@@ -116,7 +127,7 @@ static struct target_fabric_configfs *target_core_get_fabric(
 
        mutex_lock(&g_tf_lock);
        list_for_each_entry(tf, &g_tf_list, tf_list) {
-               if (!strcmp(tf->tf_name, name)) {
+               if (!strcmp(tf->tf_ops->name, name)) {
                        atomic_inc(&tf->tf_access_cnt);
                        mutex_unlock(&g_tf_lock);
                        return tf;
@@ -142,8 +153,8 @@ static struct config_group *target_core_register_fabric(
 
        tf = target_core_get_fabric(name);
        if (!tf) {
-               pr_err("target_core_register_fabric() trying autoload for %s\n",
-                       name);
+               pr_debug("target_core_register_fabric() trying autoload for %s\n",
+                        name);
 
                /*
                 * Below are some hardcoded request_module() calls to automatically
@@ -165,8 +176,8 @@ static struct config_group *target_core_register_fabric(
                         */
                        ret = request_module("iscsi_target_mod");
                        if (ret < 0) {
-                               pr_err("request_module() failed for"
-                                      " iscsi_target_mod.ko: %d\n", ret);
+                               pr_debug("request_module() failed for"
+                                        " iscsi_target_mod.ko: %d\n", ret);
                                return ERR_PTR(-EINVAL);
                        }
                } else if (!strncmp(name, "loopback", 8)) {
@@ -178,8 +189,8 @@ static struct config_group *target_core_register_fabric(
                         */
                        ret = request_module("tcm_loop");
                        if (ret < 0) {
-                               pr_err("request_module() failed for"
-                                      " tcm_loop.ko: %d\n", ret);
+                               pr_debug("request_module() failed for"
+                                        " tcm_loop.ko: %d\n", ret);
                                return ERR_PTR(-EINVAL);
                        }
                }
@@ -188,38 +199,29 @@ static struct config_group *target_core_register_fabric(
        }
 
        if (!tf) {
-               pr_err("target_core_get_fabric() failed for %s\n",
-                      name);
+               pr_debug("target_core_get_fabric() failed for %s\n",
+                        name);
                return ERR_PTR(-EINVAL);
        }
        pr_debug("Target_Core_ConfigFS: REGISTER -> Located fabric:"
-                       " %s\n", tf->tf_name);
+                       " %s\n", tf->tf_ops->name);
        /*
         * On a successful target_core_get_fabric() look, the returned
         * struct target_fabric_configfs *tf will contain a usage reference.
         */
        pr_debug("Target_Core_ConfigFS: REGISTER tfc_wwn_cit -> %p\n",
-                       &tf->tf_cit_tmpl.tfc_wwn_cit);
+                       &tf->tf_wwn_cit);
 
        tf->tf_group.default_groups = tf->tf_default_groups;
        tf->tf_group.default_groups[0] = &tf->tf_disc_group;
        tf->tf_group.default_groups[1] = NULL;
 
-       config_group_init_type_name(&tf->tf_group, name,
-                       &tf->tf_cit_tmpl.tfc_wwn_cit);
+       config_group_init_type_name(&tf->tf_group, name, &tf->tf_wwn_cit);
        config_group_init_type_name(&tf->tf_disc_group, "discovery_auth",
-                       &tf->tf_cit_tmpl.tfc_discovery_cit);
+                       &tf->tf_discovery_cit);
 
        pr_debug("Target_Core_ConfigFS: REGISTER -> Allocated Fabric:"
                        " %s\n", tf->tf_group.cg_item.ci_name);
-       /*
-        * Setup tf_ops.tf_subsys pointer for usage with configfs_depend_item()
-        */
-       tf->tf_ops.tf_subsys = tf->tf_subsys;
-       tf->tf_fabric = &tf->tf_group.cg_item;
-       pr_debug("Target_Core_ConfigFS: REGISTER -> Set tf->tf_fabric"
-                       " for %s\n", name);
-
        return &tf->tf_group;
 }
 
@@ -240,13 +242,9 @@ static void target_core_deregister_fabric(
                " tf list\n", config_item_name(item));
 
        pr_debug("Target_Core_ConfigFS: DEREGISTER -> located fabric:"
-                       " %s\n", tf->tf_name);
+                       " %s\n", tf->tf_ops->name);
        atomic_dec(&tf->tf_access_cnt);
 
-       pr_debug("Target_Core_ConfigFS: DEREGISTER -> Releasing"
-                       " tf->tf_fabric for %s\n", tf->tf_name);
-       tf->tf_fabric = NULL;
-
        pr_debug("Target_Core_ConfigFS: DEREGISTER -> Releasing ci"
                        " %s\n", config_item_name(item));
 
@@ -291,98 +289,37 @@ static struct configfs_subsystem target_core_fabrics = {
        },
 };
 
-struct configfs_subsystem *target_core_subsystem[] = {
-       &target_core_fabrics,
-       NULL,
-};
+int target_depend_item(struct config_item *item)
+{
+       return configfs_depend_item(&target_core_fabrics, item);
+}
+EXPORT_SYMBOL(target_depend_item);
+
+void target_undepend_item(struct config_item *item)
+{
+       return configfs_undepend_item(&target_core_fabrics, item);
+}
+EXPORT_SYMBOL(target_undepend_item);
 
 /*##############################################################################
 // Start functions called by external Target Fabrics Modules
 //############################################################################*/
 
-/*
- * First function called by fabric modules to:
- *
- * 1) Allocate a struct target_fabric_configfs and save the *fabric_cit pointer.
- * 2) Add struct target_fabric_configfs to g_tf_list
- * 3) Return struct target_fabric_configfs to fabric module to be passed
- *    into target_fabric_configfs_register().
- */
-struct target_fabric_configfs *target_fabric_configfs_init(
-       struct module *fabric_mod,
-       const char *name)
+static int target_fabric_tf_ops_check(const struct target_core_fabric_ops *tfo)
 {
-       struct target_fabric_configfs *tf;
-
-       if (!(name)) {
-               pr_err("Unable to locate passed fabric name\n");
-               return ERR_PTR(-EINVAL);
+       if (!tfo->name) {
+               pr_err("Missing tfo->name\n");
+               return -EINVAL;
        }
-       if (strlen(name) >= TARGET_FABRIC_NAME_SIZE) {
+       if (strlen(tfo->name) >= TARGET_FABRIC_NAME_SIZE) {
                pr_err("Passed name: %s exceeds TARGET_FABRIC"
-                       "_NAME_SIZE\n", name);
-               return ERR_PTR(-EINVAL);
+                       "_NAME_SIZE\n", tfo->name);
+               return -EINVAL;
        }
-
-       tf = kzalloc(sizeof(struct target_fabric_configfs), GFP_KERNEL);
-       if (!tf)
-               return ERR_PTR(-ENOMEM);
-
-       INIT_LIST_HEAD(&tf->tf_list);
-       atomic_set(&tf->tf_access_cnt, 0);
-       /*
-        * Setup the default generic struct config_item_type's (cits) in
-        * struct target_fabric_configfs->tf_cit_tmpl
-        */
-       tf->tf_module = fabric_mod;
-       target_fabric_setup_cits(tf);
-
-       tf->tf_subsys = target_core_subsystem[0];
-       snprintf(tf->tf_name, TARGET_FABRIC_NAME_SIZE, "%s", name);
-
-       mutex_lock(&g_tf_lock);
-       list_add_tail(&tf->tf_list, &g_tf_list);
-       mutex_unlock(&g_tf_lock);
-
-       pr_debug("<<<<<<<<<<<<<<<<<<<<<< BEGIN FABRIC API >>>>>>>>"
-                       ">>>>>>>>>>>>>>\n");
-       pr_debug("Initialized struct target_fabric_configfs: %p for"
-                       " %s\n", tf, tf->tf_name);
-       return tf;
-}
-EXPORT_SYMBOL(target_fabric_configfs_init);
-
-/*
- * Called by fabric plugins after FAILED target_fabric_configfs_register() call.
- */
-void target_fabric_configfs_free(
-       struct target_fabric_configfs *tf)
-{
-       mutex_lock(&g_tf_lock);
-       list_del(&tf->tf_list);
-       mutex_unlock(&g_tf_lock);
-
-       kfree(tf);
-}
-EXPORT_SYMBOL(target_fabric_configfs_free);
-
-/*
- * Perform a sanity check of the passed tf->tf_ops before completing
- * TCM fabric module registration.
- */
-static int target_fabric_tf_ops_check(
-       struct target_fabric_configfs *tf)
-{
-       struct target_core_fabric_ops *tfo = &tf->tf_ops;
-
        if (!tfo->get_fabric_name) {
                pr_err("Missing tfo->get_fabric_name()\n");
                return -EINVAL;
        }
-       if (!tfo->get_fabric_proto_ident) {
-               pr_err("Missing tfo->get_fabric_proto_ident()\n");
-               return -EINVAL;
-       }
        if (!tfo->tpg_get_wwn) {
                pr_err("Missing tfo->tpg_get_wwn()\n");
                return -EINVAL;
@@ -391,18 +328,6 @@ static int target_fabric_tf_ops_check(
                pr_err("Missing tfo->tpg_get_tag()\n");
                return -EINVAL;
        }
-       if (!tfo->tpg_get_default_depth) {
-               pr_err("Missing tfo->tpg_get_default_depth()\n");
-               return -EINVAL;
-       }
-       if (!tfo->tpg_get_pr_transport_id) {
-               pr_err("Missing tfo->tpg_get_pr_transport_id()\n");
-               return -EINVAL;
-       }
-       if (!tfo->tpg_get_pr_transport_id_len) {
-               pr_err("Missing tfo->tpg_get_pr_transport_id_len()\n");
-               return -EINVAL;
-       }
        if (!tfo->tpg_check_demo_mode) {
                pr_err("Missing tfo->tpg_check_demo_mode()\n");
                return -EINVAL;
@@ -419,14 +344,6 @@ static int target_fabric_tf_ops_check(
                pr_err("Missing tfo->tpg_check_prod_mode_write_protect()\n");
                return -EINVAL;
        }
-       if (!tfo->tpg_alloc_fabric_acl) {
-               pr_err("Missing tfo->tpg_alloc_fabric_acl()\n");
-               return -EINVAL;
-       }
-       if (!tfo->tpg_release_fabric_acl) {
-               pr_err("Missing tfo->tpg_release_fabric_acl()\n");
-               return -EINVAL;
-       }
        if (!tfo->tpg_get_inst_index) {
                pr_err("Missing tfo->tpg_get_inst_index()\n");
                return -EINVAL;
@@ -459,10 +376,6 @@ static int target_fabric_tf_ops_check(
                pr_err("Missing tfo->set_default_node_attributes()\n");
                return -EINVAL;
        }
-       if (!tfo->get_task_tag) {
-               pr_err("Missing tfo->get_task_tag()\n");
-               return -EINVAL;
-       }
        if (!tfo->get_cmd_state) {
                pr_err("Missing tfo->get_cmd_state()\n");
                return -EINVAL;
@@ -508,77 +421,50 @@ static int target_fabric_tf_ops_check(
        return 0;
 }
 
-/*
- * Called 2nd from fabric module with returned parameter of
- * struct target_fabric_configfs * from target_fabric_configfs_init().
- *
- * Upon a successful registration, the new fabric's struct config_item is
- * return.  Also, a pointer to this struct is set in the passed
- * struct target_fabric_configfs.
- */
-int target_fabric_configfs_register(
-       struct target_fabric_configfs *tf)
+int target_register_template(const struct target_core_fabric_ops *fo)
 {
+       struct target_fabric_configfs *tf;
        int ret;
 
+       ret = target_fabric_tf_ops_check(fo);
+       if (ret)
+               return ret;
+
+       tf = kzalloc(sizeof(struct target_fabric_configfs), GFP_KERNEL);
        if (!tf) {
-               pr_err("Unable to locate target_fabric_configfs"
-                       " pointer\n");
-               return -EINVAL;
-       }
-       if (!tf->tf_subsys) {
-               pr_err("Unable to target struct config_subsystem"
-                       " pointer\n");
-               return -EINVAL;
+               pr_err("%s: could not allocate memory!\n", __func__);
+               return -ENOMEM;
        }
-       ret = target_fabric_tf_ops_check(tf);
-       if (ret < 0)
-               return ret;
 
-       pr_debug("<<<<<<<<<<<<<<<<<<<<<< END FABRIC API >>>>>>>>>>>>"
-               ">>>>>>>>>>\n");
+       INIT_LIST_HEAD(&tf->tf_list);
+       atomic_set(&tf->tf_access_cnt, 0);
+       tf->tf_ops = fo;
+       target_fabric_setup_cits(tf);
+
+       mutex_lock(&g_tf_lock);
+       list_add_tail(&tf->tf_list, &g_tf_list);
+       mutex_unlock(&g_tf_lock);
+
        return 0;
 }
-EXPORT_SYMBOL(target_fabric_configfs_register);
+EXPORT_SYMBOL(target_register_template);
 
-void target_fabric_configfs_deregister(
-       struct target_fabric_configfs *tf)
+void target_unregister_template(const struct target_core_fabric_ops *fo)
 {
-       struct configfs_subsystem *su;
+       struct target_fabric_configfs *t;
 
-       if (!tf) {
-               pr_err("Unable to locate passed target_fabric_"
-                       "configfs\n");
-               return;
-       }
-       su = tf->tf_subsys;
-       if (!su) {
-               pr_err("Unable to locate passed tf->tf_subsys"
-                       " pointer\n");
-               return;
-       }
-       pr_debug("<<<<<<<<<<<<<<<<<<<<<< BEGIN FABRIC API >>>>>>>>>>"
-                       ">>>>>>>>>>>>\n");
        mutex_lock(&g_tf_lock);
-       if (atomic_read(&tf->tf_access_cnt)) {
-               mutex_unlock(&g_tf_lock);
-               pr_err("Non zero tf->tf_access_cnt for fabric %s\n",
-                       tf->tf_name);
-               BUG();
+       list_for_each_entry(t, &g_tf_list, tf_list) {
+               if (!strcmp(t->tf_ops->name, fo->name)) {
+                       BUG_ON(atomic_read(&t->tf_access_cnt));
+                       list_del(&t->tf_list);
+                       kfree(t);
+                       break;
+               }
        }
-       list_del(&tf->tf_list);
        mutex_unlock(&g_tf_lock);
-
-       pr_debug("Target_Core_ConfigFS: DEREGISTER -> Releasing tf:"
-                       " %s\n", tf->tf_name);
-       tf->tf_module = NULL;
-       tf->tf_subsys = NULL;
-       kfree(tf);
-
-       pr_debug("<<<<<<<<<<<<<<<<<<<<<< END FABRIC API >>>>>>>>>>>>>>>>>"
-                       ">>>>>\n");
 }
-EXPORT_SYMBOL(target_fabric_configfs_deregister);
+EXPORT_SYMBOL(target_unregister_template);
 
 /*##############################################################################
 // Stop functions called by external Target Fabrics Modules
@@ -594,7 +480,7 @@ static struct configfs_item_operations target_core_dev_attrib_ops = {
        .store_attribute        = target_core_dev_attrib_attr_store,
 };
 
-TB_CIT_SETUP(dev_attrib, &target_core_dev_attrib_ops, NULL, NULL);
+TB_CIT_SETUP_DRV(dev_attrib, &target_core_dev_attrib_ops, NULL);
 
 /* End functions for struct config_item_type tb_dev_attrib_cit */
 
@@ -891,7 +777,7 @@ static ssize_t target_core_dev_pr_show_attr_res_holder(struct se_device *dev,
 {
        int ret;
 
-       if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV)
+       if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH)
                return sprintf(page, "Passthrough\n");
 
        spin_lock(&dev->dev_reservation_lock);
@@ -942,10 +828,9 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_holder_tg_port(
                struct se_device *dev, char *page)
 {
        struct se_node_acl *se_nacl;
-       struct se_lun *lun;
        struct se_portal_group *se_tpg;
        struct t10_pr_registration *pr_reg;
-       struct target_core_fabric_ops *tfo;
+       const struct target_core_fabric_ops *tfo;
        ssize_t len = 0;
 
        spin_lock(&dev->dev_reservation_lock);
@@ -957,7 +842,6 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_holder_tg_port(
 
        se_nacl = pr_reg->pr_reg_nacl;
        se_tpg = se_nacl->se_tpg;
-       lun = pr_reg->pr_reg_tg_pt_lun;
        tfo = se_tpg->se_tpg_tfo;
 
        len += sprintf(page+len, "SPC-3 Reservation: %s"
@@ -965,9 +849,9 @@ static ssize_t target_core_dev_pr_show_attr_res_pr_holder_tg_port(
                tfo->tpg_get_wwn(se_tpg));
        len += sprintf(page+len, "SPC-3 Reservation: Relative Port"
                " Identifier Tag: %hu %s Portal Group Tag: %hu"
-               " %s Logical Unit: %u\n", lun->lun_sep->sep_rtpi,
+               " %s Logical Unit: %u\n", pr_reg->tg_pt_sep_rtpi,
                tfo->get_fabric_name(), tfo->tpg_get_tag(se_tpg),
-               tfo->get_fabric_name(), lun->unpacked_lun);
+               tfo->get_fabric_name(), pr_reg->pr_aptpl_target_lun);
 
 out_unlock:
        spin_unlock(&dev->dev_reservation_lock);
@@ -979,7 +863,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)
 {
-       struct target_core_fabric_ops *tfo;
+       const struct target_core_fabric_ops *tfo;
        struct t10_pr_registration *pr_reg;
        unsigned char buf[384];
        char i_buf[PR_REG_ISID_ID_LEN];
@@ -1042,7 +926,7 @@ SE_DEV_PR_ATTR_RO(res_pr_type);
 static ssize_t target_core_dev_pr_show_attr_res_type(
                struct se_device *dev, char *page)
 {
-       if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV)
+       if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH)
                return sprintf(page, "SPC_PASSTHROUGH\n");
        else if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS)
                return sprintf(page, "SPC2_RESERVATIONS\n");
@@ -1055,7 +939,7 @@ SE_DEV_PR_ATTR_RO(res_type);
 static ssize_t target_core_dev_pr_show_attr_res_aptpl_active(
                struct se_device *dev, char *page)
 {
-       if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV)
+       if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH)
                return 0;
 
        return sprintf(page, "APTPL Bit Status: %s\n",
@@ -1070,7 +954,7 @@ SE_DEV_PR_ATTR_RO(res_aptpl_active);
 static ssize_t target_core_dev_pr_show_attr_res_aptpl_metadata(
                struct se_device *dev, char *page)
 {
-       if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV)
+       if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH)
                return 0;
 
        return sprintf(page, "Ready to process PR APTPL metadata..\n");
@@ -1114,10 +998,10 @@ static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata(
        u64 sa_res_key = 0;
        u32 mapped_lun = 0, target_lun = 0;
        int ret = -1, res_holder = 0, all_tg_pt = 0, arg, token;
-       u16 port_rpti = 0, tpgt = 0;
-       u8 type = 0, scope;
+       u16 tpgt = 0;
+       u8 type = 0;
 
-       if (dev->transport->transport_type == TRANSPORT_PLUGIN_PHBA_PDEV)
+       if (dev->transport->transport_flags & TRANSPORT_FLAG_PASSTHROUGH)
                return 0;
        if (dev->dev_reservation_flags & DRF_SPC2_RESERVATIONS)
                return 0;
@@ -1195,7 +1079,6 @@ static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata(
                        break;
                case Opt_res_scope:
                        match_int(args, &arg);
-                       scope = (u8)arg;
                        break;
                case Opt_res_all_tg_pt:
                        match_int(args, &arg);
@@ -1235,7 +1118,6 @@ static ssize_t target_core_dev_pr_store_attr_res_aptpl_metadata(
                        break;
                case Opt_port_rtpi:
                        match_int(args, &arg);
-                       port_rpti = (u16)arg;
                        break;
                case Opt_target_lun:
                        match_int(args, &arg);
@@ -1303,13 +1185,13 @@ TB_CIT_SETUP(dev_pr, &target_core_dev_pr_ops, NULL, target_core_dev_pr_attrs);
 static ssize_t target_core_show_dev_info(void *p, char *page)
 {
        struct se_device *dev = p;
-       struct se_subsystem_api *t = dev->transport;
        int bl = 0;
        ssize_t read_bytes = 0;
 
        transport_dump_dev_state(dev, page, &bl);
        read_bytes += bl;
-       read_bytes += t->show_configfs_dev_params(dev, page+read_bytes);
+       read_bytes += dev->transport->show_configfs_dev_params(dev,
+                       page+read_bytes);
        return read_bytes;
 }
 
@@ -1327,9 +1209,8 @@ static ssize_t target_core_store_dev_control(
        size_t count)
 {
        struct se_device *dev = p;
-       struct se_subsystem_api *t = dev->transport;
 
-       return t->set_configfs_dev_params(dev, page, count);
+       return dev->transport->set_configfs_dev_params(dev, page, count);
 }
 
 static struct target_core_configfs_attribute target_core_attr_dev_control = {
@@ -2606,9 +2487,9 @@ static struct config_group *target_core_make_subdev(
        const char *name)
 {
        struct t10_alua_tg_pt_gp *tg_pt_gp;
-       struct se_subsystem_api *t;
        struct config_item *hba_ci = &group->cg_item;
        struct se_hba *hba = item_to_hba(hba_ci);
+       struct target_backend *tb = hba->backend;
        struct se_device *dev;
        struct config_group *dev_cg = NULL, *tg_pt_gp_cg = NULL;
        struct config_group *dev_stat_grp = NULL;
@@ -2617,10 +2498,6 @@ static struct config_group *target_core_make_subdev(
        ret = mutex_lock_interruptible(&hba->hba_access_mutex);
        if (ret)
                return ERR_PTR(ret);
-       /*
-        * Locate the struct se_subsystem_api from parent's struct se_hba.
-        */
-       t = hba->transport;
 
        dev = target_alloc_device(hba, name);
        if (!dev)
@@ -2633,17 +2510,17 @@ static struct config_group *target_core_make_subdev(
        if (!dev_cg->default_groups)
                goto out_free_device;
 
-       config_group_init_type_name(dev_cg, name, &t->tb_cits.tb_dev_cit);
+       config_group_init_type_name(dev_cg, name, &tb->tb_dev_cit);
        config_group_init_type_name(&dev->dev_attrib.da_group, "attrib",
-                       &t->tb_cits.tb_dev_attrib_cit);
+                       &tb->tb_dev_attrib_cit);
        config_group_init_type_name(&dev->dev_pr_group, "pr",
-                       &t->tb_cits.tb_dev_pr_cit);
+                       &tb->tb_dev_pr_cit);
        config_group_init_type_name(&dev->t10_wwn.t10_wwn_group, "wwn",
-                       &t->tb_cits.tb_dev_wwn_cit);
+                       &tb->tb_dev_wwn_cit);
        config_group_init_type_name(&dev->t10_alua.alua_tg_pt_gps_group,
-                       "alua", &t->tb_cits.tb_dev_alua_tg_pt_gps_cit);
+                       "alua", &tb->tb_dev_alua_tg_pt_gps_cit);
        config_group_init_type_name(&dev->dev_stat_grps.stat_group,
-                       "statistics", &t->tb_cits.tb_dev_stat_cit);
+                       "statistics", &tb->tb_dev_stat_cit);
 
        dev_cg->default_groups[0] = &dev->dev_attrib.da_group;
        dev_cg->default_groups[1] = &dev->dev_pr_group;
@@ -2773,7 +2650,7 @@ static ssize_t target_core_hba_show_attr_hba_info(
        char *page)
 {
        return sprintf(page, "HBA Index: %d plugin: %s version: %s\n",
-                       hba->hba_id, hba->transport->name,
+                       hba->hba_id, hba->backend->ops->name,
                        TARGET_CORE_CONFIGFS_VERSION);
 }
 
@@ -2793,11 +2670,10 @@ static ssize_t target_core_hba_show_attr_hba_mode(struct se_hba *hba,
 static ssize_t target_core_hba_store_attr_hba_mode(struct se_hba *hba,
                                const char *page, size_t count)
 {
-       struct se_subsystem_api *transport = hba->transport;
        unsigned long mode_flag;
        int ret;
 
-       if (transport->pmode_enable_hba == NULL)
+       if (hba->backend->ops->pmode_enable_hba == NULL)
                return -EINVAL;
 
        ret = kstrtoul(page, 0, &mode_flag);
@@ -2811,7 +2687,7 @@ static ssize_t target_core_hba_store_attr_hba_mode(struct se_hba *hba,
                return -EINVAL;
        }
 
-       ret = transport->pmode_enable_hba(hba, mode_flag);
+       ret = hba->backend->ops->pmode_enable_hba(hba, mode_flag);
        if (ret < 0)
                return -EINVAL;
        if (ret > 0)
@@ -2937,22 +2813,21 @@ static struct config_item_type target_core_cit = {
 
 /* Stop functions for struct config_item_type target_core_hba_cit */
 
-void target_core_setup_sub_cits(struct se_subsystem_api *sa)
+void target_setup_backend_cits(struct target_backend *tb)
 {
-       target_core_setup_dev_cit(sa);
-       target_core_setup_dev_attrib_cit(sa);
-       target_core_setup_dev_pr_cit(sa);
-       target_core_setup_dev_wwn_cit(sa);
-       target_core_setup_dev_alua_tg_pt_gps_cit(sa);
-       target_core_setup_dev_stat_cit(sa);
+       target_core_setup_dev_cit(tb);
+       target_core_setup_dev_attrib_cit(tb);
+       target_core_setup_dev_pr_cit(tb);
+       target_core_setup_dev_wwn_cit(tb);
+       target_core_setup_dev_alua_tg_pt_gps_cit(tb);
+       target_core_setup_dev_stat_cit(tb);
 }
-EXPORT_SYMBOL(target_core_setup_sub_cits);
 
 static int __init target_core_init_configfs(void)
 {
        struct config_group *target_cg, *hba_cg = NULL, *alua_cg = NULL;
        struct config_group *lu_gp_cg = NULL;
-       struct configfs_subsystem *subsys;
+       struct configfs_subsystem *subsys = &target_core_fabrics;
        struct t10_alua_lu_gp *lu_gp;
        int ret;
 
@@ -2960,7 +2835,6 @@ static int __init target_core_init_configfs(void)
                " Engine: %s on %s/%s on "UTS_RELEASE"\n",
                TARGET_CORE_VERSION, utsname()->sysname, utsname()->machine);
 
-       subsys = target_core_subsystem[0];
        config_group_init(&subsys->su_group);
        mutex_init(&subsys->su_mutex);
 
@@ -3090,13 +2964,10 @@ out_global:
 
 static void __exit target_core_exit_configfs(void)
 {
-       struct configfs_subsystem *subsys;
        struct config_group *hba_cg, *alua_cg, *lu_gp_cg;
        struct config_item *item;
        int i;
 
-       subsys = target_core_subsystem[0];
-
        lu_gp_cg = &alua_lu_gps_group;
        for (i = 0; lu_gp_cg->default_groups[i]; i++) {
                item = &lu_gp_cg->default_groups[i]->cg_item;
@@ -3127,8 +2998,8 @@ static void __exit target_core_exit_configfs(void)
         * We expect subsys->su_group.default_groups to be released
         * by configfs subsystem provider logic..
         */
-       configfs_unregister_subsystem(subsys);
-       kfree(subsys->su_group.default_groups);
+       configfs_unregister_subsystem(&target_core_fabrics);
+       kfree(target_core_fabrics.su_group.default_groups);
 
        core_alua_free_lu_gp(default_lu_gp);
        default_lu_gp = NULL;