]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: remove expired entries from the cache 22410/head
authorMark Kogan <mkogan@redhat.com>
Tue, 5 Jun 2018 08:18:30 +0000 (11:18 +0300)
committerMark Kogan <mkogan@redhat.com>
Tue, 5 Jun 2018 08:29:58 +0000 (11:29 +0300)
Fixes: http://tracker.ceph.com/issues/23379
Signed-off-by: Mark Kogan <mkogan@redhat.com>
src/rgw/rgw_cache.cc

index 7dc2156b0a5cf968c5fa40fde78d61e7e92339c9..e4d38b678a0f957c715871eab938c372a5c850f9 100644 (file)
@@ -17,14 +17,29 @@ int ObjectCache::get(const string& name, ObjectCacheInfo& info, uint32_t mask, r
   }
 
   auto iter = cache_map.find(name);
-  if (iter == cache_map.end() ||
-      (expiry.count() &&
-       (ceph::coarse_mono_clock::now() - iter->second.info.time_added) > expiry)) {
+  if (iter == cache_map.end()) {
     ldout(cct, 10) << "cache get: name=" << name << " : miss" << dendl;
     if (perfcounter)
       perfcounter->inc(l_rgw_cache_miss);
     return -ENOENT;
   }
+  if (expiry.count() &&
+       (ceph::coarse_mono_clock::now() - iter->second.info.time_added) > expiry) {
+    ldout(cct, 10) << "cache get: name=" << name << " : expiry miss" << dendl;
+    lock.unlock();
+    lock.get_write();
+    // check that wasn't already removed by other thread
+    iter = cache_map.find(name);
+    if (iter != cache_map.end()) {
+      for (auto &kv : iter->second.chained_entries)
+        kv.first->invalidate(kv.second);
+      remove_lru(name, iter->second.lru_iter);
+      cache_map.erase(iter);
+    }
+    if(perfcounter)
+      perfcounter->inc(l_rgw_cache_miss);
+    return -ENOENT;
+  }
 
   ObjectCacheEntry *entry = &iter->second;