[Devel] [PATCH] target: move blkio_cgroup from attrib/ to param/
Andrei Vagin
avagin at openvz.org
Wed May 23 02:51:14 MSK 2018
targetcli expects to get only number values for attrib/*,
all non-number attributes should be in param/
For example:
/sys/kernel/config/target/core/iblock_0/test/param/blkio_cgroup
https://pmc.acronis.com/browse/VSTOR-10194
Signed-off-by: Andrei Vagin <avagin at openvz.org>
---
drivers/target/target_core_configfs.c | 22 ++++++++++++++++++++--
drivers/target/target_core_device.c | 27 ++++++++++++++-------------
drivers/target/target_core_iblock.c | 17 +++++++++++------
include/target/target_core_backend.h | 1 +
include/target/target_core_backend_configfs.h | 1 +
include/target/target_core_base.h | 8 +++++++-
6 files changed, 54 insertions(+), 22 deletions(-)
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index 7e7de7c..a9a19a4 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -598,6 +598,20 @@ TB_CIT_SETUP(dev_attrib, &target_core_dev_attrib_ops, NULL, NULL);
/* End functions for struct config_item_type tb_dev_attrib_cit */
+/* Start functions for struct config_item_type tb_dev_param_cit */
+
+CONFIGFS_EATTR_STRUCT(target_core_dev_param, se_dev_param);
+CONFIGFS_EATTR_OPS(target_core_dev_param, se_dev_param, da_group);
+
+static struct configfs_item_operations target_core_dev_param_ops = {
+ .show_attribute = target_core_dev_param_attr_show,
+ .store_attribute = target_core_dev_param_attr_store,
+};
+
+TB_CIT_SETUP(dev_param, &target_core_dev_param_ops, NULL, NULL);
+
+/* End functions for struct config_item_type tb_dev_param_cit */
+
/* Start functions for struct config_item_type tb_dev_wwn_cit */
CONFIGFS_EATTR_STRUCT(target_core_dev_wwn, t10_wwn);
@@ -2655,7 +2669,7 @@ static struct config_group *target_core_make_subdev(
dev_cg = &dev->dev_group;
- dev_cg->default_groups = kmalloc(sizeof(struct config_group *) * 6,
+ dev_cg->default_groups = kmalloc(sizeof(struct config_group *) * 7,
GFP_KERNEL);
if (!dev_cg->default_groups)
goto out_free_device;
@@ -2663,6 +2677,8 @@ 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",
&t->tb_cits.tb_dev_attrib_cit);
+ config_group_init_type_name(&dev->dev_param.da_group, "param",
+ &t->tb_cits.tb_dev_param_cit);
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",
@@ -2677,7 +2693,8 @@ static struct config_group *target_core_make_subdev(
dev_cg->default_groups[2] = &dev->t10_wwn.t10_wwn_group;
dev_cg->default_groups[3] = &dev->t10_alua.alua_tg_pt_gps_group;
dev_cg->default_groups[4] = &dev->dev_stat_grps.stat_group;
- dev_cg->default_groups[5] = NULL;
+ dev_cg->default_groups[5] = &dev->dev_param.da_group;
+ dev_cg->default_groups[6] = NULL;
/*
* Add core/$HBA/$DEV/alua/default_tg_pt_gp
*/
@@ -2968,6 +2985,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_param_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);
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index 8f47549..c06cda3 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -835,9 +835,9 @@ ssize_t se_dev_blkio_cgroup_show(struct se_device *dev, char *page)
{
int rb;
- read_lock(&dev->dev_attrib_lock);
- if (dev->dev_attrib.blk_css) {
- rb = cgroup_path(dev->dev_attrib.blk_css->cgroup,
+ read_lock(&dev->dev_param_lock);
+ if (dev->dev_param.blk_css) {
+ rb = cgroup_path(dev->dev_param.blk_css->cgroup,
page, PAGE_SIZE - 1);
if (rb < 0)
goto out;
@@ -849,7 +849,7 @@ ssize_t se_dev_blkio_cgroup_show(struct se_device *dev, char *page)
} else
rb = 0;
out:
- read_unlock(&dev->dev_attrib_lock);
+ read_unlock(&dev->dev_param_lock);
return rb;
}
@@ -873,10 +873,10 @@ ssize_t se_dev_blkio_cgroup_store(struct se_device *dev,
else
css = NULL;
- write_lock(&dev->dev_attrib_lock);
- pcss = dev->dev_attrib.blk_css;
- dev->dev_attrib.blk_css = css;
- write_unlock(&dev->dev_attrib_lock);
+ write_lock(&dev->dev_param_lock);
+ pcss = dev->dev_param.blk_css;
+ dev->dev_param.blk_css = css;
+ write_unlock(&dev->dev_param_lock);
if (pcss)
css_put(pcss);
@@ -1562,7 +1562,7 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
INIT_LIST_HEAD(&dev->state_list);
INIT_LIST_HEAD(&dev->qf_cmd_list);
INIT_LIST_HEAD(&dev->g_dev_node);
- rwlock_init(&dev->dev_attrib_lock);
+ rwlock_init(&dev->dev_param_lock);
spin_lock_init(&dev->execute_task_lock);
spin_lock_init(&dev->delayed_cmd_lock);
spin_lock_init(&dev->dev_reservation_lock);
@@ -1611,7 +1611,8 @@ struct se_device *target_alloc_device(struct se_hba *hba, const char *name)
dev->dev_attrib.unmap_zeroes_data =
DA_UNMAP_ZEROES_DATA_DEFAULT;
dev->dev_attrib.max_write_same_len = DA_MAX_WRITE_SAME_LEN;
- dev->dev_attrib.blk_css = NULL;
+ dev->dev_param.da_dev = dev;
+ dev->dev_param.blk_css = NULL;
xcopy_lun = &dev->xcopy_lun;
xcopy_lun->lun_se_dev = dev;
@@ -1785,9 +1786,9 @@ void target_free_device(struct se_device *dev)
if (dev->transport->free_prot)
dev->transport->free_prot(dev);
- if (dev->dev_attrib.blk_css)
- css_put(dev->dev_attrib.blk_css);
- dev->dev_attrib.blk_css = NULL;
+ if (dev->dev_param.blk_css)
+ css_put(dev->dev_param.blk_css);
+ dev->dev_param.blk_css = NULL;
dev->transport->free_device(dev);
}
diff --git a/drivers/target/target_core_iblock.c b/drivers/target/target_core_iblock.c
index cac5c7b..88a0375 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -715,11 +715,11 @@ iblock_execute_rw(struct se_cmd *cmd, struct scatterlist *sgl, u32 sgl_nents,
return 0;
}
- read_lock(&dev->dev_attrib_lock);
- blk_css = dev->dev_attrib.blk_css;
+ read_lock(&dev->dev_param_lock);
+ blk_css = dev->dev_param.blk_css;
if (blk_css)
css_get(blk_css);
- read_unlock(&dev->dev_attrib_lock);
+ read_unlock(&dev->dev_param_lock);
bio = iblock_get_bio(cmd, block_lba, sgl_nents);
if (!bio)
@@ -860,22 +860,23 @@ static bool iblock_get_write_cache(struct se_device *dev)
}
DEF_TB_DEFAULT_ATTRIBS(iblock);
+
static ssize_t iblock_dev_show_attr_blkio_cgroup(
- struct se_dev_attrib *da,
+ struct se_dev_param *da,
char *page)
{
return se_dev_blkio_cgroup_show(da->da_dev, page);
}
static ssize_t iblock_dev_store_attr_blkio_cgroup(
- struct se_dev_attrib *da,
+ struct se_dev_param *da,
const char *page,
size_t count)
{
return se_dev_blkio_cgroup_store(da->da_dev, page, count);
}
-static struct target_backend_dev_attrib_attribute iblock_dev_attrib_blkio_cgroup =
+static struct target_backend_dev_param_attribute iblock_dev_attrib_blkio_cgroup =
__CONFIGFS_EATTR(blkio_cgroup, S_IRUGO | S_IWUSR,
iblock_dev_show_attr_blkio_cgroup,
iblock_dev_store_attr_blkio_cgroup);
@@ -911,6 +912,9 @@ static struct configfs_attribute *iblock_backend_dev_attrs[] = {
&iblock_dev_attrib_unmap_granularity_alignment.attr,
&iblock_dev_attrib_unmap_zeroes_data.attr,
&iblock_dev_attrib_max_write_same_len.attr,
+ NULL,
+};
+static struct configfs_attribute *iblock_backend_dev_param[] = {
&iblock_dev_attrib_blkio_cgroup.attr,
NULL,
};
@@ -943,6 +947,7 @@ static int __init iblock_module_init(void)
target_core_setup_sub_cits(&iblock_template);
tbc->tb_dev_attrib_cit.ct_attrs = iblock_backend_dev_attrs;
+ tbc->tb_dev_param_cit.ct_attrs = iblock_backend_dev_param;
return transport_subsystem_register(&iblock_template);
}
diff --git a/include/target/target_core_backend.h b/include/target/target_core_backend.h
index bd2f3fe..fb4f5cf 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_cit;
struct config_item_type tb_dev_attrib_cit;
+ struct config_item_type tb_dev_param_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;
diff --git a/include/target/target_core_backend_configfs.h b/include/target/target_core_backend_configfs.h
index 9d83493..fd2af79 100644
--- a/include/target/target_core_backend_configfs.h
+++ b/include/target/target_core_backend_configfs.h
@@ -38,6 +38,7 @@ 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_param, se_dev_param);
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 = \
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 8b85104..9f273ac 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -707,7 +707,12 @@ struct se_dev_attrib {
u32 max_bytes_per_io;
struct se_device *da_dev;
struct config_group da_group;
+};
+
+struct se_dev_param {
struct cgroup_subsys_state *blk_css;
+ struct se_device *da_dev;
+ struct config_group da_group;
};
struct se_port_stat_grps {
@@ -807,7 +812,7 @@ struct se_device {
atomic_t dev_ordered_sync;
atomic_t dev_qf_count;
int export_count;
- rwlock_t dev_attrib_lock;
+ rwlock_t dev_param_lock;
spinlock_t delayed_cmd_lock;
spinlock_t execute_task_lock;
spinlock_t dev_reservation_lock;
@@ -841,6 +846,7 @@ struct se_device {
/* T10 SPC-2 + SPC-3 Reservations */
struct t10_reservation t10_pr;
struct se_dev_attrib dev_attrib;
+ struct se_dev_param dev_param;
struct config_group dev_group;
struct config_group dev_pr_group;
struct se_dev_stat_grps dev_stat_grps;
--
1.8.3.1
More information about the Devel
mailing list