From: Ben Pfaff Date: Mon, 8 Mar 2010 22:01:16 +0000 (-0800) Subject: ovsdb-tool: Do not lock source db for compacting or converting to new db. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=aebfc8693746682c6c2c02b6cc4d0c580fab0039;p=openvswitch ovsdb-tool: Do not lock source db for compacting or converting to new db. "ovsdb-tool compact SRC DST" and "ovsdb-tool convert SRC SCHEMA DST" do not need to lock SRC, because they do not modify it. Reported-by: Justin Pettit --- diff --git a/ovsdb/ovsdb-tool.c b/ovsdb/ovsdb-tool.c index 26f9003b..b2e200cb 100644 --- a/ovsdb/ovsdb-tool.c +++ b/ovsdb/ovsdb-tool.c @@ -187,17 +187,18 @@ compact_or_convert(const char *src_name, const char *dst_name, struct ovsdb *db; int retval; - /* Get (temporary) destination. */ + /* Lock the source, if we will be replacing it. */ if (in_place) { - dst_name = xasprintf("%s.tmp", src_name); + retval = lockfile_lock(src_name, INT_MAX, &src_lock); + if (retval) { + ovs_fatal(retval, "%s: failed to lock lockfile", src_name); + } } - /* Lock source and (temporary) destination. */ - retval = lockfile_lock(src_name, INT_MAX, &src_lock); - if (retval) { - ovs_fatal(retval, "%s: failed to lock lockfile", src_name); + /* Get (temporary) destination and lock it. */ + if (in_place) { + dst_name = xasprintf("%s.tmp", src_name); } - retval = lockfile_lock(dst_name, INT_MAX, &dst_lock); if (retval) { ovs_fatal(retval, "%s: failed to lock lockfile", dst_name); @@ -217,7 +218,6 @@ compact_or_convert(const char *src_name, const char *dst_name, dst_name, src_name); } fsync_parent_dir(dst_name); - } else { lockfile_unlock(src_lock); }