vacuum: factor out full vacuum run out of ctdb_vacuum_db() as ctdb_vacuum_db_full()
authorMichael Adam <obnox@samba.org>
Fri, 16 Dec 2011 10:04:13 +0000 (11:04 +0100)
committerMichael Adam <obnox@samba.org>
Fri, 23 Dec 2011 16:39:07 +0000 (17:39 +0100)
(This used to be ctdb commit e31594e0c13899e88013ce7eb7e3dc434c2f0723)

ctdb/server/ctdb_vacuum.c

index fe01f57621a3c69f5e26974e642ea8d1ab40558a..9c7edb3b4f2121aba64def1ba2a763558252cee5 100644 (file)
@@ -568,6 +568,52 @@ static void ctdb_vacuum_db_fast(struct ctdb_db_context *ctdb_db,
        return;
 }
 
+/**
+ * Full vacuum run:
+ * read-only traverse of the database, looking for records that
+ * might be able to be vacuumed.
+ *
+ * This is not done each time but only every tunable
+ * VacuumFastPathCount times.
+ */
+static int ctdb_vacuum_db_full(struct ctdb_db_context *ctdb_db,
+                              struct vacuum_data *vdata,
+                              bool full_vacuum_run)
+{
+       int ret;
+
+       if (!full_vacuum_run) {
+               return 0;
+       }
+
+       ret = tdb_traverse_read(ctdb_db->ltdb->tdb, vacuum_traverse, vdata);
+       if (ret == -1 || vdata->traverse_error) {
+               DEBUG(DEBUG_ERR, (__location__ " Traverse error in vacuuming "
+                                 "'%s'\n", ctdb_db->db_name));
+               return -1;
+       }
+
+       if (vdata->full_total > 0) {
+               DEBUG(DEBUG_INFO,
+                     (__location__
+                      " full vacuuming db traverse statistics: "
+                      "db[%s] "
+                      "total[%u] "
+                      "skp[%u] "
+                      "err[%u] "
+                      "adl[%u] "
+                      "avf[%u]\n",
+                      ctdb_db->db_name,
+                      (unsigned)vdata->full_total,
+                      (unsigned)vdata->full_skipped,
+                      (unsigned)vdata->full_error,
+                      (unsigned)vdata->full_added_to_delete_list,
+                      (unsigned)vdata->full_added_to_vacuum_fetch_list));
+       }
+
+       return 0;
+}
+
 /**
  * Vacuum a DB:
  *  - Always do the fast vacuuming run, which traverses
@@ -666,36 +712,9 @@ static int ctdb_vacuum_db(struct ctdb_db_context *ctdb_db,
 
        ctdb_vacuum_db_fast(ctdb_db, vdata);
 
-       /*
-        * read-only traverse of the database, looking for records that
-        * might be able to be vacuumed.
-        *
-        * This is not done each time but only every tunable
-        * VacuumFastPathCount times.
-        */
-       if (full_vacuum_run) {
-               ret = tdb_traverse_read(ctdb_db->ltdb->tdb, vacuum_traverse, vdata);
-               if (ret == -1 || vdata->traverse_error) {
-                       DEBUG(DEBUG_ERR,(__location__ " Traverse error in vacuuming '%s'\n", name));
-                       return -1;
-               }
-               if (vdata->full_total > 0) {
-                       DEBUG(DEBUG_INFO,
-                             (__location__
-                              " full vacuuming db traverse statistics: "
-                              "db[%s] "
-                              "total[%u] "
-                              "skp[%u] "
-                              "err[%u] "
-                              "adl[%u] "
-                              "avf[%u]\n",
-                              ctdb_db->db_name,
-                              (unsigned)vdata->full_total,
-                              (unsigned)vdata->full_skipped,
-                              (unsigned)vdata->full_error,
-                              (unsigned)vdata->full_added_to_delete_list,
-                              (unsigned)vdata->full_added_to_vacuum_fetch_list));
-               }
+       ret = ctdb_vacuum_db_full(ctdb_db, vdata, full_vacuum_run);
+       if (ret != 0) {
+               return ret;
        }
 
        /*