[Devel] [PATCH RHEL7 COMMIT] target: move blkio_cgroup from attrib/ to param/

Konstantin Khorenko khorenko at virtuozzo.com
Mon Jun 25 19:19:54 MSK 2018


The commit is pushed to "branch-rh7-3.10.0-862.3.2.vz7.61.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-862.3.2.vz7.61.4
------>
commit 56be12973426eae23fc29ad7133d058f0a002ea6
Author: Andrei Vagin <avagin at openvz.org>
Date:   Mon Jun 25 19:19:54 2018 +0300

    target: move blkio_cgroup from attrib/ to param/
    
    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 | 39 +++++++++++++++++++++++++----------
 drivers/target/target_core_device.c   | 13 +++++++-----
 drivers/target/target_core_iblock.c   |  7 ++++---
 drivers/target/target_core_internal.h |  1 +
 include/target/target_core_backend.h  |  2 ++
 include/target/target_core_base.h     |  8 ++++++-
 6 files changed, 50 insertions(+), 20 deletions(-)

diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index 2cbe2184a90c..a5a66ce16c39 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -454,6 +454,12 @@ static inline struct se_dev_attrib *to_attrib(struct config_item *item)
 			da_group);
 }
 
+static inline struct se_dev_param *to_param(struct config_item *item)
+{
+	return container_of(to_config_group(item), struct se_dev_param,
+			da_group);
+}
+
 /* Start functions for struct config_item_type tb_dev_attrib_cit */
 #define DEF_CONFIGFS_ATTRIB_SHOW(_name)					\
 static ssize_t _name##_show(struct config_item *item, char *page)	\
@@ -997,13 +1003,14 @@ static ssize_t block_size_store(struct config_item *item,
 
 static ssize_t blkio_cgroup_show(struct config_item *item, char *page)
 {
-	struct se_dev_attrib *da = to_attrib(item);
+	struct se_dev_param *da = to_param(item);
 	struct se_device *dev = da->da_dev;
 	int rb;
 
-	read_lock(&dev->dev_attrib_lock);
-	if (dev->dev_attrib.blk_css) {
-		rb = cgroup_path(dev->dev_attrib.blk_css->cgroup,
+	printk("%s:%d: %p\n", __func__, __LINE__, dev);
+	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;
@@ -1015,7 +1022,7 @@ static ssize_t blkio_cgroup_show(struct config_item *item, char *page)
 	} else
 		rb = 0;
 out:
-	read_unlock(&dev->dev_attrib_lock);
+	read_unlock(&dev->dev_param_lock);
 
 	return rb;
 }
@@ -1023,7 +1030,7 @@ static ssize_t blkio_cgroup_show(struct config_item *item, char *page)
 static ssize_t blkio_cgroup_store(struct config_item *item,
 		const char *page, size_t count)
 {
-	struct se_dev_attrib *da = to_attrib(item);
+	struct se_dev_param *da = to_param(item);
 	struct se_device *dev = da->da_dev;
 	struct cgroup_subsys_state *css, *pcss;
 	int ret;
@@ -1040,10 +1047,10 @@ static ssize_t blkio_cgroup_store(struct config_item *item,
 	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);
@@ -1139,13 +1146,17 @@ struct configfs_attribute *sbc_attrib_attrs[] = {
 	&attr_unmap_granularity_alignment,
 	&attr_unmap_zeroes_data,
 	&attr_max_write_same_len,
-	&attr_blkio_cgroup,
 	&attr_alua_support,
 	&attr_pgr_support,
 	NULL,
 };
 EXPORT_SYMBOL(sbc_attrib_attrs);
 
+struct configfs_attribute *sbc_param_attrs[] = {
+	&attr_blkio_cgroup,
+	NULL,
+};
+EXPORT_SYMBOL(sbc_param_attrs);
 /*
  * Minimal dev_attrib attributes for devices passing through CDBs.
  * In this case we only provide a few read-only attributes for
@@ -1163,6 +1174,7 @@ struct configfs_attribute *passthrough_attrib_attrs[] = {
 EXPORT_SYMBOL(passthrough_attrib_attrs);
 
 TB_CIT_SETUP_DRV(dev_attrib, NULL, NULL);
+TB_CIT_SETUP_DRV(dev_param, NULL, NULL);
 
 /* End functions for struct config_item_type tb_dev_attrib_cit */
 
@@ -2923,6 +2935,10 @@ static struct config_group *target_core_make_subdev(
 			&tb->tb_dev_attrib_cit);
 	configfs_add_default_group(&dev->dev_attrib.da_group, &dev->dev_group);
 
+	config_group_init_type_name(&dev->dev_param.da_group, "param",
+			&tb->tb_dev_param_cit);
+	configfs_add_default_group(&dev->dev_param.da_group, &dev->dev_group);
+
 	config_group_init_type_name(&dev->dev_pr_group, "pr",
 			&tb->tb_dev_pr_cit);
 	configfs_add_default_group(&dev->dev_pr_group, &dev->dev_group);
@@ -3180,6 +3196,7 @@ void target_setup_backend_cits(struct target_backend *tb)
 {
 	target_core_setup_dev_cit(tb);
 	target_core_setup_dev_attrib_cit(tb);
+	target_core_setup_dev_param_cit(tb);
 	target_core_setup_dev_pr_cit(tb);
 	target_core_setup_dev_wwn_cit(tb);
 	target_core_setup_dev_alua_tg_pt_gps_cit(tb);
diff --git a/drivers/target/target_core_device.c b/drivers/target/target_core_device.c
index 28096d73b7ca..acafcb69a8bb 100644
--- a/drivers/target/target_core_device.c
+++ b/drivers/target/target_core_device.c
@@ -758,7 +758,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);
@@ -806,7 +806,10 @@ 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;
+	printk("%s:%d: %p\n", __func__, __LINE__, dev);
 
 	xcopy_lun = &dev->xcopy_lun;
 	rcu_assign_pointer(xcopy_lun->lun_se_dev, dev);
@@ -980,9 +983,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 266375ade594..e7042217cc9b 100644
--- a/drivers/target/target_core_iblock.c
+++ b/drivers/target/target_core_iblock.c
@@ -727,11 +727,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)
@@ -891,6 +891,7 @@ static const struct target_backend_ops iblock_ops = {
 	.get_io_opt		= iblock_get_io_opt,
 	.get_write_cache	= iblock_get_write_cache,
 	.tb_dev_attrib_attrs	= sbc_attrib_attrs,
+	.tb_dev_param_attrs	= sbc_param_attrs,
 };
 
 static int __init iblock_module_init(void)
diff --git a/drivers/target/target_core_internal.h b/drivers/target/target_core_internal.h
index 86b4a8375628..bf4b11d78520 100644
--- a/drivers/target/target_core_internal.h
+++ b/drivers/target/target_core_internal.h
@@ -11,6 +11,7 @@ struct target_backend {
 
 	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.h b/include/target/target_core_backend.h
index 90f4863d5b88..839a8dddb684 100644
--- a/include/target/target_core_backend.h
+++ b/include/target/target_core_backend.h
@@ -49,6 +49,7 @@ struct target_backend_ops {
 	void (*free_prot)(struct se_device *);
 
 	struct configfs_attribute **tb_dev_attrib_attrs;
+	struct configfs_attribute **tb_dev_param_attrs;
 };
 
 struct sbc_ops {
@@ -88,6 +89,7 @@ int	transport_set_vpd_ident_type(struct t10_vpd *, unsigned char *);
 int	transport_set_vpd_ident(struct t10_vpd *, unsigned char *);
 
 extern struct configfs_attribute *sbc_attrib_attrs[];
+extern struct configfs_attribute *sbc_param_attrs[];
 extern struct configfs_attribute *passthrough_attrib_attrs[];
 
 /* core helpers also used by command snooping in pscsi */
diff --git a/include/target/target_core_base.h b/include/target/target_core_base.h
index 047b75eea1f1..a1ff534c6976 100644
--- a/include/target/target_core_base.h
+++ b/include/target/target_core_base.h
@@ -696,7 +696,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 {
@@ -809,7 +814,7 @@ struct se_device {
 	atomic_t		dev_ordered_sync;
 	atomic_t		dev_qf_count;
 	u32			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;
@@ -843,6 +848,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;


More information about the Devel mailing list