[Ocfs2-tools-devel] [PATCH 04/32] o2cb_config: Add o2cb_cluster_delete_node()

Sunil Mushran sunil.mushran at oracle.com
Tue Sep 14 15:54:34 PDT 2010


o2cb_cluster_delete_node() added to allow removal of a node from the config.

Signed-off-by: Sunil Mushran <sunil.mushran at oracle.com>
---
 o2cb_ctl/o2cb_config.c |   18 +++++++++++++++++-
 o2cb_ctl/o2cb_config.h |    2 +-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/o2cb_ctl/o2cb_config.c b/o2cb_ctl/o2cb_config.c
index 3dae2f3..0018f46 100644
--- a/o2cb_ctl/o2cb_config.c
+++ b/o2cb_ctl/o2cb_config.c
@@ -881,8 +881,24 @@ O2CBNode *o2cb_cluster_add_node(O2CBCluster *cluster,
     return node;
 }  /* o2cb_cluster_add_node() */
 
-void o2cb_cluster_delete_node(O2CBCluster *cluster, O2CBNode *node)
+gint o2cb_cluster_delete_node(O2CBCluster *cluster, const gchar *name)
 {
+    O2CBNode *node;
+    g_return_val_if_fail(cluster != NULL, -1);
+    g_return_val_if_fail(name != NULL, -1);
+
+    node = o2cb_cluster_get_node_by_name(cluster, name);
+    if (!node)
+        return -ENOENT;
+
+    cluster->c_nodes = g_list_remove(cluster->c_nodes, node);
+    cluster->c_num_nodes--;
+    g_free(node->n_name);
+    g_free(node->n_addr);
+    g_free(node);
+
+    return 0;
+
 }  /* o2cb_cluster_delete_node() */
 
 gint o2cb_node_get_number(O2CBNode *node)
diff --git a/o2cb_ctl/o2cb_config.h b/o2cb_ctl/o2cb_config.h
index 4b040e1..6041bd5 100644
--- a/o2cb_ctl/o2cb_config.h
+++ b/o2cb_ctl/o2cb_config.h
@@ -63,7 +63,7 @@ O2CBNode *o2cb_cluster_get_node_by_name(O2CBCluster *cluster,
                                         const gchar *name);
 O2CBNode *o2cb_cluster_add_node(O2CBCluster *cluster,
                                 const gchar *name);
-void o2cb_cluster_delete_node(O2CBCluster *cluster, O2CBNode *node);
+gint o2cb_cluster_delete_node(O2CBCluster *cluster, const gchar *name);
 
 gint o2cb_node_get_number(O2CBNode *node);
 gchar *o2cb_node_get_name(O2CBNode *node);
-- 
1.7.0.4




More information about the Ocfs2-tools-devel mailing list