[ovs-dev] [PATCH 1/2] bridge: Resend netdev statistics to database if previous transaction was not successful.

Ryan Wilson wryan at nicira.com
Fri May 30 00:25:13 UTC 2014


Netdev statistics are not sent to the database if the netdev sequence
number has not changed. However, if the previous database transaction
fails, then netdev statistics will not be updated in the database
until the netdev sequence number changes.

This patch always sends netdev statistics if the last transaction was
not successful.

Signed-off-by: Ryan Wilson <wryan at nicira.com>
---
 vswitchd/bridge.c |   37 ++++++++++++++++++++++---------------
 1 file changed, 22 insertions(+), 15 deletions(-)

diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index 9764c1f..9137dcd 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -165,16 +165,23 @@ static uint64_t connectivity_seqno = LLONG_MIN;
  *
  * Some information in the database must be kept as up-to-date as possible to
  * allow controllers to respond rapidly to network outages.  Those status are
- * updated via the 'status_txn'.
+ * updated via the 'update_txn'.
  *
  * We use the global connectivity sequence number to detect the status change.
  * Also, to prevent the status update from sending too much to the database,
  * we check the return status of each update transaction and do not start new
  * update if the previous transaction status is 'TXN_INCOMPLETE'.
  *
- * 'statux_txn' is NULL if there is no ongoing status update.
+ * 'update_txn' is NULL if there is no ongoing status update.
+ *
+ * 'update_txn_status' is the last transaction status for 'update_txn'. If the
+ * last status is not 'TXN_SUCCESS' or 'TXN_UNCHANGED' and a transaction is
+ * currently not in progress (last status is not 'TXN_INCOMPLETE'), all netdev
+ * statistics are pushed to the database even if the netdev sequence number has
+ * not changed.
  */
-static struct ovsdb_idl_txn *status_txn;
+static struct ovsdb_idl_txn *update_txn;
+enum ovsdb_idl_txn_status update_txn_status = TXN_UNCOMMITTED;
 
 /* When the status update transaction returns 'TXN_INCOMPLETE', should register a
  * timeout in 'STATUS_CHECK_AGAIN_MSEC' to check again. */
@@ -1820,7 +1827,9 @@ iface_refresh_netdev_status(struct iface *iface)
         return;
     }
 
-    if (iface->change_seq == netdev_get_change_seq(iface->netdev)) {
+    if (iface->change_seq == netdev_get_change_seq(iface->netdev)
+        && (update_txn_status == TXN_SUCCESS ||
+            update_txn_status == TXN_UNCHANGED)) {
         return;
     }
 
@@ -2415,14 +2424,14 @@ bridge_run(void)
         stats_timer = time_msec() + stats_timer_interval;
     }
 
-    if (!status_txn) {
+    if (!update_txn) {
         uint64_t seq;
 
         /* Check the need to update status. */
         seq = seq_read(connectivity_seq_get());
         if (seq != connectivity_seqno) {
             connectivity_seqno = seq;
-            status_txn = ovsdb_idl_txn_create(idl);
+            update_txn = ovsdb_idl_txn_create(idl);
             HMAP_FOR_EACH (br, node, &all_bridges) {
                 struct port *port;
 
@@ -2440,15 +2449,13 @@ bridge_run(void)
         }
     }
 
-    if (status_txn) {
-        enum ovsdb_idl_txn_status status;
-
-        status = ovsdb_idl_txn_commit(status_txn);
-        /* Do not destroy "status_txn" if the transaction is
+    if (update_txn) {
+        update_txn_status = ovsdb_idl_txn_commit(update_txn);
+        /* Do not destroy "update_txn" if the transaction is
          * "TXN_INCOMPLETE". */
-        if (status != TXN_INCOMPLETE) {
-            ovsdb_idl_txn_destroy(status_txn);
-            status_txn = NULL;
+        if (update_txn_status != TXN_INCOMPLETE) {
+            ovsdb_idl_txn_destroy(update_txn);
+            update_txn = NULL;
         }
     }
 
@@ -2487,7 +2494,7 @@ bridge_wait(void)
      * register a timeout in 'STATUS_CHECK_AGAIN_MSEC'.  Else, wait on the
      * global connectivity sequence number.  Note, this also helps batch
      * multiple status changes into one transaction. */
-    if (status_txn) {
+    if (update_txn) {
         poll_timer_wait_until(time_msec() + STATUS_CHECK_AGAIN_MSEC);
     } else {
         seq_wait(connectivity_seq_get(), connectivity_seqno);
-- 
1.7.9.5




More information about the dev mailing list