-/* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
+/* Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014, 2015 Nicira, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include "ovsdb.h"
#include "row.h"
#include "table.h"
+#include "perf-counter.h"
#include "uuid.h"
struct ovsdb_txn {
}
if (datum->n != orig_n) {
- bitmap_set1(txn_row->changed, OVSDB_COL_VERSION);
bitmap_set1(txn_row->changed, column->index);
ovsdb_datum_sort_assert(datum, column->type.key.type);
if (datum->n < column->type.n_min) {
return NULL;
}
-struct ovsdb_error *
-ovsdb_txn_commit(struct ovsdb_txn *txn, bool durable)
+static struct ovsdb_error * OVS_WARN_UNUSED_RESULT
+update_version(struct ovsdb_txn *txn OVS_UNUSED, struct ovsdb_txn_row *txn_row)
+{
+ struct ovsdb_table *table = txn_row->table;
+ size_t n_columns = shash_count(&table->schema->columns);
+
+ if (txn_row->old && txn_row->new
+ && !bitmap_is_all_zeros(txn_row->changed, n_columns)) {
+ bitmap_set1(txn_row->changed, OVSDB_COL_VERSION);
+ uuid_generate(ovsdb_row_get_version_rw(txn_row->new));
+ }
+
+ return NULL;
+}
+
+static struct ovsdb_error *
+ovsdb_txn_commit_(struct ovsdb_txn *txn, bool durable)
{
struct ovsdb_replica *replica;
struct ovsdb_error *error;
return error;
}
+ /* Update _version for rows that changed. */
+ error = for_each_txn_row(txn, update_version);
+ if (error) {
+ return OVSDB_WRAP_BUG("can't happen", error);
+ }
+
/* Send the commit to each replica. */
LIST_FOR_EACH (replica, node, &txn->db->replicas) {
error = (replica->class->commit)(replica, txn, durable);
return NULL;
}
+struct ovsdb_error *
+ovsdb_txn_commit(struct ovsdb_txn *txn, bool durable)
+{
+ struct ovsdb_error *err;
+
+ PERF(__func__, err = ovsdb_txn_commit_(txn, durable));
+ return err;
+}
+
void
ovsdb_txn_for_each_change(const struct ovsdb_txn *txn,
ovsdb_txn_row_cb_func *cb, void *aux)
rw_row = ovsdb_row_clone(ro_row);
rw_row->n_refs = ro_row->n_refs;
- uuid_generate(ovsdb_row_get_version_rw(rw_row));
ovsdb_txn_row_create(txn, table, ro_row, rw_row);
hmap_replace(&table->rows, &ro_row->hmap_node, &rw_row->hmap_node);