Skip to content

Commit

Permalink
crimson: object state can be manually evicted from OSD's cache.
Browse files Browse the repository at this point in the history
Signed-off-by: Radoslaw Zarzynski <[email protected]>
  • Loading branch information
rzarzynski authored and tchaikov committed May 7, 2019
1 parent d86ffe5 commit c400cf3
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/crimson/common/shared_lru.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -85,6 +85,11 @@ class SharedLRU {
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>
Expand Down
2 changes: 1 addition & 1 deletion src/crimson/common/simple_lru.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/crimson/osd/pg_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 1 addition & 0 deletions src/crimson/osd/pg_backend.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class PGBackend
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,
Expand Down

0 comments on commit c400cf3

Please sign in to comment.