vacuum: reorder some of ctdb_process_delete_list() more intuitively
authorMichael Adam <obnox@samba.org>
Sat, 29 Dec 2012 17:32:39 +0000 (18:32 +0100)
committerMichael Adam <obnox@samba.org>
Fri, 26 Apr 2013 14:18:17 +0000 (16:18 +0200)
Now that the nodemap and its talloc children don't hang off of the
delete_records_list talloc context, we can build the nodemap
and earlier, and move the construction of the delete_records_list
to where it is more obvious what it is used for.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-By: Amitay Isaacs <amitay@gmail.com>
(cherry picked from commit e3740899c1af6962f93c85ad7d1cb71bddce45c6)

server/ctdb_vacuum.c

index dc1afc3afb0ae57ee67e4580963bd1f48e51cb40..c6858909469b039cab0aaad46e3557bfeac2d22f 100644 (file)
@@ -722,6 +722,27 @@ static int ctdb_process_delete_list(struct ctdb_db_context *ctdb_db,
 
        vdata->delete_left = vdata->delete_count;
 
+       /*
+        * now tell all the active nodes to delete all these records
+        * (if possible)
+        */
+
+       ret = ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(),
+                                  CTDB_CURRENT_NODE,
+                                  tmp_ctx,
+                                  &nodemap);
+       if (ret != 0) {
+               DEBUG(DEBUG_ERR,(__location__ " unable to get node map\n"));
+               ret = -1;
+               goto done;
+       }
+
+       active_nodes = list_of_active_nodes(ctdb, nodemap,
+                                           nodemap, /* talloc context */
+                                           false /* include self */);
+       /* yuck! ;-) */
+       num_active_nodes = talloc_get_size(active_nodes)/sizeof(*active_nodes);
+
        recs = talloc_zero(tmp_ctx, struct delete_records_list);
        if (recs == NULL) {
                DEBUG(DEBUG_ERR,(__location__ " Out of memory\n"));
@@ -748,27 +769,6 @@ static int ctdb_process_delete_list(struct ctdb_db_context *ctdb_db,
        indata.dsize = talloc_get_size(recs->records);
        indata.dptr  = (void *)recs->records;
 
-       /*
-        * now tell all the active nodes to delete all these records
-        * (if possible)
-        */
-
-       ret = ctdb_ctrl_getnodemap(ctdb, TIMELIMIT(),
-                                  CTDB_CURRENT_NODE,
-                                  tmp_ctx,
-                                  &nodemap);
-       if (ret != 0) {
-               DEBUG(DEBUG_ERR,(__location__ " unable to get node map\n"));
-               ret = -1;
-               goto done;
-       }
-
-       active_nodes = list_of_active_nodes(ctdb, nodemap,
-                                           nodemap, /* talloc context */
-                                           false /* include self */);
-       /* yuck! ;-) */
-       num_active_nodes = talloc_get_size(active_nodes)/sizeof(*active_nodes);
-
        for (i = 0; i < num_active_nodes; i++) {
                struct ctdb_marshall_buffer *records;
                struct ctdb_rec_data *rec;