From 3fa6a3fadcbf7be764bac60484c8b4b39d4c74e5 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Wed, 3 Jan 2018 14:34:41 -0500 Subject: [PATCH 1/2] rgw: change ObjectCache::lru from deque back to list ObjectCacheEntry stores an lru_iter into this lru, and depends on that iterator remaining valid as other entries are inserted/erased Fixes: http://tracker.ceph.com/issues/22560 Signed-off-by: Casey Bodley --- src/rgw/rgw_cache.cc | 4 ++-- src/rgw/rgw_cache.h | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/rgw/rgw_cache.cc b/src/rgw/rgw_cache.cc index 43c03ec5ecf..779a569625c 100644 --- a/src/rgw/rgw_cache.cc +++ b/src/rgw/rgw_cache.cc @@ -209,7 +209,7 @@ void ObjectCache::remove(string& name) } void ObjectCache::touch_lru(string& name, ObjectCacheEntry& entry, - std::deque::iterator& lru_iter) + std::list::iterator& lru_iter) { while (lru_size > (size_t)cct->_conf->rgw_cache_lru_size) { auto iter = lru.begin(); @@ -249,7 +249,7 @@ void ObjectCache::touch_lru(string& name, ObjectCacheEntry& entry, } void ObjectCache::remove_lru(string& name, - std::deque::iterator& lru_iter) + std::list::iterator& lru_iter) { if (lru_iter == lru.end()) return; diff --git a/src/rgw/rgw_cache.h b/src/rgw/rgw_cache.h index 880001647af..b6066b6b544 100644 --- a/src/rgw/rgw_cache.h +++ b/src/rgw/rgw_cache.h @@ -128,7 +128,7 @@ WRITE_CLASS_ENCODER(RGWCacheNotifyInfo) struct ObjectCacheEntry { ObjectCacheInfo info; - std::deque::iterator lru_iter; + std::list::iterator lru_iter; uint64_t lru_promotion_ts; uint64_t gen; std::vector > chained_entries; @@ -138,7 +138,7 @@ struct ObjectCacheEntry { class ObjectCache { std::unordered_map cache_map; - std::deque lru; + std::list lru; unsigned long lru_size; unsigned long lru_counter; unsigned long lru_window; @@ -151,8 +151,8 @@ class ObjectCache { ceph::timespan expiry; void touch_lru(string& name, ObjectCacheEntry& entry, - std::deque::iterator& lru_iter); - void remove_lru(string& name, std::deque::iterator& lru_iter); + std::list::iterator& lru_iter); + void remove_lru(string& name, std::list::iterator& lru_iter); void invalidate_lru(ObjectCacheEntry& entry); void do_invalidate_all(); From 25b27b5c9d3f5a82769d06d92b9ba59038952ce8 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Wed, 3 Jan 2018 16:29:32 -0500 Subject: [PATCH 2/2] rgw: add invalidate_lru() call back to ObjectCache::put() the removal of this line was causing s3test failures independently of the change from list-deque Signed-off-by: Casey Bodley --- src/rgw/rgw_cache.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rgw/rgw_cache.cc b/src/rgw/rgw_cache.cc index 779a569625c..48d3c540877 100644 --- a/src/rgw/rgw_cache.cc +++ b/src/rgw/rgw_cache.cc @@ -134,6 +134,8 @@ void ObjectCache::put(string& name, ObjectCacheInfo& info, rgw_cache_entry_info ObjectCacheEntry& entry = iter->second; ObjectCacheInfo& target = entry.info; + invalidate_lru(entry); + entry.chained_entries.clear(); entry.gen++;