diff --git a/src/crimson/common/shared_lru.h b/src/crimson/common/shared_lru.h index 25b1fe5e183..4c1da401e3b 100644 --- a/src/crimson/common/shared_lru.h +++ b/src/crimson/common/shared_lru.h @@ -29,11 +29,11 @@ class SharedLRU { SharedLRU* 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 upper_bound(const K& key); + + void erase(const K& key) { + cache.erase(key); + _erase_weak(key); + } }; template diff --git a/src/crimson/common/simple_lru.h b/src/crimson/common/simple_lru.h index fca1061fd8c..1419c48851b 100644 --- a/src/crimson/common/simple_lru.h +++ b/src/crimson/common/simple_lru.h @@ -113,7 +113,7 @@ template void SimpleLRU::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); } } diff --git a/src/crimson/osd/pg_backend.cc b/src/crimson/osd/pg_backend.cc index 10209cb6c04..25bac37cc38 100644 --- a/src/crimson/osd/pg_backend.cc +++ b/src/crimson/osd/pg_backend.cc @@ -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 PGBackend::read(const object_info_t& oi, size_t offset, size_t length, diff --git a/src/crimson/osd/pg_backend.h b/src/crimson/osd/pg_backend.h index 15f43b95866..3d0b298ae0b 100644 --- a/src/crimson/osd/pg_backend.h +++ b/src/crimson/osd/pg_backend.h @@ -34,6 +34,7 @@ public: const ec_profile_t& ec_profile); using cached_os_t = boost::local_shared_ptr; seastar::future get_object_state(const hobject_t& oid); + seastar::future<> evict_object_state(const hobject_t& oid); seastar::future read(const object_info_t& oi, uint64_t off, uint64_t len,