target: Move dev_cit to struct se_subsystem_api
authorNicholas Bellinger <nab@linux-iscsi.org>
Thu, 27 Nov 2014 21:59:20 +0000 (13:59 -0800)
committerNicholas Bellinger <nab@linux-iscsi.org>
Tue, 2 Dec 2014 05:35:22 +0000 (21:35 -0800)
This patch adds initial support for dev_cit as external config_item_type.

This includes a new struct target_backend_cits to hold the external CITs
within struct se_subsystem_api, and target_core_setup_sub_cits() to be
used by backend drivers ahead of transport_subsystem_register().

It adds a TB_CIT_SETUP() helper following target_core_fabric_configfs.c
to perform the config_item_type assignments.

Also, drop left-over target_core_dev_cit from target_core_configfs.c code
and update comments.

Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/target_core_configfs.c
drivers/target/target_core_hba.c
include/target/target_core_backend.h

index 41498b6966413ba5771d13b2c71d79853d8dcf75..f7b2186ba57b3ddc9e44d7b7125aeee80354aaf6 100644 (file)
 #include "target_core_rd.h"
 #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) \
+{                                                                      \
+       struct target_backend_cits *tbc = &sa->tb_cits;                 \
+       struct config_item_type *cit = &tbc->tb_##_name##_cit;          \
+                                                                       \
+       cit->ct_item_ops = _item_ops;                                   \
+       cit->ct_group_ops = _group_ops;                                 \
+       cit->ct_attrs = _attrs;                                         \
+       cit->ct_owner = sa->owner;                                      \
+       pr_debug("Setup generic %s\n", __stringify(_name));             \
+}
+
 extern struct t10_alua_lu_gp *default_lu_gp;
 
 static LIST_HEAD(g_tf_list);
@@ -1470,7 +1483,7 @@ static struct config_item_type target_core_dev_pr_cit = {
 
 /*  End functions for struct config_item_type target_core_dev_pr_cit */
 
-/*  Start functions for struct config_item_type target_core_dev_cit */
+/*  Start functions for struct config_item_type tb_dev_cit */
 
 static ssize_t target_core_show_dev_info(void *p, char *page)
 {
@@ -1934,7 +1947,7 @@ static struct target_core_configfs_attribute target_core_attr_dev_lba_map = {
        .store  = target_core_store_dev_lba_map,
 };
 
-static struct configfs_attribute *lio_core_dev_attrs[] = {
+static struct configfs_attribute *target_core_dev_attrs[] = {
        &target_core_attr_dev_info.attr,
        &target_core_attr_dev_control.attr,
        &target_core_attr_dev_alias.attr,
@@ -1993,13 +2006,9 @@ static struct configfs_item_operations target_core_dev_item_ops = {
        .store_attribute        = target_core_dev_store,
 };
 
-static struct config_item_type target_core_dev_cit = {
-       .ct_item_ops            = &target_core_dev_item_ops,
-       .ct_attrs               = lio_core_dev_attrs,
-       .ct_owner               = THIS_MODULE,
-};
+TB_CIT_SETUP(dev, &target_core_dev_item_ops, NULL, target_core_dev_attrs);
 
-/* End functions for struct config_item_type target_core_dev_cit */
+/* End functions for struct config_item_type tb_dev_cit */
 
 /* Start functions for struct config_item_type target_core_alua_lu_gp_cit */
 
@@ -2815,7 +2824,7 @@ 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, &target_core_dev_cit);
+       config_group_init_type_name(dev_cg, name, &t->tb_cits.tb_dev_cit);
        config_group_init_type_name(&dev->dev_attrib.da_group, "attrib",
                        &target_core_dev_attrib_cit);
        config_group_init_type_name(&dev->dev_pr_group, "pr",
@@ -3119,6 +3128,12 @@ 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)
+{
+       target_core_setup_dev_cit(sa);
+}
+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;
index e6e496ff9546ac5d9295e5f0ce1e590a367f0e7c..ff95f95dcd13d571a59c70b7f6a7b1c6d0a6120d 100644 (file)
@@ -36,6 +36,7 @@
 #include <target/target_core_base.h>
 #include <target/target_core_backend.h>
 #include <target/target_core_fabric.h>
+#include <target/target_core_configfs.h>
 
 #include "target_core_internal.h"
 
index 9adc1bca1178ba36482f63bf8cef1444045f7709..7b84436541b454a3aeaa17885aac1107dabb4fda 100644 (file)
@@ -5,6 +5,10 @@
 #define TRANSPORT_PLUGIN_VHBA_PDEV             2
 #define TRANSPORT_PLUGIN_VHBA_VDEV             3
 
+struct target_backend_cits {
+       struct config_item_type tb_dev_cit;
+};
+
 struct se_subsystem_api {
        struct list_head sub_api_list;
 
@@ -44,6 +48,8 @@ struct se_subsystem_api {
        int (*init_prot)(struct se_device *);
        int (*format_prot)(struct se_device *);
        void (*free_prot)(struct se_device *);
+
+       struct target_backend_cits tb_cits;
 };
 
 struct sbc_ops {
@@ -96,4 +102,7 @@ sense_reason_t       transport_generic_map_mem_to_cmd(struct se_cmd *,
 
 void   array_free(void *array, int n);
 
+/* From target_core_configfs.c to setup default backend config_item_types */
+void   target_core_setup_sub_cits(struct se_subsystem_api *);
+
 #endif /* TARGET_CORE_BACKEND_H */