X-Git-Url: http://git.cascardo.eti.br/?a=blobdiff_plain;f=ovsdb%2Ftransaction.c;h=2c85fee119594846406112f1ed5d97fba60eb808;hb=HEAD;hp=9e039635023e5ca338218e8acabedc45e7f702bb;hpb=ca6ba70092b1528e12d3140d70232175a13c335d;p=cascardo%2Fovs.git diff --git a/ovsdb/transaction.c b/ovsdb/transaction.c index 9e0396350..2c85fee11 100644 --- a/ovsdb/transaction.c +++ b/ovsdb/transaction.c @@ -1,4 +1,4 @@ -/* 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. @@ -27,6 +27,7 @@ #include "ovsdb.h" #include "row.h" #include "table.h" +#include "perf-counter.h" #include "uuid.h" struct ovsdb_txn { @@ -533,7 +534,6 @@ assess_weak_refs(struct ovsdb_txn *txn, struct ovsdb_txn_row *txn_row) } 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) { @@ -747,8 +747,23 @@ check_index_uniqueness(struct ovsdb_txn *txn OVS_UNUSED, 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; @@ -800,6 +815,12 @@ ovsdb_txn_commit(struct ovsdb_txn *txn, bool durable) 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); @@ -821,6 +842,15 @@ ovsdb_txn_commit(struct ovsdb_txn *txn, bool 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) @@ -905,7 +935,6 @@ ovsdb_txn_row_modify(struct ovsdb_txn *txn, const struct ovsdb_row *ro_row_) 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);