diff options
author | Michael Cahill <michael.cahill@mongodb.com> | 2015-02-24 12:45:37 +1100 |
---|---|---|
committer | Michael Cahill <michael.cahill@mongodb.com> | 2015-02-24 12:45:37 +1100 |
commit | 9721cd8c9fb88ecd1415c1021176859aba2c9949 (patch) | |
tree | b726feaba2f015773a482f4f4a9ce15a6109f8bc | |
parent | fbbfad63c007187a07fcd2d14eabf63e41893d59 (diff) | |
parent | 5839549ac1647a4173ce5adc0e044f16da63a000 (diff) | |
download | mongo-9721cd8c9fb88ecd1415c1021176859aba2c9949.tar.gz |
Merge pull request #1692 from wiredtiger/no-eviction-flag-test
Clean up a couple of hard corners.
-rw-r--r-- | src/btree/bt_compact.c | 7 | ||||
-rw-r--r-- | src/btree/bt_sync.c | 7 | ||||
-rw-r--r-- | src/evict/evict_file.c | 11 | ||||
-rw-r--r-- | src/evict/evict_lru.c | 11 | ||||
-rw-r--r-- | src/include/extern.h | 2 |
5 files changed, 22 insertions, 16 deletions
diff --git a/src/btree/bt_compact.c b/src/btree/bt_compact.c index d8b3a638de3..1528d65b8c8 100644 --- a/src/btree/bt_compact.c +++ b/src/btree/bt_compact.c @@ -76,7 +76,7 @@ __wt_compact(WT_SESSION_IMPL *session, const char *cfg[]) WT_CONNECTION_IMPL *conn; WT_DECL_RET; WT_REF *ref; - int block_manager_begin, skip; + int block_manager_begin, evict_reset, skip; WT_UNUSED(cfg); @@ -133,8 +133,9 @@ __wt_compact(WT_SESSION_IMPL *session, const char *cfg[]) * then let eviction continue; */ conn->compact_in_memory_pass = 1; - WT_ERR(__wt_evict_file_exclusive_on(session)); - __wt_evict_file_exclusive_off(session); + 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)); diff --git a/src/btree/bt_sync.c b/src/btree/bt_sync.c index a75af03d8c8..d925eefc2fe 100644 --- a/src/btree/bt_sync.c +++ b/src/btree/bt_sync.c @@ -25,6 +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; btree = S2BT(session); @@ -99,11 +100,11 @@ __sync_file(WT_SESSION_IMPL *session, int syncop) * eviction to complete. */ btree->checkpointing = 1; + WT_FULL_BARRIER(); - if (!F_ISSET(btree, WT_BTREE_NO_EVICTION)) { - WT_ERR(__wt_evict_file_exclusive_on(session)); + WT_ERR(__wt_evict_file_exclusive_on(session, &evict_reset)); + if (evict_reset) __wt_evict_file_exclusive_off(session); - } /* Write all dirty in-cache pages. */ flags |= WT_READ_NO_EVICT; diff --git a/src/evict/evict_file.c b/src/evict/evict_file.c index 910aef070ca..9e39fcc7a2c 100644 --- a/src/evict/evict_file.c +++ b/src/evict/evict_file.c @@ -15,21 +15,16 @@ int __wt_evict_file(WT_SESSION_IMPL *session, int syncop) { - WT_BTREE *btree; WT_DECL_RET; WT_PAGE *page; WT_REF *next_ref, *ref; - int eviction_enabled; - - btree = S2BT(session); - eviction_enabled = !F_ISSET(btree, WT_BTREE_NO_EVICTION); + int evict_reset; /* * We need exclusive access to the file -- disable ordinary eviction * and drain any blocks already queued. */ - if (eviction_enabled) - WT_RET(__wt_evict_file_exclusive_on(session)); + 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); @@ -140,7 +135,7 @@ err: /* On error, clear any left-over tree walk. */ session, next_ref, WT_READ_NO_EVICT)); } - if (eviction_enabled) + if (evict_reset) __wt_evict_file_exclusive_off(session); return (ret); diff --git a/src/evict/evict_lru.c b/src/evict/evict_lru.c index 83a9aa5c8c5..47fe5bb4794 100644 --- a/src/evict/evict_lru.c +++ b/src/evict/evict_lru.c @@ -653,7 +653,7 @@ __wt_evict_page(WT_SESSION_IMPL *session, WT_REF *ref) * blocks queued for eviction. */ int -__wt_evict_file_exclusive_on(WT_SESSION_IMPL *session) +__wt_evict_file_exclusive_on(WT_SESSION_IMPL *session, int *evict_resetp) { WT_BTREE *btree; WT_CACHE *cache; @@ -664,6 +664,15 @@ __wt_evict_file_exclusive_on(WT_SESSION_IMPL *session) cache = S2C(session)->cache; /* + * If the file isn't evictable, there's no work to do. + */ + if (F_ISSET(btree, WT_BTREE_NO_EVICTION)) { + *evict_resetp = 0; + return (0); + } + *evict_resetp = 1; + + /* * Hold the walk lock to set the "no eviction" flag: no new pages from * the file will be queued for eviction after this point. */ diff --git a/src/include/extern.h b/src/include/extern.h index 23bb36623e5..5d3ee5bc8f8 100644 --- a/src/include/extern.h +++ b/src/include/extern.h @@ -297,7 +297,7 @@ 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_page(WT_SESSION_IMPL *session, WT_REF *ref); -extern int __wt_evict_file_exclusive_on(WT_SESSION_IMPL *session); +extern int __wt_evict_file_exclusive_on(WT_SESSION_IMPL *session, int *evict_resetp); extern void __wt_evict_file_exclusive_off(WT_SESSION_IMPL *session); extern int __wt_evict_lru_page(WT_SESSION_IMPL *session, int is_server); extern int __wt_cache_wait(WT_SESSION_IMPL *session, int full); |