summaryrefslogtreecommitdiff
path: root/src/btree/bt_compact.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/btree/bt_compact.c')
-rw-r--r--src/btree/bt_compact.c35
1 files changed, 5 insertions, 30 deletions
diff --git a/src/btree/bt_compact.c b/src/btree/bt_compact.c
index 18f8ca54601..79a52dbcaa3 100644
--- a/src/btree/bt_compact.c
+++ b/src/btree/bt_compact.c
@@ -53,12 +53,12 @@ __compact_rewrite(WT_SESSION_IMPL *session, WT_REF *ref, int *skipp)
} else if (F_ISSET(mod, WT_PM_REC_MASK) == WT_PM_REC_REPLACE) {
/*
* The page's modification information can change underfoot if
- * the page is being reconciled, lock the page down.
+ * the page is being reconciled, serialize with reconciliation.
*/
- WT_PAGE_LOCK(session, page);
+ F_CAS_ATOMIC_WAIT(page, WT_PAGE_RECONCILIATION);
ret = bm->compact_page_skip(bm, session,
mod->mod_replace.addr, mod->mod_replace.size, skipp);
- WT_PAGE_UNLOCK(session, page);
+ F_CLR_ATOMIC(page, WT_PAGE_RECONCILIATION);
WT_RET(ret);
}
return (0);
@@ -73,14 +73,12 @@ __wt_compact(WT_SESSION_IMPL *session, const char *cfg[])
{
WT_BM *bm;
WT_BTREE *btree;
- WT_CONNECTION_IMPL *conn;
WT_DECL_RET;
WT_REF *ref;
- int block_manager_begin, evict_reset, skip;
+ int block_manager_begin, skip;
WT_UNUSED(cfg);
- conn = S2C(session);
btree = S2BT(session);
bm = btree->bm;
ref = NULL;
@@ -118,25 +116,6 @@ __wt_compact(WT_SESSION_IMPL *session, const char *cfg[])
*/
__wt_spin_lock(session, &btree->flush_lock);
- /*
- * That leaves eviction, we don't want to block eviction. Set a flag
- * so reconciliation knows compaction is running. If reconciliation
- * sees the flag it locks the page it's writing, we acquire the same
- * lock when reading the page's modify information, serializing access.
- * The same page lock blocks work on the page, but compaction is an
- * uncommon, heavy-weight operation. If it's ever a problem, there's
- * no reason we couldn't use an entirely separate lock than the page
- * lock.
- *
- * We also need to ensure we don't race with an on-going reconciliation.
- * After we set the flag, wait for eviction of this file to drain, and
- * then let eviction continue;
- */
- conn->compact_in_memory_pass = 1;
- WT_ERR(__wt_evict_file_exclusive_on(session, &evict_reset));
- if (evict_reset)
- __wt_evict_file_exclusive_off(session);
-
/* Start compaction. */
WT_ERR(bm->compact_start(bm, session));
block_manager_begin = 1;
@@ -172,11 +151,7 @@ err: if (ref != NULL)
if (block_manager_begin)
WT_TRET(bm->compact_end(bm, session));
- /*
- * Unlock will be a release barrier, use it to update the compaction
- * status for reconciliation.
- */
- conn->compact_in_memory_pass = 0;
+ /* Unblock threads writing leaf pages. */
__wt_spin_unlock(session, &btree->flush_lock);
return (ret);