]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson: object state can be manually evicted from OSD's cache.
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Mon, 29 Apr 2019 13:19:43 +0000 (15:19 +0200)
committerKefu Chai <kchai@redhat.com>
Tue, 7 May 2019 10:05:34 +0000 (18:05 +0800)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/common/shared_lru.h
src/crimson/common/simple_lru.h
src/crimson/osd/pg_backend.cc
src/crimson/osd/pg_backend.h

index 25b1fe5e183760991c5daa84a937e28c621d08f7..4c1da401e3b757680ebb52414db35000d13024c9 100644 (file)
@@ -29,11 +29,11 @@ class SharedLRU {
     SharedLRU<K,V>* cache;
     const K key;
     void operator()(V* ptr) {
-      cache->_erase(key);
+      cache->_erase_weak(key);
       delete ptr;
     }
   };
-  void _erase(const K& key) {
+  void _erase_weak(const K& key) {
     weak_refs.erase(key);
   }
 public:
@@ -85,6 +85,11 @@ public:
   shared_ptr_t lower_bound(const K& key);
   // return the first element that is greater than key
   std::optional<value_type> upper_bound(const K& key);
+
+  void erase(const K& key) {
+    cache.erase(key);
+    _erase_weak(key);
+  }
 };
 
 template<class K, class V>
index fca1061fd8cccf5acfc4d5f8616dc241544e9974..1419c48851b6b19c6e68fe34866b0a0ee23fa33d 100644 (file)
@@ -113,7 +113,7 @@ template <class Key, class Value, bool Ordered>
 void SimpleLRU<Key,Value,Ordered>::erase(const Key& key)
 {
   if (auto found = cache.find(key); found != cache.end()) {
-    lru.erase(found->second->second);
+    lru.erase(found->second.second);
     cache.erase(found);
   }
 }
index 10209cb6c0402e82221d4bd2febcd3899a20f2a6..25bac37cc38ddf8ccafb2613f88dff81f3a36126 100644 (file)
@@ -149,6 +149,13 @@ PGBackend::_load_ss(const hobject_t& oid)
   });
 }
 
+seastar::future<>
+PGBackend::evict_object_state(const hobject_t& oid)
+{
+  os_cache.erase(oid);
+  return seastar::now();
+}
+
 seastar::future<bufferlist> PGBackend::read(const object_info_t& oi,
                                             size_t offset,
                                             size_t length,
index 15f43b95866e3b3d62015ab344740bb83207aeca..3d0b298ae0b554dc04048c396b885f8f4d7e7151 100644 (file)
@@ -34,6 +34,7 @@ public:
                                           const ec_profile_t& ec_profile);
   using cached_os_t = boost::local_shared_ptr<ObjectState>;
   seastar::future<cached_os_t> get_object_state(const hobject_t& oid);
+  seastar::future<> evict_object_state(const hobject_t& oid);
   seastar::future<bufferlist> read(const object_info_t& oi,
                                   uint64_t off,
                                   uint64_t len,