target: add a new add_wwn_groups fabrics method
authorChristoph Hellwig <hch@lst.de>
Tue, 29 Mar 2016 11:03:35 +0000 (13:03 +0200)
committerNicholas Bellinger <nab@linux-iscsi.org>
Thu, 31 Mar 2016 03:06:44 +0000 (20:06 -0700)
We need to have the WWN fully initialized before addig default groups to it,
so add a new method to add these groups after the WWN has been initialized.
Also remove the default groups in the core while we're at it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
drivers/target/iscsi/iscsi_target_configfs.c
drivers/target/target_core_fabric_configfs.c
include/target/target_core_fabric.h

index 3c05d1e97f8fb75724b7279ce595a4030f9ec78f..97e5b69e066852b1ae1eefd20161fde13c44d352 100644 (file)
@@ -1239,6 +1239,16 @@ static struct se_wwn *lio_target_call_coreaddtiqn(
        if (IS_ERR(tiqn))
                return ERR_CAST(tiqn);
 
+       pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn->tiqn);
+       pr_debug("LIO_Target_ConfigFS: REGISTER -> Allocated Node:"
+                       " %s\n", name);
+       return &tiqn->tiqn_wwn;
+}
+
+static void lio_target_add_wwn_groups(struct se_wwn *wwn)
+{
+       struct iscsi_tiqn *tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn);
+
        config_group_init_type_name(&tiqn->tiqn_stat_grps.iscsi_instance_group,
                        "iscsi_instance", &iscsi_stat_instance_cit);
        configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_instance_group,
@@ -1263,12 +1273,6 @@ static struct se_wwn *lio_target_call_coreaddtiqn(
                        "iscsi_logout_stats", &iscsi_stat_logout_cit);
        configfs_add_default_group(&tiqn->tiqn_stat_grps.iscsi_logout_stats_group,
                        &tiqn->tiqn_wwn.fabric_stat_group);
-
-
-       pr_debug("LIO_Target_ConfigFS: REGISTER -> %s\n", tiqn->tiqn);
-       pr_debug("LIO_Target_ConfigFS: REGISTER -> Allocated Node:"
-                       " %s\n", name);
-       return &tiqn->tiqn_wwn;
 }
 
 static void lio_target_call_coredeltiqn(
@@ -1276,8 +1280,6 @@ static void lio_target_call_coredeltiqn(
 {
        struct iscsi_tiqn *tiqn = container_of(wwn, struct iscsi_tiqn, tiqn_wwn);
 
-       configfs_remove_default_groups(&tiqn->tiqn_wwn.fabric_stat_group);
-
        pr_debug("LIO_Target_ConfigFS: DEREGISTER -> %s\n",
                        tiqn->tiqn);
        iscsit_del_tiqn(tiqn);
@@ -1652,6 +1654,7 @@ const struct target_core_fabric_ops iscsi_ops = {
        .aborted_task                   = lio_aborted_task,
        .fabric_make_wwn                = lio_target_call_coreaddtiqn,
        .fabric_drop_wwn                = lio_target_call_coredeltiqn,
+       .add_wwn_groups                 = lio_target_add_wwn_groups,
        .fabric_make_tpg                = lio_target_tiqn_addtpg,
        .fabric_drop_tpg                = lio_target_tiqn_deltpg,
        .fabric_make_np                 = lio_target_call_addnptotpg,
index 5991a4f816d8c98df594d017aa8a2fd7689223a8..31a096aa16aba6dc4239cd412f813709709723f8 100644 (file)
@@ -891,6 +891,7 @@ static void target_fabric_release_wwn(struct config_item *item)
                                struct se_wwn, wwn_group);
        struct target_fabric_configfs *tf = wwn->wwn_tf;
 
+       configfs_remove_default_groups(&wwn->fabric_stat_group);
        tf->tf_ops->fabric_drop_wwn(wwn);
 }
 
@@ -944,6 +945,8 @@ static struct config_group *target_fabric_make_wwn(
                        &tf->tf_wwn_fabric_stats_cit);
        configfs_add_default_group(&wwn->fabric_stat_group, &wwn->wwn_group);
 
+       if (tf->tf_ops->add_wwn_groups)
+               tf->tf_ops->add_wwn_groups(wwn);
        return &wwn->wwn_group;
 }
 
index 5a9dd1892b703371261142bc29362420f309d7a8..8ff6d40a294fd5a1fcbd8f10d0139d289c00d741 100644 (file)
@@ -76,6 +76,7 @@ struct target_core_fabric_ops {
        struct se_wwn *(*fabric_make_wwn)(struct target_fabric_configfs *,
                                struct config_group *, const char *);
        void (*fabric_drop_wwn)(struct se_wwn *);
+       void (*add_wwn_groups)(struct se_wwn *);
        struct se_portal_group *(*fabric_make_tpg)(struct se_wwn *,
                                struct config_group *, const char *);
        void (*fabric_drop_tpg)(struct se_portal_group *);
This page took 0.027542 seconds and 5 git commands to generate.