Re: [PATCH 1/5] target: remove tf_subsystem pointers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 5/3/2015 9:50 AM, Christoph Hellwig wrote:
There is just one configfs subsystem in the target code, so we might as
well add two helpers to reference / unreference it from the core code
instead of passing pointers to it around.

Signed-off-by: Christoph Hellwig <hch@xxxxxx>
---
  drivers/scsi/qla2xxx/tcm_qla2xxx.c    |  6 ++----
  drivers/target/target_core_configfs.c | 30 ++++++++++++++----------------
  drivers/target/target_core_internal.h |  3 ---
  drivers/target/target_core_pr.c       | 32 +++++++-------------------------
  drivers/target/target_core_xcopy.c    | 15 ++++++---------
  drivers/vhost/scsi.c                  |  6 ++----
  include/target/target_core_configfs.h |  2 --
  include/target/target_core_fabric.h   |  4 +++-
  8 files changed, 34 insertions(+), 64 deletions(-)

diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
index af81b55..8e33122 100644
--- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c
+++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c
@@ -862,8 +862,7 @@ static void tcm_qla2xxx_depend_tpg(struct work_struct *work)
  	struct se_portal_group *se_tpg = &base_tpg->se_tpg;
  	struct scsi_qla_host *base_vha = base_tpg->lport->qla_vha;

-	if (!configfs_depend_item(se_tpg->se_tpg_tfo->tf_subsys,
-				  &se_tpg->tpg_group.cg_item)) {
+	if (!target_depend_item(&se_tpg->tpg_group.cg_item)) {
  		atomic_set(&base_tpg->lport_tpg_enabled, 1);
  		qlt_enable_vha(base_vha);
  	}
@@ -879,8 +878,7 @@ static void tcm_qla2xxx_undepend_tpg(struct work_struct *work)

  	if (!qlt_stop_phase1(base_vha->vha_tgt.qla_tgt)) {
  		atomic_set(&base_tpg->lport_tpg_enabled, 0);
-		configfs_undepend_item(se_tpg->se_tpg_tfo->tf_subsys,
-				       &se_tpg->tpg_group.cg_item);
+		target_undepend_item(&se_tpg->tpg_group.cg_item);
  	}
  	complete(&base_tpg->tpg_base_comp);
  }
diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index f4cb143..7f612dc 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -212,10 +212,6 @@ static struct config_group *target_core_register_fabric(

  	pr_debug("Target_Core_ConfigFS: REGISTER -> Allocated Fabric:"
  			" %s\n", tf->tf_group.cg_item.ci_name);
-	/*
-	 * Setup tf_ops.tf_subsys pointer for usage with configfs_depend_item()
-	 */
-	tf->tf_ops.tf_subsys = tf->tf_subsys;
  	tf->tf_fabric = &tf->tf_group.cg_item;
  	pr_debug("Target_Core_ConfigFS: REGISTER -> Set tf->tf_fabric"
  			" for %s\n", name);
@@ -291,10 +287,17 @@ static struct configfs_subsystem target_core_fabrics = {
  	},
  };

-struct configfs_subsystem *target_core_subsystem[] = {
-	&target_core_fabrics,
-	NULL,
-};
+int target_depend_item(struct config_item *item)
+{
+	return configfs_depend_item(&target_core_fabrics, item);
+}
+EXPORT_SYMBOL(target_depend_item);
+
+void target_undepend_item(struct config_item *item)
+{
+	return configfs_undepend_item(&target_core_fabrics, item);
+}
+EXPORT_SYMBOL(target_undepend_item);

  /*##############################################################################
  // Start functions called by external Target Fabrics Modules
@@ -439,7 +442,6 @@ int target_register_template(const struct target_core_fabric_ops *fo)
  	 * struct target_fabric_configfs->tf_cit_tmpl
  	 */
  	tf->tf_module = fo->module;
-	tf->tf_subsys = target_core_subsystem[0];
  	snprintf(tf->tf_name, TARGET_FABRIC_NAME_SIZE, "%s", fo->name);

  	tf->tf_ops = *fo;
@@ -2840,7 +2842,7 @@ static int __init target_core_init_configfs(void)
  {
  	struct config_group *target_cg, *hba_cg = NULL, *alua_cg = NULL;
  	struct config_group *lu_gp_cg = NULL;
-	struct configfs_subsystem *subsys;
+	struct configfs_subsystem *subsys = &target_core_fabrics;
  	struct t10_alua_lu_gp *lu_gp;
  	int ret;

@@ -2848,7 +2850,6 @@ static int __init target_core_init_configfs(void)
  		" Engine: %s on %s/%s on "UTS_RELEASE"\n",
  		TARGET_CORE_VERSION, utsname()->sysname, utsname()->machine);

-	subsys = target_core_subsystem[0];
  	config_group_init(&subsys->su_group);
  	mutex_init(&subsys->su_mutex);

@@ -2978,13 +2979,10 @@ out_global:

  static void __exit target_core_exit_configfs(void)
  {
-	struct configfs_subsystem *subsys;
  	struct config_group *hba_cg, *alua_cg, *lu_gp_cg;
  	struct config_item *item;
  	int i;

-	subsys = target_core_subsystem[0];
-
  	lu_gp_cg = &alua_lu_gps_group;
  	for (i = 0; lu_gp_cg->default_groups[i]; i++) {
  		item = &lu_gp_cg->default_groups[i]->cg_item;
@@ -3015,8 +3013,8 @@ static void __exit target_core_exit_configfs(void)
  	 * We expect subsys->su_group.default_groups to be released
  	 * by configfs subsystem provider logic..
  	 */
-	configfs_unregister_subsystem(subsys);
-	kfree(subsys->su_group.default_groups);
+	configfs_unregister_subsystem(&target_core_fabrics);
+	kfree(&target_core_fabrics.su_group.default_groups);

There is an extra & here that causes a crash on a bogus free.

Nic, can you fold this in?

diff --git a/drivers/target/target_core_configfs.c b/drivers/target/target_core_configfs.c
index a6c809c..2768221 100644
--- a/drivers/target/target_core_configfs.c
+++ b/drivers/target/target_core_configfs.c
@@ -2997,7 +2997,7 @@ static void __exit target_core_exit_configfs(void)
         * by configfs subsystem provider logic..
         */
        configfs_unregister_subsystem(&target_core_fabrics);
-       kfree(&target_core_fabrics.su_group.default_groups);
+       kfree(target_core_fabrics.su_group.default_groups);

        core_alua_free_lu_gp(default_lu_gp);
        default_lu_gp = NULL;
--
To unsubscribe from this list: send the line "unsubscribe target-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux SCSI]     [Kernel Newbies]     [Linux SCSI Target Infrastructure]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Linux IIO]     [Device Mapper]

  Powered by Linux