summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Bostic <keith@wiredtiger.com>2014-10-21 08:19:17 -0400
committerKeith Bostic <keith@wiredtiger.com>2014-10-21 08:19:17 -0400
commit18800e7fc41a60ae247dc6049cd02332fd26b830 (patch)
treef576ea57bab46eb53c21fcf09f1981213ca9e5be
parent3788fb71a021b3aca42162ecece6784b73eaf0c6 (diff)
downloadmongo-18800e7fc41a60ae247dc6049cd02332fd26b830.tar.gz
Don't separate the code to mark the root page dirty and subsequently
mark the tree clean with a call into the logging code, it's confusing. Merge __wt_cache_force_write() into the checkpoint-worker code (it's only called in one place and it's 2 lines of code).
-rw-r--r--src/btree/bt_sync.c20
-rw-r--r--src/include/extern.h1
-rw-r--r--src/txn/txn_ckpt.c31
3 files changed, 15 insertions, 37 deletions
diff --git a/src/btree/bt_sync.c b/src/btree/bt_sync.c
index 1673c2be233..7d1ad4c6c03 100644
--- a/src/btree/bt_sync.c
+++ b/src/btree/bt_sync.c
@@ -313,26 +313,6 @@ err: /* On error, clear any left-over tree walk. */
}
/*
- * __wt_cache_force_write --
- * Dirty the root page of the tree so it gets written.
- */
-int
-__wt_cache_force_write(WT_SESSION_IMPL *session)
-{
- WT_BTREE *btree;
- WT_PAGE *page;
-
- btree = S2BT(session);
- page = btree->root.page;
-
- /* Dirty the root page to ensure a write. */
- WT_RET(__wt_page_modify_init(session, page));
- __wt_page_modify_set(session, page);
-
- return (0);
-}
-
-/*
* __wt_cache_op --
* Cache operations.
*/
diff --git a/src/include/extern.h b/src/include/extern.h
index 27389c552ec..e460fed4385 100644
--- a/src/include/extern.h
+++ b/src/include/extern.h
@@ -155,7 +155,6 @@ extern int __wt_cache_read(WT_SESSION_IMPL *session, WT_REF *ref);
extern int __wt_kv_return(WT_SESSION_IMPL *session, WT_CURSOR_BTREE *cbt, WT_UPDATE *upd);
extern int __wt_bt_salvage(WT_SESSION_IMPL *session, WT_CKPT *ckptbase, const char *cfg[]);
extern int __wt_btree_stat_init(WT_SESSION_IMPL *session, WT_CURSOR_STAT *cst);
-extern int __wt_cache_force_write(WT_SESSION_IMPL *session);
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[]);
diff --git a/src/txn/txn_ckpt.c b/src/txn/txn_ckpt.c
index aa2e0839b40..4603a6ebfca 100644
--- a/src/txn/txn_ckpt.c
+++ b/src/txn/txn_ckpt.c
@@ -806,23 +806,17 @@ __checkpoint_worker(
}
/*
- * Mark the root page dirty to ensure something gets written.
- *
- * Don't test the tree modify flag first: if the tree is modified,
- * we must write the root page anyway, we're not adding additional
- * writes to the process. If the tree is not modified, we have to
- * dirty the root page to ensure something gets written. This is
- * really about paranoia: if the tree modification value gets out of
- * sync with the set of dirty pages (modify is set, but there are no
- * dirty pages), we do a checkpoint without any writes, no checkpoint
- * is created, and then things get bad.
+ * Mark the root page dirty to ensure something gets written. (If the
+ * tree is modified, we must write the root page anyway, this doesn't
+ * add additional writes to the process. If the tree is not modified,
+ * we have to dirty the root page to ensure something gets written.)
+ * This is really about paranoia: if the tree modification value gets
+ * out of sync with the set of dirty pages (modify is set, but there
+ * are no dirty pages), we perform a checkpoint without any writes, no
+ * checkpoint is created, and then things get bad.
*/
- WT_ERR(__wt_cache_force_write(session));
-
- /* Tell logging that a file checkpoint is starting. */
- if (conn->logging)
- WT_ERR(__wt_txn_checkpoint_log(
- session, 0, WT_TXN_LOG_CKPT_START, &ckptlsn));
+ WT_ERR(__wt_page_modify_init(session, btree->root.page));
+ __wt_page_modify_set(session, btree->root.page);
/*
* Clear the tree's modified flag; any changes before we clear the flag
@@ -837,6 +831,11 @@ __checkpoint_worker(
btree->modified = 0;
WT_FULL_BARRIER();
+ /* Tell logging that a file checkpoint is starting. */
+ if (conn->logging)
+ WT_ERR(__wt_txn_checkpoint_log(
+ session, 0, WT_TXN_LOG_CKPT_START, &ckptlsn));
+
/* Flush the file from the cache, creating the checkpoint. */
if (is_checkpoint)
WT_ERR(__wt_cache_op(session, ckptbase, WT_SYNC_CHECKPOINT));