summaryrefslogtreecommitdiff
path: root/src/third_party/wiredtiger/src/support
diff options
context:
space:
mode:
Diffstat (limited to 'src/third_party/wiredtiger/src/support')
-rw-r--r--src/third_party/wiredtiger/src/support/cksum.c2
-rw-r--r--src/third_party/wiredtiger/src/support/crypto.c2
-rw-r--r--src/third_party/wiredtiger/src/support/err.c2
-rw-r--r--src/third_party/wiredtiger/src/support/filename.c60
-rw-r--r--src/third_party/wiredtiger/src/support/global.c2
-rw-r--r--src/third_party/wiredtiger/src/support/hash_city.c2
-rw-r--r--src/third_party/wiredtiger/src/support/hash_fnv.c2
-rw-r--r--src/third_party/wiredtiger/src/support/hazard.c2
-rw-r--r--src/third_party/wiredtiger/src/support/hex.c6
-rw-r--r--src/third_party/wiredtiger/src/support/huffman.c2
-rw-r--r--src/third_party/wiredtiger/src/support/pow.c2
-rw-r--r--src/third_party/wiredtiger/src/support/rand.c2
-rw-r--r--src/third_party/wiredtiger/src/support/scratch.c2
13 files changed, 57 insertions, 31 deletions
diff --git a/src/third_party/wiredtiger/src/support/cksum.c b/src/third_party/wiredtiger/src/support/cksum.c
index a8b5823100d..c2982c40015 100644
--- a/src/third_party/wiredtiger/src/support/cksum.c
+++ b/src/third_party/wiredtiger/src/support/cksum.c
@@ -1,5 +1,5 @@
/*-
- * Public Domain 2014-2015 MongoDB, Inc.
+ * Public Domain 2014-2016 MongoDB, Inc.
* Public Domain 2008-2014 WiredTiger, Inc.
*
* This is free and unencumbered software released into the public domain.
diff --git a/src/third_party/wiredtiger/src/support/crypto.c b/src/third_party/wiredtiger/src/support/crypto.c
index b1102163e7b..1049621fb44 100644
--- a/src/third_party/wiredtiger/src/support/crypto.c
+++ b/src/third_party/wiredtiger/src/support/crypto.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2014-2015 MongoDB, Inc.
+ * Copyright (c) 2014-2016 MongoDB, Inc.
* Copyright (c) 2008-2014 WiredTiger, Inc.
* All rights reserved.
*
diff --git a/src/third_party/wiredtiger/src/support/err.c b/src/third_party/wiredtiger/src/support/err.c
index de518cbf08b..875bd3efcf3 100644
--- a/src/third_party/wiredtiger/src/support/err.c
+++ b/src/third_party/wiredtiger/src/support/err.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2014-2015 MongoDB, Inc.
+ * Copyright (c) 2014-2016 MongoDB, Inc.
* Copyright (c) 2008-2014 WiredTiger, Inc.
* All rights reserved.
*
diff --git a/src/third_party/wiredtiger/src/support/filename.c b/src/third_party/wiredtiger/src/support/filename.c
index 02a83803e25..215f5b47997 100644
--- a/src/third_party/wiredtiger/src/support/filename.c
+++ b/src/third_party/wiredtiger/src/support/filename.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2014-2015 MongoDB, Inc.
+ * Copyright (c) 2014-2016 MongoDB, Inc.
* Copyright (c) 2008-2014 WiredTiger, Inc.
* All rights reserved.
*
@@ -65,11 +65,49 @@ __wt_remove_if_exists(WT_SESSION_IMPL *session, const char *name)
}
/*
- * __wt_sync_and_rename_fh --
+ * __wt_rename_and_sync_directory --
+ * Rename a file and sync the enclosing directory.
+ */
+int
+__wt_rename_and_sync_directory(
+ WT_SESSION_IMPL *session, const char *from, const char *to)
+{
+ const char *fp, *tp;
+ bool same_directory;
+
+ /* Rename the source file to the target. */
+ WT_RET(__wt_rename(session, from, to));
+
+ /*
+ * Flush the backing directory to guarantee the rename. My reading of
+ * POSIX 1003.1 is there's no guarantee flushing only one of the from
+ * or to directories, or flushing a common parent, is sufficient, and
+ * even if POSIX were to make that guarantee, existing filesystems are
+ * known to not provide the guarantee or only provide the guarantee
+ * with specific mount options. Flush both of the from/to directories
+ * until it's a performance problem.
+ */
+ WT_RET(__wt_directory_sync(session, from));
+
+ /*
+ * In almost all cases, we're going to be renaming files in the same
+ * directory, we can at least fast-path that.
+ */
+ fp = strrchr(from, '/');
+ tp = strrchr(to, '/');
+ same_directory = (fp == NULL && tp == NULL) ||
+ (fp != NULL && tp != NULL &&
+ fp - from == tp - to && memcmp(from, to, (size_t)(fp - from)) == 0);
+
+ return (same_directory ? 0 : __wt_directory_sync(session, to));
+}
+
+/*
+ * __wt_fh_sync_and_rename --
* Sync and close a file, and swap it into place.
*/
int
-__wt_sync_and_rename_fh(
+__wt_fh_sync_and_rename(
WT_SESSION_IMPL *session, WT_FH **fhp, const char *from, const char *to)
{
WT_DECL_RET;
@@ -83,19 +121,15 @@ __wt_sync_and_rename_fh(
WT_TRET(__wt_close(session, &fh));
WT_RET(ret);
- /* Rename the source file to the target. */
- WT_RET(__wt_rename(session, from, to));
-
- /* Flush the backing directory to guarantee the rename. */
- return (__wt_directory_sync(session, NULL));
+ return (__wt_rename_and_sync_directory(session, from, to));
}
/*
- * __wt_sync_and_rename_fp --
+ * __wt_sync_fp_and_rename --
* Sync and close a file, and swap it into place.
*/
int
-__wt_sync_and_rename_fp(
+__wt_sync_fp_and_rename(
WT_SESSION_IMPL *session, FILE **fpp, const char *from, const char *to)
{
FILE *fp;
@@ -106,9 +140,5 @@ __wt_sync_and_rename_fp(
/* Flush to disk and close the handle. */
WT_RET(__wt_fclose(&fp, WT_FHANDLE_WRITE));
- /* Rename the source file to the target. */
- WT_RET(__wt_rename(session, from, to));
-
- /* Flush the backing directory to guarantee the rename. */
- return (__wt_directory_sync(session, NULL));
+ return (__wt_rename_and_sync_directory(session, from, to));
}
diff --git a/src/third_party/wiredtiger/src/support/global.c b/src/third_party/wiredtiger/src/support/global.c
index 2330a65a707..0234455b6ce 100644
--- a/src/third_party/wiredtiger/src/support/global.c
+++ b/src/third_party/wiredtiger/src/support/global.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2014-2015 MongoDB, Inc.
+ * Copyright (c) 2014-2016 MongoDB, Inc.
* Copyright (c) 2008-2014 WiredTiger, Inc.
* All rights reserved.
*
diff --git a/src/third_party/wiredtiger/src/support/hash_city.c b/src/third_party/wiredtiger/src/support/hash_city.c
index 33f4113c004..5780cd7b459 100644
--- a/src/third_party/wiredtiger/src/support/hash_city.c
+++ b/src/third_party/wiredtiger/src/support/hash_city.c
@@ -1,5 +1,5 @@
/*-
- * Public Domain 2014-2015 MongoDB, Inc.
+ * Public Domain 2014-2016 MongoDB, Inc.
* Public Domain 2008-2014 WiredTiger, Inc.
*
* This is free and unencumbered software released into the public domain.
diff --git a/src/third_party/wiredtiger/src/support/hash_fnv.c b/src/third_party/wiredtiger/src/support/hash_fnv.c
index e780931454d..35e7e5f3a73 100644
--- a/src/third_party/wiredtiger/src/support/hash_fnv.c
+++ b/src/third_party/wiredtiger/src/support/hash_fnv.c
@@ -1,5 +1,5 @@
/*-
- * Public Domain 2014-2015 MongoDB, Inc.
+ * Public Domain 2014-2016 MongoDB, Inc.
* Public Domain 2008-2014 WiredTiger, Inc.
*
* This is free and unencumbered software released into the public domain.
diff --git a/src/third_party/wiredtiger/src/support/hazard.c b/src/third_party/wiredtiger/src/support/hazard.c
index 0fc7051fb90..13e0eb3b9ac 100644
--- a/src/third_party/wiredtiger/src/support/hazard.c
+++ b/src/third_party/wiredtiger/src/support/hazard.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2014-2015 MongoDB, Inc.
+ * Copyright (c) 2014-2016 MongoDB, Inc.
* Copyright (c) 2008-2014 WiredTiger, Inc.
* All rights reserved.
*
diff --git a/src/third_party/wiredtiger/src/support/hex.c b/src/third_party/wiredtiger/src/support/hex.c
index 5fb8d4bc190..d42a84154ca 100644
--- a/src/third_party/wiredtiger/src/support/hex.c
+++ b/src/third_party/wiredtiger/src/support/hex.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2014-2015 MongoDB, Inc.
+ * Copyright (c) 2014-2016 MongoDB, Inc.
* Copyright (c) 2008-2014 WiredTiger, Inc.
* All rights reserved.
*
@@ -83,10 +83,6 @@ __wt_raw_to_esc_hex(
*/
WT_RET(__wt_buf_init(session, to, size * 3 + 1));
- /*
- * In the worst case, every character takes up 3 spaces, plus a
- * trailing nul byte.
- */
for (p = from, t = to->mem, i = size; i > 0; --i, ++p)
if (isprint((int)*p)) {
if (*p == '\\')
diff --git a/src/third_party/wiredtiger/src/support/huffman.c b/src/third_party/wiredtiger/src/support/huffman.c
index 9488dbf14fe..edd0bc9f648 100644
--- a/src/third_party/wiredtiger/src/support/huffman.c
+++ b/src/third_party/wiredtiger/src/support/huffman.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2014-2015 MongoDB, Inc.
+ * Copyright (c) 2014-2016 MongoDB, Inc.
* Copyright (c) 2008-2014 WiredTiger, Inc.
* All rights reserved.
*
diff --git a/src/third_party/wiredtiger/src/support/pow.c b/src/third_party/wiredtiger/src/support/pow.c
index 0f50bfe56a1..028263581d3 100644
--- a/src/third_party/wiredtiger/src/support/pow.c
+++ b/src/third_party/wiredtiger/src/support/pow.c
@@ -1,5 +1,5 @@
/*-
- * Public Domain 2014-2015 MongoDB, Inc.
+ * Public Domain 2014-2016 MongoDB, Inc.
* Public Domain 2008-2014 WiredTiger, Inc.
*
* This is free and unencumbered software released into the public domain.
diff --git a/src/third_party/wiredtiger/src/support/rand.c b/src/third_party/wiredtiger/src/support/rand.c
index 3adcb801f03..d2e4cd27aab 100644
--- a/src/third_party/wiredtiger/src/support/rand.c
+++ b/src/third_party/wiredtiger/src/support/rand.c
@@ -1,5 +1,5 @@
/*-
- * Public Domain 2014-2015 MongoDB, Inc.
+ * Public Domain 2014-2016 MongoDB, Inc.
* Public Domain 2008-2014 WiredTiger, Inc.
*
* This is free and unencumbered software released into the public domain.
diff --git a/src/third_party/wiredtiger/src/support/scratch.c b/src/third_party/wiredtiger/src/support/scratch.c
index f0c403c9ec8..94020ba2621 100644
--- a/src/third_party/wiredtiger/src/support/scratch.c
+++ b/src/third_party/wiredtiger/src/support/scratch.c
@@ -1,5 +1,5 @@
/*-
- * Copyright (c) 2014-2015 MongoDB, Inc.
+ * Copyright (c) 2014-2016 MongoDB, Inc.
* Copyright (c) 2008-2014 WiredTiger, Inc.
* All rights reserved.
*