summaryrefslogtreecommitdiff
path: root/lib/bitmap.h
diff options
context:
space:
mode:
authorBen Pfaff <blp@nicira.com>2010-03-11 17:14:31 -0800
committerBen Pfaff <blp@nicira.com>2010-03-17 14:24:56 -0700
commit17d18afbfd65619e830d551cb002441519cde059 (patch)
treebf7bd57ee1a8a9f59dffb5824b66c97c34c7f345 /lib/bitmap.h
parentc7d85e0df048a9fda6e1a111cd74e5a82e6b3b91 (diff)
downloadopenvswitch-17d18afbfd65619e830d551cb002441519cde059.tar.gz
ovsdb: Check for changed columns only once per transaction commit.
Until now, each part of a transaction commit that is interested in whether a column's value has changed has had to do a comparison of the old and new values itself. There can be several interested parties per commit (generally one for file storage and one for each remove OVSDB connection), so this seems like too much redundancy. This commit adds a bitmap to struct ovsdb_txn_row that tracks whether a column's value has actually changed, to reduce this overhead. As a convenient side effect of doing these checks up front, it then becomes easily possible to drop txn_rows (and txn_tables and entire txns) that become no-ops. (This probably fixes bug #2400, which reported that some no-ops actually report updates over monitors.)
Diffstat (limited to 'lib/bitmap.h')
-rw-r--r--lib/bitmap.h17
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/bitmap.h b/lib/bitmap.h
index 5b50c9cc4..fd05d3da1 100644
--- a/lib/bitmap.h
+++ b/lib/bitmap.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2008, 2009 Nicira Networks.
+ * Copyright (c) 2008, 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.
@@ -35,11 +35,22 @@ bitmap_bit__(size_t offset)
return 1UL << (offset % BITMAP_ULONG_BITS);
}
+static inline size_t
+bitmap_n_longs(size_t n_bits)
+{
+ return DIV_ROUND_UP(n_bits, BITMAP_ULONG_BITS);
+}
+
+static inline size_t
+bitmap_n_bytes(size_t n_bits)
+{
+ return bitmap_n_longs(n_bits) * sizeof(unsigned long int);
+}
+
static inline unsigned long *
bitmap_allocate(size_t n_bits)
{
- size_t n_longs = DIV_ROUND_UP(n_bits, BITMAP_ULONG_BITS);
- return xcalloc(sizeof(unsigned long int), n_longs);
+ return xzalloc(bitmap_n_bytes(n_bits));
}
static inline void