summaryrefslogtreecommitdiff
path: root/ovsdb/file.c
Commit message (Collapse)AuthorAgeFilesLines
* ovsdb: Allow online compacting on Windows.Alin Serdean2016-11-301-11/+76
| | | | | | | | | | | | | | | | | | This patch allows online compacting to be done under Windows. To achieve the above we need to close all file handles before trying to rename the file, switch from rename to MoveFileEx (because rename/MoveFile fails if the destination exists), reopen the right type of log after the rename. If we could not reopen the compacted database or the original database after the close simply abort and rely on the service manager. This can be changed in the future. Signed-off-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com> Co-authored-by: Ben Pfaff <blp@ovn.org> Signed-off-by: Ben Pfaff <blp@ovn.org> Tested-by: Alin Gabriel Serdean <aserdean@cloudbasesolutions.com>
* json: Move from lib to include/openvswitch.Terry Wilson2016-07-221-1/+1
| | | | | | | | | | | | | | | To easily allow both in- and out-of-tree building of the Python wrapper for the OVS JSON parser (e.g. w/ pip), move json.h to include/openvswitch. This also requires moving lib/{hmap,shash}.h. Both hmap.h and shash.h were #include-ing "util.h" even though the headers themselves did not use anything from there, but rather from include/openvswitch/util.h. Fixing that required including util.h in several C files mostly due to OVS_NOT_REACHED and things like xmalloc. Signed-off-by: Terry Wilson <twilson@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
* ovsdb: Use previous snapshot size as an additional factor for compaction.Ben Pfaff2016-03-311-7/+26
| | | | | | | | | | | | | | Until now, the minimum database size before automatically compacting has been 10 MB, regardless of the inherent size of the data in the database. A couple of people have pointed out that this won't scale well to larger databases. This commit changes this criterion to 4 times the previously compacted size of the database, with 10 MB as a minimum. The 4x factor is suggested by Diego Ongaro's thesis, "Consensus: Bridging Theory and Practice", section 5.1.2 "When to snapshot". Signed-off-by: Ben Pfaff <blp@ovn.org> Acked-by: Justin Pettit <jpettit@ovn.org>
* lib: Move vlog.h to <openvswitch/vlog.h>Thomas Graf2014-12-151-1/+1
| | | | | | | | A new function vlog_insert_module() is introduced to avoid using list_insert() from the vlog.h header. Signed-off-by: Thomas Graf <tgraf@noironetworks.com> Acked-by: Ben Pfaff <blp@nicira.com>
* ovsdb: write commit timestamps to millisecond resolution.Paul Ingram2013-09-161-1/+1
| | | | | | | | | | | | | | | | This is expected to make system debugging easier. This raises two compatibility issues: 1. When a new ovsdb-tool reads an old database, it will multiply by 1000 any timestamp it reads which is less than 1<<31. Since this date corresponds to Jan 16 1970 this is unlikely to cause a problem. 2. When an old ovsdb-tool reads a new database, it will interpret the millisecond timestamps as seconds and report dates in the far future; the time of this commit is reported as the year 45672 (each second since the epoch is interpreted as 16 minutes). Signed-off-by: Paul Ingram <pingram@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ovsdb: Use DB load time, not on-disk commit times, for compaction.Paul Ingram2013-09-161-31/+12
| | | | | | | | | | | | | | The ovsdb-server compaction timing logic is written assuming monotonic time at milliscond resolution but it calculated the next compaction time based on the oldest commit in the database. This was a problem because commit timestamps are written in wall-clock time to second resolution. This commit calculates the next compaction time based on the time when the database was first loaded or the last compaction was done, both in monotonic time at millisecond resolution. Signed-off-by: Paul Ingram <pingram@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ovsdb: Fix typo in comment ("millseconds").Ben Pfaff2013-02-251-2/+2
| | | | Signed-off-by: Ben Pfaff <blp@nicira.com>
* Replace most uses of assert by ovs_assert.Ben Pfaff2013-01-161-5/+4
| | | | | | | | This is a straight search-and-replace, except that I also removed #include <assert.h> from each file where there were no assert calls left. Signed-off-by: Ben Pfaff <blp@nicira.com> Acked-by: Ethan Jackson <ethan@nicira.com>
* lockfile: Remove lockfile_lock timeout argumentLeo Alterman2012-08-091-1/+1
| | | | | | | | | lockfile_lock() accepts a timeout argument but, aside from unit tests pertaining to timeout, its value is always 0. Since this feature relies on a periodic SIGALRM signal, which is not a given if we're not caching time, the cleanest solution is just to remove it. Signed-off-by: Leo Alterman <lalterman@nicira.com>
* ovsdb: Do not replace symlinks by regular files during compaction.Ben Pfaff2012-08-011-2/+5
| | | | Signed-off-by: Ben Pfaff <blp@nicira.com>
* Global replace of Nicira Networks.Raju Subramanian2012-05-021-1/+1
| | | | | | | | Replaced all instances of Nicira Networks(, Inc) to Nicira, Inc. Feature #10593 Signed-off-by: Raju Subramanian <rsubramanian@nicira.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
* ovsdb: Fix segfault in ovsdb_file_txn_row_from_json().Ben Pfaff2011-07-061-3/+2
| | | | | | | | If 'error' is nonnull then we destroy the row, so we must not try to reuse the row immediately after that. Support request #6155. Repoted-by: Geoff White <gwhite@nicira.com>
* ovsdb: Synchronize comments and code in ovsdb_file_commit().Ben Pfaff2011-06-241-2/+3
| | | | The comments and the code didn't match, so make them agree.
* ovsdb: Truncate bad transactions from database log.Ben Pfaff2011-03-311-1/+6
| | | | | | | | | | | | | | | | | When ovsdb-server reads a database file that is corrupted at the transaction level (that is, the transaction is valid JSON and has the correct SHA-1 hash, but it does not describe a valid database transaction), then ovsdb-server should truncate it and overwrite it by valid transactions. However, until now, it didn't. Instead, it would keep the invalid transaction and possibly every transaction in the database file (depending on in what way the transaction was invalid), which would just cause the same trouble again the next time the database was read. This fixes the problem. An invalid transaction will be deleted from the database file at the first write to the database. Bug #5144. Bug #5149.
* ovsdb: Raise database corruption log level from warning to error.Ben Pfaff2011-03-311-1/+1
| | | | | | | If there's database corruption then it indicates that something went wrong, e.g. the machine was powered-off by power failure. It's definitely something that the admin should know about. This sounds like an error to me, so use that log level.
* ovsdb: Warn when result of ovsdb_txn_commit() is ignored and fix caller.Justin Pettit2011-02-231-1/+1
| | | | | | | | ovsdb_txn_commit() may return a ovsdb_error structure, which should be freed by the caller. The only remaining caller that discards the result is in ovsdb_file_open__(), which this fixes. Suggested-by: Ben Pfaff <blp@nicira.com>
* ovsdb: Don't check "date" before assignment in ovsdb_file_txn_from_json().Justin Pettit2011-02-221-3/+1
| | | | | | | | There's no indication that "date" is optional in the description of ovsdb_file_txn_from_json(), and the one caller always passes it in, so don't bother checking whether it exists. Coverity #10732
* ovsdb: Fix double free in ovsdb_file_open_log().Justin Pettit2011-02-221-1/+0
| | | | Coverity #11066
* ovsdb: New function ovsdb_file_read_schema() for reading schema from db.Ben Pfaff2011-02-151-20/+66
| | | | | | This new function saves reading the whole database when only the schema is of interest. This commit adapts ovsdb-tool to use it for the "db-version" command. Upcoming commits will introduce another caller.
* vlog: Make client supply semicolon for VLOG_DEFINE_THIS_MODULE.Ben Pfaff2010-10-291-1/+1
| | | | | It's kind of odd for VLOG_DEFINE_THIS_MODULE to supply its own semicolon, so this commit switches to the more common form.
* Switch many macros from using CONTAINER_OF to using OBJECT_CONTAINING.Ben Pfaff2010-10-011-1/+1
| | | | | These macros require one fewer argument by switching, which makes code that uses them shorter and more readable.
* vlog: Introduce VLOG_DEFINE_THIS_MODULE for declaring vlog module in use.Ben Pfaff2010-07-211-2/+2
| | | | | | | Adding a macro to define the vlog module in use adds a level of indirection, which makes it easier to change how the vlog module must be defined. A followup commit needs to do that, so getting these widespread changes out of the way first should make that commit easier to review.
* timeval: Use monotonic time where appropriate.Jesse Gross2010-06-081-1/+1
| | | | | | | | | | Most of the timekeeping needs of OVS are simply to measure intervals, which means that it is sensitive to changes in the clock. This commit replaces the existing clocks with monotonic timers. An additional set of wall clock timers are added and used in locations that need absolute time. Bug #1858
* ovsdb: Compact databases online automatically and on-demand.Ben Pfaff2010-03-181-42/+267
| | | | | | | | | | | | If the database grows fairly large, and we've written a fair number of transactions to it, and it's been a while since the database was compacted, then (after the next commit) compact the database. Also, compact the database online if the "ovsdb-server/compact" command is issued via unixctl. I suspect that this feature will rarely if ever be used in practice, but it's easier to test than compacting automatically. Bug #2391.
* ovsdb: Rename ovsdb_file_replica to ovsdb_file.Ben Pfaff2010-03-181-30/+29
| | | | | | | | | This is in preparation for exposing ovsdb_file to clients outside this translation unit. These clients don't care that the ovsdb_file is an ovsdb replica--that's an implementation detail--and so it makes sense to rename it from their point of view. This is just a search-and-replace plus reindenting where appropriate.
* ovsdb: Always set *dbp to null on failure in ovsdb_file_open__().Ben Pfaff2010-03-181-0/+1
| | | | Found via inspection. I do not know that this fixes a real bug.
* ovsdb: Check for changed columns only once per transaction commit.Ben Pfaff2010-03-171-6/+9
| | | | | | | | | | | | | | | 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.)
* ovsdb: Implement ovsdb-tool commands "compact" and "convert".Ben Pfaff2010-02-151-16/+155
| | | | Partial fix for bug #2391.
* ovsdb: Refactor code for writing a transaction to a file.Ben Pfaff2010-02-151-52/+82
| | | | | An upcoming commit will add another user for this code, so it is good to abstract it a little better.
* ovsdb: Allow ovsdb_log_open()'s caller to choose whether to lock.Ben Pfaff2010-02-151-1/+3
| | | | | | | | | | | | The current callers of ovsdb_log_open() always want to lock the file if they are accessing it for read/write access. An upcoming commit will add a new caller that does not fit this model (it wants to lock the file across a wider region) and so the caller should be able to choose whether to do locking. This commit adds that ability. Also, get rid of the use of <fcntl.h> flags to choose the open mode, which has always seemed somewhat crude and which this change would make even cruder.
* ovsdb: Fix commit to disk of rows added to a table with all-default values.Ben Pfaff2010-02-151-1/+1
|
* ovsdb: Save some space in the log for newly inserted records.Ben Pfaff2010-01-111-3/+5
| | | | | | | | | | | | 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.)
* ovsdb: Add "comment" feature to transactions and make ovs-vsctl use them.Ben Pfaff2009-12-161-0/+14
| | | | | | The idea here is that transaction comments get copied to the ovsdb-server's transaction log, which can then make it clear later why a particular change was made to the database, to ease debugging.
* ovsdb: Add replication support and refactor files in terms of replication.Ben Pfaff2009-11-161-0/+341
| | | | | | | An upcoming commit will add support for replicating tables across JSON-RPC connection. As a prerequisite ovsdb itself must support basic replication. This commit adds that support and then reimplements the ovsdb file storage in terms of that replication.
* ovsdb: Rename ovsdb_file to ovsdb_log.Ben Pfaff2009-11-161-360/+0
| | | | | This prepares for introducing a new, higher-level ovsdb_file that encapsulates ovsdb storage in a file.
* Initial implementation of OVSDB.Ben Pfaff2009-11-041-0/+360