]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: unregister chained cache on shutdown
authorYehuda Sadeh <yehuda@redhat.com>
Fri, 12 Oct 2018 22:37:42 +0000 (15:37 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 8 Nov 2018 17:19:29 +0000 (09:19 -0800)
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.cc
src/rgw/services/svc_sys_obj_cache.h

index e4d38b678a0f957c715871eab938c372a5c850f9..a53940b262615d8d54b23344e3799ecad944f472 100644 (file)
@@ -322,3 +322,15 @@ void ObjectCache::chain_cache(RGWChainedCache *cache) {
   chained_cache.push_back(cache);
 }
 
+void ObjectCache::unchain_cache(RGWChainedCache *cache) {
+  RWLock::WLocker l(lock);
+
+  auto iter = chained_cache.begin();
+  for (; iter != chained_cache.end(); ++iter) {
+    if (cache == *iter) {
+      chained_cache.erase(iter);
+      return;
+    }
+  }
+}
+
index 3a1c3495edc5398e8405ef68be3673543ed68682..60087f92ea4efa510db2bd6f350d81242ae8cdb9 100644 (file)
@@ -209,6 +209,7 @@ public:
   void set_enabled(bool status);
 
   void chain_cache(RGWChainedCache *cache);
+  void unchain_cache(RGWChainedCache *cache);
   void invalidate_all();
 };
 
index 03786a8ff91fd4f200518f1be9a63f327b86cb41..abedea936d9b24211337ea88e64e4e31daa22d95 100644 (file)
@@ -438,6 +438,11 @@ void RGWSI_SysObj_Cache::register_chained_cache(RGWChainedCache *cc)
   cache.chain_cache(cc);
 }
 
+void RGWSI_SysObj_Cache::unregister_chained_cache(RGWChainedCache *cc)
+{
+  cache.unchain_cache(cc);
+}
+
 static void cache_list_dump_helper(Formatter* f,
                                    const std::string& name,
                                    const ceph::real_time mtime,
index 98be1c6c50df480b045b565fa68cd27c4161b285..71421131e4cce6103b7da4cac9a2eda59260dac3 100644 (file)
@@ -87,6 +87,7 @@ public:
   bool chain_cache_entry(std::initializer_list<rgw_cache_entry_info *> cache_info_entries,
                          RGWChainedCache::Entry *chained_entry);
   void register_chained_cache(RGWChainedCache *cc);
+  void unregister_chained_cache(RGWChainedCache *cc);
 
   void call_list(const std::optional<std::string>& filter, Formatter* f);
   int call_inspect(const std::string& target, Formatter* f);
@@ -104,11 +105,18 @@ class RGWChainedCacheImpl : public RGWChainedCache {
 
 public:
   RGWChainedCacheImpl() : lock("RGWChainedCacheImpl::lock") {}
-
-  void init(RGWSI_SysObj_Cache *svc) {
+  ~RGWChainedCacheImpl() {
     if (!svc) {
       return;
     }
+    svc->unregister_chained_cache(this);
+  }
+
+  void init(RGWSI_SysObj_Cache *_svc) {
+    if (!_svc) {
+      return;
+    }
+    svc = _svc;
     svc->register_chained_cache(this);
     expiry = std::chrono::seconds(svc->ctx()->_conf.get_val<uint64_t>(
                                    "rgw_cache_expiry_interval"));