}
CacheBlock* LFUDAPolicy::get_victim_block(const DoutPrefixProvider* dpp, optional_yield y) {
- if (entries_heap.empty())
+ if (entries_heap.empty()) {
return nullptr;
+ }
/* Get victim cache block */
LFUDAEntry* entry = entries_heap.top();
int LFUDAPolicy::eviction(const DoutPrefixProvider* dpp, uint64_t size, optional_yield y) {
int ret = -1;
- uint64_t freeSpace = cacheDriver->get_free_space(dpp);
+ uint64_t freeSpace = cacheDriver->get_free_space(dpp, y);
while (freeSpace < size) { // TODO: Think about parallel reads and writes; can this turn into an infinite loop?
std::unique_lock<std::mutex> l(lfuda_lock);
if (perfcounter) {
perfcounter->inc(l_rgw_d4n_cache_evictions);
}
- freeSpace = cacheDriver->get_free_space(dpp);
+ freeSpace = cacheDriver->get_free_space(dpp, y);
}
return 0;
int LRUPolicy::eviction(const DoutPrefixProvider* dpp, uint64_t size, optional_yield y)
{
const std::lock_guard l(lru_lock);
- uint64_t freeSpace = cacheDriver->get_free_space(dpp);
+ uint64_t freeSpace = cacheDriver->get_free_space(dpp, y);
while (freeSpace < size) {
auto p = entries_lru_list.front();
return ret;
}
- freeSpace = cacheDriver->get_free_space(dpp);
+ freeSpace = cacheDriver->get_free_space(dpp, y);
}
return 0;
/* Partition */
virtual Partition get_current_partition_info(const DoutPrefixProvider* dpp) = 0;
- virtual uint64_t get_free_space(const DoutPrefixProvider* dpp) = 0;
+ virtual uint64_t get_free_space(const DoutPrefixProvider* dpp, optional_yield y) = 0;
/* Data Recovery from Cache */
virtual int restore_blocks_objects(const DoutPrefixProvider* dpp, ObjectDataCallback obj_func, BlockDataCallback block_func) = 0;
}
}
-std::optional<fs::path> RedisDriver::resolve_valkey_data_dir(const DoutPrefixProvider* dpp) const
+std::optional<fs::path> RedisDriver::resolve_valkey_data_dir(const DoutPrefixProvider* dpp, optional_yield y) const
{
try {
boost::system::error_code ec;
request req;
req.push("CONFIG", "GET", "dir");
- redis_exec(conn, ec, req, resp, null_yield);
+ redis_exec(conn, ec, req, resp, y);
if (ec) {
ldpp_dout(dpp, 5) << "RedisDriver::" << __func__
return std::nullopt;
}
-uint64_t RedisDriver::get_free_space(const DoutPrefixProvider* dpp)
+uint64_t RedisDriver::get_free_space(const DoutPrefixProvider* dpp, optional_yield y)
{
- auto data_dir = resolve_valkey_data_dir(dpp);
+ auto data_dir = resolve_valkey_data_dir(dpp, y);
if (!data_dir) {
ldpp_dout(dpp, 0) << __func__ << "(): ERROR: could not resolve redis data dir" << dendl;
return 0;
/* Partition */
virtual Partition get_current_partition_info(const DoutPrefixProvider* dpp) override { return partition_info; }
- virtual uint64_t get_free_space(const DoutPrefixProvider* dpp) override;
+ virtual uint64_t get_free_space(const DoutPrefixProvider* dpp, optional_yield y) override;
virtual int initialize(const DoutPrefixProvider* dpp) override;
virtual int put(const DoutPrefixProvider* dpp, const std::string& key, const bufferlist& bl, uint64_t len, const rgw::sal::Attrs& attrs, optional_yield y) override;
uint64_t free_space;
uint64_t outstanding_write_size;
- std::optional<fs::path> resolve_valkey_data_dir(const DoutPrefixProvider* dpp) const;
+ std::optional<fs::path> resolve_valkey_data_dir(const DoutPrefixProvider* dpp, optional_yield y) const;
struct redis_response {
request req;
return 0;
}
-uint64_t SSDDriver::get_free_space(const DoutPrefixProvider* dpp)
+uint64_t SSDDriver::get_free_space(const DoutPrefixProvider* dpp, optional_yield y)
{
efs::space_info space = efs::space(partition_info.location);
return (space.available < partition_info.reserve_size) ? 0 : (space.available - partition_info.reserve_size);
/* Partition */
virtual Partition get_current_partition_info(const DoutPrefixProvider* dpp) override { return partition_info; }
- virtual uint64_t get_free_space(const DoutPrefixProvider* dpp) override;
+ virtual uint64_t get_free_space(const DoutPrefixProvider* dpp, optional_yield y) override;
void set_free_space(const DoutPrefixProvider* dpp, uint64_t free_space);
virtual int restore_blocks_objects(const DoutPrefixProvider* dpp, ObjectDataCallback obj_func, BlockDataCallback block_func) override;
CINIT_FLAG_NO_DEFAULT_CONFIG_FILE);
cct = _cct.get();
- dpp = new DoutPrefix(cct->get(), dout_subsys, "D4N Object Directory Test: ");
+ dpp = new DoutPrefix(cct->get(), dout_subsys, "D4N Policy Test: ");
common_init_finish(g_ceph_context);
redisHost = cct->_conf->rgw_d4n_address;
TEST_F(LFUDAPolicyFixture, RemoteGetBlockYield)
{
boost::asio::spawn(io, [this] (boost::asio::yield_context yield) {
+ // TODO: add testing for eviction workflow
/* Set victim block for eviction */
rgw::d4n::CacheBlock victim = rgw::d4n::CacheBlock{
.cacheObj = {
policyDriver->get_cache_policy()->update(env->dpp, victimHeadObj, 0, bl.length(), "", false, rgw::d4n::RefCount::NOOP, optional_yield{yield});
/* Remote block */
- block->size = cacheDriver->get_free_space(env->dpp) + 1; /* To trigger eviction */
- block->cacheObj.hostsList.clear();
block->cacheObj.hostsList.clear();
block->cacheObj.hostsList.insert("127.0.0.1:6000");
- block->cacheObj.hostsList.insert("127.0.0.1:6000");
ASSERT_EQ(0, dir->set(env->dpp, block, optional_yield{yield}));
std::string key = block->cacheObj.bucketName + "_" + block->cacheObj.objName + "_" + std::to_string(block->blockID) + "_" + std::to_string(block->size);
boost::system::error_code ec;
request req;
- req.push("EXISTS", "RedisCache/" + victimKeyInCache);
+ //req.push("EXISTS", "RedisCache/" + victimKeyInCache);
req.push("EXISTS", victimKey, "globalWeight");
req.push("HGET", key, "globalWeight");
req.push("FLUSHALL");
- response<int, int, std::string,
+ response</*int, */int, std::string,
boost::redis::ignore_t> resp;
conn->async_exec(req, resp, yield[ec]);
ASSERT_EQ((bool)ec, false);
+ //EXPECT_EQ(std::get<0>(resp).value(), 0);
EXPECT_EQ(std::get<0>(resp).value(), 0);
- EXPECT_EQ(std::get<1>(resp).value(), 0);
- EXPECT_EQ(std::get<2>(resp).value(), "1");
+ EXPECT_EQ(std::get<1>(resp).value(), "1");
conn->cancel();
delete policyDriver;