From 4898cb582633fd686c3057824ce0d1713284d15d Mon Sep 17 00:00:00 2001 From: Michael Cahill Date: Fri, 25 Sep 2015 16:53:44 +1000 Subject: Import wiredtiger-wiredtiger-2.6.1-1231-g10208e8.tar.gz from wiredtiger branch mongodb-3.2 --- .../bench/wtperf/runners/log-append-large.wtperf | 1 - src/third_party/wiredtiger/bench/wtperf/wtperf.c | 2 +- src/third_party/wiredtiger/dist/api_data.py | 5 +- src/third_party/wiredtiger/dist/log.py | 3 +- src/third_party/wiredtiger/dist/s_define.list | 15 +- src/third_party/wiredtiger/dist/s_string.ok | 2 + src/third_party/wiredtiger/dist/stat_data.py | 2 + src/third_party/wiredtiger/src/async/async_api.c | 23 +- src/third_party/wiredtiger/src/block/block_addr.c | 2 +- src/third_party/wiredtiger/src/block/block_ckpt.c | 46 +- .../wiredtiger/src/block/block_compact.c | 18 +- src/third_party/wiredtiger/src/block/block_ext.c | 35 +- src/third_party/wiredtiger/src/block/block_mgr.c | 42 +- src/third_party/wiredtiger/src/block/block_open.c | 19 +- src/third_party/wiredtiger/src/block/block_read.c | 4 +- src/third_party/wiredtiger/src/block/block_slvg.c | 6 +- src/third_party/wiredtiger/src/block/block_vrfy.c | 30 +- src/third_party/wiredtiger/src/block/block_write.c | 22 +- src/third_party/wiredtiger/src/btree/bt_compact.c | 18 +- src/third_party/wiredtiger/src/btree/bt_curnext.c | 24 +- src/third_party/wiredtiger/src/btree/bt_curprev.c | 22 +- src/third_party/wiredtiger/src/btree/bt_cursor.c | 90 +-- src/third_party/wiredtiger/src/btree/bt_debug.c | 28 +- src/third_party/wiredtiger/src/btree/bt_delete.c | 8 +- src/third_party/wiredtiger/src/btree/bt_discard.c | 8 +- src/third_party/wiredtiger/src/btree/bt_handle.c | 47 +- src/third_party/wiredtiger/src/btree/bt_huffman.c | 4 +- src/third_party/wiredtiger/src/btree/bt_io.c | 19 +- src/third_party/wiredtiger/src/btree/bt_misc.c | 6 +- src/third_party/wiredtiger/src/btree/bt_ovfl.c | 2 +- src/third_party/wiredtiger/src/btree/bt_page.c | 4 +- src/third_party/wiredtiger/src/btree/bt_read.c | 25 +- src/third_party/wiredtiger/src/btree/bt_ret.c | 2 +- src/third_party/wiredtiger/src/btree/bt_slvg.c | 72 +-- src/third_party/wiredtiger/src/btree/bt_split.c | 225 +++++--- src/third_party/wiredtiger/src/btree/bt_stat.c | 8 +- src/third_party/wiredtiger/src/btree/bt_sync.c | 15 +- src/third_party/wiredtiger/src/btree/bt_vrfy.c | 33 +- src/third_party/wiredtiger/src/btree/bt_vrfy_dsk.c | 17 +- src/third_party/wiredtiger/src/btree/bt_walk.c | 10 +- src/third_party/wiredtiger/src/btree/col_modify.c | 12 +- src/third_party/wiredtiger/src/btree/row_key.c | 6 +- src/third_party/wiredtiger/src/btree/row_modify.c | 10 +- src/third_party/wiredtiger/src/btree/row_srch.c | 21 +- src/third_party/wiredtiger/src/cache/cache_las.c | 2 +- src/third_party/wiredtiger/src/config/config.c | 22 +- .../wiredtiger/src/config/config_check.c | 26 +- .../wiredtiger/src/config/config_collapse.c | 12 +- src/third_party/wiredtiger/src/conn/conn_api.c | 45 +- src/third_party/wiredtiger/src/conn/conn_cache.c | 12 +- .../wiredtiger/src/conn/conn_cache_pool.c | 58 +- src/third_party/wiredtiger/src/conn/conn_ckpt.c | 16 +- src/third_party/wiredtiger/src/conn/conn_dhandle.c | 50 +- src/third_party/wiredtiger/src/conn/conn_handle.c | 2 +- src/third_party/wiredtiger/src/conn/conn_log.c | 78 +-- src/third_party/wiredtiger/src/conn/conn_open.c | 9 +- src/third_party/wiredtiger/src/conn/conn_stat.c | 41 +- src/third_party/wiredtiger/src/conn/conn_sweep.c | 14 +- src/third_party/wiredtiger/src/cursor/cur_backup.c | 50 +- src/third_party/wiredtiger/src/cursor/cur_bulk.c | 8 +- src/third_party/wiredtiger/src/cursor/cur_dump.c | 27 +- src/third_party/wiredtiger/src/cursor/cur_file.c | 34 +- src/third_party/wiredtiger/src/cursor/cur_index.c | 6 +- src/third_party/wiredtiger/src/cursor/cur_json.c | 85 +-- src/third_party/wiredtiger/src/cursor/cur_std.c | 22 +- src/third_party/wiredtiger/src/cursor/cur_table.c | 115 ++-- src/third_party/wiredtiger/src/evict/evict_file.c | 6 +- src/third_party/wiredtiger/src/evict/evict_lru.c | 74 +-- src/third_party/wiredtiger/src/evict/evict_page.c | 25 +- src/third_party/wiredtiger/src/include/api.h | 2 +- src/third_party/wiredtiger/src/include/block.h | 24 +- src/third_party/wiredtiger/src/include/btmem.h | 19 +- src/third_party/wiredtiger/src/include/btree.h | 6 +- src/third_party/wiredtiger/src/include/btree.i | 68 ++- src/third_party/wiredtiger/src/include/cache.i | 15 +- src/third_party/wiredtiger/src/include/cell.i | 11 +- src/third_party/wiredtiger/src/include/cursor.h | 4 +- src/third_party/wiredtiger/src/include/cursor.i | 6 +- src/third_party/wiredtiger/src/include/dhandle.h | 2 + src/third_party/wiredtiger/src/include/extern.h | 188 +++--- src/third_party/wiredtiger/src/include/misc.h | 27 +- src/third_party/wiredtiger/src/include/misc.i | 4 +- src/third_party/wiredtiger/src/include/os.h | 2 +- src/third_party/wiredtiger/src/include/packing.i | 4 +- src/third_party/wiredtiger/src/include/schema.h | 2 +- src/third_party/wiredtiger/src/include/serial.i | 8 +- src/third_party/wiredtiger/src/include/stat.h | 1 + src/third_party/wiredtiger/src/include/txn.i | 4 +- .../wiredtiger/src/include/wiredtiger.in | 120 ++-- src/third_party/wiredtiger/src/log/log.c | 155 +++-- src/third_party/wiredtiger/src/log/log_auto.c | 3 +- src/third_party/wiredtiger/src/log/log_slot.c | 83 ++- src/third_party/wiredtiger/src/lsm/lsm_cursor.c | 112 ++-- .../wiredtiger/src/lsm/lsm_cursor_bulk.c | 18 +- src/third_party/wiredtiger/src/lsm/lsm_manager.c | 16 +- src/third_party/wiredtiger/src/lsm/lsm_merge.c | 27 +- src/third_party/wiredtiger/src/lsm/lsm_meta.c | 6 +- src/third_party/wiredtiger/src/lsm/lsm_stat.c | 8 +- src/third_party/wiredtiger/src/lsm/lsm_tree.c | 107 ++-- src/third_party/wiredtiger/src/lsm/lsm_work_unit.c | 29 +- src/third_party/wiredtiger/src/lsm/lsm_worker.c | 16 +- src/third_party/wiredtiger/src/meta/meta_apply.c | 4 +- src/third_party/wiredtiger/src/meta/meta_table.c | 4 +- src/third_party/wiredtiger/src/meta/meta_track.c | 10 +- src/third_party/wiredtiger/src/meta/meta_turtle.c | 16 +- src/third_party/wiredtiger/src/os_posix/os_dir.c | 6 +- .../wiredtiger/src/os_posix/os_dlopen.c | 2 +- src/third_party/wiredtiger/src/os_posix/os_exist.c | 6 +- src/third_party/wiredtiger/src/os_posix/os_flock.c | 2 +- .../wiredtiger/src/os_posix/os_mtx_cond.c | 20 +- src/third_party/wiredtiger/src/os_posix/os_open.c | 17 +- src/third_party/wiredtiger/src/os_posix/os_priv.c | 2 +- src/third_party/wiredtiger/src/os_win/os_dir.c | 6 +- src/third_party/wiredtiger/src/os_win/os_dlopen.c | 2 +- src/third_party/wiredtiger/src/os_win/os_exist.c | 6 +- src/third_party/wiredtiger/src/os_win/os_flock.c | 2 +- .../wiredtiger/src/os_win/os_mtx_cond.c | 20 +- src/third_party/wiredtiger/src/os_win/os_open.c | 17 +- src/third_party/wiredtiger/src/os_win/os_priv.c | 2 +- src/third_party/wiredtiger/src/packing/pack_impl.c | 2 +- .../wiredtiger/src/reconcile/rec_write.c | 642 +++++++++++---------- .../wiredtiger/src/schema/schema_create.c | 84 ++- .../wiredtiger/src/schema/schema_drop.c | 26 +- .../wiredtiger/src/schema/schema_list.c | 4 +- .../wiredtiger/src/schema/schema_open.c | 30 +- .../wiredtiger/src/schema/schema_plan.c | 32 +- .../wiredtiger/src/schema/schema_project.c | 9 +- .../wiredtiger/src/schema/schema_rename.c | 10 +- .../wiredtiger/src/schema/schema_stat.c | 7 +- .../wiredtiger/src/schema/schema_truncate.c | 4 +- .../wiredtiger/src/schema/schema_worker.c | 18 +- .../wiredtiger/src/session/session_api.c | 37 +- .../wiredtiger/src/session/session_compact.c | 4 +- .../wiredtiger/src/session/session_dhandle.c | 76 ++- src/third_party/wiredtiger/src/support/err.c | 19 +- src/third_party/wiredtiger/src/support/filename.c | 2 +- src/third_party/wiredtiger/src/support/global.c | 8 +- src/third_party/wiredtiger/src/support/hazard.c | 12 +- src/third_party/wiredtiger/src/support/huffman.c | 3 +- src/third_party/wiredtiger/src/support/scratch.c | 6 +- src/third_party/wiredtiger/src/support/stat.c | 3 + src/third_party/wiredtiger/src/txn/txn.c | 5 +- src/third_party/wiredtiger/src/txn/txn_ckpt.c | 75 ++- src/third_party/wiredtiger/src/txn/txn_log.c | 21 +- src/third_party/wiredtiger/src/txn/txn_nsnap.c | 22 +- src/third_party/wiredtiger/src/txn/txn_recover.c | 31 +- src/third_party/wiredtiger/src/utilities/util.h | 4 +- .../wiredtiger/src/utilities/util_backup.c | 4 +- .../wiredtiger/src/utilities/util_dump.c | 48 +- .../wiredtiger/src/utilities/util_list.c | 17 +- .../wiredtiger/src/utilities/util_load.c | 54 +- .../wiredtiger/src/utilities/util_load_json.c | 31 +- .../wiredtiger/src/utilities/util_loadtext.c | 19 +- .../wiredtiger/src/utilities/util_main.c | 12 +- .../wiredtiger/src/utilities/util_misc.c | 6 +- .../wiredtiger/src/utilities/util_printlog.c | 7 +- .../wiredtiger/src/utilities/util_read.c | 11 +- .../wiredtiger/src/utilities/util_stat.c | 7 +- .../wiredtiger/src/utilities/util_verify.c | 13 +- .../wiredtiger/src/utilities/util_write.c | 11 +- 160 files changed, 2435 insertions(+), 2094 deletions(-) (limited to 'src/third_party/wiredtiger') diff --git a/src/third_party/wiredtiger/bench/wtperf/runners/log-append-large.wtperf b/src/third_party/wiredtiger/bench/wtperf/runners/log-append-large.wtperf index e7210d9e87a..c1364c17c28 100644 --- a/src/third_party/wiredtiger/bench/wtperf/runners/log-append-large.wtperf +++ b/src/third_party/wiredtiger/bench/wtperf/runners/log-append-large.wtperf @@ -8,4 +8,3 @@ report_interval=5 run_time=0 value_sz=5000000 populate_threads=8 - diff --git a/src/third_party/wiredtiger/bench/wtperf/wtperf.c b/src/third_party/wiredtiger/bench/wtperf/wtperf.c index 5d3b334785d..8dceeab2832 100644 --- a/src/third_party/wiredtiger/bench/wtperf/wtperf.c +++ b/src/third_party/wiredtiger/bench/wtperf/wtperf.c @@ -1171,7 +1171,7 @@ monitor(void *arg) if (latency_max != 0 && (read_max > latency_max || insert_max > latency_max || update_max > latency_max)) - lprintf(cfg, WT_PANIC, 0, + lprintf(cfg, 0, 0, "max latency exceeded: threshold %" PRIu32 " read max %" PRIu32 " insert max %" PRIu32 " update max %" PRIu32, latency_max, diff --git a/src/third_party/wiredtiger/dist/api_data.py b/src/third_party/wiredtiger/dist/api_data.py index 494e8f91a9a..5652edc4ebe 100644 --- a/src/third_party/wiredtiger/dist/api_data.py +++ b/src/third_party/wiredtiger/dist/api_data.py @@ -271,7 +271,10 @@ file_config = format_meta + [ leaf pages''', min=0), Config('split_deepen_min_child', '0', r''' - minimum entries in a page to consider deepening the tree''', + minimum entries in a page to consider deepening the tree. Pages + will be considered for splitting and deepening the search tree + as soon as there are more than the configured number of children + ''', type='int', undoc=True), Config('split_deepen_per_child', '0', r''' entries allocated per child when deepening the tree''', diff --git a/src/third_party/wiredtiger/dist/log.py b/src/third_party/wiredtiger/dist/log.py index da4a9c10727..feeb053db3e 100644 --- a/src/third_party/wiredtiger/dist/log.py +++ b/src/third_party/wiredtiger/dist/log.py @@ -159,7 +159,8 @@ __logrec_json_unpack_str(char *dest, size_t destlen, const char *src, \ttotal = 0; \twhile (srclen > 0) { -\t\tn = __wt_json_unpack_char(*src++, (u_char *)dest, destlen, 0); +\t\tn = __wt_json_unpack_char( +\t\t *src++, (u_char *)dest, destlen, false); \t\tsrclen--; \t\tif (n > destlen) \t\t\tdestlen = 0; diff --git a/src/third_party/wiredtiger/dist/s_define.list b/src/third_party/wiredtiger/dist/s_define.list index 8cca4471e8b..dce284dae44 100644 --- a/src/third_party/wiredtiger/dist/s_define.list +++ b/src/third_party/wiredtiger/dist/s_define.list @@ -3,12 +3,8 @@ ALIGN_CHECK API_CALL API_CALL_NOCONF API_SESSION_INIT -FLD_CLR -F_CAS_ATOMIC -F_CLR_ATOMIC -F_SET_ATOMIC -LF_CLR -LF_SET +FLD_MASK +LF_MASK LLONG_MAX LLONG_MIN SIZE_CHECK @@ -18,12 +14,10 @@ TXN_API_END WIN32_LEAN_AND_MEAN WT_ATOMIC_CAS WT_ATOMIC_FUNC -WT_BARRIER WT_BLOCK_DESC_SIZE WT_CACHE_LINE_ALIGNMENT WT_COMPILER_TYPE_ALIGN WT_CONN_CHECK_PANIC -WT_COUNTER_SLOTS WT_DEADLOCK WT_DEBUG_BYTE WT_ERR_ERROR_OK @@ -40,10 +34,7 @@ WT_PACKED_STRUCT_BEGIN WT_PACKED_STRUCT_END WT_READ_BARRIER WT_REF_SIZE -WT_RET_ERROR_OK WT_SESSION_LOCKED_CHECKPOINT -WT_STATS_FIELD_TO_SLOT -WT_STATS_SLOT_ID WT_STAT_DECR WT_STAT_DECRV WT_STAT_FAST_CONN_DECRV @@ -53,6 +44,8 @@ WT_STAT_FAST_DECRV WT_STAT_FAST_INCR WT_STAT_FAST_INCRV WT_STAT_FAST_SET +WT_STATS_FIELD_TO_SLOT +WT_STATS_SLOT_ID WT_STAT_WRITE WT_TRET_ERROR_OK WT_WITH_LOCK diff --git a/src/third_party/wiredtiger/dist/s_string.ok b/src/third_party/wiredtiger/dist/s_string.ok index 4419662b9c4..bfc4124f74d 100644 --- a/src/third_party/wiredtiger/dist/s_string.ok +++ b/src/third_party/wiredtiger/dist/s_string.ok @@ -302,6 +302,7 @@ UnixLib Unmap UnmapViewOfFile Unmarshall +Unordered Uryyb VARCHAR VLDB @@ -967,6 +968,7 @@ unmarshall unmarshalled unmerged unmodify +unordered unpackv unpadded unreferenced diff --git a/src/third_party/wiredtiger/dist/stat_data.py b/src/third_party/wiredtiger/dist/stat_data.py index accab6bb351..5bf7000f402 100644 --- a/src/third_party/wiredtiger/dist/stat_data.py +++ b/src/third_party/wiredtiger/dist/stat_data.py @@ -253,6 +253,8 @@ connection_stats = [ LogStat('log_prealloc_files', 'pre-allocated log files prepared'), LogStat('log_prealloc_max', 'number of pre-allocated log files to create', 'no_clear,no_scale'), + LogStat('log_prealloc_missed', + 'pre-allocated log files not ready and missed'), LogStat('log_prealloc_used', 'pre-allocated log files used'), LogStat('log_release_write_lsn', 'log release advances write LSN'), LogStat('log_scan_records', 'records processed by log scan'), diff --git a/src/third_party/wiredtiger/src/async/async_api.c b/src/third_party/wiredtiger/src/async/async_api.c index 416c3c84f7b..1d819474728 100644 --- a/src/third_party/wiredtiger/src/async/async_api.c +++ b/src/third_party/wiredtiger/src/async/async_api.c @@ -52,8 +52,8 @@ __async_get_format(WT_CONNECTION_IMPL *conn, const char *uri, * Insert it at the head expecting LRU usage. We need a real session * for the cursor. */ - WT_RET( - __wt_open_internal_session(conn, "async-cursor", 1, 1, &session)); + WT_RET(__wt_open_internal_session( + conn, "async-cursor", true, true, &session)); __wt_spin_lock(session, &async->ops_lock); WT_ERR(__wt_calloc_one(session, &af)); WT_ERR(__wt_strdup(session, uri, &af->uri)); @@ -171,7 +171,7 @@ retry: */ static int __async_config(WT_SESSION_IMPL *session, - WT_CONNECTION_IMPL *conn, const char **cfg, int *runp) + WT_CONNECTION_IMPL *conn, const char **cfg, bool *runp) { WT_CONFIG_ITEM cval; @@ -240,7 +240,8 @@ __async_start(WT_SESSION_IMPL *session) async = conn->async; TAILQ_INIT(&async->formatqh); WT_RET(__wt_spin_init(session, &async->ops_lock, "ops")); - WT_RET(__wt_cond_alloc(session, "async flush", 0, &async->flush_cond)); + WT_RET(__wt_cond_alloc( + session, "async flush", false, &async->flush_cond)); WT_RET(__wt_async_op_init(session)); /* @@ -255,8 +256,8 @@ __async_start(WT_SESSION_IMPL *session) * workers and we may want to selectively stop some workers * while leaving the rest running. */ - WT_RET(__wt_open_internal_session( - conn, "async-worker", 1, 1, &async->worker_sessions[i])); + WT_RET(__wt_open_internal_session(conn, + "async-worker", true, true, &async->worker_sessions[i])); F_SET(async->worker_sessions[i], WT_SESSION_SERVER_ASYNC); } for (i = 0; i < conn->async_workers; i++) { @@ -278,12 +279,12 @@ int __wt_async_create(WT_SESSION_IMPL *session, const char *cfg[]) { WT_CONNECTION_IMPL *conn; - int run; + bool run; conn = S2C(session); /* Handle configuration. */ - run = 0; + run = false; WT_RET(__async_config(session, conn, cfg, &run)); /* If async is not configured, we're done. */ @@ -303,7 +304,7 @@ __wt_async_reconfig(WT_SESSION_IMPL *session, const char *cfg[]) WT_CONNECTION_IMPL *conn, tmp_conn; WT_DECL_RET; WT_SESSION *wt_session; - int run; + bool run; uint32_t i; conn = S2C(session); @@ -370,8 +371,8 @@ __wt_async_reconfig(WT_SESSION_IMPL *session, const char *cfg[]) /* * Each worker has its own session. */ - WT_RET(__wt_open_internal_session(conn, - "async-worker", 1, 1, &async->worker_sessions[i])); + WT_RET(__wt_open_internal_session(conn, "async-worker", + true, true, &async->worker_sessions[i])); F_SET(async->worker_sessions[i], WT_SESSION_SERVER_ASYNC); } diff --git a/src/third_party/wiredtiger/src/block/block_addr.c b/src/third_party/wiredtiger/src/block/block_addr.c index 3099f5ba8dc..6d50e5f0f4e 100644 --- a/src/third_party/wiredtiger/src/block/block_addr.c +++ b/src/third_party/wiredtiger/src/block/block_addr.c @@ -89,7 +89,7 @@ __wt_block_buffer_to_addr(WT_BLOCK *block, */ int __wt_block_addr_invalid(WT_SESSION_IMPL *session, - WT_BLOCK *block, const uint8_t *addr, size_t addr_size, int live) + WT_BLOCK *block, const uint8_t *addr, size_t addr_size, bool live) { wt_off_t offset; uint32_t cksum, size; diff --git a/src/third_party/wiredtiger/src/block/block_ckpt.c b/src/third_party/wiredtiger/src/block/block_ckpt.c index abcad392e33..a23b95233e1 100644 --- a/src/third_party/wiredtiger/src/block/block_ckpt.c +++ b/src/third_party/wiredtiger/src/block/block_ckpt.c @@ -12,7 +12,7 @@ static int __ckpt_process(WT_SESSION_IMPL *, WT_BLOCK *, WT_CKPT *); static int __ckpt_string( WT_SESSION_IMPL *, WT_BLOCK *, const uint8_t *, WT_ITEM *); static int __ckpt_update( - WT_SESSION_IMPL *, WT_BLOCK *, WT_CKPT *, WT_BLOCK_CKPT *, int); + WT_SESSION_IMPL *, WT_BLOCK *, WT_CKPT *, WT_BLOCK_CKPT *, bool); /* * __wt_block_ckpt_init -- @@ -27,12 +27,14 @@ __wt_block_ckpt_init( ci->version = WT_BM_CHECKPOINT_VERSION; ci->root_offset = WT_BLOCK_INVALID_OFFSET; - WT_RET(__wt_block_extlist_init(session, &ci->alloc, name, "alloc", 0)); - WT_RET(__wt_block_extlist_init(session, &ci->avail, name, "avail", 1)); WT_RET(__wt_block_extlist_init( - session, &ci->discard, name, "discard", 0)); + session, &ci->alloc, name, "alloc", false)); WT_RET(__wt_block_extlist_init( - session, &ci->ckpt_avail, name, "ckpt_avail", 1)); + session, &ci->avail, name, "avail", true)); + WT_RET(__wt_block_extlist_init( + session, &ci->discard, name, "discard", false)); + WT_RET(__wt_block_extlist_init( + session, &ci->ckpt_avail, name, "ckpt_avail", true)); return (0); } @@ -44,7 +46,7 @@ __wt_block_ckpt_init( int __wt_block_checkpoint_load(WT_SESSION_IMPL *session, WT_BLOCK *block, const uint8_t *addr, size_t addr_size, - uint8_t *root_addr, size_t *root_addr_sizep, int checkpoint) + uint8_t *root_addr, size_t *root_addr_sizep, bool checkpoint) { WT_BLOCK_CKPT *ci, _ci; WT_DECL_ITEM(tmp); @@ -165,7 +167,7 @@ err: /* */ int __wt_block_checkpoint_unload( - WT_SESSION_IMPL *session, WT_BLOCK *block, int checkpoint) + WT_SESSION_IMPL *session, WT_BLOCK *block, bool checkpoint) { WT_DECL_RET; @@ -217,7 +219,7 @@ __wt_block_ckpt_destroy(WT_SESSION_IMPL *session, WT_BLOCK_CKPT *ci) */ int __wt_block_checkpoint(WT_SESSION_IMPL *session, - WT_BLOCK *block, WT_ITEM *buf, WT_CKPT *ckptbase, int data_cksum) + WT_BLOCK *block, WT_ITEM *buf, WT_CKPT *ckptbase, bool data_cksum) { WT_BLOCK_CKPT *ci; WT_DECL_RET; @@ -225,7 +227,7 @@ __wt_block_checkpoint(WT_SESSION_IMPL *session, ci = &block->live; /* Switch to first-fit allocation. */ - __wt_block_configure_first_fit(block, 1); + __wt_block_configure_first_fit(block, true); /* * Write the root page: it's possible for there to be a checkpoint of @@ -242,7 +244,7 @@ __wt_block_checkpoint(WT_SESSION_IMPL *session, } else WT_ERR(__wt_block_write_off(session, block, buf, &ci->root_offset, &ci->root_size, &ci->root_cksum, - data_cksum, 0)); + data_cksum, false)); /* * Checkpoints are potentially reading/writing/merging lots of blocks, @@ -257,7 +259,7 @@ __wt_block_checkpoint(WT_SESSION_IMPL *session, WT_TRET(__wt_block_ext_discard(session, 250)); /* Restore the original allocation plan. */ -err: __wt_block_configure_first_fit(block, 0); +err: __wt_block_configure_first_fit(block, false); return (ret); } @@ -363,10 +365,10 @@ __ckpt_process(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase) WT_DECL_ITEM(tmp); WT_DECL_RET; uint64_t ckpt_size; - int deleting, locked; + bool deleting, locked; ci = &block->live; - locked = 0; + locked = false; #ifdef HAVE_DIAGNOSTIC WT_RET(__ckpt_verify(session, ckptbase)); @@ -427,7 +429,7 @@ __ckpt_process(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase) */ __wt_block_extlist_free(session, &ci->ckpt_avail); WT_RET(__wt_block_extlist_init( - session, &ci->ckpt_avail, "live", "ckpt_avail", 1)); + session, &ci->ckpt_avail, "live", "ckpt_avail", true)); __wt_block_extlist_free(session, &ci->ckpt_alloc); __wt_block_extlist_free(session, &ci->ckpt_discard); @@ -436,12 +438,12 @@ __ckpt_process(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase) * the subsequent checkpoint into which it gets rolled; read them from * disk before we lock things down. */ - deleting = 0; + deleting = false; WT_CKPT_FOREACH(ckptbase, ckpt) { if (F_ISSET(ckpt, WT_CKPT_FAKE) || !F_ISSET(ckpt, WT_CKPT_DELETE)) continue; - deleting = 1; + deleting = true; /* * Read the checkpoint and next checkpoint extent lists if we @@ -473,7 +475,7 @@ __ckpt_process(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase) * the final merge of ranges into the live tree. */ __wt_spin_lock(session, &block->live_lock); - locked = 1; + locked = true; /* * We've allocated our last page, update the checkpoint size. We need @@ -599,7 +601,7 @@ __ckpt_process(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase) WT_CKPT_FOREACH(ckptbase, ckpt) if (F_ISSET(ckpt, WT_CKPT_UPDATE)) WT_ERR(__ckpt_update( - session, block, ckpt, ckpt->bpriv, 0)); + session, block, ckpt, ckpt->bpriv, false)); live_update: /* Truncate the file if that's possible. */ @@ -620,7 +622,7 @@ live_update: */ ckpt->ckpt_size = ci->ckpt_size = ckpt_size; - WT_ERR(__ckpt_update(session, block, ckpt, ci, 1)); + WT_ERR(__ckpt_update(session, block, ckpt, ci, true)); } /* @@ -631,10 +633,10 @@ live_update: */ ci->ckpt_alloc = ci->alloc; WT_ERR(__wt_block_extlist_init( - session, &ci->alloc, "live", "alloc", 0)); + session, &ci->alloc, "live", "alloc", false)); ci->ckpt_discard = ci->discard; WT_ERR(__wt_block_extlist_init( - session, &ci->discard, "live", "discard", 0)); + session, &ci->discard, "live", "discard", false)); #ifdef HAVE_DIAGNOSTIC /* @@ -675,7 +677,7 @@ err: if (locked) */ static int __ckpt_update(WT_SESSION_IMPL *session, - WT_BLOCK *block, WT_CKPT *ckpt, WT_BLOCK_CKPT *ci, int is_live) + WT_BLOCK *block, WT_CKPT *ckpt, WT_BLOCK_CKPT *ci, bool is_live) { WT_DECL_ITEM(tmp); WT_DECL_RET; diff --git a/src/third_party/wiredtiger/src/block/block_compact.c b/src/third_party/wiredtiger/src/block/block_compact.c index c48f27af243..d45d0a96da7 100644 --- a/src/third_party/wiredtiger/src/block/block_compact.c +++ b/src/third_party/wiredtiger/src/block/block_compact.c @@ -20,7 +20,7 @@ __wt_block_compact_start(WT_SESSION_IMPL *session, WT_BLOCK *block) WT_UNUSED(session); /* Switch to first-fit allocation. */ - __wt_block_configure_first_fit(block, 1); + __wt_block_configure_first_fit(block, true); block->compact_pct_tenths = 0; @@ -37,7 +37,7 @@ __wt_block_compact_end(WT_SESSION_IMPL *session, WT_BLOCK *block) WT_UNUSED(session); /* Restore the original allocation plan. */ - __wt_block_configure_first_fit(block, 0); + __wt_block_configure_first_fit(block, false); block->compact_pct_tenths = 0; @@ -49,7 +49,7 @@ __wt_block_compact_end(WT_SESSION_IMPL *session, WT_BLOCK *block) * Return if compaction will shrink the file. */ int -__wt_block_compact_skip(WT_SESSION_IMPL *session, WT_BLOCK *block, int *skipp) +__wt_block_compact_skip(WT_SESSION_IMPL *session, WT_BLOCK *block, bool *skipp) { WT_DECL_RET; WT_EXT *ext; @@ -57,7 +57,7 @@ __wt_block_compact_skip(WT_SESSION_IMPL *session, WT_BLOCK *block, int *skipp) WT_FH *fh; wt_off_t avail_eighty, avail_ninety, eighty, ninety; - *skipp = 1; /* Return a default skip. */ + *skipp = true; /* Return a default skip. */ fh = block->fh; @@ -119,11 +119,11 @@ __wt_block_compact_skip(WT_SESSION_IMPL *session, WT_BLOCK *block, int *skipp) */ if (avail_eighty > WT_MEGABYTE && avail_eighty >= ((fh->size / 10) * 2)) { - *skipp = 0; + *skipp = false; block->compact_pct_tenths = 2; } else if (avail_ninety > WT_MEGABYTE && avail_ninety >= fh->size / 10) { - *skipp = 0; + *skipp = false; block->compact_pct_tenths = 1; } @@ -138,7 +138,7 @@ err: __wt_spin_unlock(session, &block->live_lock); */ int __wt_block_compact_page_skip(WT_SESSION_IMPL *session, - WT_BLOCK *block, const uint8_t *addr, size_t addr_size, int *skipp) + WT_BLOCK *block, const uint8_t *addr, size_t addr_size, bool *skipp) { WT_DECL_RET; WT_EXT *ext; @@ -148,7 +148,7 @@ __wt_block_compact_page_skip(WT_SESSION_IMPL *session, uint32_t size, cksum; WT_UNUSED(addr_size); - *skipp = 1; /* Return a default skip. */ + *skipp = true; /* Return a default skip. */ fh = block->fh; @@ -170,7 +170,7 @@ __wt_block_compact_page_skip(WT_SESSION_IMPL *session, if (ext->off >= limit) break; if (ext->size >= size) { - *skipp = 0; + *skipp = false; break; } } diff --git a/src/third_party/wiredtiger/src/block/block_ext.c b/src/third_party/wiredtiger/src/block/block_ext.c index 018f6a20164..a56df220390 100644 --- a/src/third_party/wiredtiger/src/block/block_ext.c +++ b/src/third_party/wiredtiger/src/block/block_ext.c @@ -24,7 +24,7 @@ static int __block_append(WT_SESSION_IMPL *, static int __block_ext_overlap(WT_SESSION_IMPL *, WT_BLOCK *, WT_EXTLIST *, WT_EXT **, WT_EXTLIST *, WT_EXT **); static int __block_extlist_dump( - WT_SESSION_IMPL *, const char *, WT_EXTLIST *, int); + WT_SESSION_IMPL *, const char *, WT_EXTLIST *, bool); static int __block_merge(WT_SESSION_IMPL *, WT_BLOCK *, WT_EXTLIST *, wt_off_t, wt_off_t); @@ -59,7 +59,7 @@ __block_off_srch_last(WT_EXT **head, WT_EXT ***stack) * by-offset list referenced by a size entry), for the specified offset. */ static inline void -__block_off_srch(WT_EXT **head, wt_off_t off, WT_EXT ***stack, int skip_off) +__block_off_srch(WT_EXT **head, wt_off_t off, WT_EXT ***stack, bool skip_off) { WT_EXT **extp; int i; @@ -102,7 +102,7 @@ __block_first_srch(WT_EXT **head, wt_off_t size, WT_EXT ***stack) return (false); /* Build a stack for the offset we want. */ - __block_off_srch(head, ext->off, stack, 0); + __block_off_srch(head, ext->off, stack, false); return (true); } @@ -199,7 +199,7 @@ __block_ext_insert(WT_SESSION_IMPL *session, WT_EXTLIST *el, WT_EXT *ext) * Insert the new WT_EXT structure into the size element's * offset skiplist. */ - __block_off_srch(szp->off, ext->off, astack, 1); + __block_off_srch(szp->off, ext->off, astack, true); for (i = 0; i < ext->depth; ++i) { ext->next[i + ext->depth] = *astack[i]; *astack[i] = ext; @@ -212,7 +212,7 @@ __block_ext_insert(WT_SESSION_IMPL *session, WT_EXTLIST *el, WT_EXT *ext) #endif /* Insert the new WT_EXT structure into the offset skiplist. */ - __block_off_srch(el->off, ext->off, astack, 0); + __block_off_srch(el->off, ext->off, astack, false); for (i = 0; i < ext->depth; ++i) { ext->next[i] = *astack[i]; *astack[i] = ext; @@ -273,7 +273,7 @@ __block_off_match(WT_EXTLIST *el, wt_off_t off, wt_off_t size) */ int __wt_block_misplaced(WT_SESSION_IMPL *session, - WT_BLOCK *block, const char *tag, wt_off_t offset, uint32_t size, int live) + WT_BLOCK *block, const char *tag, wt_off_t offset, uint32_t size, bool live) { const char *name; @@ -329,7 +329,7 @@ __block_off_remove(WT_SESSION_IMPL *session, WT_BLOCK *block, u_int i; /* Find and remove the record from the by-offset skiplist. */ - __block_off_srch(el->off, off, astack, 0); + __block_off_srch(el->off, off, astack, false); ext = *astack[0]; if (ext == NULL || ext->off != off) goto corrupt; @@ -345,7 +345,7 @@ __block_off_remove(WT_SESSION_IMPL *session, WT_BLOCK *block, szp = *sstack[0]; if (szp == NULL || szp->size != ext->size) return (EINVAL); - __block_off_srch(szp->off, off, astack, 1); + __block_off_srch(szp->off, off, astack, true); ext = *astack[0]; if (ext == NULL || ext->off != off) goto corrupt; @@ -359,11 +359,11 @@ __block_off_remove(WT_SESSION_IMPL *session, WT_BLOCK *block, } #ifdef HAVE_DIAGNOSTIC if (!el->track_size) { - int not_null; - for (i = 0, not_null = 0; i < ext->depth; ++i) + bool not_null; + for (i = 0, not_null = false; i < ext->depth; ++i) if (ext->next[i + ext->depth] != NULL) - not_null = 1; - WT_ASSERT(session, not_null == 0); + not_null = true; + WT_ASSERT(session, not_null == false); } #endif @@ -603,7 +603,8 @@ __wt_block_free(WT_SESSION_IMPL *session, "free %" PRIdMAX "/%" PRIdMAX, (intmax_t)offset, (intmax_t)size)); #ifdef HAVE_DIAGNOSTIC - WT_RET(__wt_block_misplaced(session, block, "free", offset, size, 1)); + WT_RET( + __wt_block_misplaced(session, block, "free", offset, size, true)); #endif WT_RET(__wt_block_ext_prealloc(session, 5)); __wt_spin_lock(session, &block->live_lock); @@ -1315,8 +1316,8 @@ __wt_block_extlist_write(WT_SESSION_IMPL *session, #endif /* Write the extent list to disk. */ - WT_ERR(__wt_block_write_off( - session, block, tmp, &el->offset, &el->size, &el->cksum, 1, 1)); + WT_ERR(__wt_block_write_off(session, + block, tmp, &el->offset, &el->size, &el->cksum, true, true)); /* * Remove the allocated blocks from the system's allocation list, extent @@ -1386,7 +1387,7 @@ __wt_block_extlist_truncate( */ int __wt_block_extlist_init(WT_SESSION_IMPL *session, - WT_EXTLIST *el, const char *name, const char *extname, int track_size) + WT_EXTLIST *el, const char *name, const char *extname, bool track_size) { size_t size; @@ -1434,7 +1435,7 @@ __wt_block_extlist_free(WT_SESSION_IMPL *session, WT_EXTLIST *el) */ static int __block_extlist_dump( - WT_SESSION_IMPL *session, const char *tag, WT_EXTLIST *el, int show_size) + WT_SESSION_IMPL *session, const char *tag, WT_EXTLIST *el, bool show_size) { WT_EXT *ext; WT_SIZE *szp; diff --git a/src/third_party/wiredtiger/src/block/block_mgr.c b/src/third_party/wiredtiger/src/block/block_mgr.c index 015c574da8c..7260cab75d9 100644 --- a/src/third_party/wiredtiger/src/block/block_mgr.c +++ b/src/third_party/wiredtiger/src/block/block_mgr.c @@ -8,7 +8,7 @@ #include "wt_internal.h" -static void __bm_method_set(WT_BM *, int); +static void __bm_method_set(WT_BM *, bool); /* * __bm_readonly -- @@ -62,7 +62,7 @@ __bm_block_header(WT_BM *bm) */ static int __bm_checkpoint(WT_BM *bm, - WT_SESSION_IMPL *session, WT_ITEM *buf, WT_CKPT *ckptbase, int data_cksum) + WT_SESSION_IMPL *session, WT_ITEM *buf, WT_CKPT *ckptbase, bool data_cksum) { return (__wt_block_checkpoint( session, bm->block, buf, ckptbase, data_cksum)); @@ -73,7 +73,7 @@ __bm_checkpoint(WT_BM *bm, * Flush a file to disk. */ static int -__bm_sync(WT_BM *bm, WT_SESSION_IMPL *session, int async) +__bm_sync(WT_BM *bm, WT_SESSION_IMPL *session, bool async) { return (async ? __wt_fsync_async(session, bm->block->fh) : @@ -87,7 +87,7 @@ __bm_sync(WT_BM *bm, WT_SESSION_IMPL *session, int async) static int __bm_checkpoint_load(WT_BM *bm, WT_SESSION_IMPL *session, const uint8_t *addr, size_t addr_size, - uint8_t *root_addr, size_t *root_addr_sizep, int checkpoint) + uint8_t *root_addr, size_t *root_addr_sizep, bool checkpoint) { WT_CONNECTION_IMPL *conn; @@ -113,7 +113,7 @@ __bm_checkpoint_load(WT_BM *bm, WT_SESSION_IMPL *session, * prevents attempts to write a checkpoint reference, paranoia * is healthy. */ - __bm_method_set(bm, 1); + __bm_method_set(bm, true); } return (0); @@ -183,7 +183,7 @@ __bm_compact_start(WT_BM *bm, WT_SESSION_IMPL *session) */ static int __bm_compact_page_skip(WT_BM *bm, WT_SESSION_IMPL *session, - const uint8_t *addr, size_t addr_size, int *skipp) + const uint8_t *addr, size_t addr_size, bool *skipp) { return (__wt_block_compact_page_skip( session, bm->block, addr, addr_size, skipp)); @@ -194,7 +194,7 @@ __bm_compact_page_skip(WT_BM *bm, WT_SESSION_IMPL *session, * Return if a file can be compacted. */ static int -__bm_compact_skip(WT_BM *bm, WT_SESSION_IMPL *session, int *skipp) +__bm_compact_skip(WT_BM *bm, WT_SESSION_IMPL *session, bool *skipp) { return (__wt_block_compact_skip(session, bm->block, skipp)); } @@ -237,7 +237,7 @@ __bm_stat(WT_BM *bm, WT_SESSION_IMPL *session, WT_DSRC_STATS *stats) */ static int __bm_write(WT_BM *bm, WT_SESSION_IMPL *session, - WT_ITEM *buf, uint8_t *addr, size_t *addr_sizep, int data_cksum) + WT_ITEM *buf, uint8_t *addr, size_t *addr_sizep, bool data_cksum) { return (__wt_block_write( session, bm->block, buf, addr, addr_sizep, data_cksum)); @@ -269,7 +269,7 @@ __bm_salvage_start(WT_BM *bm, WT_SESSION_IMPL *session) */ static int __bm_salvage_valid(WT_BM *bm, - WT_SESSION_IMPL *session, uint8_t *addr, size_t addr_size, int valid) + WT_SESSION_IMPL *session, uint8_t *addr, size_t addr_size, bool valid) { return (__wt_block_salvage_valid( session, bm->block, addr, addr_size, valid)); @@ -281,7 +281,7 @@ __bm_salvage_valid(WT_BM *bm, */ static int __bm_salvage_next(WT_BM *bm, - WT_SESSION_IMPL *session, uint8_t *addr, size_t *addr_sizep, int *eofp) + WT_SESSION_IMPL *session, uint8_t *addr, size_t *addr_sizep, bool *eofp) { return (__wt_block_salvage_next( session, bm->block, addr, addr_sizep, eofp)); @@ -334,14 +334,14 @@ __bm_verify_end(WT_BM *bm, WT_SESSION_IMPL *session) * Set up the legal methods. */ static void -__bm_method_set(WT_BM *bm, int readonly) +__bm_method_set(WT_BM *bm, bool readonly) { if (readonly) { bm->addr_invalid = __bm_addr_invalid; bm->addr_string = __bm_addr_string; bm->block_header = __bm_block_header; - bm->checkpoint = (int (*)(WT_BM *, - WT_SESSION_IMPL *, WT_ITEM *, WT_CKPT *, int))__bm_readonly; + bm->checkpoint = (int (*)(WT_BM *, WT_SESSION_IMPL *, + WT_ITEM *, WT_CKPT *, bool))__bm_readonly; bm->checkpoint_load = __bm_checkpoint_load; bm->checkpoint_resolve = (int (*)(WT_BM *, WT_SESSION_IMPL *))__bm_readonly; @@ -350,9 +350,9 @@ __bm_method_set(WT_BM *bm, int readonly) bm->compact_end = (int (*)(WT_BM *, WT_SESSION_IMPL *))__bm_readonly; bm->compact_page_skip = (int (*)(WT_BM *, WT_SESSION_IMPL *, - const uint8_t *, size_t, int *))__bm_readonly; + const uint8_t *, size_t, bool *))__bm_readonly; bm->compact_skip = (int (*) - (WT_BM *, WT_SESSION_IMPL *, int *))__bm_readonly; + (WT_BM *, WT_SESSION_IMPL *, bool *))__bm_readonly; bm->compact_start = (int (*)(WT_BM *, WT_SESSION_IMPL *))__bm_readonly; bm->free = (int (*)(WT_BM *, @@ -362,19 +362,19 @@ __bm_method_set(WT_BM *bm, int readonly) bm->salvage_end = (int (*) (WT_BM *, WT_SESSION_IMPL *))__bm_readonly; bm->salvage_next = (int (*)(WT_BM *, WT_SESSION_IMPL *, - uint8_t *, size_t *, int *))__bm_readonly; + uint8_t *, size_t *, bool *))__bm_readonly; bm->salvage_start = (int (*) (WT_BM *, WT_SESSION_IMPL *))__bm_readonly; bm->salvage_valid = (int (*)(WT_BM *, - WT_SESSION_IMPL *, uint8_t *, size_t, int))__bm_readonly; + WT_SESSION_IMPL *, uint8_t *, size_t, bool))__bm_readonly; bm->stat = __bm_stat; bm->sync = - (int (*)(WT_BM *, WT_SESSION_IMPL *, int))__bm_readonly; + (int (*)(WT_BM *, WT_SESSION_IMPL *, bool))__bm_readonly; bm->verify_addr = __bm_verify_addr; bm->verify_end = __bm_verify_end; bm->verify_start = __bm_verify_start; bm->write = (int (*)(WT_BM *, WT_SESSION_IMPL *, - WT_ITEM *, uint8_t *, size_t *, int))__bm_readonly; + WT_ITEM *, uint8_t *, size_t *, bool))__bm_readonly; bm->write_size = (int (*) (WT_BM *, WT_SESSION_IMPL *, size_t *))__bm_readonly; } else { @@ -414,7 +414,7 @@ __bm_method_set(WT_BM *bm, int readonly) int __wt_block_manager_open(WT_SESSION_IMPL *session, const char *filename, const char *cfg[], - int forced_salvage, int readonly, uint32_t allocsize, WT_BM **bmp) + bool forced_salvage, bool readonly, uint32_t allocsize, WT_BM **bmp) { WT_BM *bm; WT_DECL_RET; @@ -422,7 +422,7 @@ __wt_block_manager_open(WT_SESSION_IMPL *session, *bmp = NULL; WT_RET(__wt_calloc_one(session, &bm)); - __bm_method_set(bm, 0); + __bm_method_set(bm, false); WT_ERR(__wt_block_open(session, filename, cfg, forced_salvage, readonly, allocsize, &bm->block)); diff --git a/src/third_party/wiredtiger/src/block/block_open.c b/src/third_party/wiredtiger/src/block/block_open.c index cfb5b000092..e1f3e6de0fe 100644 --- a/src/third_party/wiredtiger/src/block/block_open.c +++ b/src/third_party/wiredtiger/src/block/block_open.c @@ -22,7 +22,8 @@ __wt_block_manager_truncate( WT_FH *fh; /* Open the underlying file handle. */ - WT_RET(__wt_open(session, filename, 0, 0, WT_FILE_TYPE_DATA, &fh)); + WT_RET(__wt_open( + session, filename, false, false, WT_FILE_TYPE_DATA, &fh)); /* Truncate the file. */ WT_ERR(__wt_block_truncate(session, fh, (wt_off_t)0)); @@ -53,7 +54,8 @@ __wt_block_manager_create( WT_DECL_RET; WT_DECL_ITEM(tmp); WT_FH *fh; - int exists, suffix; + int suffix; + bool exists; char *path; /* @@ -65,8 +67,8 @@ __wt_block_manager_create( * in our space. Move any existing files out of the way and complain. */ for (;;) { - if ((ret = __wt_open( - session, filename, 1, 1, WT_FILE_TYPE_DATA, &fh)) == 0) + if ((ret = __wt_open(session, + filename, true, true, WT_FILE_TYPE_DATA, &fh)) == 0) break; WT_ERR_TEST(ret != EEXIST, ret); @@ -149,7 +151,7 @@ __block_destroy(WT_SESSION_IMPL *session, WT_BLOCK *block) * Configure first-fit allocation. */ void -__wt_block_configure_first_fit(WT_BLOCK *block, int on) +__wt_block_configure_first_fit(WT_BLOCK *block, bool on) { /* * Switch to first-fit allocation so we rewrite blocks at the start of @@ -170,7 +172,7 @@ __wt_block_configure_first_fit(WT_BLOCK *block, int on) int __wt_block_open(WT_SESSION_IMPL *session, const char *filename, const char *cfg[], - int forced_salvage, int readonly, uint32_t allocsize, WT_BLOCK **blockp) + bool forced_salvage, bool readonly, uint32_t allocsize, WT_BLOCK **blockp) { WT_BLOCK *block; WT_CONFIG_ITEM cval; @@ -210,8 +212,7 @@ __wt_block_open(WT_SESSION_IMPL *session, WT_ERR(__wt_strdup(session, filename, &block->name)); WT_ERR(__wt_config_gets(session, cfg, "block_allocation", &cval)); - block->allocfirst = - WT_STRING_MATCH("first", cval.str, cval.len) ? 1 : 0; + block->allocfirst = WT_STRING_MATCH("first", cval.str, cval.len); /* Configuration: optional OS buffer cache maximum size. */ WT_ERR(__wt_config_gets(session, cfg, "os_cache_max", &cval)); @@ -248,7 +249,7 @@ __wt_block_open(WT_SESSION_IMPL *session, #endif /* Open the underlying file handle. */ - WT_ERR(__wt_open(session, filename, 0, 0, + WT_ERR(__wt_open(session, filename, false, false, readonly ? WT_FILE_TYPE_CHECKPOINT : WT_FILE_TYPE_DATA, &block->fh)); diff --git a/src/third_party/wiredtiger/src/block/block_read.c b/src/third_party/wiredtiger/src/block/block_read.c index 9f7c869dd38..4b32e02a73a 100644 --- a/src/third_party/wiredtiger/src/block/block_read.c +++ b/src/third_party/wiredtiger/src/block/block_read.c @@ -20,7 +20,7 @@ __wt_bm_preload(WT_BM *bm, WT_DECL_RET; wt_off_t offset; uint32_t cksum, size; - int mapped; + bool mapped; WT_UNUSED(addr_size); block = bm->block; @@ -63,9 +63,9 @@ __wt_bm_read(WT_BM *bm, WT_SESSION_IMPL *session, WT_ITEM *buf, const uint8_t *addr, size_t addr_size) { WT_BLOCK *block; - int mapped; wt_off_t offset; uint32_t cksum, size; + bool mapped; WT_UNUSED(addr_size); block = bm->block; diff --git a/src/third_party/wiredtiger/src/block/block_slvg.c b/src/third_party/wiredtiger/src/block/block_slvg.c index 641bb8a42f7..9f3093c741d 100644 --- a/src/third_party/wiredtiger/src/block/block_slvg.c +++ b/src/third_party/wiredtiger/src/block/block_slvg.c @@ -66,7 +66,7 @@ int __wt_block_salvage_end(WT_SESSION_IMPL *session, WT_BLOCK *block) { /* Discard the checkpoint. */ - return (__wt_block_checkpoint_unload(session, block, 0)); + return (__wt_block_checkpoint_unload(session, block, false)); } /* @@ -94,7 +94,7 @@ __wt_block_offset_invalid(WT_BLOCK *block, wt_off_t offset, uint32_t size) */ int __wt_block_salvage_next(WT_SESSION_IMPL *session, - WT_BLOCK *block, uint8_t *addr, size_t *addr_sizep, int *eofp) + WT_BLOCK *block, uint8_t *addr, size_t *addr_sizep, bool *eofp) { WT_BLOCK_HEADER *blk; WT_DECL_ITEM(tmp); @@ -165,7 +165,7 @@ err: __wt_scr_free(session, &tmp); */ int __wt_block_salvage_valid(WT_SESSION_IMPL *session, - WT_BLOCK *block, uint8_t *addr, size_t addr_size, int valid) + WT_BLOCK *block, uint8_t *addr, size_t addr_size, bool valid) { wt_off_t offset; uint32_t size, cksum; diff --git a/src/third_party/wiredtiger/src/block/block_vrfy.c b/src/third_party/wiredtiger/src/block/block_vrfy.c index dc9662bd5e0..9904dcccd14 100644 --- a/src/third_party/wiredtiger/src/block/block_vrfy.c +++ b/src/third_party/wiredtiger/src/block/block_vrfy.c @@ -12,7 +12,7 @@ static int __verify_ckptfrag_add( WT_SESSION_IMPL *, WT_BLOCK *, wt_off_t, wt_off_t); static int __verify_ckptfrag_chk(WT_SESSION_IMPL *, WT_BLOCK *); static int __verify_filefrag_add( - WT_SESSION_IMPL *, WT_BLOCK *, const char *, wt_off_t, wt_off_t, int); + WT_SESSION_IMPL *, WT_BLOCK *, const char *, wt_off_t, wt_off_t, bool); static int __verify_filefrag_chk(WT_SESSION_IMPL *, WT_BLOCK *); static int __verify_last_avail(WT_SESSION_IMPL *, WT_BLOCK *, WT_CKPT *); static int __verify_last_truncate(WT_SESSION_IMPL *, WT_BLOCK *, WT_CKPT *); @@ -90,14 +90,14 @@ __wt_block_verify_start(WT_SESSION_IMPL *session, * Set this before reading any extent lists: don't panic if we see * corruption. */ - block->verify = 1; + block->verify = true; /* * We maintain an allocation list that is rolled forward through the * set of checkpoints. */ WT_RET(__wt_block_extlist_init( - session, &block->verify_alloc, "verify", "alloc", 0)); + session, &block->verify_alloc, "verify", "alloc", false)); /* * The only checkpoint avail list we care about is the last one written; @@ -107,7 +107,7 @@ __wt_block_verify_start(WT_SESSION_IMPL *session, /* Configuration: strict behavior on any error. */ WT_RET(__wt_config_gets(session, cfg, "strict", &cval)); - block->verify_strict = cval.val ? 1 : 0; + block->verify_strict = cval.val != 0; return (0); } @@ -133,8 +133,9 @@ __verify_last_avail(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckpt) WT_ERR(__wt_block_extlist_read_avail( session, block, el, ci->file_size)); WT_EXT_FOREACH(ext, el->off) - if ((ret = __verify_filefrag_add(session, block, - "avail-list chunk", ext->off, ext->size, 1)) != 0) + if ((ret = __verify_filefrag_add( + session, block, "avail-list chunk", + ext->off, ext->size, true)) != 0) break; } @@ -173,8 +174,8 @@ __wt_block_verify_end(WT_SESSION_IMPL *session, WT_BLOCK *block) /* Confirm we verified every file block. */ ret = __verify_filefrag_chk(session, block); - block->verify = 0; - block->verify_strict = 0; + block->verify = false; + block->verify_strict = false; block->verify_size = 0; /* Discard the accumulated allocation list. */ @@ -209,16 +210,16 @@ __wt_verify_ckpt_load( */ if (ci->root_offset != WT_BLOCK_INVALID_OFFSET) WT_RET(__verify_filefrag_add(session, block, "checkpoint", - ci->root_offset, (wt_off_t)ci->root_size, 1)); + ci->root_offset, (wt_off_t)ci->root_size, true)); if (ci->alloc.offset != WT_BLOCK_INVALID_OFFSET) WT_RET(__verify_filefrag_add(session, block, "alloc list", - ci->alloc.offset, (wt_off_t)ci->alloc.size, 1)); + ci->alloc.offset, (wt_off_t)ci->alloc.size, true)); if (ci->avail.offset != WT_BLOCK_INVALID_OFFSET) WT_RET(__verify_filefrag_add(session, block, "avail list", - ci->avail.offset, (wt_off_t)ci->avail.size, 1)); + ci->avail.offset, (wt_off_t)ci->avail.size, true)); if (ci->discard.offset != WT_BLOCK_INVALID_OFFSET) WT_RET(__verify_filefrag_add(session, block, "discard list", - ci->discard.offset, (wt_off_t)ci->discard.size, 1)); + ci->discard.offset, (wt_off_t)ci->discard.size, true)); /* * Checkpoint verification is similar to deleting checkpoints. As we @@ -325,7 +326,8 @@ __wt_block_verify_addr(WT_SESSION_IMPL *session, WT_RET(__wt_block_buffer_to_addr(block, addr, &offset, &size, &cksum)); /* Add to the per-file list. */ - WT_RET(__verify_filefrag_add(session, block, NULL, offset, size, 0)); + WT_RET( + __verify_filefrag_add(session, block, NULL, offset, size, false)); /* * It's tempting to try and flag a page as "verified" when we read it. @@ -354,7 +356,7 @@ __wt_block_verify_addr(WT_SESSION_IMPL *session, */ static int __verify_filefrag_add(WT_SESSION_IMPL *session, WT_BLOCK *block, - const char *type, wt_off_t offset, wt_off_t size, int nodup) + const char *type, wt_off_t offset, wt_off_t size, bool nodup) { uint64_t f, frag, frags, i; diff --git a/src/third_party/wiredtiger/src/block/block_write.c b/src/third_party/wiredtiger/src/block/block_write.c index 4e80aa41338..26efac54080 100644 --- a/src/third_party/wiredtiger/src/block/block_write.c +++ b/src/third_party/wiredtiger/src/block/block_write.c @@ -40,10 +40,10 @@ __wt_block_truncate(WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t len) */ static inline int __wt_block_extend(WT_SESSION_IMPL *session, WT_BLOCK *block, - WT_FH *fh, wt_off_t offset, size_t align_size, int *release_lockp) + WT_FH *fh, wt_off_t offset, size_t align_size, bool *release_lockp) { WT_DECL_RET; - int locked; + bool locked; /* * The locking in this function is messy: by definition, the live system @@ -58,7 +58,7 @@ __wt_block_extend(WT_SESSION_IMPL *session, WT_BLOCK *block, * need a lock after all, we re-acquire the lock and set release_lock so * our caller knows to release it. */ - locked = 1; + locked = true; /* If not configured to extend the file, we're done. */ if (fh->extend_len == 0) @@ -97,7 +97,7 @@ __wt_block_extend(WT_SESSION_IMPL *session, WT_BLOCK *block, * over the extend call.) */ if (!fh->fallocate_requires_locking && *release_lockp) { - *release_lockp = locked = 0; + *release_lockp = locked = false; __wt_spin_unlock(session, &block->live_lock); } @@ -122,7 +122,7 @@ __wt_block_extend(WT_SESSION_IMPL *session, WT_BLOCK *block, */ if (!locked) { __wt_spin_lock(session, &block->live_lock); - *release_lockp = 1; + *release_lockp = true; } /* @@ -172,14 +172,14 @@ __wt_block_write_size(WT_SESSION_IMPL *session, WT_BLOCK *block, size_t *sizep) */ int __wt_block_write(WT_SESSION_IMPL *session, WT_BLOCK *block, - WT_ITEM *buf, uint8_t *addr, size_t *addr_sizep, int data_cksum) + WT_ITEM *buf, uint8_t *addr, size_t *addr_sizep, bool data_cksum) { wt_off_t offset; uint32_t size, cksum; uint8_t *endp; WT_RET(__wt_block_write_off( - session, block, buf, &offset, &size, &cksum, data_cksum, 0)); + session, block, buf, &offset, &size, &cksum, data_cksum, false)); endp = addr; WT_RET(__wt_block_addr_to_buffer(block, &endp, offset, size, cksum)); @@ -196,14 +196,14 @@ __wt_block_write(WT_SESSION_IMPL *session, WT_BLOCK *block, int __wt_block_write_off(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_ITEM *buf, wt_off_t *offsetp, uint32_t *sizep, uint32_t *cksump, - int data_cksum, int caller_locked) + bool data_cksum, bool caller_locked) { WT_BLOCK_HEADER *blk; WT_DECL_RET; WT_FH *fh; size_t align_size; wt_off_t offset; - int local_locked; + bool local_locked; blk = WT_BLOCK_HEADER_REF(buf->mem); fh = block->fh; @@ -272,10 +272,10 @@ __wt_block_write_off(WT_SESSION_IMPL *session, WT_BLOCK *block, * the block-extend function may release the lock). * Release any locally acquired lock. */ - local_locked = 0; + local_locked = false; if (!caller_locked) { __wt_spin_lock(session, &block->live_lock); - local_locked = 1; + local_locked = true; } ret = __wt_block_alloc(session, block, &offset, (wt_off_t)align_size); if (ret == 0) diff --git a/src/third_party/wiredtiger/src/btree/bt_compact.c b/src/third_party/wiredtiger/src/btree/bt_compact.c index 79a52dbcaa3..f7997d8b909 100644 --- a/src/third_party/wiredtiger/src/btree/bt_compact.c +++ b/src/third_party/wiredtiger/src/btree/bt_compact.c @@ -13,7 +13,7 @@ * Return if a page needs to be re-written. */ static int -__compact_rewrite(WT_SESSION_IMPL *session, WT_REF *ref, int *skipp) +__compact_rewrite(WT_SESSION_IMPL *session, WT_REF *ref, bool *skipp) { WT_BM *bm; WT_DECL_RET; @@ -22,7 +22,7 @@ __compact_rewrite(WT_SESSION_IMPL *session, WT_REF *ref, int *skipp) size_t addr_size; const uint8_t *addr; - *skipp = 1; /* Default skip. */ + *skipp = true; /* Default skip. */ bm = S2BT(session)->bm; page = ref->page; @@ -44,13 +44,13 @@ __compact_rewrite(WT_SESSION_IMPL *session, WT_REF *ref, int *skipp) * If the page is a 1-to-1 replacement, test the replacement addresses. * Ignore empty pages, they get merged into the parent. */ - if (mod == NULL || F_ISSET(mod, WT_PM_REC_MASK) == 0) { + if (mod == NULL || mod->rec_result == 0) { WT_RET(__wt_ref_info(session, ref, &addr, &addr_size, NULL)); if (addr == NULL) return (0); WT_RET( bm->compact_page_skip(bm, session, addr, addr_size, skipp)); - } else if (F_ISSET(mod, WT_PM_REC_MASK) == WT_PM_REC_REPLACE) { + } else if (mod->rec_result == WT_PM_REC_REPLACE) { /* * The page's modification information can change underfoot if * the page is being reconciled, serialize with reconciliation. @@ -75,14 +75,14 @@ __wt_compact(WT_SESSION_IMPL *session, const char *cfg[]) WT_BTREE *btree; WT_DECL_RET; WT_REF *ref; - int block_manager_begin, skip; + bool block_manager_begin, skip; WT_UNUSED(cfg); btree = S2BT(session); bm = btree->bm; ref = NULL; - block_manager_begin = 0; + block_manager_begin = false; WT_STAT_FAST_DATA_INCR(session, session_compact); @@ -118,7 +118,7 @@ __wt_compact(WT_SESSION_IMPL *session, const char *cfg[]) /* Start compaction. */ WT_ERR(bm->compact_start(bm, session)); - block_manager_begin = 1; + block_manager_begin = true; /* Walk the tree reviewing pages to see if they should be re-written. */ for (;;) { @@ -162,14 +162,14 @@ err: if (ref != NULL) * Return if compaction requires we read this page. */ int -__wt_compact_page_skip(WT_SESSION_IMPL *session, WT_REF *ref, int *skipp) +__wt_compact_page_skip(WT_SESSION_IMPL *session, WT_REF *ref, bool *skipp) { WT_BM *bm; size_t addr_size; u_int type; const uint8_t *addr; - *skipp = 0; /* Default to reading. */ + *skipp = false; /* Default to reading. */ type = 0; /* Keep compiler quiet. */ bm = S2BT(session)->bm; diff --git a/src/third_party/wiredtiger/src/btree/bt_curnext.c b/src/third_party/wiredtiger/src/btree/bt_curnext.c index 49650efcdd4..3c96bad39d7 100644 --- a/src/third_party/wiredtiger/src/btree/bt_curnext.c +++ b/src/third_party/wiredtiger/src/btree/bt_curnext.c @@ -13,7 +13,7 @@ * Return the next entry on the append list. */ static inline int -__cursor_fix_append_next(WT_CURSOR_BTREE *cbt, int newpage) +__cursor_fix_append_next(WT_CURSOR_BTREE *cbt, bool newpage) { WT_ITEM *val; WT_SESSION_IMPL *session; @@ -72,7 +72,7 @@ __cursor_fix_append_next(WT_CURSOR_BTREE *cbt, int newpage) * Move to the next, fixed-length column-store item. */ static inline int -__cursor_fix_next(WT_CURSOR_BTREE *cbt, int newpage) +__cursor_fix_next(WT_CURSOR_BTREE *cbt, bool newpage) { WT_BTREE *btree; WT_ITEM *val; @@ -121,7 +121,7 @@ new_page: * Return the next variable-length entry on the append list. */ static inline int -__cursor_var_append_next(WT_CURSOR_BTREE *cbt, int newpage) +__cursor_var_append_next(WT_CURSOR_BTREE *cbt, bool newpage) { WT_ITEM *val; WT_SESSION_IMPL *session; @@ -160,7 +160,7 @@ new_page: if (cbt->ins == NULL) * Move to the next, variable-length column-store item. */ static inline int -__cursor_var_next(WT_CURSOR_BTREE *cbt, int newpage) +__cursor_var_next(WT_CURSOR_BTREE *cbt, bool newpage) { WT_CELL *cell; WT_CELL_UNPACK unpack; @@ -279,7 +279,7 @@ new_page: /* Find the matching WT_COL slot. */ * Move to the next row-store item. */ static inline int -__cursor_row_next(WT_CURSOR_BTREE *cbt, int newpage) +__cursor_row_next(WT_CURSOR_BTREE *cbt, bool newpage) { WT_INSERT *ins; WT_ITEM *key, *val; @@ -373,12 +373,10 @@ new_insert: if ((ins = cbt->ins) != NULL) { * Initialize a cursor for iteration, usually based on a search. */ void -__wt_btcur_iterate_setup(WT_CURSOR_BTREE *cbt, int next) +__wt_btcur_iterate_setup(WT_CURSOR_BTREE *cbt) { WT_PAGE *page; - WT_UNUSED(next); - /* * We don't currently have to do any setup when we switch between next * and prev calls, but I'm sure we will someday -- I'm leaving support @@ -437,13 +435,13 @@ __wt_btcur_iterate_setup(WT_CURSOR_BTREE *cbt, int next) * Move to the next record in the tree. */ int -__wt_btcur_next(WT_CURSOR_BTREE *cbt, int truncating) +__wt_btcur_next(WT_CURSOR_BTREE *cbt, bool truncating) { WT_DECL_RET; WT_PAGE *page; WT_SESSION_IMPL *session; uint32_t flags; - int newpage; + bool newpage; session = (WT_SESSION_IMPL *)cbt->iface.session; @@ -454,21 +452,21 @@ __wt_btcur_next(WT_CURSOR_BTREE *cbt, int truncating) if (truncating) LF_SET(WT_READ_TRUNCATE); - WT_RET(__cursor_func_init(cbt, 0)); + WT_RET(__cursor_func_init(cbt, false)); /* * If we aren't already iterating in the right direction, there's * some setup to do. */ if (!F_ISSET(cbt, WT_CBT_ITERATE_NEXT)) - __wt_btcur_iterate_setup(cbt, 1); + __wt_btcur_iterate_setup(cbt); /* * Walk any page we're holding until the underlying call returns not- * found. Then, move to the next page, until we reach the end of the * file. */ - for (newpage = 0;; newpage = 1) { + for (newpage = false;; newpage = true) { page = cbt->ref == NULL ? NULL : cbt->ref->page; WT_ASSERT(session, page == NULL || !WT_PAGE_IS_INTERNAL(page)); diff --git a/src/third_party/wiredtiger/src/btree/bt_curprev.c b/src/third_party/wiredtiger/src/btree/bt_curprev.c index b514d9b8bb6..b7cea561b48 100644 --- a/src/third_party/wiredtiger/src/btree/bt_curprev.c +++ b/src/third_party/wiredtiger/src/btree/bt_curprev.c @@ -124,7 +124,7 @@ restart: * Return the previous fixed-length entry on the append list. */ static inline int -__cursor_fix_append_prev(WT_CURSOR_BTREE *cbt, int newpage) +__cursor_fix_append_prev(WT_CURSOR_BTREE *cbt, bool newpage) { WT_ITEM *val; WT_PAGE *page; @@ -209,7 +209,7 @@ __cursor_fix_append_prev(WT_CURSOR_BTREE *cbt, int newpage) * Move to the previous, fixed-length column-store item. */ static inline int -__cursor_fix_prev(WT_CURSOR_BTREE *cbt, int newpage) +__cursor_fix_prev(WT_CURSOR_BTREE *cbt, bool newpage) { WT_BTREE *btree; WT_ITEM *val; @@ -258,7 +258,7 @@ new_page: * Return the previous variable-length entry on the append list. */ static inline int -__cursor_var_append_prev(WT_CURSOR_BTREE *cbt, int newpage) +__cursor_var_append_prev(WT_CURSOR_BTREE *cbt, bool newpage) { WT_ITEM *val; WT_SESSION_IMPL *session; @@ -297,7 +297,7 @@ new_page: if (cbt->ins == NULL) * Move to the previous, variable-length column-store item. */ static inline int -__cursor_var_prev(WT_CURSOR_BTREE *cbt, int newpage) +__cursor_var_prev(WT_CURSOR_BTREE *cbt, bool newpage) { WT_CELL *cell; WT_CELL_UNPACK unpack; @@ -416,7 +416,7 @@ new_page: if (cbt->recno < page->pg_var_recno) * Move to the previous row-store item. */ static inline int -__cursor_row_prev(WT_CURSOR_BTREE *cbt, int newpage) +__cursor_row_prev(WT_CURSOR_BTREE *cbt, bool newpage) { WT_INSERT *ins; WT_ITEM *key, *val; @@ -523,13 +523,13 @@ new_insert: if ((ins = cbt->ins) != NULL) { * Move to the previous record in the tree. */ int -__wt_btcur_prev(WT_CURSOR_BTREE *cbt, int truncating) +__wt_btcur_prev(WT_CURSOR_BTREE *cbt, bool truncating) { WT_DECL_RET; WT_PAGE *page; WT_SESSION_IMPL *session; uint32_t flags; - int newpage; + bool newpage; session = (WT_SESSION_IMPL *)cbt->iface.session; @@ -540,21 +540,21 @@ __wt_btcur_prev(WT_CURSOR_BTREE *cbt, int truncating) if (truncating) LF_SET(WT_READ_TRUNCATE); - WT_RET(__cursor_func_init(cbt, 0)); + WT_RET(__cursor_func_init(cbt, false)); /* * If we aren't already iterating in the right direction, there's * some setup to do. */ if (!F_ISSET(cbt, WT_CBT_ITERATE_PREV)) - __wt_btcur_iterate_setup(cbt, 0); + __wt_btcur_iterate_setup(cbt); /* * Walk any page we're holding until the underlying call returns not- * found. Then, move to the previous page, until we reach the start * of the file. */ - for (newpage = 0;; newpage = 1) { + for (newpage = false;; newpage = true) { page = cbt->ref == NULL ? NULL : cbt->ref->page; WT_ASSERT(session, page == NULL || !WT_PAGE_IS_INTERNAL(page)); @@ -582,7 +582,7 @@ __wt_btcur_prev(WT_CURSOR_BTREE *cbt, int truncating) F_CLR(cbt, WT_CBT_ITERATE_APPEND); if (ret != WT_NOTFOUND) break; - newpage = 1; + newpage = true; } if (page != NULL) { switch (page->type) { diff --git a/src/third_party/wiredtiger/src/btree/bt_cursor.c b/src/third_party/wiredtiger/src/btree/bt_cursor.c index 458a1985e28..037648696b3 100644 --- a/src/third_party/wiredtiger/src/btree/bt_cursor.c +++ b/src/third_party/wiredtiger/src/btree/bt_cursor.c @@ -63,7 +63,7 @@ static inline int __cursor_fix_implicit(WT_BTREE *btree, WT_CURSOR_BTREE *cbt) { return (btree->type == BTREE_COL_FIX && - !F_ISSET(cbt, WT_CBT_MAX_RECORD) ? 1 : 0); + !F_ISSET(cbt, WT_CBT_MAX_RECORD)); } /* @@ -234,7 +234,7 @@ __cursor_col_search( */ static inline int __cursor_row_search( - WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, WT_REF *leaf, int insert) + WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, WT_REF *leaf, bool insert) { WT_DECL_RET; @@ -249,7 +249,7 @@ __cursor_row_search( */ static inline int __cursor_col_modify( - WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, int is_remove) + WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, bool is_remove) { return (__wt_col_modify(session, cbt, cbt->iface.recno, &cbt->iface.value, NULL, is_remove)); @@ -261,7 +261,7 @@ __cursor_col_modify( */ static inline int __cursor_row_modify( - WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, int is_remove) + WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, bool is_remove) { return (__wt_row_modify(session, cbt, &cbt->iface.key, &cbt->iface.value, NULL, is_remove)); @@ -296,7 +296,7 @@ __wt_btcur_search(WT_CURSOR_BTREE *cbt) WT_DECL_RET; WT_SESSION_IMPL *session; WT_UPDATE *upd; - int valid; + bool valid; btree = cbt->btree; cursor = &cbt->iface; @@ -314,21 +314,21 @@ __wt_btcur_search(WT_CURSOR_BTREE *cbt) * or the search of the pinned page doesn't find an exact match, search * from the root. */ - valid = 0; + valid = false; if (F_ISSET(cbt, WT_CBT_ACTIVE) && cbt->ref->page->read_gen != WT_READGEN_OLDEST) { __wt_txn_cursor_op(session); WT_ERR(btree->type == BTREE_ROW ? - __cursor_row_search(session, cbt, cbt->ref, 0) : + __cursor_row_search(session, cbt, cbt->ref, false) : __cursor_col_search(session, cbt, cbt->ref)); valid = cbt->compare == 0 && __cursor_valid(cbt, &upd); } if (!valid) { - WT_ERR(__cursor_func_init(cbt, 1)); + WT_ERR(__cursor_func_init(cbt, true)); WT_ERR(btree->type == BTREE_ROW ? - __cursor_row_search(session, cbt, NULL, 0) : + __cursor_row_search(session, cbt, NULL, false) : __cursor_col_search(session, cbt, NULL)); valid = cbt->compare == 0 && __cursor_valid(cbt, &upd); } @@ -364,7 +364,8 @@ __wt_btcur_search_near(WT_CURSOR_BTREE *cbt, int *exactp) WT_DECL_RET; WT_SESSION_IMPL *session; WT_UPDATE *upd; - int exact, valid; + int exact; + bool valid; btree = cbt->btree; cursor = &cbt->iface; @@ -390,13 +391,13 @@ __wt_btcur_search_near(WT_CURSOR_BTREE *cbt, int *exactp) * to position the cursor at the end of the tree, rather than match an * existing record. */ - valid = 0; + valid = false; if (btree->type == BTREE_ROW && F_ISSET(cbt, WT_CBT_ACTIVE) && cbt->ref->page->read_gen != WT_READGEN_OLDEST) { __wt_txn_cursor_op(session); - WT_ERR(__cursor_row_search(session, cbt, cbt->ref, 1)); + WT_ERR(__cursor_row_search(session, cbt, cbt->ref, true)); /* * Search-near is trickier than search when searching an already @@ -412,9 +413,9 @@ __wt_btcur_search_near(WT_CURSOR_BTREE *cbt, int *exactp) valid = __cursor_valid(cbt, &upd); } if (!valid) { - WT_ERR(__cursor_func_init(cbt, 1)); + WT_ERR(__cursor_func_init(cbt, true)); WT_ERR(btree->type == BTREE_ROW ? - __cursor_row_search(session, cbt, NULL, 1) : + __cursor_row_search(session, cbt, NULL, true) : __cursor_col_search(session, cbt, NULL)); valid = __cursor_valid(cbt, &upd); } @@ -445,16 +446,16 @@ __wt_btcur_search_near(WT_CURSOR_BTREE *cbt, int *exactp) cursor->value.data = &cbt->v; cursor->value.size = 1; exact = 0; - } else if ((ret = __wt_btcur_next(cbt, 0)) != WT_NOTFOUND) + } else if ((ret = __wt_btcur_next(cbt, false)) != WT_NOTFOUND) exact = 1; else { WT_ERR(btree->type == BTREE_ROW ? - __cursor_row_search(session, cbt, NULL, 1) : + __cursor_row_search(session, cbt, NULL, true) : __cursor_col_search(session, cbt, NULL)); if (__cursor_valid(cbt, &upd)) { exact = cbt->compare; ret = __wt_kv_return(session, cbt, upd); - } else if ((ret = __wt_btcur_prev(cbt, 0)) != WT_NOTFOUND) + } else if ((ret = __wt_btcur_prev(cbt, false)) != WT_NOTFOUND) exact = -1; } @@ -495,11 +496,11 @@ __wt_btcur_insert(WT_CURSOR_BTREE *cbt) * and it's no longer possible to bulk-load into it. */ if (btree->bulk_load_ok) { - btree->bulk_load_ok = 0; - __wt_btree_evictable(session, 1); + btree->bulk_load_ok = false; + __wt_btree_evictable(session, true); } -retry: WT_RET(__cursor_func_init(cbt, 1)); +retry: WT_RET(__cursor_func_init(cbt, true)); switch (btree->type) { case BTREE_COL_FIX: @@ -530,12 +531,12 @@ retry: WT_RET(__cursor_func_init(cbt, 1)); (cbt->compare != 0 && __cursor_fix_implicit(btree, cbt)))) WT_ERR(WT_DUPLICATE_KEY); - WT_ERR(__cursor_col_modify(session, cbt, 0)); + WT_ERR(__cursor_col_modify(session, cbt, false)); if (F_ISSET(cursor, WT_CURSTD_APPEND)) cbt->iface.recno = cbt->recno; break; case BTREE_ROW: - WT_ERR(__cursor_row_search(session, cbt, NULL, 1)); + WT_ERR(__cursor_row_search(session, cbt, NULL, true)); /* * If not overwriting, fail if the key exists, else insert the * key/value pair. @@ -544,7 +545,7 @@ retry: WT_RET(__cursor_func_init(cbt, 1)); cbt->compare == 0 && __cursor_valid(cbt, NULL)) WT_ERR(WT_DUPLICATE_KEY); - ret = __cursor_row_modify(session, cbt, 0); + ret = __cursor_row_modify(session, cbt, false); break; WT_ILLEGAL_VALUE_ERR(session); } @@ -611,11 +612,11 @@ __wt_btcur_update_check(WT_CURSOR_BTREE *cbt) btree = cbt->btree; session = (WT_SESSION_IMPL *)cursor->session; -retry: WT_RET(__cursor_func_init(cbt, 1)); +retry: WT_RET(__cursor_func_init(cbt, true)); switch (btree->type) { case BTREE_ROW: - WT_ERR(__cursor_row_search(session, cbt, NULL, 1)); + WT_ERR(__cursor_row_search(session, cbt, NULL, true)); /* * Just check for conflicts. @@ -661,7 +662,7 @@ __wt_btcur_remove(WT_CURSOR_BTREE *cbt) if (btree->type == BTREE_ROW) WT_RET(__cursor_size_chk(session, &cursor->key)); -retry: WT_RET(__cursor_func_init(cbt, 1)); +retry: WT_RET(__cursor_func_init(cbt, true)); switch (btree->type) { case BTREE_COL_FIX: @@ -691,11 +692,11 @@ retry: WT_RET(__cursor_func_init(cbt, 1)); */ cbt->recno = cursor->recno; } else - ret = __cursor_col_modify(session, cbt, 1); + ret = __cursor_col_modify(session, cbt, true); break; case BTREE_ROW: /* Remove the record if it exists. */ - WT_ERR(__cursor_row_search(session, cbt, NULL, 0)); + WT_ERR(__cursor_row_search(session, cbt, NULL, false)); /* Check whether an update would conflict. */ WT_ERR(__curfile_update_check(cbt)); @@ -703,7 +704,7 @@ retry: WT_RET(__cursor_func_init(cbt, 1)); if (cbt->compare != 0 || !__cursor_valid(cbt, NULL)) WT_ERR(WT_NOTFOUND); - ret = __cursor_row_modify(session, cbt, 1); + ret = __cursor_row_modify(session, cbt, true); break; WT_ILLEGAL_VALUE_ERR(session); } @@ -756,11 +757,11 @@ __wt_btcur_update(WT_CURSOR_BTREE *cbt) * and it's no longer possible to bulk-load into it. */ if (btree->bulk_load_ok) { - btree->bulk_load_ok = 0; - __wt_btree_evictable(session, 1); + btree->bulk_load_ok = false; + __wt_btree_evictable(session, true); } -retry: WT_RET(__cursor_func_init(cbt, 1)); +retry: WT_RET(__cursor_func_init(cbt, true)); switch (btree->type) { case BTREE_COL_FIX: @@ -781,10 +782,10 @@ retry: WT_RET(__cursor_func_init(cbt, 1)); !__cursor_fix_implicit(btree, cbt)) WT_ERR(WT_NOTFOUND); } - ret = __cursor_col_modify(session, cbt, 0); + ret = __cursor_col_modify(session, cbt, false); break; case BTREE_ROW: - WT_ERR(__cursor_row_search(session, cbt, NULL, 1)); + WT_ERR(__cursor_row_search(session, cbt, NULL, true)); /* * If not overwriting, check for conflicts and fail if the key * does not exist. @@ -794,7 +795,7 @@ retry: WT_RET(__cursor_func_init(cbt, 1)); if (cbt->compare != 0 || !__cursor_valid(cbt, NULL)) WT_ERR(WT_NOTFOUND); } - ret = __cursor_row_modify(session, cbt, 0); + ret = __cursor_row_modify(session, cbt, false); break; WT_ILLEGAL_VALUE_ERR(session); } @@ -846,7 +847,7 @@ __wt_btcur_next_random(WT_CURSOR_BTREE *cbt) WT_STAT_FAST_CONN_INCR(session, cursor_next); WT_STAT_FAST_DATA_INCR(session, cursor_next); - WT_RET(__cursor_func_init(cbt, 1)); + WT_RET(__cursor_func_init(cbt, true)); WT_WITH_PAGE_INDEX(session, ret = __wt_row_random(session, cbt)); @@ -854,8 +855,8 @@ __wt_btcur_next_random(WT_CURSOR_BTREE *cbt) if (__cursor_valid(cbt, &upd)) WT_ERR(__wt_kv_return(session, cbt, upd)); else { - if ((ret = __wt_btcur_next(cbt, 0)) == WT_NOTFOUND) - ret = __wt_btcur_prev(cbt, 0); + if ((ret = __wt_btcur_next(cbt, false)) == WT_NOTFOUND) + ret = __wt_btcur_prev(cbt, false); WT_ERR(ret); } @@ -945,8 +946,7 @@ __cursor_equals(WT_CURSOR_BTREE *a, WT_CURSOR_BTREE *b) * Return an equality comparison between two cursors. */ int -__wt_btcur_equals( - WT_CURSOR_BTREE *a_arg, WT_CURSOR_BTREE *b_arg, int *equalp) +__wt_btcur_equals(WT_CURSOR_BTREE *a_arg, WT_CURSOR_BTREE *b_arg, int *equalp) { WT_CURSOR *a, *b; WT_SESSION_IMPL *session; @@ -985,7 +985,7 @@ __wt_btcur_equals( static int __cursor_truncate(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *start, WT_CURSOR_BTREE *stop, - int (*rmfunc)(WT_SESSION_IMPL *, WT_CURSOR_BTREE *, int)) + int (*rmfunc)(WT_SESSION_IMPL *, WT_CURSOR_BTREE *, bool)) { WT_DECL_RET; @@ -1014,7 +1014,7 @@ retry: WT_RET(__wt_btcur_remove(start)); for (ret = 0;;) { if (stop != NULL && __cursor_equals(start, stop)) break; - if ((ret = __wt_btcur_next(start, 1)) != 0) + if ((ret = __wt_btcur_next(start, true)) != 0) break; start->compare = 0; /* Exact match */ if ((ret = rmfunc(session, start, 1)) != 0) @@ -1038,7 +1038,7 @@ retry: WT_RET(__wt_btcur_remove(start)); static int __cursor_truncate_fix(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *start, WT_CURSOR_BTREE *stop, - int (*rmfunc)(WT_SESSION_IMPL *, WT_CURSOR_BTREE *, int)) + int (*rmfunc)(WT_SESSION_IMPL *, WT_CURSOR_BTREE *, bool)) { WT_DECL_RET; uint8_t *value; @@ -1067,7 +1067,7 @@ retry: WT_RET(__wt_btcur_remove(start)); for (ret = 0;;) { if (stop != NULL && __cursor_equals(start, stop)) break; - if ((ret = __wt_btcur_next(start, 1)) != 0) + if ((ret = __wt_btcur_next(start, true)) != 0) break; start->compare = 0; /* Exact match */ value = (uint8_t *)start->iface.value.data; @@ -1181,7 +1181,7 @@ __wt_btcur_open(WT_CURSOR_BTREE *cbt) * Close a btree cursor. */ int -__wt_btcur_close(WT_CURSOR_BTREE *cbt, int lowlevel) +__wt_btcur_close(WT_CURSOR_BTREE *cbt, bool lowlevel) { WT_DECL_RET; WT_SESSION_IMPL *session; diff --git a/src/third_party/wiredtiger/src/btree/bt_debug.c b/src/third_party/wiredtiger/src/btree/bt_debug.c index 38ef407e160..4d3add47052 100644 --- a/src/third_party/wiredtiger/src/btree/bt_debug.c +++ b/src/third_party/wiredtiger/src/btree/bt_debug.c @@ -31,7 +31,7 @@ static const /* Output separator */ static int __debug_cell(WT_DBG *, const WT_PAGE_HEADER *, WT_CELL_UNPACK *); static int __debug_cell_data( WT_DBG *, WT_PAGE *, int type, const char *, WT_CELL_UNPACK *); -static void __debug_col_skip(WT_DBG *, WT_INSERT_HEAD *, const char *, int); +static void __debug_col_skip(WT_DBG *, WT_INSERT_HEAD *, const char *, bool); static int __debug_config(WT_SESSION_IMPL *, WT_DBG *, const char *); static int __debug_dsk_cell(WT_DBG *, const WT_PAGE_HEADER *); static void __debug_dsk_col_fix(WT_DBG *, const WT_PAGE_HEADER *); @@ -46,7 +46,7 @@ static int __debug_page_row_leaf(WT_DBG *, WT_PAGE *); static int __debug_ref(WT_DBG *, WT_REF *); static void __debug_row_skip(WT_DBG *, WT_INSERT_HEAD *); static int __debug_tree(WT_SESSION_IMPL *, WT_PAGE *, const char *, uint32_t); -static void __debug_update(WT_DBG *, WT_UPDATE *, int); +static void __debug_update(WT_DBG *, WT_UPDATE *, bool); static void __dmsg(WT_DBG *, const char *, ...) WT_GCC_FUNC_DECL_ATTRIBUTE((format (printf, 2, 3))); static void __dmsg_wrapup(WT_DBG *); @@ -651,7 +651,7 @@ __debug_page_metadata(WT_DBG *ds, WT_PAGE *page) __dmsg(ds, ", split-insert"); if (mod != NULL) - switch (F_ISSET(mod, WT_PM_REC_MASK)) { + switch (mod->rec_result) { case WT_PM_REC_EMPTY: __dmsg(ds, ", empty"); break; @@ -707,7 +707,7 @@ __debug_page_col_fix(WT_DBG *ds, WT_PAGE *page) __dmsg(ds, "\tupdate %" PRIu64 "\n", WT_INSERT_RECNO(ins)); - __debug_update(ds, ins->upd, 1); + __debug_update(ds, ins->upd, true); ins = WT_SKIP_NEXT(ins); } ++recno; @@ -716,11 +716,12 @@ __debug_page_col_fix(WT_DBG *ds, WT_PAGE *page) if (WT_COL_UPDATE_SINGLE(page) != NULL) { __dmsg(ds, "%s", sep); - __debug_col_skip(ds, WT_COL_UPDATE_SINGLE(page), "update", 1); + __debug_col_skip( + ds, WT_COL_UPDATE_SINGLE(page), "update", true); } if (WT_COL_APPEND(page) != NULL) { __dmsg(ds, "%s", sep); - __debug_col_skip(ds, WT_COL_APPEND(page), "append", 1); + __debug_col_skip(ds, WT_COL_APPEND(page), "append", true); } } @@ -783,13 +784,13 @@ __debug_page_col_var(WT_DBG *ds, WT_PAGE *page) __debug_cell_data(ds, page, WT_PAGE_COL_VAR, tag, unpack)); if ((update = WT_COL_UPDATE(page, cip)) != NULL) - __debug_col_skip(ds, update, "update", 0); + __debug_col_skip(ds, update, "update", false); recno += rle; } if (WT_COL_APPEND(page) != NULL) { __dmsg(ds, "%s", sep); - __debug_col_skip(ds, WT_COL_APPEND(page), "append", 0); + __debug_col_skip(ds, WT_COL_APPEND(page), "append", false); } return (0); @@ -855,7 +856,7 @@ __debug_page_row_leaf(WT_DBG *ds, WT_PAGE *page) /* Dump the page's K/V pairs. */ WT_ROW_FOREACH(page, rip, i) { - WT_RET(__wt_row_leaf_key(session, page, rip, key, 0)); + WT_RET(__wt_row_leaf_key(session, page, rip, key, false)); __debug_item(ds, "K", key->data, key->size); if ((cell = __wt_row_leaf_value_cell(page, rip, NULL)) == NULL) @@ -867,7 +868,7 @@ __debug_page_row_leaf(WT_DBG *ds, WT_PAGE *page) } if ((upd = WT_ROW_UPDATE(page, rip)) != NULL) - __debug_update(ds, upd, 0); + __debug_update(ds, upd, false); if ((insert = WT_ROW_INSERT(page, rip)) != NULL) __debug_row_skip(ds, insert); @@ -882,7 +883,8 @@ err: __wt_scr_free(session, &key); * Dump a column-store skiplist. */ static void -__debug_col_skip(WT_DBG *ds, WT_INSERT_HEAD *head, const char *tag, int hexbyte) +__debug_col_skip( + WT_DBG *ds, WT_INSERT_HEAD *head, const char *tag, bool hexbyte) { WT_INSERT *ins; @@ -905,7 +907,7 @@ __debug_row_skip(WT_DBG *ds, WT_INSERT_HEAD *head) WT_SKIP_FOREACH(ins, head) { __debug_item(ds, "insert", WT_INSERT_KEY(ins), WT_INSERT_KEY_SIZE(ins)); - __debug_update(ds, ins->upd, 0); + __debug_update(ds, ins->upd, false); } } @@ -914,7 +916,7 @@ __debug_row_skip(WT_DBG *ds, WT_INSERT_HEAD *head) * Dump an update list. */ static void -__debug_update(WT_DBG *ds, WT_UPDATE *upd, int hexbyte) +__debug_update(WT_DBG *ds, WT_UPDATE *upd, bool hexbyte) { for (; upd != NULL; upd = upd->next) if (WT_UPDATE_DELETED_ISSET(upd)) diff --git a/src/third_party/wiredtiger/src/btree/bt_delete.c b/src/third_party/wiredtiger/src/btree/bt_delete.c index c3c7afa1450..23429121e98 100644 --- a/src/third_party/wiredtiger/src/btree/bt_delete.c +++ b/src/third_party/wiredtiger/src/btree/bt_delete.c @@ -61,12 +61,12 @@ * If deleting a range, try to delete the page without instantiating it. */ int -__wt_delete_page(WT_SESSION_IMPL *session, WT_REF *ref, int *skipp) +__wt_delete_page(WT_SESSION_IMPL *session, WT_REF *ref, bool *skipp) { WT_DECL_RET; WT_PAGE *parent; - *skipp = 0; + *skipp = false; /* If we have a clean page in memory, attempt to evict it. */ if (ref->state == WT_REF_MEM && @@ -126,7 +126,7 @@ __wt_delete_page(WT_SESSION_IMPL *session, WT_REF *ref, int *skipp) * future reconciliation of the child leaf page that will dirty it as * we write the tree. */ - WT_ERR(__wt_page_parent_modify_set(session, ref, 0)); + WT_ERR(__wt_page_parent_modify_set(session, ref, false)); /* * Record the change in the transaction structure and set the change's @@ -137,7 +137,7 @@ __wt_delete_page(WT_SESSION_IMPL *session, WT_REF *ref, int *skipp) WT_ERR(__wt_txn_modify_ref(session, ref)); - *skipp = 1; + *skipp = true; WT_PUBLISH(ref->state, WT_REF_DELETED); return (0); diff --git a/src/third_party/wiredtiger/src/btree/bt_discard.c b/src/third_party/wiredtiger/src/btree/bt_discard.c index 73e6affccd3..c27d42d38f4 100644 --- a/src/third_party/wiredtiger/src/btree/bt_discard.c +++ b/src/third_party/wiredtiger/src/btree/bt_discard.c @@ -147,7 +147,7 @@ __free_page_modify(WT_SESSION_IMPL *session, WT_PAGE *page) mod = page->modify; - switch (F_ISSET(mod, WT_PM_REC_MASK)) { + switch (mod->rec_result) { case WT_PM_REC_MULTIBLOCK: case WT_PM_REC_REWRITE: /* Free list of replacement blocks. */ @@ -209,7 +209,7 @@ __free_page_modify(WT_SESSION_IMPL *session, WT_PAGE *page) static void __free_page_int(WT_SESSION_IMPL *session, WT_PAGE *page) { - __wt_free_ref_index(session, page, WT_INTL_INDEX_GET_SAFE(page), 0); + __wt_free_ref_index(session, page, WT_INTL_INDEX_GET_SAFE(page), false); } /* @@ -219,7 +219,7 @@ __free_page_int(WT_SESSION_IMPL *session, WT_PAGE *page) */ void __wt_free_ref( - WT_SESSION_IMPL *session, WT_PAGE *page, WT_REF *ref, int free_pages) + WT_SESSION_IMPL *session, WT_PAGE *page, WT_REF *ref, bool free_pages) { WT_IKEY *ikey; @@ -268,7 +268,7 @@ __wt_free_ref( */ void __wt_free_ref_index(WT_SESSION_IMPL *session, - WT_PAGE *page, WT_PAGE_INDEX *pindex, int free_pages) + WT_PAGE *page, WT_PAGE_INDEX *pindex, bool free_pages) { uint32_t i; diff --git a/src/third_party/wiredtiger/src/btree/bt_handle.c b/src/third_party/wiredtiger/src/btree/bt_handle.c index 6a4243a0fc7..9187c72ae8d 100644 --- a/src/third_party/wiredtiger/src/btree/bt_handle.c +++ b/src/third_party/wiredtiger/src/btree/bt_handle.c @@ -12,7 +12,7 @@ static int __btree_conf(WT_SESSION_IMPL *, WT_CKPT *ckpt); static int __btree_get_last_recno(WT_SESSION_IMPL *); static int __btree_page_sizes(WT_SESSION_IMPL *); static int __btree_preload(WT_SESSION_IMPL *); -static int __btree_tree_open_empty(WT_SESSION_IMPL *, int); +static int __btree_tree_open_empty(WT_SESSION_IMPL *, bool); /* * __wt_btree_open -- @@ -29,14 +29,14 @@ __wt_btree_open(WT_SESSION_IMPL *session, const char *op_cfg[]) WT_DECL_RET; size_t root_addr_size; uint8_t root_addr[WT_BTREE_MAX_ADDR_COOKIE]; - int creation, forced_salvage, readonly; const char *filename; + bool creation, forced_salvage, readonly; dhandle = session->dhandle; btree = S2BT(session); /* Checkpoint files are readonly. */ - readonly = dhandle->checkpoint == NULL ? 0 : 1; + readonly = dhandle->checkpoint != NULL; /* Get the checkpoint information for this name/checkpoint pair. */ WT_CLEAR(ckpt); @@ -53,10 +53,10 @@ __wt_btree_open(WT_SESSION_IMPL *session, const char *op_cfg[]) "bulk-load is only supported on newly created objects"); /* Handle salvage configuration. */ - forced_salvage = 0; + forced_salvage = false; if (F_ISSET(btree, WT_BTREE_SALVAGE)) { WT_ERR(__wt_config_gets(session, op_cfg, "force", &cval)); - forced_salvage = (cval.val != 0); + forced_salvage = cval.val != 0; } /* Initialize and configure the WT_BTREE structure. */ @@ -169,7 +169,7 @@ __wt_btree_close(WT_SESSION_IMPL *session) btree->collator = NULL; btree->kencryptor = NULL; - btree->bulk_load_ok = 0; + btree->bulk_load_ok = false; F_CLR(btree, WT_BTREE_SPECIAL_FLAGS); @@ -189,7 +189,7 @@ __btree_conf(WT_SESSION_IMPL *session, WT_CKPT *ckpt) WT_DECL_RET; int64_t maj_version, min_version; uint32_t bitcnt; - int fixed; + bool fixed; const char **cfg, *enc_cfg[] = { NULL, NULL }; btree = S2BT(session); @@ -342,8 +342,9 @@ __btree_conf(WT_SESSION_IMPL *session, WT_CKPT *ckpt) session, &btree->ovfl_lock, "btree overflow lock")); WT_RET(__wt_spin_init(session, &btree->flush_lock, "btree flush lock")); - btree->write_gen = ckpt->write_gen; /* Write generation */ + btree->checkpointing = WT_CKPT_OFF; /* Not checkpointing */ btree->modified = 0; /* Clean */ + btree->write_gen = ckpt->write_gen; /* Write generation */ return (0); } @@ -353,7 +354,7 @@ __btree_conf(WT_SESSION_IMPL *session, WT_CKPT *ckpt) * Initialize a tree root reference, and link in the root page. */ void -__wt_root_ref_init(WT_REF *root_ref, WT_PAGE *root, int is_recno) +__wt_root_ref_init(WT_REF *root_ref, WT_PAGE *root, bool is_recno) { memset(root_ref, 0, sizeof(*root_ref)); @@ -446,7 +447,7 @@ err: __wt_buf_free(session, &dsk); * Create an empty in-memory tree. */ static int -__btree_tree_open_empty(WT_SESSION_IMPL *session, int creation) +__btree_tree_open_empty(WT_SESSION_IMPL *session, bool creation) { WT_BTREE *btree; WT_DECL_RET; @@ -465,8 +466,8 @@ __btree_tree_open_empty(WT_SESSION_IMPL *session, int creation) * globally, there's no point in searching empty trees for eviction. */ if (creation) { - btree->bulk_load_ok = 1; - __wt_btree_evictable(session, 0); + btree->bulk_load_ok = true; + __wt_btree_evictable(session, false); } /* @@ -483,8 +484,8 @@ __btree_tree_open_empty(WT_SESSION_IMPL *session, int creation) switch (btree->type) { case BTREE_COL_FIX: case BTREE_COL_VAR: - WT_ERR( - __wt_page_alloc(session, WT_PAGE_COL_INT, 1, 1, 1, &root)); + WT_ERR(__wt_page_alloc( + session, WT_PAGE_COL_INT, 1, 1, true, &root)); root->pg_intl_parent_ref = &btree->root; pindex = WT_INTL_INDEX_GET_SAFE(root); @@ -496,8 +497,8 @@ __btree_tree_open_empty(WT_SESSION_IMPL *session, int creation) ref->key.recno = 1; break; case BTREE_ROW: - WT_ERR( - __wt_page_alloc(session, WT_PAGE_ROW_INT, 0, 1, 1, &root)); + WT_ERR(__wt_page_alloc( + session, WT_PAGE_ROW_INT, 0, 1, true, &root)); root->pg_intl_parent_ref = &btree->root; pindex = WT_INTL_INDEX_GET_SAFE(root); @@ -545,16 +546,16 @@ __wt_btree_new_leaf_page(WT_SESSION_IMPL *session, WT_PAGE **pagep) switch (btree->type) { case BTREE_COL_FIX: - WT_RET( - __wt_page_alloc(session, WT_PAGE_COL_FIX, 1, 0, 0, pagep)); + WT_RET(__wt_page_alloc( + session, WT_PAGE_COL_FIX, 1, 0, false, pagep)); break; case BTREE_COL_VAR: - WT_RET( - __wt_page_alloc(session, WT_PAGE_COL_VAR, 1, 0, 0, pagep)); + WT_RET(__wt_page_alloc( + session, WT_PAGE_COL_VAR, 1, 0, false, pagep)); break; case BTREE_ROW: - WT_RET( - __wt_page_alloc(session, WT_PAGE_ROW_LEAF, 0, 0, 0, pagep)); + WT_RET(__wt_page_alloc( + session, WT_PAGE_ROW_LEAF, 0, 0, false, pagep)); break; WT_ILLEGAL_VALUE(session); } @@ -566,7 +567,7 @@ __wt_btree_new_leaf_page(WT_SESSION_IMPL *session, WT_PAGE **pagep) * Setup or release a cache-resident tree. */ void -__wt_btree_evictable(WT_SESSION_IMPL *session, int on) +__wt_btree_evictable(WT_SESSION_IMPL *session, bool on) { WT_BTREE *btree; diff --git a/src/third_party/wiredtiger/src/btree/bt_huffman.c b/src/third_party/wiredtiger/src/btree/bt_huffman.c index 40141b9efbb..d9ff9616072 100644 --- a/src/third_party/wiredtiger/src/btree/bt_huffman.c +++ b/src/third_party/wiredtiger/src/btree/bt_huffman.c @@ -134,7 +134,7 @@ static int __wt_huffman_read(WT_SESSION_IMPL *, */ static int __huffman_confchk_file( - WT_SESSION_IMPL *session, WT_CONFIG_ITEM *v, int *is_utf8p, FILE **fpp) + WT_SESSION_IMPL *session, WT_CONFIG_ITEM *v, bool *is_utf8p, FILE **fpp) { FILE *fp; WT_DECL_RET; @@ -302,7 +302,7 @@ __wt_huffman_read(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *ip, WT_DECL_RET; int64_t symbol, frequency; u_int entries, lineno; - int is_utf8; + bool is_utf8; *tablep = NULL; *entriesp = *numbytesp = 0; diff --git a/src/third_party/wiredtiger/src/btree/bt_io.c b/src/third_party/wiredtiger/src/btree/bt_io.c index 836c1540c5f..e46e4a55696 100644 --- a/src/third_party/wiredtiger/src/btree/bt_io.c +++ b/src/third_party/wiredtiger/src/btree/bt_io.c @@ -168,7 +168,7 @@ err: __wt_scr_free(session, &tmp); */ int __wt_bt_write(WT_SESSION_IMPL *session, WT_ITEM *buf, - uint8_t *addr, size_t *addr_sizep, int checkpoint, int compressed) + uint8_t *addr, size_t *addr_sizep, bool checkpoint, bool compressed) { WT_BM *bm; WT_BTREE *btree; @@ -179,17 +179,18 @@ __wt_bt_write(WT_SESSION_IMPL *session, WT_ITEM *buf, WT_ITEM *ip; WT_PAGE_HEADER *dsk; size_t dst_len, len, result_len, size, src_len; - int compression_failed, data_cksum, encrypted; + int compression_failed; /* Extension API, so not a bool. */ uint8_t *dst, *src; + bool data_cksum, encrypted; btree = S2BT(session); bm = btree->bm; - encrypted = 0; + encrypted = false; /* Checkpoint calls are different than standard calls. */ WT_ASSERT(session, - (checkpoint == 0 && addr != NULL && addr_sizep != NULL) || - (checkpoint == 1 && addr == NULL && addr_sizep == NULL)); + (!checkpoint && addr != NULL && addr_sizep != NULL) || + (checkpoint && addr == NULL && addr_sizep == NULL)); #ifdef HAVE_DIAGNOSTIC /* @@ -280,7 +281,7 @@ __wt_bt_write(WT_SESSION_IMPL *session, WT_ITEM *buf, ip = buf; WT_STAT_FAST_DATA_INCR(session, compress_write_fail); } else { - compressed = 1; + compressed = true; WT_STAT_FAST_DATA_INCR(session, compress_write); /* @@ -307,7 +308,7 @@ __wt_bt_write(WT_SESSION_IMPL *session, WT_ITEM *buf, WT_ERR(__wt_encrypt(session, kencryptor, WT_BLOCK_ENCRYPT_SKIP, ip, etmp)); - encrypted = 1; + encrypted = true; ip = etmp; } dsk = ip->mem; @@ -341,10 +342,10 @@ __wt_bt_write(WT_SESSION_IMPL *session, WT_ITEM *buf, */ switch (btree->checksum) { case CKSUM_ON: - data_cksum = 1; + data_cksum = true; break; case CKSUM_OFF: - data_cksum = 0; + data_cksum = false; break; case CKSUM_UNCOMPRESSED: default: diff --git a/src/third_party/wiredtiger/src/btree/bt_misc.c b/src/third_party/wiredtiger/src/btree/bt_misc.c index e2f0eb8f4cf..d2b16bb5d21 100644 --- a/src/third_party/wiredtiger/src/btree/bt_misc.c +++ b/src/third_party/wiredtiger/src/btree/bt_misc.c @@ -115,13 +115,15 @@ __wt_addr_string(WT_SESSION_IMPL *session, const uint8_t *addr, size_t addr_size, WT_ITEM *buf) { WT_BM *bm; + WT_BTREE *btree; - bm = S2BT(session)->bm; + btree = S2BT_SAFE(session); if (addr == NULL) { buf->data = "[NoAddr]"; buf->size = strlen("[NoAddr]"); - } else if (bm->addr_string(bm, session, buf, addr, addr_size) != 0) { + } else if (btree == NULL || (bm = btree->bm) == NULL || + bm->addr_string(bm, session, buf, addr, addr_size) != 0) { buf->data = "[Error]"; buf->size = strlen("[Error]"); } diff --git a/src/third_party/wiredtiger/src/btree/bt_ovfl.c b/src/third_party/wiredtiger/src/btree/bt_ovfl.c index 7104e702418..651cbc8d4ad 100644 --- a/src/third_party/wiredtiger/src/btree/bt_ovfl.c +++ b/src/third_party/wiredtiger/src/btree/bt_ovfl.c @@ -154,7 +154,7 @@ int __wt_ovfl_cache(WT_SESSION_IMPL *session, WT_PAGE *page, void *cookie, WT_CELL_UNPACK *vpack) { - int visible; + bool visible; /* * This function solves a problem in reconciliation. The scenario is: diff --git a/src/third_party/wiredtiger/src/btree/bt_page.c b/src/third_party/wiredtiger/src/btree/bt_page.c index ba218fc332c..34964def54c 100644 --- a/src/third_party/wiredtiger/src/btree/bt_page.c +++ b/src/third_party/wiredtiger/src/btree/bt_page.c @@ -22,7 +22,7 @@ static int __inmem_row_leaf_entries( */ int __wt_page_alloc(WT_SESSION_IMPL *session, uint8_t type, - uint64_t recno, uint32_t alloc_entries, int alloc_refs, WT_PAGE **pagep) + uint64_t recno, uint32_t alloc_entries, bool alloc_refs, WT_PAGE **pagep) { WT_CACHE *cache; WT_DECL_RET; @@ -192,7 +192,7 @@ __wt_page_inmem(WT_SESSION_IMPL *session, WT_REF *ref, /* Allocate and initialize a new WT_PAGE. */ WT_RET(__wt_page_alloc( - session, dsk->type, dsk->recno, alloc_entries, 1, &page)); + session, dsk->type, dsk->recno, alloc_entries, true, &page)); page->dsk = dsk; F_SET_ATOMIC(page, flags); diff --git a/src/third_party/wiredtiger/src/btree/bt_read.c b/src/third_party/wiredtiger/src/btree/bt_read.c index d26b44e04c0..96df838429a 100644 --- a/src/third_party/wiredtiger/src/btree/bt_read.c +++ b/src/third_party/wiredtiger/src/btree/bt_read.c @@ -74,7 +74,7 @@ __col_instantiate(WT_SESSION_IMPL *session, { /* Search the page and add updates. */ WT_RET(__wt_col_search(session, recno, ref, cbt)); - WT_RET(__wt_col_modify(session, cbt, recno, NULL, upd, 0)); + WT_RET(__wt_col_modify(session, cbt, recno, NULL, upd, false)); return (0); } @@ -87,8 +87,8 @@ __row_instantiate(WT_SESSION_IMPL *session, WT_ITEM *key, WT_REF *ref, WT_CURSOR_BTREE *cbt, WT_UPDATE *upd) { /* Search the page and add updates. */ - WT_RET(__wt_row_search(session, key, ref, cbt, 1)); - WT_RET(__wt_row_modify(session, cbt, key, NULL, upd, 0)); + WT_RET(__wt_row_search(session, key, ref, cbt, true)); + WT_RET(__wt_row_modify(session, cbt, key, NULL, upd, false)); return (0); } @@ -259,7 +259,7 @@ __las_page_instantiate(WT_SESSION_IMPL *session, } err: WT_TRET(__wt_las_cursor_close(session, &cursor, session_flags)); - WT_TRET(__wt_btcur_close(&cbt, 1)); + WT_TRET(__wt_btcur_close(&cbt, true)); /* * On error, upd points to a single unlinked WT_UPDATE structure, @@ -308,10 +308,10 @@ __evict_force_check(WT_SESSION_IMPL *session, WT_PAGE *page) __wt_page_evict_soon(page); /* Bump the oldest ID, we're about to do some visibility checks. */ - __wt_txn_update_oldest(session, 0); + __wt_txn_update_oldest(session, false); /* If eviction cannot succeed, don't try. */ - return (__wt_page_can_evict(session, page, 1, NULL)); + return (__wt_page_can_evict(session, page, true, NULL)); } /* @@ -438,12 +438,13 @@ __wt_page_in_func(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags WT_DECL_RET; WT_PAGE *page; u_int sleep_cnt, wait_cnt; - int busy, cache_work, force_attempts, oldgen, stalled; + bool busy, cache_work, oldgen, stalled; + int force_attempts; btree = S2BT(session); - stalled = 0; - for (force_attempts = oldgen = 0, sleep_cnt = wait_cnt = 0;;) { + for (oldgen = stalled = false, + force_attempts = 0, sleep_cnt = wait_cnt = 0;;) { switch (ref->state) { case WT_REF_DISK: case WT_REF_DELETED: @@ -470,7 +471,7 @@ __wt_page_in_func(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags /* Waiting on another thread's read, stall. */ WT_STAT_FAST_CONN_INCR(session, page_read_blocked); - stalled = 1; + stalled = true; break; case WT_REF_LOCKED: if (LF_ISSET(WT_READ_NO_WAIT)) @@ -478,7 +479,7 @@ __wt_page_in_func(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags /* Waiting on eviction, stall. */ WT_STAT_FAST_CONN_INCR(session, page_locked_blocked); - stalled = 1; + stalled = true; break; case WT_REF_SPLIT: return (WT_RESTART); @@ -533,7 +534,7 @@ __wt_page_in_func(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags ret = 0; WT_STAT_FAST_CONN_INCR(session, page_forcible_evict_blocked); - stalled = 1; + stalled = true; break; } WT_RET(ret); diff --git a/src/third_party/wiredtiger/src/btree/bt_ret.c b/src/third_party/wiredtiger/src/btree/bt_ret.c index 5009a2096be..c7a4b8e22f4 100644 --- a/src/third_party/wiredtiger/src/btree/bt_ret.c +++ b/src/third_party/wiredtiger/src/btree/bt_ret.c @@ -99,7 +99,7 @@ __wt_kv_return(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, WT_UPDATE *upd) cursor->key.size = cbt->row_key->size; } else WT_RET(__wt_row_leaf_key( - session, page, rip, &cursor->key, 0)); + session, page, rip, &cursor->key, false)); /* If the cursor references a WT_UPDATE item, return it. */ if (upd != NULL) { diff --git a/src/third_party/wiredtiger/src/btree/bt_slvg.c b/src/third_party/wiredtiger/src/btree/bt_slvg.c index 0edbe75ba60..4f7fdc97f5f 100644 --- a/src/third_party/wiredtiger/src/btree/bt_slvg.c +++ b/src/third_party/wiredtiger/src/btree/bt_slvg.c @@ -32,7 +32,7 @@ struct __wt_stuff { uint8_t page_type; /* Page type */ /* If need to free blocks backing merged page ranges. */ - int merge_free; + bool merge_free; WT_ITEM *tmp1; /* Verbose print buffer */ WT_ITEM *tmp2; /* Verbose print buffer */ @@ -127,7 +127,7 @@ static int __slvg_merge_block_free(WT_SESSION_IMPL *, WT_STUFF *); static int WT_CDECL __slvg_ovfl_compare(const void *, const void *); static int __slvg_ovfl_discard(WT_SESSION_IMPL *, WT_STUFF *); static int __slvg_ovfl_reconcile(WT_SESSION_IMPL *, WT_STUFF *); -static int __slvg_ovfl_ref(WT_SESSION_IMPL *, WT_TRACK *, int); +static int __slvg_ovfl_ref(WT_SESSION_IMPL *, WT_TRACK *, bool); static int __slvg_ovfl_ref_all(WT_SESSION_IMPL *, WT_TRACK *); static int __slvg_read(WT_SESSION_IMPL *, WT_STUFF *); static int __slvg_row_build_internal(WT_SESSION_IMPL *, uint32_t, WT_STUFF *); @@ -143,7 +143,7 @@ static int __slvg_row_trk_update_start( static int WT_CDECL __slvg_trk_compare_addr(const void *, const void *); static int WT_CDECL __slvg_trk_compare_gen(const void *, const void *); static int WT_CDECL __slvg_trk_compare_key(const void *, const void *); -static int __slvg_trk_free(WT_SESSION_IMPL *, WT_TRACK **, int); +static int __slvg_trk_free(WT_SESSION_IMPL *, WT_TRACK **, bool); static void __slvg_trk_free_addr(WT_SESSION_IMPL *, WT_TRACK *); static int __slvg_trk_init(WT_SESSION_IMPL *, uint8_t *, size_t, uint32_t, uint64_t, WT_STUFF *, WT_TRACK **); @@ -365,7 +365,7 @@ __slvg_read(WT_SESSION_IMPL *session, WT_STUFF *ss) const WT_PAGE_HEADER *dsk; size_t addr_size; uint8_t addr[WT_BTREE_MAX_ADDR_COOKIE]; - int eof, valid; + bool eof, valid; bm = S2BT(session)->bm; WT_ERR(__wt_scr_alloc(session, 0, &as)); @@ -391,9 +391,9 @@ __slvg_read(WT_SESSION_IMPL *session, WT_STUFF *ss) * Report the block's status to the block manager. */ if ((ret = __wt_bt_read(session, buf, addr, addr_size)) == 0) - valid = 1; + valid = true; else { - valid = 0; + valid = false; if (ret == WT_ERROR) ret = 0; WT_ERR(ret); @@ -988,8 +988,8 @@ delete_b: /* if (b_trk->shared->ref == 1) for (i = 0; i < b_trk->trk_ovfl_cnt; ++i) WT_RET(__slvg_trk_free(session, - &ss->ovfl[b_trk->trk_ovfl_slot[i]], 1)); - return (__slvg_trk_free(session, &ss->pages[b_slot], 1)); + &ss->ovfl[b_trk->trk_ovfl_slot[i]], true)); + return (__slvg_trk_free(session, &ss->pages[b_slot], true)); } /* @@ -1162,8 +1162,8 @@ __slvg_col_build_internal( addr = NULL; /* Allocate a column-store root (internal) page and fill it in. */ - WT_RET( - __wt_page_alloc(session, WT_PAGE_COL_INT, 1, leaf_cnt, 1, &page)); + WT_RET(__wt_page_alloc( + session, WT_PAGE_COL_INT, 1, leaf_cnt, true, &page)); WT_ERR(__slvg_modify_init(session, page)); pindex = WT_INTL_INDEX_GET_SAFE(page); @@ -1199,7 +1199,7 @@ __slvg_col_build_internal( * additional pass to free the merge page's backing blocks. */ if (F_ISSET(trk, WT_TRACK_MERGE)) { - ss->merge_free = 1; + ss->merge_free = true; WT_ERR(__slvg_col_build_leaf(session, trk, ref)); } else @@ -1207,7 +1207,7 @@ __slvg_col_build_internal( ++ref; } - __wt_root_ref_init(&ss->root_ref, page, 1); + __wt_root_ref_init(&ss->root_ref, page, true); if (0) { err: if (addr != NULL) @@ -1333,7 +1333,7 @@ __slvg_col_ovfl_single( ovfl = trk->ss->ovfl[trk->trk_ovfl_slot[i]]; if (unpack->size == ovfl->trk_addr_size && memcmp(unpack->data, ovfl->trk_addr, unpack->size) == 0) - return (__slvg_ovfl_ref(session, ovfl, 0)); + return (__slvg_ovfl_ref(session, ovfl, false)); } WT_PANIC_RET(session, @@ -1635,8 +1635,8 @@ delete_b: /* if (b_trk->shared->ref == 1) for (i = 0; i < b_trk->trk_ovfl_cnt; ++i) WT_RET(__slvg_trk_free(session, - &ss->ovfl[b_trk->trk_ovfl_slot[i]], 1)); - return (__slvg_trk_free(session, &ss->pages[b_slot], 1)); + &ss->ovfl[b_trk->trk_ovfl_slot[i]], true)); + return (__slvg_trk_free(session, &ss->pages[b_slot], true)); } /* @@ -1719,11 +1719,12 @@ __slvg_row_trk_update_start( WT_ROW *rip; WT_TRACK *trk; uint32_t i; - int cmp, found; + int cmp; + bool found; btree = S2BT(session); page = NULL; - found = 0; + found = false; trk = ss->pages[slot]; @@ -1757,10 +1758,10 @@ __slvg_row_trk_update_start( */ WT_ERR(__wt_scr_alloc(session, 0, &key)); WT_ROW_FOREACH(page, rip, i) { - WT_ERR(__wt_row_leaf_key(session, page, rip, key, 0)); + WT_ERR(__wt_row_leaf_key(session, page, rip, key, false)); WT_ERR(__wt_compare(session, btree->collator, key, stop, &cmp)); if (cmp > 0) { - found = 1; + found = true; break; } } @@ -1821,8 +1822,8 @@ __slvg_row_build_internal( addr = NULL; /* Allocate a row-store root (internal) page and fill it in. */ - WT_RET( - __wt_page_alloc(session, WT_PAGE_ROW_INT, 0, leaf_cnt, 1, &page)); + WT_RET(__wt_page_alloc( + session, WT_PAGE_ROW_INT, 0, leaf_cnt, true, &page)); WT_ERR(__slvg_modify_init(session, page)); pindex = WT_INTL_INDEX_GET_SAFE(page); @@ -1858,7 +1859,7 @@ __slvg_row_build_internal( * additional pass to free the merge page's backing blocks. */ if (F_ISSET(trk, WT_TRACK_MERGE)) { - ss->merge_free = 1; + ss->merge_free = true; WT_ERR(__slvg_row_build_leaf(session, trk, ref, ss)); } else { @@ -1870,7 +1871,7 @@ __slvg_row_build_internal( ++ref; } - __wt_root_ref_init(&ss->root_ref, page, 0); + __wt_root_ref_init(&ss->root_ref, page, false); if (0) { err: if (addr != NULL) @@ -1928,7 +1929,8 @@ __slvg_row_build_leaf( skip_start = skip_stop = 0; if (F_ISSET(trk, WT_TRACK_CHECK_START)) WT_ROW_FOREACH(page, rip, i) { - WT_ERR(__wt_row_leaf_key(session, page, rip, key, 0)); + WT_ERR( + __wt_row_leaf_key(session, page, rip, key, false)); /* * >= is correct: see the comment above. @@ -1951,7 +1953,8 @@ __slvg_row_build_leaf( } if (F_ISSET(trk, WT_TRACK_CHECK_STOP)) WT_ROW_FOREACH_REVERSE(page, rip, i) { - WT_ERR(__wt_row_leaf_key(session, page, rip, key, 0)); + WT_ERR( + __wt_row_leaf_key(session, page, rip, key, false)); /* * < is correct: see the comment above. @@ -1984,7 +1987,7 @@ __slvg_row_build_leaf( * a copy from the page. */ rip = page->pg_row_d + skip_start; - WT_ERR(__wt_row_leaf_key(session, page, rip, key, 0)); + WT_ERR(__wt_row_leaf_key(session, page, rip, key, false)); WT_ERR(__wt_row_ikey_incr( session, ref->home, 0, key->data, key->size, ref)); @@ -2063,7 +2066,7 @@ __slvg_row_ovfl_single(WT_SESSION_IMPL *session, WT_TRACK *trk, WT_CELL *cell) ovfl = trk->ss->ovfl[trk->trk_ovfl_slot[i]]; if (unpack.size == ovfl->trk_addr_size && memcmp(unpack.data, ovfl->trk_addr, unpack.size) == 0) - return (__slvg_ovfl_ref(session, ovfl, 1)); + return (__slvg_ovfl_ref(session, ovfl, true)); } WT_PANIC_RET(session, @@ -2223,7 +2226,7 @@ __slvg_ovfl_reconcile(WT_SESSION_IMPL *session, WT_STUFF *ss) while (j > 0) F_CLR(ss->ovfl[slot[--j]], WT_TRACK_OVFL_REFD); trk = NULL; - WT_ERR(__slvg_trk_free(session, &ss->pages[i], 1)); + WT_ERR(__slvg_trk_free(session, &ss->pages[i], true)); break; } @@ -2342,7 +2345,7 @@ __slvg_merge_block_free(WT_SESSION_IMPL *session, WT_STUFF *ss) if ((trk = ss->pages[i]) == NULL) continue; if (F_ISSET(trk, WT_TRACK_MERGE)) - WT_RET(__slvg_trk_free(session, &ss->pages[i], 1)); + WT_RET(__slvg_trk_free(session, &ss->pages[i], true)); } /* Free any unused overflow records. */ @@ -2354,7 +2357,7 @@ __slvg_merge_block_free(WT_SESSION_IMPL *session, WT_STUFF *ss) * Reference an overflow page, checking for multiple references. */ static int -__slvg_ovfl_ref(WT_SESSION_IMPL *session, WT_TRACK *trk, int multi_panic) +__slvg_ovfl_ref(WT_SESSION_IMPL *session, WT_TRACK *trk, bool multi_panic) { if (F_ISSET(trk, WT_TRACK_OVFL_REFD)) { if (!multi_panic) @@ -2413,7 +2416,7 @@ __slvg_ovfl_discard(WT_SESSION_IMPL *session, WT_STUFF *ss) "%s unused overflow page", __wt_addr_string( session, trk->trk_addr, trk->trk_addr_size, ss->tmp1))); - WT_RET(__slvg_trk_free(session, &ss->ovfl[i], 1)); + WT_RET(__slvg_trk_free(session, &ss->ovfl[i], true)); } return (0); @@ -2431,13 +2434,13 @@ __slvg_cleanup(WT_SESSION_IMPL *session, WT_STUFF *ss) /* Discard the leaf page array. */ for (i = 0; i < ss->pages_next; ++i) if (ss->pages[i] != NULL) - WT_RET(__slvg_trk_free(session, &ss->pages[i], 0)); + WT_RET(__slvg_trk_free(session, &ss->pages[i], false)); __wt_free(session, ss->pages); /* Discard the ovfl page array. */ for (i = 0; i < ss->ovfl_next; ++i) if (ss->ovfl[i] != NULL) - WT_RET(__slvg_trk_free(session, &ss->ovfl[i], 0)); + WT_RET(__slvg_trk_free(session, &ss->ovfl[i], false)); __wt_free(session, ss->ovfl); return (0); @@ -2487,7 +2490,8 @@ __slvg_trk_free_block(WT_SESSION_IMPL *session, WT_TRACK *trk) * Discard a WT_TRACK structure and (optionally) its underlying blocks. */ static int -__slvg_trk_free(WT_SESSION_IMPL *session, WT_TRACK **trkp, int free_on_last_ref) +__slvg_trk_free( + WT_SESSION_IMPL *session, WT_TRACK **trkp, bool free_on_last_ref) { WT_TRACK *trk; diff --git a/src/third_party/wiredtiger/src/btree/bt_split.c b/src/third_party/wiredtiger/src/btree/bt_split.c index 3753747c358..dba0b7883a0 100644 --- a/src/third_party/wiredtiger/src/btree/bt_split.c +++ b/src/third_party/wiredtiger/src/btree/bt_split.c @@ -149,7 +149,7 @@ __wt_split_stash_discard_all( */ static int __split_safe_free(WT_SESSION_IMPL *session, - uint64_t split_gen, int exclusive, void *p, size_t s) + uint64_t split_gen, bool exclusive, void *p, size_t s) { /* We should only call safe free if we aren't pinning the memory. */ WT_ASSERT(session, session->split_gen != split_gen); @@ -159,7 +159,7 @@ __split_safe_free(WT_SESSION_IMPL *session, * access, check whether there are other threads in the same tree. */ if (!exclusive && __split_oldest_gen(session) > split_gen) - exclusive = 1; + exclusive = true; if (exclusive) { __wt_free(session, p); @@ -191,31 +191,27 @@ __split_should_deepen(WT_SESSION_IMPL *session, WT_REF *ref) pindex = WT_INTL_INDEX_GET_SAFE(page); /* - * Deepen the tree if the page's memory footprint is larger than the - * maximum size for a page in memory (presumably putting eviction - * pressure on the cache). + * Sanity check for a reasonable number of keys on-page keys. Splitting + * with too few keys leads to excessively deep trees. */ - if (page->memory_footprint < btree->maxmempage) + if (pindex->entries < 100) return (false); /* - * Ensure the page has enough entries to make it worth splitting and - * we get a significant payback (in the case of a set of large keys, - * splitting won't help). + * Deepen the tree if the page's memory footprint is larger than the + * maximum size for a page in memory (presumably putting eviction + * pressure on the cache). */ - if (pindex->entries > btree->split_deepen_min_child) + if (page->memory_footprint > btree->maxmempage) return (true); /* - * Don't allow a single page to put pressure on cache usage. The root - * page cannot be evicted, so if it's larger than the maximum, or if - * and page has a quarter of the cache, let it split, a deep tree is - * better than making no progress at all. Sanity check for 100 on-page - * keys, nothing helps in the case of large keys and a too-small cache. + * Check if the page has enough keys to make it worth splitting. If + * the number of keys is allowed to grow too large, the cost of + * splitting into parent pages can become large enough to result + * in slow operations. */ - if (pindex->entries >= 100 && - (__wt_ref_is_root(ref) || - page->memory_footprint >= S2C(session)->cache_size / 4)) + if (pindex->entries > btree->split_deepen_min_child) return (true); return (false); @@ -249,8 +245,18 @@ __split_ovfl_key_cleanup(WT_SESSION_IMPL *session, WT_PAGE *page, WT_REF *ref) cell = WT_PAGE_REF_OFFSET(page, cell_offset); __wt_cell_unpack(cell, &kpack); - if (kpack.ovfl && kpack.raw != WT_CELL_KEY_OVFL_RM) + if (kpack.ovfl && kpack.raw != WT_CELL_KEY_OVFL_RM) { + /* + * Eviction cannot free overflow items once a checkpoint is + * running in a tree: that can corrupt the checkpoint's block + * management. Assert that checkpoints aren't running to make + * sure we're catching all paths and to avoid regressions. + */ + WT_ASSERT(session, + S2BT(session)->checkpointing != WT_CKPT_RUNNING); + WT_RET(__wt_ovfl_discard(session, cell)); + } return (0); } @@ -337,7 +343,8 @@ __split_verify_intl_key_order(WT_SESSION_IMPL *session, WT_PAGE *page) WT_ITEM *next, _next, *last, _last, *tmp; WT_REF *ref; uint64_t recno; - int cmp, first; + int cmp; + bool first; btree = S2BT(session); @@ -355,12 +362,12 @@ __split_verify_intl_key_order(WT_SESSION_IMPL *session, WT_PAGE *page) last = &_last; WT_CLEAR(_last); - first = 1; + first = true; WT_INTL_FOREACH_BEGIN(session, page, ref) { __wt_ref_key(page, ref, &next->data, &next->size); if (last->size == 0) { if (first) - first = 0; + first = false; else { WT_ASSERT(session, __wt_compare( session, btree->collator, last, @@ -394,7 +401,7 @@ __split_deepen(WT_SESSION_IMPL *session, WT_PAGE *parent) uint64_t split_gen; uint32_t children, chunk, i, j, moved_entries, new_entries, remain; uint32_t skip_leading, slots; - int panic; + bool panic; void *p; WT_STAT_FAST_CONN_INCR(session, cache_eviction_deepen); @@ -403,7 +410,7 @@ __split_deepen(WT_SESSION_IMPL *session, WT_PAGE *parent) btree = S2BT(session); alloc_index = NULL; parent_incr = parent_decr = 0; - panic = 0; + panic = false; /* * Our caller is holding the parent page locked to single-thread splits, @@ -485,7 +492,7 @@ __split_deepen(WT_SESSION_IMPL *session, WT_PAGE *parent) i = 0; i < children; ++i) { slots = i == children - 1 ? remain : chunk; WT_ERR(__wt_page_alloc( - session, parent->type, 0, slots, 0, &child)); + session, parent->type, 0, slots, false, &child)); /* * Initialize the parent page's child reference; we need a copy @@ -562,7 +569,7 @@ __split_deepen(WT_SESSION_IMPL *session, WT_PAGE *parent) WT_ASSERT(session, WT_INTL_INDEX_GET_SAFE(parent) == pindex); WT_INTL_INDEX_SET(parent, alloc_index); split_gen = __wt_atomic_addv64(&S2C(session)->split_gen, 1); - panic = 1; + panic = true; #ifdef HAVE_DIAGNOSTIC WT_WITH_PAGE_INDEX(session, @@ -656,7 +663,7 @@ __split_deepen(WT_SESSION_IMPL *session, WT_PAGE *parent) __wt_cache_page_inmem_decr(session, parent, parent_decr); if (0) { -err: __wt_free_ref_index(session, parent, alloc_index, 1); +err: __wt_free_ref_index(session, parent, alloc_index, true); /* * If panic is set, we saw an error after opening up the tree @@ -724,7 +731,7 @@ __split_multi_inmem( /* Apply the modification. */ WT_ERR(__wt_col_modify( - session, &cbt, recno, NULL, upd, 0)); + session, &cbt, recno, NULL, upd, false)); break; case WT_PAGE_ROW_LEAF: /* Build a key. */ @@ -734,7 +741,7 @@ __split_multi_inmem( orig->pg_row_upd[slot] = NULL; WT_ERR(__wt_row_leaf_key( - session, orig, supd->rip, key, 0)); + session, orig, supd->rip, key, false)); } else { upd = supd->ins->upd; supd->ins->upd = NULL; @@ -744,11 +751,11 @@ __split_multi_inmem( } /* Search the page. */ - WT_ERR(__wt_row_search(session, key, ref, &cbt, 1)); + WT_ERR(__wt_row_search(session, key, ref, &cbt, true)); /* Apply the modification. */ - WT_ERR( - __wt_row_modify(session, &cbt, key, NULL, upd, 0)); + WT_ERR(__wt_row_modify( + session, &cbt, key, NULL, upd, false)); break; WT_ILLEGAL_VALUE_ERR(session); } @@ -763,7 +770,7 @@ __split_multi_inmem( page->modify->first_dirty_txn = WT_TXN_FIRST; err: /* Free any resources that may have been cached in the cursor. */ - WT_TRET(__wt_btcur_close(&cbt, 1)); + WT_TRET(__wt_btcur_close(&cbt, true)); __wt_scr_free(session, &key); return (ret); @@ -840,30 +847,19 @@ __wt_multi_to_ref(WT_SESSION_IMPL *session, } /* - * __split_parent -- - * Resolve a multi-page split, inserting new information into the parent. + * __split_parent_lock -- + * Lock the parent page. */ static int -__split_parent(WT_SESSION_IMPL *session, WT_REF *ref, - WT_REF **ref_new, uint32_t new_entries, size_t parent_incr, int exclusive) +__split_parent_lock( + WT_SESSION_IMPL *session, WT_REF *ref, WT_PAGE **parentp, bool *hazardp) { WT_DECL_RET; - WT_IKEY *ikey; WT_PAGE *parent; - WT_PAGE_INDEX *alloc_index, *pindex; - WT_REF **alloc_refp, *next_ref, *parent_ref; - size_t parent_decr, size; - uint64_t split_gen; - uint32_t i, j; - uint32_t deleted_entries, parent_entries, result_entries; - int complete, hazard; + WT_REF *parent_ref; - parent = NULL; /* -Wconditional-uninitialized */ - alloc_index = pindex = NULL; - parent_ref = NULL; - parent_decr = 0; - parent_entries = 0; - complete = hazard = 0; + *hazardp = false; + *parentp = NULL; /* * Get a page-level lock on the parent to single-thread splits into the @@ -905,7 +901,7 @@ __split_parent(WT_SESSION_IMPL *session, WT_REF *ref, * loop until the exclusive lock is resolved). If we can't lock * the parent, give up to avoid that deadlock. */ - if (S2BT(session)->checkpointing) + if (S2BT(session)->checkpointing != WT_CKPT_OFF) return (EBUSY); __wt_yield(); } @@ -924,12 +920,62 @@ __split_parent(WT_SESSION_IMPL *session, WT_REF *ref, */ if (!__wt_ref_is_root(parent_ref = parent->pg_intl_parent_ref)) { WT_ERR(__wt_page_in(session, parent_ref, WT_READ_NO_EVICT)); - hazard = 1; + *hazardp = true; } + *parentp = parent; + return (0); + +err: F_CLR_ATOMIC(parent, WT_PAGE_RECONCILIATION); + return (ret); +} + +/* + * __split_parent_unlock -- + * Unlock the parent page. + */ +static int +__split_parent_unlock(WT_SESSION_IMPL *session, WT_PAGE *parent, bool hazard) +{ + WT_DECL_RET; + + if (hazard) + ret = __wt_hazard_clear(session, parent); + + F_CLR_ATOMIC(parent, WT_PAGE_RECONCILIATION); + return (ret); +} + +/* + * __split_parent -- + * Resolve a multi-page split, inserting new information into the parent. + */ +static int +__split_parent(WT_SESSION_IMPL *session, WT_REF *ref, + WT_REF **ref_new, uint32_t new_entries, size_t parent_incr, int exclusive) +{ + WT_DECL_RET; + WT_IKEY *ikey; + WT_PAGE *parent; + WT_PAGE_INDEX *alloc_index, *pindex; + WT_REF **alloc_refp, *next_ref, *parent_ref; + size_t parent_decr, size; + uint64_t split_gen; + uint32_t i, j; + uint32_t deleted_entries, parent_entries, result_entries; + bool complete; + + parent = ref->home; + parent_ref = parent->pg_intl_parent_ref; + + alloc_index = pindex = NULL; + parent_decr = 0; + parent_entries = 0; + complete = false; + /* - * We've locked the parent above, which means it cannot split (which is - * the only reason to worry about split generation values). + * We've locked the parent, which means it cannot split (which is the + * only reason to worry about split generation values). */ pindex = WT_INTL_INDEX_GET_SAFE(parent); parent_entries = pindex->entries; @@ -1033,7 +1079,7 @@ __split_parent(WT_SESSION_IMPL *session, WT_REF *ref, * split is OK and complete. For those reasons, we ignore errors past * this point unless there's a panic. */ - complete = 1; + complete = true; WT_ERR(__wt_verbose(session, WT_VERB_SPLIT, "%s split into parent %" PRIu32 " -> %" PRIu32 @@ -1137,12 +1183,8 @@ err: if (!complete) if (next_ref->state == WT_REF_SPLIT) next_ref->state = WT_REF_DELETED; } - F_CLR_ATOMIC(parent, WT_PAGE_RECONCILIATION); - if (hazard) - WT_TRET(__wt_hazard_clear(session, parent)); - - __wt_free_ref_index(session, NULL, alloc_index, 0); + __wt_free_ref_index(session, NULL, alloc_index, false); /* * A note on error handling: if we completed the split, return success, @@ -1156,12 +1198,11 @@ err: if (!complete) } /* - * __wt_split_insert -- - * Check for pages with append-only workloads and split their last insert - * list into a separate page. + * __split_insert -- + * Split a page's last insert list entries into a separate page. */ -int -__wt_split_insert(WT_SESSION_IMPL *session, WT_REF *ref) +static int +__split_insert(WT_SESSION_IMPL *session, WT_REF *ref) { WT_DECL_RET; WT_DECL_ITEM(key); @@ -1229,7 +1270,7 @@ __wt_split_insert(WT_SESSION_IMPL *session, WT_REF *ref) key->size = WT_INSERT_KEY_SIZE(ins); } else WT_ERR(__wt_row_leaf_key( - session, page, &page->pg_row_d[0], key, 1)); + session, page, &page->pg_row_d[0], key, true)); WT_ERR(__wt_row_ikey(session, 0, key->data, key->size, child)); parent_incr += sizeof(WT_REF) + sizeof(WT_IKEY) + key->size; __wt_scr_free(session, &key); @@ -1237,7 +1278,7 @@ __wt_split_insert(WT_SESSION_IMPL *session, WT_REF *ref) /* * The second page in the split is a new WT_REF/page pair. */ - WT_ERR(__wt_page_alloc(session, WT_PAGE_ROW_LEAF, 0, 0, 0, &right)); + WT_ERR(__wt_page_alloc(session, WT_PAGE_ROW_LEAF, 0, 0, false, &right)); WT_ERR(__wt_calloc_one(session, &right->pg_row_ins)); WT_ERR(__wt_calloc_one(session, &right->pg_row_ins[0])); right_incr += sizeof(WT_INSERT_HEAD); @@ -1384,7 +1425,7 @@ __wt_split_insert(WT_SESSION_IMPL *session, WT_REF *ref) */ page = NULL; if ((ret = __split_parent( - session, ref, split_ref, 2, parent_incr, 0)) != 0) { + session, ref, split_ref, 2, parent_incr, false)) != 0) { /* * Move the insert list element back to the original page list. * For simplicity, the previous skip list pointers originally @@ -1425,9 +1466,26 @@ err: if (split_ref[0] != NULL) { return (ret); } +/* + * __wt_split_insert -- + * Lock, then split. + */ +int +__wt_split_insert(WT_SESSION_IMPL *session, WT_REF *ref) +{ + WT_DECL_RET; + WT_PAGE *parent; + bool hazard; + + WT_RET(__split_parent_lock(session, ref, &parent, &hazard)); + ret = __split_insert(session, ref); + WT_TRET(__split_parent_unlock(session, parent, hazard)); + return (ret); +} + /* * __wt_split_rewrite -- - * Resolve a failed reconciliation by replacing a page with a new version. + * Rewrite an in-memory page with a new version. */ int __wt_split_rewrite(WT_SESSION_IMPL *session, WT_REF *ref) @@ -1469,11 +1527,11 @@ __wt_split_rewrite(WT_SESSION_IMPL *session, WT_REF *ref) } /* - * __wt_split_multi -- - * Resolve a page split. + * __split_multi -- + * Split a page into multiple pages. */ -int -__wt_split_multi(WT_SESSION_IMPL *session, WT_REF *ref, int closing) +static int +__split_multi(WT_SESSION_IMPL *session, WT_REF *ref, bool closing) { WT_DECL_RET; WT_PAGE *page; @@ -1533,7 +1591,24 @@ err: /* * For now, leak the memory by not discarding the instantiated pages. */ for (i = 0; i < new_entries; ++i) - __wt_free_ref(session, page, ref_new[i], 0); + __wt_free_ref(session, page, ref_new[i], false); __wt_free(session, ref_new); return (ret); } + +/* + * __wt_split_multi -- + * Lock, then split. + */ +int +__wt_split_multi(WT_SESSION_IMPL *session, WT_REF *ref, int closing) +{ + WT_DECL_RET; + WT_PAGE *parent; + bool hazard; + + WT_RET(__split_parent_lock(session, ref, &parent, &hazard)); + ret = __split_multi(session, ref, closing); + WT_TRET(__split_parent_unlock(session, parent, hazard)); + return (ret); +} diff --git a/src/third_party/wiredtiger/src/btree/bt_stat.c b/src/third_party/wiredtiger/src/btree/bt_stat.c index b379712f6e7..2f8759b9d82 100644 --- a/src/third_party/wiredtiger/src/btree/bt_stat.c +++ b/src/third_party/wiredtiger/src/btree/bt_stat.c @@ -117,7 +117,7 @@ __stat_page_col_var( WT_UPDATE *upd; uint64_t deleted_cnt, entry_cnt, ovfl_cnt, rle_cnt; uint32_t i; - int orig_deleted; + bool orig_deleted; unpack = &_unpack; deleted_cnt = entry_cnt = ovfl_cnt = rle_cnt = 0; @@ -134,13 +134,13 @@ __stat_page_col_var( */ WT_COL_FOREACH(page, cip, i) { if ((cell = WT_COL_PTR(page, cip)) == NULL) { - orig_deleted = 1; + orig_deleted = true; ++deleted_cnt; } else { - orig_deleted = 0; + orig_deleted = false; __wt_cell_unpack(cell, unpack); if (unpack->type == WT_CELL_ADDR_DEL) - orig_deleted = 1; + orig_deleted = true; else { entry_cnt += __wt_cell_rle(unpack); rle_cnt += __wt_cell_rle(unpack) - 1; diff --git a/src/third_party/wiredtiger/src/btree/bt_sync.c b/src/third_party/wiredtiger/src/btree/bt_sync.c index 29ae5b185cd..247bdef65c8 100644 --- a/src/third_party/wiredtiger/src/btree/bt_sync.c +++ b/src/third_party/wiredtiger/src/btree/bt_sync.c @@ -25,7 +25,7 @@ __sync_file(WT_SESSION_IMPL *session, int syncop) uint64_t internal_bytes, leaf_bytes; uint64_t internal_pages, leaf_pages; uint32_t flags; - int evict_reset; + bool evict_reset; btree = S2BT(session); @@ -99,13 +99,14 @@ __sync_file(WT_SESSION_IMPL *session, int syncop) * internal page pass is complete, then wait for any existing * eviction to complete. */ - btree->checkpointing = 1; - WT_FULL_BARRIER(); + WT_PUBLISH(btree->checkpointing, WT_CKPT_PREPARE); WT_ERR(__wt_evict_file_exclusive_on(session, &evict_reset)); if (evict_reset) __wt_evict_file_exclusive_off(session); + WT_PUBLISH(btree->checkpointing, WT_CKPT_RUNNING); + /* Write all dirty in-cache pages. */ flags |= WT_READ_NO_EVICT; for (walk = NULL;;) { @@ -140,7 +141,7 @@ __sync_file(WT_SESSION_IMPL *session, int syncop) if (!WT_PAGE_IS_INTERNAL(page) && F_ISSET(txn, WT_TXN_HAS_SNAPSHOT) && WT_TXNID_LT(txn->snap_max, mod->first_dirty_txn) && - !F_ISSET(mod, WT_PM_REC_REWRITE)) { + mod->rec_result != WT_PM_REC_REWRITE) { __wt_page_modify_set(session, page); continue; } @@ -177,7 +178,7 @@ err: /* On error, clear any left-over tree walk. */ if (txn->isolation == WT_ISO_READ_COMMITTED && session->ncursors == 0) __wt_txn_release_snapshot(session); - if (btree->checkpointing) { + if (btree->checkpointing != WT_CKPT_OFF) { /* * Update the checkpoint generation for this handle so visible * updates newer than the checkpoint can be evicted. @@ -195,7 +196,7 @@ err: /* On error, clear any left-over tree walk. */ * but publishing the change means stalled eviction gets moving * as soon as possible. */ - btree->checkpointing = 0; + btree->checkpointing = WT_CKPT_OFF; WT_FULL_BARRIER(); /* @@ -221,7 +222,7 @@ err: /* On error, clear any left-over tree walk. */ * but don't wait for it. */ if (ret == 0 && syncop == WT_SYNC_WRITE_LEAVES) - WT_RET(btree->bm->sync(btree->bm, session, 1)); + WT_RET(btree->bm->sync(btree->bm, session, true)); return (ret); } diff --git a/src/third_party/wiredtiger/src/btree/bt_vrfy.c b/src/third_party/wiredtiger/src/btree/bt_vrfy.c index 1fd660d4cd4..d745210bdce 100644 --- a/src/third_party/wiredtiger/src/btree/bt_vrfy.c +++ b/src/third_party/wiredtiger/src/btree/bt_vrfy.c @@ -23,10 +23,10 @@ typedef struct { #define WT_VRFY_DUMP(vs) \ ((vs)->dump_address || \ (vs)->dump_blocks || (vs)->dump_pages || (vs)->dump_shape) - int dump_address; /* Configure: dump special */ - int dump_blocks; - int dump_pages; - int dump_shape; + bool dump_address; /* Configure: dump special */ + bool dump_blocks; + bool dump_pages; + bool dump_shape; u_int depth, depth_internal[100], depth_leaf[100]; @@ -38,7 +38,7 @@ static void __verify_checkpoint_reset(WT_VSTUFF *); static int __verify_overflow( WT_SESSION_IMPL *, const uint8_t *, size_t, WT_VSTUFF *); static int __verify_overflow_cell( - WT_SESSION_IMPL *, WT_REF *, int *, WT_VSTUFF *); + WT_SESSION_IMPL *, WT_REF *, bool *, WT_VSTUFF *); static int __verify_row_int_key_order( WT_SESSION_IMPL *, WT_PAGE *, WT_REF *, uint32_t, WT_VSTUFF *); static int __verify_row_leaf_key_order( @@ -79,14 +79,15 @@ __verify_config(WT_SESSION_IMPL *session, const char *cfg[], WT_VSTUFF *vs) * Debugging: optionally dump specific blocks from the file. */ static int -__verify_config_offsets(WT_SESSION_IMPL *session, const char *cfg[], int *quitp) +__verify_config_offsets( + WT_SESSION_IMPL *session, const char *cfg[], bool *quitp) { WT_CONFIG list; WT_CONFIG_ITEM cval, k, v; WT_DECL_RET; u_long offset; - *quitp = 0; + *quitp = false; WT_RET(__wt_config_gets(session, cfg, "dump_offsets", &cval)); WT_RET(__wt_config_subinit(session, &list, &cval)); @@ -96,7 +97,7 @@ __verify_config_offsets(WT_SESSION_IMPL *session, const char *cfg[], int *quitp) * what the user wanted, all of this stuff is just hooked into * verify because that's where we "dump blocks" for debugging.) */ - *quitp = 1; + *quitp = true; if (v.len != 0 || sscanf(k.str, "%lu", &offset) != 1) WT_RET_MSG(session, EINVAL, "unexpected dump offset format"); @@ -156,12 +157,12 @@ __wt_verify(WT_SESSION_IMPL *session, const char *cfg[]) WT_VSTUFF *vs, _vstuff; size_t root_addr_size; uint8_t root_addr[WT_BTREE_MAX_ADDR_COOKIE]; - int bm_start, quit; + bool bm_start, quit; btree = S2BT(session); bm = btree->bm; ckptbase = NULL; - bm_start = 0; + bm_start = false; WT_CLEAR(_vstuff); vs = &_vstuff; @@ -184,7 +185,7 @@ __wt_verify(WT_SESSION_IMPL *session, const char *cfg[]) /* Inform the underlying block manager we're verifying. */ WT_ERR(bm->verify_start(bm, session, ckptbase, cfg)); - bm_start = 1; + bm_start = true; /* Loop through the file's checkpoints, verifying each one. */ WT_CKPT_FOREACH(ckptbase, ckpt) { @@ -205,7 +206,7 @@ __wt_verify(WT_SESSION_IMPL *session, const char *cfg[]) /* Load the checkpoint. */ WT_ERR(bm->checkpoint_load(bm, session, ckpt->raw.data, ckpt->raw.size, - root_addr, &root_addr_size, 1)); + root_addr, &root_addr_size, true)); /* * Ignore trees with no root page. @@ -293,7 +294,7 @@ __verify_tree(WT_SESSION_IMPL *session, WT_REF *ref, WT_VSTUFF *vs) WT_REF *child_ref; uint64_t recno; uint32_t entry, i; - int found; + bool found; bm = S2BT(session)->bm; page = ref->page; @@ -648,7 +649,7 @@ __verify_row_leaf_key_order( */ static int __verify_overflow_cell( - WT_SESSION_IMPL *session, WT_REF *ref, int *found, WT_VSTUFF *vs) + WT_SESSION_IMPL *session, WT_REF *ref, bool *found, WT_VSTUFF *vs) { WT_BTREE *btree; WT_CELL *cell; @@ -659,7 +660,7 @@ __verify_overflow_cell( btree = S2BT(session); unpack = &_unpack; - *found = 0; + *found = false; /* * If a tree is empty (just created), it won't have a disk image; @@ -676,7 +677,7 @@ __verify_overflow_cell( switch (unpack->type) { case WT_CELL_KEY_OVFL: case WT_CELL_VALUE_OVFL: - *found = 1; + *found = true; WT_ERR(__verify_overflow( session, unpack->data, unpack->size, vs)); break; diff --git a/src/third_party/wiredtiger/src/btree/bt_vrfy_dsk.c b/src/third_party/wiredtiger/src/btree/bt_vrfy_dsk.c index cf86ca9bec3..a703fbd540d 100644 --- a/src/third_party/wiredtiger/src/btree/bt_vrfy_dsk.c +++ b/src/third_party/wiredtiger/src/btree/bt_vrfy_dsk.c @@ -43,7 +43,7 @@ static int __verify_dsk_row( */ int __wt_verify_dsk_image(WT_SESSION_IMPL *session, - const char *tag, const WT_PAGE_HEADER *dsk, size_t size, int empty_page_ok) + const char *tag, const WT_PAGE_HEADER *dsk, size_t size, bool empty_page_ok) { const uint8_t *p, *end; u_int i; @@ -178,7 +178,8 @@ __wt_verify_dsk_image(WT_SESSION_IMPL *session, int __wt_verify_dsk(WT_SESSION_IMPL *session, const char *tag, WT_ITEM *buf) { - return (__wt_verify_dsk_image(session, tag, buf->data, buf->size, 0)); + return ( + __wt_verify_dsk_image(session, tag, buf->data, buf->size, false)); } /* @@ -545,7 +546,7 @@ __verify_dsk_col_var( WT_DECL_RET; size_t last_size; uint32_t cell_num, cell_type, i; - int last_deleted; + bool last_deleted; const uint8_t *last_data; uint8_t *end; @@ -556,7 +557,7 @@ __verify_dsk_col_var( last_data = NULL; last_size = 0; - last_deleted = 0; + last_deleted = false; cell_num = 0; WT_CELL_FOREACH(btree, dsk, cell, unpack, i) { @@ -588,7 +589,7 @@ __verify_dsk_col_var( * a chance for RLE encoding. We don't have to care about data * encoding or anything else, a byte comparison is enough. */ - if (last_deleted == 1) { + if (last_deleted) { if (cell_type == WT_CELL_DEL) goto match_err; } else @@ -604,15 +605,15 @@ match_err: WT_RET_VRFY(session, switch (cell_type) { case WT_CELL_DEL: - last_deleted = 1; + last_deleted = true; last_data = NULL; break; case WT_CELL_VALUE_OVFL: - last_deleted = 0; + last_deleted = false; last_data = NULL; break; case WT_CELL_VALUE: - last_deleted = 0; + last_deleted = false; last_data = unpack->data; last_size = unpack->size; break; diff --git a/src/third_party/wiredtiger/src/btree/bt_walk.c b/src/third_party/wiredtiger/src/btree/bt_walk.c index 2705f371fb5..6e1d182ed0b 100644 --- a/src/third_party/wiredtiger/src/btree/bt_walk.c +++ b/src/third_party/wiredtiger/src/btree/bt_walk.c @@ -81,11 +81,11 @@ __wt_tree_walk(WT_SESSION_IMPL *session, WT_PAGE *page; WT_PAGE_INDEX *pindex; WT_REF *couple, *couple_orig, *ref; - int empty_internal, prev, skip; + bool empty_internal, prev, skip; uint32_t slot; btree = S2BT(session); - empty_internal = 0; + empty_internal = false; /* * Tree walks are special: they look inside page structures that splits @@ -178,7 +178,7 @@ ascend: /* */ if (empty_internal) { __wt_page_evict_soon(ref->page); - empty_internal = 0; + empty_internal = false; } /* Optionally skip internal pages. */ @@ -241,7 +241,7 @@ ascend: /* * page isn't empty. */ if (ref->state != WT_REF_DELETED) - empty_internal = 0; + empty_internal = false; if (LF_ISSET(WT_READ_CACHE)) { /* @@ -358,7 +358,7 @@ descend: couple = ref; if (WT_PAGE_IS_INTERNAL(page)) { WT_INTL_INDEX_GET(session, page, pindex); slot = prev ? pindex->entries - 1 : 0; - empty_internal = 1; + empty_internal = true; } else { *refp = ref; goto done; diff --git a/src/third_party/wiredtiger/src/btree/col_modify.c b/src/third_party/wiredtiger/src/btree/col_modify.c index cbc5143698b..bb2de3f444b 100644 --- a/src/third_party/wiredtiger/src/btree/col_modify.c +++ b/src/third_party/wiredtiger/src/btree/col_modify.c @@ -17,7 +17,7 @@ static int __col_insert_alloc( */ int __wt_col_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, - uint64_t recno, WT_ITEM *value, WT_UPDATE *upd_arg, int is_remove) + uint64_t recno, WT_ITEM *value, WT_UPDATE *upd_arg, bool is_remove) { WT_BTREE *btree; WT_DECL_RET; @@ -28,13 +28,13 @@ __wt_col_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, WT_UPDATE *old_upd, *upd; size_t ins_size, upd_size; u_int i, skipdepth; - int append, logged; + bool append, logged; btree = cbt->btree; ins = NULL; page = cbt->ref->page; upd = upd_arg; - append = logged = 0; + append = logged = false; /* This code expects a remove to have a NULL value. */ if (is_remove) { @@ -55,7 +55,7 @@ __wt_col_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, if (recno == WT_RECNO_OOB || recno > (btree->type == BTREE_COL_VAR ? __col_var_last_recno(page) : __col_fix_last_recno(page))) - append = 1; + append = true; } /* If we don't yet have a modify structure, we'll need one. */ @@ -86,7 +86,7 @@ __wt_col_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, /* Allocate a WT_UPDATE structure and transaction ID. */ WT_ERR(__wt_update_alloc(session, value, &upd, &upd_size)); WT_ERR(__wt_txn_modify(session, upd)); - logged = 1; + logged = true; /* Avoid a data copy in WT_CURSOR.update. */ cbt->modify_update = upd; @@ -139,7 +139,7 @@ __wt_col_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, WT_ERR( __wt_update_alloc(session, value, &upd, &upd_size)); WT_ERR(__wt_txn_modify(session, upd)); - logged = 1; + logged = true; /* Avoid a data copy in WT_CURSOR.update. */ cbt->modify_update = upd; diff --git a/src/third_party/wiredtiger/src/btree/row_key.c b/src/third_party/wiredtiger/src/btree/row_key.c index 4affa7fa62a..6d24708e59c 100644 --- a/src/third_party/wiredtiger/src/btree/row_key.c +++ b/src/third_party/wiredtiger/src/btree/row_key.c @@ -61,7 +61,7 @@ __wt_row_leaf_keys(WT_SESSION_IMPL *session, WT_PAGE *page) for (rip = page->pg_row_d, i = 0; i < page->pg_row_entries; ++rip, ++i) if (__bit_test(tmp->mem, i)) WT_ERR(__wt_row_leaf_key_work( - session, page, rip, key, 1)); + session, page, rip, key, true)); F_SET_ATOMIC(page, WT_PAGE_BUILD_KEYS); @@ -112,7 +112,7 @@ int __wt_row_leaf_key_copy( WT_SESSION_IMPL *session, WT_PAGE *page, WT_ROW *rip, WT_ITEM *key) { - WT_RET(__wt_row_leaf_key(session, page, rip, key, 0)); + WT_RET(__wt_row_leaf_key(session, page, rip, key, false)); /* The return buffer may only hold a reference to a key, copy it. */ if (!WT_DATA_IN_ITEM(key)) @@ -128,7 +128,7 @@ __wt_row_leaf_key_copy( */ int __wt_row_leaf_key_work(WT_SESSION_IMPL *session, - WT_PAGE *page, WT_ROW *rip_arg, WT_ITEM *keyb, int instantiate) + WT_PAGE *page, WT_ROW *rip_arg, WT_ITEM *keyb, bool instantiate) { enum { FORWARD, BACKWARD } direction; WT_BTREE *btree; diff --git a/src/third_party/wiredtiger/src/btree/row_modify.c b/src/third_party/wiredtiger/src/btree/row_modify.c index 888c54d1ec9..0fc02948dd3 100644 --- a/src/third_party/wiredtiger/src/btree/row_modify.c +++ b/src/third_party/wiredtiger/src/btree/row_modify.c @@ -47,7 +47,7 @@ __wt_page_modify_alloc(WT_SESSION_IMPL *session, WT_PAGE *page) */ int __wt_row_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, - WT_ITEM *key, WT_ITEM *value, WT_UPDATE *upd_arg, int is_remove) + WT_ITEM *key, WT_ITEM *value, WT_UPDATE *upd_arg, bool is_remove) { WT_DECL_RET; WT_INSERT *ins; @@ -57,12 +57,12 @@ __wt_row_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, size_t ins_size, upd_size; uint32_t ins_slot; u_int i, skipdepth; - int logged; + bool logged; ins = NULL; page = cbt->ref->page; upd = upd_arg; - logged = 0; + logged = false; /* This code expects a remove to have a NULL value. */ if (is_remove) @@ -100,7 +100,7 @@ __wt_row_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, WT_ERR( __wt_update_alloc(session, value, &upd, &upd_size)); WT_ERR(__wt_txn_modify(session, upd)); - logged = 1; + logged = true; /* Avoid WT_CURSOR.update data copy. */ cbt->modify_update = upd; @@ -171,7 +171,7 @@ __wt_row_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, WT_ERR( __wt_update_alloc(session, value, &upd, &upd_size)); WT_ERR(__wt_txn_modify(session, upd)); - logged = 1; + logged = true; /* Avoid WT_CURSOR.update data copy. */ cbt->modify_update = upd; diff --git a/src/third_party/wiredtiger/src/btree/row_srch.c b/src/third_party/wiredtiger/src/btree/row_srch.c index 6f2856301a6..b99c93d319a 100644 --- a/src/third_party/wiredtiger/src/btree/row_srch.c +++ b/src/third_party/wiredtiger/src/btree/row_srch.c @@ -15,7 +15,7 @@ */ static inline int __wt_search_insert_append(WT_SESSION_IMPL *session, - WT_CURSOR_BTREE *cbt, WT_ITEM *srch_key, int *donep) + WT_CURSOR_BTREE *cbt, WT_ITEM *srch_key, bool *donep) { WT_BTREE *btree; WT_COLLATOR *collator; @@ -137,7 +137,7 @@ __wt_search_insert( */ int __wt_row_search(WT_SESSION_IMPL *session, - WT_ITEM *srch_key, WT_REF *leaf, WT_CURSOR_BTREE *cbt, int insert) + WT_ITEM *srch_key, WT_REF *leaf, WT_CURSOR_BTREE *cbt, bool insert) { WT_BTREE *btree; WT_COLLATOR *collator; @@ -149,7 +149,8 @@ __wt_row_search(WT_SESSION_IMPL *session, WT_ROW *rip; size_t match, skiphigh, skiplow; uint32_t base, indx, limit; - int append_check, cmp, depth, descend_right, done; + int cmp, depth; + bool append_check, descend_right, done; btree = S2BT(session); collator = btree->collator; @@ -176,7 +177,7 @@ __wt_row_search(WT_SESSION_IMPL *session, * the cursor's append history. */ append_check = insert && cbt->append_tree; - descend_right = 1; + descend_right = true; /* We may only be searching a single leaf page, not the full tree. */ if (leaf != NULL) { @@ -213,7 +214,7 @@ restart: page = current->page; goto descend; /* A failed append check turns off append checks. */ - append_check = 0; + append_check = false; } /* @@ -282,7 +283,7 @@ restart: page = current->page; * right-side descent. */ if (pindex->entries != base - 1) - descend_right = 0; + descend_right = false; descend: /* * Swap the current page for the child page. If the page splits @@ -365,7 +366,8 @@ leaf_only: for (; limit != 0; limit >>= 1) { indx = base + (limit >> 1); rip = page->pg_row_d + indx; - WT_ERR(__wt_row_leaf_key(session, page, rip, item, 1)); + WT_ERR( + __wt_row_leaf_key(session, page, rip, item, true)); match = WT_MIN(skiplow, skiphigh); cmp = __wt_lex_compare_skip(srch_key, item, &match); @@ -382,7 +384,8 @@ leaf_only: for (; limit != 0; limit >>= 1) { indx = base + (limit >> 1); rip = page->pg_row_d + indx; - WT_ERR(__wt_row_leaf_key(session, page, rip, item, 1)); + WT_ERR( + __wt_row_leaf_key(session, page, rip, item, true)); WT_ERR(__wt_compare( session, collator, srch_key, item, &cmp)); @@ -518,7 +521,7 @@ restart: * have to as well. */ return (__wt_row_leaf_key(session, - page, page->pg_row_d + cbt->slot, cbt->tmp, 0)); + page, page->pg_row_d + cbt->slot, cbt->tmp, false)); } /* diff --git a/src/third_party/wiredtiger/src/cache/cache_las.c b/src/third_party/wiredtiger/src/cache/cache_las.c index e269e8702e1..a964ac39874 100644 --- a/src/third_party/wiredtiger/src/cache/cache_las.c +++ b/src/third_party/wiredtiger/src/cache/cache_las.c @@ -102,7 +102,7 @@ __wt_las_create(WT_SESSION_IMPL *session) * for eviction. */ WT_RET(__wt_open_internal_session( - conn, "lookaside table", 1, 1, &conn->las_session)); + conn, "lookaside table", true, true, &conn->las_session)); session = conn->las_session; F_SET(session, WT_SESSION_LOOKASIDE_CURSOR | WT_SESSION_NO_EVICTION); diff --git a/src/third_party/wiredtiger/src/config/config.c b/src/third_party/wiredtiger/src/config/config.c index 2b3b9e6ca4b..27de6264a28 100644 --- a/src/third_party/wiredtiger/src/config/config.c +++ b/src/third_party/wiredtiger/src/config/config.c @@ -580,30 +580,30 @@ __wt_config_next(WT_CONFIG *conf, WT_CONFIG_ITEM *key, WT_CONFIG_ITEM *value) */ static int __config_getraw( - WT_CONFIG *cparser, WT_CONFIG_ITEM *key, WT_CONFIG_ITEM *value, int top) + WT_CONFIG *cparser, WT_CONFIG_ITEM *key, WT_CONFIG_ITEM *value, bool top) { WT_CONFIG sparser; WT_CONFIG_ITEM k, v, subk; WT_DECL_RET; - int found; + bool found; - found = 0; + found = false; while ((ret = __config_next(cparser, &k, &v)) == 0) { if (k.type != WT_CONFIG_ITEM_STRING && k.type != WT_CONFIG_ITEM_ID) continue; if (k.len == key->len && strncmp(key->str, k.str, k.len) == 0) { *value = v; - found = 1; + found = true; } else if (k.len < key->len && key->str[k.len] == '.' && strncmp(key->str, k.str, k.len) == 0) { subk.str = key->str + k.len + 1; subk.len = (key->len - k.len) - 1; WT_RET(__wt_config_initn( cparser->session, &sparser, v.str, v.len)); - if ((ret = - __config_getraw(&sparser, &subk, value, 0)) == 0) - found = 1; + if ((ret = __config_getraw( + &sparser, &subk, value, false)) == 0) + found = true; WT_RET_NOTFOUND_OK(ret); } } @@ -640,7 +640,7 @@ __wt_config_get(WT_SESSION_IMPL *session, --cfg; WT_RET(__wt_config_init(session, &cparser, *cfg)); - if ((ret = __config_getraw(&cparser, key, value, 1)) == 0) + if ((ret = __config_getraw(&cparser, key, value, true)) == 0) return (0); WT_RET_NOTFOUND_OK(ret); } while (cfg != cfg_arg); @@ -689,7 +689,7 @@ __wt_config_getone(WT_SESSION_IMPL *session, WT_CONFIG cparser; WT_RET(__wt_config_init(session, &cparser, config)); - return (__config_getraw(&cparser, key, value, 1)); + return (__config_getraw(&cparser, key, value, true)); } /* @@ -705,7 +705,7 @@ __wt_config_getones(WT_SESSION_IMPL *session, { key, strlen(key), 0, WT_CONFIG_ITEM_STRING }; WT_RET(__wt_config_init(session, &cparser, config)); - return (__config_getraw(&cparser, &key_item, value, 1)); + return (__config_getraw(&cparser, &key_item, value, true)); } /* @@ -765,7 +765,7 @@ __wt_config_subgetraw(WT_SESSION_IMPL *session, WT_CONFIG cparser; WT_RET(__wt_config_initn(session, &cparser, cfg->str, cfg->len)); - return (__config_getraw(&cparser, key, value, 1)); + return (__config_getraw(&cparser, key, value, true)); } /* diff --git a/src/third_party/wiredtiger/src/config/config_check.c b/src/third_party/wiredtiger/src/config/config_check.c index b09a1a10a85..6b9d6c563ad 100644 --- a/src/third_party/wiredtiger/src/config/config_check.c +++ b/src/third_party/wiredtiger/src/config/config_check.c @@ -83,7 +83,8 @@ config_check(WT_SESSION_IMPL *session, WT_CONFIG parser, cparser, sparser; WT_CONFIG_ITEM k, v, ck, cv, dummy; WT_DECL_RET; - int badtype, found, i; + int i; + bool badtype, found; /* * The config_len parameter is optional, and allows passing in strings @@ -105,27 +106,26 @@ config_check(WT_SESSION_IMPL *session, session, checks, checks_entries, k.str, k.len, &i)); if (strcmp(checks[i].type, "boolean") == 0) { - badtype = (v.type != WT_CONFIG_ITEM_BOOL && + badtype = v.type != WT_CONFIG_ITEM_BOOL && (v.type != WT_CONFIG_ITEM_NUM || - (v.val != 0 && v.val != 1))); + (v.val != 0 && v.val != 1)); } else if (strcmp(checks[i].type, "category") == 0) { /* Deal with categories of the form: XXX=(XXX=blah). */ ret = config_check(session, checks[i].subconfigs, checks[i].subconfigs_entries, k.str + strlen(checks[i].name) + 1, v.len); if (ret != EINVAL) - badtype = 0; + badtype = false; else - badtype = 1; + badtype = true; } else if (strcmp(checks[i].type, "format") == 0) { - badtype = 0; + badtype = false; } else if (strcmp(checks[i].type, "int") == 0) { - badtype = (v.type != WT_CONFIG_ITEM_NUM); + badtype = v.type != WT_CONFIG_ITEM_NUM; } else if (strcmp(checks[i].type, "list") == 0) { - badtype = (v.len > 0 && - v.type != WT_CONFIG_ITEM_STRUCT); + badtype = v.len > 0 && v.type != WT_CONFIG_ITEM_STRUCT; } else if (strcmp(checks[i].type, "string") == 0) { - badtype = 0; + badtype = false; } else WT_RET_MSG(session, EINVAL, "unknown configuration type: '%s'", @@ -171,18 +171,18 @@ config_check(WT_SESSION_IMPL *session, */ WT_RET(__wt_config_subinit(session, &sparser, &v)); - found = 1; + found = true; while (found && (ret = __wt_config_next(&sparser, &v, &dummy)) == 0) { ret = __wt_config_subgetraw( session, &cv, &v, &dummy); - found = (ret == 0); + found = ret == 0; } } else { ret = __wt_config_subgetraw(session, &cv, &v, &dummy); - found = (ret == 0); + found = ret == 0; } if (ret != 0 && ret != WT_NOTFOUND) diff --git a/src/third_party/wiredtiger/src/config/config_collapse.c b/src/third_party/wiredtiger/src/config/config_collapse.c index 564798ecc42..c997ac3a324 100644 --- a/src/third_party/wiredtiger/src/config/config_collapse.c +++ b/src/third_party/wiredtiger/src/config/config_collapse.c @@ -90,9 +90,9 @@ err: __wt_scr_free(session, &tmp); * the qsort stable. */ typedef struct { - char *k, *v; /* key, value */ + char *k, *v; /* key, value */ size_t gen; /* generation */ - int strip; /* remove the value */ + bool strip; /* remove the value */ } WT_CONFIG_MERGE_ENTRY; /* @@ -111,7 +111,7 @@ typedef struct { */ static int __config_merge_scan(WT_SESSION_IMPL *session, - const char *key, const char *value, int strip, WT_CONFIG_MERGE *cp) + const char *key, const char *value, bool strip, WT_CONFIG_MERGE *cp) { WT_CONFIG cparser; WT_CONFIG_ITEM k, v; @@ -385,10 +385,10 @@ __wt_config_merge(WT_SESSION_IMPL *session, * so their generation numbers are the highest. */ for (; *cfg != NULL; ++cfg) - WT_ERR(__config_merge_scan(session, NULL, *cfg, 0, &merge)); + WT_ERR(__config_merge_scan(session, NULL, *cfg, false, &merge)); if (cfg_strip != NULL) - WT_ERR( - __config_merge_scan(session, NULL, cfg_strip, 1, &merge)); + WT_ERR(__config_merge_scan( + session, NULL, cfg_strip, true, &merge)); /* * Sort the array by key and, in the case of identical keys, by diff --git a/src/third_party/wiredtiger/src/conn/conn_api.c b/src/third_party/wiredtiger/src/conn/conn_api.c index b1155d06826..376ed0e99ee 100644 --- a/src/third_party/wiredtiger/src/conn/conn_api.c +++ b/src/third_party/wiredtiger/src/conn/conn_api.c @@ -818,12 +818,12 @@ __conn_load_extension( WT_DLH *dlh; WT_SESSION_IMPL *session; int (*load)(WT_CONNECTION *, WT_CONFIG_ARG *); - int is_local; + bool is_local; const char *init_name, *terminate_name; dlh = NULL; init_name = terminate_name = NULL; - is_local = (strcmp(path, "local") == 0); + is_local = strcmp(path, "local") == 0; conn = (WT_CONNECTION_IMPL *)wt_conn; CONNECTION_API_CALL(conn, session, load_extension, config, cfg); @@ -843,11 +843,12 @@ __conn_load_extension( */ WT_ERR(__wt_config_gets(session, cfg, "entry", &cval)); WT_ERR(__wt_strndup(session, cval.str, cval.len, &init_name)); - WT_ERR(__wt_dlsym(session, dlh, init_name, 1, &load)); + WT_ERR(__wt_dlsym(session, dlh, init_name, true, &load)); WT_ERR(__wt_config_gets(session, cfg, "terminate", &cval)); WT_ERR(__wt_strndup(session, cval.str, cval.len, &terminate_name)); - WT_ERR(__wt_dlsym(session, dlh, terminate_name, 0, &dlh->terminate)); + WT_ERR( + __wt_dlsym(session, dlh, terminate_name, false, &dlh->terminate)); /* Call the load function last, it simplifies error handling. */ WT_ERR(load(wt_conn, (WT_CONFIG_ARG *)cfg)); @@ -1048,7 +1049,7 @@ __conn_reconfigure(WT_CONNECTION *wt_conn, const char *config) /* Second, reconfigure the system. */ WT_ERR(__conn_statistics_config(session, cfg)); WT_ERR(__wt_async_reconfig(session, cfg)); - WT_ERR(__wt_cache_config(session, 1, cfg)); + WT_ERR(__wt_cache_config(session, true, cfg)); WT_ERR(__wt_checkpoint_server_create(session, cfg)); WT_ERR(__wt_lsm_manager_reconfig(session, cfg)); WT_ERR(__wt_statlog_create(session, cfg)); @@ -1086,7 +1087,8 @@ __conn_open_session(WT_CONNECTION *wt_conn, CONNECTION_API_CALL(conn, session, open_session, config, cfg); WT_UNUSED(cfg); - WT_ERR(__wt_open_session(conn, event_handler, config, 1, &session_ret)); + WT_ERR(__wt_open_session( + conn, event_handler, config, true, &session_ret)); *wt_sessionp = &session_ret->iface; err: API_END_RET_NOTFOUND_MAP(session, ret); @@ -1139,13 +1141,13 @@ __conn_config_check_version(WT_SESSION_IMPL *session, const char *config) */ static int __conn_config_file(WT_SESSION_IMPL *session, - const char *filename, int is_user, const char **cfg, WT_ITEM *cbuf) + const char *filename, bool is_user, const char **cfg, WT_ITEM *cbuf) { WT_DECL_RET; WT_FH *fh; size_t len; wt_off_t size; - int exist, quoted; + bool exist, quoted; char *p, *t; fh = NULL; @@ -1156,7 +1158,7 @@ __conn_config_file(WT_SESSION_IMPL *session, return (0); /* Open the configuration file. */ - WT_RET(__wt_open(session, filename, 0, 0, 0, &fh)); + WT_RET(__wt_open(session, filename, false, false, 0, &fh)); WT_ERR(__wt_filesize(session, fh, &size)); if (size == 0) goto err; @@ -1193,7 +1195,7 @@ __conn_config_file(WT_SESSION_IMPL *session, * escaped. Comment lines (an unescaped newline where the next non- * white-space character is a hash), are discarded. */ - for (quoted = 0, p = t = cbuf->mem; len > 0;) { + for (quoted = false, p = t = cbuf->mem; len > 0;) { /* * Backslash pairs pass through untouched, unless immediately * preceding a newline, in which case both the backslash and @@ -1372,14 +1374,14 @@ __conn_single(WT_SESSION_IMPL *session, const char *cfg[]) WT_FH *fh; size_t len; wt_off_t size; - int exist, is_create; + bool exist, is_create; char buf[256]; conn = S2C(session); fh = NULL; WT_RET(__wt_config_gets(session, cfg, "create", &cval)); - is_create = cval.val == 0 ? 0 : 1; + is_create = cval.val != 0; __wt_spin_lock(session, &__wt_process.spinlock); @@ -1435,18 +1437,18 @@ __conn_single(WT_SESSION_IMPL *session, const char *cfg[]) * file exists in the directory, create the lock file, covering the case * of a hot backup. */ - exist = 0; + exist = false; if (!is_create) WT_ERR(__wt_exist(session, WT_WIREDTIGER, &exist)); WT_ERR(__wt_open(session, - WT_SINGLETHREAD, is_create || exist, 0, 0, &conn->lock_fh)); + WT_SINGLETHREAD, is_create || exist, false, 0, &conn->lock_fh)); /* * Lock a byte of the file: if we don't get the lock, some other process * is holding it, we're done. The file may be zero-length, and that's * OK, the underlying call supports locking past the end-of-file. */ - if (__wt_bytelock(conn->lock_fh, (wt_off_t)0, 1) != 0) + if (__wt_bytelock(conn->lock_fh, (wt_off_t)0, true) != 0) WT_ERR_MSG(session, EBUSY, "WiredTiger database is already being managed by another " "process"); @@ -1467,18 +1469,18 @@ __conn_single(WT_SESSION_IMPL *session, const char *cfg[]) strlen(WT_SINGLETHREAD_STRING), WT_SINGLETHREAD_STRING)); /* We own the lock file, optionally create the WiredTiger file. */ - WT_ERR(__wt_open(session, WT_WIREDTIGER, is_create, 0, 0, &fh)); + WT_ERR(__wt_open(session, WT_WIREDTIGER, is_create, false, 0, &fh)); /* * Lock the WiredTiger file (for backward compatibility reasons as * described above). Immediately release the lock, it's just a test. */ - if (__wt_bytelock(fh, (wt_off_t)0, 1) != 0) { + if (__wt_bytelock(fh, (wt_off_t)0, true) != 0) { WT_ERR_MSG(session, EBUSY, "WiredTiger database is already being managed by another " "process"); } - WT_ERR(__wt_bytelock(fh, (wt_off_t)0, 0)); + WT_ERR(__wt_bytelock(fh, (wt_off_t)0, false)); /* * We own the database home, figure out if we're creating it. There are @@ -1650,7 +1652,7 @@ __conn_write_base_config(WT_SESSION_IMPL *session, const char *cfg[]) WT_CONFIG parser; WT_CONFIG_ITEM cval, k, v; WT_DECL_RET; - int exist; + bool exist; const char *base_config; fp = NULL; @@ -1881,9 +1883,10 @@ wiredtiger_open(const char *home, WT_EVENT_HANDLER *event_handler, /* Ignore the base_config file if we config_base set to false. */ if (config_base_set != 0) - WT_ERR(__conn_config_file(session, WT_BASECONFIG, 0, cfg, i1)); + WT_ERR( + __conn_config_file(session, WT_BASECONFIG, false, cfg, i1)); __conn_config_append(cfg, config); - WT_ERR(__conn_config_file(session, WT_USERCONFIG, 1, cfg, i2)); + WT_ERR(__conn_config_file(session, WT_USERCONFIG, true, cfg, i2)); WT_ERR(__conn_config_env(session, cfg, i3)); /* diff --git a/src/third_party/wiredtiger/src/conn/conn_cache.c b/src/third_party/wiredtiger/src/conn/conn_cache.c index 8f62c7140c7..a1d509e75bd 100644 --- a/src/third_party/wiredtiger/src/conn/conn_cache.c +++ b/src/third_party/wiredtiger/src/conn/conn_cache.c @@ -13,7 +13,7 @@ * Configure the underlying cache. */ static int -__cache_config_local(WT_SESSION_IMPL *session, int shared, const char *cfg[]) +__cache_config_local(WT_SESSION_IMPL *session, bool shared, const char *cfg[]) { WT_CACHE *cache; WT_CONFIG_ITEM cval; @@ -76,11 +76,11 @@ __cache_config_local(WT_SESSION_IMPL *session, int shared, const char *cfg[]) * Configure or reconfigure the current cache and shared cache. */ int -__wt_cache_config(WT_SESSION_IMPL *session, int reconfigure, const char *cfg[]) +__wt_cache_config(WT_SESSION_IMPL *session, bool reconfigure, const char *cfg[]) { WT_CONFIG_ITEM cval; WT_CONNECTION_IMPL *conn; - int now_shared, was_shared; + bool now_shared, was_shared; conn = S2C(session); @@ -137,7 +137,7 @@ __wt_cache_create(WT_SESSION_IMPL *session, const char *cfg[]) cache = conn->cache; /* Use a common routine for run-time configuration options. */ - WT_RET(__wt_cache_config(session, 0, cfg)); + WT_RET(__wt_cache_config(session, false, cfg)); /* * The target size must be lower than the trigger size or we will never @@ -148,9 +148,9 @@ __wt_cache_create(WT_SESSION_IMPL *session, const char *cfg[]) "eviction target must be lower than the eviction trigger"); WT_ERR(__wt_cond_alloc(session, - "cache eviction server", 0, &cache->evict_cond)); + "cache eviction server", false, &cache->evict_cond)); WT_ERR(__wt_cond_alloc(session, - "eviction waiters", 0, &cache->evict_waiter_cond)); + "eviction waiters", false, &cache->evict_waiter_cond)); WT_ERR(__wt_spin_init(session, &cache->evict_lock, "cache eviction")); WT_ERR(__wt_spin_init(session, &cache->evict_walk_lock, "cache walk")); diff --git a/src/third_party/wiredtiger/src/conn/conn_cache_pool.c b/src/third_party/wiredtiger/src/conn/conn_cache_pool.c index aaae58ef168..6294e3b01a7 100644 --- a/src/third_party/wiredtiger/src/conn/conn_cache_pool.c +++ b/src/third_party/wiredtiger/src/conn/conn_cache_pool.c @@ -35,9 +35,9 @@ #define WT_CACHE_POOL_READ_MULTIPLIER 1 static int __cache_pool_adjust( - WT_SESSION_IMPL *, uint64_t, uint64_t, int, int *); + WT_SESSION_IMPL *, uint64_t, uint64_t, bool, bool *); static int __cache_pool_assess(WT_SESSION_IMPL *, uint64_t *); -static int __cache_pool_balance(WT_SESSION_IMPL *, int); +static int __cache_pool_balance(WT_SESSION_IMPL *, bool); /* * __wt_cache_pool_config -- @@ -51,17 +51,17 @@ __wt_cache_pool_config(WT_SESSION_IMPL *session, const char **cfg) WT_CONNECTION_IMPL *conn, *entry; WT_DECL_RET; char *pool_name; - int created, updating; + bool created, updating; uint64_t chunk, quota, reserve, size, used_cache; conn = S2C(session); - created = updating = 0; + created = updating = false; pool_name = NULL; cp = NULL; size = 0; if (F_ISSET(conn, WT_CONN_CACHE_POOL)) - updating = 1; + updating = true; else { WT_RET(__wt_config_gets_none( session, cfg, "shared_cache.name", &cval)); @@ -99,14 +99,14 @@ __wt_cache_pool_config(WT_SESSION_IMPL *session, const char **cfg) WT_ASSERT(session, !updating); /* Create a cache pool. */ WT_ERR(__wt_calloc_one(session, &cp)); - created = 1; + created = true; cp->name = pool_name; pool_name = NULL; /* Belongs to the cache pool now. */ TAILQ_INIT(&cp->cache_pool_qh); WT_ERR(__wt_spin_init( session, &cp->cache_pool_lock, "cache shared pool")); WT_ERR(__wt_cond_alloc(session, - "cache pool server", 0, &cp->cache_pool_cond)); + "cache pool server", false, &cp->cache_pool_cond)); __wt_process.cache_pool = cp; WT_ERR(__wt_verbose(session, @@ -253,7 +253,7 @@ __wt_conn_cache_pool_open(WT_SESSION_IMPL *session) * it in the main thread to avoid shutdown races */ if ((ret = __wt_open_internal_session( - conn, "cache-pool", 0, 0, &cache->cp_session)) != 0) + conn, "cache-pool", false, false, &cache->cp_session)) != 0) WT_RET_MSG(NULL, ret, "Failed to create session for cache pool"); @@ -299,21 +299,21 @@ __wt_conn_cache_pool_destroy(WT_SESSION_IMPL *session) WT_CONNECTION_IMPL *conn, *entry; WT_DECL_RET; WT_SESSION *wt_session; - int cp_locked, found; + bool cp_locked, found; conn = S2C(session); cache = conn->cache; - cp_locked = found = 0; + cp_locked = found = false; cp = __wt_process.cache_pool; if (!F_ISSET(conn, WT_CONN_CACHE_POOL)) return (0); __wt_spin_lock(session, &cp->cache_pool_lock); - cp_locked = 1; + cp_locked = true; TAILQ_FOREACH(entry, &cp->cache_pool_qh, cpq) if (entry == conn) { - found = 1; + found = true; break; } @@ -336,7 +336,7 @@ __wt_conn_cache_pool_destroy(WT_SESSION_IMPL *session) * operation. */ __wt_spin_unlock(session, &cp->cache_pool_lock); - cp_locked = 0; + cp_locked = false; F_CLR(cache, WT_CACHE_POOL_RUN); WT_TRET(__wt_cond_signal(session, cp->cache_pool_cond)); @@ -351,7 +351,7 @@ __wt_conn_cache_pool_destroy(WT_SESSION_IMPL *session) * participant. */ __wt_spin_lock(session, &cp->cache_pool_lock); - cp_locked = 1; + cp_locked = true; } /* @@ -383,7 +383,7 @@ __wt_conn_cache_pool_destroy(WT_SESSION_IMPL *session) __wt_process.cache_pool = NULL; __wt_spin_unlock(session, &__wt_process.spinlock); __wt_spin_unlock(session, &cp->cache_pool_lock); - cp_locked = 0; + cp_locked = false; /* Now free the pool. */ __wt_free(session, cp->name); @@ -413,15 +413,15 @@ __wt_conn_cache_pool_destroy(WT_SESSION_IMPL *session) * effectively used. */ static int -__cache_pool_balance(WT_SESSION_IMPL *session, int forward) +__cache_pool_balance(WT_SESSION_IMPL *session, bool forward) { WT_CACHE_POOL *cp; WT_DECL_RET; - int adjusted; + bool adjusted; uint64_t bump_threshold, highest; cp = __wt_process.cache_pool; - adjusted = 0; + adjusted = false; highest = 0; __wt_spin_lock(NULL, &cp->cache_pool_lock); @@ -557,19 +557,19 @@ __cache_pool_assess(WT_SESSION_IMPL *session, uint64_t *phighest) */ static int __cache_pool_adjust(WT_SESSION_IMPL *session, - uint64_t highest, uint64_t bump_threshold, int forward, int *adjustedp) + uint64_t highest, uint64_t bump_threshold, bool forward, bool *adjustedp) { WT_CACHE_POOL *cp; WT_CACHE *cache; WT_CONNECTION_IMPL *entry; uint64_t adjustment, highest_percentile, pressure, reserved, smallest; - int busy, pool_full, grow; u_int pct_full; + bool busy, pool_full, grow; - *adjustedp = 0; + *adjustedp = false; cp = __wt_process.cache_pool; - grow = 0; - pool_full = (cp->currently_used >= cp->size); + grow = false; + pool_full = cp->currently_used >= cp->size; /* Highest as a percentage, avoid 0 */ highest_percentile = (highest / 100) + 1; @@ -615,7 +615,7 @@ __cache_pool_adjust(WT_SESSION_IMPL *session, * - the reserved size has been adjusted */ if (entry->cache_size < reserved) { - grow = 1; + grow = true; adjustment = reserved - entry->cache_size; /* * Conditions for reducing the amount of resources for an @@ -632,7 +632,7 @@ __cache_pool_adjust(WT_SESSION_IMPL *session, } else if (pool_full && !busy && entry->cache_size > reserved && pressure < WT_CACHE_POOL_REDUCE_THRESHOLD && highest > 1) { - grow = 0; + grow = false; /* * Don't drop the size down too much - or it can * trigger aggressive eviction in the connection, @@ -665,7 +665,7 @@ __cache_pool_adjust(WT_SESSION_IMPL *session, (entry->cache_size * cache->eviction_target) / 100 && (pressure > bump_threshold || cp->currently_used < cp->size * 0.5)) { - grow = 1; + grow = true; adjustment = WT_MIN(WT_MIN(cp->chunk, cp->size - cp->currently_used), cache->cp_quota - entry->cache_size); @@ -682,7 +682,7 @@ __cache_pool_adjust(WT_SESSION_IMPL *session, * gradually without stalling application threads. */ if (adjustment > 0) { - *adjustedp = 1; + *adjustedp = true; if (grow) { cache->cp_skip_count = WT_CACHE_POOL_BUMP_SKIPS; entry->cache_size += adjustment; @@ -720,13 +720,13 @@ __wt_cache_pool_server(void *arg) WT_CACHE_POOL *cp; WT_DECL_RET; WT_SESSION_IMPL *session; - int forward; + bool forward; session = (WT_SESSION_IMPL *)arg; cp = __wt_process.cache_pool; cache = S2C(session)->cache; - forward = 1; + forward = true; while (F_ISSET_ATOMIC(cp, WT_CACHE_POOL_ACTIVE) && F_ISSET(cache, WT_CACHE_POOL_RUN)) { diff --git a/src/third_party/wiredtiger/src/conn/conn_ckpt.c b/src/third_party/wiredtiger/src/conn/conn_ckpt.c index 74f27d8bd18..6598c567de9 100644 --- a/src/third_party/wiredtiger/src/conn/conn_ckpt.c +++ b/src/third_party/wiredtiger/src/conn/conn_ckpt.c @@ -15,7 +15,7 @@ static int __ckpt_server_start(WT_CONNECTION_IMPL *); * Parse and setup the checkpoint server options. */ static int -__ckpt_server_config(WT_SESSION_IMPL *session, const char **cfg, int *startp) +__ckpt_server_config(WT_SESSION_IMPL *session, const char **cfg, bool *startp) { WT_CONFIG_ITEM cval; WT_CONNECTION_IMPL *conn; @@ -38,10 +38,10 @@ __ckpt_server_config(WT_SESSION_IMPL *session, const char **cfg, int *startp) if ((conn->ckpt_usecs == 0 && conn->ckpt_logsize == 0) || (conn->ckpt_logsize && conn->ckpt_usecs == 0 && !FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED))) { - *startp = 0; + *startp = false; return (0); } - *startp = 1; + *startp = true; /* * The application can specify a checkpoint name, which we ignore if @@ -131,7 +131,7 @@ __ckpt_server_start(WT_CONNECTION_IMPL *conn) F_SET(conn, WT_CONN_SERVER_CHECKPOINT); /* The checkpoint server gets its own session. */ WT_RET(__wt_open_internal_session( - conn, "checkpoint-server", 1, 1, &conn->ckpt_session)); + conn, "checkpoint-server", true, true, &conn->ckpt_session)); session = conn->ckpt_session; /* @@ -140,8 +140,8 @@ __ckpt_server_start(WT_CONNECTION_IMPL *conn) */ F_SET(session, WT_SESSION_CAN_WAIT); - WT_RET( - __wt_cond_alloc(session, "checkpoint server", 0, &conn->ckpt_cond)); + WT_RET(__wt_cond_alloc( + session, "checkpoint server", false, &conn->ckpt_cond)); /* * Start the thread. @@ -161,10 +161,10 @@ int __wt_checkpoint_server_create(WT_SESSION_IMPL *session, const char *cfg[]) { WT_CONNECTION_IMPL *conn; - int start; + bool start; conn = S2C(session); - start = 0; + start = false; /* If there is already a server running, shut it down. */ if (conn->ckpt_session != NULL) diff --git a/src/third_party/wiredtiger/src/conn/conn_dhandle.c b/src/third_party/wiredtiger/src/conn/conn_dhandle.c index bb3ffbf2b68..77e7693042b 100644 --- a/src/third_party/wiredtiger/src/conn/conn_dhandle.c +++ b/src/third_party/wiredtiger/src/conn/conn_dhandle.c @@ -125,7 +125,7 @@ __wt_conn_dhandle_find( static int __conn_dhandle_mark_dead(WT_SESSION_IMPL *session) { - int evict_reset; + bool evict_reset; /* * Handle forced discard (e.g., when dropping a file). @@ -145,16 +145,16 @@ __conn_dhandle_mark_dead(WT_SESSION_IMPL *session) * Sync and close the underlying btree handle. */ int -__wt_conn_btree_sync_and_close(WT_SESSION_IMPL *session, int final, int force) +__wt_conn_btree_sync_and_close(WT_SESSION_IMPL *session, bool final, bool force) { WT_BTREE *btree; WT_DATA_HANDLE *dhandle; WT_DECL_RET; - int marked_dead, no_schema_lock; + bool marked_dead, no_schema_lock; btree = S2BT(session); dhandle = session->dhandle; - marked_dead = 0; + marked_dead = false; if (!F_ISSET(dhandle, WT_DHANDLE_OPEN)) return (0); @@ -166,9 +166,9 @@ __wt_conn_btree_sync_and_close(WT_SESSION_IMPL *session, int final, int force) * we might deadlock with a thread that has the schema lock and wants * a handle lock (specifically, checkpoint). */ - no_schema_lock = 0; + no_schema_lock = false; if (!F_ISSET(session, WT_SESSION_LOCKED_SCHEMA)) { - no_schema_lock = 1; + no_schema_lock = true; F_SET(session, WT_SESSION_NO_SCHEMA_LOCK); } @@ -193,7 +193,7 @@ __wt_conn_btree_sync_and_close(WT_SESSION_IMPL *session, int final, int force) WT_BTREE_SALVAGE | WT_BTREE_UPGRADE | WT_BTREE_VERIFY)) { if (force && (btree->bm == NULL || btree->bm->map == NULL)) { WT_ERR(__conn_dhandle_mark_dead(session)); - marked_dead = 1; + marked_dead = true; } else WT_ERR(__wt_checkpoint_close(session, final)); } @@ -321,16 +321,27 @@ __wt_conn_btree_open( * in the tree that can block the close. */ if (F_ISSET(dhandle, WT_DHANDLE_OPEN)) - WT_RET(__wt_conn_btree_sync_and_close(session, 0, 0)); + WT_RET(__wt_conn_btree_sync_and_close(session, false, false)); /* Discard any previous configuration, set up the new configuration. */ __conn_btree_config_clear(session); WT_RET(__conn_btree_config_set(session)); /* Set any special flags on the handle. */ - F_SET(btree, LF_ISSET(WT_BTREE_SPECIAL_FLAGS)); + F_SET(btree, LF_MASK(WT_BTREE_SPECIAL_FLAGS)); WT_ERR(__wt_btree_open(session, cfg)); + + /* + * Bulk handles require true exclusive access, otherwise, handles + * marked as exclusive are allowed to be relocked by the same + * session. + */ + if (F_ISSET(dhandle, WT_DHANDLE_EXCLUSIVE) && + !LF_ISSET(WT_BTREE_BULK)) { + dhandle->excl_session = session; + dhandle->excl_ref = 1; + } F_SET(dhandle, WT_DHANDLE_OPEN); /* @@ -368,7 +379,7 @@ __conn_btree_apply_internal(WT_SESSION_IMPL *session, WT_DATA_HANDLE *dhandle, WT_SAVE_DHANDLE(session, ret = func(session, cfg)); if (WT_META_TRACKING(session)) - WT_TRET(__wt_meta_track_handle_lock(session, 0)); + WT_TRET(__wt_meta_track_handle_lock(session, false)); else WT_TRET(__wt_session_release_btree(session)); } else if (ret == EBUSY) @@ -383,7 +394,7 @@ __conn_btree_apply_internal(WT_SESSION_IMPL *session, WT_DATA_HANDLE *dhandle, */ int __wt_conn_btree_apply(WT_SESSION_IMPL *session, - int apply_checkpoints, const char *uri, + bool apply_checkpoints, const char *uri, int (*func)(WT_SESSION_IMPL *, const char *[]), const char *cfg[]) { WT_CONNECTION_IMPL *conn; @@ -522,7 +533,7 @@ __wt_conn_btree_apply_single(WT_SESSION_IMPL *session, */ int __wt_conn_dhandle_close_all( - WT_SESSION_IMPL *session, const char *uri, int force) + WT_SESSION_IMPL *session, const char *uri, bool force) { WT_CONNECTION_IMPL *conn; WT_DATA_HANDLE *dhandle; @@ -547,7 +558,7 @@ __wt_conn_dhandle_close_all( dhandle->name, dhandle->checkpoint, NULL, WT_DHANDLE_EXCLUSIVE | WT_DHANDLE_LOCK_ONLY)); if (WT_META_TRACKING(session)) - WT_ERR(__wt_meta_track_handle_lock(session, 0)); + WT_ERR(__wt_meta_track_handle_lock(session, false)); /* * We have an exclusive lock, which means there are no cursors @@ -556,7 +567,7 @@ __wt_conn_dhandle_close_all( if (F_ISSET(dhandle, WT_DHANDLE_OPEN)) { if ((ret = __wt_meta_track_sub_on(session)) == 0) ret = __wt_conn_btree_sync_and_close( - session, 0, force); + session, false, force); /* * If the close succeeded, drop any locks it acquired. @@ -582,7 +593,7 @@ err: session->dhandle = NULL; * Remove a handle from the shared list. */ static int -__conn_dhandle_remove(WT_SESSION_IMPL *session, int final) +__conn_dhandle_remove(WT_SESSION_IMPL *session, bool final) { WT_CONNECTION_IMPL *conn; WT_DATA_HANDLE *dhandle; @@ -610,7 +621,8 @@ __conn_dhandle_remove(WT_SESSION_IMPL *session, int final) * Close/discard a single data handle. */ int -__wt_conn_dhandle_discard_single(WT_SESSION_IMPL *session, int final, int force) +__wt_conn_dhandle_discard_single( + WT_SESSION_IMPL *session, bool final, bool force) { WT_DATA_HANDLE *dhandle; WT_DECL_RET; @@ -678,7 +690,8 @@ restart: continue; WT_WITH_DHANDLE(session, dhandle, - WT_TRET(__wt_conn_dhandle_discard_single(session, 1, 0))); + WT_TRET(__wt_conn_dhandle_discard_single( + session, true, false))); goto restart; } @@ -694,7 +707,8 @@ restart: /* Close the metadata file handle. */ while ((dhandle = TAILQ_FIRST(&conn->dhqh)) != NULL) WT_WITH_DHANDLE(session, dhandle, - WT_TRET(__wt_conn_dhandle_discard_single(session, 1, 0))); + WT_TRET(__wt_conn_dhandle_discard_single( + session, true, false))); return (ret); } diff --git a/src/third_party/wiredtiger/src/conn/conn_handle.c b/src/third_party/wiredtiger/src/conn/conn_handle.c index 7a8a6cba838..e10f2a8c968 100644 --- a/src/third_party/wiredtiger/src/conn/conn_handle.c +++ b/src/third_party/wiredtiger/src/conn/conn_handle.c @@ -74,7 +74,7 @@ __wt_connection_init(WT_CONNECTION_IMPL *conn) WT_RET(__wt_spin_init( session, &conn->lsm_manager.switch_lock, "LSM switch queue lock")); WT_RET(__wt_cond_alloc( - session, "LSM worker cond", 0, &conn->lsm_manager.work_cond)); + session, "LSM worker cond", false, &conn->lsm_manager.work_cond)); /* * Generation numbers. diff --git a/src/third_party/wiredtiger/src/conn/conn_log.c b/src/third_party/wiredtiger/src/conn/conn_log.c index f4baf6962ef..fee914d8986 100644 --- a/src/third_party/wiredtiger/src/conn/conn_log.c +++ b/src/third_party/wiredtiger/src/conn/conn_log.c @@ -42,7 +42,7 @@ __logmgr_sync_cfg(WT_SESSION_IMPL *session, const char **cfg) * Parse and setup the logging server options. */ static int -__logmgr_config(WT_SESSION_IMPL *session, const char **cfg, int *runp) +__logmgr_config(WT_SESSION_IMPL *session, const char **cfg, bool *runp) { WT_CONFIG_ITEM cval; WT_CONNECTION_IMPL *conn; @@ -67,7 +67,7 @@ __logmgr_config(WT_SESSION_IMPL *session, const char **cfg, int *runp) WT_RET(__wt_strndup(session, cval.str, cval.len, &conn->log_path)); /* We are done if logging isn't enabled. */ - if (*runp == 0) + if (!*runp) return (0); WT_RET(__wt_config_gets(session, cfg, "log.archive", &cval)); @@ -107,7 +107,8 @@ __log_archive_once(WT_SESSION_IMPL *session, uint32_t backup_file) WT_DECL_RET; WT_LOG *log; uint32_t lognum, min_lognum; - u_int i, locked, logcount; + u_int i, logcount; + bool locked; char **logfiles; conn = S2C(session); @@ -140,7 +141,7 @@ __log_archive_once(WT_SESSION_IMPL *session, uint32_t backup_file) * if we are the backup. */ WT_RET(__wt_readlock(session, conn->hot_backup_lock)); - locked = 1; + locked = true; if (conn->hot_backup == 0 || backup_file != 0) { for (i = 0; i < logcount; i++) { WT_ERR(__wt_log_extract_lognum( @@ -151,7 +152,7 @@ __log_archive_once(WT_SESSION_IMPL *session, uint32_t backup_file) } } WT_ERR(__wt_readunlock(session, conn->hot_backup_lock)); - locked = 0; + locked = false; __wt_log_files_free(session, logfiles, logcount); logfiles = NULL; logcount = 0; @@ -209,14 +210,13 @@ __log_prealloc_once(WT_SESSION_IMPL *session) "Missed %" PRIu32 ". Now pre-allocating up to %" PRIu32, log->prep_missed, conn->log_prealloc)); } - WT_STAT_FAST_CONN_SET(session, - log_prealloc_max, conn->log_prealloc); + WT_STAT_FAST_CONN_SET(session, log_prealloc_max, conn->log_prealloc); /* * Allocate up to the maximum number that we just computed and detected. */ for (i = reccount; i < (u_int)conn->log_prealloc; i++) { WT_ERR(__wt_log_allocfile( - session, ++log->prep_fileid, WT_LOG_PREPNAME, 1)); + session, ++log->prep_fileid, WT_LOG_PREPNAME, true)); WT_STAT_FAST_CONN_INCR(session, log_prealloc_files); } /* @@ -246,7 +246,8 @@ __wt_log_truncate_files( WT_CONNECTION_IMPL *conn; WT_DECL_RET; WT_LOG *log; - uint32_t backup_file, locked; + uint32_t backup_file; + bool locked; WT_UNUSED(cfg); conn = S2C(session); @@ -264,10 +265,10 @@ __wt_log_truncate_files( "log_truncate_files: Archive once up to %" PRIu32, backup_file)); WT_RET(__wt_writelock(session, log->log_archive_lock)); - locked = 1; + locked = true; WT_ERR(__log_archive_once(session, backup_file)); WT_ERR(__wt_writeunlock(session, log->log_archive_lock)); - locked = 0; + locked = false; err: if (locked) WT_RET(__wt_writeunlock(session, log->log_archive_lock)); @@ -289,12 +290,12 @@ __log_file_server(void *arg) WT_LSN close_end_lsn, min_lsn; WT_SESSION_IMPL *session; uint32_t filenum; - int locked; + bool locked; session = arg; conn = S2C(session); log = conn->log; - locked = 0; + locked = false; while (F_ISSET(conn, WT_CONN_LOG_SERVER_RUN)) { /* * If there is a log file to close, make sure any outstanding @@ -338,14 +339,14 @@ __log_file_server(void *arg) close_end_lsn.offset = 0; WT_ERR(__wt_fsync(session, close_fh)); __wt_spin_lock(session, &log->log_sync_lock); - locked = 1; + locked = true; WT_ERR(__wt_close(session, &close_fh)); WT_ASSERT(session, __wt_log_cmp( &close_end_lsn, &log->sync_lsn) >= 0); log->sync_lsn = close_end_lsn; WT_ERR(__wt_cond_signal( session, log->log_sync_cond)); - locked = 0; + locked = false; __wt_spin_unlock(session, &log->log_sync_lock); } } @@ -366,7 +367,7 @@ __log_file_server(void *arg) if (__wt_log_cmp(&log->bg_sync_lsn, &min_lsn) <= 0) { WT_ERR(__wt_fsync(session, log->log_fh)); __wt_spin_lock(session, &log->log_sync_lock); - locked = 1; + locked = true; /* * The sync LSN could have advanced while we * were writing to disk. @@ -377,7 +378,7 @@ __log_file_server(void *arg) WT_ERR(__wt_cond_signal( session, log->log_sync_cond)); } - locked = 0; + locked = false; __wt_spin_unlock(session, &log->log_sync_lock); } else { WT_ERR(__wt_cond_signal( @@ -456,13 +457,7 @@ restart: while (i < WT_SLOT_POOL) { save_i = i; slot = &log->slot_pool[i++]; - /* - * XXX - During debugging I saw slot 0 become orphaned. - * I believe it is fixed, but check for now. - * This assertion should catch that. - */ - if (slot->slot_state == 0) - WT_ASSERT(session, + WT_ASSERT(session, slot->slot_state != 0 || slot->slot_release_lsn.file >= log->write_lsn.file); if (slot->slot_state != WT_LOG_SLOT_WRITTEN) continue; @@ -543,6 +538,14 @@ restart: */ WT_ASSERT(session, __wt_log_cmp(&written[i].lsn, &slot->slot_release_lsn) == 0); + /* + * We need to maintain the starting offset of + * a log record so that the checkpoint LSN + * refers to the beginning of a real record. + * The last offset in a slot is kept so that + * the checkpoint LSN is close to the end of + * the record. + */ if (slot->slot_start_lsn.offset != slot->slot_last_offset) slot->slot_start_lsn.offset = @@ -609,12 +612,13 @@ __log_server(void *arg) WT_DECL_RET; WT_LOG *log; WT_SESSION_IMPL *session; - int freq_per_sec, signalled; + int freq_per_sec; + bool signalled; session = arg; conn = S2C(session); log = conn->log; - signalled = 0; + signalled = false; /* * Set this to the number of times per second we want to force out the @@ -649,7 +653,7 @@ __log_server(void *arg) * we want to force out log buffers. Only do it once per second * or if the condition was signalled. */ - if (--freq_per_sec <= 0 || signalled != 0) { + if (--freq_per_sec <= 0 || signalled) { freq_per_sec = WT_FORCE_PER_SECOND; /* @@ -696,7 +700,7 @@ __wt_logmgr_create(WT_SESSION_IMPL *session, const char *cfg[]) { WT_CONNECTION_IMPL *conn; WT_LOG *log; - int run; + bool run; conn = S2C(session); @@ -738,8 +742,10 @@ __wt_logmgr_create(WT_SESSION_IMPL *session, const char *cfg[]) WT_INIT_LSN(&log->write_lsn); WT_INIT_LSN(&log->write_start_lsn); log->fileid = 0; - WT_RET(__wt_cond_alloc(session, "log sync", 0, &log->log_sync_cond)); - WT_RET(__wt_cond_alloc(session, "log write", 0, &log->log_write_cond)); + WT_RET(__wt_cond_alloc( + session, "log sync", false, &log->log_sync_cond)); + WT_RET(__wt_cond_alloc( + session, "log write", false, &log->log_write_cond)); WT_RET(__wt_log_open(session)); WT_RET(__wt_log_slot_init(session)); @@ -766,9 +772,9 @@ __wt_logmgr_open(WT_SESSION_IMPL *session) * If logging is enabled, this thread runs. */ WT_RET(__wt_open_internal_session( - conn, "log-close-server", 0, 0, &conn->log_file_session)); + conn, "log-close-server", false, false, &conn->log_file_session)); WT_RET(__wt_cond_alloc(conn->log_file_session, - "log close server", 0, &conn->log_file_cond)); + "log close server", false, &conn->log_file_cond)); /* * Start the log file close thread. @@ -782,9 +788,9 @@ __wt_logmgr_open(WT_SESSION_IMPL *session) * If logging is enabled, this thread runs. */ WT_RET(__wt_open_internal_session( - conn, "log-wrlsn-server", 0, 0, &conn->log_wrlsn_session)); + conn, "log-wrlsn-server", false, false, &conn->log_wrlsn_session)); WT_RET(__wt_cond_alloc(conn->log_wrlsn_session, - "log write lsn server", 0, &conn->log_wrlsn_cond)); + "log write lsn server", false, &conn->log_wrlsn_cond)); WT_RET(__wt_thread_create(conn->log_wrlsn_session, &conn->log_wrlsn_tid, __log_wrlsn_server, conn->log_wrlsn_session)); conn->log_wrlsn_tid_set = 1; @@ -807,9 +813,9 @@ __wt_logmgr_open(WT_SESSION_IMPL *session) } else { /* The log server gets its own session. */ WT_RET(__wt_open_internal_session( - conn, "log-server", 0, 0, &conn->log_session)); + conn, "log-server", false, false, &conn->log_session)); WT_RET(__wt_cond_alloc(conn->log_session, - "log server", 0, &conn->log_cond)); + "log server", false, &conn->log_cond)); /* * Start the thread. diff --git a/src/third_party/wiredtiger/src/conn/conn_open.c b/src/third_party/wiredtiger/src/conn/conn_open.c index 8bc69bb3e80..199cf213e0a 100644 --- a/src/third_party/wiredtiger/src/conn/conn_open.c +++ b/src/third_party/wiredtiger/src/conn/conn_open.c @@ -37,7 +37,8 @@ __wt_connection_open(WT_CONNECTION_IMPL *conn, const char *cfg[]) * threads because those may allocate and use session resources that * need to get cleaned up on close. */ - WT_RET(__wt_open_internal_session(conn, "connection", 1, 0, &session)); + WT_RET(__wt_open_internal_session( + conn, "connection", true, false, &session)); /* * The connection's default session is originally a static structure, @@ -93,7 +94,7 @@ __wt_connection_close(WT_CONNECTION_IMPL *conn) * transaction ID will catch up with the current ID. */ for (;;) { - __wt_txn_update_oldest(session, 1); + __wt_txn_update_oldest(session, true); if (txn_global->oldest_id == txn_global->current) break; __wt_yield(); @@ -116,7 +117,7 @@ __wt_connection_close(WT_CONNECTION_IMPL *conn) F_SET(conn, WT_CONN_CLOSING); WT_TRET(__wt_checkpoint_server_destroy(session)); - WT_TRET(__wt_statlog_destroy(session, 1)); + WT_TRET(__wt_statlog_destroy(session, true)); WT_TRET(__wt_evict_destroy(session)); /* Shut down the lookaside table, after all eviction is complete. */ @@ -135,7 +136,7 @@ __wt_connection_close(WT_CONNECTION_IMPL *conn) if (FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED) && FLD_ISSET(conn->log_flags, WT_CONN_LOG_RECOVER_DONE)) WT_TRET(__wt_txn_checkpoint_log( - session, 1, WT_TXN_LOG_CKPT_STOP, NULL)); + session, true, WT_TXN_LOG_CKPT_STOP, NULL)); F_CLR(conn, WT_CONN_LOG_SERVER_RUN); WT_TRET(__wt_logmgr_destroy(session)); diff --git a/src/third_party/wiredtiger/src/conn/conn_stat.c b/src/third_party/wiredtiger/src/conn/conn_stat.c index 3b188bfd22a..44366e866f4 100644 --- a/src/third_party/wiredtiger/src/conn/conn_stat.c +++ b/src/third_party/wiredtiger/src/conn/conn_stat.c @@ -68,7 +68,7 @@ __wt_conn_stat_init(WT_SESSION_IMPL *session) * Parse and setup the statistics server options. */ static int -__statlog_config(WT_SESSION_IMPL *session, const char **cfg, int *runp) +__statlog_config(WT_SESSION_IMPL *session, const char **cfg, bool *runp) { WT_CONFIG objectconf; WT_CONFIG_ITEM cval, k, v; @@ -82,7 +82,7 @@ __statlog_config(WT_SESSION_IMPL *session, const char **cfg, int *runp) WT_RET(__wt_config_gets(session, cfg, "statistics_log.wait", &cval)); /* Only start the server if wait time is non-zero */ - *runp = (cval.val == 0) ? 0 : 1; + *runp = cval.val != 0; conn->stat_usecs = (uint64_t)cval.val * 1000000; WT_RET(__wt_config_gets( @@ -94,7 +94,7 @@ __statlog_config(WT_SESSION_IMPL *session, const char **cfg, int *runp) * Statistics logging configuration requires either a wait time or an * on-close setting. */ - if (*runp == 0 && !FLD_ISSET(conn->stat_flags, WT_CONN_STAT_ON_CLOSE)) + if (!*runp && !FLD_ISSET(conn->stat_flags, WT_CONN_STAT_ON_CLOSE)) return (0); WT_RET(__wt_config_gets(session, cfg, "statistics_log.sources", &cval)); @@ -145,7 +145,7 @@ err: __stat_sources_free(session, &sources); * Dump out handle/connection statistics. */ static int -__statlog_dump(WT_SESSION_IMPL *session, const char *name, int conn_stats) +__statlog_dump(WT_SESSION_IMPL *session, const char *name, bool conn_stats) { WT_CONNECTION_IMPL *conn; WT_CURSOR *cursor; @@ -218,8 +218,8 @@ __statlog_apply(WT_SESSION_IMPL *session, const char *cfg[]) /* Check for a match on the set of sources. */ for (p = S2C(session)->stat_sources; *p != NULL; ++p) if (WT_PREFIX_MATCH(dhandle->name, *p)) { - WT_WITHOUT_DHANDLE(session, - ret = __statlog_dump(session, dhandle->name, 0)); + WT_WITHOUT_DHANDLE(session, ret = + __statlog_dump(session, dhandle->name, false)); return (ret); } return (0); @@ -238,7 +238,8 @@ __statlog_lsm_apply(WT_SESSION_IMPL *session) #define WT_LSM_TREE_LIST_SLOTS 100 WT_LSM_TREE *lsm_tree, *list[WT_LSM_TREE_LIST_SLOTS]; WT_DECL_RET; - int cnt, locked; + int cnt; + bool locked; char **p; cnt = locked = 0; @@ -258,23 +259,23 @@ __statlog_lsm_apply(WT_SESSION_IMPL *session) * will bump a reference count, so the tree won't go away. */ __wt_spin_lock(session, &S2C(session)->schema_lock); - locked = 1; + locked = true; TAILQ_FOREACH(lsm_tree, &S2C(session)->lsmqh, q) { if (cnt == WT_LSM_TREE_LIST_SLOTS) break; for (p = S2C(session)->stat_sources; *p != NULL; ++p) if (WT_PREFIX_MATCH(lsm_tree->name, *p)) { - WT_ERR(__wt_lsm_tree_get( - session, lsm_tree->name, 0, &list[cnt++])); + WT_ERR(__wt_lsm_tree_get(session, + lsm_tree->name, false, &list[cnt++])); break; } } __wt_spin_unlock(session, &S2C(session)->schema_lock); - locked = 0; + locked = false; while (cnt > 0) { --cnt; - WT_TRET(__statlog_dump(session, list[cnt]->name, 0)); + WT_TRET(__statlog_dump(session, list[cnt]->name, false)); __wt_lsm_tree_release(session, list[cnt]); } @@ -329,7 +330,7 @@ __statlog_log_one(WT_SESSION_IMPL *session, WT_ITEM *path, WT_ITEM *tmp) conn->stat_stamp = tmp->mem; /* Dump the connection statistics. */ - WT_RET(__statlog_dump(session, conn->home, 1)); + WT_RET(__statlog_dump(session, conn->home, true)); /* * Lock the schema and walk the list of open handles, dumping @@ -338,7 +339,7 @@ __statlog_log_one(WT_SESSION_IMPL *session, WT_ITEM *path, WT_ITEM *tmp) if (conn->stat_sources != NULL) { WT_WITH_HANDLE_LIST_LOCK(session, ret = __wt_conn_btree_apply( - session, 0, NULL, __statlog_apply, NULL)); + session, false, NULL, __statlog_apply, NULL)); WT_RET(ret); } @@ -448,11 +449,11 @@ __statlog_start(WT_CONNECTION_IMPL *conn) F_SET(conn, WT_CONN_SERVER_STATISTICS); /* The statistics log server gets its own session. */ WT_RET(__wt_open_internal_session( - conn, "statlog-server", 1, 1, &conn->stat_session)); + conn, "statlog-server", true, true, &conn->stat_session)); session = conn->stat_session; WT_RET(__wt_cond_alloc( - session, "statistics log server", 0, &conn->stat_cond)); + session, "statistics log server", false, &conn->stat_cond)); /* * Start the thread. @@ -479,10 +480,10 @@ int __wt_statlog_create(WT_SESSION_IMPL *session, const char *cfg[]) { WT_CONNECTION_IMPL *conn; - int start; + bool start; conn = S2C(session); - start = 0; + start = false; /* * Stop any server that is already running. This means that each time @@ -490,7 +491,7 @@ __wt_statlog_create(WT_SESSION_IMPL *session, const char *cfg[]) * configuration changes - but that makes our lives easier. */ if (conn->stat_session != NULL) - WT_RET(__wt_statlog_destroy(session, 0)); + WT_RET(__wt_statlog_destroy(session, false)); WT_RET(__statlog_config(session, cfg, &start)); if (start) @@ -504,7 +505,7 @@ __wt_statlog_create(WT_SESSION_IMPL *session, const char *cfg[]) * Destroy the statistics server thread. */ int -__wt_statlog_destroy(WT_SESSION_IMPL *session, int is_close) +__wt_statlog_destroy(WT_SESSION_IMPL *session, bool is_close) { WT_CONNECTION_IMPL *conn; WT_DECL_RET; diff --git a/src/third_party/wiredtiger/src/conn/conn_sweep.c b/src/third_party/wiredtiger/src/conn/conn_sweep.c index 8da32416242..2de0cc12069 100644 --- a/src/third_party/wiredtiger/src/conn/conn_sweep.c +++ b/src/third_party/wiredtiger/src/conn/conn_sweep.c @@ -64,11 +64,11 @@ __sweep_expire_one(WT_SESSION_IMPL *session) WT_BTREE *btree; WT_DATA_HANDLE *dhandle; WT_DECL_RET; - int evict_reset; + bool evict_reset; btree = S2BT(session); dhandle = session->dhandle; - evict_reset = 0; + evict_reset = false; /* * Acquire an exclusive lock on the handle and mark it dead. @@ -100,7 +100,7 @@ __sweep_expire_one(WT_SESSION_IMPL *session) * handle. Closing the handle decrements the open file count, * meaning the close loop won't overrun the configured minimum. */ - ret = __wt_conn_btree_sync_and_close(session, 0, 1); + ret = __wt_conn_btree_sync_and_close(session, false, true); if (evict_reset) __wt_evict_file_exclusive_off(session); @@ -172,7 +172,7 @@ __sweep_discard_trees(WT_SESSION_IMPL *session, u_int *dead_handlesp) /* If the handle is marked "dead", flush it from cache. */ WT_WITH_DHANDLE(session, dhandle, ret = - __wt_conn_btree_sync_and_close(session, 0, 0)); + __wt_conn_btree_sync_and_close(session, false, false)); /* We closed the btree handle. */ if (ret == 0) { @@ -207,7 +207,7 @@ __sweep_remove_one(WT_SESSION_IMPL *session, WT_DATA_HANDLE *dhandle) WT_ERR(EBUSY); WT_WITH_DHANDLE(session, dhandle, - ret = __wt_conn_dhandle_discard_single(session, 0, 1)); + ret = __wt_conn_dhandle_discard_single(session, false, true)); /* * If the handle was not successfully discarded, unlock it and @@ -360,7 +360,7 @@ __wt_sweep_create(WT_SESSION_IMPL *session) F_SET(conn, WT_CONN_SERVER_SWEEP); WT_RET(__wt_open_internal_session( - conn, "sweep-server", 1, 1, &conn->sweep_session)); + conn, "sweep-server", true, true, &conn->sweep_session)); session = conn->sweep_session; /* @@ -376,7 +376,7 @@ __wt_sweep_create(WT_SESSION_IMPL *session) WT_SESSION_LOOKASIDE_CURSOR | WT_SESSION_NO_EVICTION); WT_RET(__wt_cond_alloc( - session, "handle sweep server", 0, &conn->sweep_cond)); + session, "handle sweep server", false, &conn->sweep_cond)); WT_RET(__wt_thread_create( session, &conn->sweep_tid, __sweep_server, session)); diff --git a/src/third_party/wiredtiger/src/cursor/cur_backup.c b/src/third_party/wiredtiger/src/cursor/cur_backup.c index 3d9e5e405e8..c971ed6fb75 100644 --- a/src/third_party/wiredtiger/src/cursor/cur_backup.c +++ b/src/third_party/wiredtiger/src/cursor/cur_backup.c @@ -10,7 +10,7 @@ static int __backup_all(WT_SESSION_IMPL *, WT_CURSOR_BACKUP *); static int __backup_cleanup_handles(WT_SESSION_IMPL *, WT_CURSOR_BACKUP *); -static int __backup_file_create(WT_SESSION_IMPL *, WT_CURSOR_BACKUP *, int); +static int __backup_file_create(WT_SESSION_IMPL *, WT_CURSOR_BACKUP *, bool); static int __backup_list_all_append(WT_SESSION_IMPL *, const char *[]); static int __backup_list_append( WT_SESSION_IMPL *, WT_CURSOR_BACKUP *, const char *); @@ -18,7 +18,7 @@ static int __backup_start( WT_SESSION_IMPL *, WT_CURSOR_BACKUP *, const char *[]); static int __backup_stop(WT_SESSION_IMPL *); static int __backup_uri( - WT_SESSION_IMPL *, WT_CURSOR_BACKUP *, const char *[], int *, int *); + WT_SESSION_IMPL *, WT_CURSOR_BACKUP *, const char *[], bool *, bool *); /* * __curbackup_next -- @@ -158,7 +158,7 @@ err: __wt_free(session, cb); * Append log files needed for backup. */ static int -__backup_log_append(WT_SESSION_IMPL *session, WT_CURSOR_BACKUP *cb, int active) +__backup_log_append(WT_SESSION_IMPL *session, WT_CURSOR_BACKUP *cb, bool active) { WT_CONNECTION_IMPL *conn; WT_DECL_RET; @@ -191,7 +191,7 @@ __backup_start( { WT_CONNECTION_IMPL *conn; WT_DECL_RET; - int exist, log_only, target_list; + bool exist, log_only, target_list; conn = S2C(session); @@ -222,7 +222,7 @@ __backup_start( WT_ERR(__wt_writeunlock(session, conn->hot_backup_lock)); /* Create the hot backup file. */ - WT_ERR(__backup_file_create(session, cb, 0)); + WT_ERR(__backup_file_create(session, cb, false)); /* Add log files if logging is enabled. */ @@ -234,11 +234,11 @@ __backup_start( * copying data files to avoid rolling the metadata forward across * a checkpoint that completes during the backup. */ - target_list = 0; + target_list = false; WT_ERR(__backup_uri(session, cb, cfg, &target_list, &log_only)); if (!target_list) { - WT_ERR(__backup_log_append(session, cb, 1)); + WT_ERR(__backup_log_append(session, cb, true)); WT_ERR(__backup_all(session, cb)); } @@ -391,17 +391,16 @@ err: if (cursor != NULL) */ static int __backup_uri(WT_SESSION_IMPL *session, - WT_CURSOR_BACKUP *cb, const char *cfg[], int *foundp, int *log_only) + WT_CURSOR_BACKUP *cb, const char *cfg[], bool *foundp, bool *log_only) { WT_CONFIG targetconf; WT_CONFIG_ITEM cval, k, v; WT_DECL_ITEM(tmp); WT_DECL_RET; - int target_list; + bool target_list; const char *uri; - *foundp = 0; - *log_only = 0; + *foundp = *log_only = false; /* * If we find a non-empty target configuration string, we have a job, @@ -409,11 +408,12 @@ __backup_uri(WT_SESSION_IMPL *session, */ WT_RET(__wt_config_gets(session, cfg, "target", &cval)); WT_RET(__wt_config_subinit(session, &targetconf, &cval)); - for (cb->list_next = 0, target_list = 0; - (ret = __wt_config_next(&targetconf, &k, &v)) == 0; ++target_list) { + for (cb->list_next = 0, target_list = false; + (ret = __wt_config_next(&targetconf, &k, &v)) == 0; + target_list = true) { /* If it is our first time through, allocate. */ - if (target_list == 0) { - *foundp = 1; + if (!target_list) { + *foundp = true; WT_ERR(__wt_scr_alloc(session, 512, &tmp)); } @@ -430,12 +430,8 @@ __backup_uri(WT_SESSION_IMPL *session, * Set log_only only if it is our only URI target. */ if (WT_PREFIX_MATCH(uri, "log:")) { - if (target_list == 0) - *log_only = 1; - else - *log_only = 0; - WT_ERR(__wt_backup_list_uri_append( - session, uri, NULL)); + *log_only = !target_list; + WT_ERR(__wt_backup_list_uri_append(session, uri, NULL)); } else WT_ERR(__wt_schema_worker(session, uri, NULL, __wt_backup_list_uri_append, cfg, 0)); @@ -452,7 +448,7 @@ err: __wt_scr_free(session, &tmp); */ static int __backup_file_create( - WT_SESSION_IMPL *session, WT_CURSOR_BACKUP *cb, int incremental) + WT_SESSION_IMPL *session, WT_CURSOR_BACKUP *cb, bool incremental) { return (__wt_fopen(session, incremental ? WT_INCREMENTAL_BACKUP : WT_METADATA_BACKUP, @@ -480,7 +476,7 @@ __wt_backup_file_remove(WT_SESSION_IMPL *session) */ int __wt_backup_list_uri_append( - WT_SESSION_IMPL *session, const char *name, int *skip) + WT_SESSION_IMPL *session, const char *name, bool *skip) { WT_CURSOR_BACKUP *cb; char *value; @@ -489,7 +485,7 @@ __wt_backup_list_uri_append( WT_UNUSED(skip); if (WT_PREFIX_MATCH(name, "log:")) { - WT_RET(__backup_log_append(session, cb, 0)); + WT_RET(__backup_log_append(session, cb, false)); return (0); } @@ -544,8 +540,8 @@ __backup_list_append( WT_CURSOR_BACKUP_ENTRY *p; WT_DATA_HANDLE *old_dhandle; WT_DECL_RET; + bool need_handle; const char *name; - int need_handle; /* Leave a NULL at the end to mark the end of the list. */ WT_RET(__wt_realloc_def(session, &cb->list_allocated, @@ -554,10 +550,10 @@ __backup_list_append( p[0].name = p[1].name = NULL; p[0].handle = p[1].handle = NULL; - need_handle = 0; + need_handle = false; name = uri; if (WT_PREFIX_MATCH(uri, "file:")) { - need_handle = 1; + need_handle = true; name += strlen("file:"); } diff --git a/src/third_party/wiredtiger/src/cursor/cur_bulk.c b/src/third_party/wiredtiger/src/cursor/cur_bulk.c index df7048d4b82..b996b934464 100644 --- a/src/third_party/wiredtiger/src/cursor/cur_bulk.c +++ b/src/third_party/wiredtiger/src/cursor/cur_bulk.c @@ -50,7 +50,7 @@ __curbulk_insert_var(WT_CURSOR *cursor) WT_CURSOR_BULK *cbulk; WT_DECL_RET; WT_SESSION_IMPL *session; - int duplicate; + bool duplicate; cbulk = (WT_CURSOR_BULK *)cursor; btree = cbulk->cbt.btree; @@ -71,13 +71,13 @@ __curbulk_insert_var(WT_CURSOR *cursor) * Instead of a "first time" variable, I'm using the RLE count, because * it is only zero before the first row is inserted. */ - duplicate = 0; + duplicate = false; if (cbulk->rle != 0) { if (cbulk->last.size == cursor->value.size && memcmp(cbulk->last.data, cursor->value.data, cursor->value.size) == 0) { ++cbulk->rle; - duplicate = 1; + duplicate = true; } else WT_ERR(__wt_bulk_insert_var(session, cbulk)); } @@ -225,7 +225,7 @@ err: API_END_RET(session, ret); */ int __wt_curbulk_init(WT_SESSION_IMPL *session, - WT_CURSOR_BULK *cbulk, int bitmap, int skip_sort_check) + WT_CURSOR_BULK *cbulk, bool bitmap, bool skip_sort_check) { WT_CURSOR *c; WT_CURSOR_BTREE *cbt; diff --git a/src/third_party/wiredtiger/src/cursor/cur_dump.c b/src/third_party/wiredtiger/src/cursor/cur_dump.c index ae608959f15..6c11c4b407e 100644 --- a/src/third_party/wiredtiger/src/cursor/cur_dump.c +++ b/src/third_party/wiredtiger/src/cursor/cur_dump.c @@ -15,7 +15,7 @@ */ static int __raw_to_dump( - WT_SESSION_IMPL *session, WT_ITEM *from, WT_ITEM *to, int hexonly) + WT_SESSION_IMPL *session, WT_ITEM *from, WT_ITEM *to, bool hexonly) { if (hexonly) WT_RET(__wt_raw_to_hex(session, from->data, from->size, to)); @@ -33,7 +33,7 @@ __raw_to_dump( */ static int __dump_to_raw( - WT_SESSION_IMPL *session, const char *src_arg, WT_ITEM *item, int hexonly) + WT_SESSION_IMPL *session, const char *src_arg, WT_ITEM *item, bool hexonly) { if (hexonly) WT_RET(__wt_hex_to_raw(session, src_arg, item)); @@ -85,8 +85,8 @@ __curdump_get_key(WT_CURSOR *cursor, ...) else fmt = cursor->key_format; } - ret = __wt_json_alloc_unpack(session, buffer, size, fmt, - json, 1, ap); + ret = __wt_json_alloc_unpack( + session, buffer, size, fmt, json, true, ap); } else { if (WT_CURSOR_RECNO(cursor) && !F_ISSET(cursor, WT_CURSTD_RAW)) { @@ -98,7 +98,7 @@ __curdump_get_key(WT_CURSOR *cursor, ...) WT_ERR(child->get_key(child, &item)); WT_ERR(__raw_to_dump(session, &item, &cursor->key, - F_ISSET(cursor, WT_CURSTD_DUMP_HEX) ? 1 : 0)); + F_ISSET(cursor, WT_CURSTD_DUMP_HEX))); } if (F_ISSET(cursor, WT_CURSTD_RAW)) { @@ -175,11 +175,11 @@ __curdump_set_key(WT_CURSOR *cursor, ...) } else { if (F_ISSET(cursor, WT_CURSTD_DUMP_JSON)) WT_ERR(__wt_json_to_item(session, p, cursor->key_format, - (WT_CURSOR_JSON *)cursor->json_private, 1, + (WT_CURSOR_JSON *)cursor->json_private, true, &cursor->key)); else WT_ERR(__dump_to_raw(session, p, &cursor->key, - F_ISSET(cursor, WT_CURSTD_DUMP_HEX) ? 1 : 0)); + F_ISSET(cursor, WT_CURSTD_DUMP_HEX))); child->set_key(child, &cursor->key); } @@ -219,13 +219,13 @@ __curdump_get_value(WT_CURSOR *cursor, ...) WT_ERR(__wt_cursor_get_raw_value(child, &item)); fmt = F_ISSET(cursor, WT_CURSTD_RAW) ? "u" : cursor->value_format; - ret = __wt_json_alloc_unpack(session, item.data, - item.size, fmt, json, 0, ap); + ret = __wt_json_alloc_unpack( + session, item.data, item.size, fmt, json, false, ap); } else { WT_ERR(child->get_value(child, &item)); WT_ERR(__raw_to_dump(session, &item, &cursor->value, - F_ISSET(cursor, WT_CURSTD_DUMP_HEX) ? 1 : 0)); + F_ISSET(cursor, WT_CURSTD_DUMP_HEX))); if (F_ISSET(cursor, WT_CURSTD_RAW)) { itemp = va_arg(ap, WT_ITEM *); @@ -266,10 +266,11 @@ __curdump_set_value(WT_CURSOR *cursor, ...) if (F_ISSET(cursor, WT_CURSTD_DUMP_JSON)) WT_ERR(__wt_json_to_item(session, p, cursor->value_format, - (WT_CURSOR_JSON *)cursor->json_private, 0, &cursor->value)); + (WT_CURSOR_JSON *)cursor->json_private, false, + &cursor->value)); else WT_ERR(__dump_to_raw(session, p, &cursor->value, - F_ISSET(cursor, WT_CURSTD_DUMP_HEX) ? 1 : 0)); + F_ISSET(cursor, WT_CURSTD_DUMP_HEX))); child->set_value(child, &cursor->value); @@ -384,7 +385,7 @@ __wt_curdump_create(WT_CURSOR *child, WT_CURSOR *owner, WT_CURSOR **cursorp) cdump->child = child; /* Copy the dump flags from the child cursor. */ - F_SET(cursor, F_ISSET(child, + F_SET(cursor, F_MASK(child, WT_CURSTD_DUMP_HEX | WT_CURSTD_DUMP_JSON | WT_CURSTD_DUMP_PRINT)); if (F_ISSET(cursor, WT_CURSTD_DUMP_JSON)) { WT_ERR(__wt_calloc_one(session, &json)); diff --git a/src/third_party/wiredtiger/src/cursor/cur_file.c b/src/third_party/wiredtiger/src/cursor/cur_file.c index c998565eb75..65f5dafc344 100644 --- a/src/third_party/wiredtiger/src/cursor/cur_file.c +++ b/src/third_party/wiredtiger/src/cursor/cur_file.c @@ -110,7 +110,7 @@ __curfile_next(WT_CURSOR *cursor) CURSOR_API_CALL(cursor, session, next, cbt->btree); F_CLR(cursor, WT_CURSTD_KEY_SET | WT_CURSTD_VALUE_SET); - if ((ret = __wt_btcur_next(cbt, 0)) == 0) + if ((ret = __wt_btcur_next(cbt, false)) == 0) F_SET(cursor, WT_CURSTD_KEY_INT | WT_CURSTD_VALUE_INT); err: API_END_RET(session, ret); @@ -153,7 +153,7 @@ __curfile_prev(WT_CURSOR *cursor) CURSOR_API_CALL(cursor, session, prev, cbt->btree); F_CLR(cursor, WT_CURSTD_KEY_SET | WT_CURSTD_VALUE_SET); - if ((ret = __wt_btcur_prev(cbt, 0)) == 0) + if ((ret = __wt_btcur_prev(cbt, false)) == 0) F_SET(cursor, WT_CURSTD_KEY_INT | WT_CURSTD_VALUE_INT); err: API_END_RET(session, ret); @@ -369,7 +369,7 @@ __curfile_close(WT_CURSOR *cursor) __wt_buf_free(session, &cbulk->last); } - WT_TRET(__wt_btcur_close(cbt, 0)); + WT_TRET(__wt_btcur_close(cbt, false)); /* The URI is owned by the btree handle. */ cursor->internal_uri = NULL; WT_TRET(__wt_cursor_close(cursor)); @@ -393,7 +393,7 @@ err: API_END_RET(session, ret); */ int __wt_curfile_create(WT_SESSION_IMPL *session, - WT_CURSOR *owner, const char *cfg[], int bulk, int bitmap, + WT_CURSOR *owner, const char *cfg[], bool bulk, bool bitmap, WT_CURSOR **cursorp) { WT_CURSOR_STATIC_INIT(iface, @@ -489,20 +489,28 @@ __wt_curfile_open(WT_SESSION_IMPL *session, const char *uri, { WT_CONFIG_ITEM cval; WT_DECL_RET; - int bitmap, bulk; uint32_t flags; + bool bitmap, bulk; + bitmap = bulk = false; flags = 0; WT_RET(__wt_config_gets_def(session, cfg, "bulk", 0, &cval)); if (cval.type == WT_CONFIG_ITEM_BOOL || (cval.type == WT_CONFIG_ITEM_NUM && (cval.val == 0 || cval.val == 1))) { - bitmap = 0; - bulk = (cval.val != 0); + bitmap = false; + bulk = cval.val != 0; } else if (WT_STRING_MATCH("bitmap", cval.str, cval.len)) - bitmap = bulk = 1; - else + bitmap = bulk = true; + /* + * Unordered bulk insert is a special case used internally by + * index creation on existing tables. It doesn't enforce + * any special semantics at the file level. It primarily + * exists to avoid some locking problems with LSM trees and + * index creation. + */ + else if (!WT_STRING_MATCH("unordered", cval.str, cval.len)) WT_RET_MSG(session, EINVAL, "Value for 'bulk' must be a boolean or 'bitmap'"); @@ -513,11 +521,11 @@ __wt_curfile_open(WT_SESSION_IMPL *session, const char *uri, /* Get the handle and lock it while the cursor is using it. */ if (WT_PREFIX_MATCH(uri, "file:")) { /* - * If we are opening a bulk cursor, get the handle while - * holding the checkpoint lock. This prevents a bulk cursor - * open failing with EBUSY due to a database-wide checkpoint. + * If we are opening exclusive, get the handle while holding + * the checkpoint lock. This prevents a bulk cursor open + * failing with EBUSY due to a database-wide checkpoint. */ - if (bulk) + if (LF_ISSET(WT_DHANDLE_EXCLUSIVE)) WT_WITH_CHECKPOINT_LOCK(session, ret = __wt_session_get_btree_ckpt( session, uri, cfg, flags)); diff --git a/src/third_party/wiredtiger/src/cursor/cur_index.c b/src/third_party/wiredtiger/src/cursor/cur_index.c index 045663b3614..fd2a6cd7480 100644 --- a/src/third_party/wiredtiger/src/cursor/cur_index.c +++ b/src/third_party/wiredtiger/src/cursor/cur_index.c @@ -421,7 +421,7 @@ __wt_curindex_open(WT_SESSION_IMPL *session, ++idxname; if ((ret = __wt_schema_get_table(session, - tablename, namesize, 0, &table)) != 0) { + tablename, namesize, false, &table)) != 0) { if (ret == WT_NOTFOUND) WT_RET_MSG(session, EINVAL, "Cannot open cursor '%s' on unknown table", uri); @@ -470,13 +470,13 @@ __wt_curindex_open(WT_SESSION_IMPL *session, if (columns != NULL) { WT_ERR(__wt_scr_alloc(session, 0, &tmp)); WT_ERR(__wt_struct_reformat(session, table, - columns, strlen(columns), NULL, 0, tmp)); + columns, strlen(columns), NULL, false, tmp)); WT_ERR(__wt_strndup( session, tmp->data, tmp->size, &cursor->value_format)); WT_ERR(__wt_buf_init(session, tmp, 0)); WT_ERR(__wt_struct_plan(session, table, - columns, strlen(columns), 0, tmp)); + columns, strlen(columns), false, tmp)); WT_ERR(__wt_strndup( session, tmp->data, tmp->size, &cindex->value_plan)); } diff --git a/src/third_party/wiredtiger/src/cursor/cur_json.c b/src/third_party/wiredtiger/src/cursor/cur_json.c index d793db778c6..8f858a5012f 100644 --- a/src/third_party/wiredtiger/src/cursor/cur_json.c +++ b/src/third_party/wiredtiger/src/cursor/cur_json.c @@ -11,16 +11,16 @@ static size_t __json_unpack_put(WT_SESSION_IMPL *, void *, u_char *, size_t, WT_CONFIG_ITEM *); static inline int __json_struct_size(WT_SESSION_IMPL *, const void *, size_t, - const char *, WT_CONFIG_ITEM *, int, size_t *); + const char *, WT_CONFIG_ITEM *, bool, size_t *); static inline int __json_struct_unpackv(WT_SESSION_IMPL *, const void *, size_t, - const char *, WT_CONFIG_ITEM *, u_char *, size_t, int, va_list); + const char *, WT_CONFIG_ITEM *, u_char *, size_t, bool, va_list); static int json_string_arg(WT_SESSION_IMPL *, const char **, WT_ITEM *); static int json_int_arg(WT_SESSION_IMPL *, const char **, int64_t *); static int json_uint_arg(WT_SESSION_IMPL *, const char **, uint64_t *); static int __json_pack_struct(WT_SESSION_IMPL *, void *, size_t, const char *, const char *); static int __json_pack_size(WT_SESSION_IMPL *, const char *, WT_CONFIG_ITEM *, - int, const char *, size_t *); + bool, const char *, size_t *); #define WT_PACK_JSON_GET(session, pv, jstr) do { \ switch (pv.type) { \ @@ -90,7 +90,8 @@ __json_unpack_put(WT_SESSION_IMPL *session, void *voidpv, if (pv->type == 's' || pv->havesize) { end = p + pv->size; for (; p < end; p++) { - n = __wt_json_unpack_char(*p, buf, bufsz, 0); + n = __wt_json_unpack_char( + *p, buf, bufsz, false); if (n > bufsz) bufsz = 0; else { @@ -101,7 +102,8 @@ __json_unpack_put(WT_SESSION_IMPL *session, void *voidpv, } } else for (; *p; p++) { - n = __wt_json_unpack_char(*p, buf, bufsz, 0); + n = __wt_json_unpack_char( + *p, buf, bufsz, false); if (n > bufsz) bufsz = 0; else { @@ -123,7 +125,7 @@ __json_unpack_put(WT_SESSION_IMPL *session, void *voidpv, bufsz--; } for (; p < end; p++) { - n = __wt_json_unpack_char(*p, buf, bufsz, 1); + n = __wt_json_unpack_char(*p, buf, bufsz, true); if (n > bufsz) bufsz = 0; else { @@ -163,7 +165,7 @@ __json_unpack_put(WT_SESSION_IMPL *session, void *voidpv, */ static inline int __json_struct_size(WT_SESSION_IMPL *session, const void *buffer, - size_t size, const char *fmt, WT_CONFIG_ITEM *names, int iskey, + size_t size, const char *fmt, WT_CONFIG_ITEM *names, bool iskey, size_t *presult) { WT_CONFIG_ITEM name; @@ -171,21 +173,21 @@ __json_struct_size(WT_SESSION_IMPL *session, const void *buffer, WT_DECL_RET; WT_PACK pack; WT_PACK_NAME packname; - const uint8_t *p, *end; size_t result; - int needcr; + bool needcr; + const uint8_t *p, *end; p = buffer; end = p + size; result = 0; - needcr = 0; + needcr = false; WT_RET(__pack_name_init(session, names, iskey, &packname)); WT_RET(__pack_init(session, &pack, fmt)); while ((ret = __pack_next(&pack, &pv)) == 0) { if (needcr) result += 2; - needcr = 1; + needcr = true; WT_RET(__unpack_read(session, &pv, &p, (size_t)(end - p))); WT_RET(__pack_name_next(&packname, &name)); result += __json_unpack_put(session, &pv, NULL, 0, &name); @@ -207,20 +209,20 @@ __json_struct_size(WT_SESSION_IMPL *session, const void *buffer, static inline int __json_struct_unpackv(WT_SESSION_IMPL *session, const void *buffer, size_t size, const char *fmt, WT_CONFIG_ITEM *names, - u_char *jbuf, size_t jbufsize, int iskey, va_list ap) + u_char *jbuf, size_t jbufsize, bool iskey, va_list ap) { WT_CONFIG_ITEM name; WT_DECL_PACK_VALUE(pv); WT_DECL_RET; WT_PACK pack; WT_PACK_NAME packname; - int needcr; size_t jsize; + bool needcr; const uint8_t *p, *end; p = buffer; end = p + size; - needcr = 0; + needcr = false; /* Unpacking a cursor marked as json implies a single arg. */ *va_arg(ap, const char **) = (char *)jbuf; @@ -234,7 +236,7 @@ __json_struct_unpackv(WT_SESSION_IMPL *session, jbuf += 2; jbufsize -= 2; } - needcr = 1; + needcr = true; WT_RET(__unpack_read(session, &pv, &p, (size_t)(end - p))); WT_RET(__pack_name_next(&packname, &name)); jsize = __json_unpack_put(session, @@ -261,7 +263,7 @@ __json_struct_unpackv(WT_SESSION_IMPL *session, int __wt_json_alloc_unpack(WT_SESSION_IMPL *session, const void *buffer, size_t size, const char *fmt, WT_CURSOR_JSON *json, - int iskey, va_list ap) + bool iskey, va_list ap) { WT_CONFIG_ITEM *names; WT_DECL_RET; @@ -308,7 +310,7 @@ __wt_json_close(WT_SESSION_IMPL *session, WT_CURSOR *cursor) * Can be called with null buf for sizing. */ size_t -__wt_json_unpack_char(char ch, u_char *buf, size_t bufsz, int force_unicode) +__wt_json_unpack_char(char ch, u_char *buf, size_t bufsz, bool force_unicode) { char abbrev; u_char h; @@ -456,9 +458,10 @@ __wt_json_token(WT_SESSION *wt_session, const char *src, int *toktype, const char **tokstart, size_t *toklen) { WT_SESSION_IMPL *session; - char ch; + int result; + bool backslash, isalph, isfloat; const char *bad; - int backslash, isalph, isfloat, result; + char ch; result = -1; session = (WT_SESSION_IMPL *)wt_session; @@ -475,7 +478,7 @@ __wt_json_token(WT_SESSION *wt_session, const char *src, int *toktype, /* JSON is specified in RFC 4627. */ switch (*src) { case '"': - backslash = 0; + backslash = false; src++; while ((ch = *src) != '\0') { if (!backslash) { @@ -485,7 +488,7 @@ __wt_json_token(WT_SESSION *wt_session, const char *src, int *toktype, break; } if (ch == '\\') - backslash = 1; + backslash = true; } else { /* We validate Unicode on this pass. */ if (ch == 'u') { @@ -501,7 +504,7 @@ __wt_json_token(WT_SESSION *wt_session, const char *src, int *toktype, } src += 5; } - backslash = 0; + backslash = false; } src++; } @@ -519,20 +522,20 @@ __wt_json_token(WT_SESSION *wt_session, const char *src, int *toktype, case '7': case '8': case '9': - isfloat = 0; + isfloat = false; if (*src == '-') src++; while ((ch = *src) != '\0' && isdigit(ch)) src++; if (*src == '.') { - isfloat = 1; + isfloat = true; src++; while ((ch = *src) != '\0' && isdigit(ch)) src++; } if (*src == 'e' || *src == 'E') { - isfloat = 1; + isfloat = true; src++; if (*src == '+' || *src == '-') src++; @@ -610,9 +613,9 @@ __wt_json_tokname(int toktype) static int json_string_arg(WT_SESSION_IMPL *session, const char **jstr, WT_ITEM *item) { - const char *tokstart; - int tok; WT_DECL_RET; + int tok; + const char *tokstart; WT_RET(__wt_json_token((WT_SESSION *)session, *jstr, &tok, &tokstart, &item->size)); @@ -640,8 +643,8 @@ json_int_arg(WT_SESSION_IMPL *session, const char **jstr, int64_t *ip) { char *end; const char *tokstart; - int tok; size_t toksize; + int tok; WT_RET(__wt_json_token((WT_SESSION *)session, *jstr, &tok, &tokstart, &toksize)); @@ -668,10 +671,10 @@ json_int_arg(WT_SESSION_IMPL *session, const char **jstr, int64_t *ip) static int json_uint_arg(WT_SESSION_IMPL *session, const char **jstr, uint64_t *up) { - char *end; - const char *tokstart; - int tok; size_t toksize; + int tok; + const char *tokstart; + char *end; WT_RET(__wt_json_token((WT_SESSION *)session, *jstr, &tok, &tokstart, &toksize)); @@ -718,14 +721,14 @@ __json_pack_struct(WT_SESSION_IMPL *session, void *buffer, size_t size, WT_DECL_PACK_VALUE(pv); WT_DECL_RET; WT_PACK pack; - const char *tokstart; - int multi; size_t toksize; + bool multi; uint8_t *p, *end; + const char *tokstart; p = buffer; end = p + size; - multi = 0; + multi = false; if (fmt[0] != '\0' && fmt[1] == '\0') { JSON_EXPECT_TOKEN_GET(session, jstr, 's', tokstart, toksize); @@ -745,7 +748,7 @@ __json_pack_struct(WT_SESSION_IMPL *session, void *buffer, size_t size, JSON_EXPECT_TOKEN(session, jstr, ':'); WT_PACK_JSON_GET(session, pv, jstr); WT_RET(__pack_write(session, &pv, &p, (size_t)(end - p))); - multi = 1; + multi = true; } /* Be paranoid - __pack_write should never overflow. */ @@ -767,18 +770,18 @@ __json_pack_struct(WT_SESSION_IMPL *session, void *buffer, size_t size, static int __json_pack_size( WT_SESSION_IMPL *session, const char *fmt, WT_CONFIG_ITEM *names, - int iskey, const char *jstr, size_t *sizep) + bool iskey, const char *jstr, size_t *sizep) { WT_CONFIG_ITEM name; WT_DECL_PACK_VALUE(pv); WT_PACK pack; WT_PACK_NAME packname; - const char *tokstart; - int multi; size_t toksize, total; + bool multi; + const char *tokstart; WT_RET(__pack_name_init(session, names, iskey, &packname)); - multi = 0; + multi = false; WT_RET(__pack_init(session, &pack, fmt)); for (total = 0; __pack_next(&pack, &pv) == 0;) { if (multi) @@ -794,7 +797,7 @@ __json_pack_size( JSON_EXPECT_TOKEN(session, jstr, ':'); WT_PACK_JSON_GET(session, pv, jstr); total += __pack_size(session, &pv); - multi = 1; + multi = true; } /* check end of string */ JSON_EXPECT_TOKEN(session, jstr, 0); @@ -810,7 +813,7 @@ __json_pack_size( */ int __wt_json_to_item(WT_SESSION_IMPL *session, const char *jstr, - const char *format, WT_CURSOR_JSON *json, int iskey, WT_ITEM *item) + const char *format, WT_CURSOR_JSON *json, bool iskey, WT_ITEM *item) { size_t sz; sz = 0; /* Initialize because GCC 4.1 is paranoid */ diff --git a/src/third_party/wiredtiger/src/cursor/cur_std.c b/src/third_party/wiredtiger/src/cursor/cur_std.c index 701bd845ae9..f92426355ef 100644 --- a/src/third_party/wiredtiger/src/cursor/cur_std.c +++ b/src/third_party/wiredtiger/src/cursor/cur_std.c @@ -63,7 +63,7 @@ __wt_cursor_set_notsup(WT_CURSOR *cursor) * Standard error message for key/values not set. */ int -__wt_cursor_kv_not_set(WT_CURSOR *cursor, int key) +__wt_cursor_kv_not_set(WT_CURSOR *cursor, bool key) { WT_SESSION_IMPL *session; @@ -113,9 +113,9 @@ int __wt_cursor_get_raw_key(WT_CURSOR *cursor, WT_ITEM *key) { WT_DECL_RET; - int raw_set; + bool raw_set; - raw_set = F_ISSET(cursor, WT_CURSTD_RAW) ? 1 : 0; + raw_set = F_ISSET(cursor, WT_CURSTD_RAW); if (!raw_set) F_SET(cursor, WT_CURSTD_RAW); ret = cursor->get_key(cursor, key); @@ -132,9 +132,9 @@ __wt_cursor_get_raw_key(WT_CURSOR *cursor, WT_ITEM *key) void __wt_cursor_set_raw_key(WT_CURSOR *cursor, WT_ITEM *key) { - int raw_set; + bool raw_set; - raw_set = F_ISSET(cursor, WT_CURSTD_RAW) ? 1 : 0; + raw_set = F_ISSET(cursor, WT_CURSTD_RAW); if (!raw_set) F_SET(cursor, WT_CURSTD_RAW); cursor->set_key(cursor, key); @@ -151,9 +151,9 @@ int __wt_cursor_get_raw_value(WT_CURSOR *cursor, WT_ITEM *value) { WT_DECL_RET; - int raw_set; + bool raw_set; - raw_set = F_ISSET(cursor, WT_CURSTD_RAW) ? 1 : 0; + raw_set = F_ISSET(cursor, WT_CURSTD_RAW); if (!raw_set) F_SET(cursor, WT_CURSTD_RAW); ret = cursor->get_value(cursor, value); @@ -170,9 +170,9 @@ __wt_cursor_get_raw_value(WT_CURSOR *cursor, WT_ITEM *value) void __wt_cursor_set_raw_value(WT_CURSOR *cursor, WT_ITEM *value) { - int raw_set; + bool raw_set; - raw_set = F_ISSET(cursor, WT_CURSTD_RAW) ? 1 : 0; + raw_set = F_ISSET(cursor, WT_CURSTD_RAW); if (!raw_set) F_SET(cursor, WT_CURSTD_RAW); cursor->set_value(cursor, value); @@ -195,7 +195,7 @@ __wt_cursor_get_keyv(WT_CURSOR *cursor, uint32_t flags, va_list ap) CURSOR_API_CALL(cursor, session, get_key, NULL); if (!F_ISSET(cursor, WT_CURSTD_KEY_EXT | WT_CURSTD_KEY_INT)) - WT_ERR(__wt_cursor_kv_not_set(cursor, 1)); + WT_ERR(__wt_cursor_kv_not_set(cursor, true)); if (WT_CURSOR_RECNO(cursor)) { if (LF_ISSET(WT_CURSTD_RAW)) { @@ -344,7 +344,7 @@ __wt_cursor_get_valuev(WT_CURSOR *cursor, va_list ap) CURSOR_API_CALL(cursor, session, get_value, NULL); if (!F_ISSET(cursor, WT_CURSTD_VALUE_EXT | WT_CURSTD_VALUE_INT)) - WT_ERR(__wt_cursor_kv_not_set(cursor, 0)); + WT_ERR(__wt_cursor_kv_not_set(cursor, false)); /* Fast path some common cases. */ fmt = cursor->value_format; diff --git a/src/third_party/wiredtiger/src/cursor/cur_table.c b/src/third_party/wiredtiger/src/cursor/cur_table.c index a046b2b1ed9..01d1fdd1886 100644 --- a/src/third_party/wiredtiger/src/cursor/cur_table.c +++ b/src/third_party/wiredtiger/src/cursor/cur_table.c @@ -71,11 +71,13 @@ __curextract_insert(WT_CURSOR *cursor) { } /* - * __apply_idx -- - * Apply an operation to all indices of a table. + * __wt_apply_single_idx -- + * Apply an operation to a single index of a table. */ -static int -__apply_idx(WT_CURSOR_TABLE *ctable, size_t func_off, int skip_immutable) { +int +__wt_apply_single_idx(WT_SESSION_IMPL *session, WT_INDEX *idx, + WT_CURSOR *cur, WT_CURSOR_TABLE *ctable, int (*f)(WT_CURSOR *)) +{ WT_CURSOR_STATIC_INIT(iface, __wt_cursor_get_key, /* get-key */ __wt_cursor_get_value, /* get-value */ @@ -93,11 +95,48 @@ __apply_idx(WT_CURSOR_TABLE *ctable, size_t func_off, int skip_immutable) { __wt_cursor_notsup, /* reconfigure */ __wt_cursor_notsup, /* remove */ __wt_cursor_notsup); /* close */ - WT_CURSOR **cp; WT_CURSOR_EXTRACTOR extract_cursor; WT_DECL_RET; - WT_INDEX *idx; WT_ITEM key, value; + + if (idx->extractor) { + extract_cursor.iface = iface; + extract_cursor.iface.session = &session->iface; + extract_cursor.iface.key_format = idx->exkey_format; + extract_cursor.ctable = ctable; + extract_cursor.idxc = cur; + extract_cursor.f = f; + + WT_RET(__wt_cursor_get_raw_key(&ctable->iface, &key)); + WT_RET(__wt_cursor_get_raw_value(&ctable->iface, &value)); + ret = idx->extractor->extract(idx->extractor, + &session->iface, &key, &value, + &extract_cursor.iface); + + __wt_buf_free(session, &extract_cursor.iface.key); + WT_RET(ret); + } else { + WT_RET(__wt_schema_project_merge(session, + ctable->cg_cursors, + idx->key_plan, idx->key_format, &cur->key)); + /* + * The index key is now set and the value is empty + * (it starts clear and is never set). + */ + F_SET(cur, WT_CURSTD_KEY_EXT | WT_CURSTD_VALUE_EXT); + WT_RET(f(cur)); + } + return (0); +} + +/* + * __apply_idx -- + * Apply an operation to all indices of a table. + */ +static int +__apply_idx(WT_CURSOR_TABLE *ctable, size_t func_off, bool skip_immutable) { + WT_CURSOR **cp; + WT_INDEX *idx; WT_SESSION_IMPL *session; int (*f)(WT_CURSOR *); u_int i; @@ -111,34 +150,7 @@ __apply_idx(WT_CURSOR_TABLE *ctable, size_t func_off, int skip_immutable) { continue; f = *(int (**)(WT_CURSOR *))((uint8_t *)*cp + func_off); - if (idx->extractor) { - extract_cursor.iface = iface; - extract_cursor.iface.session = &session->iface; - extract_cursor.iface.key_format = idx->exkey_format; - extract_cursor.ctable = ctable; - extract_cursor.idxc = *cp; - extract_cursor.f = f; - - WT_RET(__wt_cursor_get_raw_key(&ctable->iface, &key)); - WT_RET( - __wt_cursor_get_raw_value(&ctable->iface, &value)); - ret = idx->extractor->extract(idx->extractor, - &session->iface, &key, &value, - &extract_cursor.iface); - - __wt_buf_free(session, &extract_cursor.iface.key); - WT_RET(ret); - } else { - WT_RET(__wt_schema_project_merge(session, - ctable->cg_cursors, - idx->key_plan, idx->key_format, &(*cp)->key)); - /* - * The index key is now set and the value is empty - * (it starts clear and is never set). - */ - F_SET(*cp, WT_CURSTD_KEY_EXT | WT_CURSTD_VALUE_EXT); - WT_RET(f(*cp)); - } + WT_RET(__wt_apply_single_idx(session, idx, *cp, ctable, f)); WT_RET((*cp)->reset(*cp)); } @@ -504,7 +516,7 @@ __curtable_insert(WT_CURSOR *cursor) cp = ctable->cg_cursors; primary = *cp++; - flag_orig = F_ISSET(primary, WT_CURSTD_OVERWRITE); + flag_orig = F_MASK(primary, WT_CURSTD_OVERWRITE); if (ctable->table->nindices > 0) F_CLR(primary, WT_CURSTD_OVERWRITE); ret = primary->insert(primary); @@ -528,7 +540,7 @@ __curtable_insert(WT_CURSOR *cursor) WT_ERR((*cp)->insert(*cp)); } - WT_ERR(__apply_idx(ctable, offsetof(WT_CURSOR, insert), 0)); + WT_ERR(__apply_idx(ctable, offsetof(WT_CURSOR, insert), false)); err: CURSOR_UPDATE_API_END(session, ret); return (ret); @@ -567,7 +579,7 @@ __curtable_update(WT_CURSOR *cursor) /* Remove only if the key exists. */ if (ret == 0) { WT_ERR(__apply_idx(ctable, - offsetof(WT_CURSOR, remove), 1)); + offsetof(WT_CURSOR, remove), true)); WT_ERR(__wt_schema_project_slice(session, ctable->cg_cursors, ctable->plan, 0, cursor->value_format, value_copy)); @@ -579,7 +591,7 @@ __curtable_update(WT_CURSOR *cursor) WT_ERR(ret); if (ctable->table->nindices > 0) - WT_ERR(__apply_idx(ctable, offsetof(WT_CURSOR, insert), 1)); + WT_ERR(__apply_idx(ctable, offsetof(WT_CURSOR, insert), true)); err: CURSOR_UPDATE_API_END(session, ret); __wt_scr_free(session, &value_copy); @@ -605,7 +617,7 @@ __curtable_remove(WT_CURSOR *cursor) if (ctable->table->nindices > 0) { APPLY_CG(ctable, search); WT_ERR(ret); - WT_ERR(__apply_idx(ctable, offsetof(WT_CURSOR, remove), 0)); + WT_ERR(__apply_idx(ctable, offsetof(WT_CURSOR, remove), false)); } APPLY_CG(ctable, remove); @@ -656,7 +668,7 @@ __wt_table_range_truncate(WT_CURSOR_TABLE *start, WT_CURSOR_TABLE *stop) APPLY_CG(stop, search); WT_ERR(ret); WT_ERR(__apply_idx( - stop, offsetof(WT_CURSOR, remove), 0)); + stop, offsetof(WT_CURSOR, remove), false)); } while ((ret = wt_stop->prev(wt_stop)) == 0); WT_ERR_NOTFOUND_OK(ret); @@ -671,7 +683,7 @@ __wt_table_range_truncate(WT_CURSOR_TABLE *start, WT_CURSOR_TABLE *stop) APPLY_CG(start, search); WT_ERR(ret); WT_ERR(__apply_idx( - start, offsetof(WT_CURSOR, remove), 0)); + start, offsetof(WT_CURSOR, remove), false)); if (stop != NULL) WT_ERR(wt_start->compare( wt_start, wt_stop, @@ -711,12 +723,13 @@ __curtable_close(WT_CURSOR *cursor) ctable = (WT_CURSOR_TABLE *)cursor; CURSOR_API_CALL(cursor, session, close, NULL); - for (i = 0, cp = ctable->cg_cursors; - i < WT_COLGROUPS(ctable->table); i++, cp++) - if (*cp != NULL) { - WT_TRET((*cp)->close(*cp)); - *cp = NULL; - } + if (ctable->cg_cursors != NULL) + for (i = 0, cp = ctable->cg_cursors; + i < WT_COLGROUPS(ctable->table); i++, cp++) + if (*cp != NULL) { + WT_TRET((*cp)->close(*cp)); + *cp = NULL; + } if (ctable->idx_cursors != NULL) for (i = 0, cp = ctable->idx_cursors; @@ -764,7 +777,7 @@ __curtable_open_colgroups(WT_CURSOR_TABLE *ctable, const char *cfg_arg[]) cfg_arg[0], cfg_arg[1], "dump=\"\",readonly=0", NULL, NULL }; u_int i; - int complete; + bool complete; session = (WT_SESSION_IMPL *)ctable->iface.session; table = ctable->table; @@ -872,7 +885,7 @@ __wt_curtable_open(WT_SESSION_IMPL *session, size = strlen(tablename); else size = WT_PTRDIFF(columns, tablename); - WT_RET(__wt_schema_get_table(session, tablename, size, 0, &table)); + WT_RET(__wt_schema_get_table(session, tablename, size, false, &table)); if (table->is_simple) { /* Just return a cursor on the underlying data source. */ @@ -899,13 +912,13 @@ __wt_curtable_open(WT_SESSION_IMPL *session, WT_ERR(__wt_scr_alloc(session, 0, &tmp)); if (columns != NULL) { WT_ERR(__wt_struct_reformat(session, table, - columns, strlen(columns), NULL, 1, tmp)); + columns, strlen(columns), NULL, true, tmp)); WT_ERR(__wt_strndup( session, tmp->data, tmp->size, &cursor->value_format)); WT_ERR(__wt_buf_init(session, tmp, 0)); WT_ERR(__wt_struct_plan(session, table, - columns, strlen(columns), 0, tmp)); + columns, strlen(columns), false, tmp)); WT_ERR(__wt_strndup( session, tmp->data, tmp->size, &ctable->plan)); } diff --git a/src/third_party/wiredtiger/src/evict/evict_file.c b/src/third_party/wiredtiger/src/evict/evict_file.c index 66fabe48fb2..e17dfd835ff 100644 --- a/src/third_party/wiredtiger/src/evict/evict_file.c +++ b/src/third_party/wiredtiger/src/evict/evict_file.c @@ -18,7 +18,7 @@ __wt_evict_file(WT_SESSION_IMPL *session, int syncop) WT_DECL_RET; WT_PAGE *page; WT_REF *next_ref, *ref; - int evict_reset; + bool evict_reset; /* * We need exclusive access to the file -- disable ordinary eviction @@ -27,7 +27,7 @@ __wt_evict_file(WT_SESSION_IMPL *session, int syncop) WT_RET(__wt_evict_file_exclusive_on(session, &evict_reset)); /* Make sure the oldest transaction ID is up-to-date. */ - __wt_txn_update_oldest(session, 1); + __wt_txn_update_oldest(session, true); /* Walk the tree, discarding pages. */ next_ref = NULL; @@ -90,7 +90,7 @@ __wt_evict_file(WT_SESSION_IMPL *session, int syncop) WT_ASSERT(session, F_ISSET(session->dhandle, WT_DHANDLE_DEAD) || - __wt_page_can_evict(session, page, 0, NULL)); + __wt_page_can_evict(session, page, false, NULL)); __wt_evict_page_clean_update(session, ref, 1); break; WT_ILLEGAL_VALUE_ERR(session); diff --git a/src/third_party/wiredtiger/src/evict/evict_lru.c b/src/third_party/wiredtiger/src/evict/evict_lru.c index e0866521c7c..87f7da23c94 100644 --- a/src/third_party/wiredtiger/src/evict/evict_lru.c +++ b/src/third_party/wiredtiger/src/evict/evict_lru.c @@ -11,9 +11,9 @@ static int __evict_clear_all_walks(WT_SESSION_IMPL *); static int __evict_clear_walks(WT_SESSION_IMPL *); static int WT_CDECL __evict_lru_cmp(const void *, const void *); -static int __evict_lru_pages(WT_SESSION_IMPL *, int); +static int __evict_lru_pages(WT_SESSION_IMPL *, bool); static int __evict_lru_walk(WT_SESSION_IMPL *); -static int __evict_page(WT_SESSION_IMPL *, int); +static int __evict_page(WT_SESSION_IMPL *, bool); static int __evict_pass(WT_SESSION_IMPL *); static int __evict_walk(WT_SESSION_IMPL *); static int __evict_walk_file(WT_SESSION_IMPL *, u_int *); @@ -247,7 +247,7 @@ __evict_workers_resize(WT_SESSION_IMPL *session) for (i = conn->evict_workers_alloc; i < conn->evict_workers_max; i++) { WT_ERR(__wt_open_internal_session(conn, - "eviction-worker", 1, 0, &workers[i].session)); + "eviction-worker", true, false, &workers[i].session)); workers[i].id = i; /* @@ -286,7 +286,7 @@ __wt_evict_create(WT_SESSION_IMPL *session) /* We need a session handle because we're reading/writing pages. */ WT_RET(__wt_open_internal_session( - conn, "eviction-server", 1, 0, &conn->evict_session)); + conn, "eviction-server", true, false, &conn->evict_session)); session = conn->evict_session; /* @@ -399,7 +399,7 @@ __evict_worker(void *arg) while (F_ISSET(conn, WT_CONN_EVICTION_RUN) && F_ISSET(worker, WT_EVICT_WORKER_RUN)) { /* Don't spin in a busy loop if there is no work to do */ - if ((ret = __evict_lru_pages(session, 0)) == WT_NOTFOUND) + if ((ret = __evict_lru_pages(session, false)) == WT_NOTFOUND) WT_ERR(__wt_cond_wait( session, cache->evict_waiter_cond, 10000)); else @@ -523,7 +523,7 @@ __evict_pass(WT_SESSION_IMPL *session) * of whether the cache is full, to prevent the oldest ID * falling too far behind. */ - __wt_txn_update_oldest(session, 1); + __wt_txn_update_oldest(session, true); if (!__evict_update_work(session)) break; @@ -701,7 +701,7 @@ __evict_clear_all_walks(WT_SESSION_IMPL *session) * blocks queued for eviction. */ int -__wt_evict_file_exclusive_on(WT_SESSION_IMPL *session, int *evict_resetp) +__wt_evict_file_exclusive_on(WT_SESSION_IMPL *session, bool *evict_resetp) { WT_BTREE *btree; WT_CACHE *cache; @@ -715,10 +715,10 @@ __wt_evict_file_exclusive_on(WT_SESSION_IMPL *session, int *evict_resetp) * If the file isn't evictable, there's no work to do. */ if (F_ISSET(btree, WT_BTREE_NO_EVICTION)) { - *evict_resetp = 0; + *evict_resetp = false; return (0); } - *evict_resetp = 1; + *evict_resetp = true; /* * Hold the walk lock to set the "no eviction" flag: no new pages from @@ -775,7 +775,7 @@ __wt_evict_file_exclusive_off(WT_SESSION_IMPL *session) * Get pages from the LRU queue to evict. */ static int -__evict_lru_pages(WT_SESSION_IMPL *session, int is_server) +__evict_lru_pages(WT_SESSION_IMPL *session, bool is_server) { WT_DECL_RET; @@ -905,7 +905,7 @@ __evict_server_work(WT_SESSION_IMPL *session) cache->evict_current != NULL) __wt_yield(); } else - WT_RET_NOTFOUND_OK(__evict_lru_pages(session, 1)); + WT_RET_NOTFOUND_OK(__evict_lru_pages(session, true)); return (0); } @@ -923,12 +923,12 @@ __evict_walk(WT_SESSION_IMPL *session) WT_DATA_HANDLE *dhandle; WT_DECL_RET; u_int max_entries, prev_slot, retries, slot, start_slot, spins; - int incr, dhandle_locked; + bool dhandle_locked, incr; conn = S2C(session); cache = S2C(session)->cache; dhandle = NULL; - incr = dhandle_locked = 0; + dhandle_locked = incr = false; retries = 0; if (cache->evict_current == NULL) @@ -967,7 +967,7 @@ retry: while (slot < max_entries && ret == 0) { } if (ret != 0) break; - dhandle_locked = 1; + dhandle_locked = true; } if (dhandle == NULL) { @@ -985,7 +985,7 @@ retry: while (slot < max_entries && ret == 0) { WT_ASSERT(session, dhandle->session_inuse > 0); (void)__wt_atomic_subi32( &dhandle->session_inuse, 1); - incr = 0; + incr = false; } dhandle = TAILQ_NEXT(dhandle, q); } @@ -1008,7 +1008,8 @@ retry: while (slot < max_entries && ret == 0) { * Also skip files that are checkpointing or configured to * stick in cache until we get aggressive. */ - if ((btree->checkpointing || btree->evict_priority != 0) && + if ((btree->checkpointing != WT_CKPT_OFF || + btree->evict_priority != 0) && !FLD_ISSET(cache->state, WT_EVICT_PASS_AGGRESSIVE)) continue; @@ -1029,9 +1030,9 @@ retry: while (slot < max_entries && ret == 0) { prev_slot = slot; (void)__wt_atomic_addi32(&dhandle->session_inuse, 1); - incr = 1; + incr = true; __wt_spin_unlock(session, &conn->dhandle_lock); - dhandle_locked = 0; + dhandle_locked = false; __wt_spin_lock(session, &cache->evict_walk_lock); @@ -1064,12 +1065,12 @@ retry: while (slot < max_entries && ret == 0) { WT_ASSERT(session, dhandle->session_inuse > 0); (void)__wt_atomic_subi32(&dhandle->session_inuse, 1); - incr = 0; + incr = false; } if (dhandle_locked) { __wt_spin_unlock(session, &conn->dhandle_lock); - dhandle_locked = 0; + dhandle_locked = false; } /* @@ -1135,7 +1136,8 @@ __evict_walk_file(WT_SESSION_IMPL *session, u_int *slotp) WT_REF *ref; uint64_t pages_walked; uint32_t walk_flags; - int enough, internal_pages, modified, restarts; + int internal_pages, restarts; + bool enough, modified; conn = S2C(session); btree = S2BT(session); @@ -1143,7 +1145,8 @@ __evict_walk_file(WT_SESSION_IMPL *session, u_int *slotp) start = cache->evict_queue + *slotp; end = WT_MIN(start + WT_EVICT_WALK_PER_FILE, cache->evict_queue + cache->evict_slots); - enough = internal_pages = restarts = 0; + internal_pages = restarts = 0; + enough = false; walk_flags = WT_READ_CACHE | WT_READ_NO_EVICT | WT_READ_NO_GEN | WT_READ_NO_WAIT; @@ -1167,7 +1170,7 @@ __evict_walk_file(WT_SESSION_IMPL *session, u_int *slotp) evict < end && !enough && (ret == 0 || ret == WT_NOTFOUND); ret = __wt_tree_walk( session, &btree->evict_ref, &pages_walked, walk_flags)) { - enough = (pages_walked > WT_EVICT_MAX_PER_FILE); + enough = pages_walked > WT_EVICT_MAX_PER_FILE; if ((ref = btree->evict_ref) == NULL) { if (++restarts == 2 || enough) break; @@ -1218,7 +1221,7 @@ __evict_walk_file(WT_SESSION_IMPL *session, u_int *slotp) page->read_gen = __wt_cache_read_gen_new(session); fast: /* If the page can't be evicted, give up. */ - if (!__wt_page_can_evict(session, page, 1, NULL)) + if (!__wt_page_can_evict(session, page, true, NULL)) continue; /* @@ -1298,7 +1301,7 @@ fast: /* If the page can't be evicted, give up. */ */ static int __evict_get_ref( - WT_SESSION_IMPL *session, int is_server, WT_BTREE **btreep, WT_REF **refp) + WT_SESSION_IMPL *session, bool is_server, WT_BTREE **btreep, WT_REF **refp) { WT_CACHE *cache; WT_EVICT_ENTRY *evict; @@ -1380,7 +1383,7 @@ __evict_get_ref( * Called by both eviction and application threads to evict a page. */ static int -__evict_page(WT_SESSION_IMPL *session, int is_server) +__evict_page(WT_SESSION_IMPL *session, bool is_server) { WT_BTREE *btree; WT_CACHE *cache; @@ -1447,14 +1450,15 @@ __evict_page(WT_SESSION_IMPL *session, int is_server) * crosses its boundaries. */ int -__wt_cache_eviction_worker(WT_SESSION_IMPL *session, int busy, u_int pct_full) +__wt_cache_eviction_worker(WT_SESSION_IMPL *session, bool busy, u_int pct_full) { WT_CACHE *cache; WT_CONNECTION_IMPL *conn; WT_DECL_RET; WT_TXN_GLOBAL *txn_global; WT_TXN_STATE *txn_state; - int count, q_found, txn_busy; + int count; + bool q_found, txn_busy; conn = S2C(session); cache = conn->cache; @@ -1478,7 +1482,7 @@ __wt_cache_eviction_worker(WT_SESSION_IMPL *session, int busy, u_int pct_full) if (txn_busy) { if (pct_full < 100) return (0); - busy = 1; + busy = true; } /* @@ -1504,14 +1508,14 @@ __wt_cache_eviction_worker(WT_SESSION_IMPL *session, int busy, u_int pct_full) } /* Evict a page. */ - q_found = 0; - switch (ret = __evict_page(session, 0)) { + q_found = false; + switch (ret = __evict_page(session, false)) { case 0: cache->app_evicts++; if (--count == 0) return (0); - q_found = 1; + q_found = true; break; case EBUSY: continue; @@ -1536,8 +1540,10 @@ __wt_cache_eviction_worker(WT_SESSION_IMPL *session, int busy, u_int pct_full) cache->app_waits++; /* Check if things have changed so that we are busy. */ if (!busy && txn_state->snap_min != WT_TXN_NONE && - txn_global->current != txn_global->oldest_id) - busy = count = 1; + txn_global->current != txn_global->oldest_id) { + busy = true; + count = 1; + } } /* NOTREACHED */ } diff --git a/src/third_party/wiredtiger/src/evict/evict_page.c b/src/third_party/wiredtiger/src/evict/evict_page.c index 11284ce7b21..bbe929b4a43 100644 --- a/src/third_party/wiredtiger/src/evict/evict_page.c +++ b/src/third_party/wiredtiger/src/evict/evict_page.c @@ -8,8 +8,8 @@ #include "wt_internal.h" -static int __evict_page_dirty_update(WT_SESSION_IMPL *, WT_REF *, int); -static int __evict_review(WT_SESSION_IMPL *, WT_REF *, int *, int); +static int __evict_page_dirty_update(WT_SESSION_IMPL *, WT_REF *, bool); +static int __evict_review(WT_SESSION_IMPL *, WT_REF *, bool *, bool); /* * __evict_exclusive_clear -- @@ -49,13 +49,13 @@ __evict_exclusive(WT_SESSION_IMPL *session, WT_REF *ref) * Evict a page. */ int -__wt_evict(WT_SESSION_IMPL *session, WT_REF *ref, int closing) +__wt_evict(WT_SESSION_IMPL *session, WT_REF *ref, bool closing) { WT_CONNECTION_IMPL *conn; WT_DECL_RET; WT_PAGE *page; WT_PAGE_MODIFY *mod; - int forced_eviction, inmem_split; + bool forced_eviction, inmem_split; conn = S2C(session); @@ -64,7 +64,7 @@ __wt_evict(WT_SESSION_IMPL *session, WT_REF *ref, int closing) page = ref->page; forced_eviction = page->read_gen == WT_READGEN_OLDEST; - inmem_split = 0; + inmem_split = false; WT_RET(__wt_verbose(session, WT_VERB_EVICT, "page %p (%s)", page, __wt_page_type_string(page->type))); @@ -106,7 +106,7 @@ __wt_evict(WT_SESSION_IMPL *session, WT_REF *ref, int closing) conn->cache->evict_max_page_size = page->memory_footprint; /* Update the reference and discard the page. */ - if (mod == NULL || !F_ISSET(mod, WT_PM_REC_MASK)) { + if (mod == NULL || mod->rec_result == 0) { if (__wt_ref_is_root(ref)) __wt_ref_out(session, ref); else @@ -148,7 +148,8 @@ done: if (((inmem_split && ret == 0) || (forced_eviction && ret == EBUSY)) && * Update a clean page's reference on eviction. */ int -__wt_evict_page_clean_update(WT_SESSION_IMPL *session, WT_REF *ref, int closing) +__wt_evict_page_clean_update( + WT_SESSION_IMPL *session, WT_REF *ref, bool closing) { /* * If doing normal system eviction, but only in the service of reducing @@ -174,7 +175,7 @@ __wt_evict_page_clean_update(WT_SESSION_IMPL *session, WT_REF *ref, int closing) * Update a dirty page's reference on eviction. */ static int -__evict_page_dirty_update(WT_SESSION_IMPL *session, WT_REF *ref, int closing) +__evict_page_dirty_update(WT_SESSION_IMPL *session, WT_REF *ref, bool closing) { WT_ADDR *addr; WT_PAGE *parent; @@ -183,7 +184,7 @@ __evict_page_dirty_update(WT_SESSION_IMPL *session, WT_REF *ref, int closing) parent = ref->home; mod = ref->page->modify; - switch (F_ISSET(mod, WT_PM_REC_MASK)) { + switch (mod->rec_result) { case WT_PM_REC_EMPTY: /* Page is empty */ /* Discard the parent's address. */ if (ref->addr != NULL && __wt_off_page(parent, ref->addr)) { @@ -296,7 +297,7 @@ __evict_child_check(WT_SESSION_IMPL *session, WT_REF *parent) */ static int __evict_review( - WT_SESSION_IMPL *session, WT_REF *ref, int *inmem_splitp, int closing) + WT_SESSION_IMPL *session, WT_REF *ref, bool *inmem_splitp, bool closing) { WT_DECL_RET; WT_PAGE *page; @@ -341,9 +342,9 @@ __evict_review( * fallen behind current. */ if (__wt_page_is_modified(page)) - __wt_txn_update_oldest(session, 1); + __wt_txn_update_oldest(session, true); - if (!__wt_page_can_evict(session, page, 0, inmem_splitp)) + if (!__wt_page_can_evict(session, page, false, inmem_splitp)) return (EBUSY); /* diff --git a/src/third_party/wiredtiger/src/include/api.h b/src/third_party/wiredtiger/src/include/api.h index a6e12f4a2ad..271425ded5b 100644 --- a/src/third_party/wiredtiger/src/include/api.h +++ b/src/third_party/wiredtiger/src/include/api.h @@ -72,7 +72,7 @@ ret = 0; \ continue; \ } \ - WT_TRET(__wt_session_reset_cursors(s, 0)); \ + WT_TRET(__wt_session_reset_cursors(s, false)); \ } \ } \ break; \ diff --git a/src/third_party/wiredtiger/src/include/block.h b/src/third_party/wiredtiger/src/include/block.h index a7cdaba8b9f..41f2423206b 100644 --- a/src/third_party/wiredtiger/src/include/block.h +++ b/src/third_party/wiredtiger/src/include/block.h @@ -54,7 +54,7 @@ struct __wt_extlist { wt_off_t offset; /* Written extent offset */ uint32_t cksum, size; /* Written extent cksum, size */ - int track_size; /* Maintain per-size skiplist */ + bool track_size; /* Maintain per-size skiplist */ WT_EXT *last; /* Cached last element */ @@ -161,16 +161,16 @@ struct __wt_bm { (WT_BM *, WT_SESSION_IMPL *, WT_ITEM *, const uint8_t *, size_t); u_int (*block_header)(WT_BM *); int (*checkpoint) - (WT_BM *, WT_SESSION_IMPL *, WT_ITEM *, WT_CKPT *, int); + (WT_BM *, WT_SESSION_IMPL *, WT_ITEM *, WT_CKPT *, bool); int (*checkpoint_load)(WT_BM *, WT_SESSION_IMPL *, - const uint8_t *, size_t, uint8_t *, size_t *, int); + const uint8_t *, size_t, uint8_t *, size_t *, bool); int (*checkpoint_resolve)(WT_BM *, WT_SESSION_IMPL *); int (*checkpoint_unload)(WT_BM *, WT_SESSION_IMPL *); int (*close)(WT_BM *, WT_SESSION_IMPL *); int (*compact_end)(WT_BM *, WT_SESSION_IMPL *); int (*compact_page_skip) - (WT_BM *, WT_SESSION_IMPL *, const uint8_t *, size_t, int *); - int (*compact_skip)(WT_BM *, WT_SESSION_IMPL *, int *); + (WT_BM *, WT_SESSION_IMPL *, const uint8_t *, size_t, bool *); + int (*compact_skip)(WT_BM *, WT_SESSION_IMPL *, bool *); int (*compact_start)(WT_BM *, WT_SESSION_IMPL *); int (*free)(WT_BM *, WT_SESSION_IMPL *, const uint8_t *, size_t); int (*preload)(WT_BM *, WT_SESSION_IMPL *, const uint8_t *, size_t); @@ -178,18 +178,18 @@ struct __wt_bm { (WT_BM *, WT_SESSION_IMPL *, WT_ITEM *, const uint8_t *, size_t); int (*salvage_end)(WT_BM *, WT_SESSION_IMPL *); int (*salvage_next) - (WT_BM *, WT_SESSION_IMPL *, uint8_t *, size_t *, int *); + (WT_BM *, WT_SESSION_IMPL *, uint8_t *, size_t *, bool *); int (*salvage_start)(WT_BM *, WT_SESSION_IMPL *); int (*salvage_valid) - (WT_BM *, WT_SESSION_IMPL *, uint8_t *, size_t, int); + (WT_BM *, WT_SESSION_IMPL *, uint8_t *, size_t, bool); int (*stat)(WT_BM *, WT_SESSION_IMPL *, WT_DSRC_STATS *stats); - int (*sync)(WT_BM *, WT_SESSION_IMPL *, int); + int (*sync)(WT_BM *, WT_SESSION_IMPL *, bool); int (*verify_addr)(WT_BM *, WT_SESSION_IMPL *, const uint8_t *, size_t); int (*verify_end)(WT_BM *, WT_SESSION_IMPL *); int (*verify_start) (WT_BM *, WT_SESSION_IMPL *, WT_CKPT *, const char *[]); int (*write) (WT_BM *, - WT_SESSION_IMPL *, WT_ITEM *, uint8_t *, size_t *, int); + WT_SESSION_IMPL *, WT_ITEM *, uint8_t *, size_t *, bool); int (*write_size)(WT_BM *, WT_SESSION_IMPL *, size_t *); WT_BLOCK *block; /* Underlying file */ @@ -202,7 +202,7 @@ struct __wt_bm { * There's only a single block manager handle that can be written, all * others are checkpoints. */ - int is_live; /* The live system */ + bool is_live; /* The live system */ }; /* @@ -247,8 +247,8 @@ struct __wt_block { wt_off_t slvg_off; /* Salvage file offset */ /* Verification support */ - int verify; /* If performing verification */ - int verify_strict; /* Fail hard on any error */ + bool verify; /* If performing verification */ + bool verify_strict; /* Fail hard on any error */ wt_off_t verify_size; /* Checkpoint's file size */ WT_EXTLIST verify_alloc; /* Verification allocation list */ uint64_t frags; /* Maximum frags in the file */ diff --git a/src/third_party/wiredtiger/src/include/btmem.h b/src/third_party/wiredtiger/src/include/btmem.h index f214ddb1dc3..61c0f3cbecf 100644 --- a/src/third_party/wiredtiger/src/include/btmem.h +++ b/src/third_party/wiredtiger/src/include/btmem.h @@ -288,9 +288,11 @@ struct __wt_page_modify { uint32_t cksum; } *multi; uint32_t multi_entries; /* Multiple blocks element count */ + bool multi_row_ovfl; /* Row-store overflow key/values */ } m; #define mod_multi u1.m.multi #define mod_multi_entries u1.m.multi_entries +#define mod_multi_row_ovfl u1.m.multi_row_ovfl } u1; /* @@ -374,10 +376,6 @@ struct __wt_page_modify { /* * The write generation is incremented when a page is modified, a page * is clean if the write generation is 0. - * - * !!! - * 4B values are probably larger than required, but I'm more confident - * 4B types will always be backed by atomic writes to memory. */ uint32_t write_gen; @@ -387,14 +385,11 @@ struct __wt_page_modify { __wt_spin_unlock((s), &S2C(s)->page_lock[(p)->modify->page_lock]) uint8_t page_lock; /* Page's spinlock */ -#define WT_PM_REC_EMPTY 0x01 /* Reconciliation: no replacement */ -#define WT_PM_REC_MULTIBLOCK 0x02 /* Reconciliation: multiple blocks */ -#define WT_PM_REC_REPLACE 0x04 /* Reconciliation: single block */ -#define WT_PM_REC_REWRITE 0x08 /* Reconciliation: rewrite in place */ -#define WT_PM_REC_MASK \ - (WT_PM_REC_EMPTY | WT_PM_REC_MULTIBLOCK | \ - WT_PM_REC_REPLACE | WT_PM_REC_REWRITE) - uint8_t flags; /* Page flags */ +#define WT_PM_REC_EMPTY 1 /* Reconciliation: no replacement */ +#define WT_PM_REC_MULTIBLOCK 2 /* Reconciliation: multiple blocks */ +#define WT_PM_REC_REPLACE 3 /* Reconciliation: single block */ +#define WT_PM_REC_REWRITE 4 /* Reconciliation: rewrite in place */ + uint8_t rec_result; /* Reconciliation state */ }; /* diff --git a/src/third_party/wiredtiger/src/include/btree.h b/src/third_party/wiredtiger/src/include/btree.h index 98ce4c22c10..acfcef2ab47 100644 --- a/src/third_party/wiredtiger/src/include/btree.h +++ b/src/third_party/wiredtiger/src/include/btree.h @@ -119,7 +119,7 @@ struct __wt_btree { WT_REF root; /* Root page reference */ int modified; /* If the tree ever modified */ - int bulk_load_ok; /* Bulk-load is a possibility */ + bool bulk_load_ok; /* Bulk-load is a possibility */ WT_BM *bm; /* Block manager reference */ u_int block_header; /* WT_PAGE_HEADER_BYTE_SIZE */ @@ -134,7 +134,9 @@ struct __wt_btree { u_int evict_walk_skips; /* Number of walks skipped */ volatile uint32_t evict_busy; /* Count of threads in eviction */ - int checkpointing; /* Checkpoint in progress */ + enum { + WT_CKPT_OFF, WT_CKPT_PREPARE, WT_CKPT_RUNNING + } checkpointing; /* Checkpoint in progress */ /* * We flush pages from the tree (in order to make checkpoint faster), diff --git a/src/third_party/wiredtiger/src/include/btree.i b/src/third_party/wiredtiger/src/include/btree.i index b54cecb6ce0..6200c5e21d0 100644 --- a/src/third_party/wiredtiger/src/include/btree.i +++ b/src/third_party/wiredtiger/src/include/btree.i @@ -24,7 +24,7 @@ static inline bool __wt_page_is_empty(WT_PAGE *page) { return (page->modify != NULL && - F_ISSET(page->modify, WT_PM_REC_MASK) == WT_PM_REC_EMPTY ? 1 : 0); + page->modify->rec_result == WT_PM_REC_EMPTY); } /* @@ -77,12 +77,12 @@ __wt_cache_decr_check_size( (void)__wt_atomic_addsize(vp, v); { - static int first = 1; + static bool first = true; if (!first) return; __wt_errx(session, "%s underflow: decrementing %" WT_SIZET_FMT, fld, v); - first = 0; + first = false; } #else WT_UNUSED(fld); @@ -105,12 +105,12 @@ __wt_cache_decr_check_uint64( (void)__wt_atomic_add64(vp, v); { - static int first = 1; + static bool first = true; if (!first) return; __wt_errx(session, "%s underflow: decrementing %" WT_SIZET_FMT, fld, v); - first = 0; + first = false; } #else WT_UNUSED(fld); @@ -430,7 +430,7 @@ __wt_page_modify_set(WT_SESSION_IMPL *session, WT_PAGE *page) */ static inline int __wt_page_parent_modify_set( - WT_SESSION_IMPL *session, WT_REF *ref, int page_only) + WT_SESSION_IMPL *session, WT_REF *ref, bool page_only) { WT_PAGE *parent; @@ -791,7 +791,7 @@ __wt_row_leaf_value_set(WT_PAGE *page, WT_ROW *rip, WT_CELL_UNPACK *unpack) */ static inline int __wt_row_leaf_key(WT_SESSION_IMPL *session, - WT_PAGE *page, WT_ROW *rip, WT_ITEM *key, int instantiate) + WT_PAGE *page, WT_ROW *rip, WT_ITEM *key, bool instantiate) { void *copy; @@ -838,7 +838,7 @@ __wt_cursor_row_leaf_key(WT_CURSOR_BTREE *cbt, WT_ITEM *key) session = (WT_SESSION_IMPL *)cbt->iface.session; page = cbt->ref->page; rip = &page->u.row.d[cbt->slot]; - WT_RET(__wt_row_leaf_key(session, page, rip, key, 0)); + WT_RET(__wt_row_leaf_key(session, page, rip, key, false)); } else { key->data = WT_INSERT_KEY(cbt->ins); key->size = WT_INSERT_KEY_SIZE(cbt->ins); @@ -1035,14 +1035,14 @@ __wt_page_can_split(WT_SESSION_IMPL *session, WT_PAGE *page) */ static inline bool __wt_page_can_evict(WT_SESSION_IMPL *session, - WT_PAGE *page, int check_splits, int *inmem_splitp) + WT_PAGE *page, bool check_splits, bool *inmem_splitp) { WT_BTREE *btree; WT_PAGE_MODIFY *mod; WT_TXN_GLOBAL *txn_global; if (inmem_splitp != NULL) - *inmem_splitp = 0; + *inmem_splitp = false; btree = S2BT(session); mod = page->modify; @@ -1059,10 +1059,33 @@ __wt_page_can_evict(WT_SESSION_IMPL *session, */ if (__wt_page_can_split(session, page)) { if (inmem_splitp != NULL) - *inmem_splitp = 1; + *inmem_splitp = true; return (true); } + /* + * If the file is being checkpointed, we can't evict dirty pages: + * if we write a page and free the previous version of the page, that + * previous version might be referenced by an internal page already + * been written in the checkpoint, leaving the checkpoint inconsistent. + */ + if (btree->checkpointing != WT_CKPT_OFF && + __wt_page_is_modified(page)) { + WT_STAT_FAST_CONN_INCR(session, cache_eviction_checkpoint); + WT_STAT_FAST_DATA_INCR(session, cache_eviction_checkpoint); + return (false); + } + + /* + * We can't evict clean, multiblock row-store pages with overflow keys + * when the file is being checkpointed: the split into the parent frees + * the backing blocks for no-longer-used overflow keys, corrupting the + * checkpoint's block management. + */ + if (btree->checkpointing && + mod->rec_result == WT_PM_REC_MULTIBLOCK && mod->mod_multi_row_ovfl) + return (false); + /* * If the tree was deepened, there's a requirement that newly created * internal pages not be evicted until all threads are known to have @@ -1076,18 +1099,6 @@ __wt_page_can_evict(WT_SESSION_IMPL *session, !__wt_txn_visible_all(session, mod->mod_split_txn)) return (false); - /* - * If the file is being checkpointed, we can't evict dirty pages: - * if we write a page and free the previous version of the page, that - * previous version might be referenced by an internal page already - * been written in the checkpoint, leaving the checkpoint inconsistent. - */ - if (btree->checkpointing && __wt_page_is_modified(page)) { - WT_STAT_FAST_CONN_INCR(session, cache_eviction_checkpoint); - WT_STAT_FAST_DATA_INCR(session, cache_eviction_checkpoint); - return (false); - } - /* * If the page was recently split in-memory, don't evict it immediately: * we want to give application threads that are appending a chance to @@ -1115,7 +1126,7 @@ __wt_page_release_evict(WT_SESSION_IMPL *session, WT_REF *ref) WT_BTREE *btree; WT_DECL_RET; WT_PAGE *page; - int locked, too_big; + bool locked, too_big; btree = S2BT(session); page = ref->page; @@ -1125,7 +1136,8 @@ __wt_page_release_evict(WT_SESSION_IMPL *session, WT_REF *ref) * reference without first locking the page, it could be evicted in * between. */ - locked = __wt_atomic_casv32(&ref->state, WT_REF_MEM, WT_REF_LOCKED); + locked = __wt_atomic_casv32( + &ref->state, WT_REF_MEM, WT_REF_LOCKED) ? true : false; if ((ret = __wt_hazard_clear(session, page)) != 0 || !locked) { if (locked) ref->state = WT_REF_MEM; @@ -1134,7 +1146,7 @@ __wt_page_release_evict(WT_SESSION_IMPL *session, WT_REF *ref) (void)__wt_atomic_addv32(&btree->evict_busy, 1); - too_big = (page->memory_footprint > btree->maxmempage) ? 1 : 0; + too_big = page->memory_footprint > btree->maxmempage; if ((ret = __wt_evict(session, ref, 0)) == 0) { if (too_big) WT_STAT_FAST_CONN_INCR(session, cache_eviction_force); @@ -1194,7 +1206,7 @@ __wt_page_release(WT_SESSION_IMPL *session, WT_REF *ref, uint32_t flags) LF_ISSET(WT_READ_NO_EVICT) || F_ISSET(session, WT_SESSION_NO_EVICTION) || F_ISSET(btree, WT_BTREE_NO_EVICTION) || - !__wt_page_can_evict(session, page, 1, NULL)) + !__wt_page_can_evict(session, page, true, NULL)) return (__wt_hazard_clear(session, page)); WT_RET_BUSY_OK(__wt_page_release_evict(session, ref)); @@ -1215,7 +1227,7 @@ __wt_page_swap_func(WT_SESSION_IMPL *session, WT_REF *held, ) { WT_DECL_RET; - int acquired; + bool acquired; /* * In rare cases when walking the tree, we try to swap to the same diff --git a/src/third_party/wiredtiger/src/include/cache.i b/src/third_party/wiredtiger/src/include/cache.i index bc33f82d927..475f4a86654 100644 --- a/src/third_party/wiredtiger/src/include/cache.i +++ b/src/third_party/wiredtiger/src/include/cache.i @@ -134,11 +134,11 @@ __wt_session_can_wait(WT_SESSION_IMPL *session) * __wt_eviction_aggressive -- * Return if the eviction server is running in aggressive mode. */ -static inline int +static inline bool __wt_eviction_aggressive(WT_SESSION_IMPL *session) { return (FLD_ISSET( - S2C(session)->cache->state, WT_EVICT_PASS_AGGRESSIVE) ? 1 : 0); + S2C(session)->cache->state, WT_EVICT_PASS_AGGRESSIVE)); } /* @@ -146,11 +146,10 @@ __wt_eviction_aggressive(WT_SESSION_IMPL *session) * Return if the eviction server is running to reduce the number of dirty * pages (versus running to discard pages from the cache). */ -static inline int +static inline bool __wt_eviction_dirty_target(WT_SESSION_IMPL *session) { - return (FLD_ISSET( - S2C(session)->cache->state, WT_EVICT_PASS_DIRTY) ? 1 : 0); + return (FLD_ISSET(S2C(session)->cache->state, WT_EVICT_PASS_DIRTY)); } /* @@ -198,13 +197,13 @@ __wt_eviction_needed(WT_SESSION_IMPL *session, u_int *pct_fullp) * Evict pages if the cache crosses its boundaries. */ static inline int -__wt_cache_eviction_check(WT_SESSION_IMPL *session, int busy, int *didworkp) +__wt_cache_eviction_check(WT_SESSION_IMPL *session, bool busy, bool *didworkp) { WT_BTREE *btree; u_int pct_full; if (didworkp != NULL) - *didworkp = 0; + *didworkp = false; /* * LSM sets the no-cache-check flag when holding the LSM tree lock, in @@ -232,7 +231,7 @@ __wt_cache_eviction_check(WT_SESSION_IMPL *session, int busy, int *didworkp) * was no cache work to do. After this point, let them skip the sleep. */ if (didworkp != NULL) - *didworkp = 1; + *didworkp = true; return (__wt_cache_eviction_worker(session, busy, pct_full)); } diff --git a/src/third_party/wiredtiger/src/include/cell.i b/src/third_party/wiredtiger/src/include/cell.i index a517ac4a523..1410b30bb82 100644 --- a/src/third_party/wiredtiger/src/include/cell.i +++ b/src/third_party/wiredtiger/src/include/cell.i @@ -230,11 +230,12 @@ __wt_cell_pack_data(WT_CELL *cell, uint64_t rle, size_t size) */ static inline int __wt_cell_pack_data_match( - WT_CELL *page_cell, WT_CELL *val_cell, const uint8_t *val_data, int *matchp) + WT_CELL *page_cell, WT_CELL *val_cell, const uint8_t *val_data, + bool *matchp) { const uint8_t *a, *b; uint64_t av, bv; - int rle; + bool rle; *matchp = 0; /* Default to no-match */ @@ -252,7 +253,7 @@ __wt_cell_pack_data_match( av = a[0] >> WT_CELL_SHORT_SHIFT; ++a; } else if (WT_CELL_TYPE(a[0]) == WT_CELL_VALUE) { - rle = a[0] & WT_CELL_64V ? 1 : 0; /* Skip any RLE */ + rle = (a[0] & WT_CELL_64V) != 0; /* Skip any RLE */ ++a; if (rle) WT_RET(__wt_vunpack_uint(&a, 0, &av)); @@ -264,7 +265,7 @@ __wt_cell_pack_data_match( bv = b[0] >> WT_CELL_SHORT_SHIFT; ++b; } else if (WT_CELL_TYPE(b[0]) == WT_CELL_VALUE) { - rle = b[0] & WT_CELL_64V ? 1 : 0; /* Skip any RLE */ + rle = (b[0] & WT_CELL_64V) != 0; /* Skip any RLE */ ++b; if (rle) WT_RET(__wt_vunpack_uint(&b, 0, &bv)); @@ -273,7 +274,7 @@ __wt_cell_pack_data_match( return (0); if (av == bv) - *matchp = memcmp(a, val_data, av) == 0 ? 1 : 0; + *matchp = memcmp(a, val_data, av) == 0; return (0); } diff --git a/src/third_party/wiredtiger/src/include/cursor.h b/src/third_party/wiredtiger/src/include/cursor.h index 2f55dfc8186..4c132cbbf9c 100644 --- a/src/third_party/wiredtiger/src/include/cursor.h +++ b/src/third_party/wiredtiger/src/include/cursor.h @@ -370,11 +370,11 @@ struct __wt_cursor_table { */ #define WT_CURSOR_CHECKKEY(cursor) do { \ if (!F_ISSET(cursor, WT_CURSTD_KEY_SET)) \ - WT_ERR(__wt_cursor_kv_not_set(cursor, 1)); \ + WT_ERR(__wt_cursor_kv_not_set(cursor, true)); \ } while (0) #define WT_CURSOR_CHECKVALUE(cursor) do { \ if (!F_ISSET(cursor, WT_CURSTD_VALUE_SET)) \ - WT_ERR(__wt_cursor_kv_not_set(cursor, 0)); \ + WT_ERR(__wt_cursor_kv_not_set(cursor, false)); \ } while (0) #define WT_CURSOR_NEEDKEY(cursor) do { \ if (F_ISSET(cursor, WT_CURSTD_KEY_INT)) { \ diff --git a/src/third_party/wiredtiger/src/include/cursor.i b/src/third_party/wiredtiger/src/include/cursor.i index e7fed250251..c6ce04cab6f 100644 --- a/src/third_party/wiredtiger/src/include/cursor.i +++ b/src/third_party/wiredtiger/src/include/cursor.i @@ -60,7 +60,7 @@ __cursor_enter(WT_SESSION_IMPL *session) * whether the cache is full. */ if (session->ncursors == 0) - WT_RET(__wt_cache_eviction_check(session, 0, NULL)); + WT_RET(__wt_cache_eviction_check(session, false, NULL)); ++session->ncursors; return (0); } @@ -178,7 +178,7 @@ __wt_cursor_dhandle_decr_use(WT_SESSION_IMPL *session) * Cursor call setup. */ static inline int -__cursor_func_init(WT_CURSOR_BTREE *cbt, int reenter) +__cursor_func_init(WT_CURSOR_BTREE *cbt, bool reenter) { WT_SESSION_IMPL *session; @@ -296,7 +296,7 @@ __cursor_row_slot_return(WT_CURSOR_BTREE *cbt, WT_ROW *rip, WT_UPDATE *upd) * already did __wt_row_leaf_key's fast-path checks inline. */ slow: WT_RET(__wt_row_leaf_key_work( - session, page, rip, cbt->row_key, 0)); + session, page, rip, cbt->row_key, false)); } kb->data = cbt->row_key->data; kb->size = cbt->row_key->size; diff --git a/src/third_party/wiredtiger/src/include/dhandle.h b/src/third_party/wiredtiger/src/include/dhandle.h index 75e3c9b4607..9a54b4ddb66 100644 --- a/src/third_party/wiredtiger/src/include/dhandle.h +++ b/src/third_party/wiredtiger/src/include/dhandle.h @@ -49,7 +49,9 @@ struct __wt_data_handle { */ uint32_t session_ref; /* Sessions referencing this handle */ int32_t session_inuse; /* Sessions using this handle */ + uint32_t excl_ref; /* Refs of handle by excl_session */ time_t timeofdeath; /* Use count went to 0 */ + WT_SESSION_IMPL *excl_session; /* Session with exclusive use, if any */ uint64_t name_hash; /* Hash of name */ const char *name; /* Object name as a URI */ diff --git a/src/third_party/wiredtiger/src/include/extern.h b/src/third_party/wiredtiger/src/include/extern.h index 609dc1b7894..cfc1dc8f26e 100644 --- a/src/third_party/wiredtiger/src/include/extern.h +++ b/src/third_party/wiredtiger/src/include/extern.h @@ -11,21 +11,21 @@ extern int __wt_async_op_init(WT_SESSION_IMPL *session); extern WT_THREAD_RET __wt_async_worker(void *arg); extern int __wt_block_addr_to_buffer(WT_BLOCK *block, uint8_t **pp, wt_off_t offset, uint32_t size, uint32_t cksum); extern int __wt_block_buffer_to_addr(WT_BLOCK *block, const uint8_t *p, wt_off_t *offsetp, uint32_t *sizep, uint32_t *cksump); -extern int __wt_block_addr_invalid(WT_SESSION_IMPL *session, WT_BLOCK *block, const uint8_t *addr, size_t addr_size, int live); +extern int __wt_block_addr_invalid(WT_SESSION_IMPL *session, WT_BLOCK *block, const uint8_t *addr, size_t addr_size, bool live); extern int __wt_block_addr_string(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_ITEM *buf, const uint8_t *addr, size_t addr_size); extern int __wt_block_buffer_to_ckpt(WT_SESSION_IMPL *session, WT_BLOCK *block, const uint8_t *p, WT_BLOCK_CKPT *ci); extern int __wt_block_ckpt_to_buffer(WT_SESSION_IMPL *session, WT_BLOCK *block, uint8_t **pp, WT_BLOCK_CKPT *ci); extern int __wt_block_ckpt_init( WT_SESSION_IMPL *session, WT_BLOCK_CKPT *ci, const char *name); -extern int __wt_block_checkpoint_load(WT_SESSION_IMPL *session, WT_BLOCK *block, const uint8_t *addr, size_t addr_size, uint8_t *root_addr, size_t *root_addr_sizep, int checkpoint); -extern int __wt_block_checkpoint_unload( WT_SESSION_IMPL *session, WT_BLOCK *block, int checkpoint); +extern int __wt_block_checkpoint_load(WT_SESSION_IMPL *session, WT_BLOCK *block, const uint8_t *addr, size_t addr_size, uint8_t *root_addr, size_t *root_addr_sizep, bool checkpoint); +extern int __wt_block_checkpoint_unload( WT_SESSION_IMPL *session, WT_BLOCK *block, bool checkpoint); extern void __wt_block_ckpt_destroy(WT_SESSION_IMPL *session, WT_BLOCK_CKPT *ci); -extern int __wt_block_checkpoint(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_ITEM *buf, WT_CKPT *ckptbase, int data_cksum); +extern int __wt_block_checkpoint(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_ITEM *buf, WT_CKPT *ckptbase, bool data_cksum); extern int __wt_block_checkpoint_resolve(WT_SESSION_IMPL *session, WT_BLOCK *block); extern int __wt_block_compact_start(WT_SESSION_IMPL *session, WT_BLOCK *block); extern int __wt_block_compact_end(WT_SESSION_IMPL *session, WT_BLOCK *block); -extern int __wt_block_compact_skip(WT_SESSION_IMPL *session, WT_BLOCK *block, int *skipp); -extern int __wt_block_compact_page_skip(WT_SESSION_IMPL *session, WT_BLOCK *block, const uint8_t *addr, size_t addr_size, int *skipp); -extern int __wt_block_misplaced(WT_SESSION_IMPL *session, WT_BLOCK *block, const char *tag, wt_off_t offset, uint32_t size, int live); +extern int __wt_block_compact_skip(WT_SESSION_IMPL *session, WT_BLOCK *block, bool *skipp); +extern int __wt_block_compact_page_skip(WT_SESSION_IMPL *session, WT_BLOCK *block, const uint8_t *addr, size_t addr_size, bool *skipp); +extern int __wt_block_misplaced(WT_SESSION_IMPL *session, WT_BLOCK *block, const char *tag, wt_off_t offset, uint32_t size, bool live); extern int __wt_block_off_remove_overlap(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_EXTLIST *el, wt_off_t off, wt_off_t size); extern int __wt_block_alloc( WT_SESSION_IMPL *session, WT_BLOCK *block, wt_off_t *offp, wt_off_t size); extern int __wt_block_free(WT_SESSION_IMPL *session, WT_BLOCK *block, const uint8_t *addr, size_t addr_size); @@ -38,15 +38,15 @@ extern int __wt_block_extlist_read_avail(WT_SESSION_IMPL *session, WT_BLOCK *blo extern int __wt_block_extlist_read(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_EXTLIST *el, wt_off_t ckpt_size); extern int __wt_block_extlist_write(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_EXTLIST *el, WT_EXTLIST *additional); extern int __wt_block_extlist_truncate( WT_SESSION_IMPL *session, WT_BLOCK *block, WT_EXTLIST *el); -extern int __wt_block_extlist_init(WT_SESSION_IMPL *session, WT_EXTLIST *el, const char *name, const char *extname, int track_size); +extern int __wt_block_extlist_init(WT_SESSION_IMPL *session, WT_EXTLIST *el, const char *name, const char *extname, bool track_size); extern void __wt_block_extlist_free(WT_SESSION_IMPL *session, WT_EXTLIST *el); extern int __wt_block_map( WT_SESSION_IMPL *session, WT_BLOCK *block, void *mapp, size_t *maplenp, void **mappingcookie); extern int __wt_block_unmap( WT_SESSION_IMPL *session, WT_BLOCK *block, void *map, size_t maplen, void **mappingcookie); -extern int __wt_block_manager_open(WT_SESSION_IMPL *session, const char *filename, const char *cfg[], int forced_salvage, int readonly, uint32_t allocsize, WT_BM **bmp); +extern int __wt_block_manager_open(WT_SESSION_IMPL *session, const char *filename, const char *cfg[], bool forced_salvage, bool readonly, uint32_t allocsize, WT_BM **bmp); extern int __wt_block_manager_truncate( WT_SESSION_IMPL *session, const char *filename, uint32_t allocsize); extern int __wt_block_manager_create( WT_SESSION_IMPL *session, const char *filename, uint32_t allocsize); -extern void __wt_block_configure_first_fit(WT_BLOCK *block, int on); -extern int __wt_block_open(WT_SESSION_IMPL *session, const char *filename, const char *cfg[], int forced_salvage, int readonly, uint32_t allocsize, WT_BLOCK **blockp); +extern void __wt_block_configure_first_fit(WT_BLOCK *block, bool on); +extern int __wt_block_open(WT_SESSION_IMPL *session, const char *filename, const char *cfg[], bool forced_salvage, bool readonly, uint32_t allocsize, WT_BLOCK **blockp); extern int __wt_block_close(WT_SESSION_IMPL *session, WT_BLOCK *block); extern int __wt_desc_init(WT_SESSION_IMPL *session, WT_FH *fh, uint32_t allocsize); extern void __wt_block_stat(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_DSRC_STATS *stats); @@ -64,8 +64,8 @@ extern int __wt_block_ext_discard(WT_SESSION_IMPL *session, u_int max); extern int __wt_block_salvage_start(WT_SESSION_IMPL *session, WT_BLOCK *block); extern int __wt_block_salvage_end(WT_SESSION_IMPL *session, WT_BLOCK *block); extern bool __wt_block_offset_invalid(WT_BLOCK *block, wt_off_t offset, uint32_t size); -extern int __wt_block_salvage_next(WT_SESSION_IMPL *session, WT_BLOCK *block, uint8_t *addr, size_t *addr_sizep, int *eofp); -extern int __wt_block_salvage_valid(WT_SESSION_IMPL *session, WT_BLOCK *block, uint8_t *addr, size_t addr_size, int valid); +extern int __wt_block_salvage_next(WT_SESSION_IMPL *session, WT_BLOCK *block, uint8_t *addr, size_t *addr_sizep, bool *eofp); +extern int __wt_block_salvage_valid(WT_SESSION_IMPL *session, WT_BLOCK *block, uint8_t *addr, size_t addr_size, bool valid); extern int __wt_block_verify_start(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_CKPT *ckptbase, const char *cfg[]); extern int __wt_block_verify_end(WT_SESSION_IMPL *session, WT_BLOCK *block); extern int __wt_verify_ckpt_load( WT_SESSION_IMPL *session, WT_BLOCK *block, WT_BLOCK_CKPT *ci); @@ -74,8 +74,8 @@ extern int __wt_block_verify_addr(WT_SESSION_IMPL *session, WT_BLOCK *block, con extern u_int __wt_block_header(WT_BLOCK *block); extern int __wt_block_truncate(WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t len); extern int __wt_block_write_size(WT_SESSION_IMPL *session, WT_BLOCK *block, size_t *sizep); -extern int __wt_block_write(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_ITEM *buf, uint8_t *addr, size_t *addr_sizep, int data_cksum); -extern int __wt_block_write_off(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_ITEM *buf, wt_off_t *offsetp, uint32_t *sizep, uint32_t *cksump, int data_cksum, int caller_locked); +extern int __wt_block_write(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_ITEM *buf, uint8_t *addr, size_t *addr_sizep, bool data_cksum); +extern int __wt_block_write_off(WT_SESSION_IMPL *session, WT_BLOCK *block, WT_ITEM *buf, wt_off_t *offsetp, uint32_t *sizep, uint32_t *cksump, bool data_cksum, bool caller_locked); extern int __wt_bloom_create( WT_SESSION_IMPL *session, const char *uri, const char *config, uint64_t count, uint32_t factor, uint32_t k, WT_BLOOM **bloomp); extern int __wt_bloom_open(WT_SESSION_IMPL *session, const char *uri, uint32_t factor, uint32_t k, WT_CURSOR *owner, WT_BLOOM **bloomp); extern int __wt_bloom_insert(WT_BLOOM *bloom, WT_ITEM *key); @@ -86,10 +86,10 @@ extern int __wt_bloom_get(WT_BLOOM *bloom, WT_ITEM *key); extern int __wt_bloom_close(WT_BLOOM *bloom); extern int __wt_bloom_drop(WT_BLOOM *bloom, const char *config); extern int __wt_compact(WT_SESSION_IMPL *session, const char *cfg[]); -extern int __wt_compact_page_skip(WT_SESSION_IMPL *session, WT_REF *ref, int *skipp); -extern void __wt_btcur_iterate_setup(WT_CURSOR_BTREE *cbt, int next); -extern int __wt_btcur_next(WT_CURSOR_BTREE *cbt, int truncating); -extern int __wt_btcur_prev(WT_CURSOR_BTREE *cbt, int truncating); +extern int __wt_compact_page_skip(WT_SESSION_IMPL *session, WT_REF *ref, bool *skipp); +extern void __wt_btcur_iterate_setup(WT_CURSOR_BTREE *cbt); +extern int __wt_btcur_next(WT_CURSOR_BTREE *cbt, bool truncating); +extern int __wt_btcur_prev(WT_CURSOR_BTREE *cbt, bool truncating); extern int __wt_btcur_reset(WT_CURSOR_BTREE *cbt); extern int __wt_btcur_search(WT_CURSOR_BTREE *cbt); extern int __wt_btcur_search_near(WT_CURSOR_BTREE *cbt, int *exactp); @@ -99,11 +99,11 @@ extern int __wt_btcur_remove(WT_CURSOR_BTREE *cbt); extern int __wt_btcur_update(WT_CURSOR_BTREE *cbt); extern int __wt_btcur_next_random(WT_CURSOR_BTREE *cbt); extern int __wt_btcur_compare(WT_CURSOR_BTREE *a_arg, WT_CURSOR_BTREE *b_arg, int *cmpp); -extern int __wt_btcur_equals( WT_CURSOR_BTREE *a_arg, WT_CURSOR_BTREE *b_arg, int *equalp); +extern int __wt_btcur_equals(WT_CURSOR_BTREE *a_arg, WT_CURSOR_BTREE *b_arg, int *equalp); extern int __wt_btcur_range_truncate(WT_CURSOR_BTREE *start, WT_CURSOR_BTREE *stop); extern void __wt_btcur_init(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt); extern void __wt_btcur_open(WT_CURSOR_BTREE *cbt); -extern int __wt_btcur_close(WT_CURSOR_BTREE *cbt, int lowlevel); +extern int __wt_btcur_close(WT_CURSOR_BTREE *cbt, bool lowlevel); extern int __wt_debug_set_verbose(WT_SESSION_IMPL *session, const char *v); extern int __wt_debug_addr_print( WT_SESSION_IMPL *session, const uint8_t *addr, size_t addr_size); extern int __wt_debug_addr(WT_SESSION_IMPL *session, const uint8_t *addr, size_t addr_size, const char *ofile); @@ -114,25 +114,25 @@ extern int __wt_debug_tree_shape( WT_SESSION_IMPL *session, WT_PAGE *page, const extern int __wt_debug_tree_all(WT_SESSION_IMPL *session, WT_PAGE *page, const char *ofile); extern int __wt_debug_tree(WT_SESSION_IMPL *session, WT_PAGE *page, const char *ofile); extern int __wt_debug_page(WT_SESSION_IMPL *session, WT_PAGE *page, const char *ofile); -extern int __wt_delete_page(WT_SESSION_IMPL *session, WT_REF *ref, int *skipp); +extern int __wt_delete_page(WT_SESSION_IMPL *session, WT_REF *ref, bool *skipp); extern void __wt_delete_page_rollback(WT_SESSION_IMPL *session, WT_REF *ref); extern bool __wt_delete_page_skip(WT_SESSION_IMPL *session, WT_REF *ref); extern int __wt_delete_page_instantiate(WT_SESSION_IMPL *session, WT_REF *ref); extern void __wt_ref_out(WT_SESSION_IMPL *session, WT_REF *ref); extern void __wt_page_out(WT_SESSION_IMPL *session, WT_PAGE **pagep); -extern void __wt_free_ref( WT_SESSION_IMPL *session, WT_PAGE *page, WT_REF *ref, int free_pages); -extern void __wt_free_ref_index(WT_SESSION_IMPL *session, WT_PAGE *page, WT_PAGE_INDEX *pindex, int free_pages); +extern void __wt_free_ref( WT_SESSION_IMPL *session, WT_PAGE *page, WT_REF *ref, bool free_pages); +extern void __wt_free_ref_index(WT_SESSION_IMPL *session, WT_PAGE *page, WT_PAGE_INDEX *pindex, bool free_pages); extern void __wt_free_update_list(WT_SESSION_IMPL *session, WT_UPDATE *upd); extern int __wt_btree_open(WT_SESSION_IMPL *session, const char *op_cfg[]); extern int __wt_btree_close(WT_SESSION_IMPL *session); -extern void __wt_root_ref_init(WT_REF *root_ref, WT_PAGE *root, int is_recno); +extern void __wt_root_ref_init(WT_REF *root_ref, WT_PAGE *root, bool is_recno); extern int __wt_btree_tree_open( WT_SESSION_IMPL *session, const uint8_t *addr, size_t addr_size); extern int __wt_btree_new_leaf_page(WT_SESSION_IMPL *session, WT_PAGE **pagep); -extern void __wt_btree_evictable(WT_SESSION_IMPL *session, int on); +extern void __wt_btree_evictable(WT_SESSION_IMPL *session, bool on); extern int __wt_btree_huffman_open(WT_SESSION_IMPL *session); extern void __wt_btree_huffman_close(WT_SESSION_IMPL *session); extern int __wt_bt_read(WT_SESSION_IMPL *session, WT_ITEM *buf, const uint8_t *addr, size_t addr_size); -extern int __wt_bt_write(WT_SESSION_IMPL *session, WT_ITEM *buf, uint8_t *addr, size_t *addr_sizep, int checkpoint, int compressed); +extern int __wt_bt_write(WT_SESSION_IMPL *session, WT_ITEM *buf, uint8_t *addr, size_t *addr_sizep, bool checkpoint, bool compressed); extern const char *__wt_page_type_string(u_int type); extern const char *__wt_cell_type_string(uint8_t type); extern const char *__wt_page_addr_string(WT_SESSION_IMPL *session, WT_REF *ref, WT_ITEM *buf); @@ -140,7 +140,7 @@ extern const char *__wt_addr_string(WT_SESSION_IMPL *session, const uint8_t *add extern int __wt_ovfl_read(WT_SESSION_IMPL *session, WT_PAGE *page, WT_CELL_UNPACK *unpack, WT_ITEM *store); extern int __wt_ovfl_cache(WT_SESSION_IMPL *session, WT_PAGE *page, void *cookie, WT_CELL_UNPACK *vpack); extern int __wt_ovfl_discard(WT_SESSION_IMPL *session, WT_CELL *cell); -extern int __wt_page_alloc(WT_SESSION_IMPL *session, uint8_t type, uint64_t recno, uint32_t alloc_entries, int alloc_refs, WT_PAGE **pagep); +extern int __wt_page_alloc(WT_SESSION_IMPL *session, uint8_t type, uint64_t recno, uint32_t alloc_entries, bool alloc_refs, WT_PAGE **pagep); extern int __wt_page_inmem(WT_SESSION_IMPL *session, WT_REF *ref, const void *image, size_t memsize, uint32_t flags, WT_PAGE **pagep); extern int __wt_las_remove_block(WT_SESSION_IMPL *session, WT_CURSOR *cursor, uint32_t btree_id, const uint8_t *addr, size_t addr_size); extern int @@ -161,25 +161,25 @@ extern int __wt_btree_stat_init(WT_SESSION_IMPL *session, WT_CURSOR_STAT *cst); extern int __wt_cache_op(WT_SESSION_IMPL *session, WT_CKPT *ckptbase, int op); extern int __wt_upgrade(WT_SESSION_IMPL *session, const char *cfg[]); extern int __wt_verify(WT_SESSION_IMPL *session, const char *cfg[]); -extern int __wt_verify_dsk_image(WT_SESSION_IMPL *session, const char *tag, const WT_PAGE_HEADER *dsk, size_t size, int empty_page_ok); +extern int __wt_verify_dsk_image(WT_SESSION_IMPL *session, const char *tag, const WT_PAGE_HEADER *dsk, size_t size, bool empty_page_ok); extern int __wt_verify_dsk(WT_SESSION_IMPL *session, const char *tag, WT_ITEM *buf); extern int __wt_tree_walk(WT_SESSION_IMPL *session, WT_REF **refp, uint64_t *walkcntp, uint32_t flags); -extern int __wt_col_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, uint64_t recno, WT_ITEM *value, WT_UPDATE *upd_arg, int is_remove); +extern int __wt_col_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, uint64_t recno, WT_ITEM *value, WT_UPDATE *upd_arg, bool is_remove); extern int __wt_col_search(WT_SESSION_IMPL *session, uint64_t recno, WT_REF *leaf, WT_CURSOR_BTREE *cbt); extern int __wt_row_leaf_keys(WT_SESSION_IMPL *session, WT_PAGE *page); extern int __wt_row_leaf_key_copy( WT_SESSION_IMPL *session, WT_PAGE *page, WT_ROW *rip, WT_ITEM *key); -extern int __wt_row_leaf_key_work(WT_SESSION_IMPL *session, WT_PAGE *page, WT_ROW *rip_arg, WT_ITEM *keyb, int instantiate); +extern int __wt_row_leaf_key_work(WT_SESSION_IMPL *session, WT_PAGE *page, WT_ROW *rip_arg, WT_ITEM *keyb, bool instantiate); extern int __wt_row_ikey_alloc(WT_SESSION_IMPL *session, uint32_t cell_offset, const void *key, size_t size, WT_IKEY **ikeyp); extern int __wt_row_ikey_incr(WT_SESSION_IMPL *session, WT_PAGE *page, uint32_t cell_offset, const void *key, size_t size, WT_REF *ref); extern int __wt_row_ikey(WT_SESSION_IMPL *session, uint32_t cell_offset, const void *key, size_t size, WT_REF *ref); extern int __wt_page_modify_alloc(WT_SESSION_IMPL *session, WT_PAGE *page); -extern int __wt_row_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, WT_ITEM *key, WT_ITEM *value, WT_UPDATE *upd_arg, int is_remove); +extern int __wt_row_modify(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, WT_ITEM *key, WT_ITEM *value, WT_UPDATE *upd_arg, bool is_remove); extern int __wt_row_insert_alloc(WT_SESSION_IMPL *session, WT_ITEM *key, u_int skipdepth, WT_INSERT **insp, size_t *ins_sizep); extern int __wt_update_alloc( WT_SESSION_IMPL *session, WT_ITEM *value, WT_UPDATE **updp, size_t *sizep); extern WT_UPDATE *__wt_update_obsolete_check( WT_SESSION_IMPL *session, WT_PAGE *page, WT_UPDATE *upd); extern void __wt_update_obsolete_free( WT_SESSION_IMPL *session, WT_PAGE *page, WT_UPDATE *upd); extern int __wt_search_insert( WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, WT_ITEM *srch_key); -extern int __wt_row_search(WT_SESSION_IMPL *session, WT_ITEM *srch_key, WT_REF *leaf, WT_CURSOR_BTREE *cbt, int insert); +extern int __wt_row_search(WT_SESSION_IMPL *session, WT_ITEM *srch_key, WT_REF *leaf, WT_CURSOR_BTREE *cbt, bool insert); extern int __wt_row_random(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt); extern void __wt_las_stats_update(WT_SESSION_IMPL *session); extern int __wt_las_create(WT_SESSION_IMPL *session); @@ -224,7 +224,7 @@ extern int __wt_conn_remove_encryptor(WT_SESSION_IMPL *session); extern int __wt_extractor_config(WT_SESSION_IMPL *session, const char *uri, const char *config, WT_EXTRACTOR **extractorp, int *ownp); extern int __wt_conn_remove_extractor(WT_SESSION_IMPL *session); extern int __wt_verbose_config(WT_SESSION_IMPL *session, const char *cfg[]); -extern int __wt_cache_config(WT_SESSION_IMPL *session, int reconfigure, const char *cfg[]); +extern int __wt_cache_config(WT_SESSION_IMPL *session, bool reconfigure, const char *cfg[]); extern int __wt_cache_create(WT_SESSION_IMPL *session, const char *cfg[]); extern void __wt_cache_stats_update(WT_SESSION_IMPL *session); extern int __wt_cache_destroy(WT_SESSION_IMPL *session); @@ -236,13 +236,13 @@ extern int __wt_checkpoint_server_create(WT_SESSION_IMPL *session, const char *c extern int __wt_checkpoint_server_destroy(WT_SESSION_IMPL *session); extern int __wt_checkpoint_signal(WT_SESSION_IMPL *session, wt_off_t logsize); extern int __wt_conn_dhandle_find( WT_SESSION_IMPL *session, const char *uri, const char *checkpoint); -extern int __wt_conn_btree_sync_and_close(WT_SESSION_IMPL *session, int final, int force); +extern int __wt_conn_btree_sync_and_close(WT_SESSION_IMPL *session, bool final, bool force); extern int __wt_conn_btree_open( WT_SESSION_IMPL *session, const char *cfg[], uint32_t flags); -extern int __wt_conn_btree_apply(WT_SESSION_IMPL *session, int apply_checkpoints, const char *uri, int (*func)(WT_SESSION_IMPL *, const char *[]), const char *cfg[]); +extern int __wt_conn_btree_apply(WT_SESSION_IMPL *session, bool apply_checkpoints, const char *uri, int (*func)(WT_SESSION_IMPL *, const char *[]), const char *cfg[]); extern int __wt_conn_btree_apply_single_ckpt(WT_SESSION_IMPL *session, const char *uri, int (*func)(WT_SESSION_IMPL *, const char *[]), const char *cfg[]); extern int __wt_conn_btree_apply_single(WT_SESSION_IMPL *session, const char *uri, const char *checkpoint, int (*func)(WT_SESSION_IMPL *, const char *[]), const char *cfg[]); -extern int __wt_conn_dhandle_close_all( WT_SESSION_IMPL *session, const char *uri, int force); -extern int __wt_conn_dhandle_discard_single(WT_SESSION_IMPL *session, int final, int force); +extern int __wt_conn_dhandle_close_all( WT_SESSION_IMPL *session, const char *uri, bool force); +extern int __wt_conn_dhandle_discard_single( WT_SESSION_IMPL *session, bool final, bool force); extern int __wt_conn_dhandle_discard(WT_SESSION_IMPL *session); extern int __wt_connection_init(WT_CONNECTION_IMPL *conn); extern int __wt_connection_destroy(WT_CONNECTION_IMPL *conn); @@ -257,28 +257,28 @@ extern int __wt_connection_workers(WT_SESSION_IMPL *session, const char *cfg[]); extern void __wt_conn_stat_init(WT_SESSION_IMPL *session); extern int __wt_statlog_log_one(WT_SESSION_IMPL *session); extern int __wt_statlog_create(WT_SESSION_IMPL *session, const char *cfg[]); -extern int __wt_statlog_destroy(WT_SESSION_IMPL *session, int is_close); +extern int __wt_statlog_destroy(WT_SESSION_IMPL *session, bool is_close); extern int __wt_sweep_config(WT_SESSION_IMPL *session, const char *cfg[]); extern int __wt_sweep_create(WT_SESSION_IMPL *session); extern int __wt_sweep_destroy(WT_SESSION_IMPL *session); extern int __wt_curbackup_open(WT_SESSION_IMPL *session, const char *uri, const char *cfg[], WT_CURSOR **cursorp); extern int __wt_backup_file_remove(WT_SESSION_IMPL *session); -extern int __wt_backup_list_uri_append( WT_SESSION_IMPL *session, const char *name, int *skip); -extern int __wt_curbulk_init(WT_SESSION_IMPL *session, WT_CURSOR_BULK *cbulk, int bitmap, int skip_sort_check); +extern int __wt_backup_list_uri_append( WT_SESSION_IMPL *session, const char *name, bool *skip); +extern int __wt_curbulk_init(WT_SESSION_IMPL *session, WT_CURSOR_BULK *cbulk, bool bitmap, bool skip_sort_check); extern int __wt_curconfig_open(WT_SESSION_IMPL *session, const char *uri, const char *cfg[], WT_CURSOR **cursorp); extern int __wt_curds_open( WT_SESSION_IMPL *session, const char *uri, WT_CURSOR *owner, const char *cfg[], WT_DATA_SOURCE *dsrc, WT_CURSOR **cursorp); extern int __wt_curdump_create(WT_CURSOR *child, WT_CURSOR *owner, WT_CURSOR **cursorp); extern int __wt_curfile_update_check(WT_CURSOR *cursor); -extern int __wt_curfile_create(WT_SESSION_IMPL *session, WT_CURSOR *owner, const char *cfg[], int bulk, int bitmap, WT_CURSOR **cursorp); +extern int __wt_curfile_create(WT_SESSION_IMPL *session, WT_CURSOR *owner, const char *cfg[], bool bulk, bool bitmap, WT_CURSOR **cursorp); extern int __wt_curfile_open(WT_SESSION_IMPL *session, const char *uri, WT_CURSOR *owner, const char *cfg[], WT_CURSOR **cursorp); extern int __wt_curindex_open(WT_SESSION_IMPL *session, const char *uri, WT_CURSOR *owner, const char *cfg[], WT_CURSOR **cursorp); -extern int __wt_json_alloc_unpack(WT_SESSION_IMPL *session, const void *buffer, size_t size, const char *fmt, WT_CURSOR_JSON *json, int iskey, va_list ap); +extern int __wt_json_alloc_unpack(WT_SESSION_IMPL *session, const void *buffer, size_t size, const char *fmt, WT_CURSOR_JSON *json, bool iskey, va_list ap); extern void __wt_json_close(WT_SESSION_IMPL *session, WT_CURSOR *cursor); -extern size_t __wt_json_unpack_char(char ch, u_char *buf, size_t bufsz, int force_unicode); +extern size_t __wt_json_unpack_char(char ch, u_char *buf, size_t bufsz, bool force_unicode); extern int __wt_json_column_init(WT_CURSOR *cursor, const char *keyformat, const WT_CONFIG_ITEM *idxconf, const WT_CONFIG_ITEM *colconf); extern int __wt_json_token(WT_SESSION *wt_session, const char *src, int *toktype, const char **tokstart, size_t *toklen); extern const char *__wt_json_tokname(int toktype); -extern int __wt_json_to_item(WT_SESSION_IMPL *session, const char *jstr, const char *format, WT_CURSOR_JSON *json, int iskey, WT_ITEM *item); +extern int __wt_json_to_item(WT_SESSION_IMPL *session, const char *jstr, const char *format, WT_CURSOR_JSON *json, bool iskey, WT_ITEM *item); extern ssize_t __wt_json_strlen(const char *src, size_t srclen); extern int __wt_json_strncpy(char **pdst, size_t dstlen, const char *src, size_t srclen); extern int __wt_curlog_open(WT_SESSION_IMPL *session, const char *uri, const char *cfg[], WT_CURSOR **cursorp); @@ -289,7 +289,7 @@ extern int __wt_curstat_open(WT_SESSION_IMPL *session, const char *uri, const ch extern int __wt_cursor_notsup(WT_CURSOR *cursor); extern int __wt_cursor_noop(WT_CURSOR *cursor); extern void __wt_cursor_set_notsup(WT_CURSOR *cursor); -extern int __wt_cursor_kv_not_set(WT_CURSOR *cursor, int key); +extern int __wt_cursor_kv_not_set(WT_CURSOR *cursor, bool key); extern int __wt_cursor_get_key(WT_CURSOR *cursor, ...); extern void __wt_cursor_set_key(WT_CURSOR *cursor, ...); extern int __wt_cursor_get_raw_key(WT_CURSOR *cursor, WT_ITEM *key); @@ -307,6 +307,7 @@ extern int __wt_cursor_equals(WT_CURSOR *cursor, WT_CURSOR *other, int *equalp); extern int __wt_cursor_reconfigure(WT_CURSOR *cursor, const char *config); extern int __wt_cursor_dup_position(WT_CURSOR *to_dup, WT_CURSOR *cursor); extern int __wt_cursor_init(WT_CURSOR *cursor, const char *uri, WT_CURSOR *owner, const char *cfg[], WT_CURSOR **cursorp); +extern int __wt_apply_single_idx(WT_SESSION_IMPL *session, WT_INDEX *idx, WT_CURSOR *cur, WT_CURSOR_TABLE *ctable, int (*f)(WT_CURSOR *)); extern int __wt_curtable_get_key(WT_CURSOR *cursor, ...); extern int __wt_curtable_get_value(WT_CURSOR *cursor, ...); extern void __wt_curtable_set_key(WT_CURSOR *cursor, ...); @@ -318,29 +319,29 @@ extern void __wt_evict_list_clear_page(WT_SESSION_IMPL *session, WT_REF *ref); extern int __wt_evict_server_wake(WT_SESSION_IMPL *session); extern int __wt_evict_create(WT_SESSION_IMPL *session); extern int __wt_evict_destroy(WT_SESSION_IMPL *session); -extern int __wt_evict_file_exclusive_on(WT_SESSION_IMPL *session, int *evict_resetp); +extern int __wt_evict_file_exclusive_on(WT_SESSION_IMPL *session, bool *evict_resetp); extern void __wt_evict_file_exclusive_off(WT_SESSION_IMPL *session); -extern int __wt_cache_eviction_worker(WT_SESSION_IMPL *session, int busy, u_int pct_full); +extern int __wt_cache_eviction_worker(WT_SESSION_IMPL *session, bool busy, u_int pct_full); extern int __wt_cache_dump(WT_SESSION_IMPL *session, const char *ofile); -extern int __wt_evict(WT_SESSION_IMPL *session, WT_REF *ref, int closing); -extern int __wt_evict_page_clean_update(WT_SESSION_IMPL *session, WT_REF *ref, int closing); +extern int __wt_evict(WT_SESSION_IMPL *session, WT_REF *ref, bool closing); +extern int __wt_evict_page_clean_update( WT_SESSION_IMPL *session, WT_REF *ref, bool closing); extern int __wt_log_ckpt(WT_SESSION_IMPL *session, WT_LSN *ckp_lsn); -extern int __wt_log_flush_lsn(WT_SESSION_IMPL *session, WT_LSN *lsn, int start); +extern int __wt_log_flush_lsn(WT_SESSION_IMPL *session, WT_LSN *lsn, bool start); extern int __wt_log_background(WT_SESSION_IMPL *session, WT_LSN *lsn); extern int __wt_log_force_sync(WT_SESSION_IMPL *session, WT_LSN *min_lsn); -extern int __wt_log_needs_recovery(WT_SESSION_IMPL *session, WT_LSN *ckp_lsn, int *rec); +extern int __wt_log_needs_recovery(WT_SESSION_IMPL *session, WT_LSN *ckp_lsn, bool *recp); extern void __wt_log_written_reset(WT_SESSION_IMPL *session); -extern int __wt_log_get_all_files(WT_SESSION_IMPL *session, char ***filesp, u_int *countp, uint32_t *maxid, int active_only); +extern int __wt_log_get_all_files(WT_SESSION_IMPL *session, char ***filesp, u_int *countp, uint32_t *maxid, bool active_only); extern void __wt_log_files_free(WT_SESSION_IMPL *session, char **files, u_int count); extern int __wt_log_extract_lognum( WT_SESSION_IMPL *session, const char *name, uint32_t *id); extern int __wt_log_acquire(WT_SESSION_IMPL *session, uint64_t recsize, WT_LOGSLOT *slot); -extern int __wt_log_allocfile( WT_SESSION_IMPL *session, uint32_t lognum, const char *dest, int prealloc); +extern int __wt_log_allocfile( WT_SESSION_IMPL *session, uint32_t lognum, const char *dest, bool prealloc); extern int __wt_log_remove(WT_SESSION_IMPL *session, const char *file_prefix, uint32_t lognum); extern int __wt_log_open(WT_SESSION_IMPL *session); extern int __wt_log_close(WT_SESSION_IMPL *session); -extern int __wt_log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot, int *freep); +extern int __wt_log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot, bool *freep); extern int __wt_log_scan(WT_SESSION_IMPL *session, WT_LSN *lsnp, uint32_t flags, int (*func)(WT_SESSION_IMPL *session, WT_ITEM *record, WT_LSN *lsnp, WT_LSN *next_lsnp, void *cookie, int firstrecord), void *cookie); -extern int __wt_log_force_write(WT_SESSION_IMPL *session, int retry); +extern int __wt_log_force_write(WT_SESSION_IMPL *session, bool retry); extern int __wt_log_write(WT_SESSION_IMPL *session, WT_ITEM *record, WT_LSN *lsnp, uint32_t flags); extern int __wt_log_vprintf(WT_SESSION_IMPL *session, const char *fmt, va_list ap); extern int __wt_log_flush(WT_SESSION_IMPL *session, uint32_t flags); @@ -368,8 +369,7 @@ extern int __wt_logop_row_truncate_unpack( WT_SESSION_IMPL *session, const uint8 extern int __wt_logop_row_truncate_print( WT_SESSION_IMPL *session, const uint8_t **pp, const uint8_t *end, FILE *out); extern int __wt_txn_op_printlog( WT_SESSION_IMPL *session, const uint8_t **pp, const uint8_t *end, FILE *out); extern void __wt_log_slot_activate(WT_SESSION_IMPL *session, WT_LOGSLOT *slot); -extern int __wt_log_slot_close( WT_SESSION_IMPL *session, WT_LOGSLOT *slot, int *releasep, int forced); -extern int __wt_log_slot_switch( WT_SESSION_IMPL *session, WT_MYSLOT *myslot, int retry, int forced); +extern int __wt_log_slot_switch( WT_SESSION_IMPL *session, WT_MYSLOT *myslot, bool retry, bool forced); extern int __wt_log_slot_new(WT_SESSION_IMPL *session); extern int __wt_log_slot_init(WT_SESSION_IMPL *session); extern int __wt_log_slot_destroy(WT_SESSION_IMPL *session); @@ -401,10 +401,10 @@ extern int __wt_lsm_tree_chunk_name(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_t extern int __wt_lsm_tree_set_chunk_size( WT_SESSION_IMPL *session, WT_LSM_CHUNK *chunk); extern int __wt_lsm_tree_setup_chunk( WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, WT_LSM_CHUNK *chunk); extern int __wt_lsm_tree_setup_bloom( WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, WT_LSM_CHUNK *chunk); -extern int __wt_lsm_tree_create(WT_SESSION_IMPL *session, const char *uri, int exclusive, const char *config); -extern int __wt_lsm_tree_get(WT_SESSION_IMPL *session, const char *uri, int exclusive, WT_LSM_TREE **treep); +extern int __wt_lsm_tree_create(WT_SESSION_IMPL *session, const char *uri, bool exclusive, const char *config); +extern int __wt_lsm_tree_get(WT_SESSION_IMPL *session, const char *uri, bool exclusive, WT_LSM_TREE **treep); extern void __wt_lsm_tree_release(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree); -extern void __wt_lsm_tree_throttle( WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, int decrease_only); +extern void __wt_lsm_tree_throttle( WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, bool decrease_only); extern int __wt_lsm_tree_switch(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree); extern int __wt_lsm_tree_retire_chunks(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, u_int start_chunk, u_int nchunks); extern int __wt_lsm_tree_drop( WT_SESSION_IMPL *session, const char *name, const char *cfg[]); @@ -414,10 +414,10 @@ extern int __wt_lsm_tree_readlock(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tre extern int __wt_lsm_tree_readunlock(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree); extern int __wt_lsm_tree_writelock(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree); extern int __wt_lsm_tree_writeunlock(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree); -extern int __wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, int *skip); -extern int __wt_lsm_tree_worker(WT_SESSION_IMPL *session, const char *uri, int (*file_func)(WT_SESSION_IMPL *, const char *[]), int (*name_func)(WT_SESSION_IMPL *, const char *, int *), const char *cfg[], uint32_t open_flags); -extern int __wt_lsm_get_chunk_to_flush(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, int force, WT_LSM_CHUNK **chunkp); -extern int __wt_lsm_work_switch( WT_SESSION_IMPL *session, WT_LSM_WORK_UNIT **entryp, int *ran); +extern int __wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, bool *skipp); +extern int __wt_lsm_tree_worker(WT_SESSION_IMPL *session, const char *uri, int (*file_func)(WT_SESSION_IMPL *, const char *[]), int (*name_func)(WT_SESSION_IMPL *, const char *, bool *), const char *cfg[], uint32_t open_flags); +extern int __wt_lsm_get_chunk_to_flush(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, bool force, WT_LSM_CHUNK **chunkp); +extern int __wt_lsm_work_switch( WT_SESSION_IMPL *session, WT_LSM_WORK_UNIT **entryp, bool *ran); extern int __wt_lsm_work_bloom(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree); extern int __wt_lsm_checkpoint_chunk(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, WT_LSM_CHUNK *chunk); extern int __wt_lsm_free_chunks(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree); @@ -445,7 +445,7 @@ extern int __wt_metadata_search( WT_SESSION_IMPL *session, const char *key, char extern void __wt_meta_track_discard(WT_SESSION_IMPL *session); extern int __wt_meta_track_on(WT_SESSION_IMPL *session); extern int __wt_meta_track_find_handle( WT_SESSION_IMPL *session, const char *name, const char *checkpoint); -extern int __wt_meta_track_off(WT_SESSION_IMPL *session, int need_sync, int unroll); +extern int __wt_meta_track_off(WT_SESSION_IMPL *session, bool need_sync, bool unroll); extern int __wt_meta_track_sub_on(WT_SESSION_IMPL *session); extern int __wt_meta_track_sub_off(WT_SESSION_IMPL *session); extern int __wt_meta_track_checkpoint(WT_SESSION_IMPL *session); @@ -453,7 +453,7 @@ extern int __wt_meta_track_insert(WT_SESSION_IMPL *session, const char *key); extern int __wt_meta_track_update(WT_SESSION_IMPL *session, const char *key); extern int __wt_meta_track_fileop( WT_SESSION_IMPL *session, const char *olduri, const char *newuri); extern int __wt_meta_track_drop( WT_SESSION_IMPL *session, const char *filename); -extern int __wt_meta_track_handle_lock(WT_SESSION_IMPL *session, int created); +extern int __wt_meta_track_handle_lock(WT_SESSION_IMPL *session, bool created); extern int __wt_turtle_init(WT_SESSION_IMPL *session); extern int __wt_turtle_read(WT_SESSION_IMPL *session, const char *key, char **valuep); extern int __wt_turtle_update( WT_SESSION_IMPL *session, const char *key, const char *value); @@ -465,16 +465,16 @@ extern int __wt_strndup(WT_SESSION_IMPL *session, const void *str, size_t len, v extern void __wt_free_int(WT_SESSION_IMPL *session, const void *p_arg); extern int __wt_dirlist(WT_SESSION_IMPL *session, const char *dir, const char *prefix, uint32_t flags, char ***dirlist, u_int *countp); extern int __wt_dlopen(WT_SESSION_IMPL *session, const char *path, WT_DLH **dlhp); -extern int __wt_dlsym(WT_SESSION_IMPL *session, WT_DLH *dlh, const char *name, int fail, void *sym_ret); +extern int __wt_dlsym(WT_SESSION_IMPL *session, WT_DLH *dlh, const char *name, bool fail, void *sym_ret); extern int __wt_dlclose(WT_SESSION_IMPL *session, WT_DLH *dlh); extern int __wt_errno(void); extern const char *__wt_strerror(WT_SESSION_IMPL *session, int error, char *errbuf, size_t errlen); -extern int __wt_exist(WT_SESSION_IMPL *session, const char *filename, int *existp); +extern int __wt_exist(WT_SESSION_IMPL *session, const char *filename, bool *existp); extern void __wt_fallocate_config(WT_SESSION_IMPL *session, WT_FH *fh); extern int __wt_fallocate( WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t offset, wt_off_t len); extern int __wt_filesize(WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t *sizep); extern int __wt_filesize_name( WT_SESSION_IMPL *session, const char *filename, wt_off_t *sizep); -extern int __wt_bytelock(WT_FH *fhp, wt_off_t byte, int lock); +extern int __wt_bytelock(WT_FH *fhp, wt_off_t byte, bool lock); extern int __wt_directory_sync_fh(WT_SESSION_IMPL *session, WT_FH *fh); extern int __wt_directory_sync(WT_SESSION_IMPL *session, char *path); extern int __wt_fsync(WT_SESSION_IMPL *session, WT_FH *fh); @@ -487,8 +487,8 @@ extern int __wt_mmap(WT_SESSION_IMPL *session, WT_FH *fh, void *mapp, size_t *le extern int __wt_mmap_preload(WT_SESSION_IMPL *session, const void *p, size_t size); extern int __wt_mmap_discard(WT_SESSION_IMPL *session, void *p, size_t size); extern int __wt_munmap(WT_SESSION_IMPL *session, WT_FH *fh, void *map, size_t len, void **mappingcookie); -extern int __wt_cond_alloc(WT_SESSION_IMPL *session, const char *name, int is_signalled, WT_CONDVAR **condp); -extern int __wt_cond_wait_signal( WT_SESSION_IMPL *session, WT_CONDVAR *cond, uint64_t usecs, int *signalled); +extern int __wt_cond_alloc(WT_SESSION_IMPL *session, const char *name, bool is_signalled, WT_CONDVAR **condp); +extern int __wt_cond_wait_signal( WT_SESSION_IMPL *session, WT_CONDVAR *cond, uint64_t usecs, bool *signalled); extern int __wt_cond_signal(WT_SESSION_IMPL *session, WT_CONDVAR *cond); extern int __wt_cond_destroy(WT_SESSION_IMPL *session, WT_CONDVAR **condp); extern int __wt_rwlock_alloc( WT_SESSION_IMPL *session, WT_RWLOCK **rwlockp, const char *name); @@ -500,11 +500,11 @@ extern int __wt_writelock(WT_SESSION_IMPL *session, WT_RWLOCK *rwlock); extern int __wt_writeunlock(WT_SESSION_IMPL *session, WT_RWLOCK *rwlock); extern int __wt_rwlock_destroy(WT_SESSION_IMPL *session, WT_RWLOCK **rwlockp); extern int __wt_once(void (*init_routine)(void)); -extern int __wt_open(WT_SESSION_IMPL *session, const char *name, int ok_create, int exclusive, int dio_type, WT_FH **fhp); +extern int __wt_open(WT_SESSION_IMPL *session, const char *name, bool ok_create, bool exclusive, int dio_type, WT_FH **fhp); extern int __wt_close(WT_SESSION_IMPL *session, WT_FH **fhp); extern bool __wt_absolute_path(const char *path); extern const char *__wt_path_separator(void); -extern int __wt_has_priv(void); +extern bool __wt_has_priv(void); extern int __wt_remove(WT_SESSION_IMPL *session, const char *name); extern int __wt_rename(WT_SESSION_IMPL *session, const char *from, const char *to); extern int __wt_read( WT_SESSION_IMPL *session, WT_FH *fh, wt_off_t offset, size_t len, void *buf); @@ -525,7 +525,7 @@ extern void __wt_yield(void); extern int __wt_ext_struct_pack(WT_EXTENSION_API *wt_api, WT_SESSION *wt_session, void *buffer, size_t size, const char *fmt, ...); extern int __wt_ext_struct_size(WT_EXTENSION_API *wt_api, WT_SESSION *wt_session, size_t *sizep, const char *fmt, ...); extern int __wt_ext_struct_unpack(WT_EXTENSION_API *wt_api, WT_SESSION *wt_session, const void *buffer, size_t size, const char *fmt, ...); -extern int __wt_struct_check(WT_SESSION_IMPL *session, const char *fmt, size_t len, int *fixedp, uint32_t *fixed_lenp); +extern int __wt_struct_check(WT_SESSION_IMPL *session, const char *fmt, size_t len, bool *fixedp, uint32_t *fixed_lenp); extern int __wt_struct_confchk(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *v); extern int __wt_struct_size(WT_SESSION_IMPL *session, size_t *sizep, const char *fmt, ...); extern int __wt_struct_pack(WT_SESSION_IMPL *session, void *buffer, size_t size, const char *fmt, ...); @@ -553,7 +553,7 @@ extern int __wt_schema_colgroup_source(WT_SESSION_IMPL *session, WT_TABLE *table extern int __wt_schema_index_source(WT_SESSION_IMPL *session, WT_TABLE *table, const char *idxname, const char *config, WT_ITEM *buf); extern int __wt_schema_create( WT_SESSION_IMPL *session, const char *uri, const char *config); extern int __wt_schema_drop(WT_SESSION_IMPL *session, const char *uri, const char *cfg[]); -extern int __wt_schema_get_table(WT_SESSION_IMPL *session, const char *name, size_t namelen, int ok_incomplete, WT_TABLE **tablep); +extern int __wt_schema_get_table(WT_SESSION_IMPL *session, const char *name, size_t namelen, bool ok_incomplete, WT_TABLE **tablep); extern void __wt_schema_release_table(WT_SESSION_IMPL *session, WT_TABLE *table); extern void __wt_schema_destroy_colgroup(WT_SESSION_IMPL *session, WT_COLGROUP **colgroupp); extern int __wt_schema_destroy_index(WT_SESSION_IMPL *session, WT_INDEX **idxp); @@ -564,17 +564,17 @@ extern int __wt_schema_colgroup_name(WT_SESSION_IMPL *session, WT_TABLE *table, extern int __wt_schema_open_colgroups(WT_SESSION_IMPL *session, WT_TABLE *table); extern int __wt_schema_open_index(WT_SESSION_IMPL *session, WT_TABLE *table, const char *idxname, size_t len, WT_INDEX **indexp); extern int __wt_schema_open_indices(WT_SESSION_IMPL *session, WT_TABLE *table); -extern int __wt_schema_open_table(WT_SESSION_IMPL *session, const char *name, size_t namelen, int ok_incomplete, WT_TABLE **tablep); -extern int __wt_schema_get_colgroup(WT_SESSION_IMPL *session, const char *uri, int quiet, WT_TABLE **tablep, WT_COLGROUP **colgroupp); -extern int __wt_schema_get_index(WT_SESSION_IMPL *session, const char *uri, int quiet, WT_TABLE **tablep, WT_INDEX **indexp); +extern int __wt_schema_open_table(WT_SESSION_IMPL *session, const char *name, size_t namelen, bool ok_incomplete, WT_TABLE **tablep); +extern int __wt_schema_get_colgroup(WT_SESSION_IMPL *session, const char *uri, bool quiet, WT_TABLE **tablep, WT_COLGROUP **colgroupp); +extern int __wt_schema_get_index(WT_SESSION_IMPL *session, const char *uri, bool quiet, WT_TABLE **tablep, WT_INDEX **indexp); extern int __wt_schema_colcheck(WT_SESSION_IMPL *session, const char *key_format, const char *value_format, WT_CONFIG_ITEM *colconf, u_int *kcolsp, u_int *vcolsp); extern int __wt_table_check(WT_SESSION_IMPL *session, WT_TABLE *table); -extern int __wt_struct_plan(WT_SESSION_IMPL *session, WT_TABLE *table, const char *columns, size_t len, int value_only, WT_ITEM *plan); -extern int __wt_struct_reformat(WT_SESSION_IMPL *session, WT_TABLE *table, const char *columns, size_t len, const char *extra_cols, int value_only, WT_ITEM *format); +extern int __wt_struct_plan(WT_SESSION_IMPL *session, WT_TABLE *table, const char *columns, size_t len, bool value_only, WT_ITEM *plan); +extern int __wt_struct_reformat(WT_SESSION_IMPL *session, WT_TABLE *table, const char *columns, size_t len, const char *extra_cols, bool value_only, WT_ITEM *format); extern int __wt_struct_truncate(WT_SESSION_IMPL *session, const char *input_fmt, u_int ncols, WT_ITEM *format); extern int __wt_schema_project_in(WT_SESSION_IMPL *session, WT_CURSOR **cp, const char *proj_arg, va_list ap); extern int __wt_schema_project_out(WT_SESSION_IMPL *session, WT_CURSOR **cp, const char *proj_arg, va_list ap); -extern int __wt_schema_project_slice(WT_SESSION_IMPL *session, WT_CURSOR **cp, const char *proj_arg, int key_only, const char *vformat, WT_ITEM *value); +extern int __wt_schema_project_slice(WT_SESSION_IMPL *session, WT_CURSOR **cp, const char *proj_arg, bool key_only, const char *vformat, WT_ITEM *value); extern int __wt_schema_project_merge(WT_SESSION_IMPL *session, WT_CURSOR **cp, const char *proj_arg, const char *vformat, WT_ITEM *value); extern int __wt_schema_rename(WT_SESSION_IMPL *session, const char *uri, const char *newuri, const char *cfg[]); extern int __wt_curstat_colgroup_init(WT_SESSION_IMPL *session, const char *uri, const char *cfg[], WT_CURSOR_STAT *cst); @@ -586,17 +586,17 @@ extern int __wt_schema_range_truncate( WT_SESSION_IMPL *session, WT_CURSOR *star extern WT_DATA_SOURCE *__wt_schema_get_source(WT_SESSION_IMPL *session, const char *name); extern int __wt_str_name_check(WT_SESSION_IMPL *session, const char *str); extern int __wt_name_check(WT_SESSION_IMPL *session, const char *str, size_t len); -extern int __wt_schema_worker(WT_SESSION_IMPL *session, const char *uri, int (*file_func)(WT_SESSION_IMPL *, const char *[]), int (*name_func)(WT_SESSION_IMPL *, const char *, int *), const char *cfg[], uint32_t open_flags); -extern int __wt_session_reset_cursors(WT_SESSION_IMPL *session, int free_buffers); +extern int __wt_schema_worker(WT_SESSION_IMPL *session, const char *uri, int (*file_func)(WT_SESSION_IMPL *, const char *[]), int (*name_func)(WT_SESSION_IMPL *, const char *, bool *), const char *cfg[], uint32_t open_flags); +extern int __wt_session_reset_cursors(WT_SESSION_IMPL *session, bool free_buffers); extern int __wt_session_copy_values(WT_SESSION_IMPL *session); extern int __wt_open_cursor(WT_SESSION_IMPL *session, const char *uri, WT_CURSOR *owner, const char *cfg[], WT_CURSOR **cursorp); extern int __wt_session_create( WT_SESSION_IMPL *session, const char *uri, const char *config); extern int __wt_session_drop(WT_SESSION_IMPL *session, const char *uri, const char *cfg[]); -extern int __wt_open_internal_session(WT_CONNECTION_IMPL *conn, const char *name, int uses_dhandles, int open_metadata, WT_SESSION_IMPL **sessionp); -extern int __wt_open_session(WT_CONNECTION_IMPL *conn, WT_EVENT_HANDLER *event_handler, const char *config, int open_metadata, WT_SESSION_IMPL **sessionp); -extern int __wt_compact_uri_analyze(WT_SESSION_IMPL *session, const char *uri, int *skip); +extern int __wt_open_internal_session(WT_CONNECTION_IMPL *conn, const char *name, bool uses_dhandles, bool open_metadata, WT_SESSION_IMPL **sessionp); +extern int __wt_open_session(WT_CONNECTION_IMPL *conn, WT_EVENT_HANDLER *event_handler, const char *config, bool open_metadata, WT_SESSION_IMPL **sessionp); +extern int __wt_compact_uri_analyze(WT_SESSION_IMPL *session, const char *uri, bool *skipp); extern int __wt_session_compact( WT_SESSION *wt_session, const char *uri, const char *config); -extern int __wt_session_lock_dhandle( WT_SESSION_IMPL *session, uint32_t flags, int *is_deadp); +extern int __wt_session_lock_dhandle( WT_SESSION_IMPL *session, uint32_t flags, bool *is_deadp); extern int __wt_session_release_btree(WT_SESSION_IMPL *session); extern int __wt_session_get_btree_ckpt(WT_SESSION_IMPL *session, const char *uri, const char *cfg[], uint32_t flags); extern void __wt_session_close_cache(WT_SESSION_IMPL *session); @@ -609,7 +609,7 @@ extern int __wt_decrypt(WT_SESSION_IMPL *session, WT_ENCRYPTOR *encryptor, size_ extern int __wt_encrypt(WT_SESSION_IMPL *session, WT_KEYED_ENCRYPTOR *kencryptor, size_t skip, WT_ITEM *in, WT_ITEM *out); extern void __wt_encrypt_size(WT_SESSION_IMPL *session, WT_KEYED_ENCRYPTOR *kencryptor, size_t incoming_size, size_t *sizep); extern void __wt_event_handler_set(WT_SESSION_IMPL *session, WT_EVENT_HANDLER *handler); -extern int __wt_eventv(WT_SESSION_IMPL *session, int msg_event, int error, const char *file_name, int line_number, const char *fmt, va_list ap); +extern int __wt_eventv(WT_SESSION_IMPL *session, bool msg_event, int error, const char *file_name, int line_number, const char *fmt, va_list ap); extern void __wt_err(WT_SESSION_IMPL *session, int error, const char *fmt, ...) WT_GCC_FUNC_DECL_ATTRIBUTE((format (printf, 3, 4))); extern void __wt_errx(WT_SESSION_IMPL *session, const char *fmt, ...) WT_GCC_FUNC_DECL_ATTRIBUTE((format (printf, 2, 3))); extern int __wt_ext_err_printf( WT_EXTENSION_API *wt_api, WT_SESSION *wt_session, const char *fmt, ...) WT_GCC_FUNC_DECL_ATTRIBUTE((format (printf, 3, 4))); @@ -633,7 +633,7 @@ extern void __wt_attach(WT_SESSION_IMPL *session); extern uint64_t __wt_hash_city64(const void *s, size_t len); extern uint64_t __wt_hash_fnv64(const void *string, size_t len); extern int -__wt_hazard_set(WT_SESSION_IMPL *session, WT_REF *ref, int *busyp +__wt_hazard_set(WT_SESSION_IMPL *session, WT_REF *ref, bool *busyp #ifdef HAVE_DIAGNOSTIC , const char *file, int line #endif @@ -685,7 +685,7 @@ extern void __wt_stat_connection_clear_all(WT_CONNECTION_STATS **stats); extern void __wt_stat_connection_aggregate( WT_CONNECTION_STATS **from, WT_CONNECTION_STATS *to); extern void __wt_txn_release_snapshot(WT_SESSION_IMPL *session); extern void __wt_txn_get_snapshot(WT_SESSION_IMPL *session); -extern void __wt_txn_update_oldest(WT_SESSION_IMPL *session, int force); +extern void __wt_txn_update_oldest(WT_SESSION_IMPL *session, bool force); extern int __wt_txn_config(WT_SESSION_IMPL *session, const char *cfg[]); extern void __wt_txn_release(WT_SESSION_IMPL *session); extern int __wt_txn_commit(WT_SESSION_IMPL *session, const char *cfg[]); @@ -700,7 +700,7 @@ extern int __wt_checkpoint_list(WT_SESSION_IMPL *session, const char *cfg[]); extern int __wt_txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[]); extern int __wt_checkpoint(WT_SESSION_IMPL *session, const char *cfg[]); extern int __wt_checkpoint_sync(WT_SESSION_IMPL *session, const char *cfg[]); -extern int __wt_checkpoint_close(WT_SESSION_IMPL *session, int final); +extern int __wt_checkpoint_close(WT_SESSION_IMPL *session, bool final); extern uint64_t __wt_ext_transaction_id(WT_EXTENSION_API *wt_api, WT_SESSION *wt_session); extern int __wt_ext_transaction_isolation_level( WT_EXTENSION_API *wt_api, WT_SESSION *wt_session); extern int __wt_ext_transaction_notify( WT_EXTENSION_API *wt_api, WT_SESSION *wt_session, WT_TXN_NOTIFY *notify); @@ -710,13 +710,13 @@ extern void __wt_txn_op_free(WT_SESSION_IMPL *session, WT_TXN_OP *op); extern int __wt_txn_log_op(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt); extern int __wt_txn_log_commit(WT_SESSION_IMPL *session, const char *cfg[]); extern int __wt_txn_checkpoint_logread( WT_SESSION_IMPL *session, const uint8_t **pp, const uint8_t *end, WT_LSN *ckpt_lsn); -extern int __wt_txn_checkpoint_log( WT_SESSION_IMPL *session, int full, uint32_t flags, WT_LSN *lsnp); +extern int __wt_txn_checkpoint_log( WT_SESSION_IMPL *session, bool full, uint32_t flags, WT_LSN *lsnp); extern int __wt_txn_truncate_log( WT_SESSION_IMPL *session, WT_CURSOR_BTREE *start, WT_CURSOR_BTREE *stop); extern int __wt_txn_truncate_end(WT_SESSION_IMPL *session); extern int __wt_txn_printlog(WT_SESSION *wt_session, FILE *out); extern int __wt_txn_named_snapshot_begin(WT_SESSION_IMPL *session, const char *cfg[]); extern int __wt_txn_named_snapshot_drop(WT_SESSION_IMPL *session, const char *cfg[]); extern int __wt_txn_named_snapshot_get(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *nameval); -extern int __wt_txn_named_snapshot_config(WT_SESSION_IMPL *session, const char *cfg[], int *has_create, int *has_drops); +extern int __wt_txn_named_snapshot_config(WT_SESSION_IMPL *session, const char *cfg[], bool *has_create, bool *has_drops); extern int __wt_txn_named_snapshot_destroy(WT_SESSION_IMPL *session); extern int __wt_txn_recover(WT_SESSION_IMPL *session); diff --git a/src/third_party/wiredtiger/src/include/misc.h b/src/third_party/wiredtiger/src/include/misc.h index 1b2cbf11fc2..ff2f6645e5a 100644 --- a/src/third_party/wiredtiger/src/include/misc.h +++ b/src/third_party/wiredtiger/src/include/misc.h @@ -120,18 +120,21 @@ * hex constant might be a negative integer), and to ensure the hex constant is * the correct size before applying the bitwise not operator. */ -#define F_CLR(p, mask) ((p)->flags &= ~((uint32_t)(mask))) -#define F_ISSET(p, mask) ((p)->flags & ((uint32_t)(mask))) -#define F_SET(p, mask) ((p)->flags |= ((uint32_t)(mask))) +#define FLD_CLR(field, mask) ((field) &= ~((uint32_t)(mask))) +#define FLD_MASK(field, mask) ((field) & (uint32_t)(mask)) +#define FLD_ISSET(field, mask) (FLD_MASK(field, mask) != 0) +#define FLD64_ISSET(field, mask) (((field) & (uint64_t)(mask)) != 0) +#define FLD_SET(field, mask) ((field) |= ((uint32_t)(mask))) -#define LF_CLR(mask) ((flags) &= ~((uint32_t)(mask))) -#define LF_ISSET(mask) ((flags) & ((uint32_t)(mask))) -#define LF_SET(mask) ((flags) |= ((uint32_t)(mask))) +#define F_CLR(p, mask) FLD_CLR((p)->flags, mask) +#define F_ISSET(p, mask) FLD_ISSET((p)->flags, mask) +#define F_MASK(p, mask) FLD_MASK((p)->flags, mask) +#define F_SET(p, mask) FLD_SET((p)->flags, mask) -#define FLD_CLR(field, mask) ((field) &= ~((uint32_t)(mask))) -#define FLD_ISSET(field, mask) ((field) & ((uint32_t)(mask))) -#define FLD64_ISSET(field, mask) ((field) & ((uint64_t)(mask))) -#define FLD_SET(field, mask) ((field) |= ((uint32_t)(mask))) +#define LF_CLR(mask) FLD_CLR(flags, mask) +#define LF_ISSET(mask) FLD_ISSET(flags, mask) +#define LF_MASK(mask) FLD_MASK(flags, mask) +#define LF_SET(mask) FLD_SET(flags, mask) /* * Insertion sort, for sorting small sets of values. @@ -165,14 +168,14 @@ */ #define WT_BINARY_SEARCH(key, arrayp, n, found) do { \ uint32_t __base, __indx, __limit; \ - found = 0; \ + found = false; \ for (__base = 0, __limit = (n); __limit != 0; __limit >>= 1) { \ __indx = __base + (__limit >> 1); \ if ((arrayp)[__indx] < key) { \ __base = __indx + 1; \ --__limit; \ } else if ((arrayp)[__indx] == key) { \ - found = 1; \ + found = true; \ break; \ } \ } \ diff --git a/src/third_party/wiredtiger/src/include/misc.i b/src/third_party/wiredtiger/src/include/misc.i index 6b502c4c1d1..80096d0cf72 100644 --- a/src/third_party/wiredtiger/src/include/misc.i +++ b/src/third_party/wiredtiger/src/include/misc.i @@ -13,7 +13,7 @@ static inline int __wt_cond_wait(WT_SESSION_IMPL *session, WT_CONDVAR *cond, uint64_t usecs) { - int notused; + bool notused; return (__wt_cond_wait_signal(session, cond, usecs, ¬used)); } @@ -43,7 +43,7 @@ __wt_verbose(WT_SESSION_IMPL *session, int flag, const char *fmt, ...) if (WT_VERBOSE_ISSET(session, flag)) { va_start(ap, fmt); - ret = __wt_eventv(session, 1, 0, NULL, 0, fmt, ap); + ret = __wt_eventv(session, true, 0, NULL, 0, fmt, ap); va_end(ap); } return (ret); diff --git a/src/third_party/wiredtiger/src/include/os.h b/src/third_party/wiredtiger/src/include/os.h index 518b124f547..a8bf59f25d3 100644 --- a/src/third_party/wiredtiger/src/include/os.h +++ b/src/third_party/wiredtiger/src/include/os.h @@ -93,7 +93,7 @@ struct __wt_fh { wt_off_t extend_size; /* File extended size */ wt_off_t extend_len; /* File extend chunk size */ - int direct_io; /* O_DIRECT configured */ + bool direct_io; /* O_DIRECT configured */ enum { /* file extend configuration */ WT_FALLOCATE_AVAILABLE, diff --git a/src/third_party/wiredtiger/src/include/packing.i b/src/third_party/wiredtiger/src/include/packing.i index da0ca54e6c2..9be38251703 100644 --- a/src/third_party/wiredtiger/src/include/packing.i +++ b/src/third_party/wiredtiger/src/include/packing.i @@ -42,7 +42,7 @@ typedef struct { WT_CONFIG config; char buf[20]; int count; - int iskey; + bool iskey; int genname; } WT_PACK_NAME; @@ -82,7 +82,7 @@ __pack_init(WT_SESSION_IMPL *session, WT_PACK *pack, const char *fmt) */ static inline int __pack_name_init(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *names, - int iskey, WT_PACK_NAME *pn) + bool iskey, WT_PACK_NAME *pn) { WT_CLEAR(*pn); pn->iskey = iskey; diff --git a/src/third_party/wiredtiger/src/include/schema.h b/src/third_party/wiredtiger/src/include/schema.h index 0664af5adba..b226d1f2b50 100644 --- a/src/third_party/wiredtiger/src/include/schema.h +++ b/src/third_party/wiredtiger/src/include/schema.h @@ -65,7 +65,7 @@ struct __wt_table { TAILQ_ENTRY(__wt_table) q; TAILQ_ENTRY(__wt_table) hashq; - int cg_complete, idx_complete, is_simple; + bool cg_complete, idx_complete, is_simple; u_int ncolgroups, nindices, nkey_columns; uint32_t refcnt; /* Number of open cursors */ diff --git a/src/third_party/wiredtiger/src/include/serial.i b/src/third_party/wiredtiger/src/include/serial.i index fd6ede46c69..5358b874c06 100644 --- a/src/third_party/wiredtiger/src/include/serial.i +++ b/src/third_party/wiredtiger/src/include/serial.i @@ -202,8 +202,8 @@ __wt_insert_serial(WT_SESSION_IMPL *session, WT_PAGE *page, { WT_INSERT *new_ins = *new_insp; WT_DECL_RET; - int simple; u_int i; + bool simple; /* Check for page write generation wrap. */ WT_RET(__page_write_gen_wrapped_check(page)); @@ -211,10 +211,10 @@ __wt_insert_serial(WT_SESSION_IMPL *session, WT_PAGE *page, /* Clear references to memory we now own and must free on error. */ *new_insp = NULL; - simple = 1; + simple = true; for (i = 0; i < skipdepth; i++) if (new_ins->next[i] == NULL) - simple = 0; + simple = false; if (simple) ret = __insert_simple_func( @@ -306,7 +306,7 @@ __wt_update_serial(WT_SESSION_IMPL *session, WT_PAGE *page, if ((txn = page->modify->obsolete_check_txn) != WT_TXN_NONE) { if (!__wt_txn_visible_all(session, txn)) { /* Try to move the oldest ID forward and re-check. */ - __wt_txn_update_oldest(session, 0); + __wt_txn_update_oldest(session, false); if (!__wt_txn_visible_all(session, txn)) return (0); diff --git a/src/third_party/wiredtiger/src/include/stat.h b/src/third_party/wiredtiger/src/include/stat.h index 2f975b70c40..3f7d8985a84 100644 --- a/src/third_party/wiredtiger/src/include/stat.h +++ b/src/third_party/wiredtiger/src/include/stat.h @@ -320,6 +320,7 @@ struct __wt_connection_stats { int64_t log_max_filesize; int64_t log_prealloc_files; int64_t log_prealloc_max; + int64_t log_prealloc_missed; int64_t log_prealloc_used; int64_t log_release_write_lsn; int64_t log_scan_records; diff --git a/src/third_party/wiredtiger/src/include/txn.i b/src/third_party/wiredtiger/src/include/txn.i index 2b42990f5e5..54c30adae76 100644 --- a/src/third_party/wiredtiger/src/include/txn.i +++ b/src/third_party/wiredtiger/src/include/txn.i @@ -263,7 +263,7 @@ __wt_txn_begin(WT_SESSION_IMPL *session, const char *cfg[]) * We're about to allocate a snapshot: if we need to block for * eviction, it's better to do it beforehand. */ - WT_RET(__wt_cache_eviction_check(session, 0, NULL)); + WT_RET(__wt_cache_eviction_check(session, false, NULL)); __wt_txn_get_snapshot(session); } @@ -327,7 +327,7 @@ __wt_txn_idle_cache_check(WT_SESSION_IMPL *session) */ if (F_ISSET(txn, WT_TXN_RUNNING) && !F_ISSET(txn, WT_TXN_HAS_ID) && txn_state->snap_min == WT_TXN_NONE) - WT_RET(__wt_cache_eviction_check(session, 0, NULL)); + WT_RET(__wt_cache_eviction_check(session, false, NULL)); return (0); } diff --git a/src/third_party/wiredtiger/src/include/wiredtiger.in b/src/third_party/wiredtiger/src/include/wiredtiger.in index e9ef7ac5ff4..9078a0e2e99 100644 --- a/src/third_party/wiredtiger/src/include/wiredtiger.in +++ b/src/third_party/wiredtiger/src/include/wiredtiger.in @@ -3757,124 +3757,126 @@ extern int wiredtiger_extension_terminate(WT_CONNECTION *connection); #define WT_STAT_CONN_LOG_PREALLOC_FILES 1091 /*! log: number of pre-allocated log files to create */ #define WT_STAT_CONN_LOG_PREALLOC_MAX 1092 +/*! log: pre-allocated log files not ready and missed */ +#define WT_STAT_CONN_LOG_PREALLOC_MISSED 1093 /*! log: pre-allocated log files used */ -#define WT_STAT_CONN_LOG_PREALLOC_USED 1093 +#define WT_STAT_CONN_LOG_PREALLOC_USED 1094 /*! log: log release advances write LSN */ -#define WT_STAT_CONN_LOG_RELEASE_WRITE_LSN 1094 +#define WT_STAT_CONN_LOG_RELEASE_WRITE_LSN 1095 /*! log: records processed by log scan */ -#define WT_STAT_CONN_LOG_SCAN_RECORDS 1095 +#define WT_STAT_CONN_LOG_SCAN_RECORDS 1096 /*! log: log scan records requiring two reads */ -#define WT_STAT_CONN_LOG_SCAN_REREADS 1096 +#define WT_STAT_CONN_LOG_SCAN_REREADS 1097 /*! log: log scan operations */ -#define WT_STAT_CONN_LOG_SCANS 1097 +#define WT_STAT_CONN_LOG_SCANS 1098 /*! log: consolidated slot closures */ -#define WT_STAT_CONN_LOG_SLOT_CLOSES 1098 +#define WT_STAT_CONN_LOG_SLOT_CLOSES 1099 /*! log: written slots coalesced */ -#define WT_STAT_CONN_LOG_SLOT_COALESCED 1099 +#define WT_STAT_CONN_LOG_SLOT_COALESCED 1100 /*! log: logging bytes consolidated */ -#define WT_STAT_CONN_LOG_SLOT_CONSOLIDATED 1100 +#define WT_STAT_CONN_LOG_SLOT_CONSOLIDATED 1101 /*! log: consolidated slot joins */ -#define WT_STAT_CONN_LOG_SLOT_JOINS 1101 +#define WT_STAT_CONN_LOG_SLOT_JOINS 1102 /*! log: consolidated slot join races */ -#define WT_STAT_CONN_LOG_SLOT_RACES 1102 +#define WT_STAT_CONN_LOG_SLOT_RACES 1103 /*! log: busy returns attempting to switch slots */ -#define WT_STAT_CONN_LOG_SLOT_SWITCH_BUSY 1103 +#define WT_STAT_CONN_LOG_SLOT_SWITCH_BUSY 1104 /*! log: consolidated slot join transitions */ -#define WT_STAT_CONN_LOG_SLOT_TRANSITIONS 1104 +#define WT_STAT_CONN_LOG_SLOT_TRANSITIONS 1105 /*! log: consolidated slot unbuffered writes */ -#define WT_STAT_CONN_LOG_SLOT_UNBUFFERED 1105 +#define WT_STAT_CONN_LOG_SLOT_UNBUFFERED 1106 /*! log: log sync operations */ -#define WT_STAT_CONN_LOG_SYNC 1106 +#define WT_STAT_CONN_LOG_SYNC 1107 /*! log: log sync_dir operations */ -#define WT_STAT_CONN_LOG_SYNC_DIR 1107 +#define WT_STAT_CONN_LOG_SYNC_DIR 1108 /*! log: log server thread advances write LSN */ -#define WT_STAT_CONN_LOG_WRITE_LSN 1108 +#define WT_STAT_CONN_LOG_WRITE_LSN 1109 /*! log: log write operations */ -#define WT_STAT_CONN_LOG_WRITES 1109 +#define WT_STAT_CONN_LOG_WRITES 1110 /*! LSM: sleep for LSM checkpoint throttle */ -#define WT_STAT_CONN_LSM_CHECKPOINT_THROTTLE 1110 +#define WT_STAT_CONN_LSM_CHECKPOINT_THROTTLE 1111 /*! LSM: sleep for LSM merge throttle */ -#define WT_STAT_CONN_LSM_MERGE_THROTTLE 1111 +#define WT_STAT_CONN_LSM_MERGE_THROTTLE 1112 /*! LSM: rows merged in an LSM tree */ -#define WT_STAT_CONN_LSM_ROWS_MERGED 1112 +#define WT_STAT_CONN_LSM_ROWS_MERGED 1113 /*! LSM: application work units currently queued */ -#define WT_STAT_CONN_LSM_WORK_QUEUE_APP 1113 +#define WT_STAT_CONN_LSM_WORK_QUEUE_APP 1114 /*! LSM: merge work units currently queued */ -#define WT_STAT_CONN_LSM_WORK_QUEUE_MANAGER 1114 +#define WT_STAT_CONN_LSM_WORK_QUEUE_MANAGER 1115 /*! LSM: tree queue hit maximum */ -#define WT_STAT_CONN_LSM_WORK_QUEUE_MAX 1115 +#define WT_STAT_CONN_LSM_WORK_QUEUE_MAX 1116 /*! LSM: switch work units currently queued */ -#define WT_STAT_CONN_LSM_WORK_QUEUE_SWITCH 1116 +#define WT_STAT_CONN_LSM_WORK_QUEUE_SWITCH 1117 /*! LSM: tree maintenance operations scheduled */ -#define WT_STAT_CONN_LSM_WORK_UNITS_CREATED 1117 +#define WT_STAT_CONN_LSM_WORK_UNITS_CREATED 1118 /*! LSM: tree maintenance operations discarded */ -#define WT_STAT_CONN_LSM_WORK_UNITS_DISCARDED 1118 +#define WT_STAT_CONN_LSM_WORK_UNITS_DISCARDED 1119 /*! LSM: tree maintenance operations executed */ -#define WT_STAT_CONN_LSM_WORK_UNITS_DONE 1119 +#define WT_STAT_CONN_LSM_WORK_UNITS_DONE 1120 /*! connection: memory allocations */ -#define WT_STAT_CONN_MEMORY_ALLOCATION 1120 +#define WT_STAT_CONN_MEMORY_ALLOCATION 1121 /*! connection: memory frees */ -#define WT_STAT_CONN_MEMORY_FREE 1121 +#define WT_STAT_CONN_MEMORY_FREE 1122 /*! connection: memory re-allocations */ -#define WT_STAT_CONN_MEMORY_GROW 1122 +#define WT_STAT_CONN_MEMORY_GROW 1123 /*! thread-yield: page acquire busy blocked */ -#define WT_STAT_CONN_PAGE_BUSY_BLOCKED 1123 +#define WT_STAT_CONN_PAGE_BUSY_BLOCKED 1124 /*! thread-yield: page acquire eviction blocked */ -#define WT_STAT_CONN_PAGE_FORCIBLE_EVICT_BLOCKED 1124 +#define WT_STAT_CONN_PAGE_FORCIBLE_EVICT_BLOCKED 1125 /*! thread-yield: page acquire locked blocked */ -#define WT_STAT_CONN_PAGE_LOCKED_BLOCKED 1125 +#define WT_STAT_CONN_PAGE_LOCKED_BLOCKED 1126 /*! thread-yield: page acquire read blocked */ -#define WT_STAT_CONN_PAGE_READ_BLOCKED 1126 +#define WT_STAT_CONN_PAGE_READ_BLOCKED 1127 /*! thread-yield: page acquire time sleeping (usecs) */ -#define WT_STAT_CONN_PAGE_SLEEP 1127 +#define WT_STAT_CONN_PAGE_SLEEP 1128 /*! connection: total read I/Os */ -#define WT_STAT_CONN_READ_IO 1128 +#define WT_STAT_CONN_READ_IO 1129 /*! reconciliation: page reconciliation calls */ -#define WT_STAT_CONN_REC_PAGES 1129 +#define WT_STAT_CONN_REC_PAGES 1130 /*! reconciliation: page reconciliation calls for eviction */ -#define WT_STAT_CONN_REC_PAGES_EVICTION 1130 +#define WT_STAT_CONN_REC_PAGES_EVICTION 1131 /*! reconciliation: split bytes currently awaiting free */ -#define WT_STAT_CONN_REC_SPLIT_STASHED_BYTES 1131 +#define WT_STAT_CONN_REC_SPLIT_STASHED_BYTES 1132 /*! reconciliation: split objects currently awaiting free */ -#define WT_STAT_CONN_REC_SPLIT_STASHED_OBJECTS 1132 +#define WT_STAT_CONN_REC_SPLIT_STASHED_OBJECTS 1133 /*! connection: pthread mutex shared lock read-lock calls */ -#define WT_STAT_CONN_RWLOCK_READ 1133 +#define WT_STAT_CONN_RWLOCK_READ 1134 /*! connection: pthread mutex shared lock write-lock calls */ -#define WT_STAT_CONN_RWLOCK_WRITE 1134 +#define WT_STAT_CONN_RWLOCK_WRITE 1135 /*! session: open cursor count */ -#define WT_STAT_CONN_SESSION_CURSOR_OPEN 1135 +#define WT_STAT_CONN_SESSION_CURSOR_OPEN 1136 /*! session: open session count */ -#define WT_STAT_CONN_SESSION_OPEN 1136 +#define WT_STAT_CONN_SESSION_OPEN 1137 /*! transaction: transaction begins */ -#define WT_STAT_CONN_TXN_BEGIN 1137 +#define WT_STAT_CONN_TXN_BEGIN 1138 /*! transaction: transaction checkpoints */ -#define WT_STAT_CONN_TXN_CHECKPOINT 1138 +#define WT_STAT_CONN_TXN_CHECKPOINT 1139 /*! transaction: transaction checkpoint generation */ -#define WT_STAT_CONN_TXN_CHECKPOINT_GENERATION 1139 +#define WT_STAT_CONN_TXN_CHECKPOINT_GENERATION 1140 /*! transaction: transaction checkpoint currently running */ -#define WT_STAT_CONN_TXN_CHECKPOINT_RUNNING 1140 +#define WT_STAT_CONN_TXN_CHECKPOINT_RUNNING 1141 /*! transaction: transaction checkpoint max time (msecs) */ -#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_MAX 1141 +#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_MAX 1142 /*! transaction: transaction checkpoint min time (msecs) */ -#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_MIN 1142 +#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_MIN 1143 /*! transaction: transaction checkpoint most recent time (msecs) */ -#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_RECENT 1143 +#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_RECENT 1144 /*! transaction: transaction checkpoint total time (msecs) */ -#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_TOTAL 1144 +#define WT_STAT_CONN_TXN_CHECKPOINT_TIME_TOTAL 1145 /*! transaction: transactions committed */ -#define WT_STAT_CONN_TXN_COMMIT 1145 +#define WT_STAT_CONN_TXN_COMMIT 1146 /*! transaction: transaction failures due to cache overflow */ -#define WT_STAT_CONN_TXN_FAIL_CACHE 1146 +#define WT_STAT_CONN_TXN_FAIL_CACHE 1147 /*! transaction: transaction range of IDs currently pinned by a checkpoint */ -#define WT_STAT_CONN_TXN_PINNED_CHECKPOINT_RANGE 1147 +#define WT_STAT_CONN_TXN_PINNED_CHECKPOINT_RANGE 1148 /*! transaction: transaction range of IDs currently pinned */ -#define WT_STAT_CONN_TXN_PINNED_RANGE 1148 +#define WT_STAT_CONN_TXN_PINNED_RANGE 1149 /*! transaction: transactions rolled back */ -#define WT_STAT_CONN_TXN_ROLLBACK 1149 +#define WT_STAT_CONN_TXN_ROLLBACK 1150 /*! transaction: transaction sync calls */ -#define WT_STAT_CONN_TXN_SYNC 1150 +#define WT_STAT_CONN_TXN_SYNC 1151 /*! connection: total write I/Os */ -#define WT_STAT_CONN_WRITE_IO 1151 +#define WT_STAT_CONN_WRITE_IO 1152 /*! * @} diff --git a/src/third_party/wiredtiger/src/log/log.c b/src/third_party/wiredtiger/src/log/log.c index 79513944a1c..29b19443ae4 100644 --- a/src/third_party/wiredtiger/src/log/log.c +++ b/src/third_party/wiredtiger/src/log/log.c @@ -39,7 +39,7 @@ __wt_log_ckpt(WT_SESSION_IMPL *session, WT_LSN *ckp_lsn) * write_start_lsn or write_lsn depending on the argument. */ int -__wt_log_flush_lsn(WT_SESSION_IMPL *session, WT_LSN *lsn, int start) +__wt_log_flush_lsn(WT_SESSION_IMPL *session, WT_LSN *lsn, bool start) { WT_CONNECTION_IMPL *conn; WT_LOG *log; @@ -118,8 +118,8 @@ __wt_log_force_sync(WT_SESSION_IMPL *session, WT_LSN *min_lsn) */ if (log->sync_dir_lsn.file < min_lsn->file) { WT_ERR(__wt_verbose(session, WT_VERB_LOG, - "log_force_sync: sync directory %s", - log->log_dir_fh->name)); + "log_force_sync: sync directory %s to LSN %d/%lu", + log->log_dir_fh->name, min_lsn->file, min_lsn->offset)); WT_ERR(__wt_directory_sync_fh(session, log->log_dir_fh)); log->sync_dir_lsn = *min_lsn; WT_STAT_FAST_CONN_INCR(session, log_sync_dir); @@ -129,8 +129,8 @@ __wt_log_force_sync(WT_SESSION_IMPL *session, WT_LSN *min_lsn) */ if (__wt_log_cmp(&log->sync_lsn, min_lsn) < 0) { WT_ERR(__wt_verbose(session, WT_VERB_LOG, - "log_force_sync: sync to LSN %d/%lu", - min_lsn->file, min_lsn->offset)); + "log_force_sync: sync %s to LSN %d/%lu", + log->log_fh->name, min_lsn->file, min_lsn->offset)); WT_ERR(__wt_fsync(session, log->log_fh)); log->sync_lsn = *min_lsn; WT_STAT_FAST_CONN_INCR(session, log_sync); @@ -147,7 +147,7 @@ err: * must be run in the given variable. */ int -__wt_log_needs_recovery(WT_SESSION_IMPL *session, WT_LSN *ckp_lsn, int *rec) +__wt_log_needs_recovery(WT_SESSION_IMPL *session, WT_LSN *ckp_lsn, bool *recp) { WT_CONNECTION_IMPL *conn; WT_CURSOR *c; @@ -164,7 +164,7 @@ __wt_log_needs_recovery(WT_SESSION_IMPL *session, WT_LSN *ckp_lsn, int *rec) * Default is to run recovery always (regardless of whether this * connection has logging enabled). */ - *rec = 1; + *recp = true; if (log == NULL) return (0); @@ -190,7 +190,7 @@ __wt_log_needs_recovery(WT_SESSION_IMPL *session, WT_LSN *ckp_lsn, int *rec) * If we get to the end of the log, we can skip recovery. */ if (ret == WT_NOTFOUND) { - *rec = 0; + *recp = false; ret = 0; } } else if (ret == WT_NOTFOUND) @@ -256,7 +256,7 @@ __log_get_files(WT_SESSION_IMPL *session, */ int __wt_log_get_all_files(WT_SESSION_IMPL *session, - char ***filesp, u_int *countp, uint32_t *maxid, int active_only) + char ***filesp, u_int *countp, uint32_t *maxid, bool active_only) { WT_DECL_RET; WT_LOG *log; @@ -464,14 +464,11 @@ __log_decrypt(WT_SESSION_IMPL *session, WT_ITEM *in, WT_ITEM *out) */ static int __log_fill(WT_SESSION_IMPL *session, - WT_MYSLOT *myslot, int force, WT_ITEM *record, WT_LSN *lsnp) + WT_MYSLOT *myslot, bool force, WT_ITEM *record, WT_LSN *lsnp) { WT_DECL_RET; WT_LOG_RECORD *logrec; - /* - * The WT_LOG_SLOT_BUF_MAX macro uses log. - */ logrec = (WT_LOG_RECORD *)record->mem; /* * Call __wt_write or copy into the buffer. For now the offset is the @@ -510,7 +507,7 @@ err: */ static int __log_file_header( - WT_SESSION_IMPL *session, WT_FH *fh, WT_LSN *end_lsn, int prealloc) + WT_SESSION_IMPL *session, WT_FH *fh, WT_LSN *end_lsn, bool prealloc) { WT_CONNECTION_IMPL *conn; WT_DECL_ITEM(buf); @@ -561,7 +558,7 @@ __log_file_header( WT_ASSERT(session, fh == NULL); WT_ERR(__wt_log_acquire(session, logrec->len, &tmp)); } - WT_ERR(__log_fill(session, &myslot, 1, buf, NULL)); + WT_ERR(__log_fill(session, &myslot, true, buf, NULL)); /* * Make sure the header gets to disk. */ @@ -579,7 +576,7 @@ err: __wt_scr_free(session, &buf); */ static int __log_openfile(WT_SESSION_IMPL *session, - int ok_create, WT_FH **fh, const char *file_prefix, uint32_t id) + bool ok_create, WT_FH **fh, const char *file_prefix, uint32_t id) { WT_DECL_ITEM(buf); WT_DECL_RET; @@ -598,7 +595,7 @@ __log_openfile(WT_SESSION_IMPL *session, WT_ERR(__wt_verbose(session, WT_VERB_LOG, "opening log %s", (const char *)buf->data)); WT_ERR(__wt_open( - session, buf->data, ok_create, 0, WT_FILE_TYPE_LOG, fh)); + session, buf->data, ok_create, false, WT_FILE_TYPE_LOG, fh)); /* * If we are not creating the log file but opening it for reading, * check that the magic number and versions are correct. @@ -683,18 +680,19 @@ err: __wt_scr_free(session, &from_path); * Create the next log file and write the file header record into it. */ static int -__log_newfile(WT_SESSION_IMPL *session, int conn_open, int *created) +__log_newfile(WT_SESSION_IMPL *session, bool conn_open, bool *created) { WT_CONNECTION_IMPL *conn; WT_DECL_RET; WT_LOG *log; WT_LSN end_lsn; - int create_log, yield_cnt; + int yield_cnt; + bool create_log; conn = S2C(session); log = conn->log; - create_log = 1; + create_log = true; yield_cnt = 0; /* * Set aside the log file handle to be closed later. Other threads @@ -710,6 +708,11 @@ __log_newfile(WT_SESSION_IMPL *session, int conn_open, int *created) return (EBUSY); __wt_yield(); } + /* + * Note, the file server worker thread has code that knows that + * the file handle is set before the LSN. Do not reorder without + * also reviewing that code. + */ log->log_close_fh = log->log_fh; if (log->log_close_fh != NULL) log->log_close_lsn = log->alloc_lsn; @@ -722,7 +725,7 @@ __log_newfile(WT_SESSION_IMPL *session, int conn_open, int *created) * If we're pre-allocating log files, look for one. If there aren't any * or we're not pre-allocating, then create one. */ - if (conn->log_prealloc) { + if (conn->log_prealloc > 0) { ret = __log_alloc_prealloc(session, log->fileid); /* * If ret is 0 it means we found a pre-allocated file. @@ -731,13 +734,19 @@ __log_newfile(WT_SESSION_IMPL *session, int conn_open, int *created) * the new log file. */ if (ret == 0) - create_log = 0; + create_log = false; /* * If we get any error other than WT_NOTFOUND, return it. */ if (ret != 0 && ret != WT_NOTFOUND) return (ret); ret = 0; + if (create_log) { + WT_STAT_FAST_CONN_INCR(session, log_prealloc_missed); + if (conn->log_cond != NULL) + WT_RET(__wt_cond_signal( + session, conn->log_cond)); + } } /* * If we need to create the log file, do so now. @@ -745,10 +754,10 @@ __log_newfile(WT_SESSION_IMPL *session, int conn_open, int *created) if (create_log) { log->prep_missed++; WT_RET(__wt_log_allocfile( - session, log->fileid, WT_LOG_FILENAME, 1)); + session, log->fileid, WT_LOG_FILENAME, true)); } WT_RET(__log_openfile(session, - 0, &log->log_fh, WT_LOG_FILENAME, log->fileid)); + false, &log->log_fh, WT_LOG_FILENAME, log->fileid)); /* * We need to setup the LSNs. Set the end LSN and alloc LSN to * the end of the header. @@ -782,11 +791,11 @@ __wt_log_acquire(WT_SESSION_IMPL *session, uint64_t recsize, WT_LOGSLOT *slot) { WT_CONNECTION_IMPL *conn; WT_LOG *log; - int created_log; + bool created_log; conn = S2C(session); log = conn->log; - created_log = 1; + created_log = true; /* * Add recsize to alloc_lsn. Save our starting LSN * where the previous allocation finished for the release LSN. @@ -798,8 +807,14 @@ __wt_log_acquire(WT_SESSION_IMPL *session, uint64_t recsize, WT_LOGSLOT *slot) * We need to set the release LSN earlier, before a log file change. */ slot->slot_release_lsn = log->alloc_lsn; + /* + * Make sure that the size can fit in the file. Proactively switch + * if it cannot. This reduces, but does not eliminate, log files + * that exceed the maximum file size. We want to minimize the risk + * of an error due to no space. + */ if (!__log_size_fit(session, &log->alloc_lsn, recsize)) { - WT_RET(__log_newfile(session, 0, &created_log)); + WT_RET(__log_newfile(session, false, &created_log)); if (log->log_close_fh != NULL) F_SET(slot, WT_SLOT_CLOSEFH); } @@ -849,7 +864,7 @@ __log_truncate(WT_SESSION_IMPL *session, /* * Truncate the log file to the given LSN. */ - WT_ERR(__log_openfile(session, 0, &log_fh, file_prefix, lsn->file)); + WT_ERR(__log_openfile(session, false, &log_fh, file_prefix, lsn->file)); WT_ERR(__wt_ftruncate(session, log_fh, lsn->offset)); WT_ERR(__wt_fsync(session, log_fh)); WT_ERR(__wt_close(session, &log_fh)); @@ -866,7 +881,7 @@ __log_truncate(WT_SESSION_IMPL *session, WT_ERR(__wt_log_extract_lognum(session, logfiles[i], &lognum)); if (lognum > lsn->file && lognum < log->trunc_lsn.file) { WT_ERR(__log_openfile(session, - 0, &log_fh, file_prefix, lognum)); + false, &log_fh, file_prefix, lognum)); /* * If there are intervening files pre-allocated, * truncate them to the end of the log file header. @@ -890,7 +905,7 @@ err: WT_TRET(__wt_close(session, &log_fh)); */ int __wt_log_allocfile( - WT_SESSION_IMPL *session, uint32_t lognum, const char *dest, int prealloc) + WT_SESSION_IMPL *session, uint32_t lognum, const char *dest, bool prealloc) { WT_CONNECTION_IMPL *conn; WT_DECL_ITEM(from_path); @@ -919,8 +934,8 @@ __wt_log_allocfile( /* * Set up the temporary file. */ - WT_ERR(__log_openfile(session, 1, &log_fh, WT_LOG_TMPNAME, tmp_id)); - WT_ERR(__log_file_header(session, log_fh, NULL, 1)); + WT_ERR(__log_openfile(session, true, &log_fh, WT_LOG_TMPNAME, tmp_id)); + WT_ERR(__log_file_header(session, log_fh, NULL, true)); WT_ERR(__wt_ftruncate(session, log_fh, WT_LOG_FIRST_RECORD)); if (prealloc) WT_ERR(__log_prealloc(session, log_fh)); @@ -991,7 +1006,7 @@ __wt_log_open(WT_SESSION_IMPL *session) WT_RET(__wt_verbose(session, WT_VERB_LOG, "log_open: open fh to directory %s", conn->log_path)); WT_RET(__wt_open(session, conn->log_path, - 0, 0, WT_FILE_TYPE_DIRECTORY, &log->log_dir_fh)); + false, false, WT_FILE_TYPE_DIRECTORY, &log->log_dir_fh)); } /* * Clean up any old interim pre-allocated files. @@ -1040,7 +1055,7 @@ __wt_log_open(WT_SESSION_IMPL *session) * where the previous log file ends. */ WT_WITH_SLOT_LOCK(session, log, - ret = __log_newfile(session, 1, NULL)); + ret = __log_newfile(session, true, NULL)); WT_ERR(ret); /* If we found log files, save the new state. */ @@ -1183,25 +1198,26 @@ err: * Release a log slot. */ int -__wt_log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot, int *freep) +__wt_log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot, bool *freep) { WT_CONNECTION_IMPL *conn; WT_DECL_RET; WT_LOG *log; WT_LSN sync_lsn; - int locked, need_relock, yield_count; int64_t release_buffered, release_bytes; + int yield_count; + bool locked, need_relock; conn = S2C(session); log = conn->log; - locked = need_relock = yield_count = 0; + locked = need_relock = false; + yield_count = 0; if (freep != NULL) *freep = 1; release_buffered = WT_LOG_SLOT_RELEASED_BUFFERED(slot->slot_state); release_bytes = release_buffered + slot->slot_unbuffered; - /* Write the buffered records */ /* * Checkpoints can be configured based on amount of log written. * Add in this log record to the sum and if needed, signal the @@ -1215,6 +1231,7 @@ __wt_log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot, int *freep) WT_RET(__wt_checkpoint_signal(session, log->log_written)); } + /* Write the buffered records */ if (release_buffered != 0) WT_ERR(__wt_write(session, slot->slot_fh, slot->slot_start_offset, @@ -1256,7 +1273,7 @@ __wt_log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot, int *freep) */ if (F_ISSET(session, WT_SESSION_LOCKED_SLOT)) { __wt_spin_unlock(session, &log->log_slot_lock); - need_relock = 1; + need_relock = true; } if (++yield_count < 1000) __wt_yield(); @@ -1265,7 +1282,7 @@ __wt_log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot, int *freep) session, log->log_write_cond, 200)); if (F_ISSET(session, WT_SESSION_LOCKED_SLOT)) { __wt_spin_lock(session, &log->log_slot_lock); - need_relock = 0; + need_relock = false; } } @@ -1298,7 +1315,7 @@ __wt_log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot, int *freep) session, log->log_sync_cond, 10000)); continue; } - locked = 1; + locked = true; /* * Record the current end of our update after the lock. @@ -1315,8 +1332,9 @@ __wt_log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot, int *freep) (log->sync_dir_lsn.file < sync_lsn.file)) { WT_ASSERT(session, log->log_dir_fh != NULL); WT_ERR(__wt_verbose(session, WT_VERB_LOG, - "log_release: sync directory %s", - log->log_dir_fh->name)); + "log_release: sync directory %s to LSN %d/%lu", + log->log_dir_fh->name, + sync_lsn.file, sync_lsn.offset)); WT_ERR(__wt_directory_sync_fh( session, log->log_dir_fh)); log->sync_dir_lsn = sync_lsn; @@ -1329,7 +1347,8 @@ __wt_log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot, int *freep) if (F_ISSET(slot, WT_SLOT_SYNC) && __wt_log_cmp(&log->sync_lsn, &slot->slot_end_lsn) < 0) { WT_ERR(__wt_verbose(session, WT_VERB_LOG, - "log_release: sync log %s", log->log_fh->name)); + "log_release: sync log %s to LSN %d/%lu", + log->log_fh->name, sync_lsn.file, sync_lsn.offset)); WT_STAT_FAST_CONN_INCR(session, log_sync); WT_ERR(__wt_fsync(session, log->log_fh)); log->sync_lsn = sync_lsn; @@ -1339,9 +1358,8 @@ __wt_log_release(WT_SESSION_IMPL *session, WT_LOGSLOT *slot, int *freep) * Clear the flags before leaving the loop. */ F_CLR(slot, WT_SLOT_SYNC | WT_SLOT_SYNC_DIR); - locked = 0; + locked = false; __wt_spin_unlock(session, &log->log_sync_lock); - break; } err: if (locked) __wt_spin_unlock(session, &log->log_sync_lock); @@ -1376,7 +1394,8 @@ __wt_log_scan(WT_SESSION_IMPL *session, WT_LSN *lsnp, uint32_t flags, wt_off_t log_size; uint32_t allocsize, cksum, firstlog, lastlog, lognum, rdup_len, reclen; u_int i, logcount; - int eol, firstrecord; + int firstrecord; + bool eol; char **logfiles; conn = S2C(session); @@ -1384,7 +1403,7 @@ __wt_log_scan(WT_SESSION_IMPL *session, WT_LSN *lsnp, uint32_t flags, log_fh = NULL; logcount = 0; logfiles = NULL; - eol = 0; + eol = false; firstrecord = 1; /* @@ -1463,7 +1482,7 @@ __wt_log_scan(WT_SESSION_IMPL *session, WT_LSN *lsnp, uint32_t flags, logfiles = NULL; } WT_ERR(__log_openfile( - session, 0, &log_fh, WT_LOG_FILENAME, start_lsn.file)); + session, false, &log_fh, WT_LOG_FILENAME, start_lsn.file)); WT_ERR(__log_filesize(session, log_fh, &log_size)); rd_lsn = start_lsn; @@ -1478,7 +1497,7 @@ advance: */ WT_ERR(__wt_close(session, &log_fh)); log_fh = NULL; - eol = 1; + eol = true; /* * Truncate this log file before we move to the next. */ @@ -1493,10 +1512,10 @@ advance: */ if (rd_lsn.file > end_lsn.file) break; - WT_ERR(__log_openfile( - session, 0, &log_fh, WT_LOG_FILENAME, rd_lsn.file)); + WT_ERR(__log_openfile(session, + false, &log_fh, WT_LOG_FILENAME, rd_lsn.file)); WT_ERR(__log_filesize(session, log_fh, &log_size)); - eol = 0; + eol = false; continue; } /* @@ -1521,7 +1540,7 @@ advance: */ if (reclen == 0) { /* This LSN is the end. */ - eol = 1; + eol = true; break; } rdup_len = __wt_rduppo2(reclen, allocsize); @@ -1638,7 +1657,7 @@ err: WT_STAT_FAST_CONN_INCR(session, log_scans); * Wrapper function that takes the lock. */ int -__wt_log_force_write(WT_SESSION_IMPL *session, int retry) +__wt_log_force_write(WT_SESSION_IMPL *session, bool retry) { WT_LOG *log; WT_MYSLOT myslot; @@ -1646,7 +1665,7 @@ __wt_log_force_write(WT_SESSION_IMPL *session, int retry) log = S2C(session)->log; memset(&myslot, 0, sizeof(myslot)); myslot.slot = log->active_slot; - return (__wt_log_slot_switch(session, &myslot, retry, 1)); + return (__wt_log_slot_switch(session, &myslot, retry, true)); } /* @@ -1794,11 +1813,16 @@ __log_write_internal(WT_SESSION_IMPL *session, WT_ITEM *record, WT_LSN *lsnp, WT_MYSLOT myslot; int64_t release_size; uint32_t force, rdup_len; - int free_slot; + bool free_slot; conn = S2C(session); log = conn->log; - free_slot = 0; + if (record->size > UINT32_MAX) { + __wt_errx(session, "Log record size of %" WT_SIZET_FMT + " exceeds the maximum supported size of %" PRIu32, + record->size, UINT32_MAX); + return (EFBIG); + } WT_INIT_LSN(&lsn); myslot.slot = NULL; memset(&myslot, 0, sizeof(myslot)); @@ -1840,9 +1864,9 @@ __log_write_internal(WT_SESSION_IMPL *session, WT_ITEM *record, WT_LSN *lsnp, ret = 0; if (myslot.end_offset >= WT_LOG_SLOT_BUF_MAX || F_ISSET(&myslot, WT_MYSLOT_UNBUFFERED) || force) - ret = __wt_log_slot_switch(session, &myslot, 1, 0); + ret = __wt_log_slot_switch(session, &myslot, true, false); if (ret == 0) - ret = __log_fill(session, &myslot, 0, record, &lsn); + ret = __log_fill(session, &myslot, false, record, &lsn); release_size = __wt_log_slot_release( session, &myslot, (int64_t)rdup_len); /* @@ -1972,15 +1996,22 @@ __wt_log_flush(WT_SESSION_IMPL *session, uint32_t flags) conn = S2C(session); WT_ASSERT(session, FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED)); log = conn->log; + /* + * We need to flush out the current slot first to get the real + * end of log LSN in log->alloc_lsn. + */ + WT_RET(__wt_log_flush_lsn(session, &lsn, 0)); last_lsn = log->alloc_lsn; - lsn = log->write_lsn; + /* * Wait until all current outstanding writes have been written * to the file system. */ while (__wt_log_cmp(&last_lsn, &lsn) > 0) - WT_RET(__wt_log_flush_lsn(session, &lsn, 0)); + WT_RET(__wt_log_flush_lsn(session, &lsn, false)); + WT_RET(__wt_verbose(session, WT_VERB_LOG, + "log_flush: flags %d LSN %d/%lu", flags, lsn.file, lsn.offset)); /* * If the user wants write-no-sync, there is nothing more to do. * If the user wants background sync, set the LSN and we're done. diff --git a/src/third_party/wiredtiger/src/log/log_auto.c b/src/third_party/wiredtiger/src/log/log_auto.c index 4f1dd1c0baf..5a1d03b1976 100644 --- a/src/third_party/wiredtiger/src/log/log_auto.c +++ b/src/third_party/wiredtiger/src/log/log_auto.c @@ -52,7 +52,8 @@ __logrec_json_unpack_str(char *dest, size_t destlen, const char *src, total = 0; while (srclen > 0) { - n = __wt_json_unpack_char(*src++, (u_char *)dest, destlen, 0); + n = __wt_json_unpack_char( + *src++, (u_char *)dest, destlen, false); srclen--; if (n > destlen) destlen = 0; diff --git a/src/third_party/wiredtiger/src/log/log_slot.c b/src/third_party/wiredtiger/src/log/log_slot.c index 0d6555f8973..fcfa1d242c6 100644 --- a/src/third_party/wiredtiger/src/log/log_slot.c +++ b/src/third_party/wiredtiger/src/log/log_slot.c @@ -22,32 +22,38 @@ __wt_log_slot_activate(WT_SESSION_IMPL *session, WT_LOGSLOT *slot) log = conn->log; slot->slot_state = 0; + /* + * !!! slot_release_lsn must be set outside this function because + * this function may be called after a log file switch and the + * slot_release_lsn must refer to the end of the previous log. + */ slot->slot_start_lsn = slot->slot_end_lsn = log->alloc_lsn; slot->slot_start_offset = log->alloc_lsn.offset; slot->slot_last_offset = log->alloc_lsn.offset; slot->slot_fh = log->log_fh; slot->slot_error = 0; slot->slot_unbuffered = 0; + slot->flags = WT_SLOT_INIT_FLAGS; } /* - * __wt_log_slot_close -- + * __log_slot_close -- * Close out the slot the caller is using. The slot may already be * closed or freed by another thread. */ -int -__wt_log_slot_close( - WT_SESSION_IMPL *session, WT_LOGSLOT *slot, int *releasep, int forced) +static int +__log_slot_close( + WT_SESSION_IMPL *session, WT_LOGSLOT *slot, bool *releasep, bool forced) { WT_CONNECTION_IMPL *conn; WT_LOG *log; int64_t end_offset, new_state, old_state; WT_ASSERT(session, F_ISSET(session, WT_SESSION_LOCKED_SLOT)); + WT_ASSERT(session, releasep != NULL); conn = S2C(session); log = conn->log; - if (releasep != NULL) - *releasep = 0; + *releasep = 0; if (slot == NULL) return (WT_NOTFOUND); retry: @@ -83,7 +89,7 @@ retry: * Set the end LSN. */ WT_STAT_FAST_CONN_INCR(session, log_slot_closes); - if (WT_LOG_SLOT_DONE(new_state) && releasep != NULL) + if (WT_LOG_SLOT_DONE(new_state)) *releasep = 1; slot->slot_end_lsn = slot->slot_start_lsn; end_offset = @@ -105,15 +111,15 @@ retry: */ static int __log_slot_switch_internal( - WT_SESSION_IMPL *session, WT_MYSLOT *myslot, int forced) + WT_SESSION_IMPL *session, WT_MYSLOT *myslot, bool forced) { WT_DECL_RET; WT_LOG *log; WT_LOGSLOT *slot; - int free_slot, release; + bool free_slot, release; log = S2C(session)->log; - release = 0; + release = false; slot = myslot->slot; WT_ASSERT(session, F_ISSET(session, WT_SESSION_LOCKED_SLOT)); @@ -126,13 +132,16 @@ __log_slot_switch_internal( return (0); /* - * If close returns WT_NOTFOUND, it means that someone else is - * processing the slot change. However, we could have retried - * from a busy time creating a new slot. If so, we are that - * someone else and we need to try setting up a new slot again. + * We may come through here multiple times if we were able to close + * a slot but could not set up a new one. If we closed it already, + * don't try to do it again but still set up the new slot. */ if (!F_ISSET(myslot, WT_MYSLOT_CLOSE)) { - ret = __wt_log_slot_close(session, slot, &release, forced); + ret = __log_slot_close(session, slot, &release, forced); + /* + * If close returns WT_NOTFOUND it means that someone else + * is processing the slot change. + */ if (ret == WT_NOTFOUND) return (0); WT_RET(ret); @@ -158,7 +167,7 @@ __log_slot_switch_internal( */ int __wt_log_slot_switch( - WT_SESSION_IMPL *session, WT_MYSLOT *myslot, int retry, int forced) + WT_SESSION_IMPL *session, WT_MYSLOT *myslot, bool retry, bool forced) { WT_DECL_RET; WT_LOG *log; @@ -168,6 +177,12 @@ __wt_log_slot_switch( * !!! Since the WT_WITH_SLOT_LOCK macro is a do-while loop, the * compiler does not like it combined directly with the while loop * here. + * + * The loop conditional is a bit complex. We have to retry if we + * closed the slot but were unable to set up a new slot. In that + * case the flag indicating we have closed the slot will still be set. + * We have to retry in that case regardless of the retry setting + * because we are responsible for setting up the new slot. */ do { WT_WITH_SLOT_LOCK(session, log, @@ -217,19 +232,13 @@ __wt_log_slot_new(WT_SESSION_IMPL *session) slot = &log->slot_pool[i]; if (slot->slot_state == WT_LOG_SLOT_FREE) { /* - * Make sure that the next buffer size can - * fit in the file. Proactively switch if - * it cannot. This reduces, but does not - * eliminate, log files that exceed the - * maximum file size. - * - * We want to minimize the risk of an - * error due to no space. + * Acquire our starting position in the + * log file. Assume the full buffer size. */ WT_RET(__wt_log_acquire(session, log->slot_buf_size, slot)); /* - * We have a new, free slot to use. + * We have a new, initialized slot to use. * Set it as the active slot. */ WT_STAT_FAST_CONN_INCR(session, @@ -267,20 +276,16 @@ __wt_log_slot_init(WT_SESSION_IMPL *session) log->slot_pool[i].slot_state = WT_LOG_SLOT_FREE; /* - * Allocate memory for buffers now that the arrays are setup. Split - * this out to make error handling simpler. + * Allocate memory for buffers now that the arrays are setup. Separate + * this from the loop above to make error handling simpler. */ /* - * Cap the slot buffer to the log file size times two if needed. - * That means we try to fill to half the buffer but allow some - * extra space. - * * !!! If the buffer size is too close to the log file size, we will * switch log files very aggressively. Scale back the buffer for * small log file sizes. */ log->slot_buf_size = (uint32_t)WT_MIN( - (size_t)conn->log_file_max/10, WT_LOG_SLOT_BUF_SIZE); + (size_t)conn->log_file_max / 10, WT_LOG_SLOT_BUF_SIZE); for (i = 0; i < WT_SLOT_POOL; i++) { WT_ERR(__wt_buf_init(session, &log->slot_pool[i].slot_buf, log->slot_buf_size)); @@ -294,7 +299,7 @@ __wt_log_slot_init(WT_SESSION_IMPL *session) slot = &log->slot_pool[0]; /* * We cannot initialize the release LSN in the activate function - * because that is called after a log file switch. + * because that function can be called after a log file switch. */ slot->slot_release_lsn = log->alloc_lsn; __wt_log_slot_activate(session, slot); @@ -356,7 +361,7 @@ __wt_log_slot_join(WT_SESSION_IMPL *session, uint64_t mysize, int64_t flag_state, new_state, old_state, released; int32_t join_offset, new_join; #ifdef HAVE_DIAGNOSTIC - int unbuf_force; + bool unbuf_force; #endif conn = S2C(session); @@ -373,7 +378,7 @@ __wt_log_slot_join(WT_SESSION_IMPL *session, uint64_t mysize, * There should almost always be a slot open. */ #ifdef HAVE_DIAGNOSTIC - unbuf_force = ((++log->write_calls % 1000) == 0); + unbuf_force = (++log->write_calls % 1000) == 0; #endif for (;;) { WT_BARRIER(); @@ -479,14 +484,6 @@ __wt_log_slot_release(WT_SESSION_IMPL *session, WT_MYSLOT *myslot, int64_t size) void __wt_log_slot_free(WT_SESSION_IMPL *session, WT_LOGSLOT *slot) { - - /* - * Make sure flags don't get retained between uses. - * We have to reset them them here because multiple threads may - * change the flags when joining the slot. - */ WT_UNUSED(session); - slot->flags = WT_SLOT_INIT_FLAGS; - slot->slot_error = 0; slot->slot_state = WT_LOG_SLOT_FREE; } diff --git a/src/third_party/wiredtiger/src/lsm/lsm_cursor.c b/src/third_party/wiredtiger/src/lsm/lsm_cursor.c index 6068bb6c559..cca417a31fc 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_cursor.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_cursor.c @@ -16,7 +16,7 @@ __wt_compare(s, (lsm_tree)->collator, &(c1)->key, &(c2)->key, &cmp) static int __clsm_lookup(WT_CURSOR_LSM *, WT_ITEM *); -static int __clsm_open_cursors(WT_CURSOR_LSM *, int, u_int, uint32_t); +static int __clsm_open_cursors(WT_CURSOR_LSM *, bool, u_int, uint32_t); static int __clsm_reset_cursors(WT_CURSOR_LSM *, WT_CURSOR *); /* @@ -100,15 +100,15 @@ __clsm_enter_update(WT_CURSOR_LSM *clsm) WT_LSM_CHUNK *primary_chunk; WT_LSM_TREE *lsm_tree; WT_SESSION_IMPL *session; - int hard_limit, have_primary, ovfl; + bool hard_limit, have_primary, ovfl; lsm_tree = clsm->lsm_tree; - ovfl = 0; + ovfl = false; session = (WT_SESSION_IMPL *)clsm->iface.session; if (clsm->nchunks == 0) { primary = NULL; - have_primary = 0; + have_primary = false; } else { primary = clsm->cursors[clsm->nchunks - 1]; primary_chunk = clsm->primary_chunk; @@ -129,7 +129,7 @@ __clsm_enter_update(WT_CURSOR_LSM *clsm) * chunk grows twice as large as the configured size, block until it * can be switched. */ - hard_limit = F_ISSET(lsm_tree, WT_LSM_TREE_NEED_SWITCH) ? 1 : 0; + hard_limit = F_ISSET(lsm_tree, WT_LSM_TREE_NEED_SWITCH); if (have_primary) { WT_ENTER_PAGE_INDEX(session); @@ -160,7 +160,7 @@ __clsm_enter_update(WT_CURSOR_LSM *clsm) * Start an operation on an LSM cursor, update if the tree has changed. */ static inline int -__clsm_enter(WT_CURSOR_LSM *clsm, int reset, int update) +__clsm_enter(WT_CURSOR_LSM *clsm, bool reset, bool update) { WT_DECL_RET; WT_LSM_TREE *lsm_tree; @@ -297,7 +297,7 @@ static const WT_ITEM __tombstone = { "\x14\x14", 2, 0, NULL, 0 }; * __clsm_deleted -- * Check whether the current value is a tombstone. */ -static inline int +static inline bool __clsm_deleted(WT_CURSOR_LSM *clsm, const WT_ITEM *item) { return (!F_ISSET(clsm, WT_CLSM_MINOR_MERGE) && @@ -394,7 +394,7 @@ __clsm_close_cursors(WT_CURSOR_LSM *clsm, u_int start, u_int end) */ static int __clsm_open_cursors( - WT_CURSOR_LSM *clsm, int update, u_int start_chunk, uint32_t start_id) + WT_CURSOR_LSM *clsm, bool update, u_int start_chunk, uint32_t start_id) { WT_BTREE *btree; WT_CURSOR *c, **cp, *primary; @@ -407,13 +407,13 @@ __clsm_open_cursors( uint64_t saved_gen; u_int i, nchunks, ngood, nupdates; u_int close_range_end, close_range_start; - int locked; + bool locked; c = &clsm->iface; session = (WT_SESSION_IMPL *)c->session; txn = &session->txn; chunk = NULL; - locked = 0; + locked = false; lsm_tree = clsm->lsm_tree; /* @@ -447,7 +447,7 @@ __clsm_open_cursors( F_CLR(clsm, WT_CLSM_ITERATE_NEXT | WT_CLSM_ITERATE_PREV); WT_RET(__wt_lsm_tree_readlock(session, lsm_tree)); - locked = 1; + locked = true; /* Merge cursors have already figured out how many chunks they need. */ retry: if (F_ISSET(clsm, WT_CLSM_MERGE)) { @@ -564,12 +564,12 @@ retry: if (F_ISSET(clsm, WT_CLSM_MERGE)) { } if (close_range_end > close_range_start) { saved_gen = lsm_tree->dsk_gen; - locked = 0; + locked = false; WT_ERR(__wt_lsm_tree_readunlock(session, lsm_tree)); WT_ERR(__clsm_close_cursors( clsm, close_range_start, close_range_end)); WT_ERR(__wt_lsm_tree_readlock(session, lsm_tree)); - locked = 1; + locked = true; if (lsm_tree->dsk_gen != saved_gen) goto retry; } @@ -648,9 +648,9 @@ retry: if (F_ISSET(clsm, WT_CLSM_MERGE)) { */ btree = ((WT_CURSOR_BTREE *)(primary))->btree; if (btree->bulk_load_ok) { - btree->bulk_load_ok = 0; + btree->bulk_load_ok = false; WT_WITH_BTREE(session, btree, - __wt_btree_evictable(session, 0)); + __wt_btree_evictable(session, false)); } } @@ -711,7 +711,7 @@ __wt_clsm_init_merge( clsm->nchunks = nchunks; WT_WITH_SCHEMA_LOCK(session, - ret = __clsm_open_cursors(clsm, 0, start_chunk, start_id)); + ret = __clsm_open_cursors(clsm, false, start_chunk, start_id)); return (ret); } @@ -720,15 +720,16 @@ __wt_clsm_init_merge( * Find the smallest / largest of the cursors and copy its key/value. */ static int -__clsm_get_current( - WT_SESSION_IMPL *session, WT_CURSOR_LSM *clsm, int smallest, int *deletedp) +__clsm_get_current(WT_SESSION_IMPL *session, + WT_CURSOR_LSM *clsm, bool smallest, bool *deletedp) { WT_CURSOR *c, *current; - int cmp, multiple; + int cmp; u_int i; + bool multiple; current = NULL; - multiple = 0; + multiple = false; WT_FORALL_CURSORS(clsm, c, i) { if (!F_ISSET(c, WT_CURSTD_KEY_INT)) @@ -740,9 +741,9 @@ __clsm_get_current( WT_RET(WT_LSM_CURCMP(session, clsm->lsm_tree, c, current, cmp)); if (smallest ? cmp < 0 : cmp > 0) { current = c; - multiple = 0; + multiple = false; } else if (cmp == 0) - multiple = 1; + multiple = true; } c = &clsm->iface; @@ -760,7 +761,7 @@ __clsm_get_current( WT_RET(current->get_value(current, &c->value)); F_CLR(c, WT_CURSTD_KEY_SET | WT_CURSTD_VALUE_SET); - if ((*deletedp = __clsm_deleted(clsm, &c->value)) == 0) + if ((*deletedp = __clsm_deleted(clsm, &c->value)) == false) F_SET(c, WT_CURSTD_KEY_INT | WT_CURSTD_VALUE_INT); return (0); @@ -810,13 +811,14 @@ __clsm_next(WT_CURSOR *cursor) WT_DECL_RET; WT_SESSION_IMPL *session; u_int i; - int check, cmp, deleted; + int cmp; + bool check, deleted; clsm = (WT_CURSOR_LSM *)cursor; CURSOR_API_CALL(cursor, session, next, NULL); WT_CURSOR_NOVALUE(cursor); - WT_ERR(__clsm_enter(clsm, 0, 0)); + WT_ERR(__clsm_enter(clsm, false, false)); /* If we aren't positioned for a forward scan, get started. */ if (clsm->current == NULL || !F_ISSET(clsm, WT_CLSM_ITERATE_NEXT)) { @@ -854,7 +856,7 @@ retry: /* * forward. */ if (F_ISSET(clsm, WT_CLSM_MULTIPLE)) { - check = 0; + check = false; WT_FORALL_CURSORS(clsm, c, i) { if (!F_ISSET(c, WT_CURSTD_KEY_INT)) continue; @@ -866,7 +868,7 @@ retry: /* WT_ERR_NOTFOUND_OK(c->next(c)); } if (c == clsm->current) - check = 1; + check = true; } } @@ -876,7 +878,7 @@ retry: /* } /* Find the cursor(s) with the smallest key. */ - if ((ret = __clsm_get_current(session, clsm, 1, &deleted)) == 0 && + if ((ret = __clsm_get_current(session, clsm, true, &deleted)) == 0 && deleted) goto retry; @@ -899,13 +901,14 @@ __clsm_prev(WT_CURSOR *cursor) WT_DECL_RET; WT_SESSION_IMPL *session; u_int i; - int check, cmp, deleted; + int cmp; + bool check, deleted; clsm = (WT_CURSOR_LSM *)cursor; CURSOR_API_CALL(cursor, session, prev, NULL); WT_CURSOR_NOVALUE(cursor); - WT_ERR(__clsm_enter(clsm, 0, 0)); + WT_ERR(__clsm_enter(clsm, false, false)); /* If we aren't positioned for a reverse scan, get started. */ if (clsm->current == NULL || !F_ISSET(clsm, WT_CLSM_ITERATE_PREV)) { @@ -942,7 +945,7 @@ retry: /* * backwards. */ if (F_ISSET(clsm, WT_CLSM_MULTIPLE)) { - check = 0; + check = false; WT_FORALL_CURSORS(clsm, c, i) { if (!F_ISSET(c, WT_CURSTD_KEY_INT)) continue; @@ -954,7 +957,7 @@ retry: /* WT_ERR_NOTFOUND_OK(c->prev(c)); } if (c == clsm->current) - check = 1; + check = true; } } @@ -964,7 +967,7 @@ retry: /* } /* Find the cursor(s) with the largest key. */ - if ((ret = __clsm_get_current(session, clsm, 0, &deleted)) == 0 && + if ((ret = __clsm_get_current(session, clsm, false, &deleted)) == 0 && deleted) goto retry; @@ -1047,11 +1050,11 @@ __clsm_lookup(WT_CURSOR_LSM *clsm, WT_ITEM *value) WT_DECL_RET; WT_SESSION_IMPL *session; u_int i; - int have_hash; + bool have_hash; c = NULL; cursor = &clsm->iface; - have_hash = 0; + have_hash = false; session = (WT_SESSION_IMPL *)cursor->session; WT_FORALL_CURSORS(clsm, c, i) { @@ -1061,7 +1064,7 @@ __clsm_lookup(WT_CURSOR_LSM *clsm, WT_ITEM *value) if (!have_hash) { WT_ERR(__wt_bloom_hash( bloom, &cursor->key, &bhash)); - have_hash = 1; + have_hash = true; } ret = __wt_bloom_hash_get(bloom, &bhash); @@ -1123,7 +1126,7 @@ __clsm_search(WT_CURSOR *cursor) CURSOR_API_CALL(cursor, session, search, NULL); WT_CURSOR_NEEDKEY(cursor); WT_CURSOR_NOVALUE(cursor); - WT_ERR(__clsm_enter(clsm, 1, 0)); + WT_ERR(__clsm_enter(clsm, true, false)); ret = __clsm_lookup(clsm, &cursor->value); @@ -1146,16 +1149,18 @@ __clsm_search_near(WT_CURSOR *cursor, int *exactp) WT_DECL_RET; WT_SESSION_IMPL *session; u_int i; - int cmp, deleted, exact; + int cmp, exact; + bool deleted; closest = NULL; clsm = (WT_CURSOR_LSM *)cursor; - deleted = exact = 0; + exact = 0; + deleted = false; CURSOR_API_CALL(cursor, session, search_near, NULL); WT_CURSOR_NEEDKEY(cursor); WT_CURSOR_NOVALUE(cursor); - WT_ERR(__clsm_enter(clsm, 1, 0)); + WT_ERR(__clsm_enter(clsm, true, false)); F_CLR(clsm, WT_CLSM_ITERATE_NEXT | WT_CLSM_ITERATE_PREV); /* @@ -1224,7 +1229,7 @@ __clsm_search_near(WT_CURSOR *cursor, int *exactp) * end up with WT_NOTFOUND, as expected. */ if (closest == NULL) - deleted = 1; + deleted = true; else { WT_ERR(closest->get_key(closest, &cursor->key)); WT_ERR(closest->get_value(closest, &cursor->value)); @@ -1246,7 +1251,7 @@ __clsm_search_near(WT_CURSOR *cursor, int *exactp) F_SET(cursor, WT_CURSTD_KEY_INT); if ((ret = cursor->next(cursor)) == 0) { cmp = 1; - deleted = 0; + deleted = false; } } WT_ERR_NOTFOUND_OK(ret); @@ -1278,8 +1283,8 @@ err: __clsm_leave(clsm); * necessary. */ static inline int -__clsm_put(WT_SESSION_IMPL *session, - WT_CURSOR_LSM *clsm, const WT_ITEM *key, const WT_ITEM *value, int position) +__clsm_put(WT_SESSION_IMPL *session, WT_CURSOR_LSM *clsm, + const WT_ITEM *key, const WT_ITEM *value, bool position) { WT_CURSOR *c, *primary; WT_LSM_TREE *lsm_tree; @@ -1364,7 +1369,7 @@ __clsm_insert(WT_CURSOR *cursor) CURSOR_UPDATE_API_CALL(cursor, session, insert, NULL); WT_CURSOR_NEEDKEY(cursor); WT_CURSOR_NEEDVALUE(cursor); - WT_ERR(__clsm_enter(clsm, 0, 1)); + WT_ERR(__clsm_enter(clsm, false, true)); if (!F_ISSET(cursor, WT_CURSTD_OVERWRITE) && (ret = __clsm_lookup(clsm, &value)) != WT_NOTFOUND) { @@ -1374,7 +1379,7 @@ __clsm_insert(WT_CURSOR *cursor) } WT_ERR(__clsm_deleted_encode(session, &cursor->value, &value, &buf)); - ret = __clsm_put(session, clsm, &cursor->key, &value, 0); + ret = __clsm_put(session, clsm, &cursor->key, &value, false); err: __wt_scr_free(session, &buf); __clsm_leave(clsm); @@ -1400,13 +1405,13 @@ __clsm_update(WT_CURSOR *cursor) CURSOR_UPDATE_API_CALL(cursor, session, update, NULL); WT_CURSOR_NEEDKEY(cursor); WT_CURSOR_NEEDVALUE(cursor); - WT_ERR(__clsm_enter(clsm, 0, 1)); + WT_ERR(__clsm_enter(clsm, false, true)); if (F_ISSET(cursor, WT_CURSTD_OVERWRITE) || (ret = __clsm_lookup(clsm, &value)) == 0) { WT_ERR(__clsm_deleted_encode( session, &cursor->value, &value, &buf)); - ret = __clsm_put(session, clsm, &cursor->key, &value, 1); + ret = __clsm_put(session, clsm, &cursor->key, &value, true); } err: __wt_scr_free(session, &buf); @@ -1432,11 +1437,12 @@ __clsm_remove(WT_CURSOR *cursor) CURSOR_UPDATE_API_CALL(cursor, session, remove, NULL); WT_CURSOR_NEEDKEY(cursor); WT_CURSOR_NOVALUE(cursor); - WT_ERR(__clsm_enter(clsm, 0, 1)); + WT_ERR(__clsm_enter(clsm, false, true)); if (F_ISSET(cursor, WT_CURSTD_OVERWRITE) || (ret = __clsm_lookup(clsm, &value)) == 0) - ret = __clsm_put(session, clsm, &cursor->key, &__tombstone, 1); + ret = __clsm_put( + session, clsm, &cursor->key, &__tombstone, true); err: __clsm_leave(clsm); CURSOR_UPDATE_API_END(session, ret); @@ -1507,9 +1513,8 @@ __wt_clsm_open(WT_SESSION_IMPL *session, WT_CURSOR_LSM *clsm; WT_DECL_RET; WT_LSM_TREE *lsm_tree; - int bulk; + bool bulk; - bulk = 0; clsm = NULL; cursor = NULL; lsm_tree = NULL; @@ -1523,8 +1528,7 @@ __wt_clsm_open(WT_SESSION_IMPL *session, "LSM does not support opening by checkpoint"); WT_RET(__wt_config_gets_def(session, cfg, "bulk", 0, &cval)); - if (cval.val != 0) - bulk = 1; + bulk = cval.val != 0; /* Get the LSM tree. */ WT_WITH_HANDLE_LIST_LOCK(session, diff --git a/src/third_party/wiredtiger/src/lsm/lsm_cursor_bulk.c b/src/third_party/wiredtiger/src/lsm/lsm_cursor_bulk.c index ef1c124111f..65e8fe1e9a7 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_cursor_bulk.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_cursor_bulk.c @@ -91,6 +91,7 @@ int __wt_clsm_open_bulk(WT_CURSOR_LSM *clsm, const char *cfg[]) { WT_CURSOR *cursor, *bulk_cursor; + WT_DECL_RET; WT_LSM_TREE *lsm_tree; WT_SESSION_IMPL *session; @@ -106,17 +107,16 @@ __wt_clsm_open_bulk(WT_CURSOR_LSM *clsm, const char *cfg[]) cursor->insert = __clsm_insert_bulk; cursor->close = __clsm_close_bulk; - /* Setup the first chunk in the tree. */ - WT_RET(__wt_clsm_request_switch(clsm)); - WT_RET(__wt_clsm_await_switch(clsm)); - /* - * Grab and release the LSM tree lock to ensure that the first chunk - * has been fully created before proceeding. We have the LSM tree - * open exclusive, so that saves us from needing the lock generally. + * Setup the first chunk in the tree. This is the only time we switch + * without using the LSM worker threads, it's safe to do here since + * we have an exclusive lock on the LSM tree. We need to do this + * switch inline, since switch needs a schema lock and online index + * creation opens a bulk cursor while holding the schema lock. */ - WT_RET(__wt_lsm_tree_readlock(session, lsm_tree)); - WT_RET(__wt_lsm_tree_readunlock(session, lsm_tree)); + WT_WITH_SCHEMA_LOCK(session, + ret = __wt_lsm_tree_switch(session, lsm_tree)); + WT_RET(ret); /* * Open a bulk cursor on the first chunk, it's not a regular LSM chunk diff --git a/src/third_party/wiredtiger/src/lsm/lsm_manager.c b/src/third_party/wiredtiger/src/lsm/lsm_manager.c index 6c59232b619..bd3adb3a528 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_manager.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_manager.c @@ -225,7 +225,7 @@ __wt_lsm_manager_start(WT_SESSION_IMPL *session) */ for (i = 0; i < WT_LSM_MAX_WORKERS; i++) { WT_ERR(__wt_open_internal_session( - S2C(session), "lsm-worker", 1, 0, &worker_session)); + S2C(session), "lsm-worker", true, false, &worker_session)); worker_session->isolation = WT_ISO_READ_UNCOMMITTED; manager->lsm_worker_cookies[i].session = worker_session; } @@ -369,10 +369,10 @@ __lsm_manager_run_server(WT_SESSION_IMPL *session) WT_LSM_TREE *lsm_tree; struct timespec now; uint64_t fillms, pushms; - int dhandle_locked; + bool dhandle_locked; conn = S2C(session); - dhandle_locked = 0; + dhandle_locked = false; while (F_ISSET(conn, WT_CONN_SERVER_RUN)) { __wt_sleep(0, 10000); @@ -380,7 +380,7 @@ __lsm_manager_run_server(WT_SESSION_IMPL *session) continue; __wt_spin_lock(session, &conn->dhandle_lock); F_SET(session, WT_SESSION_LOCKED_HANDLE_LIST); - dhandle_locked = 1; + dhandle_locked = true; TAILQ_FOREACH(lsm_tree, &S2C(session)->lsmqh, q) { if (!F_ISSET(lsm_tree, WT_LSM_TREE_ACTIVE)) continue; @@ -440,7 +440,7 @@ __lsm_manager_run_server(WT_SESSION_IMPL *session) } __wt_spin_unlock(session, &conn->dhandle_lock); F_CLR(session, WT_SESSION_LOCKED_HANDLE_LIST); - dhandle_locked = 0; + dhandle_locked = false; } err: if (dhandle_locked) { @@ -611,7 +611,7 @@ __wt_lsm_manager_push_entry(WT_SESSION_IMPL *session, WT_DECL_RET; WT_LSM_MANAGER *manager; WT_LSM_WORK_UNIT *entry; - int pushed; + bool pushed; manager = &S2C(session)->lsm_manager; @@ -645,7 +645,7 @@ __wt_lsm_manager_push_entry(WT_SESSION_IMPL *session, return (0); } - pushed = 0; + pushed = false; WT_ERR(__wt_epoch(session, &lsm_tree->work_push_ts)); WT_ERR(__wt_calloc_one(session, &entry)); entry->type = type; @@ -662,7 +662,7 @@ __wt_lsm_manager_push_entry(WT_SESSION_IMPL *session, else LSM_PUSH_ENTRY(&manager->appqh, &manager->app_lock, lsm_work_queue_app); - pushed = 1; + pushed = true; WT_ERR(__wt_cond_signal(session, manager->work_cond)); return (0); diff --git a/src/third_party/wiredtiger/src/lsm/lsm_merge.c b/src/third_party/wiredtiger/src/lsm/lsm_merge.c index 01a61359949..dd1419fe67d 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_merge.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_merge.c @@ -353,21 +353,18 @@ __wt_lsm_merge(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, u_int id) WT_LSM_CHUNK *chunk; uint32_t generation; uint64_t insert_count, record_count; - u_int dest_id, end_chunk, i, nchunks, start_chunk, start_id; - u_int created_chunk, verb; - int create_bloom, locked, in_sync, tret; + u_int dest_id, end_chunk, i, nchunks, start_chunk, start_id, verb; + int tret; + bool created_chunk, create_bloom, locked, in_sync; const char *cfg[3]; const char *drop_cfg[] = { WT_CONFIG_BASE(session, WT_SESSION_drop), "force", NULL }; bloom = NULL; chunk = NULL; - create_bloom = 0; - created_chunk = 0; dest = src = NULL; - locked = 0; start_id = 0; - in_sync = 0; + created_chunk = create_bloom = locked = in_sync = false; /* Fast path if it's obvious no merges could be done. */ if (lsm_tree->nchunks < lsm_tree->merge_min && @@ -380,7 +377,7 @@ __wt_lsm_merge(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, u_int id) * long time. */ WT_RET(__wt_lsm_tree_writelock(session, lsm_tree)); - locked = 1; + locked = true; WT_ERR(__lsm_merge_span(session, lsm_tree, id, &start_chunk, &end_chunk, &record_count)); @@ -395,7 +392,7 @@ __wt_lsm_merge(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, u_int id) lsm_tree->chunk[start_chunk + i]->generation + 1); WT_ERR(__wt_lsm_tree_writeunlock(session, lsm_tree)); - locked = 0; + locked = false; /* Allocate an ID for the merge. */ dest_id = __wt_atomic_add32(&lsm_tree->last, 1); @@ -422,13 +419,13 @@ __wt_lsm_merge(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, u_int id) } WT_ERR(__wt_calloc_one(session, &chunk)); - created_chunk = 1; + created_chunk = true; chunk->id = dest_id; if (FLD_ISSET(lsm_tree->bloom, WT_LSM_BLOOM_MERGED) && (FLD_ISSET(lsm_tree->bloom, WT_LSM_BLOOM_OLDEST) || start_chunk > 0) && record_count > 0) - create_bloom = 1; + create_bloom = true; /* * Special setup for the merge cursor: @@ -494,7 +491,7 @@ __wt_lsm_merge(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, u_int id) * progress. */ (void)__wt_atomic_add32(&lsm_tree->merge_syncing, 1); - in_sync = 1; + in_sync = true; /* * We've successfully created the new chunk. Now install it. We need * to ensure that the NO_CACHE flag is cleared and the bloom filter @@ -545,12 +542,12 @@ __wt_lsm_merge(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, u_int id) dest = NULL; ++lsm_tree->merge_progressing; (void)__wt_atomic_sub32(&lsm_tree->merge_syncing, 1); - in_sync = 0; + in_sync = false; WT_ERR_NOTFOUND_OK(ret); WT_ERR(__wt_lsm_tree_set_chunk_size(session, chunk)); WT_ERR(__wt_lsm_tree_writelock(session, lsm_tree)); - locked = 1; + locked = true; /* * Check whether we raced with another merge, and adjust the chunk @@ -591,7 +588,7 @@ __wt_lsm_merge(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, u_int id) lsm_tree->dsk_gen++; /* Update the throttling while holding the tree lock. */ - __wt_lsm_tree_throttle(session, lsm_tree, 1); + __wt_lsm_tree_throttle(session, lsm_tree, true); /* Schedule a pass to discard old chunks */ WT_ERR(__wt_lsm_manager_push_entry( diff --git a/src/third_party/wiredtiger/src/lsm/lsm_meta.c b/src/third_party/wiredtiger/src/lsm/lsm_meta.c index e4c95125428..64ca283e2c8 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_meta.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_meta.c @@ -184,7 +184,7 @@ __wt_lsm_meta_write(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree) WT_DECL_RET; WT_LSM_CHUNK *chunk; u_int i; - int first; + bool first; WT_RET(__wt_scr_alloc(session, 0, &buf)); WT_ERR(__wt_buf_fmt(session, buf, @@ -229,12 +229,12 @@ __wt_lsm_meta_write(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree) } WT_ERR(__wt_buf_catfmt(session, buf, "]")); WT_ERR(__wt_buf_catfmt(session, buf, ",old_chunks=[")); - first = 1; + first = true; for (i = 0; i < lsm_tree->nold_chunks; i++) { chunk = lsm_tree->old_chunks[i]; WT_ASSERT(session, chunk != NULL); if (first) - first = 0; + first = false; else WT_ERR(__wt_buf_catfmt(session, buf, ",")); WT_ERR(__wt_buf_catfmt(session, buf, "\"%s\"", chunk->uri)); diff --git a/src/third_party/wiredtiger/src/lsm/lsm_stat.c b/src/third_party/wiredtiger/src/lsm/lsm_stat.c index 2817ec9eeb7..4381ca0df00 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_stat.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_stat.c @@ -24,7 +24,7 @@ __curstat_lsm_init( WT_LSM_TREE *lsm_tree; int64_t bloom_count; u_int i; - int locked; + bool locked; char config[64]; const char *cfg[] = { WT_CONFIG_BASE(session, WT_SESSION_open_cursor), NULL, NULL }; @@ -32,9 +32,9 @@ __curstat_lsm_init( WT_CONFIG_BASE(session, WT_SESSION_open_cursor), "checkpoint=" WT_CHECKPOINT, NULL, NULL }; - locked = 0; + locked = false; WT_WITH_HANDLE_LIST_LOCK(session, - ret = __wt_lsm_tree_get(session, uri, 0, &lsm_tree)); + ret = __wt_lsm_tree_get(session, uri, false, &lsm_tree)); WT_RET(ret); WT_ERR(__wt_scr_alloc(session, 0, &uribuf)); @@ -52,7 +52,7 @@ __curstat_lsm_init( /* Hold the LSM lock so that we can safely walk through the chunks. */ WT_ERR(__wt_lsm_tree_readlock(session, lsm_tree)); - locked = 1; + locked = true; /* * Set the cursor to reference the data source statistics into which diff --git a/src/third_party/wiredtiger/src/lsm/lsm_tree.c b/src/third_party/wiredtiger/src/lsm/lsm_tree.c index 46db76e099c..bd54202de5e 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_tree.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_tree.c @@ -11,7 +11,7 @@ static int __lsm_tree_cleanup_old(WT_SESSION_IMPL *, const char *); static int __lsm_tree_open_check(WT_SESSION_IMPL *, WT_LSM_TREE *); static int __lsm_tree_open( - WT_SESSION_IMPL *, const char *, int, WT_LSM_TREE **); + WT_SESSION_IMPL *, const char *, bool, WT_LSM_TREE **); static int __lsm_tree_set_name(WT_SESSION_IMPL *, WT_LSM_TREE *, const char *); /* @@ -19,7 +19,7 @@ static int __lsm_tree_set_name(WT_SESSION_IMPL *, WT_LSM_TREE *, const char *); * Free an LSM tree structure. */ static int -__lsm_tree_discard(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, int final) +__lsm_tree_discard(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, bool final) { WT_DECL_RET; WT_LSM_CHUNK *chunk; @@ -143,7 +143,7 @@ __wt_lsm_tree_close_all(WT_SESSION_IMPL *session) */ (void)__wt_atomic_add32(&lsm_tree->refcnt, 1); WT_TRET(__lsm_tree_close(session, lsm_tree)); - WT_TRET(__lsm_tree_discard(session, lsm_tree, 1)); + WT_TRET(__lsm_tree_discard(session, lsm_tree, true)); } return (ret); @@ -239,7 +239,7 @@ __lsm_tree_cleanup_old(WT_SESSION_IMPL *session, const char *uri) WT_DECL_RET; const char *cfg[] = { WT_CONFIG_BASE(session, WT_SESSION_drop), "force", NULL }; - int exists; + bool exists; WT_RET(__wt_exist(session, uri + strlen("file:"), &exists)); if (exists) @@ -304,7 +304,7 @@ __wt_lsm_tree_setup_bloom( */ int __wt_lsm_tree_create(WT_SESSION_IMPL *session, - const char *uri, int exclusive, const char *config) + const char *uri, bool exclusive, const char *config) { WT_CONFIG_ITEM cval; WT_DECL_ITEM(buf); @@ -316,7 +316,7 @@ __wt_lsm_tree_create(WT_SESSION_IMPL *session, /* If the tree is open, it already exists. */ WT_WITH_HANDLE_LIST_LOCK(session, - ret = __wt_lsm_tree_get(session, uri, 0, &lsm_tree)); + ret = __wt_lsm_tree_get(session, uri, false, &lsm_tree)); if (ret == 0) { __wt_lsm_tree_release(session, lsm_tree); return (exclusive ? EEXIST : 0); @@ -433,7 +433,7 @@ __wt_lsm_tree_create(WT_SESSION_IMPL *session, WT_ERR(__wt_lsm_meta_write(session, lsm_tree)); /* Discard our partially populated handle. */ - ret = __lsm_tree_discard(session, lsm_tree, 0); + ret = __lsm_tree_discard(session, lsm_tree, false); lsm_tree = NULL; /* @@ -443,12 +443,12 @@ __wt_lsm_tree_create(WT_SESSION_IMPL *session, */ if (ret == 0) WT_WITH_HANDLE_LIST_LOCK(session, - ret = __lsm_tree_open(session, uri, 1, &lsm_tree)); + ret = __lsm_tree_open(session, uri, true, &lsm_tree)); if (ret == 0) __wt_lsm_tree_release(session, lsm_tree); if (0) { -err: WT_TRET(__lsm_tree_discard(session, lsm_tree, 0)); +err: WT_TRET(__lsm_tree_discard(session, lsm_tree, false)); } __wt_scr_free(session, &buf); return (ret); @@ -463,7 +463,7 @@ err: WT_TRET(__lsm_tree_discard(session, lsm_tree, 0)); */ static int __lsm_tree_find(WT_SESSION_IMPL *session, - const char *uri, int exclusive, WT_LSM_TREE **treep) + const char *uri, bool exclusive, WT_LSM_TREE **treep) { WT_LSM_TREE *lsm_tree; @@ -555,7 +555,7 @@ __lsm_tree_open_check(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree) */ static int __lsm_tree_open(WT_SESSION_IMPL *session, - const char *uri, int exclusive, WT_LSM_TREE **treep) + const char *uri, bool exclusive, WT_LSM_TREE **treep) { WT_CONNECTION_IMPL *conn; WT_DECL_RET; @@ -611,7 +611,7 @@ __lsm_tree_open(WT_SESSION_IMPL *session, *treep = lsm_tree; if (0) { -err: WT_TRET(__lsm_tree_discard(session, lsm_tree, 0)); +err: WT_TRET(__lsm_tree_discard(session, lsm_tree, false)); } return (ret); } @@ -622,7 +622,7 @@ err: WT_TRET(__lsm_tree_discard(session, lsm_tree, 0)); */ int __wt_lsm_tree_get(WT_SESSION_IMPL *session, - const char *uri, int exclusive, WT_LSM_TREE **treep) + const char *uri, bool exclusive, WT_LSM_TREE **treep) { WT_DECL_RET; @@ -632,7 +632,8 @@ __wt_lsm_tree_get(WT_SESSION_IMPL *session, if (ret == WT_NOTFOUND) ret = __lsm_tree_open(session, uri, exclusive, treep); - WT_ASSERT(session, ret != 0 || exclusive == (*treep)->exclusive); + WT_ASSERT(session, ret != 0 || + (exclusive ? 1 : 0) == (*treep)->exclusive); return (ret); } @@ -676,7 +677,7 @@ __wt_lsm_tree_release(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree) */ void __wt_lsm_tree_throttle( - WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, int decrease_only) + WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree, bool decrease_only) { WT_LSM_CHUNK *last_chunk, **cp, *ondisk, *prev_chunk; uint64_t cache_sz, cache_used, oldtime, record_count, timediff; @@ -819,13 +820,13 @@ __wt_lsm_tree_switch(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree) WT_DECL_RET; WT_LSM_CHUNK *chunk, *last_chunk; uint32_t chunks_moved, nchunks, new_id; - int first_switch; + bool first_switch; WT_RET(__wt_lsm_tree_writelock(session, lsm_tree)); nchunks = lsm_tree->nchunks; - first_switch = nchunks == 0 ? 1 : 0; + first_switch = nchunks == 0; /* * Check if a switch is still needed: we may have raced while waiting @@ -839,7 +840,7 @@ __wt_lsm_tree_switch(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree) goto err; /* Update the throttle time. */ - __wt_lsm_tree_throttle(session, lsm_tree, 0); + __wt_lsm_tree_throttle(session, lsm_tree, false); new_id = __wt_atomic_add32(&lsm_tree->last, 1); @@ -948,13 +949,13 @@ __wt_lsm_tree_drop( WT_LSM_CHUNK *chunk; WT_LSM_TREE *lsm_tree; u_int i; - int locked; + bool locked; - locked = 0; + locked = false; /* Get the LSM tree. */ WT_WITH_HANDLE_LIST_LOCK(session, - ret = __wt_lsm_tree_get(session, name, 1, &lsm_tree)); + ret = __wt_lsm_tree_get(session, name, true, &lsm_tree)); WT_RET(ret); /* Shut down the LSM worker. */ @@ -962,7 +963,7 @@ __wt_lsm_tree_drop( /* Prevent any new opens. */ WT_ERR(__wt_lsm_tree_writelock(session, lsm_tree)); - locked = 1; + locked = true; /* Drop the chunks. */ for (i = 0; i < lsm_tree->nchunks; i++) { @@ -983,14 +984,14 @@ __wt_lsm_tree_drop( __wt_schema_drop(session, chunk->bloom_uri, cfg)); } - locked = 0; + locked = false; WT_ERR(__wt_lsm_tree_writeunlock(session, lsm_tree)); ret = __wt_metadata_remove(session, name); err: if (locked) WT_TRET(__wt_lsm_tree_writeunlock(session, lsm_tree)); WT_WITH_HANDLE_LIST_LOCK(session, - WT_TRET(__lsm_tree_discard(session, lsm_tree, 0))); + WT_TRET(__lsm_tree_discard(session, lsm_tree, false))); return (ret); } @@ -1007,14 +1008,14 @@ __wt_lsm_tree_rename(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree; const char *old; u_int i; - int locked; + bool locked; old = NULL; - locked = 0; + locked = false; /* Get the LSM tree. */ WT_WITH_HANDLE_LIST_LOCK(session, - ret = __wt_lsm_tree_get(session, olduri, 1, &lsm_tree)); + ret = __wt_lsm_tree_get(session, olduri, true, &lsm_tree)); WT_RET(ret); /* Shut down the LSM worker. */ @@ -1022,7 +1023,7 @@ __wt_lsm_tree_rename(WT_SESSION_IMPL *session, /* Prevent any new opens. */ WT_ERR(__wt_lsm_tree_writelock(session, lsm_tree)); - locked = 1; + locked = true; /* Set the new name. */ WT_ERR(__lsm_tree_set_name(session, lsm_tree, newuri)); @@ -1051,7 +1052,7 @@ __wt_lsm_tree_rename(WT_SESSION_IMPL *session, } WT_ERR(__wt_lsm_meta_write(session, lsm_tree)); - locked = 0; + locked = false; WT_ERR(__wt_lsm_tree_writeunlock(session, lsm_tree)); WT_ERR(__wt_metadata_remove(session, olduri)); @@ -1064,7 +1065,7 @@ err: if (locked) * tree will create a new one. */ WT_WITH_HANDLE_LIST_LOCK(session, - WT_TRET(__lsm_tree_discard(session, lsm_tree, 0))); + WT_TRET(__lsm_tree_discard(session, lsm_tree, false))); return (ret); } @@ -1079,15 +1080,15 @@ __wt_lsm_tree_truncate( WT_DECL_RET; WT_LSM_CHUNK *chunk; WT_LSM_TREE *lsm_tree; - int locked; + bool locked; WT_UNUSED(cfg); chunk = NULL; - locked = 0; + locked = false; /* Get the LSM tree. */ WT_WITH_HANDLE_LIST_LOCK(session, - ret = __wt_lsm_tree_get(session, name, 1, &lsm_tree)); + ret = __wt_lsm_tree_get(session, name, true, &lsm_tree)); WT_RET(ret); /* Shut down the LSM worker. */ @@ -1095,7 +1096,7 @@ __wt_lsm_tree_truncate( /* Prevent any new opens. */ WT_ERR(__wt_lsm_tree_writelock(session, lsm_tree)); - locked = 1; + locked = true; /* Create the new chunk. */ WT_ERR(__wt_calloc_one(session, &chunk)); @@ -1108,7 +1109,7 @@ __wt_lsm_tree_truncate( WT_ERR(__wt_lsm_meta_write(session, lsm_tree)); - locked = 0; + locked = false; WT_ERR(__wt_lsm_tree_writeunlock(session, lsm_tree)); __wt_lsm_tree_release(session, lsm_tree); @@ -1126,7 +1127,7 @@ err: if (locked) * in a valid (not truncated) tree. */ WT_WITH_HANDLE_LIST_LOCK(session, - WT_TRET(__lsm_tree_discard(session, lsm_tree, 0))); + WT_TRET(__lsm_tree_discard(session, lsm_tree, false))); } return (ret); } @@ -1202,7 +1203,7 @@ __wt_lsm_tree_writeunlock(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree) * Compact an LSM tree called via __wt_schema_worker. */ int -__wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, int *skip) +__wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, bool *skipp) { WT_DECL_RET; WT_LSM_CHUNK *chunk; @@ -1210,9 +1211,9 @@ __wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, int *skip) time_t begin, end; uint64_t progress; uint32_t i; - int compacting, flushing, locked, ref; + bool compacting, flushing, locked, ref; - compacting = flushing = locked = ref = 0; + compacting = flushing = locked = ref = false; chunk = NULL; /* * This function is applied to all matching sources: ignore anything @@ -1222,10 +1223,10 @@ __wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, int *skip) return (0); /* Tell __wt_schema_worker not to look inside the LSM tree. */ - *skip = 1; + *skipp = true; WT_WITH_HANDLE_LIST_LOCK(session, - ret = __wt_lsm_tree_get(session, name, 0, &lsm_tree)); + ret = __wt_lsm_tree_get(session, name, false, &lsm_tree)); WT_RET(ret); if (!F_ISSET(S2C(session), WT_CONN_LSM_MERGE)) @@ -1261,7 +1262,7 @@ __wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, int *skip) /* Lock the tree: single-thread compaction. */ WT_ERR(__wt_lsm_tree_writelock(session, lsm_tree)); - locked = 1; + locked = true; /* Clear any merge throttle: compact throws out that calculation. */ lsm_tree->merge_throttle = 0; @@ -1286,10 +1287,10 @@ __wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, int *skip) * So we need to add a reference to keep it available. */ (void)__wt_atomic_add32(&chunk->refcnt, 1); - ref = 1; + ref = true; } - locked = 0; + locked = false; WT_ERR(__wt_lsm_tree_writeunlock(session, lsm_tree)); if (chunk != NULL) { @@ -1297,7 +1298,7 @@ __wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, int *skip) "Compact force flush %s flags 0x%" PRIx32 " chunk %u flags 0x%" PRIx32, name, lsm_tree->flags, chunk->id, chunk->flags)); - flushing = 1; + flushing = true; /* * Make sure the in-memory chunk gets flushed do not push a * switch, because we don't want to create a new in-memory @@ -1310,7 +1311,7 @@ __wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, int *skip) * If there is no chunk to flush, go straight to the * compacting state. */ - compacting = 1; + compacting = true; progress = lsm_tree->merge_progressing; F_SET(lsm_tree, WT_LSM_TREE_COMPACTING); WT_ERR(__wt_verbose(session, WT_VERB_LSM, @@ -1334,8 +1335,8 @@ __wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, int *skip) name, chunk->id, lsm_tree->merge_progressing)); (void)__wt_atomic_sub32(&chunk->refcnt, 1); - flushing = ref = 0; - compacting = 1; + flushing = ref = false; + compacting = true; F_SET(lsm_tree, WT_LSM_TREE_COMPACTING); progress = lsm_tree->merge_progressing; } else { @@ -1411,17 +1412,17 @@ int __wt_lsm_tree_worker(WT_SESSION_IMPL *session, const char *uri, int (*file_func)(WT_SESSION_IMPL *, const char *[]), - int (*name_func)(WT_SESSION_IMPL *, const char *, int *), + int (*name_func)(WT_SESSION_IMPL *, const char *, bool *), const char *cfg[], uint32_t open_flags) { WT_DECL_RET; WT_LSM_CHUNK *chunk; WT_LSM_TREE *lsm_tree; u_int i; - int exclusive, locked; + bool exclusive, locked; - locked = 0; - exclusive = FLD_ISSET(open_flags, WT_DHANDLE_EXCLUSIVE) ? 1 : 0; + locked = false; + exclusive = FLD_ISSET(open_flags, WT_DHANDLE_EXCLUSIVE); WT_WITH_HANDLE_LIST_LOCK(session, ret = __wt_lsm_tree_get(session, uri, exclusive, &lsm_tree)); WT_RET(ret); @@ -1434,7 +1435,7 @@ __wt_lsm_tree_worker(WT_SESSION_IMPL *session, WT_ERR(exclusive ? __wt_lsm_tree_writelock(session, lsm_tree) : __wt_lsm_tree_readlock(session, lsm_tree)); - locked = 1; + locked = true; for (i = 0; i < lsm_tree->nchunks; i++) { chunk = lsm_tree->chunk[i]; if (file_func == __wt_checkpoint && diff --git a/src/third_party/wiredtiger/src/lsm/lsm_work_unit.c b/src/third_party/wiredtiger/src/lsm/lsm_work_unit.c index 8eba0127b8b..a0cd2e5dba2 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_work_unit.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_work_unit.c @@ -19,7 +19,7 @@ static int __lsm_discard_handle(WT_SESSION_IMPL *, const char *, const char *); */ static int __lsm_copy_chunks(WT_SESSION_IMPL *session, - WT_LSM_TREE *lsm_tree, WT_LSM_WORKER_COOKIE *cookie, int old_chunks) + WT_LSM_TREE *lsm_tree, WT_LSM_WORKER_COOKIE *cookie, bool old_chunks) { WT_DECL_RET; u_int i, nchunks; @@ -68,7 +68,7 @@ err: WT_TRET(__wt_lsm_tree_readunlock(session, lsm_tree)); */ int __wt_lsm_get_chunk_to_flush(WT_SESSION_IMPL *session, - WT_LSM_TREE *lsm_tree, int force, WT_LSM_CHUNK **chunkp) + WT_LSM_TREE *lsm_tree, bool force, WT_LSM_CHUNK **chunkp) { WT_DECL_RET; WT_LSM_CHUNK *chunk, *evict_chunk, *flush_chunk; @@ -157,14 +157,14 @@ __lsm_unpin_chunks(WT_SESSION_IMPL *session, WT_LSM_WORKER_COOKIE *cookie) */ int __wt_lsm_work_switch( - WT_SESSION_IMPL *session, WT_LSM_WORK_UNIT **entryp, int *ran) + WT_SESSION_IMPL *session, WT_LSM_WORK_UNIT **entryp, bool *ran) { WT_DECL_RET; WT_LSM_WORK_UNIT *entry; /* We've become responsible for freeing the work unit. */ entry = *entryp; - *ran = 0; + *ran = false; *entryp = NULL; if (F_ISSET(entry->lsm_tree, WT_LSM_TREE_NEED_SWITCH)) { @@ -177,7 +177,7 @@ __wt_lsm_work_switch( WT_LSM_WORK_SWITCH, 0, entry->lsm_tree)); ret = 0; } else - *ran = 1; + *ran = true; } err: __wt_lsm_manager_free_work_unit(session, entry); return (ret); @@ -198,7 +198,7 @@ __wt_lsm_work_bloom(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree) WT_CLEAR(cookie); - WT_RET(__lsm_copy_chunks(session, lsm_tree, &cookie, 0)); + WT_RET(__lsm_copy_chunks(session, lsm_tree, &cookie, false)); /* Create bloom filters in all checkpointed chunks. */ merge = 0; @@ -285,7 +285,7 @@ __wt_lsm_checkpoint_chunk(WT_SESSION_IMPL *session, } /* Stop if a running transaction needs the chunk. */ - __wt_txn_update_oldest(session, 1); + __wt_txn_update_oldest(session, true); if (chunk->switch_txn == WT_TXN_NONE || !__wt_txn_visible_all(session, chunk->switch_txn)) { WT_RET(__wt_verbose(session, WT_VERB_LSM, @@ -344,7 +344,7 @@ __wt_lsm_checkpoint_chunk(WT_SESSION_IMPL *session, ++lsm_tree->dsk_gen; /* Update the throttle time. */ - __wt_lsm_tree_throttle(session, lsm_tree, 1); + __wt_lsm_tree_throttle(session, lsm_tree, true); WT_TRET(__wt_lsm_tree_writeunlock(session, lsm_tree)); if (ret != 0) @@ -357,7 +357,7 @@ __wt_lsm_checkpoint_chunk(WT_SESSION_IMPL *session, * forced eviction. */ WT_RET(__wt_session_get_btree(session, chunk->uri, NULL, NULL, 0)); - __wt_btree_evictable(session, 1); + __wt_btree_evictable(session, true); WT_RET(__wt_session_release_btree(session)); /* Make sure we aren't pinning a transaction ID. */ @@ -519,9 +519,10 @@ __wt_lsm_free_chunks(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree) WT_LSM_CHUNK *chunk; WT_LSM_WORKER_COOKIE cookie; u_int i, skipped; - int flush_metadata, drop_ret; + int drop_ret; + bool flush_metadata; - flush_metadata = 0; + flush_metadata = false; if (lsm_tree->nold_chunks == 0) return (0); @@ -543,7 +544,7 @@ __wt_lsm_free_chunks(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree) * one to keep the non-NULL slots at the beginning of the array. */ WT_CLEAR(cookie); - WT_RET(__lsm_copy_chunks(session, lsm_tree, &cookie, 1)); + WT_RET(__lsm_copy_chunks(session, lsm_tree, &cookie, true)); for (i = skipped = 0; i < cookie.nchunks; i++) { chunk = cookie.chunk_array[i]; WT_ASSERT(session, chunk != NULL); @@ -580,7 +581,7 @@ __wt_lsm_free_chunks(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree) } else if (drop_ret != ENOENT) WT_ERR(drop_ret); - flush_metadata = 1; + flush_metadata = true; F_CLR(chunk, WT_LSM_CHUNK_BLOOM); } if (chunk->uri != NULL) { @@ -590,7 +591,7 @@ __wt_lsm_free_chunks(WT_SESSION_IMPL *session, WT_LSM_TREE *lsm_tree) continue; } else if (drop_ret != ENOENT) WT_ERR(drop_ret); - flush_metadata = 1; + flush_metadata = true; } /* Lock the tree to clear out the old chunk information. */ diff --git a/src/third_party/wiredtiger/src/lsm/lsm_worker.c b/src/third_party/wiredtiger/src/lsm/lsm_worker.c index 3add3155e17..625783ac16c 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_worker.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_worker.c @@ -9,7 +9,7 @@ #include "wt_internal.h" static int __lsm_worker_general_op( - WT_SESSION_IMPL *, WT_LSM_WORKER_ARGS *, int *); + WT_SESSION_IMPL *, WT_LSM_WORKER_ARGS *, bool *); static WT_THREAD_RET __lsm_worker(void *); /* @@ -30,14 +30,14 @@ __wt_lsm_worker_start(WT_SESSION_IMPL *session, WT_LSM_WORKER_ARGS *args) */ static int __lsm_worker_general_op( - WT_SESSION_IMPL *session, WT_LSM_WORKER_ARGS *cookie, int *completed) + WT_SESSION_IMPL *session, WT_LSM_WORKER_ARGS *cookie, bool *completed) { WT_DECL_RET; WT_LSM_CHUNK *chunk; WT_LSM_WORK_UNIT *entry; - int force; + bool force; - *completed = 0; + *completed = false; /* * Return if this thread cannot process a bloom, drop or flush. */ @@ -72,7 +72,7 @@ __lsm_worker_general_op( WT_ERR(__wt_lsm_free_chunks(session, entry->lsm_tree)); else if (entry->type == WT_LSM_WORK_BLOOM) WT_ERR(__wt_lsm_work_bloom(session, entry->lsm_tree)); - *completed = 1; + *completed = true; err: __wt_lsm_manager_free_work_unit(session, entry); return (ret); @@ -90,7 +90,7 @@ __lsm_worker(void *arg) WT_LSM_WORK_UNIT *entry; WT_LSM_WORKER_ARGS *cookie; WT_SESSION_IMPL *session; - int progress, ran; + bool progress, ran; cookie = (WT_LSM_WORKER_ARGS *)arg; session = cookie->session; @@ -99,7 +99,7 @@ __lsm_worker(void *arg) entry = NULL; while (F_ISSET(conn, WT_CONN_SERVER_RUN) && F_ISSET(cookie, WT_LSM_WORKER_RUN)) { - progress = 0; + progress = false; /* * Workers process the different LSM work queues. Some workers @@ -148,7 +148,7 @@ __lsm_worker(void *arg) __wt_lsm_manager_free_work_unit(session, entry); entry = NULL; - progress = 1; + progress = true; } /* Flag an error if the pop failed. */ WT_ERR(ret); diff --git a/src/third_party/wiredtiger/src/meta/meta_apply.c b/src/third_party/wiredtiger/src/meta/meta_apply.c index 315621f2ae9..95c5b9807ca 100644 --- a/src/third_party/wiredtiger/src/meta/meta_apply.c +++ b/src/third_party/wiredtiger/src/meta/meta_apply.c @@ -46,8 +46,8 @@ __wt_meta_btree_apply(WT_SESSION_IMPL *session, WT_SAVE_DHANDLE(session, ret = func(session, cfg)); if (WT_META_TRACKING(session)) - WT_TRET( - __wt_meta_track_handle_lock(session, 0)); + WT_TRET(__wt_meta_track_handle_lock( + session, false)); else WT_TRET(__wt_session_release_btree(session)); } else if (ret == EBUSY) diff --git a/src/third_party/wiredtiger/src/meta/meta_table.c b/src/third_party/wiredtiger/src/meta/meta_table.c index 8255f004dab..0bab52b9d9c 100644 --- a/src/third_party/wiredtiger/src/meta/meta_table.c +++ b/src/third_party/wiredtiger/src/meta/meta_table.c @@ -78,7 +78,7 @@ __wt_metadata_cursor( { WT_DATA_HANDLE *saved_dhandle; WT_DECL_RET; - int is_dead; + bool is_dead; const char *cfg[] = { WT_CONFIG_BASE(session, WT_SESSION_open_cursor), config, NULL }; @@ -96,7 +96,7 @@ __wt_metadata_cursor( /* The metadata should never be closed. */ WT_ASSERT(session, !is_dead); - WT_ERR(__wt_curfile_create(session, NULL, cfg, 0, 0, cursorp)); + WT_ERR(__wt_curfile_create(session, NULL, cfg, false, false, cursorp)); __wt_cursor_dhandle_incr_use(session); /* Restore the caller's btree. */ diff --git a/src/third_party/wiredtiger/src/meta/meta_track.c b/src/third_party/wiredtiger/src/meta/meta_track.c index 2ac1bfa71a1..e82ae902f92 100644 --- a/src/third_party/wiredtiger/src/meta/meta_track.c +++ b/src/third_party/wiredtiger/src/meta/meta_track.c @@ -25,7 +25,7 @@ typedef struct __wt_meta_track { } op; char *a, *b; /* Strings */ WT_DATA_HANDLE *dhandle; /* Locked handle */ - int created; /* Handle on newly created file */ + bool created; /* Handle on newly created file */ } WT_META_TRACK; /* @@ -274,7 +274,7 @@ __wt_meta_track_find_handle( * Turn off metadata operation tracking, unrolling on error. */ int -__wt_meta_track_off(WT_SESSION_IMPL *session, int need_sync, int unroll) +__wt_meta_track_off(WT_SESSION_IMPL *session, bool need_sync, bool unroll) { WT_DECL_RET; WT_META_TRACK *trk, *trk_orig; @@ -317,8 +317,8 @@ __wt_meta_track_off(WT_SESSION_IMPL *session, int need_sync, int unroll) /* If we're logging, make sure the metadata update was flushed. */ if (FLD_ISSET(S2C(session)->log_flags, WT_CONN_LOG_ENABLED)) { WT_WITH_DHANDLE(session, session->meta_dhandle, - ret = __wt_txn_checkpoint_log(session, - 0, WT_TXN_LOG_CKPT_SYNC, NULL)); + ret = __wt_txn_checkpoint_log( + session, false, WT_TXN_LOG_CKPT_SYNC, NULL)); WT_RET(ret); } else { WT_WITH_DHANDLE(session, session->meta_dhandle, @@ -490,7 +490,7 @@ err: __meta_track_err(session); * Track a locked handle. */ int -__wt_meta_track_handle_lock(WT_SESSION_IMPL *session, int created) +__wt_meta_track_handle_lock(WT_SESSION_IMPL *session, bool created) { WT_META_TRACK *trk; diff --git a/src/third_party/wiredtiger/src/meta/meta_turtle.c b/src/third_party/wiredtiger/src/meta/meta_turtle.c index a44e647ff08..1aa9c953689 100644 --- a/src/third_party/wiredtiger/src/meta/meta_turtle.c +++ b/src/third_party/wiredtiger/src/meta/meta_turtle.c @@ -72,7 +72,7 @@ __metadata_load_hot_backup(WT_SESSION_IMPL *session) WT_DECL_ITEM(key); WT_DECL_ITEM(value); WT_DECL_RET; - int exist; + bool exist; /* Look for a hot backup file: if we find it, load it. */ WT_RET(__wt_exist(session, WT_METADATA_BACKUP, &exist)); @@ -112,7 +112,7 @@ __metadata_load_bulk(WT_SESSION_IMPL *session) WT_CURSOR *cursor; WT_DECL_RET; uint32_t allocsize; - int exist; + bool exist; const char *filecfg[] = { WT_CONFIG_BASE(session, file_meta), NULL }; const char *key; @@ -155,7 +155,7 @@ int __wt_turtle_init(WT_SESSION_IMPL *session) { WT_DECL_RET; - int exist, exist_incr; + bool exist, exist_incr; char *metaconf; metaconf = NULL; @@ -222,7 +222,7 @@ __wt_turtle_read(WT_SESSION_IMPL *session, const char *key, char **valuep) FILE *fp; WT_DECL_ITEM(buf); WT_DECL_RET; - int exist, match; + bool exist, match; *valuep = NULL; @@ -241,12 +241,12 @@ __wt_turtle_read(WT_SESSION_IMPL *session, const char *key, char **valuep) /* Search for the key. */ WT_ERR(__wt_scr_alloc(session, 512, &buf)); - for (match = 0;;) { + for (match = false;;) { WT_ERR(__wt_getline(session, buf, fp)); if (buf->size == 0) WT_ERR(WT_NOTFOUND); if (strcmp(key, buf->data) == 0) - match = 1; + match = true; /* Key matched: read the subsequent line for the value. */ WT_ERR(__wt_getline(session, buf, fp)); @@ -284,8 +284,8 @@ __wt_turtle_update( * Create the turtle setup file: we currently re-write it from scratch * every time. */ - WT_RET(__wt_open( - session, WT_METADATA_TURTLE_SET, 1, 1, WT_FILE_TYPE_TURTLE, &fh)); + WT_RET(__wt_open(session, + WT_METADATA_TURTLE_SET, true, true, WT_FILE_TYPE_TURTLE, &fh)); version = wiredtiger_version(&vmajor, &vminor, &vpatch); WT_ERR(__wt_scr_alloc(session, 2 * 1024, &buf)); diff --git a/src/third_party/wiredtiger/src/os_posix/os_dir.c b/src/third_party/wiredtiger/src/os_posix/os_dir.c index 5bf6e7349fe..9eba641ca51 100644 --- a/src/third_party/wiredtiger/src/os_posix/os_dir.c +++ b/src/third_party/wiredtiger/src/os_posix/os_dir.c @@ -24,7 +24,7 @@ __wt_dirlist(WT_SESSION_IMPL *session, const char *dir, const char *prefix, WT_DECL_RET; size_t dirallocsz; u_int count, dirsz; - int match; + bool match; char **entries, *path; *dirlist = NULL; @@ -54,13 +54,13 @@ __wt_dirlist(WT_SESSION_IMPL *session, const char *dir, const char *prefix, if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0) continue; - match = 0; + match = false; if (prefix != NULL && ((LF_ISSET(WT_DIRLIST_INCLUDE) && WT_PREFIX_MATCH(dp->d_name, prefix)) || (LF_ISSET(WT_DIRLIST_EXCLUDE) && !WT_PREFIX_MATCH(dp->d_name, prefix)))) - match = 1; + match = true; if (prefix == NULL || match) { /* * We have a file name we want to return. diff --git a/src/third_party/wiredtiger/src/os_posix/os_dlopen.c b/src/third_party/wiredtiger/src/os_posix/os_dlopen.c index a468e7ab49d..2b5fa249163 100644 --- a/src/third_party/wiredtiger/src/os_posix/os_dlopen.c +++ b/src/third_party/wiredtiger/src/os_posix/os_dlopen.c @@ -39,7 +39,7 @@ err: __wt_free(session, dlh->name); */ int __wt_dlsym(WT_SESSION_IMPL *session, - WT_DLH *dlh, const char *name, int fail, void *sym_ret) + WT_DLH *dlh, const char *name, bool fail, void *sym_ret) { void *sym; diff --git a/src/third_party/wiredtiger/src/os_posix/os_exist.c b/src/third_party/wiredtiger/src/os_posix/os_exist.c index 173021e6100..644a27dca9a 100644 --- a/src/third_party/wiredtiger/src/os_posix/os_exist.c +++ b/src/third_party/wiredtiger/src/os_posix/os_exist.c @@ -13,13 +13,13 @@ * Return if the file exists. */ int -__wt_exist(WT_SESSION_IMPL *session, const char *filename, int *existp) +__wt_exist(WT_SESSION_IMPL *session, const char *filename, bool *existp) { struct stat sb; WT_DECL_RET; char *path; - *existp = 0; + *existp = false; WT_RET(__wt_filename(session, filename, &path)); @@ -28,7 +28,7 @@ __wt_exist(WT_SESSION_IMPL *session, const char *filename, int *existp) __wt_free(session, path); if (ret == 0) { - *existp = 1; + *existp = true; return (0); } if (ret == ENOENT) diff --git a/src/third_party/wiredtiger/src/os_posix/os_flock.c b/src/third_party/wiredtiger/src/os_posix/os_flock.c index 69cd367dde3..07393481e7d 100644 --- a/src/third_party/wiredtiger/src/os_posix/os_flock.c +++ b/src/third_party/wiredtiger/src/os_posix/os_flock.c @@ -13,7 +13,7 @@ * Lock/unlock a byte in a file. */ int -__wt_bytelock(WT_FH *fhp, wt_off_t byte, int lock) +__wt_bytelock(WT_FH *fhp, wt_off_t byte, bool lock) { struct flock fl; WT_DECL_RET; diff --git a/src/third_party/wiredtiger/src/os_posix/os_mtx_cond.c b/src/third_party/wiredtiger/src/os_posix/os_mtx_cond.c index 7946b4ab0cc..fac2c06957d 100644 --- a/src/third_party/wiredtiger/src/os_posix/os_mtx_cond.c +++ b/src/third_party/wiredtiger/src/os_posix/os_mtx_cond.c @@ -14,7 +14,7 @@ */ int __wt_cond_alloc(WT_SESSION_IMPL *session, - const char *name, int is_signalled, WT_CONDVAR **condp) + const char *name, bool is_signalled, WT_CONDVAR **condp) { WT_CONDVAR *cond; WT_DECL_RET; @@ -47,16 +47,16 @@ err: __wt_free(session, cond); */ int __wt_cond_wait_signal( - WT_SESSION_IMPL *session, WT_CONDVAR *cond, uint64_t usecs, int *signalled) + WT_SESSION_IMPL *session, WT_CONDVAR *cond, uint64_t usecs, bool *signalled) { struct timespec ts; WT_DECL_RET; - int locked; + bool locked; - locked = 0; + locked = false; /* Fast path if already signalled. */ - *signalled = 1; + *signalled = true; if (__wt_atomic_addi32(&cond->waiters, 1) == 0) return (0); @@ -71,7 +71,7 @@ __wt_cond_wait_signal( } WT_ERR(pthread_mutex_lock(&cond->mtx)); - locked = 1; + locked = true; if (usecs > 0) { WT_ERR(__wt_epoch(session, &ts)); @@ -92,7 +92,7 @@ __wt_cond_wait_signal( ret == ETIME || #endif ret == ETIMEDOUT) { - *signalled = 0; + *signalled = false; ret = 0; } @@ -113,9 +113,9 @@ int __wt_cond_signal(WT_SESSION_IMPL *session, WT_CONDVAR *cond) { WT_DECL_RET; - int locked; + bool locked; - locked = 0; + locked = false; /* * !!! @@ -131,7 +131,7 @@ __wt_cond_signal(WT_SESSION_IMPL *session, WT_CONDVAR *cond) if (cond->waiters > 0 || !__wt_atomic_casi32(&cond->waiters, 0, -1)) { WT_ERR(pthread_mutex_lock(&cond->mtx)); - locked = 1; + locked = true; WT_ERR(pthread_cond_broadcast(&cond->cond)); } diff --git a/src/third_party/wiredtiger/src/os_posix/os_open.c b/src/third_party/wiredtiger/src/os_posix/os_open.c index ef4662aa369..a87272db391 100644 --- a/src/third_party/wiredtiger/src/os_posix/os_open.c +++ b/src/third_party/wiredtiger/src/os_posix/os_open.c @@ -30,18 +30,19 @@ __open_directory(WT_SESSION_IMPL *session, char *path, int *fd) */ int __wt_open(WT_SESSION_IMPL *session, - const char *name, int ok_create, int exclusive, int dio_type, WT_FH **fhp) + const char *name, bool ok_create, bool exclusive, int dio_type, WT_FH **fhp) { WT_CONNECTION_IMPL *conn; WT_DECL_RET; WT_FH *fh, *tfh; mode_t mode; uint64_t bucket, hash; - int direct_io, f, fd, matched; + int f, fd; + bool direct_io, matched; char *path; conn = S2C(session); - direct_io = 0; + direct_io = false; fh = NULL; fd = -1; path = NULL; @@ -49,7 +50,7 @@ __wt_open(WT_SESSION_IMPL *session, WT_RET(__wt_verbose(session, WT_VERB_FILEOPS, "%s: open", name)); /* Increment the reference count if we already have the file open. */ - matched = 0; + matched = false; hash = __wt_hash_city64(name, strlen(name)); bucket = hash % WT_HASH_ARRAY_SIZE; __wt_spin_lock(session, &conn->fh_lock); @@ -57,7 +58,7 @@ __wt_open(WT_SESSION_IMPL *session, if (strcmp(name, tfh->name) == 0) { ++tfh->ref; *fhp = tfh; - matched = 1; + matched = true; break; } } @@ -103,7 +104,7 @@ __wt_open(WT_SESSION_IMPL *session, #ifdef O_DIRECT if (dio_type && FLD_ISSET(conn->direct_io, dio_type)) { f |= O_DIRECT; - direct_io = 1; + direct_io = true; } #endif if (dio_type == WT_FILE_TYPE_LOG && @@ -165,13 +166,13 @@ setupfh: * Repeat the check for a match, but then link onto the database's list * of files. */ - matched = 0; + matched = false; __wt_spin_lock(session, &conn->fh_lock); TAILQ_FOREACH(tfh, &conn->fhhash[bucket], hashq) { if (strcmp(name, tfh->name) == 0) { ++tfh->ref; *fhp = tfh; - matched = 1; + matched = true; break; } } diff --git a/src/third_party/wiredtiger/src/os_posix/os_priv.c b/src/third_party/wiredtiger/src/os_posix/os_priv.c index 21549cad957..a8479668d67 100644 --- a/src/third_party/wiredtiger/src/os_posix/os_priv.c +++ b/src/third_party/wiredtiger/src/os_posix/os_priv.c @@ -13,7 +13,7 @@ * Return if the process has special privileges, defined as having * different effective and read UIDs or GIDs. */ -int +bool __wt_has_priv(void) { return (getuid() != geteuid() || getgid() != getegid()); diff --git a/src/third_party/wiredtiger/src/os_win/os_dir.c b/src/third_party/wiredtiger/src/os_win/os_dir.c index 33489bc2497..aff916c25f5 100644 --- a/src/third_party/wiredtiger/src/os_win/os_dir.c +++ b/src/third_party/wiredtiger/src/os_win/os_dir.c @@ -23,7 +23,7 @@ __wt_dirlist(WT_SESSION_IMPL *session, const char *dir, const char *prefix, WT_DECL_RET; size_t dirallocsz, pathlen; u_int count, dirsz; - int match; + bool match; char **entries, *path; *dirlist = NULL; @@ -66,13 +66,13 @@ __wt_dirlist(WT_SESSION_IMPL *session, const char *dir, const char *prefix, if (strcmp(finddata.cFileName, ".") == 0 || strcmp(finddata.cFileName, "..") == 0) continue; - match = 0; + match = false; if (prefix != NULL && ((LF_ISSET(WT_DIRLIST_INCLUDE) && WT_PREFIX_MATCH(finddata.cFileName, prefix)) || (LF_ISSET(WT_DIRLIST_EXCLUDE) && !WT_PREFIX_MATCH(finddata.cFileName, prefix)))) - match = 1; + match = true; if (prefix == NULL || match) { /* * We have a file name we want to return. diff --git a/src/third_party/wiredtiger/src/os_win/os_dlopen.c b/src/third_party/wiredtiger/src/os_win/os_dlopen.c index ee052299f1a..1c57d5f8073 100644 --- a/src/third_party/wiredtiger/src/os_win/os_dlopen.c +++ b/src/third_party/wiredtiger/src/os_win/os_dlopen.c @@ -49,7 +49,7 @@ err: __wt_free(session, dlh->name); */ int __wt_dlsym(WT_SESSION_IMPL *session, - WT_DLH *dlh, const char *name, int fail, void *sym_ret) + WT_DLH *dlh, const char *name, bool fail, void *sym_ret) { void *sym; diff --git a/src/third_party/wiredtiger/src/os_win/os_exist.c b/src/third_party/wiredtiger/src/os_win/os_exist.c index 747ea7dfc27..4a727801569 100644 --- a/src/third_party/wiredtiger/src/os_win/os_exist.c +++ b/src/third_party/wiredtiger/src/os_win/os_exist.c @@ -13,7 +13,7 @@ * Return if the file exists. */ int -__wt_exist(WT_SESSION_IMPL *session, const char *filename, int *existp) +__wt_exist(WT_SESSION_IMPL *session, const char *filename, bool *existp) { WT_DECL_RET; char *path; @@ -25,9 +25,9 @@ __wt_exist(WT_SESSION_IMPL *session, const char *filename, int *existp) __wt_free(session, path); if (ret != INVALID_FILE_ATTRIBUTES) - *existp = 1; + *existp = true; else - *existp = 0; + *existp = false; return (0); } diff --git a/src/third_party/wiredtiger/src/os_win/os_flock.c b/src/third_party/wiredtiger/src/os_win/os_flock.c index d551480ba4d..947d7bdcde7 100644 --- a/src/third_party/wiredtiger/src/os_win/os_flock.c +++ b/src/third_party/wiredtiger/src/os_win/os_flock.c @@ -13,7 +13,7 @@ * Lock/unlock a byte in a file. */ int -__wt_bytelock(WT_FH *fhp, wt_off_t byte, int lock) +__wt_bytelock(WT_FH *fhp, wt_off_t byte, bool lock) { WT_DECL_RET; diff --git a/src/third_party/wiredtiger/src/os_win/os_mtx_cond.c b/src/third_party/wiredtiger/src/os_win/os_mtx_cond.c index 14ca5d61282..b909afa9ba6 100644 --- a/src/third_party/wiredtiger/src/os_win/os_mtx_cond.c +++ b/src/third_party/wiredtiger/src/os_win/os_mtx_cond.c @@ -14,7 +14,7 @@ */ int __wt_cond_alloc(WT_SESSION_IMPL *session, - const char *name, int is_signalled, WT_CONDVAR **condp) + const char *name, bool is_signalled, WT_CONDVAR **condp) { WT_CONDVAR *cond; @@ -43,17 +43,17 @@ __wt_cond_alloc(WT_SESSION_IMPL *session, */ int __wt_cond_wait_signal( - WT_SESSION_IMPL *session, WT_CONDVAR *cond, uint64_t usecs, int *signalled) + WT_SESSION_IMPL *session, WT_CONDVAR *cond, uint64_t usecs, bool *signalled) { DWORD err, milliseconds; WT_DECL_RET; uint64_t milliseconds64; - int locked; + bool locked; - locked = 0; + locked = false; /* Fast path if already signalled. */ - *signalled = 1; + *signalled = true; if (__wt_atomic_addi32(&cond->waiters, 1) == 0) return (0); @@ -68,7 +68,7 @@ __wt_cond_wait_signal( } EnterCriticalSection(&cond->mtx); - locked = 1; + locked = true; if (usecs > 0) { milliseconds64 = usecs / 1000; @@ -101,7 +101,7 @@ __wt_cond_wait_signal( */ if (ret == 0) { if ((err = GetLastError()) == ERROR_TIMEOUT) - *signalled = 0; + *signalled = false; else ret = __wt_errno(); } else @@ -125,9 +125,9 @@ int __wt_cond_signal(WT_SESSION_IMPL *session, WT_CONDVAR *cond) { WT_DECL_RET; - int locked; + bool locked; - locked = 0; + locked = false; /* * !!! @@ -143,7 +143,7 @@ __wt_cond_signal(WT_SESSION_IMPL *session, WT_CONDVAR *cond) if (cond->waiters > 0 || !__wt_atomic_casi32(&cond->waiters, 0, -1)) { EnterCriticalSection(&cond->mtx); - locked = 1; + locked = true; WakeAllConditionVariable(&cond->cond); } diff --git a/src/third_party/wiredtiger/src/os_win/os_open.c b/src/third_party/wiredtiger/src/os_win/os_open.c index 3bd24369242..c7b30408e63 100644 --- a/src/third_party/wiredtiger/src/os_win/os_open.c +++ b/src/third_party/wiredtiger/src/os_win/os_open.c @@ -14,7 +14,7 @@ */ int __wt_open(WT_SESSION_IMPL *session, - const char *name, int ok_create, int exclusive, int dio_type, WT_FH **fhp) + const char *name, bool ok_create, bool exclusive, int dio_type, WT_FH **fhp) { DWORD dwCreationDisposition; HANDLE filehandle, filehandle_secondary; @@ -22,7 +22,8 @@ __wt_open(WT_SESSION_IMPL *session, WT_DECL_RET; WT_FH *fh, *tfh; uint64_t bucket, hash; - int direct_io, f, matched, share_mode; + int f, share_mode; + bool direct_io, matched; char *path; conn = S2C(session); @@ -30,20 +31,20 @@ __wt_open(WT_SESSION_IMPL *session, path = NULL; filehandle = INVALID_HANDLE_VALUE; filehandle_secondary = INVALID_HANDLE_VALUE; - direct_io = 0; + direct_io = false; hash = __wt_hash_city64(name, strlen(name)); bucket = hash % WT_HASH_ARRAY_SIZE; WT_RET(__wt_verbose(session, WT_VERB_FILEOPS, "%s: open", name)); /* Increment the reference count if we already have the file open. */ - matched = 0; + matched = false; __wt_spin_lock(session, &conn->fh_lock); TAILQ_FOREACH(tfh, &conn->fhhash[bucket], hashq) if (strcmp(name, tfh->name) == 0) { ++tfh->ref; *fhp = tfh; - matched = 1; + matched = true; break; } __wt_spin_unlock(session, &conn->fh_lock); @@ -79,7 +80,7 @@ __wt_open(WT_SESSION_IMPL *session, if (dio_type && FLD_ISSET(conn->direct_io, dio_type)) { f |= FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH; - direct_io = 1; + direct_io = true; } if (dio_type == WT_FILE_TYPE_LOG && @@ -158,13 +159,13 @@ setupfh: * Repeat the check for a match, but then link onto the database's list * of files. */ - matched = 0; + matched = false; __wt_spin_lock(session, &conn->fh_lock); TAILQ_FOREACH(tfh, &conn->fhhash[bucket], hashq) if (strcmp(name, tfh->name) == 0) { ++tfh->ref; *fhp = tfh; - matched = 1; + matched = true; break; } if (!matched) { diff --git a/src/third_party/wiredtiger/src/os_win/os_priv.c b/src/third_party/wiredtiger/src/os_win/os_priv.c index b5dc1eb55fe..5c32d6b5999 100644 --- a/src/third_party/wiredtiger/src/os_win/os_priv.c +++ b/src/third_party/wiredtiger/src/os_win/os_priv.c @@ -13,7 +13,7 @@ * Return if the process has special privileges, defined as having * different effective and read UIDs or GIDs. */ -int +bool __wt_has_priv(void) { return (0); diff --git a/src/third_party/wiredtiger/src/packing/pack_impl.c b/src/third_party/wiredtiger/src/packing/pack_impl.c index c92325a4c23..3a4428eae15 100644 --- a/src/third_party/wiredtiger/src/packing/pack_impl.c +++ b/src/third_party/wiredtiger/src/packing/pack_impl.c @@ -15,7 +15,7 @@ */ int __wt_struct_check(WT_SESSION_IMPL *session, - const char *fmt, size_t len, int *fixedp, uint32_t *fixed_lenp) + const char *fmt, size_t len, bool *fixedp, uint32_t *fixed_lenp) { WT_DECL_PACK_VALUE(pv); WT_DECL_RET; diff --git a/src/third_party/wiredtiger/src/reconcile/rec_write.c b/src/third_party/wiredtiger/src/reconcile/rec_write.c index 8a374a1a559..3ad90aeb58c 100644 --- a/src/third_party/wiredtiger/src/reconcile/rec_write.c +++ b/src/third_party/wiredtiger/src/reconcile/rec_write.c @@ -50,7 +50,7 @@ typedef struct { * When we can't mark the page clean (for example, checkpoint found some * uncommitted updates), there's a leave-dirty flag. */ - int leave_dirty; + bool leave_dirty; /* * Raw compression (don't get me started, as if normal reconciliation @@ -61,7 +61,7 @@ typedef struct { * a lot of work, we turn off most compression: dictionary, copy-cell, * prefix and row-store internal page suffix compression are all off. */ - int raw_compression; + bool raw_compression; uint32_t raw_max_slots; /* Raw compression array sizes */ uint32_t *raw_entries; /* Raw compression slot entries */ uint32_t *raw_offsets; /* Raw compression slot offsets */ @@ -86,7 +86,7 @@ typedef struct { * figure out if the rows selected by raw compression included overflow * items, and the optimization isn't worth another pass over the data. */ - int ovfl_items; + bool ovfl_items; /* * Track if reconciliation of a row-store leaf page has seen empty (zero @@ -101,7 +101,7 @@ typedef struct { * The test is per-page reconciliation as described above for the * overflow-item test. */ - int all_empty_value, any_empty_value; + bool all_empty_value, any_empty_value; /* * Reconciliation gets tricky if we have to split a page, which happens @@ -184,7 +184,7 @@ typedef struct { * final block as part of a checkpoint. If raw compression * was configured, that block may have already been compressed. */ - int already_compressed; + bool already_compressed; } *bnd; /* Saved boundaries */ uint32_t bnd_next; /* Next boundary slot */ uint32_t bnd_next_max; /* Maximum boundary slots used */ @@ -241,7 +241,7 @@ typedef struct { * There's some trickiness here, see the code for comments on how * these fields work. */ - int cell_zero; /* Row-store internal page 0th key */ + bool cell_zero; /* Row-store internal page 0th key */ /* * WT_DICTIONARY -- @@ -276,34 +276,32 @@ typedef struct { WT_ITEM *cur, _cur; /* Key/Value being built */ WT_ITEM *last, _last; /* Last key/value built */ - int key_pfx_compress; /* If can prefix-compress next key */ - int key_pfx_compress_conf; /* If prefix compression configured */ - int key_sfx_compress; /* If can suffix-compress next key */ - int key_sfx_compress_conf; /* If suffix compression configured */ + bool key_pfx_compress; /* If can prefix-compress next key */ + bool key_pfx_compress_conf; /* If prefix compression configured */ + bool key_sfx_compress; /* If can suffix-compress next key */ + bool key_sfx_compress_conf; /* If suffix compression configured */ - int is_bulk_load; /* If it's a bulk load */ + bool is_bulk_load; /* If it's a bulk load */ WT_SALVAGE_COOKIE *salvage; /* If it's a salvage operation */ - int cache_write_lookaside; /* Used the lookaside table */ - int cache_write_restore; /* Used update/restoration */ + bool cache_write_lookaside; /* Used the lookaside table */ + bool cache_write_restore; /* Used update/restoration */ uint32_t tested_ref_state; /* Debugging information */ } WT_RECONCILE; -static void __rec_bnd_cleanup(WT_SESSION_IMPL *, WT_RECONCILE *, int); +static void __rec_bnd_cleanup(WT_SESSION_IMPL *, WT_RECONCILE *, bool); static void __rec_cell_build_addr( WT_RECONCILE *, const void *, size_t, u_int, uint64_t); static int __rec_cell_build_int_key(WT_SESSION_IMPL *, - WT_RECONCILE *, const void *, size_t, int *); + WT_RECONCILE *, const void *, size_t, bool *); static int __rec_cell_build_leaf_key(WT_SESSION_IMPL *, - WT_RECONCILE *, const void *, size_t, int *); + WT_RECONCILE *, const void *, size_t, bool *); static int __rec_cell_build_ovfl(WT_SESSION_IMPL *, WT_RECONCILE *, WT_KV *, uint8_t, uint64_t); static int __rec_cell_build_val(WT_SESSION_IMPL *, WT_RECONCILE *, const void *, size_t, uint64_t); -static int __rec_child_deleted( - WT_SESSION_IMPL *, WT_RECONCILE *, WT_REF *, int *); static int __rec_col_fix(WT_SESSION_IMPL *, WT_RECONCILE *, WT_PAGE *); static int __rec_col_fix_slvg(WT_SESSION_IMPL *, WT_RECONCILE *, WT_PAGE *, WT_SALVAGE_COOKIE *); @@ -312,7 +310,7 @@ static int __rec_col_merge(WT_SESSION_IMPL *, WT_RECONCILE *, WT_PAGE *); static int __rec_col_var(WT_SESSION_IMPL *, WT_RECONCILE *, WT_PAGE *, WT_SALVAGE_COOKIE *); static int __rec_col_var_helper(WT_SESSION_IMPL *, WT_RECONCILE *, - WT_SALVAGE_COOKIE *, WT_ITEM *, int, uint8_t, uint64_t); + WT_SALVAGE_COOKIE *, WT_ITEM *, bool, uint8_t, uint64_t); static int __rec_destroy_session(WT_SESSION_IMPL *); static int __rec_root_write(WT_SESSION_IMPL *, WT_PAGE *, uint32_t); static int __rec_row_int(WT_SESSION_IMPL *, WT_RECONCILE *, WT_PAGE *); @@ -328,7 +326,7 @@ static int __rec_split_row(WT_SESSION_IMPL *, WT_RECONCILE *, WT_PAGE *); static int __rec_split_row_promote( WT_SESSION_IMPL *, WT_RECONCILE *, WT_ITEM *, uint8_t); static int __rec_split_write(WT_SESSION_IMPL *, - WT_RECONCILE *, WT_BOUNDARY *, WT_ITEM *, int); + WT_RECONCILE *, WT_BOUNDARY *, WT_ITEM *, bool); static int __rec_update_las( WT_SESSION_IMPL *, WT_RECONCILE *, uint32_t, WT_BOUNDARY *); static int __rec_write_init(WT_SESSION_IMPL *, @@ -458,7 +456,7 @@ __wt_reconcile(WT_SESSION_IMPL *session, * got roped into doing forced eviction, they won't be discarded for the * life of the session. */ - __rec_bnd_cleanup(session, r, 0); + __rec_bnd_cleanup(session, r, false); WT_RET(ret); @@ -478,7 +476,7 @@ __wt_reconcile(WT_SESSION_IMPL *session, * checkpoint, it's cleared the tree's dirty flag, and we don't want to * set it again as part of that walk. */ - return (__wt_page_parent_modify_set(session, ref, 1)); + return (__wt_page_parent_modify_set(session, ref, true)); } /* @@ -624,7 +622,7 @@ __rec_root_write(WT_SESSION_IMPL *session, WT_PAGE *page, uint32_t flags) * write it instead of adding code to write blocks based on the list of * blocks resulting from a multiblock reconciliation. */ - switch (F_ISSET(mod, WT_PM_REC_MASK)) { + switch (mod->rec_result) { case WT_PM_REC_EMPTY: /* Page is empty */ case WT_PM_REC_REPLACE: /* 1-for-1 page swap */ case WT_PM_REC_REWRITE: /* Rewrite */ @@ -644,11 +642,11 @@ __rec_root_write(WT_SESSION_IMPL *session, WT_PAGE *page, uint32_t flags) switch (page->type) { case WT_PAGE_COL_INT: WT_RET(__wt_page_alloc(session, - WT_PAGE_COL_INT, 1, mod->mod_multi_entries, 0, &next)); + WT_PAGE_COL_INT, 1, mod->mod_multi_entries, false, &next)); break; case WT_PAGE_ROW_INT: WT_RET(__wt_page_alloc(session, - WT_PAGE_ROW_INT, 0, mod->mod_multi_entries, 0, &next)); + WT_PAGE_ROW_INT, 0, mod->mod_multi_entries, false, &next)); break; WT_ILLEGAL_VALUE(session); } @@ -818,7 +816,7 @@ __rec_write_init(WT_SESSION_IMPL *session, r->flags = flags; /* Track if the page can be marked clean. */ - r->leave_dirty = 0; + r->leave_dirty = false; /* Raw compression. */ r->raw_compression = @@ -826,11 +824,11 @@ __rec_write_init(WT_SESSION_IMPL *session, r->raw_destination.flags = WT_ITEM_ALIGNED; /* Track overflow items. */ - r->ovfl_items = 0; + r->ovfl_items = false; /* Track empty values. */ - r->all_empty_value = 1; - r->any_empty_value = 0; + r->all_empty_value = true; + r->any_empty_value = false; /* The list of saved updates. */ r->supd_next = 0; @@ -849,6 +847,14 @@ __rec_write_init(WT_SESSION_IMPL *session, r, btree->dictionary < 100 ? 100 : btree->dictionary)); __rec_dictionary_reset(r); + /* + * Prefix compression discards repeated prefix bytes from row-store leaf + * page keys. + */ + r->key_pfx_compress_conf = false; + if (btree->prefix_compression && page->type == WT_PAGE_ROW_LEAF) + r->key_pfx_compress_conf = true; + /* * Suffix compression shortens internal page keys by discarding trailing * bytes that aren't necessary for tree navigation. We don't do suffix @@ -863,21 +869,17 @@ __rec_write_init(WT_SESSION_IMPL *session, * The raw compression routines don't even consider suffix compression, * but it doesn't hurt to confirm that. */ - r->key_sfx_compress_conf = 0; + r->key_sfx_compress_conf = false; if (btree->collator == NULL && btree->internal_key_truncate && !r->raw_compression) - r->key_sfx_compress_conf = 1; + r->key_sfx_compress_conf = true; - /* - * Prefix compression discards repeated prefix bytes from row-store leaf - * page keys. - */ - r->key_pfx_compress_conf = 0; - if (btree->prefix_compression && page->type == WT_PAGE_ROW_LEAF) - r->key_pfx_compress_conf = 1; + r->is_bulk_load = false; r->salvage = salvage; + r->cache_write_lookaside = r->cache_write_restore = false; + /* * Running transactions may update the page after we write it, so * this is the highest ID we can be confident we will see. @@ -907,7 +909,7 @@ __rec_destroy(WT_SESSION_IMPL *session, void *reconcilep) __wt_free(session, r->raw_recnos); __wt_buf_free(session, &r->raw_destination); - __rec_bnd_cleanup(session, r, 1); + __rec_bnd_cleanup(session, r, true); __wt_free(session, r->supd); @@ -937,7 +939,7 @@ __rec_destroy_session(WT_SESSION_IMPL *session) * Cleanup the boundary structure information. */ static void -__rec_bnd_cleanup(WT_SESSION_IMPL *session, WT_RECONCILE *r, int destroy) +__rec_bnd_cleanup(WT_SESSION_IMPL *session, WT_RECONCILE *r, bool destroy) { WT_BOUNDARY *bnd; uint32_t i, last_used; @@ -1057,7 +1059,7 @@ __rec_txn_read(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_UPDATE *append, *upd, *upd_list; size_t notused; uint64_t max_txn, min_txn, txnid; - int append_origv, skipped; + bool append_origv, skipped; *updp = NULL; @@ -1075,7 +1077,7 @@ __rec_txn_read(WT_SESSION_IMPL *session, WT_RECONCILE *r, } else upd_list = ins->upd; - for (skipped = 0, + for (skipped = false, max_txn = WT_TXN_NONE, min_txn = UINT64_MAX, upd = upd_list; upd != NULL; upd = upd->next) { if ((txnid = upd->txnid) == WT_TXN_ABORTED) @@ -1107,7 +1109,7 @@ __rec_txn_read(WT_SESSION_IMPL *session, WT_RECONCILE *r, if (*updp == NULL) *updp = upd; } else - skipped = 1; + skipped = true; } else { /* * Checkpoint can only write updates visible as of its @@ -1121,7 +1123,7 @@ __rec_txn_read(WT_SESSION_IMPL *session, WT_RECONCILE *r, if (__wt_txn_visible(session, txnid)) *updp = upd; else - skipped = 1; + skipped = true; } } } @@ -1177,7 +1179,7 @@ __rec_txn_read(WT_SESSION_IMPL *session, WT_RECONCILE *r, * the page can't be marked clean. */ if (!F_ISSET(r, WT_EVICTING)) { - r->leave_dirty = 1; + r->leave_dirty = true; return (0); } @@ -1202,7 +1204,7 @@ __rec_txn_read(WT_SESSION_IMPL *session, WT_RECONCILE *r, if (skipped && !F_ISSET(r, WT_EVICT_UPDATE_RESTORE)) return (EBUSY); - append_origv = 0; + append_origv = false; if (F_ISSET(r, WT_EVICT_UPDATE_RESTORE)) { /* * The save/restore eviction path. @@ -1216,7 +1218,7 @@ __rec_txn_read(WT_SESSION_IMPL *session, WT_RECONCILE *r, *updp = NULL; /* The page can't be marked clean. */ - r->leave_dirty = 1; + r->leave_dirty = true; /* * A special-case for overflow values, where we can't write the @@ -1254,7 +1256,7 @@ __rec_txn_read(WT_SESSION_IMPL *session, WT_RECONCILE *r, if (vpack != NULL && vpack->raw == WT_CELL_VALUE_OVFL_RM && !__wt_txn_visible_all(session, min_txn)) - append_origv = 1; + append_origv = true; } else { /* * The lookaside table eviction path. @@ -1264,7 +1266,7 @@ __rec_txn_read(WT_SESSION_IMPL *session, WT_RECONCILE *r, * globally visible, readers require the page's original value. */ if (!__wt_txn_visible_all(session, min_txn)) - append_origv = 1; + append_origv = true; } /* @@ -1322,42 +1324,167 @@ __rec_txn_read(WT_SESSION_IMPL *session, WT_RECONCILE *r, } /* - * CHILD_RELEASE -- + * WT_CHILD_RELEASE, WT_CHILD_RELEASE_ERR -- * Macros to clean up during internal-page reconciliation, releasing the * hazard pointer we're holding on child pages. */ -#undef CHILD_RELEASE -#define CHILD_RELEASE(session, hazard, ref) do { \ +#define WT_CHILD_RELEASE(session, hazard, ref) do { \ if (hazard) { \ - hazard = 0; \ + hazard = false; \ WT_TRET( \ __wt_page_release(session, ref, WT_READ_NO_EVICT)); \ } \ } while (0) -#undef CHILD_RELEASE_ERR -#define CHILD_RELEASE_ERR(session, hazard, ref) do { \ - CHILD_RELEASE(session, hazard, ref); \ +#define WT_CHILD_RELEASE_ERR(session, hazard, ref) do { \ + WT_CHILD_RELEASE(session, hazard, ref); \ WT_ERR(ret); \ } while (0) +typedef enum { + WT_CHILD_IGNORE, /* Deleted child: ignore */ + WT_CHILD_MODIFIED, /* Modified child */ + WT_CHILD_ORIGINAL, /* Original child */ + WT_CHILD_PROXY /* Deleted child: proxy */ +} WT_CHILD_STATE; + +/* + * __rec_child_deleted -- + * Handle pages with leaf pages in the WT_REF_DELETED state. + */ +static int +__rec_child_deleted(WT_SESSION_IMPL *session, + WT_RECONCILE *r, WT_REF *ref, WT_CHILD_STATE *statep) +{ + WT_PAGE_DELETED *page_del; + size_t addr_size; + const uint8_t *addr; + + page_del = ref->page_del; + + /* + * Internal pages with child leaf pages in the WT_REF_DELETED state are + * a special case during reconciliation. First, if the deletion was a + * result of a session truncate call, the deletion may not be visible to + * us. In that case, we proceed as with any change not visible during + * reconciliation by ignoring the change for the purposes of writing the + * internal page. + * + * In this case, there must be an associated page-deleted structure, and + * it holds the transaction ID we care about. + * + * In some cases, there had better not be any updates we can't see. + */ + if (F_ISSET(r, WT_VISIBILITY_ERR) && + page_del != NULL && !__wt_txn_visible(session, page_del->txnid)) + WT_PANIC_RET(session, EINVAL, + "reconciliation illegally skipped an update"); + + /* + * Deal with any underlying disk blocks. + * + * First, check to see if there is an address associated with this leaf: + * if there isn't, we're done, the underlying page is already gone. If + * the page still exists, check for any transactions in the system that + * might want to see the page's state before it's deleted. + * + * If any such transactions exist, we cannot discard the underlying leaf + * page to the block manager because the transaction may eventually read + * it. However, this write might be part of a checkpoint, and should we + * recover to that checkpoint, we'll need to delete the leaf page, else + * we'd leak it. The solution is to write a proxy cell on the internal + * page ensuring the leaf page is eventually discarded. + * + * If no such transactions exist, we can discard the leaf page to the + * block manager and no cell needs to be written at all. We do this + * outside of the underlying tracking routines because this action is + * permanent and irrevocable. (Clearing the address means we've lost + * track of the disk address in a permanent way. This is safe because + * there's no path to reading the leaf page again: if there's ever a + * read into this part of the name space again, the cache read function + * instantiates an entirely new page.) + */ + if (ref->addr != NULL && + (page_del == NULL || + __wt_txn_visible_all(session, page_del->txnid))) { + WT_RET(__wt_ref_info(session, ref, &addr, &addr_size, NULL)); + WT_RET(__rec_block_free(session, addr, addr_size)); + + if (__wt_off_page(ref->home, ref->addr)) { + __wt_free(session, ((WT_ADDR *)ref->addr)->addr); + __wt_free(session, ref->addr); + } + ref->addr = NULL; + } + + /* + * If the original page is gone, we can skip the slot on the internal + * page. + */ + if (ref->addr == NULL) { + *statep = WT_CHILD_IGNORE; + + /* + * Minor memory cleanup: if a truncate call deleted this page + * and we were ever forced to instantiate the page in memory, + * we would have built a list of updates in the page reference + * in order to be able to abort the truncate. It's a cheap + * test to make that memory go away, we do it here because + * there's really nowhere else we do the checks. In short, if + * we have such a list, and the backing address blocks are + * gone, there can't be any transaction that can abort. + */ + if (page_del != NULL) { + __wt_free(session, ref->page_del->update_list); + __wt_free(session, ref->page_del); + } + + return (0); + } + + /* + * Internal pages with deletes that aren't stable cannot be evicted, we + * don't have sufficient information to restore the page's information + * if subsequently read (we wouldn't know which transactions should see + * the original page and which should see the deleted page). + */ + if (F_ISSET(r, WT_EVICTING)) + return (EBUSY); + + /* + * If there are deleted child pages we can't discard immediately, keep + * the page dirty so they are eventually freed. + */ + r->leave_dirty = 1; + + /* + * If the original page cannot be freed, we need to keep a slot on the + * page to reference it from the parent page. + * + * If the delete is not visible in this checkpoint, write the original + * address normally. Otherwise, we have to write a proxy record. + */ + if (__wt_txn_visible(session, page_del->txnid)) + *statep = WT_CHILD_PROXY; + + return (0); +} + /* * __rec_child_modify -- * Return if the internal page's child references any modifications. */ static int __rec_child_modify(WT_SESSION_IMPL *session, - WT_RECONCILE *r, WT_REF *ref, int *hazardp, int *statep) + WT_RECONCILE *r, WT_REF *ref, bool *hazardp, WT_CHILD_STATE *statep) { WT_DECL_RET; WT_PAGE_MODIFY *mod; /* We may acquire a hazard pointer our caller must release. */ - *hazardp = 0; + *hazardp = false; -#define WT_CHILD_IGNORE 1 /* Deleted child: ignore */ -#define WT_CHILD_MODIFIED 2 /* Modified child */ -#define WT_CHILD_PROXY 3 /* Deleted child: proxy */ - *statep = 0; + /* Default to using the original child address. */ + *statep = WT_CHILD_ORIGINAL; /* * This function is called when walking an internal page to decide how @@ -1452,7 +1579,7 @@ __rec_child_modify(WT_SESSION_IMPL *session, break; } WT_RET(ret); - *hazardp = 1; + *hazardp = true; goto in_memory; case WT_REF_READING: @@ -1499,120 +1626,17 @@ in_memory: * reason to write the cell. */ mod = ref->page->modify; - if (mod != NULL && F_ISSET(mod, WT_PM_REC_MASK)) + if (mod != NULL && mod->rec_result != 0) *statep = WT_CHILD_MODIFIED; else if (ref->addr == NULL) { *statep = WT_CHILD_IGNORE; - CHILD_RELEASE(session, *hazardp, ref); + WT_CHILD_RELEASE(session, *hazardp, ref); } done: WT_DIAGNOSTIC_YIELD; return (ret); } -/* - * __rec_child_deleted -- - * Handle pages with leaf pages in the WT_REF_DELETED state. - */ -static int -__rec_child_deleted( - WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_REF *ref, int *statep) -{ - WT_PAGE_DELETED *page_del; - size_t addr_size; - const uint8_t *addr; - - page_del = ref->page_del; - - /* - * Internal pages with child leaf pages in the WT_REF_DELETED state are - * a special case during reconciliation. First, if the deletion was a - * result of a session truncate call, the deletion may not be visible to - * us. In that case, we proceed as with any change not visible during - * reconciliation by ignoring the change for the purposes of writing the - * internal page. - * - * In this case, there must be an associated page-deleted structure, and - * it holds the transaction ID we care about. - * - * In some cases, there had better not be any updates we can't see. - */ - if (F_ISSET(r, WT_VISIBILITY_ERR) && - page_del != NULL && !__wt_txn_visible(session, page_del->txnid)) - WT_PANIC_RET(session, EINVAL, - "reconciliation illegally skipped an update"); - - /* - * Deal with any underlying disk blocks. - * - * First, check to see if there is an address associated with this leaf: - * if there isn't, we're done, the underlying page is already gone. If - * the page still exists, check for any transactions in the system that - * might want to see the page's state before it's deleted. - * - * If any such transactions exist, we cannot discard the underlying leaf - * page to the block manager because the transaction may eventually read - * it. However, this write might be part of a checkpoint, and should we - * recover to that checkpoint, we'll need to delete the leaf page, else - * we'd leak it. The solution is to write a proxy cell on the internal - * page ensuring the leaf page is eventually discarded. - * - * If no such transactions exist, we can discard the leaf page to the - * block manager and no cell needs to be written at all. We do this - * outside of the underlying tracking routines because this action is - * permanent and irrevocable. (Clearing the address means we've lost - * track of the disk address in a permanent way. This is safe because - * there's no path to reading the leaf page again: if there's ever a - * read into this part of the name space again, the cache read function - * instantiates an entirely new page.) - */ - if (ref->addr != NULL && - (page_del == NULL || - __wt_txn_visible_all(session, page_del->txnid))) { - WT_RET(__wt_ref_info(session, ref, &addr, &addr_size, NULL)); - WT_RET(__rec_block_free(session, addr, addr_size)); - - if (__wt_off_page(ref->home, ref->addr)) { - __wt_free(session, ((WT_ADDR *)ref->addr)->addr); - __wt_free(session, ref->addr); - } - ref->addr = NULL; - } - - /* - * If there are deleted child pages that we can't discard immediately, - * keep the page dirty so they are eventually freed. - */ - if (ref->addr != NULL) { - r->leave_dirty = 1; - - /* This page cannot be evicted, quit now. */ - if (F_ISSET(r, WT_EVICTING)) - return (EBUSY); - } - - /* - * Minor memory cleanup: if a truncate call deleted this page and we - * were ever forced to instantiate the page in memory, we would have - * built a list of updates in the page reference in order to be able - * to abort the truncate. It's a cheap test to make that memory go - * away, we do it here because there's really nowhere else we do the - * checks. In short, if we have such a list, and the backing address - * blocks are gone, there can't be any transaction that can abort. - */ - if (ref->addr == NULL && page_del != NULL) { - __wt_free(session, ref->page_del->update_list); - __wt_free(session, ref->page_del); - } - - /* - * If there's still a disk address, then we have to write a proxy - * record, otherwise, we can safely ignore this child page. - */ - *statep = ref->addr == NULL ? WT_CHILD_IGNORE : WT_CHILD_PROXY; - return (0); -} - /* * __rec_incr -- * Update the memory tracking structure for a set of new entries. @@ -1718,7 +1742,7 @@ __rec_dict_replace( * Update prefix and suffix compression based on the last key. */ static inline void -__rec_key_state_update(WT_RECONCILE *r, int ovfl_key) +__rec_key_state_update(WT_RECONCILE *r, bool ovfl_key) { WT_ITEM *a; @@ -1748,7 +1772,7 @@ __rec_key_state_update(WT_RECONCILE *r, int ovfl_key) * value and turn on both prefix and suffix compression. */ if (ovfl_key) - r->key_sfx_compress = 0; + r->key_sfx_compress = false; else { a = r->cur; r->cur = r->last; @@ -1859,7 +1883,7 @@ __rec_split_bnd_init(WT_SESSION_IMPL *session, WT_BOUNDARY *bnd) * reconciliation. */ - bnd->already_compressed = 0; + bnd->already_compressed = false; } /* @@ -2045,7 +2069,7 @@ __rec_split_init(WT_SESSION_IMPL *session, r->recno = recno; /* New page, compression off. */ - r->key_pfx_compress = r->key_sfx_compress = 0; + r->key_pfx_compress = r->key_sfx_compress = false; return (0); } @@ -2180,8 +2204,8 @@ __rec_split_row_promote( for (i = r->supd_next; i > 0; --i) { supd = &r->supd[i - 1]; if (supd->ins == NULL) - WT_ERR(__wt_row_leaf_key( - session, r->page, supd->rip, update, 0)); + WT_ERR(__wt_row_leaf_key(session, + r->page, supd->rip, update, false)); else { update->data = WT_INSERT_KEY(supd->ins); update->size = WT_INSERT_KEY_SIZE(supd->ins); @@ -2405,7 +2429,7 @@ __rec_split(WT_SESSION_IMPL *session, WT_RECONCILE *r, size_t next_len) dsk->recno = last->recno; dsk->u.entries = r->entries; dsk->mem_size = r->dsk.size = WT_PTRDIFF32(r->first_free, dsk); - WT_RET(__rec_split_write(session, r, last, &r->dsk, 0)); + WT_RET(__rec_split_write(session, r, last, &r->dsk, false)); /* * Set the caller's entry count and buffer information for the @@ -2444,7 +2468,7 @@ __rec_split(WT_SESSION_IMPL *session, WT_RECONCILE *r, size_t next_len) */ static int __rec_split_raw_worker(WT_SESSION_IMPL *session, - WT_RECONCILE *r, size_t next_len, int no_more_rows) + WT_RECONCILE *r, size_t next_len, bool no_more_rows) { WT_BM *bm; WT_BOUNDARY *last, *next; @@ -2459,7 +2483,7 @@ __rec_split_raw_worker(WT_SESSION_IMPL *session, size_t corrected_page_size, extra_skip, len, result_len; uint64_t recno; uint32_t entry, i, result_slots, slots; - int last_block; + bool last_block; uint8_t *dsk_start; wt_session = (WT_SESSION *)session; @@ -2680,7 +2704,7 @@ __rec_split_raw_worker(WT_SESSION_IMPL *session, * Mark it as uncompressed so the standard compression * function is called before the buffer is written. */ - last->already_compressed = 0; + last->already_compressed = false; } else { WT_STAT_FAST_DATA_INCR(session, compress_raw_ok); @@ -2701,7 +2725,7 @@ __rec_split_raw_worker(WT_SESSION_IMPL *session, if (result_slots == slots && !no_more_rows) result_slots = 0; else - last->already_compressed = 1; + last->already_compressed = true; } break; default: @@ -2790,7 +2814,7 @@ no_slots: r->space_avail = r->page_size - WT_PAGE_HEADER_BYTE_SIZE(btree); write_ref = &r->dsk; - last->already_compressed = 0; + last->already_compressed = false; } else { /* * Compression failed, there are more rows to accumulate and the @@ -2875,8 +2899,8 @@ __rec_raw_decompress( WT_ERR(__wt_illegal_value(session, btree->dhandle->name)); WT_ERR(__wt_strndup(session, tmp->data, dsk->mem_size, retp)); - WT_ASSERT(session, __wt_verify_dsk_image( - session, "[raw evict split]", tmp->data, dsk->mem_size, 0) == 0); + WT_ASSERT(session, __wt_verify_dsk_image(session, + "[raw evict split]", tmp->data, dsk->mem_size, false) == 0); err: __wt_scr_free(session, &tmp); return (ret); @@ -2889,7 +2913,7 @@ err: __wt_scr_free(session, &tmp); static inline int __rec_split_raw(WT_SESSION_IMPL *session, WT_RECONCILE *r, size_t next_len) { - return (__rec_split_raw_worker(session, r, next_len, 0)); + return (__rec_split_raw_worker(session, r, next_len, false)); } /* @@ -2967,7 +2991,7 @@ __rec_split_finish_std(WT_SESSION_IMPL *session, WT_RECONCILE *r) /* If this is a checkpoint, we're done, otherwise write the page. */ return (__rec_is_checkpoint(session, r, bnd) ? - 0 : __rec_split_write(session, r, bnd, &r->dsk, 1)); + 0 : __rec_split_write(session, r, bnd, &r->dsk, true)); } /* @@ -2980,7 +3004,7 @@ __rec_split_finish(WT_SESSION_IMPL *session, WT_RECONCILE *r) /* We're done reconciling - write the final page */ if (r->raw_compression && r->entries != 0) { while (r->entries != 0) - WT_RET(__rec_split_raw_worker(session, r, 0, 1)); + WT_RET(__rec_split_raw_worker(session, r, 0, true)); } else WT_RET(__rec_split_finish_std(session, r)); @@ -3036,7 +3060,7 @@ __rec_split_fixup(WT_SESSION_IMPL *session, WT_RECONCILE *r) dsk->u.entries = bnd->entries; tmp->size = WT_PAGE_HEADER_BYTE_SIZE(btree) + len; dsk->mem_size = WT_STORE_SIZE(tmp->size); - WT_ERR(__rec_split_write(session, r, bnd, tmp, 0)); + WT_ERR(__rec_split_write(session, r, bnd, tmp, false)); } /* @@ -3084,7 +3108,7 @@ err: __wt_scr_free(session, &tmp); */ static int __rec_split_write(WT_SESSION_IMPL *session, - WT_RECONCILE *r, WT_BOUNDARY *bnd, WT_ITEM *buf, int last_block) + WT_RECONCILE *r, WT_BOUNDARY *bnd, WT_ITEM *buf, bool last_block) { WT_BTREE *btree; WT_DECL_ITEM(key); @@ -3166,7 +3190,7 @@ __rec_split_write(WT_SESSION_IMPL *session, case WT_PAGE_ROW_LEAF: if (supd->ins == NULL) WT_ERR(__wt_row_leaf_key( - session, page, supd->rip, key, 0)); + session, page, supd->rip, key, false)); else { key->data = WT_INSERT_KEY(supd->ins); key->size = WT_INSERT_KEY_SIZE(supd->ins); @@ -3198,7 +3222,7 @@ supd_check_complete: */ if (F_ISSET(r, WT_EVICT_LOOKASIDE) && bnd->supd != NULL) { F_SET(dsk, WT_PAGE_LAS_UPDATE); - r->cache_write_lookaside = 1; + r->cache_write_lookaside = true; } /* @@ -3208,7 +3232,7 @@ supd_check_complete: * updates we skipped. */ if (F_ISSET(r, WT_EVICT_UPDATE_RESTORE) && bnd->supd != NULL) { - r->cache_write_restore = 1; + r->cache_write_restore = true; /* * If the buffer is compressed (raw compression was configured), @@ -3227,7 +3251,7 @@ supd_check_complete: WT_ERR(__wt_strndup( session, buf->data, buf->size, &bnd->dsk)); WT_ASSERT(session, __wt_verify_dsk_image(session, - "[evict split]", buf->data, buf->size, 1) == 0); + "[evict split]", buf->data, buf->size, true) == 0); } goto done; } @@ -3244,7 +3268,8 @@ supd_check_complete: */ bnd_slot = (uint32_t)(bnd - r->bnd); if (bnd_slot > 1 || - (F_ISSET(mod, WT_PM_REC_MULTIBLOCK) && mod->mod_multi != NULL)) { + (mod->rec_result == WT_PM_REC_MULTIBLOCK && + mod->mod_multi != NULL)) { /* * There are page header fields which need to be cleared to get * consistent checksums: specifically, the write generation and @@ -3256,7 +3281,7 @@ supd_check_complete: memset(WT_BLOCK_HEADER_REF(dsk), 0, btree->block_header); bnd->cksum = __wt_cksum(buf->data, buf->size); - if (F_ISSET(mod, WT_PM_REC_MULTIBLOCK) && + if (mod->rec_result == WT_PM_REC_MULTIBLOCK && mod->mod_multi_entries > bnd_slot) { multi = &mod->mod_multi[bnd_slot]; if (multi->size == bnd->size && @@ -3271,7 +3296,7 @@ supd_check_complete: } WT_ERR(__wt_bt_write(session, - buf, addr, &addr_size, 0, bnd->already_compressed)); + buf, addr, &addr_size, false, bnd->already_compressed)); WT_ERR(__wt_strndup(session, addr, addr_size, &bnd->addr.addr)); bnd->addr.size = (uint8_t)addr_size; @@ -3364,7 +3389,7 @@ __rec_update_las(WT_SESSION_IMPL *session, case WT_PAGE_ROW_LEAF: if (list->ins == NULL) WT_ERR(__wt_row_leaf_key( - session, page, list->rip, key, 0)); + session, page, list->rip, key, false)); else { key->data = WT_INSERT_KEY(list->ins); key->size = WT_INSERT_KEY_SIZE(list->ins); @@ -3448,7 +3473,7 @@ __wt_bulk_init(WT_SESSION_IMPL *session, WT_CURSOR_BULK *cbulk) WT_RET( __rec_write_init(session, cbulk->ref, 0, NULL, &cbulk->reconcile)); r = cbulk->reconcile; - r->is_bulk_load = 1; + r->is_bulk_load = true; switch (btree->type) { case BTREE_COL_FIX: @@ -3520,7 +3545,7 @@ __wt_bulk_insert_row(WT_SESSION_IMPL *session, WT_CURSOR_BULK *cbulk) WT_CURSOR *cursor; WT_KV *key, *val; WT_RECONCILE *r; - int ovfl_key; + bool ovfl_key; r = cbulk->reconcile; btree = S2BT(session); @@ -3545,7 +3570,7 @@ __wt_bulk_insert_row(WT_SESSION_IMPL *session, WT_CURSOR_BULK *cbulk) * overflow key), rebuild the key without compression. */ if (r->key_pfx_compress_conf) { - r->key_pfx_compress = 0; + r->key_pfx_compress = false; if (!ovfl_key) WT_RET(__rec_cell_build_leaf_key( session, r, NULL, 0, &ovfl_key)); @@ -3558,9 +3583,9 @@ __wt_bulk_insert_row(WT_SESSION_IMPL *session, WT_CURSOR_BULK *cbulk) /* Copy the key/value pair onto the page. */ __rec_copy_incr(session, r, key); if (val->len == 0) - r->any_empty_value = 1; + r->any_empty_value = true; else { - r->all_empty_value = 0; + r->all_empty_value = false; if (btree->dictionary) WT_RET(__rec_dict_replace(session, r, 0, val)); __rec_copy_incr(session, r, val); @@ -3718,15 +3743,16 @@ __rec_col_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) WT_ADDR *addr; WT_BTREE *btree; WT_CELL_UNPACK *vpack, _vpack; + WT_CHILD_STATE state; WT_DECL_RET; WT_KV *val; WT_PAGE *child; WT_REF *ref; - int hazard, state; + bool hazard; btree = S2BT(session); child = NULL; - hazard = 0; + hazard = false; val = &r->v; vpack = &_vpack; @@ -3748,18 +3774,18 @@ __rec_col_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) addr = NULL; child = ref->page; - /* Deleted child we don't have to write. */ - if (state == WT_CHILD_IGNORE) { - CHILD_RELEASE_ERR(session, hazard, ref); + switch (state) { + case WT_CHILD_IGNORE: + /* Deleted child we don't have to write. */ + WT_CHILD_RELEASE_ERR(session, hazard, ref); continue; - } - /* - * Modified child. Empty pages are merged into the parent and - * discarded. - */ - if (state == WT_CHILD_MODIFIED) { - switch (F_ISSET(child->modify, WT_PM_REC_MASK)) { + case WT_CHILD_MODIFIED: + /* + * Modified child. Empty pages are merged into the + * parent and discarded. + */ + switch (child->modify->rec_result) { case WT_PM_REC_EMPTY: /* * Column-store pages are almost never empty, as @@ -3767,11 +3793,11 @@ __rec_col_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) * name space. The exceptions are pages created * when the tree is created, and never filled. */ - CHILD_RELEASE_ERR(session, hazard, ref); + WT_CHILD_RELEASE_ERR(session, hazard, ref); continue; case WT_PM_REC_MULTIBLOCK: WT_ERR(__rec_col_merge(session, r, child)); - CHILD_RELEASE_ERR(session, hazard, ref); + WT_CHILD_RELEASE_ERR(session, hazard, ref); continue; case WT_PM_REC_REPLACE: addr = &child->modify->mod_replace; @@ -3780,9 +3806,18 @@ __rec_col_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) break; WT_ILLEGAL_VALUE_ERR(session); } - } else - /* No other states are expected for column stores. */ - WT_ASSERT(session, state == 0); + break; + case WT_CHILD_ORIGINAL: + /* Original child. */ + break; + case WT_CHILD_PROXY: + /* + * Deleted child where we write a proxy cell, not + * yet supported for column-store. + */ + ret = __wt_illegal_value(session, NULL); + goto err; + } /* * Build the value cell. The child page address is in one of 3 @@ -3804,7 +3839,7 @@ __rec_col_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) } else __rec_cell_build_addr(r, addr->addr, addr->size, __rec_vtype(addr), ref->key.recno); - CHILD_RELEASE_ERR(session, hazard, ref); + WT_CHILD_RELEASE_ERR(session, hazard, ref); /* Boundary: split or write the page. */ if (val->len > r->space_avail) @@ -3819,7 +3854,7 @@ __rec_col_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) /* Write the remnant page. */ return (__rec_split_finish(session, r)); -err: CHILD_RELEASE(session, hazard, ref); +err: WT_CHILD_RELEASE(session, hazard, ref); return (ret); } @@ -4020,7 +4055,7 @@ __rec_col_fix_slvg(WT_SESSION_IMPL *session, static int __rec_col_var_helper(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_SALVAGE_COOKIE *salvage, - WT_ITEM *value, int deleted, uint8_t overflow_type, uint64_t rle) + WT_ITEM *value, bool deleted, uint8_t overflow_type, uint64_t rle) { WT_BTREE *btree; WT_KV *val; @@ -4112,7 +4147,7 @@ __rec_col_var(WT_SESSION_IMPL *session, WT_UPDATE *upd; uint64_t n, nrepeat, repeat_count, rle, skip, src_recno; uint32_t i, size; - int deleted, last_deleted, orig_deleted, update_no_copy; + bool deleted, last_deleted, orig_deleted, update_no_copy; const void *data; btree = S2BT(session); @@ -4139,11 +4174,11 @@ __rec_col_var(WT_SESSION_IMPL *session, * helper function's assistance.) */ rle = 0; - last_deleted = 0; + last_deleted = false; if (salvage != NULL && salvage->missing != 0) { if (salvage->skip == 0) { rle = salvage->missing; - last_deleted = 1; + last_deleted = true; /* * Correct the number of records we're going to "take", @@ -4151,8 +4186,8 @@ __rec_col_var(WT_SESSION_IMPL *session, */ salvage->take += salvage->missing; } else - WT_ERR(__rec_col_var_helper( - session, r, NULL, NULL, 1, 0, salvage->missing)); + WT_ERR(__rec_col_var_helper(session, + r, NULL, NULL, true, false, salvage->missing)); } /* @@ -4174,7 +4209,7 @@ __rec_col_var(WT_SESSION_IMPL *session, if ((cell = WT_COL_PTR(page, cip)) == NULL) { nrepeat = 1; ins = NULL; - orig_deleted = 1; + orig_deleted = true; } else { __wt_cell_unpack(cell, vpack); nrepeat = __wt_cell_rle(vpack); @@ -4184,7 +4219,7 @@ __rec_col_var(WT_SESSION_IMPL *session, * If the original value is "deleted", there's no value * to compare, we're done. */ - orig_deleted = vpack->type == WT_CELL_DEL ? 1 : 0; + orig_deleted = vpack->type == WT_CELL_DEL; if (orig_deleted) goto record_loop; @@ -4237,7 +4272,7 @@ record_loop: /* ins = WT_SKIP_NEXT(ins); } if (upd != NULL) { - update_no_copy = 1; /* No data copy */ + update_no_copy = true; /* No data copy */ repeat_count = 1; /* Single record */ deleted = WT_UPDATE_DELETED_ISSET(upd); @@ -4246,10 +4281,10 @@ record_loop: /* size = upd->size; } } else if (vpack->raw == WT_CELL_VALUE_OVFL_RM) { - update_no_copy = 1; /* No data copy */ + update_no_copy = true; /* No data copy */ repeat_count = 1; /* Single record */ - deleted = 0; + deleted = false; /* * If doing update save and restore, there's an @@ -4278,7 +4313,7 @@ record_loop: /* data = "@"; size = 1; } else { - update_no_copy = 0; /* Maybe data copy */ + update_no_copy = false; /* Maybe data copy */ /* * The repeat count is the number of records up @@ -4322,11 +4357,11 @@ record_loop: /* last->data = vpack->data; last->size = vpack->size; WT_ERR(__rec_col_var_helper( - session, r, salvage, last, 0, + session, r, salvage, last, false, WT_CELL_VALUE_OVFL, repeat_count)); /* Track if page has overflow items. */ - r->ovfl_items = 1; + r->ovfl_items = true; ovfl_state = OVFL_USED; continue; @@ -4430,7 +4465,7 @@ compare: /* * part. */ if (src_recno < n) { - deleted = 1; + deleted = true; if (last_deleted) { /* * The record adjustment is decremented @@ -4507,6 +4542,7 @@ __rec_row_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) WT_BTREE *btree; WT_CELL *cell; WT_CELL_UNPACK *kpack, _kpack, *vpack, _vpack; + WT_CHILD_STATE state; WT_DECL_RET; WT_IKEY *ikey; WT_KV *key, *val; @@ -4514,12 +4550,12 @@ __rec_row_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) WT_REF *ref; size_t size; u_int vtype; - int hazard, key_onpage_ovfl, ovfl_key, state; + bool hazard, key_onpage_ovfl, ovfl_key; const void *p; btree = S2BT(session); child = NULL; - hazard = 0; + hazard = false; key = &r->k; kpack = &_kpack; @@ -4546,7 +4582,7 @@ __rec_row_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) * have to special case transforming the page from its disk image to * its in-memory version, for example). */ - r->cell_zero = 1; + r->cell_zero = true; /* For each entry in the in-memory page... */ WT_INTL_FOREACH_BEGIN(session, page, ref) { @@ -4562,7 +4598,7 @@ __rec_row_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) ikey = __wt_ref_key_instantiated(ref); if (ikey == NULL || ikey->cell_offset == 0) { cell = NULL; - key_onpage_ovfl = 0; + key_onpage_ovfl = false; } else { cell = WT_PAGE_REF_OFFSET(page, ikey->cell_offset); __wt_cell_unpack(cell, kpack); @@ -4574,9 +4610,11 @@ __rec_row_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) addr = ref->addr; child = ref->page; - /* Deleted child we don't have to write. */ - if (state == WT_CHILD_IGNORE) { + switch (state) { + case WT_CHILD_IGNORE: /* + * Deleted child we don't have to write. + * * Overflow keys referencing discarded pages are no * longer useful, schedule them for discard. Don't * worry about instantiation, internal page keys are @@ -4586,16 +4624,15 @@ __rec_row_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) if (key_onpage_ovfl) WT_ERR(__wt_ovfl_discard_add( session, page, kpack->cell)); - CHILD_RELEASE_ERR(session, hazard, ref); + WT_CHILD_RELEASE_ERR(session, hazard, ref); continue; - } - /* - * Modified child. Empty pages are merged into the parent and - * discarded. - */ - if (state == WT_CHILD_MODIFIED) - switch (F_ISSET(child->modify, WT_PM_REC_MASK)) { + case WT_CHILD_MODIFIED: + /* + * Modified child. Empty pages are merged into the + * parent and discarded. + */ + switch (child->modify->rec_result) { case WT_PM_REC_EMPTY: /* * Overflow keys referencing empty pages are no @@ -4608,7 +4645,7 @@ __rec_row_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) if (key_onpage_ovfl) WT_ERR(__wt_ovfl_discard_add( session, page, kpack->cell)); - CHILD_RELEASE_ERR(session, hazard, ref); + WT_CHILD_RELEASE_ERR(session, hazard, ref); continue; case WT_PM_REC_MULTIBLOCK: /* @@ -4625,7 +4662,7 @@ __rec_row_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) session, page, kpack->cell)); WT_ERR(__rec_row_merge(session, r, child)); - CHILD_RELEASE_ERR(session, hazard, ref); + WT_CHILD_RELEASE_ERR(session, hazard, ref); continue; case WT_PM_REC_REPLACE: /* @@ -4636,6 +4673,14 @@ __rec_row_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) break; WT_ILLEGAL_VALUE_ERR(session); } + break; + case WT_CHILD_ORIGINAL: + /* Original child. */ + break; + case WT_CHILD_PROXY: + /* Deleted child where we write a proxy cell. */ + break; + } /* * Build the value cell, the child page's address. Addr points @@ -4657,7 +4702,7 @@ __rec_row_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) WT_CELL_ADDR_DEL : (u_int)vpack->raw; } __rec_cell_build_addr(r, p, size, vtype, WT_RECNO_OOB); - CHILD_RELEASE_ERR(session, hazard, ref); + WT_CHILD_RELEASE_ERR(session, hazard, ref); /* * Build key cell. @@ -4668,13 +4713,13 @@ __rec_row_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) key->buf.size = __wt_cell_total_len(kpack); key->cell_len = 0; key->len = key->buf.size; - ovfl_key = 1; + ovfl_key = true; } else { __wt_ref_key(page, ref, &p, &size); WT_ERR(__rec_cell_build_int_key( session, r, p, r->cell_zero ? 1 : size, &ovfl_key)); } - r->cell_zero = 0; + r->cell_zero = false; /* Boundary: split or write the page. */ if (key->len + val->len > r->space_avail) { @@ -4691,7 +4736,7 @@ __rec_row_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) if (key_onpage_ovfl) { WT_ERR(__wt_buf_set(session, r->cur, WT_IKEY_DATA(ikey), ikey->size)); - key_onpage_ovfl = 0; + key_onpage_ovfl = false; } WT_ERR(__rec_split( session, r, key->len + val->len)); @@ -4709,7 +4754,7 @@ __rec_row_int(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) /* Write the remnant page. */ return (__rec_split_finish(session, r)); -err: CHILD_RELEASE(session, hazard, ref); +err: WT_CHILD_RELEASE(session, hazard, ref); return (ret); } @@ -4725,7 +4770,7 @@ __rec_row_merge(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) WT_MULTI *multi; WT_PAGE_MODIFY *mod; uint32_t i; - int ovfl_key; + bool ovfl_key; mod = page->modify; @@ -4739,7 +4784,7 @@ __rec_row_merge(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) WT_RET(__rec_cell_build_int_key(session, r, WT_IKEY_DATA(multi->key.ikey), r->cell_zero ? 1 : multi->key.ikey->size, &ovfl_key)); - r->cell_zero = 0; + r->cell_zero = false; addr = &multi->addr; __rec_cell_build_addr( @@ -4783,7 +4828,7 @@ __rec_row_leaf(WT_SESSION_IMPL *session, size_t size; uint64_t slvg_skip; uint32_t i; - int dictionary, key_onpage_ovfl, ovfl_key; + bool dictionary, key_onpage_ovfl, ovfl_key; const void *p; void *copy; @@ -4851,7 +4896,7 @@ __rec_row_leaf(WT_SESSION_IMPL *session, WT_ERR(__rec_txn_read(session, r, NULL, rip, vpack, &upd)); /* Build value cell. */ - dictionary = 0; + dictionary = false; if (upd == NULL) { /* * When the page was read into memory, there may not @@ -4880,7 +4925,7 @@ __rec_row_leaf(WT_SESSION_IMPL *session, } WT_ERR(__rec_cell_build_val( session, r, p, size, (uint64_t)0)); - dictionary = 1; + dictionary = true; } else if (vpack->raw == WT_CELL_VALUE_OVFL_RM) { /* * If doing update save and restore in service @@ -4936,7 +4981,7 @@ __rec_row_leaf(WT_SESSION_IMPL *session, /* Track if page has overflow items. */ if (vpack->ovfl) - r->ovfl_items = 1; + r->ovfl_items = true; } } else { /* @@ -4973,7 +5018,7 @@ __rec_row_leaf(WT_SESSION_IMPL *session, if (ikey == NULL) WT_ERR(__wt_row_leaf_key( session, - page, rip, tmpkey, 1)); + page, rip, tmpkey, true)); WT_ERR(__wt_ovfl_discard_add( session, page, kpack->cell)); @@ -5002,7 +5047,7 @@ __rec_row_leaf(WT_SESSION_IMPL *session, WT_ERR(__rec_cell_build_val(session, r, WT_UPDATE_DATA(upd), upd->size, (uint64_t)0)); - dictionary = 1; + dictionary = true; } } @@ -5019,7 +5064,7 @@ __rec_row_leaf(WT_SESSION_IMPL *session, key->buf.size = __wt_cell_total_len(kpack); key->cell_len = 0; key->len = key->buf.size; - ovfl_key = 1; + ovfl_key = true; /* * We aren't creating a key so we can't use this key as @@ -5028,7 +5073,7 @@ __rec_row_leaf(WT_SESSION_IMPL *session, tmpkey->size = 0; /* Track if page has overflow items. */ - r->ovfl_items = 1; + r->ovfl_items = true; } else { /* * Get the key from the page or an instantiated key, or @@ -5092,7 +5137,7 @@ build: if (key_onpage_ovfl) { WT_ERR(__wt_dsk_cell_data_ref(session, WT_PAGE_ROW_LEAF, kpack, r->cur)); - key_onpage_ovfl = 0; + key_onpage_ovfl = false; } /* @@ -5102,7 +5147,7 @@ build: * key without compression. */ if (r->key_pfx_compress_conf) { - r->key_pfx_compress = 0; + r->key_pfx_compress = false; if (!ovfl_key) WT_ERR( __rec_cell_build_leaf_key( @@ -5118,9 +5163,9 @@ build: /* Copy the key/value pair onto the page. */ __rec_copy_incr(session, r, key); if (val->len == 0) - r->any_empty_value = 1; + r->any_empty_value = true; else { - r->all_empty_value = 0; + r->all_empty_value = false; if (dictionary && btree->dictionary) WT_ERR(__rec_dict_replace(session, r, 0, val)); __rec_copy_incr(session, r, val); @@ -5152,7 +5197,7 @@ __rec_row_leaf_insert(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_INSERT *ins) WT_BTREE *btree; WT_KV *key, *val; WT_UPDATE *upd; - int ovfl_key; + bool ovfl_key; btree = S2BT(session); @@ -5188,7 +5233,7 @@ __rec_row_leaf_insert(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_INSERT *ins) * key without compression. */ if (r->key_pfx_compress_conf) { - r->key_pfx_compress = 0; + r->key_pfx_compress = false; if (!ovfl_key) WT_RET( __rec_cell_build_leaf_key( @@ -5204,9 +5249,9 @@ __rec_row_leaf_insert(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_INSERT *ins) /* Copy the key/value pair onto the page. */ __rec_copy_incr(session, r, key); if (val->len == 0) - r->any_empty_value = 1; + r->any_empty_value = true; else { - r->all_empty_value = 0; + r->all_empty_value = false; if (btree->dictionary) WT_RET(__rec_dict_replace(session, r, 0, val)); __rec_copy_incr(session, r, val); @@ -5310,7 +5355,7 @@ __rec_write_wrapup(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) * and clear the underlying modification information, we're creating a * new reality. */ - switch (F_ISSET(mod, WT_PM_REC_MASK)) { + switch (mod->rec_result) { case 0: /* * The page has never been reconciled before, free the original * address blocks (if any). The "if any" is for empty trees @@ -5364,7 +5409,9 @@ __rec_write_wrapup(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) break; WT_ILLEGAL_VALUE(session); } - F_CLR(mod, WT_PM_REC_MASK); + + /* Reset the reconciliation state. */ + mod->rec_result = 0; /* * Wrap up overflow tracking. If we are about to create a checkpoint, @@ -5384,8 +5431,8 @@ __rec_write_wrapup(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) /* If this is the root page, we need to create a sync point. */ ref = r->ref; if (__wt_ref_is_root(ref)) - WT_RET( - bm->checkpoint(bm, session, NULL, btree->ckpt, 0)); + WT_RET(bm->checkpoint( + bm, session, NULL, btree->ckpt, false)); /* * If the page was empty, we want to discard it from the tree @@ -5394,7 +5441,7 @@ __rec_write_wrapup(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) * page in memory. If the page is subsequently modified, that * is OK, we'll just reconcile it again. */ - F_SET(mod, WT_PM_REC_EMPTY); + mod->rec_result = WT_PM_REC_EMPTY; break; case 1: /* 1-for-1 page swap */ /* @@ -5420,7 +5467,7 @@ __rec_write_wrapup(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) bnd->dsk = NULL; mod->mod_multi_entries = 1; - F_SET(mod, WT_PM_REC_REWRITE); + mod->rec_result = WT_PM_REC_REWRITE; break; } @@ -5430,14 +5477,14 @@ __rec_write_wrapup(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) * we were about to write the buffer so we know what to do here. */ if (bnd->addr.addr == NULL) - WT_RET(__wt_bt_write(session, - &r->dsk, NULL, NULL, 1, bnd->already_compressed)); + WT_RET(__wt_bt_write(session, &r->dsk, + NULL, NULL, true, bnd->already_compressed)); else { mod->mod_replace = bnd->addr; bnd->addr.addr = NULL; } - F_SET(mod, WT_PM_REC_REPLACE); + mod->rec_result = WT_PM_REC_REPLACE; break; default: /* Page split */ WT_RET(__wt_verbose(session, WT_VERB_RECONCILE, @@ -5512,7 +5559,7 @@ err: __wt_scr_free(session, &tkey); break; WT_ILLEGAL_VALUE(session); } - F_SET(mod, WT_PM_REC_MULTIBLOCK); + mod->rec_result = WT_PM_REC_MULTIBLOCK; break; } return (0); @@ -5538,7 +5585,7 @@ __rec_write_wrapup_err(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) * information (otherwise we might think the backing block is being * reused on a subsequent reconciliation where we want to free it). */ - switch (F_ISSET(mod, WT_PM_REC_MASK)) { + switch (mod->rec_result) { case WT_PM_REC_MULTIBLOCK: case WT_PM_REC_REWRITE: for (multi = mod->mod_multi, @@ -5620,6 +5667,15 @@ __rec_split_row(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) } mod->mod_multi_entries = r->bnd_next; + /* + * We can't evict clean, multiblock row-store pages with overflow keys + * when the file is being checkpointed: the split into the parent frees + * the backing blocks for no-longer-used overflow keys, corrupting the + * checkpoint's block management. Column-store pages have no overflow + * keys, so they're not a problem, track overflow items for row-store. + */ + mod->mod_multi_row_ovfl = r->ovfl_items; + return (0); } @@ -5670,12 +5726,12 @@ __rec_split_col(WT_SESSION_IMPL *session, WT_RECONCILE *r, WT_PAGE *page) */ static int __rec_cell_build_int_key(WT_SESSION_IMPL *session, - WT_RECONCILE *r, const void *data, size_t size, int *is_ovflp) + WT_RECONCILE *r, const void *data, size_t size, bool *is_ovflp) { WT_BTREE *btree; WT_KV *key; - *is_ovflp = 0; + *is_ovflp = false; btree = S2BT(session); @@ -5689,7 +5745,7 @@ __rec_cell_build_int_key(WT_SESSION_IMPL *session, if (size > btree->maxintlkey) { WT_STAT_FAST_DATA_INCR(session, rec_overflow_key_internal); - *is_ovflp = 1; + *is_ovflp = true; return (__rec_cell_build_ovfl( session, r, key, WT_CELL_KEY_OVFL, (uint64_t)0)); } @@ -5707,7 +5763,7 @@ __rec_cell_build_int_key(WT_SESSION_IMPL *session, */ static int __rec_cell_build_leaf_key(WT_SESSION_IMPL *session, - WT_RECONCILE *r, const void *data, size_t size, int *is_ovflp) + WT_RECONCILE *r, const void *data, size_t size, bool *is_ovflp) { WT_BTREE *btree; WT_KV *key; @@ -5715,7 +5771,7 @@ __rec_cell_build_leaf_key(WT_SESSION_IMPL *session, uint8_t pfx; const uint8_t *a, *b; - *is_ovflp = 0; + *is_ovflp = false; btree = S2BT(session); @@ -5789,7 +5845,7 @@ __rec_cell_build_leaf_key(WT_SESSION_IMPL *session, if (pfx == 0) { WT_STAT_FAST_DATA_INCR(session, rec_overflow_key_leaf); - *is_ovflp = 1; + *is_ovflp = true; return (__rec_cell_build_ovfl( session, r, key, WT_CELL_KEY_OVFL, (uint64_t)0)); } @@ -5903,7 +5959,7 @@ __rec_cell_build_ovfl(WT_SESSION_IMPL *session, page = r->page; /* Track if page has overflow items. */ - r->ovfl_items = 1; + r->ovfl_items = true; /* * See if this overflow record has already been written and reuse it if @@ -5929,7 +5985,7 @@ __rec_cell_build_ovfl(WT_SESSION_IMPL *session, /* Write the buffer. */ addr = buf; - WT_ERR(__wt_bt_write(session, tmp, addr, &size, 0, 0)); + WT_ERR(__wt_bt_write(session, tmp, addr, &size, false, false)); /* * Track the overflow record (unless it's a bulk load, which @@ -6099,7 +6155,7 @@ __rec_dictionary_lookup( { WT_DICTIONARY *dp, *next; uint64_t hash; - int match; + bool match; *dpp = NULL; diff --git a/src/third_party/wiredtiger/src/schema/schema_create.c b/src/third_party/wiredtiger/src/schema/schema_create.c index 4041a1d7b9f..db4658cbd0e 100644 --- a/src/third_party/wiredtiger/src/schema/schema_create.c +++ b/src/third_party/wiredtiger/src/schema/schema_create.c @@ -70,12 +70,12 @@ __wt_direct_io_size_check(WT_SESSION_IMPL *session, */ static int __create_file(WT_SESSION_IMPL *session, - const char *uri, int exclusive, const char *config) + const char *uri, bool exclusive, const char *config) { WT_DECL_ITEM(val); WT_DECL_RET; uint32_t allocsize; - int is_metadata; + bool is_metadata; const char *filename, **p, *filecfg[] = { WT_CONFIG_BASE(session, file_meta), config, NULL, NULL }; char *fileconf; @@ -135,7 +135,7 @@ __create_file(WT_SESSION_IMPL *session, WT_ERR(__wt_session_get_btree( session, uri, NULL, NULL, WT_DHANDLE_EXCLUSIVE)); if (WT_META_TRACKING(session)) - WT_ERR(__wt_meta_track_handle_lock(session, 1)); + WT_ERR(__wt_meta_track_handle_lock(session, true)); else WT_ERR(__wt_session_release_btree(session)); @@ -186,7 +186,7 @@ __wt_schema_colgroup_source(WT_SESSION_IMPL *session, */ static int __create_colgroup(WT_SESSION_IMPL *session, - const char *name, int exclusive, const char *config) + const char *name, bool exclusive, const char *config) { WT_CONFIG_ITEM cval; WT_DECL_RET; @@ -216,7 +216,7 @@ __create_colgroup(WT_SESSION_IMPL *session, tlen = strlen(tablename); if ((ret = - __wt_schema_get_table(session, tablename, tlen, 1, &table)) != 0) + __wt_schema_get_table(session, tablename, tlen, true, &table)) != 0) WT_RET_MSG(session, (ret == WT_NOTFOUND) ? ENOENT : ret, "Can't create '%s' for non-existent table '%.*s'", name, (int)tlen, tablename); @@ -258,7 +258,7 @@ __create_colgroup(WT_SESSION_IMPL *session, "No 'columns' configuration for '%s'", name); WT_ERR(__wt_buf_catfmt(session, &fmt, ",value_format=")); WT_ERR(__wt_struct_reformat(session, - table, cval.str, cval.len, NULL, 1, &fmt)); + table, cval.str, cval.len, NULL, true, &fmt)); } sourcecfg[1] = fmt.data; WT_ERR(__wt_config_merge(session, sourcecfg, NULL, &sourceconf)); @@ -321,18 +321,60 @@ __wt_schema_index_source(WT_SESSION_IMPL *session, return (0); } +/* + * __fill_index -- + * Fill the index from the current contents of the table. + */ +static int +__fill_index(WT_SESSION_IMPL *session, WT_TABLE *table, WT_INDEX *idx) +{ + WT_DECL_RET; + WT_CURSOR *tcur, *icur; + WT_SESSION *wt_session; + + wt_session = &session->iface; + tcur = NULL; + icur = NULL; + WT_RET(__wt_schema_open_colgroups(session, table)); + + /* + * If the column groups have not been completely created, + * there cannot be data inserted yet, and we're done. + */ + if (!table->cg_complete) + return (0); + + WT_ERR(wt_session->open_cursor(wt_session, + idx->source, NULL, "bulk=unordered", &icur)); + WT_ERR(wt_session->open_cursor(wt_session, + table->name, NULL, "readonly", &tcur)); + + while ((ret = tcur->next(tcur)) == 0) + WT_ERR(__wt_apply_single_idx(session, idx, + icur, (WT_CURSOR_TABLE *)tcur, icur->insert)); + + WT_ERR_NOTFOUND_OK(ret); +err: + if (icur) + WT_TRET(icur->close(icur)); + if (tcur) + WT_TRET(tcur->close(tcur)); + return (ret); +} + /* * __create_index -- * Create an index. */ static int __create_index(WT_SESSION_IMPL *session, - const char *name, int exclusive, const char *config) + const char *name, bool exclusive, const char *config) { WT_CONFIG kcols, pkcols; WT_CONFIG_ITEM ckey, cval, icols, kval; WT_DECL_PACK_VALUE(pv); WT_DECL_RET; + WT_INDEX *idx; WT_ITEM confbuf, extra_cols, fmt, namebuf; WT_PACK pack; WT_TABLE *table; @@ -342,7 +384,7 @@ __create_index(WT_SESSION_IMPL *session, const char *source, *sourceconf, *idxname, *tablename; char *idxconf; size_t tlen; - int have_extractor; + bool have_extractor; u_int i, npublic_cols; sourceconf = NULL; @@ -351,7 +393,7 @@ __create_index(WT_SESSION_IMPL *session, WT_CLEAR(fmt); WT_CLEAR(extra_cols); WT_CLEAR(namebuf); - have_extractor = 0; + have_extractor = false; tablename = name; if (!WT_PREFIX_SKIP(tablename, "index:")) @@ -363,7 +405,7 @@ __create_index(WT_SESSION_IMPL *session, tlen = (size_t)(idxname++ - tablename); if ((ret = - __wt_schema_get_table(session, tablename, tlen, 1, &table)) != 0) + __wt_schema_get_table(session, tablename, tlen, true, &table)) != 0) WT_RET_MSG(session, ret, "Can't create an index for a non-existent table: %.*s", (int)tlen, tablename); @@ -388,7 +430,7 @@ __create_index(WT_SESSION_IMPL *session, if (__wt_config_getones_none( session, config, "extractor", &cval) == 0 && cval.len != 0) { - have_extractor = 1; + have_extractor = true; /* Custom extractors must supply a key format. */ if ((ret = __wt_config_getones( session, config, "key_format", &kval)) != 0) @@ -463,7 +505,7 @@ __create_index(WT_SESSION_IMPL *session, * for custom extractors. */ WT_ERR(__wt_struct_reformat(session, table, - icols.str, icols.len, (const char *)extra_cols.data, 0, &fmt)); + icols.str, icols.len, (const char *)extra_cols.data, false, &fmt)); /* Check for a record number index key, which makes no sense. */ WT_ERR(__wt_config_getones(session, fmt.data, "key_format", &cval)); @@ -495,7 +537,9 @@ __create_index(WT_SESSION_IMPL *session, /* Make sure that the configuration is valid. */ WT_ERR(__wt_schema_open_index( - session, table, idxname, strlen(idxname), NULL)); + session, table, idxname, strlen(idxname), &idx)); + + WT_ERR(__fill_index(session, table, idx)); err: __wt_free(session, idxconf); __wt_free(session, sourceconf); @@ -514,7 +558,7 @@ err: __wt_free(session, idxconf); */ static int __create_table(WT_SESSION_IMPL *session, - const char *name, int exclusive, const char *config) + const char *name, bool exclusive, const char *config) { WT_CONFIG conf; WT_CONFIG_ITEM cgkey, cgval, cval; @@ -536,7 +580,7 @@ __create_table(WT_SESSION_IMPL *session, return (EINVAL); if ((ret = __wt_schema_get_table(session, - tablename, strlen(tablename), 0, &table)) == 0) { + tablename, strlen(tablename), false, &table)) == 0) { __wt_schema_release_table(session, table); return (exclusive ? EEXIST : 0); } @@ -563,7 +607,7 @@ __create_table(WT_SESSION_IMPL *session, /* Attempt to open the table now to catch any errors. */ WT_ERR(__wt_schema_get_table( - session, tablename, strlen(tablename), 1, &table)); + session, tablename, strlen(tablename), true, &table)); if (ncolgroups == 0) { cgsize = strlen("colgroup:") + strlen(tablename) + 1; @@ -629,11 +673,11 @@ __wt_schema_create( WT_CONFIG_ITEM cval; WT_DATA_SOURCE *dsrc; WT_DECL_RET; - int exclusive; + bool exclusive; - exclusive = ( + exclusive = __wt_config_getones(session, config, "exclusive", &cval) == 0 && - cval.val != 0); + cval.val != 0; /* * We track create operations: if we fail in the middle of creating a @@ -659,7 +703,7 @@ __wt_schema_create( ret = __wt_bad_object_type(session, uri); session->dhandle = NULL; - WT_TRET(__wt_meta_track_off(session, 1, ret != 0)); + WT_TRET(__wt_meta_track_off(session, true, ret != 0)); return (ret); } diff --git a/src/third_party/wiredtiger/src/schema/schema_drop.c b/src/third_party/wiredtiger/src/schema/schema_drop.c index 0fb0e735ae1..9b9f3a23961 100644 --- a/src/third_party/wiredtiger/src/schema/schema_drop.c +++ b/src/third_party/wiredtiger/src/schema/schema_drop.c @@ -14,15 +14,15 @@ */ static int __drop_file( - WT_SESSION_IMPL *session, const char *uri, int force, const char *cfg[]) + WT_SESSION_IMPL *session, const char *uri, bool force, const char *cfg[]) { WT_CONFIG_ITEM cval; WT_DECL_RET; - int remove_files; + bool remove_files; const char *filename; WT_RET(__wt_config_gets(session, cfg, "remove_files", &cval)); - remove_files = (cval.val != 0); + remove_files = cval.val != 0; filename = uri; if (!WT_PREFIX_SKIP(filename, "file:")) @@ -53,7 +53,7 @@ __drop_file( */ static int __drop_colgroup( - WT_SESSION_IMPL *session, const char *uri, int force, const char *cfg[]) + WT_SESSION_IMPL *session, const char *uri, bool force, const char *cfg[]) { WT_COLGROUP *colgroup; WT_DECL_RET; @@ -64,7 +64,7 @@ __drop_colgroup( /* If we can get the colgroup, detach it from the table. */ if ((ret = __wt_schema_get_colgroup( session, uri, force, &table, &colgroup)) == 0) { - table->cg_complete = 0; + table->cg_complete = false; WT_TRET(__wt_schema_drop(session, colgroup->source, cfg)); } @@ -78,7 +78,7 @@ __drop_colgroup( */ static int __drop_index( - WT_SESSION_IMPL *session, const char *uri, int force, const char *cfg[]) + WT_SESSION_IMPL *session, const char *uri, bool force, const char *cfg[]) { WT_INDEX *idx; WT_DECL_RET; @@ -87,7 +87,7 @@ __drop_index( /* If we can get the colgroup, detach it from the table. */ if ((ret = __wt_schema_get_index( session, uri, force, &table, &idx)) == 0) { - table->idx_complete = 0; + table->idx_complete = false; WT_TRET(__wt_schema_drop(session, idx->source, cfg)); } @@ -100,8 +100,7 @@ __drop_index( * WT_SESSION::drop for a table. */ static int -__drop_table( - WT_SESSION_IMPL *session, const char *uri, const char *cfg[]) +__drop_table(WT_SESSION_IMPL *session, const char *uri, const char *cfg[]) { WT_COLGROUP *colgroup; WT_DECL_RET; @@ -114,7 +113,8 @@ __drop_table( (void)WT_PREFIX_SKIP(name, "table:"); table = NULL; - WT_ERR(__wt_schema_get_table(session, name, strlen(name), 1, &table)); + WT_ERR(__wt_schema_get_table( + session, name, strlen(name), true, &table)); /* Drop the column groups. */ for (i = 0; i < WT_COLGROUPS(table); i++) { @@ -164,10 +164,10 @@ __wt_schema_drop(WT_SESSION_IMPL *session, const char *uri, const char *cfg[]) WT_CONFIG_ITEM cval; WT_DATA_SOURCE *dsrc; WT_DECL_RET; - int force; + bool force; WT_RET(__wt_config_gets_def(session, cfg, "force", 0, &cval)); - force = (cval.val != 0); + force = cval.val != 0; WT_RET(__wt_meta_track_on(session)); @@ -202,7 +202,7 @@ __wt_schema_drop(WT_SESSION_IMPL *session, const char *uri, const char *cfg[]) /* Bump the schema generation so that stale data is ignored. */ ++S2C(session)->schema_gen; - WT_TRET(__wt_meta_track_off(session, 1, ret != 0)); + WT_TRET(__wt_meta_track_off(session, true, ret != 0)); return (ret); } diff --git a/src/third_party/wiredtiger/src/schema/schema_list.c b/src/third_party/wiredtiger/src/schema/schema_list.c index d091a5d94da..da5f033ad40 100644 --- a/src/third_party/wiredtiger/src/schema/schema_list.c +++ b/src/third_party/wiredtiger/src/schema/schema_list.c @@ -14,7 +14,7 @@ */ static int __schema_add_table(WT_SESSION_IMPL *session, - const char *name, size_t namelen, int ok_incomplete, WT_TABLE **tablep) + const char *name, size_t namelen, bool ok_incomplete, WT_TABLE **tablep) { WT_DECL_RET; WT_TABLE *table; @@ -86,7 +86,7 @@ restart: */ int __wt_schema_get_table(WT_SESSION_IMPL *session, - const char *name, size_t namelen, int ok_incomplete, WT_TABLE **tablep) + const char *name, size_t namelen, bool ok_incomplete, WT_TABLE **tablep) { WT_DECL_RET; WT_TABLE *table; diff --git a/src/third_party/wiredtiger/src/schema/schema_open.c b/src/third_party/wiredtiger/src/schema/schema_open.c index bd4f2012480..42b578946f4 100644 --- a/src/third_party/wiredtiger/src/schema/schema_open.c +++ b/src/third_party/wiredtiger/src/schema/schema_open.c @@ -100,12 +100,12 @@ __wt_schema_open_colgroups(WT_SESSION_IMPL *session, WT_TABLE *table) WT_ERR(__wt_buf_init(session, buf, 0)); WT_ERR(__wt_struct_plan(session, - table, table->colconf.str, table->colconf.len, 1, buf)); + table, table->colconf.str, table->colconf.len, true, buf)); WT_ERR(__wt_strndup( session, buf->data, buf->size, &table->plan)); } - table->cg_complete = 1; + table->cg_complete = true; err: __wt_scr_free(session, &buf); __wt_schema_destroy_colgroup(session, &colgroup); @@ -228,7 +228,8 @@ __open_index(WT_SESSION_IMPL *session, WT_TABLE *table, WT_INDEX *idx) goto err; WT_ERR(__wt_scr_alloc(session, 0, &plan)); - WT_ERR(__wt_struct_plan(session, table, buf->data, buf->size, 0, plan)); + WT_ERR(__wt_struct_plan( + session, table, buf->data, buf->size, false, plan)); WT_ERR(__wt_strndup(session, plan->data, plan->size, &idx->key_plan)); /* Set up the cursor key format (the visible columns). */ @@ -250,7 +251,7 @@ __open_index(WT_SESSION_IMPL *session, WT_TABLE *table, WT_INDEX *idx) /* TODO Optimize to use index columns in preference to table lookups. */ WT_ERR(__wt_buf_init(session, plan, 0)); WT_ERR(__wt_struct_plan(session, - table, table->colconf.str, table->colconf.len, 1, plan)); + table, table->colconf.str, table->colconf.len, true, plan)); WT_ERR(__wt_strndup(session, plan->data, plan->size, &idx->value_plan)); err: __wt_scr_free(session, &buf); @@ -271,7 +272,8 @@ __wt_schema_open_index(WT_SESSION_IMPL *session, WT_DECL_RET; WT_INDEX *idx; u_int i; - int cmp, match; + int cmp; + bool match; const char *idxconf, *name, *tablename, *uri; /* Check if we've already done the work. */ @@ -280,7 +282,7 @@ __wt_schema_open_index(WT_SESSION_IMPL *session, cursor = NULL; idx = NULL; - match = 0; + match = false; /* Build a search key. */ tablename = table->name; @@ -374,7 +376,7 @@ __wt_schema_open_index(WT_SESSION_IMPL *session, /* If we did a full pass, we won't need to do it again. */ if (idxname == NULL) { table->nindices = i; - table->idx_complete = 1; + table->idx_complete = true; } err: __wt_scr_free(session, &tmp); @@ -400,7 +402,7 @@ __wt_schema_open_indices(WT_SESSION_IMPL *session, WT_TABLE *table) */ int __wt_schema_open_table(WT_SESSION_IMPL *session, - const char *name, size_t namelen, int ok_incomplete, WT_TABLE **tablep) + const char *name, size_t namelen, bool ok_incomplete, WT_TABLE **tablep) { WT_CONFIG cparser; WT_CONFIG_ITEM ckey, cval; @@ -448,9 +450,9 @@ __wt_schema_open_table(WT_SESSION_IMPL *session, * are not named. */ WT_ERR(__wt_config_subinit(session, &cparser, &table->colconf)); - table->is_simple = 1; + table->is_simple = true; while ((ret = __wt_config_next(&cparser, &ckey, &cval)) == 0) - table->is_simple = 0; + table->is_simple = false; if (ret != WT_NOTFOUND) goto err; @@ -505,7 +507,7 @@ err: WT_TRET(__wt_schema_destroy_table(session, &table)); */ int __wt_schema_get_colgroup(WT_SESSION_IMPL *session, - const char *uri, int quiet, WT_TABLE **tablep, WT_COLGROUP **colgroupp) + const char *uri, bool quiet, WT_TABLE **tablep, WT_COLGROUP **colgroupp) { WT_COLGROUP *colgroup; WT_TABLE *table; @@ -522,7 +524,7 @@ __wt_schema_get_colgroup(WT_SESSION_IMPL *session, tend = tablename + strlen(tablename); WT_RET(__wt_schema_get_table(session, - tablename, WT_PTRDIFF(tend, tablename), 0, &table)); + tablename, WT_PTRDIFF(tend, tablename), false, &table)); for (i = 0; i < WT_COLGROUPS(table); i++) { colgroup = table->cgroups[i]; @@ -548,7 +550,7 @@ __wt_schema_get_colgroup(WT_SESSION_IMPL *session, */ int __wt_schema_get_index(WT_SESSION_IMPL *session, - const char *uri, int quiet, WT_TABLE **tablep, WT_INDEX **indexp) + const char *uri, bool quiet, WT_TABLE **tablep, WT_INDEX **indexp) { WT_DECL_RET; WT_INDEX *idx; @@ -564,7 +566,7 @@ __wt_schema_get_index(WT_SESSION_IMPL *session, return (__wt_bad_object_type(session, uri)); WT_RET(__wt_schema_get_table(session, - tablename, WT_PTRDIFF(tend, tablename), 0, &table)); + tablename, WT_PTRDIFF(tend, tablename), false, &table)); /* Try to find the index in the table. */ for (i = 0; i < table->nindices; i++) { diff --git a/src/third_party/wiredtiger/src/schema/schema_plan.c b/src/third_party/wiredtiger/src/schema/schema_plan.c index 918cbe68fcc..066e666190b 100644 --- a/src/third_party/wiredtiger/src/schema/schema_plan.c +++ b/src/third_party/wiredtiger/src/schema/schema_plan.c @@ -21,14 +21,14 @@ __find_next_col(WT_SESSION_IMPL *session, WT_TABLE *table, WT_CONFIG_ITEM cval, k, v; WT_DECL_RET; u_int cg, col, foundcg, foundcol, matchcg, matchcol; - int getnext; + bool getnext; foundcg = foundcol = UINT_MAX; matchcg = *cgnump; matchcol = (*coltype == WT_PROJ_KEY) ? *colnump : *colnump + table->nkey_columns; - getnext = 1; + getnext = true; for (colgroup = NULL, cg = 0; cg < WT_COLGROUPS(table); cg++) { colgroup = table->cgroups[cg]; @@ -53,7 +53,7 @@ cgcols: cval = colgroup->colconf; foundcg = cg; foundcol = col; } - getnext = (cg == matchcg && col == matchcol); + getnext = cg == matchcg && col == matchcol; } if (cg == 0 && table->ncolgroups > 0 && col == table->nkey_columns - 1) @@ -174,13 +174,13 @@ __wt_table_check(WT_SESSION_IMPL *session, WT_TABLE *table) */ int __wt_struct_plan(WT_SESSION_IMPL *session, WT_TABLE *table, - const char *columns, size_t len, int value_only, WT_ITEM *plan) + const char *columns, size_t len, bool value_only, WT_ITEM *plan) { WT_CONFIG conf; WT_CONFIG_ITEM k, v; WT_DECL_RET; u_int cg, col, current_cg, current_col, i, start_cg, start_col; - int have_it; + bool have_it; char coltype, current_coltype; start_cg = start_col = UINT_MAX; /* -Wuninitialized */ @@ -195,7 +195,7 @@ __wt_struct_plan(WT_SESSION_IMPL *session, WT_TABLE *table, current_col = col = INT_MAX; current_coltype = coltype = WT_PROJ_KEY; /* Keep lint quiet. */ for (i = 0; (ret = __wt_config_next(&conf, &k, &v)) == 0; i++) { - have_it = 0; + have_it = false; while ((ret = __find_next_col(session, table, &k, &cg, &col, &coltype)) == 0 && @@ -242,7 +242,7 @@ __wt_struct_plan(WT_SESSION_IMPL *session, WT_TABLE *table, start_cg = cg; start_col = col; - have_it = 1; + have_it = true; } else WT_RET(__wt_buf_catfmt(session, plan, "%c", WT_PROJ_REUSE)); @@ -272,25 +272,25 @@ __wt_struct_plan(WT_SESSION_IMPL *session, WT_TABLE *table, * Find the format of the named column. */ static int -__find_column_format(WT_SESSION_IMPL *session, - WT_TABLE *table, WT_CONFIG_ITEM *colname, int value_only, WT_PACK_VALUE *pv) +__find_column_format(WT_SESSION_IMPL *session, WT_TABLE *table, + WT_CONFIG_ITEM *colname, bool value_only, WT_PACK_VALUE *pv) { WT_CONFIG conf; WT_CONFIG_ITEM k, v; WT_DECL_RET; WT_PACK pack; - int inkey; + bool inkey; WT_RET(__wt_config_subinit(session, &conf, &table->colconf)); WT_RET(__pack_init(session, &pack, table->key_format)); - inkey = 1; + inkey = true; while ((ret = __wt_config_next(&conf, &k, &v)) == 0) { if ((ret = __pack_next(&pack, pv)) == WT_NOTFOUND && inkey) { ret = __pack_init(session, &pack, table->value_format); if (ret == 0) ret = __pack_next(&pack, pv); - inkey = 0; + inkey = false; } if (ret != 0) return (ret); @@ -314,14 +314,14 @@ __find_column_format(WT_SESSION_IMPL *session, */ int __wt_struct_reformat(WT_SESSION_IMPL *session, WT_TABLE *table, - const char *columns, size_t len, const char *extra_cols, int value_only, + const char *columns, size_t len, const char *extra_cols, bool value_only, WT_ITEM *format) { WT_CONFIG config; WT_CONFIG_ITEM k, next_k, next_v; WT_DECL_PACK_VALUE(pv); WT_DECL_RET; - int have_next; + bool have_next; WT_RET(__wt_config_initn(session, &config, columns, len)); /* @@ -344,12 +344,12 @@ __wt_struct_reformat(WT_SESSION_IMPL *session, WT_TABLE *table, ret = __wt_config_next(&config, &next_k, &next_v); if (ret != 0 && ret != WT_NOTFOUND) return (ret); - have_next = (ret == 0); + have_next = ret == 0; if (!have_next && extra_cols != NULL) { WT_RET(__wt_config_init(session, &config, extra_cols)); WT_RET(__wt_config_next(&config, &next_k, &next_v)); - have_next = 1; + have_next = true; extra_cols = NULL; } diff --git a/src/third_party/wiredtiger/src/schema/schema_project.c b/src/third_party/wiredtiger/src/schema/schema_project.c index c9b69b3c922..be5f73b48ed 100644 --- a/src/third_party/wiredtiger/src/schema/schema_project.c +++ b/src/third_party/wiredtiger/src/schema/schema_project.c @@ -220,7 +220,7 @@ __wt_schema_project_out(WT_SESSION_IMPL *session, */ int __wt_schema_project_slice(WT_SESSION_IMPL *session, WT_CURSOR **cp, - const char *proj_arg, int key_only, const char *vformat, WT_ITEM *value) + const char *proj_arg, bool key_only, const char *vformat, WT_ITEM *value) { WT_CURSOR *c; WT_DECL_ITEM(buf); @@ -233,7 +233,7 @@ __wt_schema_project_slice(WT_SESSION_IMPL *session, WT_CURSOR **cp, uint8_t *end, *p; const uint8_t *next, *vp, *vend; size_t len, offset, old_len; - int skip; + bool skip; p = end = NULL; /* -Wuninitialized */ @@ -259,7 +259,7 @@ __wt_schema_project_slice(WT_SESSION_IMPL *session, WT_CURSOR **cp, switch (*proj) { case WT_PROJ_KEY: - skip = 0; + skip = false; c = cp[arg]; if (WT_CURSOR_RECNO(c)) { c->key.data = &c->recno; @@ -274,7 +274,8 @@ __wt_schema_project_slice(WT_SESSION_IMPL *session, WT_CURSOR **cp, continue; case WT_PROJ_VALUE: - if ((skip = key_only) != 0) + skip = key_only; + if (skip) continue; c = cp[arg]; WT_RET(__pack_init(session, &pack, c->value_format)); diff --git a/src/third_party/wiredtiger/src/schema/schema_rename.c b/src/third_party/wiredtiger/src/schema/schema_rename.c index 1031b27db3d..3f368417d40 100644 --- a/src/third_party/wiredtiger/src/schema/schema_rename.c +++ b/src/third_party/wiredtiger/src/schema/schema_rename.c @@ -17,7 +17,7 @@ __rename_file( WT_SESSION_IMPL *session, const char *uri, const char *newuri) { WT_DECL_RET; - int exist; + bool exist; const char *filename, *newfile; char *newvalue, *oldvalue; @@ -31,7 +31,7 @@ __rename_file( /* Close any btree handles in the file. */ WT_WITH_HANDLE_LIST_LOCK(session, - ret = __wt_conn_dhandle_close_all(session, uri, 0)); + ret = __wt_conn_dhandle_close_all(session, uri, false)); WT_ERR(ret); /* @@ -87,9 +87,9 @@ __rename_tree(WT_SESSION_IMPL *session, WT_DECL_ITEM(nv); WT_DECL_ITEM(os); WT_DECL_RET; + bool is_colgroup; const char *newname, *olduri, *suffix; char *value; - int is_colgroup; olduri = table->name; value = NULL; @@ -210,7 +210,7 @@ __rename_table(WT_SESSION_IMPL *session, (void)WT_PREFIX_SKIP(oldname, "table:"); WT_RET(__wt_schema_get_table( - session, oldname, strlen(oldname), 0, &table)); + session, oldname, strlen(oldname), false, &table)); /* Rename the column groups. */ for (i = 0; i < WT_COLGROUPS(table); i++) @@ -276,7 +276,7 @@ __wt_schema_rename(WT_SESSION_IMPL *session, /* Bump the schema generation so that stale data is ignored. */ ++S2C(session)->schema_gen; - WT_TRET(__wt_meta_track_off(session, 1, ret != 0)); + WT_TRET(__wt_meta_track_off(session, true, ret != 0)); /* If we didn't find a metadata entry, map that error to ENOENT. */ return (ret == WT_NOTFOUND ? ENOENT : ret); diff --git a/src/third_party/wiredtiger/src/schema/schema_stat.c b/src/third_party/wiredtiger/src/schema/schema_stat.c index e9439abe16f..0c2c5fe78c0 100644 --- a/src/third_party/wiredtiger/src/schema/schema_stat.c +++ b/src/third_party/wiredtiger/src/schema/schema_stat.c @@ -20,7 +20,7 @@ __wt_curstat_colgroup_init(WT_SESSION_IMPL *session, WT_DECL_ITEM(buf); WT_DECL_RET; - WT_RET(__wt_schema_get_colgroup(session, uri, 0, NULL, &colgroup)); + WT_RET(__wt_schema_get_colgroup(session, uri, false, NULL, &colgroup)); WT_RET(__wt_scr_alloc(session, 0, &buf)); WT_ERR(__wt_buf_fmt(session, buf, "statistics:%s", colgroup->source)); @@ -42,7 +42,7 @@ __wt_curstat_index_init(WT_SESSION_IMPL *session, WT_DECL_RET; WT_INDEX *idx; - WT_RET(__wt_schema_get_index(session, uri, 0, NULL, &idx)); + WT_RET(__wt_schema_get_index(session, uri, false, NULL, &idx)); WT_RET(__wt_scr_alloc(session, 0, &buf)); WT_ERR(__wt_buf_fmt(session, buf, "statistics:%s", idx->source)); @@ -69,7 +69,8 @@ __wt_curstat_table_init(WT_SESSION_IMPL *session, const char *name; name = uri + strlen("table:"); - WT_RET(__wt_schema_get_table(session, name, strlen(name), 0, &table)); + WT_RET(__wt_schema_get_table( + session, name, strlen(name), false, &table)); WT_ERR(__wt_scr_alloc(session, 0, &buf)); diff --git a/src/third_party/wiredtiger/src/schema/schema_truncate.c b/src/third_party/wiredtiger/src/schema/schema_truncate.c index 899c46470ca..03a991a9aba 100644 --- a/src/third_party/wiredtiger/src/schema/schema_truncate.c +++ b/src/third_party/wiredtiger/src/schema/schema_truncate.c @@ -34,7 +34,7 @@ __truncate_file(WT_SESSION_IMPL *session, const char *uri) /* Close any btree handles in the file. */ WT_WITH_HANDLE_LIST_LOCK(session, - ret = __wt_conn_dhandle_close_all(session, uri, 0)); + ret = __wt_conn_dhandle_close_all(session, uri, false)); WT_RET(ret); /* Delete the root address and truncate the file. */ @@ -55,7 +55,7 @@ __truncate_table(WT_SESSION_IMPL *session, const char *uri, const char *cfg[]) WT_TABLE *table; u_int i; - WT_RET(__wt_schema_get_table(session, uri, strlen(uri), 0, &table)); + WT_RET(__wt_schema_get_table(session, uri, strlen(uri), false, &table)); /* Truncate the column groups. */ for (i = 0; i < WT_COLGROUPS(table); i++) diff --git a/src/third_party/wiredtiger/src/schema/schema_worker.c b/src/third_party/wiredtiger/src/schema/schema_worker.c index 76b47a2ccff..64218923173 100644 --- a/src/third_party/wiredtiger/src/schema/schema_worker.c +++ b/src/third_party/wiredtiger/src/schema/schema_worker.c @@ -17,7 +17,7 @@ int __wt_schema_worker(WT_SESSION_IMPL *session, const char *uri, int (*file_func)(WT_SESSION_IMPL *, const char *[]), - int (*name_func)(WT_SESSION_IMPL *, const char *, int *), + int (*name_func)(WT_SESSION_IMPL *, const char *, bool *), const char *cfg[], uint32_t open_flags) { WT_COLGROUP *colgroup; @@ -28,12 +28,12 @@ __wt_schema_worker(WT_SESSION_IMPL *session, WT_TABLE *table; const char *tablename; u_int i; - int skip; + bool skip; table = NULL; tablename = uri; - skip = 0; + skip = false; if (name_func != NULL) WT_ERR(name_func(session, uri, &skip)); @@ -51,7 +51,7 @@ __wt_schema_worker(WT_SESSION_IMPL *session, if (FLD_ISSET(open_flags, WT_DHANDLE_EXCLUSIVE)) { WT_WITH_HANDLE_LIST_LOCK(session, ret = __wt_conn_dhandle_close_all( - session, uri, 0)); + session, uri, false)); WT_ERR(ret); } @@ -71,12 +71,12 @@ __wt_schema_worker(WT_SESSION_IMPL *session, } } else if (WT_PREFIX_MATCH(uri, "colgroup:")) { WT_ERR(__wt_schema_get_colgroup( - session, uri, 0, NULL, &colgroup)); + session, uri, false, NULL, &colgroup)); WT_ERR(__wt_schema_worker(session, colgroup->source, file_func, name_func, cfg, open_flags)); } else if (WT_PREFIX_SKIP(tablename, "index:")) { idx = NULL; - WT_ERR(__wt_schema_get_index(session, uri, 0, NULL, &idx)); + WT_ERR(__wt_schema_get_index(session, uri, false, NULL, &idx)); WT_ERR(__wt_schema_worker(session, idx->source, file_func, name_func, cfg, open_flags)); } else if (WT_PREFIX_MATCH(uri, "lsm:")) { @@ -89,7 +89,7 @@ __wt_schema_worker(WT_SESSION_IMPL *session, uri, file_func, name_func, cfg, open_flags)); } else if (WT_PREFIX_SKIP(tablename, "table:")) { WT_ERR(__wt_schema_get_table(session, - tablename, strlen(tablename), 0, &table)); + tablename, strlen(tablename), false, &table)); WT_ASSERT(session, session->dhandle == NULL); /* @@ -100,7 +100,7 @@ __wt_schema_worker(WT_SESSION_IMPL *session, */ for (i = 0; i < WT_COLGROUPS(table); i++) { colgroup = table->cgroups[i]; - skip = 0; + skip = false; if (name_func != NULL) WT_ERR(name_func( session, colgroup->name, &skip)); @@ -113,7 +113,7 @@ __wt_schema_worker(WT_SESSION_IMPL *session, WT_ERR(__wt_schema_open_indices(session, table)); for (i = 0; i < table->nindices; i++) { idx = table->indices[i]; - skip = 0; + skip = false; if (name_func != NULL) WT_ERR(name_func(session, idx->name, &skip)); if (!skip) diff --git a/src/third_party/wiredtiger/src/session/session_api.c b/src/third_party/wiredtiger/src/session/session_api.c index 37a1f895589..98509ecdceb 100644 --- a/src/third_party/wiredtiger/src/session/session_api.c +++ b/src/third_party/wiredtiger/src/session/session_api.c @@ -17,7 +17,7 @@ static int __session_rollback_transaction(WT_SESSION *, const char *); * Reset all open cursors. */ int -__wt_session_reset_cursors(WT_SESSION_IMPL *session, int free_buffers) +__wt_session_reset_cursors(WT_SESSION_IMPL *session, bool free_buffers) { WT_CURSOR *cursor; WT_DECL_RET; @@ -203,7 +203,7 @@ __session_reconfigure(WT_SESSION *wt_session, const char *config) if (F_ISSET(&session->txn, WT_TXN_RUNNING)) WT_ERR_MSG(session, EINVAL, "transaction in progress"); - WT_TRET(__wt_session_reset_cursors(session, 0)); + WT_TRET(__wt_session_reset_cursors(session, false)); WT_ERR(__wt_config_gets_def(session, cfg, "isolation", 0, &cval)); if (cval.len != 0) @@ -253,7 +253,7 @@ __wt_open_cursor(WT_SESSION_IMPL *session, * the underlying data source. */ WT_RET(__wt_schema_get_colgroup( - session, uri, 0, NULL, &colgroup)); + session, uri, false, NULL, &colgroup)); WT_RET(__wt_open_cursor( session, colgroup->source, owner, cfg, cursorp)); } else if (WT_PREFIX_MATCH(uri, "config:")) @@ -545,7 +545,7 @@ __session_reset(WT_SESSION *wt_session) if (F_ISSET(&session->txn, WT_TXN_RUNNING)) WT_ERR_MSG(session, EINVAL, "transaction in progress"); - WT_TRET(__wt_session_reset_cursors(session, 1)); + WT_TRET(__wt_session_reset_cursors(session, true)); WT_ASSERT(session, session->ncursors == 0); @@ -650,9 +650,10 @@ __session_truncate(WT_SESSION *wt_session, WT_DECL_RET; WT_SESSION_IMPL *session; WT_CURSOR *cursor; - int cmp, local_start; + int cmp; + bool local_start; - local_start = 0; + local_start = false; session = (WT_SESSION_IMPL *)wt_session; SESSION_TXN_API_CALL(session, truncate, config, cfg); @@ -752,7 +753,7 @@ __session_truncate(WT_SESSION *wt_session, if (start == NULL) { WT_ERR(__session_open_cursor( wt_session, stop->uri, NULL, NULL, &start)); - local_start = 1; + local_start = true; WT_ERR(start->next(start)); } @@ -872,7 +873,7 @@ __session_commit_transaction(WT_SESSION *wt_session, const char *config) if (ret == 0) ret = __wt_txn_commit(session, cfg); else { - WT_TRET(__wt_session_reset_cursors(session, 0)); + WT_TRET(__wt_session_reset_cursors(session, false)); WT_TRET(__wt_txn_rollback(session, cfg)); } @@ -893,7 +894,7 @@ __session_rollback_transaction(WT_SESSION *wt_session, const char *config) SESSION_API_CALL(session, rollback_transaction, config, cfg); WT_STAT_FAST_CONN_INCR(session, txn_rollback); - WT_TRET(__wt_session_reset_cursors(session, 0)); + WT_TRET(__wt_session_reset_cursors(session, false)); WT_TRET(__wt_txn_rollback(session, cfg)); @@ -947,7 +948,7 @@ __session_transaction_sync(WT_SESSION *wt_session, const char *config) WT_TXN *txn; struct timespec now, start; uint64_t timeout_ms, waited_ms; - int forever; + bool forever; session = (WT_SESSION_IMPL *)wt_session; SESSION_API_CALL(session, transaction_sync, config, cfg); @@ -966,7 +967,7 @@ __session_transaction_sync(WT_SESSION *wt_session, const char *config) log = conn->log; timeout_ms = waited_ms = 0; - forever = 1; + forever = true; /* * If there is no background sync LSN in this session, there @@ -990,7 +991,7 @@ __session_transaction_sync(WT_SESSION *wt_session, const char *config) session, cfg, "timeout_ms", (int)UINT_MAX, &cval)); if ((unsigned int)cval.val != UINT_MAX) { timeout_ms = (uint64_t)cval.val; - forever = 0; + forever = false; } if (timeout_ms == 0) @@ -1056,7 +1057,7 @@ __session_checkpoint(WT_SESSION *wt_session, const char *config) * checkpoint code will acquire the schema lock before we do that, and * some implementation of WT_CURSOR::reset might need the schema lock. */ - WT_ERR(__wt_session_reset_cursors(session, 0)); + WT_ERR(__wt_session_reset_cursors(session, false)); /* * Don't highjack the session checkpoint thread for eviction. @@ -1095,9 +1096,9 @@ __session_snapshot(WT_SESSION *wt_session, const char *config) WT_DECL_RET; WT_SESSION_IMPL *session; WT_TXN_GLOBAL *txn_global; - int has_create, has_drop; + bool has_create, has_drop; - has_create = has_drop = 0; + has_create = has_drop = false; session = (WT_SESSION_IMPL *)wt_session; txn_global = &S2C(session)->txn_global; @@ -1141,7 +1142,7 @@ __session_strerror(WT_SESSION *wt_session, int error) */ int __wt_open_internal_session(WT_CONNECTION_IMPL *conn, const char *name, - int uses_dhandles, int open_metadata, WT_SESSION_IMPL **sessionp) + bool uses_dhandles, bool open_metadata, WT_SESSION_IMPL **sessionp) { WT_SESSION_IMPL *session; @@ -1176,7 +1177,7 @@ __wt_open_internal_session(WT_CONNECTION_IMPL *conn, const char *name, */ int __wt_open_session(WT_CONNECTION_IMPL *conn, - WT_EVENT_HANDLER *event_handler, const char *config, int open_metadata, + WT_EVENT_HANDLER *event_handler, const char *config, bool open_metadata, WT_SESSION_IMPL **sessionp) { static const WT_SESSION stds = { @@ -1246,7 +1247,7 @@ __wt_open_session(WT_CONNECTION_IMPL *conn, session_ret->iface = stds; session_ret->iface.connection = &conn->iface; - WT_ERR(__wt_cond_alloc(session, "session", 0, &session_ret->cond)); + WT_ERR(__wt_cond_alloc(session, "session", false, &session_ret->cond)); if (WT_SESSION_FIRST_USE(session_ret)) __wt_random_init(&session_ret->rnd); diff --git a/src/third_party/wiredtiger/src/session/session_compact.c b/src/third_party/wiredtiger/src/session/session_compact.c index e9f1e3a5a97..cd2c9ddb35d 100644 --- a/src/third_party/wiredtiger/src/session/session_compact.c +++ b/src/third_party/wiredtiger/src/session/session_compact.c @@ -103,7 +103,7 @@ * Called via the schema_worker function. */ int -__wt_compact_uri_analyze(WT_SESSION_IMPL *session, const char *uri, int *skip) +__wt_compact_uri_analyze(WT_SESSION_IMPL *session, const char *uri, bool *skipp) { /* * Add references to schema URI objects to the list of objects to be @@ -112,7 +112,7 @@ __wt_compact_uri_analyze(WT_SESSION_IMPL *session, const char *uri, int *skip) */ if (WT_PREFIX_MATCH(uri, "lsm:")) { session->compact->lsm_count++; - *skip = 1; + *skipp = true; } else if (WT_PREFIX_MATCH(uri, "file:")) session->compact->file_count++; diff --git a/src/third_party/wiredtiger/src/session/session_dhandle.c b/src/third_party/wiredtiger/src/session/session_dhandle.c index 66b669dde22..e506b6848a1 100644 --- a/src/third_party/wiredtiger/src/session/session_dhandle.c +++ b/src/third_party/wiredtiger/src/session/session_dhandle.c @@ -117,19 +117,19 @@ retry: TAILQ_FOREACH(dhandle_cache, &session->dhhash[bucket], hashq) { */ int __wt_session_lock_dhandle( - WT_SESSION_IMPL *session, uint32_t flags, int *is_deadp) + WT_SESSION_IMPL *session, uint32_t flags, bool *is_deadp) { WT_BTREE *btree; WT_DATA_HANDLE *dhandle; WT_DECL_RET; - int is_open, lock_busy, want_exclusive; + bool is_open, lock_busy, want_exclusive; *is_deadp = 0; dhandle = session->dhandle; btree = dhandle->handle; - lock_busy = 0; - want_exclusive = LF_ISSET(WT_DHANDLE_EXCLUSIVE) ? 1 : 0; + lock_busy = false; + want_exclusive = LF_ISSET(WT_DHANDLE_EXCLUSIVE); /* * Check that the handle is open. We've already incremented @@ -173,12 +173,12 @@ __wt_session_lock_dhandle( __wt_readunlock(session, dhandle->rwlock)); } - is_open = F_ISSET(dhandle, WT_DHANDLE_OPEN) ? 1 : 0; + is_open = F_ISSET(dhandle, WT_DHANDLE_OPEN); if (is_open && !want_exclusive) return (0); WT_RET(__wt_readunlock(session, dhandle->rwlock)); } else - is_open = 0; + is_open = false; /* * It isn't open or we want it exclusive: try to get an @@ -199,7 +199,7 @@ __wt_session_lock_dhandle( */ if (F_ISSET(dhandle, WT_DHANDLE_OPEN) && !want_exclusive) { - lock_busy = 0; + lock_busy = false; WT_RET( __wt_writeunlock(session, dhandle->rwlock)); continue; @@ -212,7 +212,7 @@ __wt_session_lock_dhandle( } if (ret != EBUSY || (is_open && want_exclusive)) return (ret); - lock_busy = 1; + lock_busy = true; /* Give other threads a chance to make progress. */ __wt_yield(); @@ -230,11 +230,12 @@ __wt_session_release_btree(WT_SESSION_IMPL *session) WT_DATA_HANDLE *dhandle; WT_DATA_HANDLE_CACHE *dhandle_cache; WT_DECL_RET; - int write_locked; + bool locked, write_locked; btree = S2BT(session); dhandle = session->dhandle; - write_locked = F_ISSET(dhandle, WT_DHANDLE_EXCLUSIVE) ? 1 : 0; + write_locked = F_ISSET(dhandle, WT_DHANDLE_EXCLUSIVE); + locked = true; /* * If we had special flags set, close the handle so that future access @@ -248,21 +249,29 @@ __wt_session_release_btree(WT_SESSION_IMPL *session) } if (F_ISSET(dhandle, WT_DHANDLE_DISCARD_FORCE)) { - ret = __wt_conn_btree_sync_and_close(session, 0, 1); + ret = __wt_conn_btree_sync_and_close(session, false, true); F_CLR(dhandle, WT_DHANDLE_DISCARD_FORCE); } else if (F_ISSET(dhandle, WT_DHANDLE_DISCARD) || F_ISSET(btree, WT_BTREE_SPECIAL_FLAGS)) { WT_ASSERT(session, F_ISSET(dhandle, WT_DHANDLE_EXCLUSIVE)); - ret = __wt_conn_btree_sync_and_close(session, 0, 0); + ret = __wt_conn_btree_sync_and_close(session, false, false); F_CLR(dhandle, WT_DHANDLE_DISCARD); } - if (write_locked) - F_CLR(dhandle, WT_DHANDLE_EXCLUSIVE); + if (session == dhandle->excl_session) { + if (--dhandle->excl_ref == 0) + dhandle->excl_session = NULL; + else + locked = false; + } + if (locked) { + if (write_locked) + F_CLR(dhandle, WT_DHANDLE_EXCLUSIVE); - WT_TRET(write_locked ? - __wt_writeunlock(session, dhandle->rwlock): - __wt_readunlock(session, dhandle->rwlock)); + WT_TRET(write_locked ? + __wt_writeunlock(session, dhandle->rwlock): + __wt_readunlock(session, dhandle->rwlock)); + } session->dhandle = NULL; return (ret); @@ -279,10 +288,10 @@ __wt_session_get_btree_ckpt(WT_SESSION_IMPL *session, { WT_CONFIG_ITEM cval; WT_DECL_RET; - int last_ckpt; + bool last_ckpt; const char *checkpoint; - last_ckpt = 0; + last_ckpt = false; checkpoint = NULL; /* @@ -297,7 +306,7 @@ __wt_session_get_btree_ckpt(WT_SESSION_IMPL *session, * unnamed checkpoint of the object. */ if (WT_STRING_MATCH(WT_CHECKPOINT, cval.str, cval.len)) { - last_ckpt = 1; + last_ckpt = true; retry: WT_RET(__wt_meta_checkpoint_last_name( session, uri, &checkpoint)); } else @@ -437,7 +446,7 @@ __wt_session_get_btree(WT_SESSION_IMPL *session, { WT_DATA_HANDLE *dhandle; WT_DECL_RET; - int is_dead; + bool is_dead; WT_ASSERT(session, !F_ISSET(session, WT_SESSION_NO_DATA_HANDLES)); @@ -445,10 +454,19 @@ __wt_session_get_btree(WT_SESSION_IMPL *session, WT_RET(__session_get_dhandle(session, uri, checkpoint)); dhandle = session->dhandle; - /* Try to lock the handle. */ - WT_RET(__wt_session_lock_dhandle(session, flags, &is_dead)); - if (is_dead) - continue; + /* + * If this session already owns the handle, increase + * the owner ref count. + */ + if (dhandle->excl_session == session) + dhandle->excl_ref++; + else { + /* Try to lock the handle. */ + WT_RET(__wt_session_lock_dhandle( + session, flags, &is_dead)); + if (is_dead) + continue; + } /* If the handle is open in the mode we want, we're done. */ if (LF_ISSET(WT_DHANDLE_LOCK_ONLY) || @@ -470,6 +488,8 @@ __wt_session_get_btree(WT_SESSION_IMPL *session, */ if (!F_ISSET(session, WT_SESSION_LOCKED_SCHEMA) || !F_ISSET(session, WT_SESSION_LOCKED_HANDLE_LIST)) { + dhandle->excl_session = NULL; + dhandle->excl_ref = 0; F_CLR(dhandle, WT_DHANDLE_EXCLUSIVE); WT_RET(__wt_writeunlock(session, dhandle->rwlock)); @@ -490,6 +510,8 @@ __wt_session_get_btree(WT_SESSION_IMPL *session, * If we got the handle exclusive to open it but only want * ordinary access, drop our lock and retry the open. */ + dhandle->excl_session = NULL; + dhandle->excl_ref = 0; F_CLR(dhandle, WT_DHANDLE_EXCLUSIVE); WT_TRET(__wt_writeunlock(session, dhandle->rwlock)); WT_RET(ret); @@ -500,7 +522,7 @@ __wt_session_get_btree(WT_SESSION_IMPL *session, F_ISSET(dhandle, WT_DHANDLE_OPEN)); WT_ASSERT(session, LF_ISSET(WT_DHANDLE_EXCLUSIVE) == - F_ISSET(dhandle, WT_DHANDLE_EXCLUSIVE)); + F_ISSET(dhandle, WT_DHANDLE_EXCLUSIVE) || dhandle->excl_ref > 1); return (0); } @@ -549,7 +571,7 @@ __wt_session_lock_checkpoint(WT_SESSION_IMPL *session, const char *checkpoint) dhandle = session->dhandle; F_SET(dhandle, WT_DHANDLE_DISCARD); - WT_ERR(__wt_meta_track_handle_lock(session, 0)); + WT_ERR(__wt_meta_track_handle_lock(session, false)); /* Restore the original btree in the session. */ err: session->dhandle = saved_dhandle; diff --git a/src/third_party/wiredtiger/src/support/err.c b/src/third_party/wiredtiger/src/support/err.c index e9b7a53a2ab..c4bf4e8946a 100644 --- a/src/third_party/wiredtiger/src/support/err.c +++ b/src/third_party/wiredtiger/src/support/err.c @@ -85,7 +85,7 @@ static WT_EVENT_HANDLER __event_handler_default = { */ static void __handler_failure(WT_SESSION_IMPL *session, - int error, const char *which, int error_handler_failed) + int error, const char *which, bool error_handler_failed) { WT_EVENT_HANDLER *handler; WT_SESSION *wt_session; @@ -142,7 +142,7 @@ __wt_event_handler_set(WT_SESSION_IMPL *session, WT_EVENT_HANDLER *handler) * Report a message to an event handler. */ int -__wt_eventv(WT_SESSION_IMPL *session, int msg_event, int error, +__wt_eventv(WT_SESSION_IMPL *session, bool msg_event, int error, const char *file_name, int line_number, const char *fmt, va_list ap) { WT_EVENT_HANDLER *handler; @@ -280,11 +280,11 @@ __wt_eventv(WT_SESSION_IMPL *session, int msg_event, int error, if (msg_event) { ret = handler->handle_message(handler, wt_session, s); if (ret != 0) - __handler_failure(session, ret, "message", 0); + __handler_failure(session, ret, "message", false); } else { ret = handler->handle_error(handler, wt_session, error, s); if (ret != 0 && handler->handle_error != __handle_error_default) - __handler_failure(session, ret, "error", 1); + __handler_failure(session, ret, "error", true); } return (ret); @@ -305,7 +305,7 @@ __wt_err(WT_SESSION_IMPL *session, int error, const char *fmt, ...) * an error value to return. */ va_start(ap, fmt); - (void)__wt_eventv(session, 0, error, NULL, 0, fmt, ap); + (void)__wt_eventv(session, false, error, NULL, 0, fmt, ap); va_end(ap); } @@ -324,7 +324,7 @@ __wt_errx(WT_SESSION_IMPL *session, const char *fmt, ...) * an error value to return. */ va_start(ap, fmt); - (void)__wt_eventv(session, 0, 0, NULL, 0, fmt, ap); + (void)__wt_eventv(session, false, 0, NULL, 0, fmt, ap); va_end(ap); } @@ -345,7 +345,7 @@ __wt_ext_err_printf( session = ((WT_CONNECTION_IMPL *)wt_api->conn)->default_session; va_start(ap, fmt); - ret = __wt_eventv(session, 0, 0, NULL, 0, fmt, ap); + ret = __wt_eventv(session, false, 0, NULL, 0, fmt, ap); va_end(ap); return (ret); } @@ -444,7 +444,7 @@ __wt_progress(WT_SESSION_IMPL *session, const char *s, uint64_t v) if (handler != NULL && handler->handle_progress != NULL) if ((ret = handler->handle_progress(handler, wt_session, s == NULL ? session->name : s, v)) != 0) - __handler_failure(session, ret, "progress", 0); + __handler_failure(session, ret, "progress", false); return (0); } @@ -461,7 +461,8 @@ __wt_assert(WT_SESSION_IMPL *session, va_list ap; va_start(ap, fmt); - (void)__wt_eventv(session, 0, error, file_name, line_number, fmt, ap); + (void)__wt_eventv( + session, false, error, file_name, line_number, fmt, ap); va_end(ap); #ifdef HAVE_DIAGNOSTIC diff --git a/src/third_party/wiredtiger/src/support/filename.c b/src/third_party/wiredtiger/src/support/filename.c index c66e35e2ade..02a83803e25 100644 --- a/src/third_party/wiredtiger/src/support/filename.c +++ b/src/third_party/wiredtiger/src/support/filename.c @@ -56,7 +56,7 @@ __wt_nfilename( int __wt_remove_if_exists(WT_SESSION_IMPL *session, const char *name) { - int exist; + bool exist; WT_RET(__wt_exist(session, name, &exist)); if (exist) diff --git a/src/third_party/wiredtiger/src/support/global.c b/src/third_party/wiredtiger/src/support/global.c index 5ddd291c6d4..1e32f5b4453 100644 --- a/src/third_party/wiredtiger/src/support/global.c +++ b/src/third_party/wiredtiger/src/support/global.c @@ -19,10 +19,10 @@ static int __system_is_little_endian(void) { uint64_t v; - int little; + bool little; v = 1; - little = *((uint8_t *)&v) == 0 ? 0 : 1; + little = *((uint8_t *)&v) != 0; if (little) return (0); @@ -74,7 +74,7 @@ __wt_global_once(void) int __wt_library_init(void) { - static int first = 1; + static bool first = true; WT_DECL_RET; /* @@ -86,7 +86,7 @@ __wt_library_init(void) if (first) { if ((ret = __wt_once(__wt_global_once)) != 0) __wt_pthread_once_failed = ret; - first = 0; + first = false; } return (__wt_pthread_once_failed); } diff --git a/src/third_party/wiredtiger/src/support/hazard.c b/src/third_party/wiredtiger/src/support/hazard.c index 0f45c1dfd99..0fc7051fb90 100644 --- a/src/third_party/wiredtiger/src/support/hazard.c +++ b/src/third_party/wiredtiger/src/support/hazard.c @@ -17,7 +17,7 @@ static void __hazard_dump(WT_SESSION_IMPL *); * Set a hazard pointer. */ int -__wt_hazard_set(WT_SESSION_IMPL *session, WT_REF *ref, int *busyp +__wt_hazard_set(WT_SESSION_IMPL *session, WT_REF *ref, bool *busyp #ifdef HAVE_DIAGNOSTIC , const char *file, int line #endif @@ -30,7 +30,7 @@ __wt_hazard_set(WT_SESSION_IMPL *session, WT_REF *ref, int *busyp btree = S2BT(session); conn = S2C(session); - *busyp = 0; + *busyp = false; /* If a file can never be evicted, hazard pointers aren't required. */ if (F_ISSET(btree, WT_BTREE_IN_MEMORY)) @@ -117,7 +117,7 @@ __wt_hazard_set(WT_SESSION_IMPL *session, WT_REF *ref, int *busyp * prevent some random page from being evicted. */ hp->page = NULL; - *busyp = 1; + *busyp = true; return (0); } @@ -187,17 +187,17 @@ void __wt_hazard_close(WT_SESSION_IMPL *session) { WT_HAZARD *hp; - int found; + bool found; /* * Check for a set hazard pointer and complain if we find one. We could * just check the session's hazard pointer count, but this is a useful * diagnostic. */ - for (found = 0, hp = session->hazard; + for (found = false, hp = session->hazard; hp < session->hazard + session->hazard_size; ++hp) if (hp->page != NULL) { - found = 1; + found = true; break; } if (session->nhazard == 0 && !found) diff --git a/src/third_party/wiredtiger/src/support/huffman.c b/src/third_party/wiredtiger/src/support/huffman.c index ae1f05af41c..966257bb080 100644 --- a/src/third_party/wiredtiger/src/support/huffman.c +++ b/src/third_party/wiredtiger/src/support/huffman.c @@ -790,7 +790,8 @@ __wt_huffman_decode(WT_SESSION_IMPL *session, void *huffman_arg, symbol = huffman->code2symbol[pattern & mask]; len = huffman->codes[symbol].length; valid -= len; - WT_ASSERT(session, from_len_bits >= len); + if (from_len_bits < len) /* corrupted */ + WT_ERR(EINVAL); from_len_bits -= len; WT_ASSERT(session, diff --git a/src/third_party/wiredtiger/src/support/scratch.c b/src/third_party/wiredtiger/src/support/scratch.c index ebea484a51f..f0c403c9ec8 100644 --- a/src/third_party/wiredtiger/src/support/scratch.c +++ b/src/third_party/wiredtiger/src/support/scratch.c @@ -17,7 +17,7 @@ int __wt_buf_grow_worker(WT_SESSION_IMPL *session, WT_ITEM *buf, size_t size) { size_t offset; - int copy_data; + bool copy_data; /* * Maintain the existing data: there are 3 cases: @@ -30,10 +30,10 @@ __wt_buf_grow_worker(WT_SESSION_IMPL *session, WT_ITEM *buf, size_t size) */ if (WT_DATA_IN_ITEM(buf)) { offset = WT_PTRDIFF(buf->data, buf->mem); - copy_data = 0; + copy_data = false; } else { offset = 0; - copy_data = buf->size ? 1 : 0; + copy_data = buf->size > 0; } /* diff --git a/src/third_party/wiredtiger/src/support/stat.c b/src/third_party/wiredtiger/src/support/stat.c index b6b9dd71b3b..4e7f54937f4 100644 --- a/src/third_party/wiredtiger/src/support/stat.c +++ b/src/third_party/wiredtiger/src/support/stat.c @@ -577,6 +577,7 @@ static const char * const __stats_connection_desc[] = { "log: maximum log file size", "log: pre-allocated log files prepared", "log: number of pre-allocated log files to create", + "log: pre-allocated log files not ready and missed", "log: pre-allocated log files used", "log: log release advances write LSN", "log: records processed by log scan", @@ -773,6 +774,7 @@ __wt_stat_connection_clear_single(WT_CONNECTION_STATS *stats) stats->log_slot_consolidated = 0; /* not clearing log_max_filesize */ /* not clearing log_prealloc_max */ + stats->log_prealloc_missed = 0; stats->log_prealloc_files = 0; stats->log_prealloc_used = 0; stats->log_scan_records = 0; @@ -959,6 +961,7 @@ __wt_stat_connection_aggregate( WT_STAT_READ(from, log_slot_consolidated); to->log_max_filesize += WT_STAT_READ(from, log_max_filesize); to->log_prealloc_max += WT_STAT_READ(from, log_prealloc_max); + to->log_prealloc_missed += WT_STAT_READ(from, log_prealloc_missed); to->log_prealloc_files += WT_STAT_READ(from, log_prealloc_files); to->log_prealloc_used += WT_STAT_READ(from, log_prealloc_used); to->log_scan_records += WT_STAT_READ(from, log_scan_records); diff --git a/src/third_party/wiredtiger/src/txn/txn.c b/src/third_party/wiredtiger/src/txn/txn.c index e81f8a68251..a37fa3555b0 100644 --- a/src/third_party/wiredtiger/src/txn/txn.c +++ b/src/third_party/wiredtiger/src/txn/txn.c @@ -202,7 +202,7 @@ __wt_txn_get_snapshot(WT_SESSION_IMPL *session) * past the last committed transaction. */ void -__wt_txn_update_oldest(WT_SESSION_IMPL *session, int force) +__wt_txn_update_oldest(WT_SESSION_IMPL *session, bool force) { WT_CONNECTION_IMPL *conn; WT_SESSION_IMPL *oldest_session; @@ -211,7 +211,7 @@ __wt_txn_update_oldest(WT_SESSION_IMPL *session, int force) uint64_t current_id, id, last_running, oldest_id, prev_oldest_id; uint32_t i, session_cnt; int32_t count; - int last_running_moved; + bool last_running_moved; conn = S2C(session); txn_global = &conn->txn_global; @@ -519,7 +519,6 @@ __wt_txn_commit(WT_SESSION_IMPL *session, const char *cfg[]) */ __wt_txn_release_snapshot(session); ret = __wt_txn_log_commit(session, cfg); - WT_ASSERT(session, ret == 0); } /* diff --git a/src/third_party/wiredtiger/src/txn/txn_ckpt.c b/src/third_party/wiredtiger/src/txn/txn_ckpt.c index 9f59c53314e..ccd6ce23560 100644 --- a/src/third_party/wiredtiger/src/txn/txn_ckpt.c +++ b/src/third_party/wiredtiger/src/txn/txn_ckpt.c @@ -90,15 +90,15 @@ err: if (cursor != NULL) */ static int __checkpoint_apply_all(WT_SESSION_IMPL *session, const char *cfg[], - int (*op)(WT_SESSION_IMPL *, const char *[]), int *fullp) + int (*op)(WT_SESSION_IMPL *, const char *[]), bool *fullp) { WT_CONFIG targetconf; WT_CONFIG_ITEM cval, k, v; WT_DECL_ITEM(tmp); WT_DECL_RET; - int ckpt_closed, named, target_list; + bool ckpt_closed, named, target_list; - target_list = 0; + target_list = false; /* Flag if this is a named checkpoint, and check if the name is OK. */ WT_RET(__wt_config_gets(session, cfg, "name", &cval)); @@ -112,7 +112,7 @@ __checkpoint_apply_all(WT_SESSION_IMPL *session, const char *cfg[], while ((ret = __wt_config_next(&targetconf, &k, &v)) == 0) { if (!target_list) { WT_ERR(__wt_scr_alloc(session, 512, &tmp)); - target_list = 1; + target_list = true; } if (v.len != 0) @@ -157,7 +157,7 @@ __checkpoint_apply_all(WT_SESSION_IMPL *session, const char *cfg[], } WT_ERR(ckpt_closed ? __wt_meta_btree_apply(session, op, cfg) : - __wt_conn_btree_apply(session, 0, NULL, op, cfg)); + __wt_conn_btree_apply(session, false, NULL, op, cfg)); } if (fullp != NULL) @@ -359,7 +359,7 @@ __wt_txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[]) WT_TXN_STATE *txn_state; void *saved_meta_next; u_int i; - int full, idle, logging, tracking; + bool full, idle, logging, tracking; const char *txn_cfg[] = { WT_CONFIG_BASE(session, WT_SESSION_begin_transaction), "isolation=snapshot", NULL }; @@ -368,7 +368,7 @@ __wt_txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[]) txn_global = &conn->txn_global; txn_state = WT_SESSION_TXN_STATE(session); saved_isolation = session->isolation; - full = idle = logging= tracking = 0; + full = idle = logging = tracking = false; /* Ensure the metadata table is open before taking any locks. */ WT_RET(__wt_metadata_open(session)); @@ -399,7 +399,7 @@ __wt_txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[]) * This is particularly important for compact, so that all dirty pages * can be fully written. */ - __wt_txn_update_oldest(session, 1); + __wt_txn_update_oldest(session, true); /* Flush data-sources before we start the checkpoint. */ WT_ERR(__checkpoint_data_source(session, cfg)); @@ -427,7 +427,7 @@ __wt_txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[]) __wt_spin_lock(session, &conn->schema_lock); WT_ERR(__wt_meta_track_on(session)); - tracking = 1; + tracking = true; /* Tell logging that we are about to start a database checkpoint. */ if (full && logging) @@ -559,8 +559,8 @@ __wt_txn_checkpoint(WT_SESSION_IMPL *session, const char *cfg[]) "metadata sync completed", &verb_timer)); } else WT_WITH_DHANDLE(session, session->meta_dhandle, - ret = __wt_txn_checkpoint_log(session, - 0, WT_TXN_LOG_CKPT_SYNC, NULL)); + ret = __wt_txn_checkpoint_log( + session, false, WT_TXN_LOG_CKPT_SYNC, NULL)); if (full) { WT_ERR(__wt_epoch(session, &stop)); @@ -582,7 +582,7 @@ err: /* */ session->isolation = txn->isolation = WT_ISO_READ_UNCOMMITTED; if (tracking) - WT_TRET(__wt_meta_track_off(session, 0, ret != 0)); + WT_TRET(__wt_meta_track_off(session, false, ret != 0)); if (F_ISSET(txn, WT_TXN_RUNNING)) { /* @@ -603,7 +603,7 @@ err: /* if (ret == 0 && F_ISSET((WT_BTREE *)session->meta_dhandle->handle, WT_BTREE_SKIP_CKPT)) - idle = 1; + idle = true; WT_TRET(__wt_txn_checkpoint_log(session, full, (ret == 0 && !idle) ? WT_TXN_LOG_CKPT_STOP : WT_TXN_LOG_CKPT_CLEANUP, NULL)); @@ -664,7 +664,7 @@ static void __drop_from(WT_CKPT *ckptbase, const char *name, size_t len) { WT_CKPT *ckpt; - int matched; + bool matched; /* * There's a special case -- if the name is "all", then we delete all @@ -681,12 +681,12 @@ __drop_from(WT_CKPT *ckptbase, const char *name, size_t len) * checkpoints with the same name in the list, we'll delete from the * first match to the end. */ - matched = 0; + matched = false; WT_CKPT_FOREACH(ckptbase, ckpt) { if (!matched && !WT_STRING_MATCH(ckpt->name, name, len)) continue; - matched = 1; + matched = true; F_SET(ckpt, WT_CKPT_DELETE); } } @@ -727,7 +727,7 @@ __drop_to(WT_CKPT *ckptbase, const char *name, size_t len) */ static int __checkpoint_worker( - WT_SESSION_IMPL *session, const char *cfg[], int is_checkpoint) + WT_SESSION_IMPL *session, const char *cfg[], bool is_checkpoint) { WT_BM *bm; WT_BTREE *btree; @@ -738,8 +738,9 @@ __checkpoint_worker( WT_DATA_HANDLE *dhandle; WT_DECL_RET; WT_LSN ckptlsn; + int deleted, was_modified; + bool fake_ckpt, force, hot_backup_locked; const char *name; - int deleted, fake_ckpt, force, hot_backup_locked, was_modified; char *name_alloc; btree = S2BT(session); @@ -747,11 +748,9 @@ __checkpoint_worker( conn = S2C(session); ckpt = ckptbase = NULL; dhandle = session->dhandle; - name_alloc = NULL; - hot_backup_locked = 0; - name_alloc = NULL; - fake_ckpt = 0; was_modified = btree->modified; + fake_ckpt = hot_backup_locked = false; + name_alloc = NULL; /* * Set the checkpoint LSN to the maximum LSN so that if logging is @@ -836,14 +835,14 @@ __checkpoint_worker( * to open the checkpoint in a cursor after taking any checkpoint, which * means it must exist. */ - force = 0; + force = false; F_CLR(btree, WT_BTREE_SKIP_CKPT); if (!btree->modified && cfg != NULL) { ret = __wt_config_gets(session, cfg, "force", &cval); if (ret != 0 && ret != WT_NOTFOUND) WT_ERR(ret); if (ret == 0 && cval.val != 0) - force = 1; + force = true; } if (!btree->modified && !force) { if (!is_checkpoint) @@ -890,7 +889,7 @@ nockpt: F_SET(btree, WT_BTREE_SKIP_CKPT); * we don't want to race with a future hot backup. */ WT_ERR(__wt_readlock(session, conn->hot_backup_lock)); - hot_backup_locked = 1; + hot_backup_locked = true; if (conn->hot_backup) WT_CKPT_FOREACH(ckptbase, ckpt) { if (!F_ISSET(ckpt, WT_CKPT_DELETE)) @@ -961,7 +960,7 @@ nockpt: F_SET(btree, WT_BTREE_SKIP_CKPT); * names with checkpoints. */ if (is_checkpoint) - switch (F_ISSET(btree, WT_BTREE_SPECIAL_FLAGS)) { + switch (F_MASK(btree, WT_BTREE_SPECIAL_FLAGS)) { case 0: break; case WT_BTREE_BULK: @@ -976,7 +975,7 @@ nockpt: F_SET(btree, WT_BTREE_SKIP_CKPT); WT_ERR_MSG(session, ret, "block-manager checkpoint found " "for a bulk-loaded file"); - fake_ckpt = 1; + fake_ckpt = true; goto fake; case WT_BTREE_SALVAGE: case WT_BTREE_UPGRADE: @@ -1001,7 +1000,7 @@ nockpt: F_SET(btree, WT_BTREE_SKIP_CKPT); */ if (is_checkpoint) if (btree->bulk_load_ok) { - fake_ckpt = 1; + fake_ckpt = true; goto fake; } @@ -1034,7 +1033,7 @@ nockpt: F_SET(btree, WT_BTREE_SKIP_CKPT); /* Tell logging that a file checkpoint is starting. */ if (FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED)) WT_ERR(__wt_txn_checkpoint_log( - session, 0, WT_TXN_LOG_CKPT_START, &ckptlsn)); + session, false, WT_TXN_LOG_CKPT_START, &ckptlsn)); /* Flush the file from the cache, creating the checkpoint. */ if (is_checkpoint) @@ -1097,7 +1096,7 @@ fake: /* /* Tell logging that the checkpoint is complete. */ if (FLD_ISSET(conn->log_flags, WT_CONN_LOG_ENABLED)) WT_ERR(__wt_txn_checkpoint_log( - session, 0, WT_TXN_LOG_CKPT_STOP, NULL)); + session, false, WT_TXN_LOG_CKPT_STOP, NULL)); done: err: /* @@ -1129,7 +1128,7 @@ __wt_checkpoint(WT_SESSION_IMPL *session, const char *cfg[]) /* Should be holding the schema lock. */ WT_ASSERT(session, F_ISSET(session, WT_SESSION_LOCKED_SCHEMA)); - return (__checkpoint_worker(session, cfg, 1)); + return (__checkpoint_worker(session, cfg, true)); } /* @@ -1151,7 +1150,7 @@ __wt_checkpoint_sync(WT_SESSION_IMPL *session, const char *cfg[]) /* Should have an underlying block manager reference. */ WT_ASSERT(session, bm != NULL); - return (bm->sync(bm, session, 0)); + return (bm->sync(bm, session, false)); } /* @@ -1159,14 +1158,14 @@ __wt_checkpoint_sync(WT_SESSION_IMPL *session, const char *cfg[]) * Checkpoint a single file as part of closing the handle. */ int -__wt_checkpoint_close(WT_SESSION_IMPL *session, int final) +__wt_checkpoint_close(WT_SESSION_IMPL *session, bool final) { WT_BTREE *btree; WT_DECL_RET; - int bulk, need_tracking; + bool bulk, need_tracking; btree = S2BT(session); - bulk = F_ISSET(btree, WT_BTREE_BULK) ? 1 : 0; + bulk = F_ISSET(btree, WT_BTREE_BULK); /* * If the handle is already dead or the file isn't durable, force the @@ -1185,7 +1184,7 @@ __wt_checkpoint_close(WT_SESSION_IMPL *session, int final) * for active readers. */ if (!btree->modified && !bulk) { - __wt_txn_update_oldest(session, 1); + __wt_txn_update_oldest(session, true); return (__wt_txn_visible_all(session, btree->rec_max_txn) ? __wt_cache_op(session, NULL, WT_SYNC_DISCARD) : EBUSY); } @@ -1209,10 +1208,10 @@ __wt_checkpoint_close(WT_SESSION_IMPL *session, int final) if (need_tracking) WT_RET(__wt_meta_track_on(session)); - WT_TRET(__checkpoint_worker(session, NULL, 0)); + WT_TRET(__checkpoint_worker(session, NULL, false)); if (need_tracking) - WT_RET(__wt_meta_track_off(session, 1, ret != 0)); + WT_RET(__wt_meta_track_off(session, true, ret != 0)); return (ret); } diff --git a/src/third_party/wiredtiger/src/txn/txn_log.c b/src/third_party/wiredtiger/src/txn/txn_log.c index 7a53fb65b1f..05efd00aff8 100644 --- a/src/third_party/wiredtiger/src/txn/txn_log.c +++ b/src/third_party/wiredtiger/src/txn/txn_log.c @@ -66,9 +66,9 @@ static int __txn_commit_printlog( WT_SESSION_IMPL *session, const uint8_t **pp, const uint8_t *end, FILE *out) { - int firstrecord; + bool firstrecord; - firstrecord = 1; + firstrecord = true; WT_RET(__wt_fprintf(out, " \"ops\": [\n")); /* The logging subsystem zero-pads records. */ @@ -77,7 +77,7 @@ __txn_commit_printlog( WT_RET(__wt_fprintf(out, ",\n")); WT_RET(__wt_fprintf(out, " {")); - firstrecord = 0; + firstrecord = false; WT_RET(__wt_txn_op_printlog(session, pp, end, out)); WT_RET(__wt_fprintf(out, "\n }")); @@ -226,7 +226,8 @@ __txn_log_file_sync(WT_SESSION_IMPL *session, uint32_t flags, WT_LSN *lsnp) WT_DECL_RET; size_t header_size; uint32_t rectype = WT_LOGREC_FILE_SYNC; - int start, need_sync; + int start; + bool need_sync; const char *fmt = WT_UNCHECKED_STRING(III); btree = S2BT(session); @@ -276,7 +277,7 @@ __wt_txn_checkpoint_logread( */ int __wt_txn_checkpoint_log( - WT_SESSION_IMPL *session, int full, uint32_t flags, WT_LSN *lsnp) + WT_SESSION_IMPL *session, bool full, uint32_t flags, WT_LSN *lsnp) { WT_DECL_ITEM(logrec); WT_DECL_RET; @@ -307,7 +308,7 @@ __wt_txn_checkpoint_log( switch (flags) { case WT_TXN_LOG_CKPT_PREPARE: txn->full_ckpt = 1; - WT_ERR(__wt_log_flush_lsn(session, ckpt_lsn, 1)); + WT_ERR(__wt_log_flush_lsn(session, ckpt_lsn, true)); /* * We need to make sure that the log records in the checkpoint * LSN are on disk. In particular to make sure that the @@ -336,7 +337,7 @@ __wt_txn_checkpoint_log( txn->ckpt_nsnapshot = 0; WT_CLEAR(empty); ckpt_snapshot = ∅ - WT_ERR(__wt_log_flush_lsn(session, ckpt_lsn, 1)); + WT_ERR(__wt_log_flush_lsn(session, ckpt_lsn, true)); } else ckpt_snapshot = txn->ckpt_snapshot; @@ -458,12 +459,12 @@ __txn_printlog(WT_SESSION_IMPL *session, FILE *out; WT_LOG_RECORD *logrec; WT_LSN ckpt_lsn; - int compressed; + const uint8_t *end, *p; + const char *msg; uint64_t txnid; uint32_t fileid, rectype; int32_t start; - const uint8_t *end, *p; - const char *msg; + bool compressed; WT_UNUSED(next_lsnp); out = cookie; diff --git a/src/third_party/wiredtiger/src/txn/txn_nsnap.c b/src/third_party/wiredtiger/src/txn/txn_nsnap.c index be736cc1c98..a5ec9cb9b82 100644 --- a/src/third_party/wiredtiger/src/txn/txn_nsnap.c +++ b/src/third_party/wiredtiger/src/txn/txn_nsnap.c @@ -57,7 +57,7 @@ __nsnap_drop_one(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *name) * dropped. The named snapshot lock must be held write locked. */ static int -__nsnap_drop_to(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *name, int inclusive) +__nsnap_drop_to(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *name, bool inclusive) { WT_DECL_RET; WT_NAMED_SNAPSHOT *last, *nsnap, *prev; @@ -135,9 +135,9 @@ __wt_txn_named_snapshot_begin(WT_SESSION_IMPL *session, const char *cfg[]) const char *txn_cfg[] = { WT_CONFIG_BASE(session, WT_SESSION_begin_transaction), "isolation=snapshot", NULL }; - int started_txn; + bool started_txn; - started_txn = 0; + started_txn = false; nsnap_new = NULL; txn_global = &S2C(session)->txn_global; txn = &session->txn; @@ -147,7 +147,7 @@ __wt_txn_named_snapshot_begin(WT_SESSION_IMPL *session, const char *cfg[]) if (!F_ISSET(txn, WT_TXN_RUNNING)) { WT_RET(__wt_txn_begin(session, txn_cfg)); - started_txn = 1; + started_txn = true; } F_SET(txn, WT_TXN_READONLY); @@ -208,11 +208,11 @@ __wt_txn_named_snapshot_drop(WT_SESSION_IMPL *session, const char *cfg[]) session, cfg, "drop.before", 0, &before_config)); if (all_config.val != 0) - WT_RET(__nsnap_drop_to(session, NULL, 1)); + WT_RET(__nsnap_drop_to(session, NULL, true)); else if (before_config.len != 0) - WT_RET(__nsnap_drop_to(session, &before_config, 0)); + WT_RET(__nsnap_drop_to(session, &before_config, false)); else if (to_config.len != 0) - WT_RET(__nsnap_drop_to(session, &to_config, 1)); + WT_RET(__nsnap_drop_to(session, &to_config, true)); /* We are done if there are no named drops */ @@ -284,14 +284,14 @@ __wt_txn_named_snapshot_get(WT_SESSION_IMPL *session, WT_CONFIG_ITEM *nameval) */ int __wt_txn_named_snapshot_config(WT_SESSION_IMPL *session, - const char *cfg[], int *has_create, int *has_drops) + const char *cfg[], bool *has_create, bool *has_drops) { WT_CONFIG_ITEM cval; WT_CONFIG_ITEM all_config, names_config, to_config, before_config; WT_TXN *txn; txn = &session->txn; - *has_create = *has_drops = 0; + *has_create = *has_drops = false; /* Verify that the name is legal. */ WT_RET(__wt_config_gets_def(session, cfg, "name", 0, &cval)); @@ -311,7 +311,7 @@ __wt_txn_named_snapshot_config(WT_SESSION_IMPL *session, WT_RET_MSG(session, EINVAL, "Can't create a named snapshot from a running " "transaction that has made updates"); - *has_create = 1; + *has_create = true; } /* Verify that the drop configuration is sane. */ @@ -334,7 +334,7 @@ __wt_txn_named_snapshot_config(WT_SESSION_IMPL *session, WT_RET_MSG(session, EINVAL, "Illegal configuration; named snapshot drop can't " "specify all and any other options"); - *has_drops = 1; + *has_drops = true; } if (!*has_create && !*has_drops) diff --git a/src/third_party/wiredtiger/src/txn/txn_recover.c b/src/third_party/wiredtiger/src/txn/txn_recover.c index 240d0a5ffd3..f2b181711d1 100644 --- a/src/third_party/wiredtiger/src/txn/txn_recover.c +++ b/src/third_party/wiredtiger/src/txn/txn_recover.c @@ -24,9 +24,8 @@ typedef struct { WT_LSN ckpt_lsn; /* Start LSN for main recovery loop. */ - int missing; /* Were there missing files? */ - int modified; /* Did recovery make any changes? */ - int metadata_only; /* + bool missing; /* Were there missing files? */ + bool metadata_only; /* * Set during the first recovery pass, * when only the metadata is recovered. */ @@ -38,12 +37,12 @@ typedef struct { */ static int __recovery_cursor(WT_SESSION_IMPL *session, WT_RECOVERY *r, - WT_LSN *lsnp, u_int id, int duplicate, WT_CURSOR **cp) + WT_LSN *lsnp, u_int id, bool duplicate, WT_CURSOR **cp) { WT_CURSOR *c; + bool metadata_op; const char *cfg[] = { WT_CONFIG_BASE( session, WT_SESSION_open_cursor), "overwrite", NULL }; - int metadata_op; c = NULL; @@ -55,7 +54,7 @@ __recovery_cursor(WT_SESSION_IMPL *session, WT_RECOVERY *r, * is more recent than the last checkpoint. If there is no entry for a * file, assume it was dropped or missing after a hot backup. */ - metadata_op = (id == WT_METAFILE_ID); + metadata_op = id == WT_METAFILE_ID; if (r->metadata_only != metadata_op) ; else if (id >= r->nfiles || r->files[id].uri == NULL) { @@ -64,7 +63,7 @@ __recovery_cursor(WT_SESSION_IMPL *session, WT_RECOVERY *r, WT_RET(__wt_verbose(session, WT_VERB_RECOVERY, "No file found with ID %u (max %u)", id, r->nfiles)); - r->missing = 1; + r->missing = true; } else if (__wt_log_cmp(lsnp, &r->files[id].ckpt_lsn) >= 0) { /* * We're going to apply the operation. Get the cursor, opening @@ -90,7 +89,7 @@ __recovery_cursor(WT_SESSION_IMPL *session, WT_RECOVERY *r, */ #define GET_RECOVERY_CURSOR(session, r, lsnp, fileid, cp) \ WT_ERR(__recovery_cursor( \ - (session), (r), (lsnp), (fileid), 0, (cp))); \ + (session), (r), (lsnp), (fileid), false, (cp))); \ WT_ERR(__wt_verbose((session), WT_VERB_RECOVERY, \ "%s op %d to file %d at LSN %u/%" PRIuMAX, \ (cursor == NULL) ? "Skipping" : "Applying", \ @@ -153,7 +152,7 @@ __txn_op_apply( } else { start = cursor; WT_ERR(__recovery_cursor( - session, r, lsnp, fileid, 1, &stop)); + session, r, lsnp, fileid, true, &stop)); } /* Set the keys. */ @@ -200,7 +199,7 @@ __txn_op_apply( case WT_TXN_TRUNC_BOTH: start = cursor; WT_ERR(__recovery_cursor( - session, r, lsnp, fileid, 1, &stop)); + session, r, lsnp, fileid, true, &stop)); break; case WT_TXN_TRUNC_START: start = cursor; @@ -233,8 +232,6 @@ __txn_op_apply( if (cursor != NULL) WT_ERR(cursor->reset(cursor)); - r->modified = 1; - err: if (ret != 0) __wt_err(session, ret, "Operation failed during recovery"); return (ret); @@ -415,15 +412,15 @@ __wt_txn_recover(WT_SESSION_IMPL *session) WT_RECOVERY r; struct WT_RECOVERY_FILE *metafile; char *config; - int needs_rec, was_backup; + bool needs_rec, was_backup; conn = S2C(session); WT_CLEAR(r); WT_INIT_LSN(&r.ckpt_lsn); - was_backup = F_ISSET(conn, WT_CONN_WAS_BACKUP) ? 1 : 0; + was_backup = F_ISSET(conn, WT_CONN_WAS_BACKUP); /* We need a real session for recovery. */ - WT_RET(__wt_open_session(conn, NULL, NULL, 1, &session)); + WT_RET(__wt_open_session(conn, NULL, NULL, true, &session)); F_SET(session, WT_SESSION_NO_LOGGING); r.session = session; @@ -451,7 +448,7 @@ __wt_txn_recover(WT_SESSION_IMPL *session) * backup: we already have the correct metadata in that case. */ if (!was_backup) { - r.metadata_only = 1; + r.metadata_only = true; if (WT_IS_INIT_LSN(&metafile->ckpt_lsn)) WT_ERR(__wt_log_scan(session, NULL, WT_LOGSCAN_FIRST, __txn_log_recover, &r)); @@ -485,7 +482,7 @@ __wt_txn_recover(WT_SESSION_IMPL *session) * Now, recover all the files apart from the metadata. * Pass WT_LOGSCAN_RECOVER so that old logs get truncated. */ - r.metadata_only = 0; + r.metadata_only = false; WT_ERR(__wt_verbose(session, WT_VERB_RECOVERY, "Main recovery loop: starting at %u/%" PRIuMAX, r.ckpt_lsn.file, (uintmax_t)r.ckpt_lsn.offset)); diff --git a/src/third_party/wiredtiger/src/utilities/util.h b/src/third_party/wiredtiger/src/utilities/util.h index 692b02e63f2..08d0537956f 100644 --- a/src/third_party/wiredtiger/src/utilities/util.h +++ b/src/third_party/wiredtiger/src/utilities/util.h @@ -16,7 +16,7 @@ typedef struct { extern const char *home; /* Home directory */ extern const char *progname; /* Program name */ extern const char *usage_prefix; /* Global arguments */ -extern int verbose; /* Verbose flag */ +extern bool verbose; /* Verbose flag */ extern WT_EVENT_HANDLER *verbose_handler; @@ -41,7 +41,7 @@ int util_loadtext(WT_SESSION *, int, char *[]); char *util_name(WT_SESSION *, const char *, const char *); int util_printlog(WT_SESSION *, int, char *[]); int util_read(WT_SESSION *, int, char *[]); -int util_read_line(WT_SESSION *, ULINE *, int, int *); +int util_read_line(WT_SESSION *, ULINE *, bool, bool *); int util_rename(WT_SESSION *, int, char *[]); int util_salvage(WT_SESSION *, int, char *[]); int util_stat(WT_SESSION *, int, char *[]); diff --git a/src/third_party/wiredtiger/src/utilities/util_backup.c b/src/third_party/wiredtiger/src/utilities/util_backup.c index 0eca4b3103a..d07c99afc19 100644 --- a/src/third_party/wiredtiger/src/utilities/util_backup.c +++ b/src/third_party/wiredtiger/src/utilities/util_backup.c @@ -21,7 +21,7 @@ static char *cbuf; static int append_target(WT_SESSION *session, const char *target, char **bufp) { - static int first = 1; + static bool first = true; static size_t len = 0, remain = 0; static char *buf = NULL; @@ -34,7 +34,7 @@ append_target(WT_SESSION *session, const char *target, char **bufp) *bufp = buf; } if (first) { - first = 0; + first = false; strcpy(buf, "target=("); } else buf[strlen(buf) - 1] = ','; /* overwrite previous ")" */ diff --git a/src/third_party/wiredtiger/src/utilities/util_dump.c b/src/third_party/wiredtiger/src/utilities/util_dump.c index 28d0309242d..7dfac50b724 100644 --- a/src/third_party/wiredtiger/src/utilities/util_dump.c +++ b/src/third_party/wiredtiger/src/utilities/util_dump.c @@ -8,7 +8,7 @@ #include "util.h" -static int dump_config(WT_SESSION *, const char *, int); +static int dump_config(WT_SESSION *, const char *, bool); static int dump_json_begin(WT_SESSION *); static int dump_json_end(WT_SESSION *); static int dump_json_separator(WT_SESSION *); @@ -18,8 +18,8 @@ static int dump_json_table_cg( WT_SESSION *, WT_CURSOR *, const char *, const char *, const char *); static int dump_json_table_config(WT_SESSION *, const char *); static int dump_json_table_end(WT_SESSION *); -static int dump_prefix(WT_SESSION *, int); -static int dump_record(WT_CURSOR *, int, int); +static int dump_prefix(WT_SESSION *, bool); +static int dump_record(WT_CURSOR *, bool, bool); static int dump_suffix(WT_SESSION *); static int dump_table_config(WT_SESSION *, WT_CURSOR *, const char *); static int dump_table_config_type( @@ -34,10 +34,11 @@ util_dump(WT_SESSION *session, int argc, char *argv[]) WT_CURSOR *cursor; WT_DECL_RET; size_t len; - int ch, hex, i, json, reverse; + int ch, i; + bool hex, json, reverse; char *checkpoint, *config, *name; - hex = json = reverse = 0; + hex = json = reverse = false; checkpoint = config = name = NULL; while ((ch = __wt_getopt(progname, argc, argv, "c:f:jrx")) != EOF) switch (ch) { @@ -50,13 +51,13 @@ util_dump(WT_SESSION *session, int argc, char *argv[]) session, errno, "%s: reopen", __wt_optarg)); break; case 'j': - json = 1; + json = true; break; case 'r': - reverse = 1; + reverse = true; break; case 'x': - hex = 1; + hex = true; break; case '?': default: @@ -141,7 +142,7 @@ err: ret = 1; * Dump the config for the uri. */ static int -dump_config(WT_SESSION *session, const char *uri, int hex) +dump_config(WT_SESSION *session, const char *uri, bool hex) { WT_CURSOR *cursor; WT_DECL_RET; @@ -270,13 +271,14 @@ static int dump_json_table_cg(WT_SESSION *session, WT_CURSOR *cursor, const char *name, const char *entry, const char *header) { + static const char * const indent = " "; WT_DECL_RET; + int exact; + bool once; const char *key, *skip, *value; - int exact, once; char *jsonconfig; - static const char * const indent = " "; - once = 0; + once = false; if (printf(" \"%s\" : [", header) < 0) return (util_err(session, EIO, NULL)); @@ -328,15 +330,15 @@ match: if ((ret = cursor->get_key(cursor, &key)) != 0) "%s \"uri\" : \"%s\",\n" "%s \"config\" : \"%s\"\n" "%s}", - (once == 0 ? "" : ","), + once ? "," : "", indent, indent, key, indent, jsonconfig, indent); free(jsonconfig); if (ret < 0) return (util_err(session, EIO, NULL)); - once = 1; + once = true; } - if (printf("%s]", (once == 0 ? "" : "\n ")) < 0) + if (printf("%s]", once ? "\n " : "") < 0) return (util_err(session, EIO, NULL)); if (ret == 0 || ret == WT_NOTFOUND) return (0); @@ -544,7 +546,7 @@ match: if ((ret = cursor->get_key(cursor, &key)) != 0) * Output the dump file header prefix. */ static int -dump_prefix(WT_SESSION *session, int hex) +dump_prefix(WT_SESSION *session, bool hex) { int vmajor, vminor, vpatch; @@ -565,16 +567,16 @@ dump_prefix(WT_SESSION *session, int hex) * with JSON formatting if needed. */ static int -dump_record(WT_CURSOR *cursor, int reverse, int json) +dump_record(WT_CURSOR *cursor, bool reverse, bool json) { WT_DECL_RET; WT_SESSION *session; const char *infix, *key, *prefix, *suffix, *value; - int once; + bool once; session = cursor->session; - once = 0; + once = false; if (json) { prefix = "\n{\n"; infix = ",\n"; @@ -590,10 +592,10 @@ dump_record(WT_CURSOR *cursor, int reverse, int json) return (util_cerr(cursor, "get_key", ret)); if ((ret = cursor->get_value(cursor, &value)) != 0) return (util_cerr(cursor, "get_value", ret)); - if (printf("%s%s%s%s%s%s", (json && once) ? "," : "", + if (printf("%s%s%s%s%s%s", json && once ? "," : "", prefix, key, infix, value, suffix) < 0) return (util_err(session, EIO, NULL)); - once = 1; + once = true; } if (json && once && printf("\n") < 0) return (util_err(session, EIO, NULL)); @@ -627,14 +629,14 @@ dup_json_string(const char *str, char **result) nchars = 0; for (p = str; *p; p++, nchars++) - nchars += __wt_json_unpack_char(*p, NULL, 0, 0); + nchars += __wt_json_unpack_char(*p, NULL, 0, false); q = malloc(nchars + 1); if (q == NULL) return (1); *result = q; left = nchars; for (p = str; *p; p++, nchars++) { - nchars = __wt_json_unpack_char(*p, (u_char *)q, left, 0); + nchars = __wt_json_unpack_char(*p, (u_char *)q, left, false); left -= nchars; q += nchars; } diff --git a/src/third_party/wiredtiger/src/utilities/util_list.c b/src/third_party/wiredtiger/src/utilities/util_list.c index 1d35f2efc72..99a1455a74e 100644 --- a/src/third_party/wiredtiger/src/utilities/util_list.c +++ b/src/third_party/wiredtiger/src/utilities/util_list.c @@ -8,7 +8,7 @@ #include "util.h" -static int list_print(WT_SESSION *, const char *, int, int); +static int list_print(WT_SESSION *, const char *, bool, bool); static int list_print_checkpoint(WT_SESSION *, const char *); static int usage(void); @@ -16,18 +16,19 @@ int util_list(WT_SESSION *session, int argc, char *argv[]) { WT_DECL_RET; - int cflag, ch, vflag; + int ch; + bool cflag, vflag; char *name; - cflag = vflag = 0; + cflag = vflag = false; name = NULL; while ((ch = __wt_getopt(progname, argc, argv, "cv")) != EOF) switch (ch) { case 'c': - cflag = 1; + cflag = true; break; case 'v': - vflag = 1; + vflag = true; break; case '?': default: @@ -59,11 +60,11 @@ util_list(WT_SESSION *session, int argc, char *argv[]) * List the high-level objects in the database. */ static int -list_print(WT_SESSION *session, const char *name, int cflag, int vflag) +list_print(WT_SESSION *session, const char *name, bool cflag, bool vflag) { WT_CURSOR *cursor; WT_DECL_RET; - int found; + bool found; const char *key, *value; /* Open the metadata file. */ @@ -93,7 +94,7 @@ list_print(WT_SESSION *session, const char *name, int cflag, int vflag) if (name != NULL) { if (!WT_PREFIX_MATCH(key, name)) continue; - found = 1; + found = true; } /* diff --git a/src/third_party/wiredtiger/src/utilities/util_load.c b/src/third_party/wiredtiger/src/utilities/util_load.c index f4f173b90c2..a40fa60361f 100644 --- a/src/third_party/wiredtiger/src/utilities/util_load.c +++ b/src/third_party/wiredtiger/src/utilities/util_load.c @@ -9,25 +9,25 @@ #include "util.h" #include "util_load.h" -static int config_read(WT_SESSION *, char ***, int *); +static int config_read(WT_SESSION *, char ***, bool *); static int config_rename(WT_SESSION *, char **, const char *); static int format(WT_SESSION *); static int insert(WT_CURSOR *, const char *); static int load_dump(WT_SESSION *); static int usage(void); -static int append; /* -a append (ignore record number keys) */ -static char *cmdname; /* -r rename */ -static char **cmdconfig; /* configuration pairs */ -static int json; /* -j input is JSON format */ -static int no_overwrite; /* -n don't overwrite existing data */ +static bool append = false; /* -a append (ignore number keys) */ +static char *cmdname; /* -r rename */ +static char **cmdconfig; /* configuration pairs */ +static bool json = false; /* -j input is JSON format */ +static bool no_overwrite = false; /* -n don't overwrite existing data */ int util_load(WT_SESSION *session, int argc, char *argv[]) { + uint32_t flags; int ch; const char *filename; - uint32_t flags; flags = 0; @@ -35,7 +35,7 @@ util_load(WT_SESSION *session, int argc, char *argv[]) while ((ch = __wt_getopt(progname, argc, argv, "af:jnr:")) != EOF) switch (ch) { case 'a': /* append (ignore record number keys) */ - append = 1; + append = true; break; case 'f': /* input file */ if (freopen(__wt_optarg, "r", stdin) == NULL) @@ -46,10 +46,10 @@ util_load(WT_SESSION *session, int argc, char *argv[]) filename = __wt_optarg; break; case 'j': /* input is JSON */ - json = 1; + json = true; break; case 'n': /* don't overwrite existing data */ - no_overwrite = 1; + no_overwrite = true; break; case 'r': /* rename */ cmdname = __wt_optarg; @@ -62,7 +62,7 @@ util_load(WT_SESSION *session, int argc, char *argv[]) argv += __wt_optind; /* -a and -o are mutually exclusive. */ - if (append == 1 && no_overwrite == 1) + if (append && no_overwrite) return (util_err(session, EINVAL, "the -a (append) and -n (no-overwrite) flags are mutually " "exclusive")); @@ -93,12 +93,13 @@ load_dump(WT_SESSION *session) { WT_CURSOR *cursor; WT_DECL_RET; - int hex, tret; + int tret; + bool hex; char **list, **tlist, *uri, config[64]; cursor = NULL; list = NULL; /* -Wuninitialized */ - hex = 0; /* -Wuninitialized */ + hex = false; /* -Wuninitialized */ uri = NULL; /* Read the metadata file. */ @@ -217,11 +218,12 @@ config_list_free(CONFIG_LIST *clp) * Read the config lines and do some basic validation. */ static int -config_read(WT_SESSION *session, char ***listp, int *hexp) +config_read(WT_SESSION *session, char ***listp, bool *hexp) { ULINE l; WT_DECL_RET; - int entry, eof, max_entry; + int entry, max_entry; + bool eof; const char *s; char **list, **tlist; @@ -229,31 +231,31 @@ config_read(WT_SESSION *session, char ***listp, int *hexp) memset(&l, 0, sizeof(l)); /* Header line #1: "WiredTiger Dump" and a WiredTiger version. */ - if (util_read_line(session, &l, 0, &eof)) + if (util_read_line(session, &l, false, &eof)) return (1); s = "WiredTiger Dump "; if (strncmp(l.mem, s, strlen(s)) != 0) return (format(session)); /* Header line #2: "Format={hex,print}". */ - if (util_read_line(session, &l, 0, &eof)) + if (util_read_line(session, &l, false, &eof)) return (1); if (strcmp(l.mem, "Format=print") == 0) - *hexp = 0; + *hexp = false; else if (strcmp(l.mem, "Format=hex") == 0) - *hexp = 1; + *hexp = true; else return (format(session)); /* Header line #3: "Header". */ - if (util_read_line(session, &l, 0, &eof)) + if (util_read_line(session, &l, false, &eof)) return (1); if (strcmp(l.mem, "Header") != 0) return (format(session)); /* Now, read in lines until we get to the end of the headers. */ for (entry = max_entry = 0, list = NULL;; ++entry) { - if ((ret = util_read_line(session, &l, 0, &eof)) != 0) + if ((ret = util_read_line(session, &l, false, &eof)) != 0) goto err; if (strcmp(l.mem, "Data") == 0) break; @@ -350,8 +352,8 @@ int config_update(WT_SESSION *session, char **list) { WT_DECL_RET; - int found; size_t cnt; + int found; const char *p, **cfg; char **configp, **listp; @@ -513,7 +515,7 @@ insert(WT_CURSOR *cursor, const char *name) WT_DECL_RET; WT_SESSION *session; uint64_t insert_count; - int eof; + bool eof; session = cursor->session; @@ -528,14 +530,14 @@ insert(WT_CURSOR *cursor, const char *name) * and ignore it (a dump with "append" set), or not read it at * all (flat-text load). */ - if (util_read_line(session, &key, 1, &eof)) + if (util_read_line(session, &key, true, &eof)) return (1); - if (eof == 1) + if (eof) break; if (!append) cursor->set_key(cursor, key.mem); - if (util_read_line(session, &value, 0, &eof)) + if (util_read_line(session, &value, false, &eof)) return (1); cursor->set_value(cursor, value.mem); diff --git a/src/third_party/wiredtiger/src/utilities/util_load_json.c b/src/third_party/wiredtiger/src/utilities/util_load_json.c index 2604348e56b..c7d4893ae20 100644 --- a/src/third_party/wiredtiger/src/utilities/util_load_json.c +++ b/src/third_party/wiredtiger/src/utilities/util_load_json.c @@ -28,8 +28,8 @@ typedef struct { WT_SESSION *session; /* associated session */ ULINE line; /* current line */ const char *p; /* points to cur position in line.mem */ - int ateof; /* current token is EOF */ - int peeking; /* peeking at next token */ + bool ateof; /* current token is EOF */ + bool peeking; /* peeking at next token */ int toktype; /* next token, defined by __wt_json_token() */ const char *tokstart; /* next token start (points into line.mem) */ size_t toklen; /* next token length */ @@ -71,8 +71,8 @@ json_column_group_index(WT_SESSION *session, JSON_INPUT_STATE *ins, CONFIG_LIST *clp, int idx) { WT_DECL_RET; + bool isconfig; char *config, *p, *uri; - int isconfig; uri = NULL; config = NULL; @@ -144,8 +144,8 @@ static int json_kvraw_append(WT_SESSION *session, JSON_INPUT_STATE *ins, const char *str, size_t len) { - char *tmp; size_t needsize; + char *tmp; if (len > 0) { needsize = strlen(ins->kvraw) + len + 2; @@ -213,12 +213,13 @@ json_data(WT_SESSION *session, { WT_CURSOR *cursor; WT_DECL_RET; - char config[64], *endp, *uri; - const char *keyformat; - int isrec, nfield, nkeys, toktype, tret; size_t keystrlen; ssize_t gotnolen; uint64_t gotno, recno; + int nfield, nkeys, toktype, tret; + bool isrec; + char config[64], *endp, *uri; + const char *keyformat; cursor = NULL; uri = NULL; @@ -246,7 +247,7 @@ json_data(WT_SESSION *session, goto err; } keyformat = cursor->key_format; - isrec = (strcmp(keyformat, "r") == 0); + isrec = strcmp(keyformat, "r") == 0; for (nkeys = 0; *keyformat; keyformat++) if (!isdigit(*keyformat)) nkeys++; @@ -345,10 +346,10 @@ json_top_level(WT_SESSION *session, JSON_INPUT_STATE *ins, uint32_t flags) { CONFIG_LIST cl; WT_DECL_RET; - char *config, *tableuri; int toktype; static const char *json_markers[] = { "\"config\"", "\"colgroups\"", "\"indices\"", "\"data\"", NULL }; + char *config, *tableuri; memset(&cl, 0, sizeof(cl)); tableuri = NULL; @@ -462,7 +463,7 @@ json_peek(WT_SESSION *session, JSON_INPUT_STATE *ins) ins->kvrawstart = 0; } if (util_read_line( - session, &ins->line, 1, &ins->ateof)) { + session, &ins->line, true, &ins->ateof)) { ins->toktype = -1; ret = -1; goto err; @@ -476,7 +477,7 @@ json_peek(WT_SESSION *session, JSON_INPUT_STATE *ins) &ins->toktype, &ins->tokstart, &ins->toklen) != 0) ins->toktype = -1; - ins->peeking = 1; + ins->peeking = true; } if (0) { err: if (ret == 0) @@ -498,7 +499,7 @@ json_expect(WT_SESSION *session, JSON_INPUT_STATE *ins, int wanttok) if (json_peek(session, ins) < 0) return (1); ins->p += ins->toklen; - ins->peeking = 0; + ins->peeking = false; if (ins->toktype != wanttok) { fprintf(stderr, "%s: %d: %" WT_SIZET_FMT ": expected %s, got %s\n", @@ -532,7 +533,7 @@ json_skip(WT_SESSION *session, JSON_INPUT_STATE *ins, const char **matches) for (match = matches; *match != NULL; match++) if ((hit = strstr(ins->p, *match)) != NULL) goto out; - if (util_read_line(session, &ins->line, 1, &ins->ateof)) { + if (util_read_line(session, &ins->line, true, &ins->ateof)) { ins->toktype = -1; return (1); } @@ -545,7 +546,7 @@ out: /* Set to this token. */ ins->p = hit; - ins->peeking = 0; + ins->peeking = false; ins->toktype = 0; (void)json_peek(session, ins); return (0); @@ -563,7 +564,7 @@ util_load_json(WT_SESSION *session, const char *filename, uint32_t flags) memset(&instate, 0, sizeof(instate)); instate.session = session; - if (util_read_line(session, &instate.line, 0, &instate.ateof)) + if (util_read_line(session, &instate.line, false, &instate.ateof)) return (1); instate.p = (const char *)instate.line.mem; instate.linenum = 1; diff --git a/src/third_party/wiredtiger/src/utilities/util_loadtext.c b/src/third_party/wiredtiger/src/utilities/util_loadtext.c index c200198a0a1..c6cd264c423 100644 --- a/src/third_party/wiredtiger/src/utilities/util_loadtext.c +++ b/src/third_party/wiredtiger/src/utilities/util_loadtext.c @@ -8,7 +8,7 @@ #include "util.h" -static int insert(WT_CURSOR *, const char *, int); +static int insert(WT_CURSOR *, const char *, bool); static int text(WT_SESSION *, const char *); static int usage(void); @@ -50,7 +50,8 @@ text(WT_SESSION *session, const char *uri) { WT_CURSOR *cursor; WT_DECL_RET; - int readkey, tret; + int tret; + bool readkey; /* * Open the cursor, configured to append new records (in the case of @@ -74,7 +75,7 @@ text(WT_SESSION *session, const char *uri) return (util_err(session, EINVAL, "the loadtext command can only load objects configured " "for record number or string keys, and string values")); - readkey = strcmp(cursor->key_format, "r") == 0 ? 0 : 1; + readkey = strcmp(cursor->key_format, "r") != 0; /* Insert the records */ ret = insert(cursor, uri, readkey); @@ -100,13 +101,13 @@ text(WT_SESSION *session, const char *uri) * Read and insert data. */ static int -insert(WT_CURSOR *cursor, const char *name, int readkey) +insert(WT_CURSOR *cursor, const char *name, bool readkey) { ULINE key, value; WT_DECL_RET; WT_SESSION *session; uint64_t insert_count; - int eof; + bool eof; session = cursor->session; @@ -122,15 +123,15 @@ insert(WT_CURSOR *cursor, const char *name, int readkey) * all (flat-text load). */ if (readkey) { - if (util_read_line(session, &key, 1, &eof)) + if (util_read_line(session, &key, true, &eof)) return (1); - if (eof == 1) + if (eof) break; cursor->set_key(cursor, key.mem); } - if (util_read_line(session, &value, readkey ? 0 : 1, &eof)) + if (util_read_line(session, &value, !readkey, &eof)) return (1); - if (eof == 1) + if (eof) break; cursor->set_value(cursor, value.mem); diff --git a/src/third_party/wiredtiger/src/utilities/util_main.c b/src/third_party/wiredtiger/src/utilities/util_main.c index 348460e95e0..9cbda08690e 100644 --- a/src/third_party/wiredtiger/src/utilities/util_main.c +++ b/src/third_party/wiredtiger/src/utilities/util_main.c @@ -12,7 +12,7 @@ const char *home = "."; /* Home directory */ const char *progname; /* Program name */ /* Global arguments */ const char *usage_prefix = "[-LRVv] [-C config] [-E secretkey] [-h home]"; -int verbose; /* Verbose flag */ +bool verbose = false; /* Verbose flag */ static const char *command; /* Command name */ @@ -30,7 +30,7 @@ main(int argc, char *argv[]) WT_SESSION *session; size_t len; int ch, major_v, minor_v, tret, (*func)(WT_SESSION *, int, char *[]); - int logoff, recover; + bool logoff, recover; char *p, *secretkey; const char *cmd_config, *config, *p1, *p2, *p3, *rec_config; @@ -66,7 +66,7 @@ main(int argc, char *argv[]) * needed, the user can specify -R to run recovery. */ rec_config = REC_ERROR; - logoff = recover = 0; + logoff = recover = false; /* Check for standard options. */ while ((ch = __wt_getopt(progname, argc, argv, "C:E:h:LRVv")) != EOF) switch (ch) { @@ -85,17 +85,17 @@ main(int argc, char *argv[]) break; case 'L': /* no logging */ rec_config = REC_LOGOFF; - logoff = 1; + logoff = true; break; case 'R': /* recovery */ rec_config = REC_RECOVER; - recover = 1; + recover = true; break; case 'V': /* version */ printf("%s\n", wiredtiger_version(NULL, NULL, NULL)); return (EXIT_SUCCESS); case 'v': /* verbose */ - verbose = 1; + verbose = true; break; case '?': default: diff --git a/src/third_party/wiredtiger/src/utilities/util_misc.c b/src/third_party/wiredtiger/src/utilities/util_misc.c index f14ad7119bd..76cb37b30dc 100644 --- a/src/third_party/wiredtiger/src/utilities/util_misc.c +++ b/src/third_party/wiredtiger/src/utilities/util_misc.c @@ -44,14 +44,14 @@ util_err(WT_SESSION *session, int e, const char *fmt, ...) * Read a line from stdin into a ULINE. */ int -util_read_line(WT_SESSION *session, ULINE *l, int eof_expected, int *eofp) +util_read_line(WT_SESSION *session, ULINE *l, bool eof_expected, bool *eofp) { static uint64_t line = 0; size_t len; int ch; ++line; - *eofp = 0; + *eofp = false; if (l->memsize == 0) { if ((l->mem = realloc(l->mem, l->memsize + 1024)) == NULL) @@ -62,7 +62,7 @@ util_read_line(WT_SESSION *session, ULINE *l, int eof_expected, int *eofp) if ((ch = getchar()) == EOF) { if (len == 0) { if (eof_expected) { - *eofp = 1; + *eofp = true; return (0); } return (util_err(session, 0, diff --git a/src/third_party/wiredtiger/src/utilities/util_printlog.c b/src/third_party/wiredtiger/src/utilities/util_printlog.c index 4ec2d0b7e1c..d202b09b228 100644 --- a/src/third_party/wiredtiger/src/utilities/util_printlog.c +++ b/src/third_party/wiredtiger/src/utilities/util_printlog.c @@ -14,9 +14,10 @@ int util_printlog(WT_SESSION *session, int argc, char *argv[]) { WT_DECL_RET; - int ch, printable; + int ch; + bool printable; - printable = 0; + printable = false; while ((ch = __wt_getopt(progname, argc, argv, "f:p")) != EOF) switch (ch) { case 'f': /* output file */ @@ -27,7 +28,7 @@ util_printlog(WT_SESSION *session, int argc, char *argv[]) } break; case 'p': - printable = 1; + printable = true; break; case '?': default: diff --git a/src/third_party/wiredtiger/src/utilities/util_read.c b/src/third_party/wiredtiger/src/utilities/util_read.c index fe9f5541d6e..a2fcc330c7d 100644 --- a/src/third_party/wiredtiger/src/utilities/util_read.c +++ b/src/third_party/wiredtiger/src/utilities/util_read.c @@ -16,7 +16,8 @@ util_read(WT_SESSION *session, int argc, char *argv[]) WT_CURSOR *cursor; WT_DECL_RET; uint64_t recno; - int ch, rkey, rval; + int ch; + bool rkey, rval; const char *uri, *value; while ((ch = __wt_getopt(progname, argc, argv, "")) != EOF) @@ -51,7 +52,7 @@ util_read(WT_SESSION *session, int argc, char *argv[]) progname); return (1); } - rkey = strcmp(cursor->key_format, "r") == 0 ? 1 : 0; + rkey = strcmp(cursor->key_format, "r") == 0; if (strcmp(cursor->value_format, "S") != 0) { fprintf(stderr, "%s: read command only possible when the value format is " @@ -64,7 +65,7 @@ util_read(WT_SESSION *session, int argc, char *argv[]) * Run through the keys, returning non-zero on error or if any requested * key isn't found. */ - for (rval = 0; *++argv != NULL;) { + for (rval = false; *++argv != NULL;) { if (rkey) { if (util_str2recno(session, *argv, &recno)) return (1); @@ -81,14 +82,14 @@ util_read(WT_SESSION *session, int argc, char *argv[]) break; case WT_NOTFOUND: (void)util_err(session, 0, "%s: not found", *argv); - rval = 1; + rval = true; break; default: return (util_cerr(cursor, "search", ret)); } } - return (rval); + return (rval ? 1 : 0); } static int diff --git a/src/third_party/wiredtiger/src/utilities/util_stat.c b/src/third_party/wiredtiger/src/utilities/util_stat.c index 77c420f8dee..b7558ee3be0 100644 --- a/src/third_party/wiredtiger/src/utilities/util_stat.c +++ b/src/third_party/wiredtiger/src/utilities/util_stat.c @@ -16,11 +16,12 @@ util_stat(WT_SESSION *session, int argc, char *argv[]) WT_CURSOR *cursor; WT_DECL_RET; size_t urilen; - int ch, objname_free; + int ch; + bool objname_free; const char *config, *pval, *desc; char *objname, *uri; - objname_free = 0; + objname_free = false; objname = uri = NULL; config = NULL; while ((ch = __wt_getopt(progname, argc, argv, "af")) != EOF) @@ -56,7 +57,7 @@ util_stat(WT_SESSION *session, int argc, char *argv[]) case 1: if ((objname = util_name(session, *argv, "table")) == NULL) return (1); - objname_free = 1; + objname_free = true; break; default: return (usage()); diff --git a/src/third_party/wiredtiger/src/utilities/util_verify.c b/src/third_party/wiredtiger/src/utilities/util_verify.c index 9d95a6c9022..12f76e9d4ed 100644 --- a/src/third_party/wiredtiger/src/utilities/util_verify.c +++ b/src/third_party/wiredtiger/src/utilities/util_verify.c @@ -15,18 +15,19 @@ util_verify(WT_SESSION *session, int argc, char *argv[]) { WT_DECL_RET; size_t size; - int ch, dump_address, dump_blocks, dump_pages, dump_shape; + int ch; + bool dump_address, dump_blocks, dump_pages, dump_shape; char *config, *dump_offsets, *name; - dump_address = dump_blocks = dump_pages = dump_shape = 0; + dump_address = dump_blocks = dump_pages = dump_shape = false; config = dump_offsets = name = NULL; while ((ch = __wt_getopt(progname, argc, argv, "d:")) != EOF) switch (ch) { case 'd': if (strcmp(__wt_optarg, "dump_address") == 0) - dump_address = 1; + dump_address = true; else if (strcmp(__wt_optarg, "dump_blocks") == 0) - dump_blocks = 1; + dump_blocks = true; else if ( WT_PREFIX_MATCH(__wt_optarg, "dump_offsets=")) { if (dump_offsets != NULL) { @@ -38,9 +39,9 @@ util_verify(WT_SESSION *session, int argc, char *argv[]) dump_offsets = __wt_optarg + strlen("dump_offsets="); } else if (strcmp(__wt_optarg, "dump_pages") == 0) - dump_pages = 1; + dump_pages = true; else if (strcmp(__wt_optarg, "dump_shape") == 0) - dump_shape = 1; + dump_shape = true; else return (usage()); break; diff --git a/src/third_party/wiredtiger/src/utilities/util_write.c b/src/third_party/wiredtiger/src/utilities/util_write.c index e5eafa5ab25..7871040411b 100644 --- a/src/third_party/wiredtiger/src/utilities/util_write.c +++ b/src/third_party/wiredtiger/src/utilities/util_write.c @@ -16,18 +16,19 @@ util_write(WT_SESSION *session, int argc, char *argv[]) WT_CURSOR *cursor; WT_DECL_RET; uint64_t recno; - int append, ch, overwrite, rkey; + int ch; + bool append, overwrite, rkey; const char *uri; char config[100]; - append = overwrite = 0; + append = overwrite = false; while ((ch = __wt_getopt(progname, argc, argv, "ao")) != EOF) switch (ch) { case 'a': - append = 1; + append = true; break; case 'o': - overwrite = 1; + overwrite = true; break; case '?': default: @@ -68,7 +69,7 @@ util_write(WT_SESSION *session, int argc, char *argv[]) progname); return (1); } - rkey = strcmp(cursor->key_format, "r") == 0 ? 1 : 0; + rkey = strcmp(cursor->key_format, "r") == 0; if (strcmp(cursor->value_format, "S") != 0) { fprintf(stderr, "%s: write command only possible when the value format is " -- cgit v1.2.1