From 73112edca9be1d7c37d0b94348c82c3742c3ef58 Mon Sep 17 00:00:00 2001 From: Nicholas Bellinger Date: Thu, 27 Nov 2014 13:59:20 -0800 Subject: target: Move dev_cit to struct se_subsystem_api 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 --- include/target/target_core_backend.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'include') diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 9adc1bca1178..7b84436541b4 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -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 */ -- cgit v1.2.3 From f79a897efa6a95d698c4064e48e0a5afddc0ad9f Mon Sep 17 00:00:00 2001 From: Nicholas Bellinger Date: Thu, 27 Nov 2014 14:51:14 -0800 Subject: target: Move dev_attrib_cit to struct se_subsystem_api This patch adds support for dev_attrib_cit as an external config_item_type using TB_CIT_SETUP() helper macro, and sets both ct_item_ops + ct_attr following existing code. It updates target_core_make_subdev() + target_core_setup_dev_attrib_cit() + struct target_backend_cits, and drops left-over target_core_dev_attrib_cit from target_core_configfs.c code and update comments. This patch introduces no functional change from existing code. Signed-off-by: Nicholas Bellinger --- drivers/target/target_core_configfs.c | 14 ++++++-------- include/target/target_core_backend.h | 1 + 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index f7b2186ba57b..78ed857cc7b9 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c @@ -584,7 +584,7 @@ EXPORT_SYMBOL(target_fabric_configfs_deregister); // Stop functions called by external Target Fabrics Modules //############################################################################*/ -/* Start functions for struct config_item_type target_core_dev_attrib_cit */ +/* Start functions for struct config_item_type tb_dev_attrib_cit */ #define DEF_DEV_ATTRIB_SHOW(_name) \ static ssize_t target_core_dev_show_attr_##_name( \ @@ -767,13 +767,10 @@ static struct configfs_item_operations target_core_dev_attrib_ops = { .store_attribute = target_core_dev_attrib_attr_store, }; -static struct config_item_type target_core_dev_attrib_cit = { - .ct_item_ops = &target_core_dev_attrib_ops, - .ct_attrs = target_core_dev_attrib_attrs, - .ct_owner = THIS_MODULE, -}; +TB_CIT_SETUP(dev_attrib, &target_core_dev_attrib_ops, NULL, + target_core_dev_attrib_attrs); -/* End functions for struct config_item_type target_core_dev_attrib_cit */ +/* End functions for struct config_item_type tb_dev_attrib_cit */ /* Start functions for struct config_item_type target_core_dev_wwn_cit */ @@ -2826,7 +2823,7 @@ static struct config_group *target_core_make_subdev( 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); + &t->tb_cits.tb_dev_attrib_cit); config_group_init_type_name(&dev->dev_pr_group, "pr", &target_core_dev_pr_cit); config_group_init_type_name(&dev->t10_wwn.t10_wwn_group, "wwn", @@ -3131,6 +3128,7 @@ static struct config_item_type target_core_cit = { void target_core_setup_sub_cits(struct se_subsystem_api *sa) { target_core_setup_dev_cit(sa); + target_core_setup_dev_attrib_cit(sa); } EXPORT_SYMBOL(target_core_setup_sub_cits); diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 7b84436541b4..735f85672ec6 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -7,6 +7,7 @@ struct target_backend_cits { struct config_item_type tb_dev_cit; + struct config_item_type tb_dev_attrib_cit; }; struct se_subsystem_api { -- cgit v1.2.3 From 91e2e39ba89cd627beddafea2a760684adcec89d Mon Sep 17 00:00:00 2001 From: Nicholas Bellinger Date: Thu, 27 Nov 2014 14:57:01 -0800 Subject: target: Move dev_pr_cit to struct se_subsystem_api This patch adds support for dev_pr_cit as an external config_item_type using TB_CIT_SETUP() helper macro, and sets both ct_item_ops + ct_attr following existing code. It updates target_core_make_subdev() + target_core_setup_dev_attrib_cit() + struct target_backend_cits, and drops left-over target_core_dev_pr_cit from target_core_configfs.c code and update comments. This patch introduces no functional change from existing code. Signed-off-by: Nicholas Bellinger --- drivers/target/target_core_configfs.c | 13 +++++-------- include/target/target_core_backend.h | 1 + 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index 78ed857cc7b9..49d51ba40fca 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c @@ -1011,7 +1011,7 @@ static struct config_item_type target_core_dev_wwn_cit = { /* End functions for struct config_item_type target_core_dev_wwn_cit */ -/* Start functions for struct config_item_type target_core_dev_pr_cit */ +/* Start functions for struct config_item_type tb_dev_pr_cit */ CONFIGFS_EATTR_STRUCT(target_core_dev_pr, se_device); #define SE_DEV_PR_ATTR(_name, _mode) \ @@ -1472,13 +1472,9 @@ static struct configfs_item_operations target_core_dev_pr_ops = { .store_attribute = target_core_dev_pr_attr_store, }; -static struct config_item_type target_core_dev_pr_cit = { - .ct_item_ops = &target_core_dev_pr_ops, - .ct_attrs = target_core_dev_pr_attrs, - .ct_owner = THIS_MODULE, -}; +TB_CIT_SETUP(dev_pr, &target_core_dev_pr_ops, NULL, target_core_dev_pr_attrs); -/* End functions for struct config_item_type target_core_dev_pr_cit */ +/* End functions for struct config_item_type tb_dev_pr_cit */ /* Start functions for struct config_item_type tb_dev_cit */ @@ -2825,7 +2821,7 @@ static struct config_group *target_core_make_subdev( config_group_init_type_name(&dev->dev_attrib.da_group, "attrib", &t->tb_cits.tb_dev_attrib_cit); config_group_init_type_name(&dev->dev_pr_group, "pr", - &target_core_dev_pr_cit); + &t->tb_cits.tb_dev_pr_cit); config_group_init_type_name(&dev->t10_wwn.t10_wwn_group, "wwn", &target_core_dev_wwn_cit); config_group_init_type_name(&dev->t10_alua.alua_tg_pt_gps_group, @@ -3129,6 +3125,7 @@ void target_core_setup_sub_cits(struct se_subsystem_api *sa) { target_core_setup_dev_cit(sa); target_core_setup_dev_attrib_cit(sa); + target_core_setup_dev_pr_cit(sa); } EXPORT_SYMBOL(target_core_setup_sub_cits); diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 735f85672ec6..a47e78989b6f 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -8,6 +8,7 @@ struct target_backend_cits { struct config_item_type tb_dev_cit; struct config_item_type tb_dev_attrib_cit; + struct config_item_type tb_dev_pr_cit; }; struct se_subsystem_api { -- cgit v1.2.3 From f8d389c6f6074aa382963ae13f9d77d99ec3e92d Mon Sep 17 00:00:00 2001 From: Nicholas Bellinger Date: Thu, 27 Nov 2014 15:01:12 -0800 Subject: target: Move dev_wwn_cit to struct se_subsystem_api This patch adds support for dev_wwn_cit as an external config_item_type using TB_CIT_SETUP() helper macro, and sets both ct_item_ops + ct_attr following existing code. It updates target_core_make_subdev() + target_core_setup_dev_attrib_cit() + struct target_backend_cits, and drops left-over target_core_dev_wwn_cit from target_core_configfs.c code and update comments. This patch introduces no functional change from existing code. Signed-off-by: Nicholas Bellinger --- drivers/target/target_core_configfs.c | 13 +++++-------- include/target/target_core_backend.h | 1 + 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'include') diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index 49d51ba40fca..43d180e03931 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c @@ -772,7 +772,7 @@ TB_CIT_SETUP(dev_attrib, &target_core_dev_attrib_ops, NULL, /* End functions for struct config_item_type tb_dev_attrib_cit */ -/* Start functions for struct config_item_type target_core_dev_wwn_cit */ +/* Start functions for struct config_item_type tb_dev_wwn_cit */ CONFIGFS_EATTR_STRUCT(target_core_dev_wwn, t10_wwn); #define SE_DEV_WWN_ATTR(_name, _mode) \ @@ -1003,13 +1003,9 @@ static struct configfs_item_operations target_core_dev_wwn_ops = { .store_attribute = target_core_dev_wwn_attr_store, }; -static struct config_item_type target_core_dev_wwn_cit = { - .ct_item_ops = &target_core_dev_wwn_ops, - .ct_attrs = target_core_dev_wwn_attrs, - .ct_owner = THIS_MODULE, -}; +TB_CIT_SETUP(dev_wwn, &target_core_dev_wwn_ops, NULL, target_core_dev_wwn_attrs); -/* End functions for struct config_item_type target_core_dev_wwn_cit */ +/* End functions for struct config_item_type tb_dev_wwn_cit */ /* Start functions for struct config_item_type tb_dev_pr_cit */ @@ -2823,7 +2819,7 @@ static struct config_group *target_core_make_subdev( config_group_init_type_name(&dev->dev_pr_group, "pr", &t->tb_cits.tb_dev_pr_cit); config_group_init_type_name(&dev->t10_wwn.t10_wwn_group, "wwn", - &target_core_dev_wwn_cit); + &t->tb_cits.tb_dev_wwn_cit); config_group_init_type_name(&dev->t10_alua.alua_tg_pt_gps_group, "alua", &target_core_alua_tg_pt_gps_cit); config_group_init_type_name(&dev->dev_stat_grps.stat_group, @@ -3126,6 +3122,7 @@ void target_core_setup_sub_cits(struct se_subsystem_api *sa) 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); } EXPORT_SYMBOL(target_core_setup_sub_cits); diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index a47e78989b6f..68fad7814982 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -9,6 +9,7 @@ struct target_backend_cits { struct config_item_type tb_dev_cit; struct config_item_type tb_dev_attrib_cit; struct config_item_type tb_dev_pr_cit; + struct config_item_type tb_dev_wwn_cit; }; struct se_subsystem_api { -- cgit v1.2.3 From 72aca57bd3fef535972b64c9cd76a088107c589c Mon Sep 17 00:00:00 2001 From: Nicholas Bellinger Date: Thu, 27 Nov 2014 15:06:23 -0800 Subject: target: Move dev_alua_tg_pt_gps_cit to struct se_subsystem_api This patch adds support for dev_alua_tg_pt_gps_cit as an external config_item_type using TB_CIT_SETUP() helper macro, and sets only ct_group_ops following existing code. It updates target_core_make_subdev() + target_core_setup_dev_attrib_cit() + struct target_backend_cits, and drops left-over target_core_dev_alua_tg_pt_gps_cit from target_core_configfs.c code and update comments. This patch introduces no functional change from existing code. Signed-off-by: Nicholas Bellinger --- drivers/target/target_core_configfs.c | 12 +++++------- include/target/target_core_backend.h | 1 + 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index 43d180e03931..0cf41ad54bbf 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c @@ -2677,7 +2677,7 @@ static struct config_item_type target_core_alua_tg_pt_gp_cit = { /* End functions for struct config_item_type target_core_alua_tg_pt_gp_cit */ -/* Start functions for struct config_item_type target_core_alua_tg_pt_gps_cit */ +/* Start functions for struct config_item_type tb_alua_tg_pt_gps_cit */ static struct config_group *target_core_alua_create_tg_pt_gp( struct config_group *group, @@ -2728,12 +2728,9 @@ static struct configfs_group_operations target_core_alua_tg_pt_gps_group_ops = { .drop_item = &target_core_alua_drop_tg_pt_gp, }; -static struct config_item_type target_core_alua_tg_pt_gps_cit = { - .ct_group_ops = &target_core_alua_tg_pt_gps_group_ops, - .ct_owner = THIS_MODULE, -}; +TB_CIT_SETUP(dev_alua_tg_pt_gps, NULL, &target_core_alua_tg_pt_gps_group_ops, NULL); -/* End functions for struct config_item_type target_core_alua_tg_pt_gps_cit */ +/* End functions for struct config_item_type tb_alua_tg_pt_gps_cit */ /* Start functions for struct config_item_type target_core_alua_cit */ @@ -2821,7 +2818,7 @@ static struct config_group *target_core_make_subdev( config_group_init_type_name(&dev->t10_wwn.t10_wwn_group, "wwn", &t->tb_cits.tb_dev_wwn_cit); config_group_init_type_name(&dev->t10_alua.alua_tg_pt_gps_group, - "alua", &target_core_alua_tg_pt_gps_cit); + "alua", &t->tb_cits.tb_dev_alua_tg_pt_gps_cit); config_group_init_type_name(&dev->dev_stat_grps.stat_group, "statistics", &target_core_stat_cit); @@ -3123,6 +3120,7 @@ void target_core_setup_sub_cits(struct se_subsystem_api *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); } EXPORT_SYMBOL(target_core_setup_sub_cits); diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 68fad7814982..157d173f28fb 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -10,6 +10,7 @@ struct target_backend_cits { struct config_item_type tb_dev_attrib_cit; struct config_item_type tb_dev_pr_cit; struct config_item_type tb_dev_wwn_cit; + struct config_item_type tb_dev_alua_tg_pt_gps_cit; }; struct se_subsystem_api { -- cgit v1.2.3 From d23ab570bcb1de0256f1dcea0b8ad3af8e534e40 Mon Sep 17 00:00:00 2001 From: Nicholas Bellinger Date: Thu, 27 Nov 2014 15:09:32 -0800 Subject: target: Move dev_stat_cit to struct se_subsystem_api This patch adds support for dev_stat_cit as an external config_item_type using TB_CIT_SETUP() helper macro, and sets only ct_group_ops following existing code. It updates target_core_make_subdev() + target_core_setup_dev_attrib_cit() + struct target_backend_cits, and drops left-over target_core_dev_stat_cit from target_core_configfs.c code and update comments. This patch introduces no functional change from existing code. Signed-off-by: Nicholas Bellinger --- drivers/target/target_core_configfs.c | 12 +++++------- include/target/target_core_backend.h | 1 + 2 files changed, 6 insertions(+), 7 deletions(-) (limited to 'include') diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c index 0cf41ad54bbf..2903d8931625 100644 --- a/drivers/target/target_core_configfs.c +++ b/drivers/target/target_core_configfs.c @@ -2748,7 +2748,7 @@ static struct config_item_type target_core_alua_cit = { /* End functions for struct config_item_type target_core_alua_cit */ -/* Start functions for struct config_item_type target_core_stat_cit */ +/* Start functions for struct config_item_type tb_dev_stat_cit */ static struct config_group *target_core_stat_mkdir( struct config_group *group, @@ -2769,12 +2769,9 @@ static struct configfs_group_operations target_core_stat_group_ops = { .drop_item = &target_core_stat_rmdir, }; -static struct config_item_type target_core_stat_cit = { - .ct_group_ops = &target_core_stat_group_ops, - .ct_owner = THIS_MODULE, -}; +TB_CIT_SETUP(dev_stat, NULL, &target_core_stat_group_ops, NULL); -/* End functions for struct config_item_type target_core_stat_cit */ +/* End functions for struct config_item_type tb_dev_stat_cit */ /* Start functions for struct config_item_type target_core_hba_cit */ @@ -2820,7 +2817,7 @@ static struct config_group *target_core_make_subdev( config_group_init_type_name(&dev->t10_alua.alua_tg_pt_gps_group, "alua", &t->tb_cits.tb_dev_alua_tg_pt_gps_cit); config_group_init_type_name(&dev->dev_stat_grps.stat_group, - "statistics", &target_core_stat_cit); + "statistics", &t->tb_cits.tb_dev_stat_cit); dev_cg->default_groups[0] = &dev->dev_attrib.da_group; dev_cg->default_groups[1] = &dev->dev_pr_group; @@ -3121,6 +3118,7 @@ void target_core_setup_sub_cits(struct se_subsystem_api *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); } EXPORT_SYMBOL(target_core_setup_sub_cits); diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 157d173f28fb..83a3726eabc5 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -11,6 +11,7 @@ struct target_backend_cits { struct config_item_type tb_dev_pr_cit; struct config_item_type tb_dev_wwn_cit; struct config_item_type tb_dev_alua_tg_pt_gps_cit; + struct config_item_type tb_dev_stat_cit; }; struct se_subsystem_api { -- cgit v1.2.3 From 7a23f890b7c11b63dfc2a6c7ae1f0a631ed84865 Mon Sep 17 00:00:00 2001 From: Nicholas Bellinger Date: Thu, 27 Nov 2014 18:57:27 -0800 Subject: target: Add target_core_backend_configfs.h helper macros This patch adds a number of configfs e-attr macros following what existing target_core_configfs.c code does for internal target_backend_dev_attrib setup, and similar to how target fabric drivers allow for external config_item_type + cit->ct_attrs. assignment. This is useful for backend drivers like PSCSI who need to only expose a small subset of device attributes, while still retaining a default list of attributes for other backend drivers like IBLOCK, FILEIO, RAMDISK, and TCMU. Signed-off-by: Nicholas Bellinger --- include/target/target_core_backend_configfs.h | 53 +++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 include/target/target_core_backend_configfs.h (limited to 'include') diff --git a/include/target/target_core_backend_configfs.h b/include/target/target_core_backend_configfs.h new file mode 100644 index 000000000000..f91935b5ef24 --- /dev/null +++ b/include/target/target_core_backend_configfs.h @@ -0,0 +1,53 @@ +#ifndef TARGET_CORE_BACKEND_CONFIGFS_H +#define TARGET_CORE_BACKEND_CONFIGFS_H + +#include + +#define DEF_TB_DEV_ATTRIB_SHOW(_backend, _name) \ +static ssize_t _backend##_dev_show_attr_##_name( \ + struct se_dev_attrib *da, \ + char *page) \ +{ \ + return snprintf(page, PAGE_SIZE, "%u\n", \ + (u32)da->da_dev->dev_attrib._name); \ +} + +#define DEF_TB_DEV_ATTRIB_STORE(_backend, _name) \ +static ssize_t _backend##_dev_store_attr_##_name( \ + struct se_dev_attrib *da, \ + const char *page, \ + size_t count) \ +{ \ + unsigned long val; \ + int ret; \ + \ + ret = kstrtoul(page, 0, &val); \ + if (ret < 0) { \ + pr_err("kstrtoul() failed with ret: %d\n", ret); \ + return -EINVAL; \ + } \ + ret = se_dev_set_##_name(da->da_dev, (u32)val); \ + \ + return (!ret) ? count : -EINVAL; \ +} + +#define DEF_TB_DEV_ATTRIB(_backend, _name) \ +DEF_TB_DEV_ATTRIB_SHOW(_backend, _name); \ +DEF_TB_DEV_ATTRIB_STORE(_backend, _name); + +#define DEF_TB_DEV_ATTRIB_RO(_backend, name) \ +DEF_TB_DEV_ATTRIB_SHOW(_backend, name); + +CONFIGFS_EATTR_STRUCT(target_backend_dev_attrib, se_dev_attrib); +#define TB_DEV_ATTR(_backend, _name, _mode) \ +static struct target_backend_dev_attrib_attribute _backend##_dev_attrib_##_name = \ + __CONFIGFS_EATTR(_name, _mode, \ + _backend##_dev_show_attr_##_name, \ + _backend##_dev_store_attr_##_name); + +#define TB_DEV_ATTR_RO(_backend, _name) \ +static struct target_backend_dev_attrib_attribute _backend##_dev_attrib_##_name = \ + __CONFIGFS_EATTR_RO(_name, \ + _backend##_dev_show_attr_##_name); + +#endif /* TARGET_CORE_BACKEND_CONFIGFS_H */ -- cgit v1.2.3 From d30cd1238c2f89662c82d5d2c4686971a6dc3693 Mon Sep 17 00:00:00 2001 From: Nicholas Bellinger Date: Thu, 27 Nov 2014 19:15:48 -0800 Subject: target: Add EXPORT_SYMBOL for existing se_dev_set_* Now that target_core_backend_configfs.h macros will be using these se_dev_set attribute functions externally to allow backend drivers to populate different attributes, go ahead and add EXPORT_SYMBOL() for the existing default set of 30 device attributes. Also update target_core_backend.h with proper function prototypes. Signed-off-by: Nicholas Bellinger --- drivers/target/target_core_device.c | 26 ++++++++++++++++++++++++++ drivers/target/target_core_iblock.c | 1 + drivers/target/target_core_internal.h | 28 ---------------------------- include/target/target_core_backend.h | 29 +++++++++++++++++++++++++++++ 4 files changed, 56 insertions(+), 28 deletions(-) (limited to 'include') diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c index c45f9e907e44..953fff79bc14 100644 --- a/drivers/target/target_core_device.c +++ b/drivers/target/target_core_device.c @@ -659,6 +659,7 @@ int se_dev_set_max_unmap_lba_count( dev, dev->dev_attrib.max_unmap_lba_count); return 0; } +EXPORT_SYMBOL(se_dev_set_max_unmap_lba_count); int se_dev_set_max_unmap_block_desc_count( struct se_device *dev, @@ -670,6 +671,7 @@ int se_dev_set_max_unmap_block_desc_count( dev, dev->dev_attrib.max_unmap_block_desc_count); return 0; } +EXPORT_SYMBOL(se_dev_set_max_unmap_block_desc_count); int se_dev_set_unmap_granularity( struct se_device *dev, @@ -680,6 +682,7 @@ int se_dev_set_unmap_granularity( dev, dev->dev_attrib.unmap_granularity); return 0; } +EXPORT_SYMBOL(se_dev_set_unmap_granularity); int se_dev_set_unmap_granularity_alignment( struct se_device *dev, @@ -690,6 +693,7 @@ int se_dev_set_unmap_granularity_alignment( dev, dev->dev_attrib.unmap_granularity_alignment); return 0; } +EXPORT_SYMBOL(se_dev_set_unmap_granularity_alignment); int se_dev_set_max_write_same_len( struct se_device *dev, @@ -700,6 +704,7 @@ int se_dev_set_max_write_same_len( dev, dev->dev_attrib.max_write_same_len); return 0; } +EXPORT_SYMBOL(se_dev_set_max_write_same_len); static void dev_set_t10_wwn_model_alias(struct se_device *dev) { @@ -738,6 +743,7 @@ int se_dev_set_emulate_model_alias(struct se_device *dev, int flag) return 0; } +EXPORT_SYMBOL(se_dev_set_emulate_model_alias); int se_dev_set_emulate_dpo(struct se_device *dev, int flag) { @@ -753,6 +759,7 @@ int se_dev_set_emulate_dpo(struct se_device *dev, int flag) return 0; } +EXPORT_SYMBOL(se_dev_set_emulate_dpo); int se_dev_set_emulate_fua_write(struct se_device *dev, int flag) { @@ -771,6 +778,7 @@ int se_dev_set_emulate_fua_write(struct se_device *dev, int flag) dev, dev->dev_attrib.emulate_fua_write); return 0; } +EXPORT_SYMBOL(se_dev_set_emulate_fua_write); int se_dev_set_emulate_fua_read(struct se_device *dev, int flag) { @@ -786,6 +794,7 @@ int se_dev_set_emulate_fua_read(struct se_device *dev, int flag) return 0; } +EXPORT_SYMBOL(se_dev_set_emulate_fua_read); int se_dev_set_emulate_write_cache(struct se_device *dev, int flag) { @@ -809,6 +818,7 @@ int se_dev_set_emulate_write_cache(struct se_device *dev, int flag) dev, dev->dev_attrib.emulate_write_cache); return 0; } +EXPORT_SYMBOL(se_dev_set_emulate_write_cache); int se_dev_set_emulate_ua_intlck_ctrl(struct se_device *dev, int flag) { @@ -829,6 +839,7 @@ int se_dev_set_emulate_ua_intlck_ctrl(struct se_device *dev, int flag) return 0; } +EXPORT_SYMBOL(se_dev_set_emulate_ua_intlck_ctrl); int se_dev_set_emulate_tas(struct se_device *dev, int flag) { @@ -849,6 +860,7 @@ int se_dev_set_emulate_tas(struct se_device *dev, int flag) return 0; } +EXPORT_SYMBOL(se_dev_set_emulate_tas); int se_dev_set_emulate_tpu(struct se_device *dev, int flag) { @@ -870,6 +882,7 @@ int se_dev_set_emulate_tpu(struct se_device *dev, int flag) dev, flag); return 0; } +EXPORT_SYMBOL(se_dev_set_emulate_tpu); int se_dev_set_emulate_tpws(struct se_device *dev, int flag) { @@ -891,6 +904,7 @@ int se_dev_set_emulate_tpws(struct se_device *dev, int flag) dev, flag); return 0; } +EXPORT_SYMBOL(se_dev_set_emulate_tpws); int se_dev_set_emulate_caw(struct se_device *dev, int flag) { @@ -904,6 +918,7 @@ int se_dev_set_emulate_caw(struct se_device *dev, int flag) return 0; } +EXPORT_SYMBOL(se_dev_set_emulate_caw); int se_dev_set_emulate_3pc(struct se_device *dev, int flag) { @@ -917,6 +932,7 @@ int se_dev_set_emulate_3pc(struct se_device *dev, int flag) return 0; } +EXPORT_SYMBOL(se_dev_set_emulate_3pc); int se_dev_set_pi_prot_type(struct se_device *dev, int flag) { @@ -970,6 +986,7 @@ int se_dev_set_pi_prot_type(struct se_device *dev, int flag) return 0; } +EXPORT_SYMBOL(se_dev_set_pi_prot_type); int se_dev_set_pi_prot_format(struct se_device *dev, int flag) { @@ -1005,6 +1022,7 @@ int se_dev_set_pi_prot_format(struct se_device *dev, int flag) return 0; } +EXPORT_SYMBOL(se_dev_set_pi_prot_format); int se_dev_set_enforce_pr_isids(struct se_device *dev, int flag) { @@ -1017,6 +1035,7 @@ int se_dev_set_enforce_pr_isids(struct se_device *dev, int flag) (dev->dev_attrib.enforce_pr_isids) ? "Enabled" : "Disabled"); return 0; } +EXPORT_SYMBOL(se_dev_set_enforce_pr_isids); int se_dev_set_force_pr_aptpl(struct se_device *dev, int flag) { @@ -1034,6 +1053,7 @@ int se_dev_set_force_pr_aptpl(struct se_device *dev, int flag) pr_debug("dev[%p]: SE Device force_pr_aptpl: %d\n", dev, flag); return 0; } +EXPORT_SYMBOL(se_dev_set_force_pr_aptpl); int se_dev_set_is_nonrot(struct se_device *dev, int flag) { @@ -1046,6 +1066,7 @@ int se_dev_set_is_nonrot(struct se_device *dev, int flag) dev, flag); return 0; } +EXPORT_SYMBOL(se_dev_set_is_nonrot); int se_dev_set_emulate_rest_reord(struct se_device *dev, int flag) { @@ -1058,6 +1079,7 @@ int se_dev_set_emulate_rest_reord(struct se_device *dev, int flag) pr_debug("dev[%p]: SE Device emulate_rest_reord: %d\n", dev, flag); return 0; } +EXPORT_SYMBOL(se_dev_set_emulate_rest_reord); /* * Note, this can only be called on unexported SE Device Object. @@ -1101,6 +1123,7 @@ int se_dev_set_queue_depth(struct se_device *dev, u32 queue_depth) dev, queue_depth); return 0; } +EXPORT_SYMBOL(se_dev_set_queue_depth); int se_dev_set_fabric_max_sectors(struct se_device *dev, u32 fabric_max_sectors) { @@ -1155,6 +1178,7 @@ int se_dev_set_fabric_max_sectors(struct se_device *dev, u32 fabric_max_sectors) dev, fabric_max_sectors); return 0; } +EXPORT_SYMBOL(se_dev_set_fabric_max_sectors); int se_dev_set_optimal_sectors(struct se_device *dev, u32 optimal_sectors) { @@ -1181,6 +1205,7 @@ int se_dev_set_optimal_sectors(struct se_device *dev, u32 optimal_sectors) dev, optimal_sectors); return 0; } +EXPORT_SYMBOL(se_dev_set_optimal_sectors); int se_dev_set_block_size(struct se_device *dev, u32 block_size) { @@ -1218,6 +1243,7 @@ int se_dev_set_block_size(struct se_device *dev, u32 block_size) return 0; } +EXPORT_SYMBOL(se_dev_set_block_size); struct se_lun *core_dev_add_lun( struct se_portal_group *tpg, diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c index 7e6b857c6b3f..5e69d36af105 100644 --- a/drivers/target/target_core_iblock.c +++ b/drivers/target/target_core_iblock.c @@ -858,6 +858,7 @@ static bool iblock_get_write_cache(struct se_device *dev) return q->flush_flags & REQ_FLUSH; } + static struct se_subsystem_api iblock_template = { .name = "iblock", .inquiry_prod = "IBLOCK", diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h index e31f42f369ff..60381db90026 100644 --- a/drivers/target/target_core_internal.h +++ b/drivers/target/target_core_internal.h @@ -18,34 +18,6 @@ int core_dev_export(struct se_device *, struct se_portal_group *, struct se_lun *); void core_dev_unexport(struct se_device *, struct se_portal_group *, struct se_lun *); -int se_dev_set_task_timeout(struct se_device *, u32); -int se_dev_set_max_unmap_lba_count(struct se_device *, u32); -int se_dev_set_max_unmap_block_desc_count(struct se_device *, u32); -int se_dev_set_unmap_granularity(struct se_device *, u32); -int se_dev_set_unmap_granularity_alignment(struct se_device *, u32); -int se_dev_set_max_write_same_len(struct se_device *, u32); -int se_dev_set_emulate_model_alias(struct se_device *, int); -int se_dev_set_emulate_dpo(struct se_device *, int); -int se_dev_set_emulate_fua_write(struct se_device *, int); -int se_dev_set_emulate_fua_read(struct se_device *, int); -int se_dev_set_emulate_write_cache(struct se_device *, int); -int se_dev_set_emulate_ua_intlck_ctrl(struct se_device *, int); -int se_dev_set_emulate_tas(struct se_device *, int); -int se_dev_set_emulate_tpu(struct se_device *, int); -int se_dev_set_emulate_tpws(struct se_device *, int); -int se_dev_set_emulate_caw(struct se_device *, int); -int se_dev_set_emulate_3pc(struct se_device *, int); -int se_dev_set_pi_prot_type(struct se_device *, int); -int se_dev_set_pi_prot_format(struct se_device *, int); -int se_dev_set_enforce_pr_isids(struct se_device *, int); -int se_dev_set_force_pr_aptpl(struct se_device *, int); -int se_dev_set_is_nonrot(struct se_device *, int); -int se_dev_set_emulate_rest_reord(struct se_device *dev, int); -int se_dev_set_queue_depth(struct se_device *, u32); -int se_dev_set_max_sectors(struct se_device *, u32); -int se_dev_set_fabric_max_sectors(struct se_device *, u32); -int se_dev_set_optimal_sectors(struct se_device *, u32); -int se_dev_set_block_size(struct se_device *, u32); struct se_lun *core_dev_add_lun(struct se_portal_group *, struct se_device *, u32); void core_dev_del_lun(struct se_portal_group *, struct se_lun *); struct se_lun *core_get_lun_from_tpg(struct se_portal_group *, u32); diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h index 83a3726eabc5..430cfaf92285 100644 --- a/include/target/target_core_backend.h +++ b/include/target/target_core_backend.h @@ -110,4 +110,33 @@ 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 *); +/* attribute helpers from target_core_device.c for backend drivers */ +int se_dev_set_max_unmap_lba_count(struct se_device *, u32); +int se_dev_set_max_unmap_block_desc_count(struct se_device *, u32); +int se_dev_set_unmap_granularity(struct se_device *, u32); +int se_dev_set_unmap_granularity_alignment(struct se_device *, u32); +int se_dev_set_max_write_same_len(struct se_device *, u32); +int se_dev_set_emulate_model_alias(struct se_device *, int); +int se_dev_set_emulate_dpo(struct se_device *, int); +int se_dev_set_emulate_fua_write(struct se_device *, int); +int se_dev_set_emulate_fua_read(struct se_device *, int); +int se_dev_set_emulate_write_cache(struct se_device *, int); +int se_dev_set_emulate_ua_intlck_ctrl(struct se_device *, int); +int se_dev_set_emulate_tas(struct se_device *, int); +int se_dev_set_emulate_tpu(struct se_device *, int); +int se_dev_set_emulate_tpws(struct se_device *, int); +int se_dev_set_emulate_caw(struct se_device *, int); +int se_dev_set_emulate_3pc(struct se_device *, int); +int se_dev_set_pi_prot_type(struct se_device *, int); +int se_dev_set_pi_prot_format(struct se_device *, int); +int se_dev_set_enforce_pr_isids(struct se_device *, int); +int se_dev_set_force_pr_aptpl(struct se_device *, int); +int se_dev_set_is_nonrot(struct se_device *, int); +int se_dev_set_emulate_rest_reord(struct se_device *dev, int); +int se_dev_set_queue_depth(struct se_device *, u32); +int se_dev_set_max_sectors(struct se_device *, u32); +int se_dev_set_fabric_max_sectors(struct se_device *, u32); +int se_dev_set_optimal_sectors(struct se_device *, u32); +int se_dev_set_block_size(struct se_device *, u32); + #endif /* TARGET_CORE_BACKEND_H */ -- cgit v1.2.3 From e6c39f703a878b8d9427ca7b4dc8f97874d12ae6 Mon Sep 17 00:00:00 2001 From: Nicholas Bellinger Date: Thu, 27 Nov 2014 19:49:36 -0800 Subject: target: Add DEF_TB_DEFAULT_ATTRIBS macro for virtual device attrs This helper macro adds the default set of 30 device attributes for virtual devices from existing target_core_configfs.c code, and moves the definitions into a single macro to create the structs necessary for backend drivers. It allows them to populate their own external struct configfs_attribute for se_subsystem_api->tb_cits.tb_dev_attrib_cit.ct_attrs. Signed-off-by: Nicholas Bellinger --- include/target/target_core_backend_configfs.h | 67 +++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) (limited to 'include') diff --git a/include/target/target_core_backend_configfs.h b/include/target/target_core_backend_configfs.h index f91935b5ef24..3247d7530107 100644 --- a/include/target/target_core_backend_configfs.h +++ b/include/target/target_core_backend_configfs.h @@ -50,4 +50,71 @@ static struct target_backend_dev_attrib_attribute _backend##_dev_attrib_##_name __CONFIGFS_EATTR_RO(_name, \ _backend##_dev_show_attr_##_name); +/* + * Default list of target backend device attributes as defined by + * struct se_dev_attrib + */ + +#define DEF_TB_DEFAULT_ATTRIBS(_backend) \ + DEF_TB_DEV_ATTRIB(_backend, emulate_model_alias); \ + TB_DEV_ATTR(_backend, emulate_model_alias, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, emulate_dpo); \ + TB_DEV_ATTR(_backend, emulate_dpo, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, emulate_fua_write); \ + TB_DEV_ATTR(_backend, emulate_fua_write, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, emulate_fua_read); \ + TB_DEV_ATTR(_backend, emulate_fua_read, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, emulate_write_cache); \ + TB_DEV_ATTR(_backend, emulate_write_cache, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, emulate_ua_intlck_ctrl); \ + TB_DEV_ATTR(_backend, emulate_ua_intlck_ctrl, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, emulate_tas); \ + TB_DEV_ATTR(_backend, emulate_tas, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, emulate_tpu); \ + TB_DEV_ATTR(_backend, emulate_tpu, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, emulate_tpws); \ + TB_DEV_ATTR(_backend, emulate_tpws, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, emulate_caw); \ + TB_DEV_ATTR(_backend, emulate_caw, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, emulate_3pc); \ + TB_DEV_ATTR(_backend, emulate_3pc, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, pi_prot_type); \ + TB_DEV_ATTR(_backend, pi_prot_type, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB_RO(_backend, hw_pi_prot_type); \ + TB_DEV_ATTR_RO(_backend, hw_pi_prot_type); \ + DEF_TB_DEV_ATTRIB(_backend, pi_prot_format); \ + TB_DEV_ATTR(_backend, pi_prot_format, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, enforce_pr_isids); \ + TB_DEV_ATTR(_backend, enforce_pr_isids, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, is_nonrot); \ + TB_DEV_ATTR(_backend, is_nonrot, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, emulate_rest_reord); \ + TB_DEV_ATTR(_backend, emulate_rest_reord, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, force_pr_aptpl); \ + TB_DEV_ATTR(_backend, force_pr_aptpl, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB_RO(_backend, hw_block_size); \ + TB_DEV_ATTR_RO(_backend, hw_block_size); \ + DEF_TB_DEV_ATTRIB(_backend, block_size); \ + TB_DEV_ATTR(_backend, block_size, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB_RO(_backend, hw_max_sectors); \ + TB_DEV_ATTR_RO(_backend, hw_max_sectors); \ + DEF_TB_DEV_ATTRIB(_backend, fabric_max_sectors); \ + TB_DEV_ATTR(_backend, fabric_max_sectors, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, optimal_sectors); \ + TB_DEV_ATTR(_backend, optimal_sectors, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB_RO(_backend, hw_queue_depth); \ + TB_DEV_ATTR_RO(_backend, hw_queue_depth); \ + DEF_TB_DEV_ATTRIB(_backend, queue_depth); \ + TB_DEV_ATTR(_backend, queue_depth, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, max_unmap_lba_count); \ + TB_DEV_ATTR(_backend, max_unmap_lba_count, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, max_unmap_block_desc_count); \ + TB_DEV_ATTR(_backend, max_unmap_block_desc_count, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, unmap_granularity); \ + TB_DEV_ATTR(_backend, unmap_granularity, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, unmap_granularity_alignment); \ + TB_DEV_ATTR(_backend, unmap_granularity_alignment, S_IRUGO | S_IWUSR); \ + DEF_TB_DEV_ATTRIB(_backend, max_write_same_len); \ + TB_DEV_ATTR(_backend, max_write_same_len, S_IRUGO | S_IWUSR); + #endif /* TARGET_CORE_BACKEND_CONFIGFS_H */ -- cgit v1.2.3 From 3875f15207f9ecb3f24a8e91e7ad196899139595 Mon Sep 17 00:00:00 2001 From: Kyle McMartin Date: Thu, 18 Dec 2014 12:57:14 -0500 Subject: uapi/linux/target_core_user.h: fix headers_install.sh badness scripts/headers_install.sh will transform __packed to __attribute__((packed)), so the #ifndef is not necessary. (and, in fact, it's problematic, because we'll end up with the header containing: #ifndef __attribute__((packed)) #define __attribu... and so forth.) Cc: stable@vger.kernel.org # 3.18 Signed-off-by: Kyle McMartin Signed-off-by: Nicholas Bellinger --- include/uapi/linux/target_core_user.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'include') diff --git a/include/uapi/linux/target_core_user.h b/include/uapi/linux/target_core_user.h index 7dcfbe6771b1..b483d1909d3e 100644 --- a/include/uapi/linux/target_core_user.h +++ b/include/uapi/linux/target_core_user.h @@ -6,10 +6,6 @@ #include #include -#ifndef __packed -#define __packed __attribute__((packed)) -#endif - #define TCMU_VERSION "1.0" /* -- cgit v1.2.3