: Generic fabric module configfs infrastructure WIP
Subsystems (3)
PATCH 1/3 : Generic fabric module configfs infrastructure WIP
From: Nicholas Bellinger <[email protected]>
This commit contains the first running pieces of TCM generic fabric module configfs infrastructure code for v4.0. This involes the addition of include/target/target_core_configfs.h:struct target_fabric_configfs_template that contains struct config_item_type members used to define the new generic layout in drivers/target/target_core_fabric_configfs.c code.
struct target_fabric_configfs_template {
struct config_item_type tfc_wwn_cit;
struct config_item_type tfc_tpg_cit;
struct config_item_type tfc_tpg_base_cit;
struct config_item_type tfc_tpg_lun_cit;
struct config_item_type tfc_tpg_port_cit;
struct config_item_type tfc_tpg_np_cit;
struct config_item_type tfc_tpg_np_base_cit;
struct config_item_type tfc_tpg_attrib_cit;
struct config_item_type tfc_tpg_param_cit;
struct config_item_type tfc_tpg_acl_cit;
};So far, everything aside from tfc_tpg_acl_cit and NodeACL+MappedLUN ACLs are up and running and able to reproduce existing 3.x fabric module configfs layout in demo mode with patched LIO-Target and TCM_Loop fabric modules. The following fabric module API calls in include/target/target_core_fabric_ops.h:struct target_core_fabric_ops have been added and are used by fabric modules to reproduce existing 3.x $WWN, tpgt_$TPGT and lun/np default groups from /sys/kernel/config/target/$FABRIC/$WWN/tpgt_$TPGT/[lun,np]
/*
* fabric module calls for target_core_fabric_configfs.c
*/
struct se_wwn_s *(*fabric_make_wwn)(struct target_fabric_configfs *,
struct config_group *, const char *);
void (*fabric_drop_wwn)(struct se_wwn_s *);
struct se_portal_group_s *(*fabric_make_tpg)(struct se_wwn_s *,
struct config_group *, const char *);
void (*fabric_drop_tpg)(struct se_portal_group_s *);
int (*fabric_post_link)(struct se_portal_group_s *,
struct se_lun_s *);
void (*fabric_pre_unlink)(struct se_portal_group_s *,
struct se_lun_s *);
struct se_tpg_np_s *(*fabric_make_np)(struct se_portal_group_s *,
struct config_group *, const char *);
void (*fabric_drop_np)(struct se_tpg_np_s *);This commit also includes a number of config_item_type context specific TF_* + CONFIGFS_EATTR() macros in include/target/target_core_fabric_configfs.h that are used by fabric modules to define attributes for 'cits' in the new target_core_fabric_configfs.c code hanging of struct target_fabric_configfs_template.
There are also other relatively minor changes required to existing target_core_mod code in order to get things up and running. This includes:
Changing target_fabric_configfs_init() to accept a 'struct module *' instead of 'struct config_item_type', and saving it at struct target_fabric_configfs->tf_module.
and changing core_tpg_register() to accept the struct se_portal_group_s pointer hanging off the fabric's internal struct $FABRIC_portal_group, and new parent struct se_wwn_s *
--- drivers/target/Kbuild | 1 + drivers/target/target_core_configfs.c | 24 +- drivers/target/target_core_fabric_configfs.c | 612 ++++++++++++++++++++++++++ drivers/target/target_core_tpg.c | 18 +- include/target/target_core_base.h | 22 +- include/target/target_core_configfs.h | 20 +- include/target/target_core_fabric_configfs.h | 50 +++ include/target/target_core_fabric_ops.h | 19 + include/target/target_core_tpg.h | 6 +- 9 files changed, 748 insertions(+), 24 deletions(-) create mode 100644 drivers/target/target_core_fabric_configfs.c create mode 100644 include/target/target_core_fabric_configfs.h
drivers/target/Kbuild +1 -0
@@ -2,6 +2,7 @@ EXTRA_CFLAGS += -I$(srctree)/drivers/target/ -I$(srctree)/drivers/scsi/ target_core_mod-y := target_core_configfs.o \ target_core_device.o \ + target_core_fabric_configfs.o \ target_core_hba.o \ target_core_plugin.o \ target_core_pr.o \
drivers/target/target_core_configfs.c +16 -8
@@ -47,6 +47,7 @@#include <target/target_core_alua.h> #include <target/target_core_pr.h> #include <target/target_core_fabric_ops.h> +#include <target/target_core_fabric_configfs.h> #include <target/target_core_configfs.h> #include <target/configfs_macros.h>
@@ -186,9 +187,10 @@ static struct config_group *target_core_register_fabric(* On a successful target_core_get_fabric() look, the returned * struct target_fabric_configfs *tf will contain a usage reference. */ -printk (KERN_INFO "Target_Core_ConfigFS: REGISTER -> %p\n" , - tf->tf_fabric_cit); -config_group_init_type_name (&tf->tf_group, name, tf->tf_fabric_cit); +printk (KERN_INFO "Target_Core_ConfigFS: REGISTER tfc_wwn_cit -> %p\n" , + &TF_CIT_TMPL (tf)->tfc_wwn_cit); +config_group_init_type_name (&tf->tf_group, name, + &TF_CIT_TMPL (tf)->tfc_wwn_cit);/* * Setup any default configfs groups in the top level directory of * this fabric module.
@@ -285,13 +287,13 @@ static struct configfs_subsystem *target_core_subsystem[] = {* into target_fabric_configfs_register(). */ struct target_fabric_configfs *target_fabric_configfs_init ( -struct config_item_type *fabric_cit, +struct module *fabric_mod,const char *name) {struct target_fabric_configfs *tf; -if (!(fabric_cit)) { -printk (KERN_ERR "Missing struct config_item_type * pointer\n" ); +if (!(fabric_mod)) { +printk (KERN_ERR "Missing struct module *fabric_mod pointer\n" );return NULL ; }if (!(name)) {
@@ -310,7 +312,13 @@ struct target_fabric_configfs *target_fabric_configfs_init(INIT_LIST_HEAD (&tf->tf_list);atomic_set (&tf->tf_access_cnt,0 ); - tf->tf_fabric_cit = fabric_cit; +/* +* 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);
@@ -433,7 +441,7 @@ void target_fabric_configfs_deregister(printk (KERN_INFO "Target_Core_ConfigFS: DEREGISTER -> Releasing tf:" " %s\n" , tf->tf_name); - tf->tf_fabric_cit =NULL ; + tf->tf_module =NULL ; tf->tf_subsys =NULL ;kfree (tf->tf_group.default_groups);kfree (tf);
drivers/target/target_core_fabric_configfs.c new file +612 -0
612 lines not on this page · raw message
drivers/target/target_core_tpg.c +6 -12
@@ -629,28 +629,22 @@ int core_tpg_set_initiator_node_queue_depth( }EXPORT_SYMBOL (core_tpg_set_initiator_node_queue_depth); -se_portal_group_t *core_tpg_register ( +int core_tpg_register (struct target_core_fabric_ops *tfo, +struct se_wwn_s *se_wwn, +struct se_portal_group_s *se_tpg,void *tpg_fabric_ptr,int se_tpg_type) {se_lun_t *lun; -se_portal_group_t *se_tpg;u32 i; - se_tpg =kzalloc (sizeof (se_portal_group_t),GFP_KERNEL ); -if (!(se_tpg)) { -printk (KERN_ERR "Unable to allocate se_portal_group_t\n" ); -return ERR_PTR (-ENOMEM ); - } - se_tpg->tpg_lun_list =kzalloc ((sizeof (se_lun_t) *TRANSPORT_MAX_LUNS_PER_TPG ),GFP_KERNEL );if (!(se_tpg->tpg_lun_list)) {printk (KERN_ERR "Unable to allocate se_portal_group_t->" "tpg_lun_list\n" ); -kfree (se_tpg); -return ERR_PTR (-ENOMEM ); +return -ENOMEM ; }for (i =0 ; i <TRANSPORT_MAX_LUNS_PER_TPG ; i++) {
@@ -669,6 +663,7 @@ se_portal_group_t *core_tpg_register( se_tpg->se_tpg_type = se_tpg_type; se_tpg->se_tpg_fabric_ptr = tpg_fabric_ptr; se_tpg->se_tpg_tfo = tfo; + se_tpg->se_tpg_wwn = se_wwn;INIT_LIST_HEAD (&se_tpg->acl_node_list);INIT_LIST_HEAD (&se_tpg->se_tpg_list);INIT_LIST_HEAD (&se_tpg->tpg_sess_list);
@@ -686,7 +681,7 @@ se_portal_group_t *core_tpg_register( "Normal" : "Discovery", (tfo->tpg_get_wwn(se_tpg) == NULL) ? "None" : tfo->tpg_get_wwn(se_tpg), tfo->tpg_get_tag(se_tpg)); -return se_tpg; +return 0 ; }EXPORT_SYMBOL (core_tpg_register);
@@ -705,7 +700,6 @@ int core_tpg_deregister(se_portal_group_t *se_tpg) se_tpg->se_tpg_fabric_ptr =NULL ;kfree (se_tpg->tpg_lun_list); -kfree (se_tpg);return 0 ; }EXPORT_SYMBOL (core_tpg_deregister);
include/target/target_core_base.h +21 -1
@@ -38,7 +38,7 @@#include <target/target_core_mib.h> #endif /* SNMP_SUPPORT */ -#define TARGET_CORE_MOD_VERSION "v3.2.2" +#define TARGET_CORE_MOD_VERSION "v3.9.8"#define SHUTDOWN_SIGS (sigmask(SIGKILL)|sigmask(SIGINT)|sigmask(SIGABRT))/* SCSI Command Descriptor Block Size a la SCSI's MAX_COMMAND_SIZE */
@@ -936,6 +936,10 @@ typedef struct se_port_s {struct list_head sep_list; }____cacheline_aligned se_port_t; +typedef struct se_tpg_np_s { +struct config_group tpg_np_group; +}____cacheline_aligned se_tpg_np_t ; + typedef struct se_portal_group_s { /* Type of target portal group */ int se_tpg_type;
@@ -956,11 +960,27 @@ typedef struct se_portal_group_s {struct list_head tpg_sess_list;/* Pointer to $FABRIC_MOD dependent code */ struct target_core_fabric_ops *se_tpg_tfo; +struct se_wwn_s *se_tpg_wwn;struct config_group tpg_group; +struct config_group *tpg_default_groups[6 ]; +struct config_group tpg_lun_group; +struct config_group tpg_np_group; +struct config_group tpg_acl_group; +struct config_group tpg_attrib_group; +struct config_group tpg_param_group; }____cacheline_aligned se_portal_group_t;#define TPG_TFO (se_tpg) ((struct target_core_fabric_ops *)(se_tpg)->se_tpg_tfo) +typedef struct se_auth_s { +struct config_group auth_group; +}____cacheline_aligned se_auth_t ; + +typedef struct se_wwn_s { +struct target_fabric_configfs *wwn_tf; +struct config_group wwn_group; +}____cacheline_aligned se_wwn_t ; + typedef struct se_global_s { u16 alua_lu_gps_counter; u32 in_shutdown;
include/target/target_core_configfs.h +19 -1
@@ -36,13 +36,26 @@ extern se_global_t *se_global;extern struct se_hba_s *target_core_get_hba_from_item (struct config_item *);extern struct target_fabric_configfs *target_fabric_configfs_init ( -struct config_item_type *,const char *name); +struct module *,const char *);extern void target_fabric_configfs_free (struct target_fabric_configfs *);extern int target_fabric_configfs_register (struct target_fabric_configfs *);extern void target_fabric_configfs_deregister (struct target_fabric_configfs *);extern int target_core_init_configfs (void );extern void target_core_exit_configfs (void ); +struct target_fabric_configfs_template { +struct config_item_type tfc_wwn_cit; +struct config_item_type tfc_tpg_cit; +struct config_item_type tfc_tpg_base_cit; +struct config_item_type tfc_tpg_lun_cit; +struct config_item_type tfc_tpg_port_cit; +struct config_item_type tfc_tpg_np_cit; +struct config_item_type tfc_tpg_np_base_cit; +struct config_item_type tfc_tpg_attrib_cit; +struct config_item_type tfc_tpg_param_cit; +struct config_item_type tfc_tpg_acl_cit; +}; +struct target_fabric_configfs {char tf_name[TARGET_FABRIC_NAME_SIZE ];atomic_t tf_access_cnt;
@@ -55,5 +68,10 @@ struct target_fabric_configfs {struct config_item_type *tf_fabric_cit;/* Pointer to target core subsystem */ struct configfs_subsystem *tf_subsys; +/* Pointer to fabric's struct module */ +struct module *tf_module;struct target_core_fabric_ops tf_ops; +struct target_fabric_configfs_template tf_cit_tmpl; }; + +#define TF_CIT_TMPL (tf) (&(tf)->tf_cit_tmpl)
include/target/target_core_fabric_configfs.h new file +50 -0
50 lines not on this page · raw message
include/target/target_core_fabric_ops.h +19 -0
@@ -1,3 +1,6 @@ +/* Defined in target_core_configfs.h */ +struct target_fabric_configfs ; +struct target_core_fabric_ops {struct configfs_subsystem *tf_subsys;char *(*get_fabric_name)(void );
@@ -55,4 +58,20 @@ struct target_core_fabric_ops {u16 (*get_fabric_sense_len)(void);int (*is_state_remove)(struct se_cmd_s *);u64 (*pack_lun)(unsigned int ); +/* +* fabric module calls for target_core_fabric_configfs.c +*/ +struct se_wwn_s *(*fabric_make_wwn)(struct target_fabric_configfs *, +struct config_group *,const char *); +void (*fabric_drop_wwn)(struct se_wwn_s *); +struct se_portal_group_s *(*fabric_make_tpg)(struct se_wwn_s *, +struct config_group *,const char *); +void (*fabric_drop_tpg)(struct se_portal_group_s *); +int (*fabric_post_link)(struct se_portal_group_s *, +struct se_lun_s *); +void (*fabric_pre_unlink)(struct se_portal_group_s *, +struct se_lun_s *); +struct se_tpg_np_s *(*fabric_make_np)(struct se_portal_group_s *, +struct config_group *,const char *); +void (*fabric_drop_np)(struct se_tpg_np_s *); };
include/target/target_core_tpg.h +4 -2
@@ -47,8 +47,10 @@ extern int core_tpg_del_initiator_node_acl(se_portal_group_t *, se_node_acl_t *, int);extern int core_tpg_set_initiator_node_queue_depth (se_portal_group_t *,unsigned char *,u32 ,int ); -extern se_portal_group_t *core_tpg_register (struct target_core_fabric_ops *, -void *,int ); +extern int core_tpg_register (struct target_core_fabric_ops *, +struct se_wwn_s *, +struct se_portal_group_s *,void *, +int );extern int core_tpg_deregister (struct se_portal_group_s *);extern se_lun_t *core_tpg_pre_addlun (se_portal_group_t *,u32 ); extern int core_tpg_post_addlun(se_portal_group_t *, se_lun_t *, int, u32,
Signature · 1 line
1.5.6.5