From 0d2fad0dcfaa6ac07b91ebc7bb414ba9a720d702 Mon Sep 17 00:00:00 2001 From: David Hows Date: Tue, 15 Mar 2016 16:35:48 +1100 Subject: [PATCH] WT-2476 - Revert changing the cache evict_walk_lock to the btree evict_lock --- src/btree/bt_handle.c | 2 -- src/conn/conn_cache.c | 2 ++ src/evict/evict_lru.c | 16 +++++++++------- src/include/btree.h | 1 - src/include/cache.h | 1 + 5 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/btree/bt_handle.c b/src/btree/bt_handle.c index bf888bfa65f..1d33a7e7c9a 100644 --- a/src/btree/bt_handle.c +++ b/src/btree/bt_handle.c @@ -164,7 +164,6 @@ __wt_btree_close(WT_SESSION_IMPL *session) /* Destroy locks. */ WT_TRET(__wt_rwlock_destroy(session, &btree->ovfl_lock)); - __wt_spin_destroy(session, &btree->evict_lock); __wt_spin_destroy(session, &btree->flush_lock); /* Free allocated memory. */ @@ -351,7 +350,6 @@ __btree_conf(WT_SESSION_IMPL *session, WT_CKPT *ckpt) /* Initialize locks. */ WT_RET(__wt_rwlock_alloc( session, &btree->ovfl_lock, "btree overflow lock")); - WT_RET(__wt_spin_init(session, &btree->evict_lock, "btree evict")); WT_RET(__wt_spin_init(session, &btree->flush_lock, "btree flush")); btree->checkpointing = WT_CKPT_OFF; /* Not checkpointing */ diff --git a/src/conn/conn_cache.c b/src/conn/conn_cache.c index 9850854a1de..9a2c394e9a6 100644 --- a/src/conn/conn_cache.c +++ b/src/conn/conn_cache.c @@ -158,6 +158,7 @@ __wt_cache_create(WT_SESSION_IMPL *session, const char *cfg[]) WT_ERR(__wt_cond_alloc(session, "eviction waiters", false, &cache->evict_waiter_cond)); WT_ERR(__wt_spin_init(session, &cache->evict_lock, "cache eviction")); + WT_ERR(__wt_spin_init(session, &cache->evict_walk_lock, "cache walk")); /* Allocate the LRU eviction queue. */ cache->evict_slots = WT_EVICT_WALK_BASE + WT_EVICT_WALK_INCR; @@ -254,6 +255,7 @@ __wt_cache_destroy(WT_SESSION_IMPL *session) WT_TRET(__wt_cond_auto_destroy(session, &cache->evict_cond)); WT_TRET(__wt_cond_destroy(session, &cache->evict_waiter_cond)); __wt_spin_destroy(session, &cache->evict_lock); + __wt_spin_destroy(session, &cache->evict_walk_lock); __wt_free(session, cache->evict_queue); __wt_free(session, conn->cache); diff --git a/src/evict/evict_lru.c b/src/evict/evict_lru.c index 855824930f8..50a00787f35 100644 --- a/src/evict/evict_lru.c +++ b/src/evict/evict_lru.c @@ -796,11 +796,11 @@ __wt_evict_file_exclusive_on(WT_SESSION_IMPL *session) * The no-eviction flag can be set permanently, in which case we never * increment the no-eviction count. */ - __wt_spin_lock(session, &btree->evict_lock); + __wt_spin_lock(session, &cache->evict_walk_lock); if (F_ISSET(btree, WT_BTREE_NO_EVICTION)) { if (btree->evict_disabled != 0) ++btree->evict_disabled; - __wt_spin_unlock(session, &btree->evict_lock); + __wt_spin_unlock(session, &cache->evict_walk_lock); return (0); } ++btree->evict_disabled; @@ -837,7 +837,7 @@ __wt_evict_file_exclusive_on(WT_SESSION_IMPL *session) err: --btree->evict_disabled; F_CLR(btree, WT_BTREE_NO_EVICTION); } - __wt_spin_unlock(session, &btree->evict_lock); + __wt_spin_unlock(session, &cache->evict_walk_lock); return (ret); } @@ -849,8 +849,10 @@ void __wt_evict_file_exclusive_off(WT_SESSION_IMPL *session) { WT_BTREE *btree; + WT_CACHE *cache; btree = S2BT(session); + cache = S2C(session)->cache; /* * We have seen subtle bugs with multiple threads racing to turn @@ -865,10 +867,10 @@ __wt_evict_file_exclusive_off(WT_SESSION_IMPL *session) * The no-eviction flag can be set permanently, in which case we never * increment the no-eviction count. */ - __wt_spin_lock(session, &btree->evict_lock); + __wt_spin_lock(session, &cache->evict_walk_lock); if (btree->evict_disabled > 0 && --btree->evict_disabled == 0) F_CLR(btree, WT_BTREE_NO_EVICTION); - __wt_spin_unlock(session, &btree->evict_lock); + __wt_spin_unlock(session, &cache->evict_walk_lock); } /* @@ -1174,14 +1176,14 @@ retry: while (slot < max_entries && ret == 0) { * waiting on this thread to acknowledge that action. */ if (!F_ISSET(btree, WT_BTREE_NO_EVICTION) && - !__wt_spin_trylock(session, &btree->evict_lock)) { + !__wt_spin_trylock(session, &cache->evict_walk_lock)) { if (!F_ISSET(btree, WT_BTREE_NO_EVICTION)) { cache->evict_file_next = dhandle; WT_WITH_DHANDLE(session, dhandle, ret = __evict_walk_file(session, &slot)); WT_ASSERT(session, session->split_gen == 0); } - __wt_spin_unlock(session, &btree->evict_lock); + __wt_spin_unlock(session, &cache->evict_walk_lock); } /* diff --git a/src/include/btree.h b/src/include/btree.h index 2d8a9ad4607..fd921677751 100644 --- a/src/include/btree.h +++ b/src/include/btree.h @@ -129,7 +129,6 @@ struct __wt_btree { uint64_t rec_max_txn; /* Maximum txn seen (clean trees) */ uint64_t write_gen; /* Write generation */ - WT_SPINLOCK evict_lock; /* Eviction lock */ WT_REF *evict_ref; /* Eviction thread's location */ uint64_t evict_priority; /* Relative priority of cached pages */ u_int evict_walk_period; /* Skip this many LRU walks */ diff --git a/src/include/cache.h b/src/include/cache.h index af819cf250a..9184a2fe6ed 100644 --- a/src/include/cache.h +++ b/src/include/cache.h @@ -84,6 +84,7 @@ struct __wt_cache { */ WT_CONDVAR *evict_cond; /* Eviction server condition */ WT_SPINLOCK evict_lock; /* Eviction LRU queue */ + WT_SPINLOCK evict_walk_lock; /* Eviction walk location */ /* Condition signalled when the eviction server populates the queue */ WT_CONDVAR *evict_waiter_cond;