summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Cahill <michael.cahill@mongodb.com>2016-06-03 15:18:38 +1000
committerMichael Cahill <michael.cahill@mongodb.com>2016-06-03 15:18:38 +1000
commitfb1663e6fc800be97c0ddc697b6f939dc610e08e (patch)
tree309dd2bf6118a916be76552234df812942359611
parentff108d7c705b82e482fb17e33488dc14304bf259 (diff)
parentc9dfa31598c33255a5f5710d9b22a1ed648feca3 (diff)
downloadmongo-fb1663e6fc800be97c0ddc697b6f939dc610e08e.tar.gz
Merge branch 'develop' into mongodb-3.4mongodb-3.3.8mongodb-3.3.7
-rw-r--r--SConstruct26
-rw-r--r--build_posix/configure.ac.in18
-rwxr-xr-xbuild_posix/makemake22
-rw-r--r--build_win/filelist.win171
-rw-r--r--dist/dist.py15
-rw-r--r--dist/filelist56
-rwxr-xr-xdist/s_define2
-rwxr-xr-xdist/s_funcs2
-rwxr-xr-xdist/s_prototypes2
-rwxr-xr-xdist/s_stat4
-rw-r--r--dist/s_string.ok1
-rwxr-xr-xdist/s_typedef2
-rwxr-xr-xdist/s_win35
-rw-r--r--src/btree/bt_sync.c6
-rw-r--r--src/cache/cache_las.c11
-rw-r--r--src/checksum/power8/crc32.S2
-rw-r--r--src/include/log.h1
-rw-r--r--src/include/os.h27
-rw-r--r--src/log/log.c17
-rw-r--r--src/os_posix/os_dir.c2
-rw-r--r--src/os_posix/os_fs.c30
-rw-r--r--src/os_posix/os_map.c11
-rw-r--r--src/os_win/os_fs.c5
23 files changed, 181 insertions, 287 deletions
diff --git a/SConstruct b/SConstruct
index c724d94da7c..a5dd8761d6c 100644
--- a/SConstruct
+++ b/SConstruct
@@ -240,12 +240,26 @@ wtheader = env.Substfile(
#
# WiredTiger library
#
-filelistfile = r'build_win\filelist.win'
-filelist = open(filelistfile)
-wtsources = [line.strip()
- for line in filelist
- if not line.startswith("#") and len(line) > 1]
-filelist.close()
+# Map WiredTiger build conditions: any conditions that appear in WiredTiger's
+# dist/filelist must appear here, and if the value is true, those files will be
+# included.
+#
+condition_map = {
+ 'POSIX_HOST' : env['PLATFORM'] == 'posix',
+ 'POWERPC_HOST' : False,
+ 'WINDOWS_HOST' : env['PLATFORM'] == 'win32',
+}
+
+def filtered_filelist(f):
+ for line in f:
+ file_cond = line.split()
+ if line.startswith("#") or len(file_cond) == 0:
+ continue
+ if len(file_cond) == 1 or condition_map[file_cond[1]]:
+ yield file_cond[0]
+
+filelistfile = r'dist/filelist'
+wtsources = list(filtered_filelist(open(filelistfile)))
if useZlib:
wtsources.append("ext/compressors/zlib/zlib_compress.c")
diff --git a/build_posix/configure.ac.in b/build_posix/configure.ac.in
index 9251873be73..617304f9215 100644
--- a/build_posix/configure.ac.in
+++ b/build_posix/configure.ac.in
@@ -34,6 +34,16 @@ AC_PROG_CC(cc gcc)
AC_PROG_CXX(c++ g++)
AM_PROG_AS(as gas)
+AM_CONDITIONAL([POSIX_HOST], [true])
+AM_CONDITIONAL([WINDOWS_HOST], [false])
+
+AS_CASE([$host_cpu],
+ [ppc64*], [wt_cv_powerpc="yes"],
+ [elf64lppc], [wt_cv_powerpc="yes"],
+ [powerpc*], [wt_cv_powerpc="yes"],
+ [wt_cv_powerpc="no"])
+AM_CONDITIONAL([POWERPC_HOST], [test "$wt_cv_powerpc" = "yes"])
+
# This is a workaround as part of WT-2459. Currently, clang (v3.7) does not
# support compiling the ASM code we have to perform the CRC checks on PowerPC.
# To compile with clang we need to override the ASM compiler with CCAS to use
@@ -41,12 +51,8 @@ AM_PROG_AS(as gas)
# determine what tag to use for that one .S file. If we catch that we are using
# two different compilers for CC and CCAS and we are on a PowerPC system we
# overload the libtool flags to provide CC by default.
-if test "$CC" != "$CCAS"; then
- AS_CASE([$host_cpu],
- [ppc64*], [AM_LIBTOOLFLAGS+="--tag=CC"],
- [elf64lppc], [AM_LIBTOOLFLAGS+="--tag=CC"],
- [powerpc*], [AM_LIBTOOLFLAGS+="--tag=CC"],
- [])
+if test "$wt_cv_powerpc" = "yes" -a "$CC" != "$CCAS"; then
+ [AM_LIBTOOLFLAGS+="--tag=CC"]
fi
AC_SUBST(AM_LIBTOOLFLAGS)
diff --git a/build_posix/makemake b/build_posix/makemake
index 9ed9d252911..506420b4aaf 100755
--- a/build_posix/makemake
+++ b/build_posix/makemake
@@ -7,7 +7,7 @@
(sed -n '1,/BEGIN SUBDIRS/p' Make.base
echo "SUBDIRS ="
-sed -e 's/#.*$//' -e '/^$/d' Make.subdirs | (while read dir cond ; do
+sed -e 's/#.*$//' -e '/^$/d' Make.subdirs | while read dir cond ; do
test -d ../$dir || continue
if test -n "$cond" ; then
cat <<END_CONDITIONAL
@@ -18,17 +18,27 @@ END_CONDITIONAL
else
echo "SUBDIRS += $dir"
fi
-done)
+done
# Write the rest of Make.base, up to SOURCES
sed -n '/END SUBDIRS/,/BEGIN SOURCES/p' Make.base
+# Write the list of sources.
echo
echo "libwiredtiger_la_LDFLAGS = -release @VERSION@"
-echo "libwiredtiger_la_SOURCES=\\"
-sed -e '/^[a-z]/!d' \
- -e 's/.*/ & \\/' \
- -e '$s/ \\$//' < ../dist/filelist
+echo "libwiredtiger_la_SOURCES ="
+sed -e '/^[a-z]/!d' < ../dist/filelist | while read file cond; do
+ if test -n "$cond"; then
+ cat <<END_CONDITIONAL
+# DO NOT indent the "libwiredtiger_la_SOURCES" lines, it breaks the build.
+if ${cond}
+libwiredtiger_la_SOURCES += $file
+endif
+END_CONDITIONAL
+ else
+ echo "libwiredtiger_la_SOURCES += $file"
+ fi
+done
# Write the rest of Make.base
sed -n '/END SOURCES/,$p' Make.base
diff --git a/build_win/filelist.win b/build_win/filelist.win
deleted file mode 100644
index d52a57ba2e3..00000000000
--- a/build_win/filelist.win
+++ /dev/null
@@ -1,171 +0,0 @@
-
-# List of source files for WiredTiger library.
-# filelist --
-src/async/async_api.c
-src/async/async_op.c
-src/async/async_worker.c
-src/block/block_addr.c
-src/block/block_ckpt.c
-src/block/block_compact.c
-src/block/block_ext.c
-src/block/block_map.c
-src/block/block_mgr.c
-src/block/block_open.c
-src/block/block_read.c
-src/block/block_session.c
-src/block/block_slvg.c
-src/block/block_vrfy.c
-src/block/block_write.c
-src/bloom/bloom.c
-src/btree/bt_compact.c
-src/btree/bt_curnext.c
-src/btree/bt_curprev.c
-src/btree/bt_cursor.c
-src/btree/bt_debug.c
-src/btree/bt_delete.c
-src/btree/bt_discard.c
-src/btree/bt_handle.c
-src/btree/bt_huffman.c
-src/btree/bt_io.c
-src/btree/bt_misc.c
-src/btree/bt_ovfl.c
-src/btree/bt_page.c
-src/btree/bt_read.c
-src/btree/bt_rebalance.c
-src/btree/bt_ret.c
-src/btree/bt_slvg.c
-src/btree/bt_split.c
-src/btree/bt_stat.c
-src/btree/bt_sync.c
-src/btree/bt_upgrade.c
-src/btree/bt_vrfy.c
-src/btree/bt_vrfy_dsk.c
-src/btree/bt_walk.c
-src/btree/col_modify.c
-src/btree/col_srch.c
-src/btree/row_key.c
-src/btree/row_modify.c
-src/btree/row_srch.c
-src/cache/cache_las.c
-src/checksum/checksum.c
-src/config/config.c
-src/config/config_api.c
-src/config/config_check.c
-src/config/config_collapse.c
-src/config/config_def.c
-src/config/config_ext.c
-src/config/config_upgrade.c
-src/conn/api_strerror.c
-src/conn/api_version.c
-src/conn/conn_api.c
-src/conn/conn_cache.c
-src/conn/conn_cache_pool.c
-src/conn/conn_ckpt.c
-src/conn/conn_dhandle.c
-src/conn/conn_handle.c
-src/conn/conn_log.c
-src/conn/conn_open.c
-src/conn/conn_stat.c
-src/conn/conn_sweep.c
-src/cursor/cur_backup.c
-src/cursor/cur_bulk.c
-src/cursor/cur_config.c
-src/cursor/cur_ds.c
-src/cursor/cur_dump.c
-src/cursor/cur_file.c
-src/cursor/cur_index.c
-src/cursor/cur_join.c
-src/cursor/cur_json.c
-src/cursor/cur_log.c
-src/cursor/cur_metadata.c
-src/cursor/cur_stat.c
-src/cursor/cur_std.c
-src/cursor/cur_table.c
-src/evict/evict_file.c
-src/evict/evict_lru.c
-src/evict/evict_page.c
-src/log/log.c
-src/log/log_auto.c
-src/log/log_slot.c
-src/lsm/lsm_cursor.c
-src/lsm/lsm_cursor_bulk.c
-src/lsm/lsm_manager.c
-src/lsm/lsm_merge.c
-src/lsm/lsm_meta.c
-src/lsm/lsm_stat.c
-src/lsm/lsm_tree.c
-src/lsm/lsm_work_unit.c
-src/lsm/lsm_worker.c
-src/meta/meta_apply.c
-src/meta/meta_ckpt.c
-src/meta/meta_ext.c
-src/meta/meta_table.c
-src/meta/meta_track.c
-src/meta/meta_turtle.c
-src/os_common/filename.c
-src/os_common/os_abort.c
-src/os_common/os_alloc.c
-src/os_common/os_fhandle.c
-src/os_common/os_fs_inmemory.c
-src/os_common/os_fstream.c
-src/os_common/os_fstream_stdio.c
-src/os_common/os_getopt.c
-src/os_common/os_strtouq.c
-src/os_win/os_dir.c
-src/os_win/os_dlopen.c
-src/os_win/os_errno.c
-src/os_win/os_fs.c
-src/os_win/os_getenv.c
-src/os_win/os_map.c
-src/os_win/os_mtx_cond.c
-src/os_win/os_once.c
-src/os_win/os_pagesize.c
-src/os_win/os_path.c
-src/os_win/os_priv.c
-src/os_win/os_setvbuf.c
-src/os_win/os_sleep.c
-src/os_win/os_snprintf.c
-src/os_win/os_thread.c
-src/os_win/os_time.c
-src/os_win/os_vsnprintf.c
-src/os_win/os_yield.c
-src/packing/pack_api.c
-src/packing/pack_impl.c
-src/packing/pack_stream.c
-src/reconcile/rec_track.c
-src/reconcile/rec_write.c
-src/schema/schema_create.c
-src/schema/schema_drop.c
-src/schema/schema_list.c
-src/schema/schema_open.c
-src/schema/schema_plan.c
-src/schema/schema_project.c
-src/schema/schema_rename.c
-src/schema/schema_stat.c
-src/schema/schema_truncate.c
-src/schema/schema_util.c
-src/schema/schema_worker.c
-src/session/session_api.c
-src/session/session_compact.c
-src/session/session_dhandle.c
-src/session/session_salvage.c
-src/support/cond_auto.c
-src/support/crypto.c
-src/support/err.c
-src/support/global.c
-src/support/hash_city.c
-src/support/hash_fnv.c
-src/support/hazard.c
-src/support/hex.c
-src/support/huffman.c
-src/support/mtx_rw.c
-src/support/pow.c
-src/support/rand.c
-src/support/scratch.c
-src/support/stat.c
-src/txn/txn.c
-src/txn/txn_ckpt.c
-src/txn/txn_ext.c
-src/txn/txn_log.c
-src/txn/txn_nsnap.c
-src/txn/txn_recover.c
diff --git a/dist/dist.py b/dist/dist.py
index 1b3ad828dfb..555cc03989b 100644
--- a/dist/dist.py
+++ b/dist/dist.py
@@ -2,21 +2,16 @@ import filecmp, glob, os, re, shutil
# source_files --
# Return a list of the WiredTiger source file names.
-def source_files(skip_includes=False):
- if not skip_includes:
- for line in glob.iglob('../src/include/*.[hi]'):
- yield line
+def source_files():
file_re = re.compile(r'^\w')
+ for line in glob.iglob('../src/include/*.[hi]'):
+ yield line
for line in open('filelist', 'r'):
if file_re.match(line):
- yield os.path.join('..', line.rstrip())
- # Return only the Windows-specific files in the Windows filelist
- for line in open('../build_win/filelist.win', 'r'):
- if 'os_win' in line and file_re.match(line):
- yield os.path.join('..', line.rstrip())
+ yield os.path.join('..', line.split()[0])
for line in open('extlist', 'r'):
if file_re.match(line):
- yield os.path.join('..', line.rstrip())
+ yield os.path.join('..', line.split()[0])
# source_dirs --
# Return a list of the WiredTiger source directory names.
diff --git a/dist/filelist b/dist/filelist
index 22d29d22edf..f3cb9514968 100644
--- a/dist/filelist
+++ b/dist/filelist
@@ -48,8 +48,8 @@ src/btree/row_modify.c
src/btree/row_srch.c
src/cache/cache_las.c
src/checksum/checksum.c
-src/checksum/power8/crc32.S
-src/checksum/power8/crc32_wrapper.c
+src/checksum/power8/crc32.S POWERPC_HOST
+src/checksum/power8/crc32_wrapper.c POWERPC_HOST
src/config/config.c
src/config/config_api.c
src/config/config_check.c
@@ -113,23 +113,41 @@ src/os_common/os_fstream.c
src/os_common/os_fstream_stdio.c
src/os_common/os_getopt.c
src/os_common/os_strtouq.c
-src/os_posix/os_dir.c
-src/os_posix/os_dlopen.c
-src/os_posix/os_errno.c
-src/os_posix/os_fallocate.c
-src/os_posix/os_fs.c
-src/os_posix/os_getenv.c
-src/os_posix/os_map.c
-src/os_posix/os_mtx_cond.c
-src/os_posix/os_once.c
-src/os_posix/os_pagesize.c
-src/os_posix/os_path.c
-src/os_posix/os_priv.c
-src/os_posix/os_setvbuf.c
-src/os_posix/os_sleep.c
-src/os_posix/os_thread.c
-src/os_posix/os_time.c
-src/os_posix/os_yield.c
+src/os_posix/os_dir.c POSIX_HOST
+src/os_posix/os_dlopen.c POSIX_HOST
+src/os_posix/os_errno.c POSIX_HOST
+src/os_posix/os_fallocate.c POSIX_HOST
+src/os_posix/os_fs.c POSIX_HOST
+src/os_posix/os_getenv.c POSIX_HOST
+src/os_posix/os_map.c POSIX_HOST
+src/os_posix/os_mtx_cond.c POSIX_HOST
+src/os_posix/os_once.c POSIX_HOST
+src/os_posix/os_pagesize.c POSIX_HOST
+src/os_posix/os_path.c POSIX_HOST
+src/os_posix/os_priv.c POSIX_HOST
+src/os_posix/os_setvbuf.c POSIX_HOST
+src/os_posix/os_sleep.c POSIX_HOST
+src/os_posix/os_thread.c POSIX_HOST
+src/os_posix/os_time.c POSIX_HOST
+src/os_posix/os_yield.c POSIX_HOST
+src/os_win/os_dir.c WINDOWS_HOST
+src/os_win/os_dlopen.c WINDOWS_HOST
+src/os_win/os_errno.c WINDOWS_HOST
+src/os_win/os_fs.c WINDOWS_HOST
+src/os_win/os_getenv.c WINDOWS_HOST
+src/os_win/os_map.c WINDOWS_HOST
+src/os_win/os_mtx_cond.c WINDOWS_HOST
+src/os_win/os_once.c WINDOWS_HOST
+src/os_win/os_pagesize.c WINDOWS_HOST
+src/os_win/os_path.c WINDOWS_HOST
+src/os_win/os_priv.c WINDOWS_HOST
+src/os_win/os_setvbuf.c WINDOWS_HOST
+src/os_win/os_sleep.c WINDOWS_HOST
+src/os_win/os_snprintf.c WINDOWS_HOST
+src/os_win/os_thread.c WINDOWS_HOST
+src/os_win/os_time.c WINDOWS_HOST
+src/os_win/os_vsnprintf.c WINDOWS_HOST
+src/os_win/os_yield.c WINDOWS_HOST
src/packing/pack_api.c
src/packing/pack_impl.c
src/packing/pack_stream.c
diff --git a/dist/s_define b/dist/s_define
index 77673bdcdf9..050101e8510 100755
--- a/dist/s_define
+++ b/dist/s_define
@@ -5,7 +5,7 @@ t=__wt.$$
trap 'rm -f $t; exit 0' 0 1 2 3 13 15
# List of source files to search.
-l=`sed -e 's,#.*,,' -e '/^$/d' -e 's,^,../,' filelist`
+l=`sed -e '/^[a-z]/!d' -e 's/[ ].*$//' -e 's,^,../,' filelist`
l="$l `echo ../src/include/*.i ../src/utilities/*.c ../test/*/*.c`"
# List of include files for source #defines.
diff --git a/dist/s_funcs b/dist/s_funcs
index 5fee03b5615..8695c8d4fa7 100755
--- a/dist/s_funcs
+++ b/dist/s_funcs
@@ -5,7 +5,7 @@ t=__wt.$$
trap 'rm -f $t; exit 0' 0 1 2 3 13 15
# List of files to search.
-l=`sed -e 's,#.*,,' -e '/^$/d' -e 's,^,../,' filelist`
+l=`sed -e '/^[a-z]/!d' -e 's/[ ].*$//' -e 's,^,../,' filelist`
l="$l `echo ../src/*/*.i ../src/utilities/*.c ../bench/wtperf/*.c`"
(
diff --git a/dist/s_prototypes b/dist/s_prototypes
index aa66d06dbe0..01d1e9bb4c3 100755
--- a/dist/s_prototypes
+++ b/dist/s_prototypes
@@ -47,7 +47,7 @@ EOF
# signatures are on multiple lines, that is, #ifdef'd function signatures. Since
# the OS directories are the only places with repeated names, and they have no
# #ifdef'd signatures, we do it this way.
-l=`sed -e '/^[a-z]/!d' -e '/src\/os/d' filelist`
+l=`sed -e '/^[a-z]/!d' -e '/src\/os/d' -e 's/[ ].*$//' filelist`
for i in $l; do
proto ../$i
done
diff --git a/dist/s_stat b/dist/s_stat
index 3938b8e65eb..0638a7f3337 100755
--- a/dist/s_stat
+++ b/dist/s_stat
@@ -8,8 +8,8 @@ trap 'rm -f $t; exit 0' 0 1 2 3 13 15
# definition.
l=`sed \
-e '/src\/support\/stat.c/d' \
- -e 's,#.*,,' \
- -e '/^$/d' \
+ -e '/^[a-z]/!d' \
+ -e 's/[ ].*$//' \
-e 's,^,../,' filelist`
l="$l `echo ../src/include/*.i ../src/include/os.h`"
diff --git a/dist/s_string.ok b/dist/s_string.ok
index 2cceccc538e..d45cace728a 100644
--- a/dist/s_string.ok
+++ b/dist/s_string.ok
@@ -442,6 +442,7 @@ bzDecompressInit
bzalloc
bzfree
bzip
+call's
calloc
cas
catfmt
diff --git a/dist/s_typedef b/dist/s_typedef
index 233f432f0e5..b044a0e6b4b 100755
--- a/dist/s_typedef
+++ b/dist/s_typedef
@@ -44,7 +44,7 @@ build() {
check() {
# Complain about unused #typedefs.
# List of files to search.
- l=`sed -e 's,#.*,,' -e '/^$/d' -e 's,^,../,' filelist`
+ l=`sed -e '/^[a-z]/!d' -e 's/[ ].*$//' -e 's,^,../,' filelist`
l="$l `echo ../src/utilities/*.c`"
(
diff --git a/dist/s_win b/dist/s_win
index 7fe525c202d..49deb348bc3 100755
--- a/dist/s_win
+++ b/dist/s_win
@@ -39,42 +39,7 @@ win_export()
(echo "Building $f" && rm -f $f && cp $t $f)
}
-win_filelist()
-{
- f='../build_win/filelist.win'
-
- # Discard POSIX-only and PPC-only files, add in Windows-only files.
- (
- sed \
- -e '/\/os_posix\//d' \
- -e '/src\/checksum\/power8\/crc32.S/d' \
- -e '/src\/checksum\/power8\/crc32_wrapper.c/d'
-
- echo 'src/os_win/os_dir.c'
- echo 'src/os_win/os_dlopen.c'
- echo 'src/os_win/os_errno.c'
- echo 'src/os_win/os_fs.c'
- echo 'src/os_win/os_getenv.c'
- echo 'src/os_win/os_map.c'
- echo 'src/os_win/os_mtx_cond.c'
- echo 'src/os_win/os_once.c'
- echo 'src/os_win/os_pagesize.c'
- echo 'src/os_win/os_path.c'
- echo 'src/os_win/os_priv.c'
- echo 'src/os_win/os_setvbuf.c'
- echo 'src/os_win/os_sleep.c'
- echo 'src/os_win/os_snprintf.c'
- echo 'src/os_win/os_thread.c'
- echo 'src/os_win/os_time.c'
- echo 'src/os_win/os_vsnprintf.c'
- echo 'src/os_win/os_yield.c') < filelist | sort > $t
-
- cmp $t $f > /dev/null 2>&1 ||
- (echo "Building $f" && rm -f $f && cp $t $f)
-}
-
win_config
win_export
-win_filelist
exit 0
diff --git a/src/btree/bt_sync.c b/src/btree/bt_sync.c
index 5d60c436a08..4404069e507 100644
--- a/src/btree/bt_sync.c
+++ b/src/btree/bt_sync.c
@@ -96,8 +96,10 @@ __sync_file(WT_SESSION_IMPL *session, WT_CACHE_OP syncop)
* snapshot now.
*
* All changes committed up to this point should be included.
- * We don't update the snapshot in between pages because (a)
- * the metadata shouldn't be that big, and (b) if we do ever
+ * We don't update the snapshot in between pages because the
+ * metadata shouldn't have many pages. Instead, read-committed
+ * isolation ensures that all metadata updates completed before
+ * the checkpoint are included.
*/
if (txn->isolation == WT_ISO_READ_COMMITTED)
WT_ERR(__wt_txn_get_snapshot(session));
diff --git a/src/cache/cache_las.c b/src/cache/cache_las.c
index fd541458fa8..27c2900fa98 100644
--- a/src/cache/cache_las.c
+++ b/src/cache/cache_las.c
@@ -42,6 +42,17 @@ __wt_las_stats_update(WT_SESSION_IMPL *session)
WT_STAT_SET(session, cstats, cache_lookaside_insert, v);
v = WT_STAT_READ(dstats, cursor_remove);
WT_STAT_SET(session, cstats, cache_lookaside_remove, v);
+ /*
+ * If we're clearing stats we need to clear the cursor values we just
+ * read. This does not clear the rest of the statistics in the
+ * lookaside data source stat cursor, but we own that namespace so we
+ * don't have to worry about users seeing inconsistent data source
+ * information.
+ */
+ if (FLD_ISSET(conn->stat_flags, WT_CONN_STAT_CLEAR)) {
+ WT_STAT_SET(session, dstats, cursor_insert, 0);
+ WT_STAT_SET(session, dstats, cursor_remove, 0);
+ }
}
/*
diff --git a/src/checksum/power8/crc32.S b/src/checksum/power8/crc32.S
index f990acb7b12..0b7870668b5 100644
--- a/src/checksum/power8/crc32.S
+++ b/src/checksum/power8/crc32.S
@@ -773,6 +773,6 @@ FUNC_END(__crc32_vpmsum)
/*
* Make sure the stack isn't executable with GCC (regardless of platform).
*/
-#ifndef __clang__
+#ifdef __ELF__
.section .note.GNU-stack,"",@progbits
#endif
diff --git a/src/include/log.h b/src/include/log.h
index 387d0c6c154..7655cfbb3e9 100644
--- a/src/include/log.h
+++ b/src/include/log.h
@@ -257,6 +257,7 @@ struct __wt_log {
uint64_t write_calls; /* Calls to log_write */
#endif
+#define WT_LOG_NOT_VERIFIED 0x1 /* Log just started */
uint32_t flags;
};
diff --git a/src/include/os.h b/src/include/os.h
index 1e08683bc83..dd9b96f73a8 100644
--- a/src/include/os.h
+++ b/src/include/os.h
@@ -9,15 +9,26 @@
#define WT_SYSCALL_RETRY(call, ret) do { \
int __retry; \
for (__retry = 0; __retry < 10; ++__retry) { \
- if ((call) == 0) { \
- (ret) = 0; \
- break; \
- } \
- switch ((ret) = __wt_errno()) { \
- case 0: \
- /* The call failed but didn't set errno. */ \
- (ret) = WT_ERROR; \
+ /* \
+ * A call returning 0 indicates success; any call where \
+ * 0 is not the only successful return must provide an \
+ * expression evaluating to 0 in all successful cases. \
+ */ \
+ if (((ret) = (call)) == 0) \
break; \
+ /* \
+ * The call's error was either returned by the call or \
+ * is in errno, and there are cases where it depends on \
+ * the software release as to which it is (for example, \
+ * posix_fadvise on FreeBSD and OS X). Failing calls \
+ * must either return a non-zero error value, or -1 if \
+ * the error value is in errno. (The WiredTiger errno \
+ * function returns WT_ERROR if errno is 0, which isn't \
+ * ideal but won't discard the failure.) \
+ */ \
+ if ((ret) == -1) \
+ (ret) = __wt_errno(); \
+ switch (ret) { \
case EAGAIN: \
case EBUSY: \
case EINTR: \
diff --git a/src/log/log.c b/src/log/log.c
index 01bfb97718f..56e9f65f914 100644
--- a/src/log/log.c
+++ b/src/log/log.c
@@ -1090,6 +1090,7 @@ __wt_log_open(WT_SESSION_IMPL *session)
logcount = 0;
lastlog = 0;
firstlog = UINT32_MAX;
+ F_SET(log, WT_LOG_NOT_VERIFIED);
/*
* Open up a file handle to the log directory if we haven't.
@@ -1744,6 +1745,22 @@ advance:
&rd_lsn, WT_LOG_FILENAME, 0));
err: WT_STAT_FAST_CONN_INCR(session, log_scans);
+ /*
+ * If the first attempt to read a log record results in
+ * an error recovery is likely going to fail. Try to provide
+ * a helpful failure message.
+ */
+ if (ret != 0 && F_ISSET(log, WT_LOG_NOT_VERIFIED)) {
+ __wt_errx(session,
+ "WiredTiger is unable to read the recovery log.");
+ __wt_errx(session, "This may be due to the log"
+ " files being encrypted, being from an older"
+ " version or due to corruption on disk");
+ __wt_errx(session, "You should confirm that you have"
+ " opened the database with the correct options including"
+ " all encryption and compression options");
+ }
+ F_CLR(log, WT_LOG_NOT_VERIFIED);
WT_TRET(__wt_fs_directory_list_free(session, &logfiles, logcount));
diff --git a/src/os_posix/os_dir.c b/src/os_posix/os_dir.c
index a23051e5b93..ea0ca11fa54 100644
--- a/src/os_posix/os_dir.c
+++ b/src/os_posix/os_dir.c
@@ -38,7 +38,7 @@ __wt_posix_directory_list(WT_FILE_SYSTEM *file_system,
dirallocsz = 0;
entries = NULL;
- WT_SYSCALL_RETRY(((dirp = opendir(directory)) == NULL ? 1 : 0), ret);
+ WT_SYSCALL_RETRY(((dirp = opendir(directory)) == NULL ? -1 : 0), ret);
if (ret != 0)
WT_RET_MSG(session, ret,
"%s: directory-list: opendir", directory);
diff --git a/src/os_posix/os_fs.c b/src/os_posix/os_fs.c
index c05f75f2bd5..1cfa8fd2d2d 100644
--- a/src/os_posix/os_fs.c
+++ b/src/os_posix/os_fs.c
@@ -53,7 +53,7 @@ __posix_sync(
* "This is currently implemented on HFS, MS-DOS (FAT), and Universal
* Disk Format (UDF) file systems."
*/
- WT_SYSCALL_RETRY(fcntl(fd, F_FULLFSYNC, 0), ret);
+ WT_SYSCALL_RETRY(fcntl(fd, F_FULLFSYNC, 0) == -1 ? -1 : 0, ret);
if (ret == 0)
return (0);
/*
@@ -92,7 +92,7 @@ __posix_directory_sync(
session = (WT_SESSION_IMPL *)wt_session;
WT_SYSCALL_RETRY((
- (fd = open(path, O_RDONLY, 0444)) == -1 ? 1 : 0), ret);
+ (fd = open(path, O_RDONLY, 0444)) == -1 ? -1 : 0), ret);
if (ret != 0)
WT_RET_MSG(session, ret, "%s: directory-sync: open", path);
@@ -151,10 +151,17 @@ __posix_fs_remove(
session = (WT_SESSION_IMPL *)wt_session;
- WT_SYSCALL_RETRY(remove(name), ret);
+ /*
+ * ISO C doesn't require remove return -1 on failure or set errno (note
+ * POSIX 1003.1 extends C with those requirements). Regardless, use the
+ * unlink system call, instead of remove, to simplify error handling;
+ * where we're not doing any special checking for standards compliance,
+ * using unlink may be marginally safer.
+ */
+ WT_SYSCALL_RETRY(unlink(name), ret);
if (ret == 0)
return (0);
- WT_RET_MSG(session, ret, "%s: file-remove: remove", name);
+ WT_RET_MSG(session, ret, "%s: file-remove: unlink", name);
}
/*
@@ -172,7 +179,14 @@ __posix_fs_rename(WT_FILE_SYSTEM *file_system,
session = (WT_SESSION_IMPL *)wt_session;
- WT_SYSCALL_RETRY(rename(from, to), ret);
+ /*
+ * ISO C doesn't require rename return -1 on failure or set errno (note
+ * POSIX 1003.1 extends C with those requirements). Be cautious, force
+ * any non-zero return to -1 so we'll check errno. We can still end up
+ * with the wrong errno (if errno is garbage), or the generic WT_ERROR
+ * return (if errno is 0), but we've done the best we can.
+ */
+ WT_SYSCALL_RETRY(rename(from, to) != 0 ? -1 : 0, ret);
if (ret == 0)
return (0);
WT_RET_MSG(session, ret, "%s to %s: file-rename: rename", from, to);
@@ -295,7 +309,7 @@ __posix_file_lock(
fl.l_type = lock ? F_WRLCK : F_UNLCK;
fl.l_whence = SEEK_SET;
- WT_SYSCALL_RETRY(fcntl(pfh->fd, F_SETLK, &fl), ret);
+ WT_SYSCALL_RETRY(fcntl(pfh->fd, F_SETLK, &fl) == -1 ? -1 : 0, ret);
if (ret == 0)
return (0);
WT_RET_MSG(session, ret, "%s: handle-lock: fcntl", file_handle->name);
@@ -533,7 +547,7 @@ __posix_open_file(WT_FILE_SYSTEM *file_system, WT_SESSION *wt_session,
f |= O_CLOEXEC;
#endif
WT_SYSCALL_RETRY((
- (pfh->fd = open(name, f, 0444)) == -1 ? 1 : 0), ret);
+ (pfh->fd = open(name, f, 0444)) == -1 ? -1 : 0), ret);
if (ret != 0)
WT_ERR_MSG(session, ret, "%s: handle-open: open", name);
WT_ERR(__posix_open_file_cloexec(session, pfh->fd, name));
@@ -587,7 +601,7 @@ __posix_open_file(WT_FILE_SYSTEM *file_system, WT_SESSION *wt_session,
#endif
}
- WT_SYSCALL_RETRY(((pfh->fd = open(name, f, mode)) == -1 ? 1 : 0), ret);
+ WT_SYSCALL_RETRY(((pfh->fd = open(name, f, mode)) == -1 ? -1 : 0), ret);
if (ret != 0)
WT_ERR_MSG(session, ret,
pfh->direct_io ?
diff --git a/src/os_posix/os_map.c b/src/os_posix/os_map.c
index 9cdb58b95c8..d89ba4d7c26 100644
--- a/src/os_posix/os_map.c
+++ b/src/os_posix/os_map.c
@@ -102,10 +102,13 @@ __wt_posix_map_preload(WT_FILE_HANDLE *fh,
* size, so we will be conservative.
*/
length &= ~(size_t)(conn->page_size - 1);
+ if (length <= (size_t)conn->page_size)
+ return (0);
- if (length <= (size_t)conn->page_size ||
- (ret = posix_madvise(blk, length, POSIX_MADV_WILLNEED)) == 0)
+ WT_SYSCALL_RETRY(posix_madvise(blk, length, POSIX_MADV_WILLNEED), ret);
+ if (ret == 0)
return (0);
+
WT_RET_MSG(session, ret,
"%s: memory-map preload: posix_madvise: POSIX_MADV_WILLNEED",
fh->name);
@@ -135,8 +138,10 @@ __wt_posix_map_discard(WT_FILE_HANDLE *fh,
blk = (void *)((uintptr_t)map & ~(uintptr_t)(conn->page_size - 1));
length += WT_PTRDIFF(map, blk);
- if ((ret = posix_madvise(blk, length, POSIX_MADV_DONTNEED)) == 0)
+ WT_SYSCALL_RETRY(posix_madvise(blk, length, POSIX_MADV_DONTNEED), ret);
+ if (ret == 0)
return (0);
+
WT_RET_MSG(session, ret,
"%s: memory-map discard: posix_madvise: POSIX_MADV_DONTNEED",
fh->name);
diff --git a/src/os_win/os_fs.c b/src/os_win/os_fs.c
index c4a1235b61b..4da60d5ffb0 100644
--- a/src/os_win/os_fs.c
+++ b/src/os_win/os_fs.c
@@ -169,11 +169,6 @@ __win_file_lock(
* WiredTiger requires this function be able to acquire locks past
* the end of file.
*
- * Note we're using fcntl(2) locking: all fcntl locks associated with a
- * file for a given process are removed when any file descriptor for the
- * file is closed by the process, even if a lock was never requested for
- * that file descriptor.
- *
* http://msdn.microsoft.com/
* en-us/library/windows/desktop/aa365202%28v=vs.85%29.aspx
*