mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 14:25:26 +00:00
ovsdb-idl: Fix *_is_new() IDL functions.
Currently all functions of the type *_is_new() always return
'false'. This patch resolves this issue by using the
'OVSDB_IDL_CHANGE_INSERT' 'change_seqno' instead of the
'OVSDB_IDL_CHANGE_MODIFY' 'change_seqno' to determine if a row
is new and by resetting the 'OVSDB_IDL_CHANGE_INSERT'
'change_seqno' on clear.
Further to this, the code is also updated to match the following
behaviour:
When a row is inserted, the 'OVSDB_IDL_CHANGE_INSERT'
'change_seqno' is updated to match the new database
change_seqno. The 'OVSDB_IDL_CHANGE_MODIFY' 'change_seqno'
is not set for inserted rows (only for updated rows).
At the end of a run, ovsdb_idl_db_track_clear() should be
called to clear all tracking information, this includes
resetting all row 'change_seqno' to zero. This will ensure
that subsequent runs will not see a previously 'new' row.
add_tracked_change_for_references() is updated to only
track rows that reference the current row.
Also, update unit tests in order to test the *_is_new(),
*_is_delete() functions.
Suggested-by: Dumitru Ceara <dceara@redhat.com>
Reported-at: https://bugzilla.redhat.com/1883562
Fixes: ca545a787a
("ovsdb-idl.c: Increase seqno for change-tracking of table references.")
Signed-off-by: Mark Gray <mark.d.gray@redhat.com>
Acked-by: Han Zhou <hzhou@ovn.org>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
This commit is contained in:
@@ -1959,6 +1959,11 @@ ovsdb_idl_db_track_clear(struct ovsdb_idl_db *db)
|
||||
free(row->updated);
|
||||
row->updated = NULL;
|
||||
}
|
||||
|
||||
row->change_seqno[OVSDB_IDL_CHANGE_INSERT] =
|
||||
row->change_seqno[OVSDB_IDL_CHANGE_MODIFY] =
|
||||
row->change_seqno[OVSDB_IDL_CHANGE_DELETE] = 0;
|
||||
|
||||
ovs_list_remove(&row->track_node);
|
||||
ovs_list_init(&row->track_node);
|
||||
if (ovsdb_idl_row_is_orphan(row) && row->tracked_old_datum) {
|
||||
@@ -2684,22 +2689,25 @@ ovsdb_idl_process_update2(struct ovsdb_idl_table *table,
|
||||
return OVSDB_IDL_UPDATE_DB_CHANGED;
|
||||
}
|
||||
|
||||
/* Recursively add rows to tracked change lists for current row
|
||||
* and the rows that reference this row. */
|
||||
/* Recursively add rows to tracked change lists for all rows that reference
|
||||
'row'. */
|
||||
static void
|
||||
add_tracked_change_for_references(struct ovsdb_idl_row *row)
|
||||
{
|
||||
if (ovs_list_is_empty(&row->track_node) &&
|
||||
ovsdb_idl_track_is_set(row->table)) {
|
||||
ovs_list_push_back(&row->table->track_list,
|
||||
&row->track_node);
|
||||
row->change_seqno[OVSDB_IDL_CHANGE_MODIFY]
|
||||
= row->table->change_seqno[OVSDB_IDL_CHANGE_MODIFY]
|
||||
= row->table->db->change_seqno + 1;
|
||||
const struct ovsdb_idl_arc *arc;
|
||||
LIST_FOR_EACH (arc, dst_node, &row->dst_arcs) {
|
||||
struct ovsdb_idl_row *ref = arc->src;
|
||||
|
||||
const struct ovsdb_idl_arc *arc;
|
||||
LIST_FOR_EACH (arc, dst_node, &row->dst_arcs) {
|
||||
add_tracked_change_for_references(arc->src);
|
||||
if (ovs_list_is_empty(&ref->track_node) &&
|
||||
ovsdb_idl_track_is_set(ref->table)) {
|
||||
ovs_list_push_back(&ref->table->track_list,
|
||||
&ref->track_node);
|
||||
|
||||
ref->change_seqno[OVSDB_IDL_CHANGE_MODIFY]
|
||||
= ref->table->change_seqno[OVSDB_IDL_CHANGE_MODIFY]
|
||||
= ref->table->db->change_seqno + 1;
|
||||
|
||||
add_tracked_change_for_references(ref);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2767,7 +2775,14 @@ ovsdb_idl_row_change__(struct ovsdb_idl_row *row, const struct json *row_json,
|
||||
row->change_seqno[change]
|
||||
= row->table->change_seqno[change]
|
||||
= row->table->db->change_seqno + 1;
|
||||
|
||||
if (table->modes[column_idx] & OVSDB_IDL_TRACK) {
|
||||
if (ovs_list_is_empty(&row->track_node) &&
|
||||
ovsdb_idl_track_is_set(row->table)) {
|
||||
ovs_list_push_back(&row->table->track_list,
|
||||
&row->track_node);
|
||||
}
|
||||
|
||||
add_tracked_change_for_references(row);
|
||||
if (!row->updated) {
|
||||
row->updated = bitmap_allocate(class->n_columns);
|
||||
@@ -4843,6 +4858,7 @@ ovsdb_idl_txn_insert(struct ovsdb_idl_txn *txn,
|
||||
hmap_insert(&row->table->rows, &row->hmap_node, uuid_hash(&row->uuid));
|
||||
hmap_insert(&txn->txn_rows, &row->txn_node, uuid_hash(&row->uuid));
|
||||
ovsdb_idl_add_to_indexes(row);
|
||||
|
||||
return row;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user