When compacting the database by writing the transaction history as a
single initial data point previously the names "snapshot" and "compact"
where used interchangably. While they currently share the same
implementation, these will diverge in the future.
"snapshot" will mean to replace the whole database with some arbitrary
new data. "compact" will mean to take a part of the history and replace
it with a single data point.

Since we are doing the second option here it should be named
appropriately.

Signed-off-by: Felix Huettner <felix.huettner@stackit.cloud>
---
 ovsdb/ovsdb-server.c | 20 ++++++++++----------
 ovsdb/ovsdb.c        | 42 +++++++++++++++++++++---------------------
 ovsdb/ovsdb.h        | 10 +++++-----
 ovsdb/storage.c      |  2 +-
 ovsdb/storage.h      |  2 +-
 5 files changed, 38 insertions(+), 38 deletions(-)

diff --git a/ovsdb/ovsdb-server.c b/ovsdb/ovsdb-server.c
index 5303a46c6..32aab6aae 100644
--- a/ovsdb/ovsdb-server.c
+++ b/ovsdb/ovsdb-server.c
@@ -354,10 +354,10 @@ main_loop(struct server_config *config,
                 remove_db(config, node,
                           xasprintf("removing database %s because storage "
                                     "disconnected permanently", node->name));
-            } else if (!ovsdb_snapshot_in_progress(db->db)
-                       && (ovsdb_storage_should_snapshot(db->db->storage) ||
-                           ovsdb_snapshot_ready(db->db))) {
-                log_and_free_error(ovsdb_snapshot(db->db, trim_memory));
+            } else if (!ovsdb_compcation_in_progress(db->db)
+                       && (ovsdb_storage_should_compact(db->db->storage) ||
+                           ovsdb_compaction_ready(db->db))) {
+                log_and_free_error(ovsdb_compact(db->db, trim_memory));
             }
         }
         if (run_process) {
@@ -389,7 +389,7 @@ main_loop(struct server_config *config,
             ovsdb_trigger_wait(db->db, time_msec());
             ovsdb_storage_wait(db->db->storage);
             ovsdb_storage_read_wait(db->db->storage);
-            ovsdb_snapshot_wait(db->db);
+            ovsdb_compaction_wait(db->db);
         }
         if (run_process) {
             process_wait(run_process);
@@ -2168,13 +2168,13 @@ ovsdb_server_compact(struct unixctl_conn *conn, int 
argc,
                 VLOG_INFO("compacting %s database by user request",
                           node->name);
 
-                error = ovsdb_snapshot(db->db, trim_memory);
-                if (!error && ovsdb_snapshot_in_progress(db->db)) {
-                    while (ovsdb_snapshot_in_progress(db->db)) {
-                        ovsdb_snapshot_wait(db->db);
+                error = ovsdb_compact(db->db, trim_memory);
+                if (!error && ovsdb_compcation_in_progress(db->db)) {
+                    while (ovsdb_compcation_in_progress(db->db)) {
+                        ovsdb_compaction_wait(db->db);
                         poll_block();
                     }
-                    error = ovsdb_snapshot(db->db, trim_memory);
+                    error = ovsdb_compact(db->db, trim_memory);
                 }
 
                 if (error) {
diff --git a/ovsdb/ovsdb.c b/ovsdb/ovsdb.c
index 298616a64..7336f500c 100644
--- a/ovsdb/ovsdb.c
+++ b/ovsdb/ovsdb.c
@@ -504,12 +504,12 @@ ovsdb_destroy(struct ovsdb *db)
         struct shash_node *node;
 
         /* Need to wait for compaction thread to finish the work. */
-        while (ovsdb_snapshot_in_progress(db)) {
-            ovsdb_snapshot_wait(db);
+        while (ovsdb_compcation_in_progress(db)) {
+            ovsdb_compaction_wait(db);
             poll_block();
         }
-        if (ovsdb_snapshot_ready(db)) {
-            struct ovsdb_error *error = ovsdb_snapshot(db, false);
+        if (ovsdb_compaction_ready(db)) {
+            struct ovsdb_error *error = ovsdb_compact(db, false);
 
             if (error) {
                 char *s = ovsdb_error_to_string_free(error);
@@ -640,31 +640,31 @@ compaction_thread(void *aux)
 }
 
 void
-ovsdb_snapshot_wait(struct ovsdb *db)
+ovsdb_compaction_wait(struct ovsdb *db)
 {
-    if (db->snap_state) {
-        seq_wait(db->snap_state->done, db->snap_state->seqno);
+    if (db->compact_state) {
+        seq_wait(db->compact_state->done, db->compact_state->seqno);
     }
 }
 
 bool
-ovsdb_snapshot_in_progress(struct ovsdb *db)
+ovsdb_compcation_in_progress(struct ovsdb *db)
 {
-    return db->snap_state &&
-           seq_read(db->snap_state->done) == db->snap_state->seqno;
+    return db->compact_state &&
+           seq_read(db->compact_state->done) == db->compact_state->seqno;
 }
 
 bool
-ovsdb_snapshot_ready(struct ovsdb *db)
+ovsdb_compaction_ready(struct ovsdb *db)
 {
-    return db->snap_state &&
-           seq_read(db->snap_state->done) != db->snap_state->seqno;
+    return db->compact_state &&
+           seq_read(db->compact_state->done) != db->compact_state->seqno;
 }
 
 struct ovsdb_error * OVS_WARN_UNUSED_RESULT
-ovsdb_snapshot(struct ovsdb *db, bool trim_memory OVS_UNUSED)
+ovsdb_compact(struct ovsdb *db, bool trim_memory OVS_UNUSED)
 {
-    if (!db->storage || ovsdb_snapshot_in_progress(db)) {
+    if (!db->storage || ovsdb_compcation_in_progress(db)) {
         return NULL;
     }
 
@@ -678,17 +678,17 @@ ovsdb_snapshot(struct ovsdb *db, bool trim_memory 
OVS_UNUSED)
         state->data = ovsdb_to_txn_json(db,
                                         "compacting database online", true);
         state->schema = ovsdb_schema_to_json(db->schema);
-    } else if (ovsdb_snapshot_ready(db)) {
-        xpthread_join(db->snap_state->thread, NULL);
+    } else if (ovsdb_compaction_ready(db)) {
+        xpthread_join(db->compact_state->thread, NULL);
 
-        state = db->snap_state;
-        db->snap_state = NULL;
+        state = db->compact_state;
+        db->compact_state = NULL;
 
         ovsdb_destroy(state->db);
         seq_destroy(state->done);
     } else {
         /* Creating a thread. */
-        ovs_assert(!db->snap_state);
+        ovs_assert(!db->compact_state);
         state = xzalloc(sizeof *state);
 
         state->db = ovsdb_clone_data(db);
@@ -700,7 +700,7 @@ ovsdb_snapshot(struct ovsdb *db, bool trim_memory 
OVS_UNUSED)
                                           compaction_thread, state);
         state->init_time = time_msec() - start_time;
 
-        db->snap_state = state;
+        db->compact_state = state;
         return NULL;
     }
 
diff --git a/ovsdb/ovsdb.h b/ovsdb/ovsdb.h
index 325900bc6..6e08a679b 100644
--- a/ovsdb/ovsdb.h
+++ b/ovsdb/ovsdb.h
@@ -125,7 +125,7 @@ struct ovsdb {
     struct hmap txn_forward_sent;
 
     /* Database compaction. */
-    struct ovsdb_compaction_state *snap_state;
+    struct ovsdb_compaction_state *compact_state;
 };
 
 /* Total number of 'weak reference' objects in all databases
@@ -154,11 +154,11 @@ struct json *ovsdb_execute(struct ovsdb *, const struct 
ovsdb_session *,
                            long long int elapsed_msec,
                            long long int *timeout_msec);
 
-struct ovsdb_error *ovsdb_snapshot(struct ovsdb *, bool trim_memory)
+struct ovsdb_error *ovsdb_compact(struct ovsdb *, bool trim_memory)
     OVS_WARN_UNUSED_RESULT;
-void ovsdb_snapshot_wait(struct ovsdb *);
-bool ovsdb_snapshot_in_progress(struct ovsdb *);
-bool ovsdb_snapshot_ready(struct ovsdb *);
+void ovsdb_compaction_wait(struct ovsdb *);
+bool ovsdb_compcation_in_progress(struct ovsdb *);
+bool ovsdb_compaction_ready(struct ovsdb *);
 
 void ovsdb_replace(struct ovsdb *dst, struct ovsdb *src);
 
diff --git a/ovsdb/storage.c b/ovsdb/storage.c
index a1fb86df9..c2f28ca5a 100644
--- a/ovsdb/storage.c
+++ b/ovsdb/storage.c
@@ -522,7 +522,7 @@ schedule_next_snapshot(struct ovsdb_storage *storage, bool 
quick)
 }
 
 bool
-ovsdb_storage_should_snapshot(struct ovsdb_storage *storage)
+ovsdb_storage_should_compact(struct ovsdb_storage *storage)
 {
     if (storage->raft || storage->log) {
         /* If we haven't reached the minimum snapshot time, don't snapshot. */
diff --git a/ovsdb/storage.h b/ovsdb/storage.h
index 7079ea261..6e5ef9185 100644
--- a/ovsdb/storage.h
+++ b/ovsdb/storage.h
@@ -76,7 +76,7 @@ uint64_t ovsdb_write_get_commit_index(const struct 
ovsdb_write *);
 void ovsdb_write_wait(const struct ovsdb_write *);
 void ovsdb_write_destroy(struct ovsdb_write *);
 
-bool ovsdb_storage_should_snapshot(struct ovsdb_storage *);
+bool ovsdb_storage_should_compact(struct ovsdb_storage *);
 struct ovsdb_error *ovsdb_storage_store_snapshot(struct ovsdb_storage *storage,
                                                  const struct json *schema,
                                                  const struct json *snapshot,
-- 
2.43.0


_______________________________________________
dev mailing list
d...@openvswitch.org
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to