mirror of
https://github.com/openvswitch/ovs
synced 2025-08-31 06:15:47 +00:00
ovsdb: Save some space in the log for newly inserted records.
When a new record is inserted into a database, ovsdb logs the values of all of the fields in the record. However, often new records have many columns that contain default values. There is no need to log those values, so this commit causes them to be omitted. As a side effect, this also makes "ovsdb-tool show-log --more --more" output easier to read, because record insertions print less noise. (Adding --more --more to this command makes it print changes to database records. The --more option will be introduced in an upcoming commit.)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* Copyright (c) 2009 Nicira Networks
|
||||
/* Copyright (c) 2009, 2010 Nicira Networks
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -65,6 +65,35 @@ ovsdb_atom_init_default(union ovsdb_atom *atom, enum ovsdb_atomic_type type)
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
ovsdb_atom_is_default(const union ovsdb_atom *atom,
|
||||
enum ovsdb_atomic_type type)
|
||||
{
|
||||
switch (type) {
|
||||
case OVSDB_TYPE_VOID:
|
||||
NOT_REACHED();
|
||||
|
||||
case OVSDB_TYPE_INTEGER:
|
||||
return atom->integer == 0;
|
||||
|
||||
case OVSDB_TYPE_REAL:
|
||||
return atom->real == 0.0;
|
||||
|
||||
case OVSDB_TYPE_BOOLEAN:
|
||||
return atom->boolean == false;
|
||||
|
||||
case OVSDB_TYPE_STRING:
|
||||
return atom->string[0] == '\0';
|
||||
|
||||
case OVSDB_TYPE_UUID:
|
||||
return uuid_is_zero(&atom->uuid);
|
||||
|
||||
case OVSDB_N_TYPES:
|
||||
default:
|
||||
NOT_REACHED();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ovsdb_atom_clone(union ovsdb_atom *new, const union ovsdb_atom *old,
|
||||
enum ovsdb_atomic_type type)
|
||||
@@ -351,6 +380,28 @@ ovsdb_datum_init_default(struct ovsdb_datum *datum,
|
||||
datum->values = alloc_default_atoms(type->value_type, datum->n);
|
||||
}
|
||||
|
||||
bool
|
||||
ovsdb_datum_is_default(const struct ovsdb_datum *datum,
|
||||
const struct ovsdb_type *type)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (datum->n != type->n_min) {
|
||||
return false;
|
||||
}
|
||||
for (i = 0; i < datum->n; i++) {
|
||||
if (!ovsdb_atom_is_default(&datum->keys[i], type->key_type)) {
|
||||
return false;
|
||||
}
|
||||
if (type->value_type != OVSDB_TYPE_VOID
|
||||
&& !ovsdb_atom_is_default(&datum->values[i], type->value_type)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static union ovsdb_atom *
|
||||
clone_atoms(const union ovsdb_atom *old, enum ovsdb_atomic_type type, size_t n)
|
||||
{
|
||||
|
Reference in New Issue
Block a user