]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: chained cache shouldn't access service after it was unchained
authorYehuda Sadeh <yehuda@redhat.com>
Fri, 26 Oct 2018 23:20:05 +0000 (16:20 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 8 Nov 2018 17:19:30 +0000 (09:19 -0800)
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 <yehuda@redhat.com>
src/rgw/rgw_cache.cc
src/rgw/rgw_cache.h
src/rgw/services/svc_sys_obj_cache.h

index a53940b262615d8d54b23344e3799ecad944f472..fe8ab51f539e4fa50fb48c3d8ebf6bebb17289f1 100644 (file)
@@ -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();
+  }
+}
+
index 60087f92ea4efa510db2bd6f350d81242ae8cdb9..b0696237fe6b2bbeb5815fcca3831ce8a9670143 100644 (file)
@@ -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<ObjectCacheInfo> get(const std::string& name) {
     std::optional<ObjectCacheInfo> info{std::in_place};
index 7b986fe508969330a707631db0785f83778abc32..fefbc298cd8591f421ffe38706865d7834548879 100644 (file)
@@ -112,6 +112,10 @@ public:
     svc->unregister_chained_cache(this);
   }
 
+  void unregistered() override {
+    svc = nullptr;
+  }
+
   void init(RGWSI_SysObj_Cache *_svc) {
     if (!_svc) {
       return;