Skip to contentSkip to conversation

target/configfs: add module wide action support

PATCH In review [email protected] 2 participants 5 messages Apr 19, 2018 – May 3, 2018 SCSI target

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/3 target/configfs: add module wide action support

From: Xiubo Li <[email protected]>

For some case we need some module wide configfs to contol some attributes of the whole transport module.

---
 drivers/target/target_core_configfs.c | 46 +++++++++++++++++++++++++++++++++++
 drivers/target/target_core_hba.c      | 11 +++++++++
 drivers/target/target_core_internal.h |  5 ++++
 include/target/target_core_backend.h  |  1 +
 4 files changed, 63 insertions(+)
drivers/target/target_core_configfs.c +46 -0
index 3f4bf12..a1ee716 100644
@@ -79,6 +79,7 @@
 static struct config_group target_core_hbagroup;
 static struct config_group alua_group;
 static struct config_group alua_lu_gps_group;
+static struct config_group action_group;
 
 static inline struct se_hba *
 item_to_hba(struct config_item *item)
@@ -1198,6 +1199,7 @@ struct configfs_attribute *passthrough_attrib_attrs[] = {
 
 TB_CIT_SETUP_DRV(dev_attrib, NULL, NULL);
 TB_CIT_SETUP_DRV(dev_action, NULL, NULL);
+TB_CIT_SETUP_DRV(mod_action, NULL, NULL);
 
 /* End functions for struct config_item_type tb_dev_attrib_cit */
 
@@ -2893,6 +2895,20 @@ static void target_core_alua_drop_tg_pt_gp(
 
 /* End functions for struct config_item_type target_core_alua_cit */
 
+/* Start functions for struct config_item_type target_core_action_cit */
+
+/*
+ * target_core_action_cit is a ConfigFS group that lives under
+ * /sys/kernel/config/target/core/action.
+ */
+static const struct config_item_type target_core_action_cit = {
+	.ct_item_ops		= NULL,
+	.ct_attrs		= NULL,
+	.ct_owner		= THIS_MODULE,
+};
+
+/* End functions for struct config_item_type target_core_action_cit */
+
 /* Start functions for struct config_item_type tb_dev_stat_cit */
 
 static struct config_group *target_core_stat_mkdir(
@@ -3211,6 +3227,30 @@ void target_setup_backend_cits(struct target_backend *tb)
 	target_core_setup_dev_wwn_cit(tb);
 	target_core_setup_dev_alua_tg_pt_gps_cit(tb);
 	target_core_setup_dev_stat_cit(tb);
+
+	target_core_setup_mod_action_cit(tb);
+}
+
+int target_setup_backend_action(struct target_backend *tb)
+{
+	if (!tb->ops->tb_mod_action_attrs)
+		return 0;
+
+	tb->action_group = configfs_register_default_group(&action_group,
+						tb->ops->name,
+						&tb->tb_mod_action_cit);
+	if (!tb->action_group)
+		return PTR_ERR(tb->action_group);
+
+	return 0;
+}
+
+void target_unset_backend_action(struct target_backend *tb)
+{
+	if (!tb->ops->tb_mod_action_attrs)
+		return;
+
+	configfs_unregister_default_group(tb->action_group);
 }
 
 static int __init target_core_init_configfs(void)
@@ -3267,6 +3307,12 @@ static int __init target_core_init_configfs(void)
 	default_lu_gp = lu_gp;
 
 	/*
+	 * Create ALUA infrastructure under /sys/kernel/config/target/core/action/
+	 */
+	config_group_init_type_name(&action_group, "action", &target_core_action_cit);
+	configfs_add_default_group(&action_group, &target_core_hbagroup);
+
+	/*
 	 * Register the target_core_mod subsystem with configfs.
 	 */
 	ret = configfs_register_subsystem(subsys);
drivers/target/target_core_hba.c +11 -0
index 22390e0..6903087 100644
@@ -51,6 +51,7 @@
 int transport_backend_register(const struct target_backend_ops *ops)
 {
 	struct target_backend *tb, *old;
+	int ret;
 
 	tb = kzalloc(sizeof(*tb), GFP_KERNEL);
 	if (!tb)
@@ -67,11 +68,20 @@ int transport_backend_register(const struct target_backend_ops *ops)
 		}
 	}
 	target_setup_backend_cits(tb);
+
+	ret = target_setup_backend_action(tb);
+	if (ret) {
+		mutex_unlock(&backend_mutex);
+		kfree(tb);
+		return ret;
+	}
+
 	list_add_tail(&tb->list, &backend_list);
 	mutex_unlock(&backend_mutex);
 
 	pr_debug("TCM: Registered subsystem plugin: %s struct module: %p\n",
 			ops->name, ops->owner);
+
 	return 0;
 }
 EXPORT_SYMBOL(transport_backend_register);
@@ -84,6 +94,7 @@ void target_backend_unregister(const struct target_backend_ops *ops)
 	list_for_each_entry(tb, &backend_list, list) {
 		if (tb->ops = ops) {
 			list_del(&tb->list);
+			target_unset_backend_action(tb);
 			mutex_unlock(&backend_mutex);
 			/*
 			 * Wait for any outstanding backend driver ->rcu_head
drivers/target/target_core_internal.h +5 -0
index 1d5afc3..73e8157 100644
@@ -22,6 +22,9 @@ struct target_backend {
 	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 config_group *action_group;
+	struct config_item_type tb_mod_action_cit;
 };
 
 struct target_fabric_configfs {
@@ -92,6 +95,8 @@ int	target_for_each_device(int (*fn)(struct se_device *dev, void *data),
 /* target_core_configfs.c */
 extern struct configfs_item_operations target_core_dev_item_ops;
 void	target_setup_backend_cits(struct target_backend *);
+int target_setup_backend_action(struct target_backend *tb);
+void target_unset_backend_action(struct target_backend *tb);
 
 /* target_core_fabric_configfs.c */
 int	target_fabric_setup_cits(struct target_fabric_configfs *);
include/target/target_core_backend.h +1 -0
index 34a15d5..5df7059 100644
@@ -54,6 +54,7 @@ struct target_backend_ops {
 
 	struct configfs_attribute **tb_dev_attrib_attrs;
 	struct configfs_attribute **tb_dev_action_attrs;
+	struct configfs_attribute **tb_mod_action_attrs;
 };
 
 struct sbc_ops {
Signature · 1 line
1.8.3.1
#1 lore raw
Quoted 4 lines · On 04/19/2018 02:46 AM, [email protected] wrote:

From: Xiubo Li <[email protected]>

For some case we need some module wide configfs to contol some attributes of the whole transport module.

When I suggested to move it module wide I just meant to add another mod param like the global max data area param. I like the approach below though, because rtslib can work similar to how it does for other objects. However for tcmu we will have a mix of types, so I am not sure how you are going to deal with compat. Maybe add a module level attrs attr and add a max data area there that calls the same mod param code. There would still be a kernel where it is not supported though.

Add some comments below if we go this route.

Quoted 51 lines
---
 drivers/target/target_core_configfs.c | 46 +++++++++++++++++++++++++++++++++++
 drivers/target/target_core_hba.c      | 11 +++++++++
 drivers/target/target_core_internal.h |  5 ++++
 include/target/target_core_backend.h  |  1 +
 4 files changed, 63 insertions(+)
drivers/target/target_core_configfs.c +16 -0
index 3f4bf12..a1ee716 100644
@@ -79,6 +79,7 @@
 static struct config_group target_core_hbagroup;
 static struct config_group alua_group;
 static struct config_group alua_lu_gps_group;
+static struct config_group action_group;
 
 static inline struct se_hba *
 item_to_hba(struct config_item *item)
@@ -1198,6 +1199,7 @@ struct configfs_attribute *passthrough_attrib_attrs[] = {
 
 TB_CIT_SETUP_DRV(dev_attrib, NULL, NULL);
 TB_CIT_SETUP_DRV(dev_action, NULL, NULL);
+TB_CIT_SETUP_DRV(mod_action, NULL, NULL);
 
 /* End functions for struct config_item_type tb_dev_attrib_cit */
 
@@ -2893,6 +2895,20 @@ static void target_core_alua_drop_tg_pt_gp(
 
 /* End functions for struct config_item_type target_core_alua_cit */
 
+/* Start functions for struct config_item_type target_core_action_cit */
+
+/*
+ * target_core_action_cit is a ConfigFS group that lives under
+ * /sys/kernel/config/target/core/action.
+ */
+static const struct config_item_type target_core_action_cit = {
+	.ct_item_ops		= NULL,
+	.ct_attrs		= NULL,
+	.ct_owner		= THIS_MODULE,
+};
+
+/* End functions for struct config_item_type target_core_action_cit */
+
 /* Start functions for struct config_item_type tb_dev_stat_cit */
 
 static struct config_group *target_core_stat_mkdir(

drivers/target/target_core_configfs.c void target_setup_backend_cits(struct target_backend *tb) · line 3234

Quoted 8 lines
drivers/target/target_core_configfs.c +5 -0
@@ -3211,6 +3227,30 @@ void target_setup_backend_cits(struct target_backend *tb)
 	target_core_setup_dev_wwn_cit(tb);
 	target_core_setup_dev_alua_tg_pt_gps_cit(tb);
 	target_core_setup_dev_stat_cit(tb);
+
+	target_core_setup_mod_action_cit(tb);
+}
+
+int target_setup_backend_action(struct target_backend *tb)

I think it might be best to rename these to:

target_register_backend_action_group
target_unregister_backend_action_group

It seems we are doing the setup and un/registration and unset is not a common name type in the existing code.

drivers/target/target_core_configfs.c void target_setup_backend_cits(struct target_backend *tb) · line 3242

Quoted 8 lines
drivers/target/target_core_configfs.c +8 -0
+{
+	if (!tb->ops->tb_mod_action_attrs)
+		return 0;
+
+	tb->action_group = configfs_register_default_group(&action_group,
+						tb->ops->name,
+						&tb->tb_mod_action_cit);
+	if (!tb->action_group)

I think you need to do

if (IS_ERR(tb->action_group))

Quoted 15 lines
drivers/target/target_core_configfs.c +11 -0
+		return PTR_ERR(tb->action_group);
+
+	return 0;
+}
+
+void target_unset_backend_action(struct target_backend *tb)
+{
+	if (!tb->ops->tb_mod_action_attrs)
+		return;
+
+	configfs_unregister_default_group(tb->action_group);
 }
 
 static int __init target_core_init_configfs(void)

drivers/target/target_core_configfs.c static int __init target_core_init_configfs(void) · line 3310

Quoted 4 lines
drivers/target/target_core_configfs.c +1 -0
@@ -3267,6 +3307,12 @@ static int __init target_core_init_configfs(void)
 	default_lu_gp = lu_gp;
 
 	/*
+	 * Create ALUA infrastructure under /sys/kernel/config/target/core/action/

Fix up the ALUA reference in the comment.

Quoted 21 lines
drivers/target/target_core_configfs.c +5 -0
+	 */
+	config_group_init_type_name(&action_group, "action", &target_core_action_cit);
+	configfs_add_default_group(&action_group, &target_core_hbagroup);
+
+	/*
 	 * Register the target_core_mod subsystem with configfs.
 	 */
 	ret = configfs_register_subsystem(subsys);
drivers/target/target_core_hba.c +1 -0
index 22390e0..6903087 100644
@@ -51,6 +51,7 @@
 int transport_backend_register(const struct target_backend_ops *ops)
 {
 	struct target_backend *tb, *old;
+	int ret;
 
 	tb = kzalloc(sizeof(*tb), GFP_KERNEL);
 	if (!tb)

drivers/target/target_core_hba.c int transport_backend_register(const struct target_backend_ops *ops) · line 75

Quoted 8 lines
drivers/target/target_core_hba.c +5 -0
@@ -67,11 +68,20 @@ int transport_backend_register(const struct target_backend_ops *ops)
 		}
 	}
 	target_setup_backend_cits(tb);
+
+	ret = target_setup_backend_action(tb);
+	if (ret) {
+		mutex_unlock(&backend_mutex);
+		kfree(tb);

Just do a goto since we have multiple places doing the same cleanup with this addition.

drivers/target/target_core_hba.c int transport_backend_register(const struct target_backend_ops *ops) · line 84

Quoted 9 lines
drivers/target/target_core_hba.c +4 -0
+		return ret;
+	}
+
 	list_add_tail(&tb->list, &backend_list);
 	mutex_unlock(&backend_mutex);
 
 	pr_debug("TCM: Registered subsystem plugin: %s struct module: %p\n",
 			ops->name, ops->owner);
+

Don't add extra formatting.

author
#2 lore raw
In reply to [email protected]
Quoted 5 lines · Mike Christie
Quoted 4 lines · On 04/19/2018 02:46 AM, [email protected] wrote:

From: Xiubo Li <[email protected]>

For some case we need some module wide configfs to contol some attributes of the whole transport module.

Quoted 7 lines

When I suggested to move it module wide I just meant to add another mod param like the global max data area param. I like the approach below though, because rtslib can work similar to how it does for other objects. However for tcmu we will have a mix of types, so I am not sure how you are going to deal with compat. Maybe add a module level attrs attr and add a max data area there that calls the same mod param code. There would still be a kernel where it is not supported though.

Hey Mike,

I just thought currently approach will be more flexible. Yeah,  for the compat issue it should be a little painful to deal with. It's up to you and I am okay for both approaches.

BRs
Thanks,

Quoted 153 lines

Add some comments below if we go this route.

Quoted 50 lines
---
  drivers/target/target_core_configfs.c | 46 +++++++++++++++++++++++++++++++++++
  drivers/target/target_core_hba.c      | 11 +++++++++
  drivers/target/target_core_internal.h |  5 ++++
  include/target/target_core_backend.h  |  1 +
  4 files changed, 63 insertions(+)
drivers/target/target_core_configfs.c +16 -0
index 3f4bf12..a1ee716 100644
@@ -79,6 +79,7 @@
  static struct config_group target_core_hbagroup;
  static struct config_group alua_group;
  static struct config_group alua_lu_gps_group;
+static struct config_group action_group;
 
  static inline struct se_hba *
  item_to_hba(struct config_item *item)
@@ -1198,6 +1199,7 @@ struct configfs_attribute *passthrough_attrib_attrs[] = {
 
  TB_CIT_SETUP_DRV(dev_attrib, NULL, NULL);
  TB_CIT_SETUP_DRV(dev_action, NULL, NULL);
+TB_CIT_SETUP_DRV(mod_action, NULL, NULL);
 
  /* End functions for struct config_item_type tb_dev_attrib_cit */
 
@@ -2893,6 +2895,20 @@ static void target_core_alua_drop_tg_pt_gp(
 
  /* End functions for struct config_item_type target_core_alua_cit */
 
+/* Start functions for struct config_item_type target_core_action_cit */
+
+/*
+ * target_core_action_cit is a ConfigFS group that lives under
+ * /sys/kernel/config/target/core/action.
+ */
+static const struct config_item_type target_core_action_cit = {
+	.ct_item_ops		= NULL,
+	.ct_attrs		= NULL,
+	.ct_owner		= THIS_MODULE,
+};
+
+/* End functions for struct config_item_type target_core_action_cit */
+
  /* Start functions for struct config_item_type tb_dev_stat_cit */
 
  static struct config_group *target_core_stat_mkdir(

drivers/target/target_core_configfs.c void target_setup_backend_cits(struct target_backend *tb) · line 3234

Quoted 8 lines
drivers/target/target_core_configfs.c +5 -0
@@ -3211,6 +3227,30 @@ void target_setup_backend_cits(struct target_backend *tb)
  	target_core_setup_dev_wwn_cit(tb);
  	target_core_setup_dev_alua_tg_pt_gps_cit(tb);
  	target_core_setup_dev_stat_cit(tb);
+
+	target_core_setup_mod_action_cit(tb);
+}
+
+int target_setup_backend_action(struct target_backend *tb)

I think it might be best to rename these to:

target_register_backend_action_group
target_unregister_backend_action_group

It seems we are doing the setup and un/registration and unset is not a common name type in the existing code.

drivers/target/target_core_configfs.c void target_setup_backend_cits(struct target_backend *tb) · line 3242

Quoted 8 lines
drivers/target/target_core_configfs.c +8 -0
+{
+	if (!tb->ops->tb_mod_action_attrs)
+		return 0;
+
+	tb->action_group = configfs_register_default_group(&action_group,
+						tb->ops->name,
+						&tb->tb_mod_action_cit);
+	if (!tb->action_group)

I think you need to do

if (IS_ERR(tb->action_group))

Quoted 15 lines
drivers/target/target_core_configfs.c +11 -0
+		return PTR_ERR(tb->action_group);
+
+	return 0;
+}
+
+void target_unset_backend_action(struct target_backend *tb)
+{
+	if (!tb->ops->tb_mod_action_attrs)
+		return;
+
+	configfs_unregister_default_group(tb->action_group);
  }
 
  static int __init target_core_init_configfs(void)

drivers/target/target_core_configfs.c static int __init target_core_init_configfs(void) · line 3310

Quoted 4 lines
drivers/target/target_core_configfs.c +1 -0
@@ -3267,6 +3307,12 @@ static int __init target_core_init_configfs(void)
  	default_lu_gp = lu_gp;
 
  	/*
+	 * Create ALUA infrastructure under /sys/kernel/config/target/core/action/

Fix up the ALUA reference in the comment.

Quoted 21 lines
drivers/target/target_core_configfs.c +5 -0
+	 */
+	config_group_init_type_name(&action_group, "action", &target_core_action_cit);
+	configfs_add_default_group(&action_group, &target_core_hbagroup);
+
+	/*
  	 * Register the target_core_mod subsystem with configfs.
  	 */
  	ret = configfs_register_subsystem(subsys);
drivers/target/target_core_hba.c +1 -0
index 22390e0..6903087 100644
@@ -51,6 +51,7 @@
  int transport_backend_register(const struct target_backend_ops *ops)
  {
  	struct target_backend *tb, *old;
+	int ret;
 
  	tb = kzalloc(sizeof(*tb), GFP_KERNEL);
  	if (!tb)

drivers/target/target_core_hba.c int transport_backend_register(const struct target_backend_ops *ops) · line 75

Quoted 8 lines
drivers/target/target_core_hba.c +5 -0
@@ -67,11 +68,20 @@ int transport_backend_register(const struct target_backend_ops *ops)
  		}
  	}
  	target_setup_backend_cits(tb);
+
+	ret = target_setup_backend_action(tb);
+	if (ret) {
+		mutex_unlock(&backend_mutex);
+		kfree(tb);

Just do a goto since we have multiple places doing the same cleanup with this addition.

drivers/target/target_core_hba.c int transport_backend_register(const struct target_backend_ops *ops) · line 84

Quoted 9 lines
drivers/target/target_core_hba.c +4 -0
+		return ret;
+	}
+
  	list_add_tail(&tb->list, &backend_list);
  	mutex_unlock(&backend_mutex);
 
  	pr_debug("TCM: Registered subsystem plugin: %s struct module: %p\n",
  			ops->name, ops->owner);
+

Don't add extra formatting.

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

author
#3 lore raw
In reply to [email protected]
Quoted 5 lines · Mike Christie
Quoted 4 lines · On 04/19/2018 02:46 AM, [email protected] wrote:

From: Xiubo Li <[email protected]>

For some case we need some module wide configfs to contol some attributes of the whole transport module.

Quoted 7 lines

When I suggested to move it module wide I just meant to add another mod param like the global max data area param. I like the approach below though, because rtslib can work similar to how it does for other objects. However for tcmu we will have a mix of types, so I am not sure how you are going to deal with compat. Maybe add a module level attrs attr and add a max data area there that calls the same mod param code. There would still be a kernel where it is not supported though.

But from currently after the tcmu-runner is crashed the target_core_user.ko will still be kept inserted, something like:

[root@gblock2 ~]# lsmod |grep target
target_core_pscsi      18799  0
target_core_file       18217  0
target_core_iblock     18282  0
iscsi_target_mod      291661  8
target_core_user       24557  2
target_core_mod       340729  18 target_core_iblock,target_core_pscsi,iscsi_target_mod,target_core_file,target_core_user uio                    19259  1 target_core_user
crc_t10dif             12912  2 target_core_mod,sd_mod

If make it a mod param, like this issue how could it be work when the tcmu-runner is crashed and try to start again?

BRs

Quoted 153 lines

Add some comments below if we go this route.

Quoted 50 lines
---
  drivers/target/target_core_configfs.c | 46 +++++++++++++++++++++++++++++++++++
  drivers/target/target_core_hba.c      | 11 +++++++++
  drivers/target/target_core_internal.h |  5 ++++
  include/target/target_core_backend.h  |  1 +
  4 files changed, 63 insertions(+)
drivers/target/target_core_configfs.c +16 -0
index 3f4bf12..a1ee716 100644
@@ -79,6 +79,7 @@
  static struct config_group target_core_hbagroup;
  static struct config_group alua_group;
  static struct config_group alua_lu_gps_group;
+static struct config_group action_group;
 
  static inline struct se_hba *
  item_to_hba(struct config_item *item)
@@ -1198,6 +1199,7 @@ struct configfs_attribute *passthrough_attrib_attrs[] = {
 
  TB_CIT_SETUP_DRV(dev_attrib, NULL, NULL);
  TB_CIT_SETUP_DRV(dev_action, NULL, NULL);
+TB_CIT_SETUP_DRV(mod_action, NULL, NULL);
 
  /* End functions for struct config_item_type tb_dev_attrib_cit */
 
@@ -2893,6 +2895,20 @@ static void target_core_alua_drop_tg_pt_gp(
 
  /* End functions for struct config_item_type target_core_alua_cit */
 
+/* Start functions for struct config_item_type target_core_action_cit */
+
+/*
+ * target_core_action_cit is a ConfigFS group that lives under
+ * /sys/kernel/config/target/core/action.
+ */
+static const struct config_item_type target_core_action_cit = {
+	.ct_item_ops		= NULL,
+	.ct_attrs		= NULL,
+	.ct_owner		= THIS_MODULE,
+};
+
+/* End functions for struct config_item_type target_core_action_cit */
+
  /* Start functions for struct config_item_type tb_dev_stat_cit */
 
  static struct config_group *target_core_stat_mkdir(

drivers/target/target_core_configfs.c void target_setup_backend_cits(struct target_backend *tb) · line 3234

Quoted 8 lines
drivers/target/target_core_configfs.c +5 -0
@@ -3211,6 +3227,30 @@ void target_setup_backend_cits(struct target_backend *tb)
  	target_core_setup_dev_wwn_cit(tb);
  	target_core_setup_dev_alua_tg_pt_gps_cit(tb);
  	target_core_setup_dev_stat_cit(tb);
+
+	target_core_setup_mod_action_cit(tb);
+}
+
+int target_setup_backend_action(struct target_backend *tb)

I think it might be best to rename these to:

target_register_backend_action_group
target_unregister_backend_action_group

It seems we are doing the setup and un/registration and unset is not a common name type in the existing code.

drivers/target/target_core_configfs.c void target_setup_backend_cits(struct target_backend *tb) · line 3242

Quoted 8 lines
drivers/target/target_core_configfs.c +8 -0
+{
+	if (!tb->ops->tb_mod_action_attrs)
+		return 0;
+
+	tb->action_group = configfs_register_default_group(&action_group,
+						tb->ops->name,
+						&tb->tb_mod_action_cit);
+	if (!tb->action_group)

I think you need to do

if (IS_ERR(tb->action_group))

Quoted 15 lines
drivers/target/target_core_configfs.c +11 -0
+		return PTR_ERR(tb->action_group);
+
+	return 0;
+}
+
+void target_unset_backend_action(struct target_backend *tb)
+{
+	if (!tb->ops->tb_mod_action_attrs)
+		return;
+
+	configfs_unregister_default_group(tb->action_group);
  }
 
  static int __init target_core_init_configfs(void)

drivers/target/target_core_configfs.c static int __init target_core_init_configfs(void) · line 3310

Quoted 4 lines
drivers/target/target_core_configfs.c +1 -0
@@ -3267,6 +3307,12 @@ static int __init target_core_init_configfs(void)
  	default_lu_gp = lu_gp;
 
  	/*
+	 * Create ALUA infrastructure under /sys/kernel/config/target/core/action/

Fix up the ALUA reference in the comment.

Quoted 21 lines
drivers/target/target_core_configfs.c +5 -0
+	 */
+	config_group_init_type_name(&action_group, "action", &target_core_action_cit);
+	configfs_add_default_group(&action_group, &target_core_hbagroup);
+
+	/*
  	 * Register the target_core_mod subsystem with configfs.
  	 */
  	ret = configfs_register_subsystem(subsys);
drivers/target/target_core_hba.c +1 -0
index 22390e0..6903087 100644
@@ -51,6 +51,7 @@
  int transport_backend_register(const struct target_backend_ops *ops)
  {
  	struct target_backend *tb, *old;
+	int ret;
 
  	tb = kzalloc(sizeof(*tb), GFP_KERNEL);
  	if (!tb)

drivers/target/target_core_hba.c int transport_backend_register(const struct target_backend_ops *ops) · line 75

Quoted 8 lines
drivers/target/target_core_hba.c +5 -0
@@ -67,11 +68,20 @@ int transport_backend_register(const struct target_backend_ops *ops)
  		}
  	}
  	target_setup_backend_cits(tb);
+
+	ret = target_setup_backend_action(tb);
+	if (ret) {
+		mutex_unlock(&backend_mutex);
+		kfree(tb);

Just do a goto since we have multiple places doing the same cleanup with this addition.

drivers/target/target_core_hba.c int transport_backend_register(const struct target_backend_ops *ops) · line 84

Quoted 9 lines
drivers/target/target_core_hba.c +4 -0
+		return ret;
+	}
+
  	list_add_tail(&tb->list, &backend_list);
  	mutex_unlock(&backend_mutex);
 
  	pr_debug("TCM: Registered subsystem plugin: %s struct module: %p\n",
  			ops->name, ops->owner);
+

Don't add extra formatting.

--
To unsubscribe from this list: send the line "unsubscribe target-devel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#4 lore raw
In reply to [email protected]
Quoted 23 lines · Xiubo Li
Quoted 5 lines · Mike Christie
Quoted 4 lines · On 04/19/2018 02:46 AM, [email protected] wrote:

From: Xiubo Li <[email protected]>

For some case we need some module wide configfs to contol some attributes of the whole transport module.

Quoted 7 lines

When I suggested to move it module wide I just meant to add another mod param like the global max data area param. I like the approach below though, because rtslib can work similar to how it does for other objects. However for tcmu we will have a mix of types, so I am not sure how you are going to deal with compat. Maybe add a module level attrs attr and add a max data area there that calls the same mod param code. There would still be a kernel where it is not supported though.

But from currently after the tcmu-runner is crashed the target_core_user.ko will still be kept inserted, something like:

[root@gblock2 ~]# lsmod |grep target

target_core_pscsi      18799  0
target_core_file       18217  0
target_core_iblock     18282  0
iscsi_target_mod      291661  8
target_core_user       24557  2
target_core_mod       340729  18
Quoted 7 lines

target_core_iblock,target_core_pscsi,iscsi_target_mod,target_core_file,target_core_user

uio                    19259  1 target_core_user
crc_t10dif             12912  2 target_core_mod,sd_mod

If make it a mod param, like this issue how could it be work when the tcmu-runner is crashed and try to start again?

When you do a module_param_cb it creates a sysfs file in /sys/module/target_core_user/parameters that you can read/write to like any other sysfs file.