diff options
author | Michael Cahill <michael.cahill@mongodb.com> | 2015-09-25 09:47:19 +1000 |
---|---|---|
committer | Michael Cahill <michael.cahill@mongodb.com> | 2015-09-29 16:56:36 +1000 |
commit | 4b6157e191d644603e6c0642aed1e9f07eee596d (patch) | |
tree | a3bc4859b2dac87d4cbc571e8b9fefe2377f49c5 /src/lsm | |
parent | d1dff562e256cf3726f8ec229feced879f212096 (diff) | |
download | mongo-4b6157e191d644603e6c0642aed1e9f07eee596d.tar.gz |
WT-2112 Use bool in more places
Merge pull request #2216 from wiredtiger/more-bool
(cherry picked from commit 53638a10713925406f92d20fa840a94cd2cfa22a)
Diffstat (limited to 'src/lsm')
-rw-r--r-- | src/lsm/lsm_cursor.c | 100 | ||||
-rw-r--r-- | src/lsm/lsm_manager.c | 10 | ||||
-rw-r--r-- | src/lsm/lsm_merge.c | 27 | ||||
-rw-r--r-- | src/lsm/lsm_meta.c | 6 | ||||
-rw-r--r-- | src/lsm/lsm_stat.c | 8 | ||||
-rw-r--r-- | src/lsm/lsm_tree.c | 89 | ||||
-rw-r--r-- | src/lsm/lsm_work_unit.c | 27 | ||||
-rw-r--r-- | src/lsm/lsm_worker.c | 14 |
8 files changed, 142 insertions, 139 deletions
diff --git a/src/lsm/lsm_cursor.c b/src/lsm/lsm_cursor.c index 0f3f6c6105d..9ed5eef6ecc 100644 --- a/src/lsm/lsm_cursor.c +++ b/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 *); /* @@ -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; @@ -295,7 +295,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) && @@ -392,7 +392,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; @@ -405,13 +405,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; /* @@ -445,7 +445,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)) { @@ -562,12 +562,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; } @@ -709,7 +709,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); } @@ -718,15 +718,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)) @@ -738,9 +739,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; @@ -758,7 +759,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); @@ -808,13 +809,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)) { @@ -852,7 +854,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; @@ -864,7 +866,7 @@ retry: /* WT_ERR_NOTFOUND_OK(c->next(c)); } if (c == clsm->current) - check = 1; + check = true; } } @@ -874,7 +876,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; @@ -897,13 +899,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)) { @@ -940,7 +943,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; @@ -952,7 +955,7 @@ retry: /* WT_ERR_NOTFOUND_OK(c->prev(c)); } if (c == clsm->current) - check = 1; + check = true; } } @@ -962,7 +965,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; @@ -1045,11 +1048,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) { @@ -1059,7 +1062,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); @@ -1121,7 +1124,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); @@ -1144,16 +1147,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); /* @@ -1222,7 +1227,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)); @@ -1244,7 +1249,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); @@ -1276,8 +1281,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; @@ -1362,7 +1367,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) { @@ -1372,7 +1377,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); @@ -1398,13 +1403,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); @@ -1430,11 +1435,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); @@ -1505,9 +1511,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; @@ -1521,8 +1526,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/lsm/lsm_manager.c b/src/lsm/lsm_manager.c index 2309b55670f..14377f10125 100644 --- a/src/lsm/lsm_manager.c +++ b/src/lsm/lsm_manager.c @@ -226,7 +226,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; } @@ -408,10 +408,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); @@ -419,7 +419,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; @@ -479,7 +479,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) { diff --git a/src/lsm/lsm_merge.c b/src/lsm/lsm_merge.c index de7ea37e498..76caf4318fa 100644 --- a/src/lsm/lsm_merge.c +++ b/src/lsm/lsm_merge.c @@ -239,21 +239,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, 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 && @@ -266,7 +263,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)); @@ -281,7 +278,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); @@ -304,13 +301,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: @@ -376,7 +373,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 @@ -427,12 +424,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 @@ -473,7 +470,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/lsm/lsm_meta.c b/src/lsm/lsm_meta.c index e4c95125428..64ca283e2c8 100644 --- a/src/lsm/lsm_meta.c +++ b/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/lsm/lsm_stat.c b/src/lsm/lsm_stat.c index b704226b345..086860fc73a 100644 --- a/src/lsm/lsm_stat.c +++ b/src/lsm/lsm_stat.c @@ -23,7 +23,7 @@ __curstat_lsm_init( WT_LSM_CHUNK *chunk; WT_LSM_TREE *lsm_tree; u_int i; - int locked; + bool locked; char config[64]; const char *cfg[] = { WT_CONFIG_BASE(session, session_open_cursor), NULL, NULL }; @@ -31,9 +31,9 @@ __curstat_lsm_init( WT_CONFIG_BASE(session, 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)); @@ -58,7 +58,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; /* Initialize the statistics. */ __wt_stat_init_dsrc_stats(stats); diff --git a/src/lsm/lsm_tree.c b/src/lsm/lsm_tree.c index a5709ac97ad..0680d98bdde 100644 --- a/src/lsm/lsm_tree.c +++ b/src/lsm/lsm_tree.c @@ -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; @@ -136,7 +136,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); @@ -297,7 +297,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); @@ -309,7 +309,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); @@ -421,7 +421,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; /* @@ -436,7 +436,7 @@ __wt_lsm_tree_create(WT_SESSION_IMPL *session, __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); @@ -451,7 +451,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; @@ -586,7 +586,7 @@ __lsm_tree_open(WT_SESSION_IMPL *session, * with getting handles exclusive. */ lsm_tree->refcnt = 1; - lsm_tree->exclusive = exclusive; + lsm_tree->exclusive = exclusive ? 1 : 0; lsm_tree->queue_ref = 0; /* Set a flush timestamp as a baseline. */ @@ -599,7 +599,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); } @@ -610,7 +610,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; @@ -620,7 +620,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); } @@ -664,7 +665,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; @@ -827,7 +828,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); @@ -936,13 +937,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. */ @@ -950,7 +951,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++) { @@ -971,14 +972,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); } @@ -995,14 +996,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. */ @@ -1010,7 +1011,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)); @@ -1039,7 +1040,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)); @@ -1052,7 +1053,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); } @@ -1067,15 +1068,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. */ @@ -1083,7 +1084,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)); @@ -1096,7 +1097,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); @@ -1114,7 +1115,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); } @@ -1198,9 +1199,9 @@ __wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, bool *skipp) 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 @@ -1213,7 +1214,7 @@ __wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, bool *skipp) *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)) @@ -1237,7 +1238,7 @@ __wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, bool *skipp) /* 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; @@ -1262,10 +1263,10 @@ __wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, bool *skipp) * 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) { @@ -1273,7 +1274,7 @@ __wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, bool *skipp) "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 @@ -1286,7 +1287,7 @@ __wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, bool *skipp) * 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, @@ -1310,8 +1311,8 @@ __wt_lsm_compact(WT_SESSION_IMPL *session, const char *name, bool *skipp) 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 { @@ -1394,9 +1395,9 @@ __wt_lsm_tree_worker(WT_SESSION_IMPL *session, WT_LSM_CHUNK *chunk; WT_LSM_TREE *lsm_tree; u_int i; - int exclusive, locked; + bool exclusive, locked; - locked = 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)); @@ -1410,7 +1411,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/lsm/lsm_work_unit.c b/src/lsm/lsm_work_unit.c index 08c02467517..72c6cfb9d79 100644 --- a/src/lsm/lsm_work_unit.c +++ b/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; @@ -281,7 +281,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, @@ -337,7 +337,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) @@ -530,9 +530,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); @@ -554,7 +555,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); @@ -591,7 +592,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) { @@ -601,7 +602,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/lsm/lsm_worker.c b/src/lsm/lsm_worker.c index 6346791f905..fcf35261604 100644 --- a/src/lsm/lsm_worker.c +++ b/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; 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); |