Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

target: simplify backend driver registration

Rewrite the backend driver registration based on what we did to the fabric
drivers: introduce a read-only struct target_bakckend_ops that the driver
registers, which is then instanciate as a struct target_backend by the
core. This allows the ops vector to be smaller and allows us to mark it
const. At the same time the registration function can set up the
configfs attributes, avoiding the need to add additional boilerplate code
for that to the drivers.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>

authored by

Christoph Hellwig and committed by
Nicholas Bellinger
0a06d430 46247737

+133 -156
+36 -32
drivers/target/target_core_configfs.c
··· 51 51 #include "target_core_xcopy.h" 52 52 53 53 #define TB_CIT_SETUP(_name, _item_ops, _group_ops, _attrs) \ 54 - static void target_core_setup_##_name##_cit(struct se_subsystem_api *sa) \ 54 + static void target_core_setup_##_name##_cit(struct target_backend *tb) \ 55 55 { \ 56 - struct target_backend_cits *tbc = &sa->tb_cits; \ 57 - struct config_item_type *cit = &tbc->tb_##_name##_cit; \ 56 + struct config_item_type *cit = &tb->tb_##_name##_cit; \ 58 57 \ 59 58 cit->ct_item_ops = _item_ops; \ 60 59 cit->ct_group_ops = _group_ops; \ 61 60 cit->ct_attrs = _attrs; \ 62 - cit->ct_owner = sa->owner; \ 61 + cit->ct_owner = tb->ops->owner; \ 62 + pr_debug("Setup generic %s\n", __stringify(_name)); \ 63 + } 64 + 65 + #define TB_CIT_SETUP_DRV(_name, _item_ops, _group_ops) \ 66 + static void target_core_setup_##_name##_cit(struct target_backend *tb) \ 67 + { \ 68 + struct config_item_type *cit = &tb->tb_##_name##_cit; \ 69 + \ 70 + cit->ct_item_ops = _item_ops; \ 71 + cit->ct_group_ops = _group_ops; \ 72 + cit->ct_attrs = tb->ops->tb_##_name##_attrs; \ 73 + cit->ct_owner = tb->ops->owner; \ 63 74 pr_debug("Setup generic %s\n", __stringify(_name)); \ 64 75 } 65 76 ··· 480 469 .store_attribute = target_core_dev_attrib_attr_store, 481 470 }; 482 471 483 - TB_CIT_SETUP(dev_attrib, &target_core_dev_attrib_ops, NULL, NULL); 472 + TB_CIT_SETUP_DRV(dev_attrib, &target_core_dev_attrib_ops, NULL); 484 473 485 474 /* End functions for struct config_item_type tb_dev_attrib_cit */ 486 475 ··· 1185 1174 static ssize_t target_core_show_dev_info(void *p, char *page) 1186 1175 { 1187 1176 struct se_device *dev = p; 1188 - struct se_subsystem_api *t = dev->transport; 1189 1177 int bl = 0; 1190 1178 ssize_t read_bytes = 0; 1191 1179 1192 1180 transport_dump_dev_state(dev, page, &bl); 1193 1181 read_bytes += bl; 1194 - read_bytes += t->show_configfs_dev_params(dev, page+read_bytes); 1182 + read_bytes += dev->transport->show_configfs_dev_params(dev, 1183 + page+read_bytes); 1195 1184 return read_bytes; 1196 1185 } 1197 1186 ··· 1209 1198 size_t count) 1210 1199 { 1211 1200 struct se_device *dev = p; 1212 - struct se_subsystem_api *t = dev->transport; 1213 1201 1214 - return t->set_configfs_dev_params(dev, page, count); 1202 + return dev->transport->set_configfs_dev_params(dev, page, count); 1215 1203 } 1216 1204 1217 1205 static struct target_core_configfs_attribute target_core_attr_dev_control = { ··· 2487 2477 const char *name) 2488 2478 { 2489 2479 struct t10_alua_tg_pt_gp *tg_pt_gp; 2490 - struct se_subsystem_api *t; 2491 2480 struct config_item *hba_ci = &group->cg_item; 2492 2481 struct se_hba *hba = item_to_hba(hba_ci); 2482 + struct target_backend *tb = hba->backend; 2493 2483 struct se_device *dev; 2494 2484 struct config_group *dev_cg = NULL, *tg_pt_gp_cg = NULL; 2495 2485 struct config_group *dev_stat_grp = NULL; ··· 2498 2488 ret = mutex_lock_interruptible(&hba->hba_access_mutex); 2499 2489 if (ret) 2500 2490 return ERR_PTR(ret); 2501 - /* 2502 - * Locate the struct se_subsystem_api from parent's struct se_hba. 2503 - */ 2504 - t = hba->transport; 2505 2491 2506 2492 dev = target_alloc_device(hba, name); 2507 2493 if (!dev) ··· 2510 2504 if (!dev_cg->default_groups) 2511 2505 goto out_free_device; 2512 2506 2513 - config_group_init_type_name(dev_cg, name, &t->tb_cits.tb_dev_cit); 2507 + config_group_init_type_name(dev_cg, name, &tb->tb_dev_cit); 2514 2508 config_group_init_type_name(&dev->dev_attrib.da_group, "attrib", 2515 - &t->tb_cits.tb_dev_attrib_cit); 2509 + &tb->tb_dev_attrib_cit); 2516 2510 config_group_init_type_name(&dev->dev_pr_group, "pr", 2517 - &t->tb_cits.tb_dev_pr_cit); 2511 + &tb->tb_dev_pr_cit); 2518 2512 config_group_init_type_name(&dev->t10_wwn.t10_wwn_group, "wwn", 2519 - &t->tb_cits.tb_dev_wwn_cit); 2513 + &tb->tb_dev_wwn_cit); 2520 2514 config_group_init_type_name(&dev->t10_alua.alua_tg_pt_gps_group, 2521 - "alua", &t->tb_cits.tb_dev_alua_tg_pt_gps_cit); 2515 + "alua", &tb->tb_dev_alua_tg_pt_gps_cit); 2522 2516 config_group_init_type_name(&dev->dev_stat_grps.stat_group, 2523 - "statistics", &t->tb_cits.tb_dev_stat_cit); 2517 + "statistics", &tb->tb_dev_stat_cit); 2524 2518 2525 2519 dev_cg->default_groups[0] = &dev->dev_attrib.da_group; 2526 2520 dev_cg->default_groups[1] = &dev->dev_pr_group; ··· 2650 2644 char *page) 2651 2645 { 2652 2646 return sprintf(page, "HBA Index: %d plugin: %s version: %s\n", 2653 - hba->hba_id, hba->transport->name, 2647 + hba->hba_id, hba->backend->ops->name, 2654 2648 TARGET_CORE_CONFIGFS_VERSION); 2655 2649 } 2656 2650 ··· 2670 2664 static ssize_t target_core_hba_store_attr_hba_mode(struct se_hba *hba, 2671 2665 const char *page, size_t count) 2672 2666 { 2673 - struct se_subsystem_api *transport = hba->transport; 2674 2667 unsigned long mode_flag; 2675 2668 int ret; 2676 2669 2677 - if (transport->pmode_enable_hba == NULL) 2670 + if (hba->backend->ops->pmode_enable_hba == NULL) 2678 2671 return -EINVAL; 2679 2672 2680 2673 ret = kstrtoul(page, 0, &mode_flag); ··· 2687 2682 return -EINVAL; 2688 2683 } 2689 2684 2690 - ret = transport->pmode_enable_hba(hba, mode_flag); 2685 + ret = hba->backend->ops->pmode_enable_hba(hba, mode_flag); 2691 2686 if (ret < 0) 2692 2687 return -EINVAL; 2693 2688 if (ret > 0) ··· 2813 2808 2814 2809 /* Stop functions for struct config_item_type target_core_hba_cit */ 2815 2810 2816 - void target_core_setup_sub_cits(struct se_subsystem_api *sa) 2811 + void target_setup_backend_cits(struct target_backend *tb) 2817 2812 { 2818 - target_core_setup_dev_cit(sa); 2819 - target_core_setup_dev_attrib_cit(sa); 2820 - target_core_setup_dev_pr_cit(sa); 2821 - target_core_setup_dev_wwn_cit(sa); 2822 - target_core_setup_dev_alua_tg_pt_gps_cit(sa); 2823 - target_core_setup_dev_stat_cit(sa); 2813 + target_core_setup_dev_cit(tb); 2814 + target_core_setup_dev_attrib_cit(tb); 2815 + target_core_setup_dev_pr_cit(tb); 2816 + target_core_setup_dev_wwn_cit(tb); 2817 + target_core_setup_dev_alua_tg_pt_gps_cit(tb); 2818 + target_core_setup_dev_stat_cit(tb); 2824 2819 } 2825 - EXPORT_SYMBOL(target_core_setup_sub_cits); 2826 2820 2827 2821 static int __init target_core_init_configfs(void) 2828 2822 {
+3 -3
drivers/target/target_core_device.c
··· 1367 1367 struct se_device *dev; 1368 1368 struct se_lun *xcopy_lun; 1369 1369 1370 - dev = hba->transport->alloc_device(hba, name); 1370 + dev = hba->backend->ops->alloc_device(hba, name); 1371 1371 if (!dev) 1372 1372 return NULL; 1373 1373 1374 1374 dev->dev_link_magic = SE_DEV_LINK_MAGIC; 1375 1375 dev->se_hba = hba; 1376 - dev->transport = hba->transport; 1376 + dev->transport = hba->backend->ops; 1377 1377 dev->prot_length = sizeof(struct se_dif_v1_tuple); 1378 1378 1379 1379 INIT_LIST_HEAD(&dev->dev_list); ··· 1571 1571 goto out_free_hba; 1572 1572 } 1573 1573 1574 - hba->transport->set_configfs_dev_params(dev, buf, sizeof(buf)); 1574 + hba->backend->ops->set_configfs_dev_params(dev, buf, sizeof(buf)); 1575 1575 1576 1576 ret = target_configure_device(dev); 1577 1577 if (ret)
+4 -12
drivers/target/target_core_file.c
··· 46 46 return container_of(dev, struct fd_dev, dev); 47 47 } 48 48 49 - /* fd_attach_hba(): (Part of se_subsystem_api_t template) 50 - * 51 - * 52 - */ 53 49 static int fd_attach_hba(struct se_hba *hba, u32 host_id) 54 50 { 55 51 struct fd_host *fd_host; ··· 877 881 NULL, 878 882 }; 879 883 880 - static struct se_subsystem_api fileio_template = { 884 + static const struct target_backend_ops fileio_ops = { 881 885 .name = "fileio", 882 886 .inquiry_prod = "FILEIO", 883 887 .inquiry_rev = FD_VERSION, ··· 895 899 .init_prot = fd_init_prot, 896 900 .format_prot = fd_format_prot, 897 901 .free_prot = fd_free_prot, 902 + .tb_dev_attrib_attrs = fileio_backend_dev_attrs, 898 903 }; 899 904 900 905 static int __init fileio_module_init(void) 901 906 { 902 - struct target_backend_cits *tbc = &fileio_template.tb_cits; 903 - 904 - target_core_setup_sub_cits(&fileio_template); 905 - tbc->tb_dev_attrib_cit.ct_attrs = fileio_backend_dev_attrs; 906 - 907 - return transport_subsystem_register(&fileio_template); 907 + return transport_backend_register(&fileio_ops); 908 908 } 909 909 910 910 static void __exit fileio_module_exit(void) 911 911 { 912 - transport_subsystem_release(&fileio_template); 912 + target_backend_unregister(&fileio_ops); 913 913 } 914 914 915 915 MODULE_DESCRIPTION("TCM FILEIO subsystem plugin");
+52 -40
drivers/target/target_core_hba.c
··· 39 39 40 40 #include "target_core_internal.h" 41 41 42 - static LIST_HEAD(subsystem_list); 43 - static DEFINE_MUTEX(subsystem_mutex); 42 + static LIST_HEAD(backend_list); 43 + static DEFINE_MUTEX(backend_mutex); 44 44 45 45 static u32 hba_id_counter; 46 46 47 47 static DEFINE_SPINLOCK(hba_lock); 48 48 static LIST_HEAD(hba_list); 49 49 50 - int transport_subsystem_register(struct se_subsystem_api *sub_api) 50 + 51 + int transport_backend_register(const struct target_backend_ops *ops) 51 52 { 52 - struct se_subsystem_api *s; 53 + struct target_backend *tb, *old; 53 54 54 - INIT_LIST_HEAD(&sub_api->sub_api_list); 55 + tb = kzalloc(sizeof(*tb), GFP_KERNEL); 56 + if (!tb) 57 + return -ENOMEM; 58 + tb->ops = ops; 55 59 56 - mutex_lock(&subsystem_mutex); 57 - list_for_each_entry(s, &subsystem_list, sub_api_list) { 58 - if (!strcmp(s->name, sub_api->name)) { 59 - pr_err("%p is already registered with" 60 - " duplicate name %s, unable to process" 61 - " request\n", s, s->name); 62 - mutex_unlock(&subsystem_mutex); 60 + mutex_lock(&backend_mutex); 61 + list_for_each_entry(old, &backend_list, list) { 62 + if (!strcmp(old->ops->name, ops->name)) { 63 + pr_err("backend %s already registered.\n", ops->name); 64 + mutex_unlock(&backend_mutex); 65 + kfree(tb); 63 66 return -EEXIST; 64 67 } 65 68 } 66 - list_add_tail(&sub_api->sub_api_list, &subsystem_list); 67 - mutex_unlock(&subsystem_mutex); 69 + target_setup_backend_cits(tb); 70 + list_add_tail(&tb->list, &backend_list); 71 + mutex_unlock(&backend_mutex); 68 72 69 - pr_debug("TCM: Registered subsystem plugin: %s struct module:" 70 - " %p\n", sub_api->name, sub_api->owner); 73 + pr_debug("TCM: Registered subsystem plugin: %s struct module: %p\n", 74 + ops->name, ops->owner); 71 75 return 0; 72 76 } 73 - EXPORT_SYMBOL(transport_subsystem_register); 77 + EXPORT_SYMBOL(transport_backend_register); 74 78 75 - void transport_subsystem_release(struct se_subsystem_api *sub_api) 79 + void target_backend_unregister(const struct target_backend_ops *ops) 76 80 { 77 - mutex_lock(&subsystem_mutex); 78 - list_del(&sub_api->sub_api_list); 79 - mutex_unlock(&subsystem_mutex); 81 + struct target_backend *tb; 82 + 83 + mutex_lock(&backend_mutex); 84 + list_for_each_entry(tb, &backend_list, list) { 85 + if (tb->ops == ops) { 86 + list_del(&tb->list); 87 + kfree(tb); 88 + break; 89 + } 90 + } 91 + mutex_unlock(&backend_mutex); 80 92 } 81 - EXPORT_SYMBOL(transport_subsystem_release); 93 + EXPORT_SYMBOL(target_backend_unregister); 82 94 83 - static struct se_subsystem_api *core_get_backend(const char *sub_name) 95 + static struct target_backend *core_get_backend(const char *name) 84 96 { 85 - struct se_subsystem_api *s; 97 + struct target_backend *tb; 86 98 87 - mutex_lock(&subsystem_mutex); 88 - list_for_each_entry(s, &subsystem_list, sub_api_list) { 89 - if (!strcmp(s->name, sub_name)) 99 + mutex_lock(&backend_mutex); 100 + list_for_each_entry(tb, &backend_list, list) { 101 + if (!strcmp(tb->ops->name, name)) 90 102 goto found; 91 103 } 92 - mutex_unlock(&subsystem_mutex); 104 + mutex_unlock(&backend_mutex); 93 105 return NULL; 94 106 found: 95 - if (s->owner && !try_module_get(s->owner)) 96 - s = NULL; 97 - mutex_unlock(&subsystem_mutex); 98 - return s; 107 + if (tb->ops->owner && !try_module_get(tb->ops->owner)) 108 + tb = NULL; 109 + mutex_unlock(&backend_mutex); 110 + return tb; 99 111 } 100 112 101 113 struct se_hba * ··· 128 116 hba->hba_index = scsi_get_new_index(SCSI_INST_INDEX); 129 117 hba->hba_flags |= hba_flags; 130 118 131 - hba->transport = core_get_backend(plugin_name); 132 - if (!hba->transport) { 119 + hba->backend = core_get_backend(plugin_name); 120 + if (!hba->backend) { 133 121 ret = -EINVAL; 134 122 goto out_free_hba; 135 123 } 136 124 137 - ret = hba->transport->attach_hba(hba, plugin_dep_id); 125 + ret = hba->backend->ops->attach_hba(hba, plugin_dep_id); 138 126 if (ret < 0) 139 127 goto out_module_put; 140 128 ··· 149 137 return hba; 150 138 151 139 out_module_put: 152 - module_put(hba->transport->owner); 153 - hba->transport = NULL; 140 + module_put(hba->backend->ops->owner); 141 + hba->backend = NULL; 154 142 out_free_hba: 155 143 kfree(hba); 156 144 return ERR_PTR(ret); ··· 161 149 { 162 150 WARN_ON(hba->dev_count); 163 151 164 - hba->transport->detach_hba(hba); 152 + hba->backend->ops->detach_hba(hba); 165 153 166 154 spin_lock(&hba_lock); 167 155 list_del(&hba->hba_node); ··· 170 158 pr_debug("CORE_HBA[%d] - Detached HBA from Generic Target" 171 159 " Core\n", hba->hba_id); 172 160 173 - module_put(hba->transport->owner); 161 + module_put(hba->backend->ops->owner); 174 162 175 - hba->transport = NULL; 163 + hba->backend = NULL; 176 164 kfree(hba); 177 165 return 0; 178 166 }
+4 -14
drivers/target/target_core_iblock.c
··· 54 54 } 55 55 56 56 57 - static struct se_subsystem_api iblock_template; 58 - 59 - /* iblock_attach_hba(): (Part of se_subsystem_api_t template) 60 - * 61 - * 62 - */ 63 57 static int iblock_attach_hba(struct se_hba *hba, u32 host_id) 64 58 { 65 59 pr_debug("CORE_HBA[%d] - TCM iBlock HBA Driver %s on" ··· 893 899 NULL, 894 900 }; 895 901 896 - static struct se_subsystem_api iblock_template = { 902 + static const struct target_backend_ops iblock_ops = { 897 903 .name = "iblock", 898 904 .inquiry_prod = "IBLOCK", 899 905 .inquiry_rev = IBLOCK_VERSION, ··· 913 919 .get_io_min = iblock_get_io_min, 914 920 .get_io_opt = iblock_get_io_opt, 915 921 .get_write_cache = iblock_get_write_cache, 922 + .tb_dev_attrib_attrs = iblock_backend_dev_attrs, 916 923 }; 917 924 918 925 static int __init iblock_module_init(void) 919 926 { 920 - struct target_backend_cits *tbc = &iblock_template.tb_cits; 921 - 922 - target_core_setup_sub_cits(&iblock_template); 923 - tbc->tb_dev_attrib_cit.ct_attrs = iblock_backend_dev_attrs; 924 - 925 - return transport_subsystem_register(&iblock_template); 927 + return transport_backend_register(&iblock_ops); 926 928 } 927 929 928 930 static void __exit iblock_module_exit(void) 929 931 { 930 - transport_subsystem_release(&iblock_template); 932 + target_backend_unregister(&iblock_ops); 931 933 } 932 934 933 935 MODULE_DESCRIPTION("TCM IBLOCK subsystem plugin");
+16
drivers/target/target_core_internal.h
··· 1 1 #ifndef TARGET_CORE_INTERNAL_H 2 2 #define TARGET_CORE_INTERNAL_H 3 3 4 + struct target_backend { 5 + struct list_head list; 6 + 7 + const struct target_backend_ops *ops; 8 + 9 + struct config_item_type tb_dev_cit; 10 + struct config_item_type tb_dev_attrib_cit; 11 + struct config_item_type tb_dev_pr_cit; 12 + struct config_item_type tb_dev_wwn_cit; 13 + struct config_item_type tb_dev_alua_tg_pt_gps_cit; 14 + struct config_item_type tb_dev_stat_cit; 15 + }; 16 + 4 17 /* target_core_alua.c */ 5 18 extern struct t10_alua_lu_gp *default_lu_gp; 6 19 ··· 52 39 struct se_device *target_alloc_device(struct se_hba *hba, const char *name); 53 40 int target_configure_device(struct se_device *dev); 54 41 void target_free_device(struct se_device *); 42 + 43 + /* target_core_configfs.c */ 44 + void target_setup_backend_cits(struct target_backend *); 55 45 56 46 /* target_core_fabric_lib.c */ 57 47 int target_get_pr_transport_id_len(struct se_node_acl *nacl,
+4 -10
drivers/target/target_core_pscsi.c
··· 57 57 return container_of(dev, struct pscsi_dev_virt, dev); 58 58 } 59 59 60 - static struct se_subsystem_api pscsi_template; 61 - 62 60 static sense_reason_t pscsi_execute_cmd(struct se_cmd *cmd); 63 61 static void pscsi_req_done(struct request *, int); 64 62 ··· 1139 1141 NULL, 1140 1142 }; 1141 1143 1142 - static struct se_subsystem_api pscsi_template = { 1144 + static const struct target_backend_ops pscsi_ops = { 1143 1145 .name = "pscsi", 1144 1146 .owner = THIS_MODULE, 1145 1147 .transport_flags = TRANSPORT_FLAG_PASSTHROUGH, ··· 1155 1157 .show_configfs_dev_params = pscsi_show_configfs_dev_params, 1156 1158 .get_device_type = pscsi_get_device_type, 1157 1159 .get_blocks = pscsi_get_blocks, 1160 + .tb_dev_attrib_attrs = pscsi_backend_dev_attrs, 1158 1161 }; 1159 1162 1160 1163 static int __init pscsi_module_init(void) 1161 1164 { 1162 - struct target_backend_cits *tbc = &pscsi_template.tb_cits; 1163 - 1164 - target_core_setup_sub_cits(&pscsi_template); 1165 - tbc->tb_dev_attrib_cit.ct_attrs = pscsi_backend_dev_attrs; 1166 - 1167 - return transport_subsystem_register(&pscsi_template); 1165 + return transport_backend_register(&pscsi_ops); 1168 1166 } 1169 1167 1170 1168 static void __exit pscsi_module_exit(void) 1171 1169 { 1172 - transport_subsystem_release(&pscsi_template); 1170 + target_backend_unregister(&pscsi_ops); 1173 1171 } 1174 1172 1175 1173 MODULE_DESCRIPTION("TCM PSCSI subsystem plugin");
+4 -18
drivers/target/target_core_rd.c
··· 43 43 return container_of(dev, struct rd_dev, dev); 44 44 } 45 45 46 - /* rd_attach_hba(): (Part of se_subsystem_api_t template) 47 - * 48 - * 49 - */ 50 46 static int rd_attach_hba(struct se_hba *hba, u32 host_id) 51 47 { 52 48 struct rd_host *rd_host; ··· 731 735 NULL, 732 736 }; 733 737 734 - static struct se_subsystem_api rd_mcp_template = { 738 + static const struct target_backend_ops rd_mcp_ops = { 735 739 .name = "rd_mcp", 736 740 .inquiry_prod = "RAMDISK-MCP", 737 741 .inquiry_rev = RD_MCP_VERSION, ··· 747 751 .get_blocks = rd_get_blocks, 748 752 .init_prot = rd_init_prot, 749 753 .free_prot = rd_free_prot, 754 + .tb_dev_attrib_attrs = rd_mcp_backend_dev_attrs, 750 755 }; 751 756 752 757 int __init rd_module_init(void) 753 758 { 754 - struct target_backend_cits *tbc = &rd_mcp_template.tb_cits; 755 - int ret; 756 - 757 - target_core_setup_sub_cits(&rd_mcp_template); 758 - tbc->tb_dev_attrib_cit.ct_attrs = rd_mcp_backend_dev_attrs; 759 - 760 - ret = transport_subsystem_register(&rd_mcp_template); 761 - if (ret < 0) { 762 - return ret; 763 - } 764 - 765 - return 0; 759 + return transport_backend_register(&rd_mcp_ops); 766 760 } 767 761 768 762 void rd_module_exit(void) 769 763 { 770 - transport_subsystem_release(&rd_mcp_template); 764 + target_backend_unregister(&rd_mcp_ops); 771 765 }
+4 -7
drivers/target/target_core_user.c
··· 1115 1115 NULL, 1116 1116 }; 1117 1117 1118 - static struct se_subsystem_api tcmu_template = { 1118 + static const struct target_backend_ops tcmu_ops = { 1119 1119 .name = "user", 1120 1120 .inquiry_prod = "USER", 1121 1121 .inquiry_rev = TCMU_VERSION, ··· 1131 1131 .show_configfs_dev_params = tcmu_show_configfs_dev_params, 1132 1132 .get_device_type = sbc_get_device_type, 1133 1133 .get_blocks = tcmu_get_blocks, 1134 + .tb_dev_attrib_attrs = tcmu_backend_dev_attrs, 1134 1135 }; 1135 1136 1136 1137 static int __init tcmu_module_init(void) 1137 1138 { 1138 - struct target_backend_cits *tbc = &tcmu_template.tb_cits; 1139 1139 int ret; 1140 1140 1141 1141 BUILD_BUG_ON((sizeof(struct tcmu_cmd_entry) % TCMU_OP_ALIGN_SIZE) != 0); ··· 1158 1158 goto out_unreg_device; 1159 1159 } 1160 1160 1161 - target_core_setup_sub_cits(&tcmu_template); 1162 - tbc->tb_dev_attrib_cit.ct_attrs = tcmu_backend_dev_attrs; 1163 - 1164 - ret = transport_subsystem_register(&tcmu_template); 1161 + ret = transport_backend_register(&tcmu_ops); 1165 1162 if (ret) 1166 1163 goto out_unreg_genl; 1167 1164 ··· 1176 1179 1177 1180 static void __exit tcmu_module_exit(void) 1178 1181 { 1179 - transport_subsystem_release(&tcmu_template); 1182 + target_backend_unregister(&tcmu_ops); 1180 1183 genl_unregister_family(&tcmu_genl_family); 1181 1184 root_device_unregister(tcmu_root_device); 1182 1185 kmem_cache_destroy(tcmu_cmd_cache);
+4 -18
include/target/target_core_backend.h
··· 3 3 4 4 #define TRANSPORT_FLAG_PASSTHROUGH 1 5 5 6 - struct target_backend_cits { 7 - struct config_item_type tb_dev_cit; 8 - struct config_item_type tb_dev_attrib_cit; 9 - struct config_item_type tb_dev_pr_cit; 10 - struct config_item_type tb_dev_wwn_cit; 11 - struct config_item_type tb_dev_alua_tg_pt_gps_cit; 12 - struct config_item_type tb_dev_stat_cit; 13 - }; 14 - 15 - struct se_subsystem_api { 16 - struct list_head sub_api_list; 17 - 6 + struct target_backend_ops { 18 7 char name[16]; 19 8 char inquiry_prod[16]; 20 9 char inquiry_rev[4]; ··· 41 52 int (*format_prot)(struct se_device *); 42 53 void (*free_prot)(struct se_device *); 43 54 44 - struct target_backend_cits tb_cits; 55 + struct configfs_attribute **tb_dev_attrib_attrs; 45 56 }; 46 57 47 58 struct sbc_ops { ··· 53 64 sense_reason_t (*execute_unmap)(struct se_cmd *cmd); 54 65 }; 55 66 56 - int transport_subsystem_register(struct se_subsystem_api *); 57 - void transport_subsystem_release(struct se_subsystem_api *); 67 + int transport_backend_register(const struct target_backend_ops *); 68 + void target_backend_unregister(const struct target_backend_ops *); 58 69 59 70 void target_complete_cmd(struct se_cmd *, u8); 60 71 void target_complete_cmd_with_length(struct se_cmd *, u8, int); ··· 91 102 struct scatterlist *, u32, struct scatterlist *, u32); 92 103 93 104 bool target_lun_is_rdonly(struct se_cmd *); 94 - 95 - /* From target_core_configfs.c to setup default backend config_item_types */ 96 - void target_core_setup_sub_cits(struct se_subsystem_api *); 97 105 98 106 /* attribute helpers from target_core_device.c for backend drivers */ 99 107 bool se_dev_check_wce(struct se_device *);
+2 -2
include/target/target_core_base.h
··· 797 797 #define SE_UDEV_PATH_LEN 512 /* must be less than PAGE_SIZE */ 798 798 unsigned char udev_path[SE_UDEV_PATH_LEN]; 799 799 /* Pointer to template of function pointers for transport */ 800 - struct se_subsystem_api *transport; 800 + const struct target_backend_ops *transport; 801 801 /* Linked list for struct se_hba struct se_device list */ 802 802 struct list_head dev_list; 803 803 struct se_lun xcopy_lun; ··· 819 819 spinlock_t device_lock; 820 820 struct config_group hba_group; 821 821 struct mutex hba_access_mutex; 822 - struct se_subsystem_api *transport; 822 + struct target_backend *backend; 823 823 }; 824 824 825 825 struct scsi_port_stats {