From: Yehuda Sadeh Date: Fri, 26 Oct 2018 23:20:05 +0000 (-0700) Subject: rgw: chained cache shouldn't access service after it was unchained X-Git-Tag: v14.1.0~965^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=238f0ef4a44481787fa36db99c78936480202d6f;p=ceph.git rgw: chained cache shouldn't access service after it was unchained This fixes a cleanup ordering issue. We can now have the chained cache removed before and after the service is destructed. Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_cache.cc b/src/rgw/rgw_cache.cc index a53940b26261..fe8ab51f539e 100644 --- a/src/rgw/rgw_cache.cc +++ b/src/rgw/rgw_cache.cc @@ -329,8 +329,16 @@ void ObjectCache::unchain_cache(RGWChainedCache *cache) { for (; iter != chained_cache.end(); ++iter) { if (cache == *iter) { chained_cache.erase(iter); + cache->unregistered(); return; } } } +ObjectCache::~ObjectCache() +{ + for (auto cache : chained_cache) { + cache->unregistered(); + } +} + diff --git a/src/rgw/rgw_cache.h b/src/rgw/rgw_cache.h index 60087f92ea4e..b0696237fe6b 100644 --- a/src/rgw/rgw_cache.h +++ b/src/rgw/rgw_cache.h @@ -132,6 +132,7 @@ public: virtual void chain_cb(const string& key, void *data) = 0; virtual void invalidate(const string& key) = 0; virtual void invalidate_all() = 0; + virtual void unregistered() {} struct Entry { RGWChainedCache *cache; @@ -173,8 +174,10 @@ class ObjectCache { void invalidate_lru(ObjectCacheEntry& entry); void do_invalidate_all(); + public: ObjectCache() : lru_size(0), lru_counter(0), lru_window(0), lock("ObjectCache"), cct(NULL), enabled(false) { } + ~ObjectCache(); int get(const std::string& name, ObjectCacheInfo& bl, uint32_t mask, rgw_cache_entry_info *cache_info); std::optional get(const std::string& name) { std::optional info{std::in_place}; diff --git a/src/rgw/services/svc_sys_obj_cache.h b/src/rgw/services/svc_sys_obj_cache.h index 7b986fe50896..fefbc298cd85 100644 --- a/src/rgw/services/svc_sys_obj_cache.h +++ b/src/rgw/services/svc_sys_obj_cache.h @@ -112,6 +112,10 @@ public: svc->unregister_chained_cache(this); } + void unregistered() override { + svc = nullptr; + } + void init(RGWSI_SysObj_Cache *_svc) { if (!_svc) { return;