From a6c348aa16ee8676026be979fbf0a5c080c1a503 Mon Sep 17 00:00:00 2001 From: Dan Pasette Date: Thu, 12 Feb 2015 07:39:45 -0500 Subject: Import wiredtiger-wiredtiger-mongodb-3.0-rc9-1-g8eecf94.tar.gz from wiredtiger branch mongodb-3.0 --- src/third_party/wiredtiger/src/block/block_open.c | 12 +++- src/third_party/wiredtiger/src/btree/bt_split.c | 8 +-- src/third_party/wiredtiger/src/conn/conn_ckpt.c | 16 +++--- src/third_party/wiredtiger/src/conn/conn_stat.c | 6 +- src/third_party/wiredtiger/src/conn/conn_sweep.c | 1 - src/third_party/wiredtiger/src/cursor/cur_stat.c | 66 +--------------------- src/third_party/wiredtiger/src/include/cursor.i | 6 +- src/third_party/wiredtiger/src/include/mutex.i | 5 +- src/third_party/wiredtiger/src/lsm/lsm_cursor.c | 24 ++++---- src/third_party/wiredtiger/src/lsm/lsm_work_unit.c | 10 ++-- src/third_party/wiredtiger/src/meta/meta_turtle.c | 8 +-- 11 files changed, 45 insertions(+), 117 deletions(-) (limited to 'src/third_party/wiredtiger/src') diff --git a/src/third_party/wiredtiger/src/block/block_open.c b/src/third_party/wiredtiger/src/block/block_open.c index 2429e1c641c..5c824b59ec9 100644 --- a/src/third_party/wiredtiger/src/block/block_open.c +++ b/src/third_party/wiredtiger/src/block/block_open.c @@ -28,7 +28,13 @@ __wt_block_manager_truncate( WT_ERR(__wt_ftruncate(session, fh, (wt_off_t)0)); /* Write out the file's meta-data. */ - ret = __wt_desc_init(session, fh, allocsize); + WT_ERR(__wt_desc_init(session, fh, allocsize)); + + /* + * Ensure the truncated file has made it to disk, then the upper-level + * is never surprised. + */ + WT_ERR(__wt_fsync(session, fh)); /* Close the file handle. */ err: WT_TRET(__wt_close(session, fh)); @@ -55,8 +61,8 @@ __wt_block_manager_create( ret = __wt_desc_init(session, fh, allocsize); /* - * Ensure the new file has made it to disk. Otherwise a crash - * after log records exist for the file can lead to a recovery failure. + * Ensure the truncated file has made it to disk, then the upper-level + * is never surprised. */ WT_TRET(__wt_fsync(session, fh)); diff --git a/src/third_party/wiredtiger/src/btree/bt_split.c b/src/third_party/wiredtiger/src/btree/bt_split.c index a7dfdf8d998..6ebd4609efa 100644 --- a/src/third_party/wiredtiger/src/btree/bt_split.c +++ b/src/third_party/wiredtiger/src/btree/bt_split.c @@ -799,12 +799,12 @@ __split_parent(WT_SESSION_IMPL *session, WT_REF *ref, WT_REF **ref_new, uint64_t split_gen; uint32_t children, i, j; uint32_t deleted_entries, parent_entries, result_entries; - int complete, hazard, locked; + int complete, hazard; parent = NULL; /* -Wconditional-uninitialized */ alloc_index = pindex = NULL; parent_ref = NULL; - complete = hazard = locked = 0; + complete = hazard = 0; parent_entries = 0; /* @@ -830,7 +830,6 @@ __split_parent(WT_SESSION_IMPL *session, WT_REF *ref, WT_REF **ref_new, } __wt_yield(); } - locked = 1; /* * We have exclusive access to split the parent, and at this point, the @@ -1044,8 +1043,7 @@ err: if (!complete) if (next_ref->state == WT_REF_SPLIT) next_ref->state = WT_REF_DELETED; } - if (locked) - F_CLR_ATOMIC(parent, WT_PAGE_SPLITTING); + F_CLR_ATOMIC(parent, WT_PAGE_SPLITTING); if (hazard) WT_TRET(__wt_hazard_clear(session, parent)); diff --git a/src/third_party/wiredtiger/src/conn/conn_ckpt.c b/src/third_party/wiredtiger/src/conn/conn_ckpt.c index f38628617dd..6eb134c1765 100644 --- a/src/third_party/wiredtiger/src/conn/conn_ckpt.c +++ b/src/third_party/wiredtiger/src/conn/conn_ckpt.c @@ -83,6 +83,14 @@ __ckpt_server(void *arg) while (F_ISSET(conn, WT_CONN_SERVER_RUN) && F_ISSET(conn, WT_CONN_SERVER_CHECKPOINT)) { + /* + * Wait... + * NOTE: If the user only configured logsize, then usecs + * will be 0 and this wait won't return until signalled. + */ + WT_ERR( + __wt_cond_wait(session, conn->ckpt_cond, conn->ckpt_usecs)); + /* Checkpoint the database. */ WT_ERR(wt_session->checkpoint(wt_session, conn->ckpt_config)); @@ -99,14 +107,6 @@ __ckpt_server(void *arg) */ WT_ERR(__wt_cond_wait(session, conn->ckpt_cond, 1)); } - - /* - * Wait... - * NOTE: If the user only configured logsize, then usecs - * will be 0 and this wait won't return until signalled. - */ - WT_ERR( - __wt_cond_wait(session, conn->ckpt_cond, conn->ckpt_usecs)); } if (0) { diff --git a/src/third_party/wiredtiger/src/conn/conn_stat.c b/src/third_party/wiredtiger/src/conn/conn_stat.c index 2d8395c0517..be2172ea8d8 100644 --- a/src/third_party/wiredtiger/src/conn/conn_stat.c +++ b/src/third_party/wiredtiger/src/conn/conn_stat.c @@ -406,12 +406,12 @@ __statlog_server(void *arg) while (F_ISSET(conn, WT_CONN_SERVER_RUN) && F_ISSET(conn, WT_CONN_SERVER_STATISTICS)) { - if (!FLD_ISSET(conn->stat_flags, WT_CONN_STAT_NONE)) - WT_ERR(__statlog_log_one(session, &path, &tmp)); - /* Wait until the next event. */ WT_ERR( __wt_cond_wait(session, conn->stat_cond, conn->stat_usecs)); + + if (!FLD_ISSET(conn->stat_flags, WT_CONN_STAT_NONE)) + WT_ERR(__statlog_log_one(session, &path, &tmp)); } if (0) { diff --git a/src/third_party/wiredtiger/src/conn/conn_sweep.c b/src/third_party/wiredtiger/src/conn/conn_sweep.c index a5bd8e1343c..5145583fc7d 100644 --- a/src/third_party/wiredtiger/src/conn/conn_sweep.c +++ b/src/third_party/wiredtiger/src/conn/conn_sweep.c @@ -118,7 +118,6 @@ __sweep_server(void *arg) */ while (F_ISSET(conn, WT_CONN_SERVER_RUN) && F_ISSET(conn, WT_CONN_SERVER_SWEEP)) { - /* Wait until the next event. */ WT_ERR(__wt_cond_wait(session, conn->sweep_cond, WT_DHANDLE_SWEEP_PERIOD * WT_MILLION)); diff --git a/src/third_party/wiredtiger/src/cursor/cur_stat.c b/src/third_party/wiredtiger/src/cursor/cur_stat.c index e3364ad8009..bebce217a6a 100644 --- a/src/third_party/wiredtiger/src/cursor/cur_stat.c +++ b/src/third_party/wiredtiger/src/cursor/cur_stat.c @@ -327,42 +327,6 @@ __curstat_conn_init(WT_SESSION_IMPL *session, WT_CURSOR_STAT *cst) cst->stats_count = sizeof(WT_CONNECTION_STATS) / sizeof(WT_STATS); } -/* - * When returning the statistics for a file URI, we review open handles, and - * aggregate checkpoint handle statistics with the file URI statistics. To - * make that work, we have to pass information to the function reviewing the - * handles, this structure is what we pass. - */ -struct __checkpoint_args { - const char *name; /* Data source handle name */ - WT_DSRC_STATS *stats; /* Stat structure being filled */ - int clear; /* WT_STATISTICS_CLEAR */ -}; - -/* - * __curstat_checkpoint -- - * Aggregate statistics from checkpoint handles. - */ -static int -__curstat_checkpoint(WT_SESSION_IMPL *session, const char *cfg[]) -{ - struct __checkpoint_args *args; - WT_DATA_HANDLE *dhandle; - - dhandle = session->dhandle; - args = (struct __checkpoint_args *)cfg[0]; - - /* Aggregate the flagged file's checkpoint handles. */ - if (dhandle->checkpoint != NULL && - strcmp(dhandle->name, args->name) == 0) { - __wt_stat_aggregate_dsrc_stats(&dhandle->stats, args->stats); - if (args->clear) - __wt_stat_refresh_dsrc_stats(&dhandle->stats); - } - - return (0); -} - /* * __curstat_file_init -- * Initialize the statistics for a file. @@ -371,10 +335,8 @@ static int __curstat_file_init(WT_SESSION_IMPL *session, const char *uri, const char *cfg[], WT_CURSOR_STAT *cst) { - struct __checkpoint_args args; - WT_DATA_HANDLE *dhandle, *saved_dhandle; + WT_DATA_HANDLE *dhandle; WT_DECL_RET; - const char *cfg_arg[] = { NULL, NULL }; WT_RET(__wt_session_get_btree_ckpt(session, uri, cfg, 0)); dhandle = session->dhandle; @@ -394,32 +356,6 @@ __curstat_file_init(WT_SESSION_IMPL *session, WT_TRET(__wt_session_release_btree(session)); WT_RET(ret); - /* - * If no checkpoint was specified, review the open handles and aggregate - * the statistics from any checkpoint handles matching this file. - */ - if (dhandle->checkpoint == NULL) { - args.name = dhandle->name; - args.stats = &cst->u.dsrc_stats; - args.clear = F_ISSET(cst, WT_CONN_STAT_CLEAR); - cfg_arg[0] = (char *)&args; - - /* - * We're likely holding the handle lock inside the statistics - * logging thread, not to mention calling __wt_conn_btree_apply - * from there as well. Save/restore the handle. - * Take the schema lock now, in case btree apply needs to - * get it later - that would violate lock ordering - * conventions and can lead to deadlocks. - */ - saved_dhandle = dhandle; - WT_WITH_SCHEMA_LOCK(session, - WT_WITH_DHANDLE_LOCK(session, - ret = __wt_conn_btree_apply(session, - 1, dhandle->name, __curstat_checkpoint, cfg_arg))); - session->dhandle = saved_dhandle; - } - return (ret); } diff --git a/src/third_party/wiredtiger/src/include/cursor.i b/src/third_party/wiredtiger/src/include/cursor.i index ad42f989bf4..f6a5fc8d8a9 100644 --- a/src/third_party/wiredtiger/src/include/cursor.i +++ b/src/third_party/wiredtiger/src/include/cursor.i @@ -69,7 +69,7 @@ __cursor_enter(WT_SESSION_IMPL *session) * __cursor_leave -- * Deactivate a cursor. */ -static inline int +static inline void __cursor_leave(WT_SESSION_IMPL *session) { /* @@ -80,8 +80,6 @@ __cursor_leave(WT_SESSION_IMPL *session) WT_ASSERT(session, session->ncursors > 0); if (--session->ncursors == 0) __wt_txn_read_last(session); - - return (0); } /* @@ -113,7 +111,7 @@ __curfile_leave(WT_CURSOR_BTREE *cbt) /* If the cursor was active, deactivate it. */ if (F_ISSET(cbt, WT_CBT_ACTIVE)) { - WT_RET(__cursor_leave(session)); + __cursor_leave(session); F_CLR(cbt, WT_CBT_ACTIVE); } diff --git a/src/third_party/wiredtiger/src/include/mutex.i b/src/third_party/wiredtiger/src/include/mutex.i index 03450322616..e4b497af2a7 100644 --- a/src/third_party/wiredtiger/src/include/mutex.i +++ b/src/third_party/wiredtiger/src/include/mutex.i @@ -172,9 +172,8 @@ __wt_spin_lock(WT_SESSION_IMPL *session, WT_SPINLOCK *t) { WT_UNUSED(session); - pthread_mutex_lock(&t->lock); + (void)pthread_mutex_lock(&t->lock); } - #endif #if SPINLOCK_TYPE == SPINLOCK_PTHREAD_MUTEX_LOGGING @@ -286,7 +285,7 @@ __wt_spin_unlock(WT_SESSION_IMPL *session, WT_SPINLOCK *t) { WT_UNUSED(session); - pthread_mutex_unlock(&t->lock); + (void)pthread_mutex_unlock(&t->lock); } #elif SPINLOCK_TYPE == SPINLOCK_MSVC diff --git a/src/third_party/wiredtiger/src/lsm/lsm_cursor.c b/src/third_party/wiredtiger/src/lsm/lsm_cursor.c index 05dbd04858e..3b4dc639945 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_cursor.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_cursor.c @@ -248,7 +248,7 @@ open: WT_WITH_SCHEMA_LOCK(session, * __clsm_leave -- * Finish an operation on an LSM cursor. */ -static int +static void __clsm_leave(WT_CURSOR_LSM *clsm) { WT_SESSION_IMPL *session; @@ -256,11 +256,9 @@ __clsm_leave(WT_CURSOR_LSM *clsm) session = (WT_SESSION_IMPL *)clsm->iface.session; if (F_ISSET(clsm, WT_CLSM_ACTIVE)) { - WT_RET(__cursor_leave(session)); + __cursor_leave(session); F_CLR(clsm, WT_CLSM_ACTIVE); } - - return (0); } /* @@ -848,7 +846,7 @@ retry: /* deleted) goto retry; -err: WT_TRET(__clsm_leave(clsm)); +err: __clsm_leave(clsm); API_END(session, ret); if (ret == 0) __clsm_deleted_decode(clsm, &cursor->value); @@ -936,7 +934,7 @@ retry: /* deleted) goto retry; -err: WT_TRET(__clsm_leave(clsm)); +err: __clsm_leave(clsm); API_END(session, ret); if (ret == 0) __clsm_deleted_decode(clsm, &cursor->value); @@ -997,7 +995,7 @@ __clsm_reset(WT_CURSOR *cursor) WT_TRET(__clsm_reset_cursors(clsm, NULL)); /* In case we were left positioned, clear that. */ - WT_TRET(__clsm_leave(clsm)); + __clsm_leave(clsm); err: API_END_RET(session, ret); } @@ -1095,7 +1093,7 @@ __clsm_search(WT_CURSOR *cursor) ret = __clsm_lookup(clsm, &cursor->value); -err: WT_TRET(__clsm_leave(clsm)); +err: __clsm_leave(clsm); API_END(session, ret); if (ret == 0) __clsm_deleted_decode(clsm, &cursor->value); @@ -1214,7 +1212,7 @@ __clsm_search_near(WT_CURSOR *cursor, int *exactp) } *exactp = cmp; -err: WT_TRET(__clsm_leave(clsm)); +err: __clsm_leave(clsm); API_END(session, ret); if (closest != NULL) WT_TRET(closest->reset(closest)); @@ -1325,7 +1323,7 @@ __clsm_insert(WT_CURSOR *cursor) ret = __clsm_put(session, clsm, &cursor->key, &value, 0); err: __wt_scr_free(session, &buf); - WT_TRET(__clsm_leave(clsm)); + __clsm_leave(clsm); CURSOR_UPDATE_API_END(session, ret); return (ret); } @@ -1358,7 +1356,7 @@ __clsm_update(WT_CURSOR *cursor) } err: __wt_scr_free(session, &buf); - WT_TRET(__clsm_leave(clsm)); + __clsm_leave(clsm); CURSOR_UPDATE_API_END(session, ret); return (ret); } @@ -1386,7 +1384,7 @@ __clsm_remove(WT_CURSOR *cursor) (ret = __clsm_lookup(clsm, &value)) == 0) ret = __clsm_put(session, clsm, &cursor->key, &__tombstone, 1); -err: WT_TRET(__clsm_leave(clsm)); +err: __clsm_leave(clsm); CURSOR_UPDATE_API_END(session, ret); return (ret); } @@ -1414,7 +1412,7 @@ __clsm_close(WT_CURSOR *cursor) __wt_free(session, clsm->switch_txn); /* In case we were somehow left positioned, clear that. */ - WT_TRET(__clsm_leave(clsm)); + __clsm_leave(clsm); /* The WT_LSM_TREE owns the URI. */ cursor->uri = NULL; 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 2e87dd539db..f4ddd4f7e2f 100644 --- a/src/third_party/wiredtiger/src/lsm/lsm_work_unit.c +++ b/src/third_party/wiredtiger/src/lsm/lsm_work_unit.c @@ -79,8 +79,7 @@ __wt_lsm_get_chunk_to_flush(WT_SESSION_IMPL *session, WT_ASSERT(session, lsm_tree->queue_ref > 0); WT_RET(__wt_lsm_tree_readlock(session, lsm_tree)); - if (!F_ISSET(lsm_tree, WT_LSM_TREE_ACTIVE) || - lsm_tree->nchunks == 0) + if (!F_ISSET(lsm_tree, WT_LSM_TREE_ACTIVE) || lsm_tree->nchunks == 0) return (__wt_lsm_tree_readunlock(session, lsm_tree)); /* Search for a chunk to evict and/or a chunk to flush. */ @@ -118,16 +117,15 @@ __wt_lsm_get_chunk_to_flush(WT_SESSION_IMPL *session, chunk = (evict_chunk != NULL) ? evict_chunk : flush_chunk; if (chunk != NULL) { - (void)WT_ATOMIC_ADD4(chunk->refcnt, 1); WT_ERR(__wt_verbose(session, WT_VERB_LSM, "Flush%s: return chunk %u of %u: %s", force ? " w/ force" : "", i, lsm_tree->nchunks, chunk->uri)); + + (void)WT_ATOMIC_ADD4(chunk->refcnt, 1); } -err: if (ret != 0 && chunk != NULL) - (void)WT_ATOMIC_SUB4(chunk->refcnt, 1); - WT_RET(__wt_lsm_tree_readunlock(session, lsm_tree)); +err: WT_RET(__wt_lsm_tree_readunlock(session, lsm_tree)); *chunkp = chunk; return (ret); diff --git a/src/third_party/wiredtiger/src/meta/meta_turtle.c b/src/third_party/wiredtiger/src/meta/meta_turtle.c index 9e0af69366e..5983fb12e38 100644 --- a/src/third_party/wiredtiger/src/meta/meta_turtle.c +++ b/src/third_party/wiredtiger/src/meta/meta_turtle.c @@ -74,7 +74,6 @@ __metadata_load_hot_backup(WT_SESSION_IMPL *session) WT_DECL_RET; char *path; - fp = NULL; path = NULL; /* Look for a hot backup file: if we find it, load it. */ @@ -99,8 +98,7 @@ __metadata_load_hot_backup(WT_SESSION_IMPL *session) F_SET(S2C(session), WT_CONN_WAS_BACKUP); -err: if (fp != NULL) - WT_TRET(fclose(fp) == 0 ? 0 : __wt_errno()); +err: WT_TRET(fclose(fp) == 0 ? 0 : __wt_errno()); __wt_scr_free(session, &key); __wt_scr_free(session, &value); return (ret); @@ -237,7 +235,6 @@ __wt_turtle_read(WT_SESSION_IMPL *session, const char *key, char **valuep) *valuep = NULL; - fp = NULL; path = NULL; /* @@ -274,8 +271,7 @@ __wt_turtle_read(WT_SESSION_IMPL *session, const char *key, char **valuep) /* Copy the value for the caller. */ WT_ERR(__wt_strdup(session, buf->data, valuep)); -err: if (fp != NULL) - WT_TRET(fclose(fp) == 0 ? 0 : __wt_errno()); +err: WT_TRET(fclose(fp) == 0 ? 0 : __wt_errno()); __wt_scr_free(session, &buf); return (ret); } -- cgit v1.2.1