refcount = entry->refcount;
ldpp_dout(dpp, 20) << "LFUDAPolicy::" << __func__ << "(): old refcount is: " << refcount << dendl;
if (op == RefCount::INCR) {
- refcount += 1;
- }
- if (op == RefCount::DECR) {
- if (refcount > 1) {
+ refcount += 1;
+ } else if (op == RefCount::DECR) {
+ if (refcount > 0) {
refcount -= 1;
}
}
(*entry->handle)->refcount = refcount;
+ entries_heap.update(entry->handle);
ldpp_dout(dpp, 20) << "LFUDAPolicy::" << __func__ << "(): updated refcount is: " << (*entry->handle)->refcount << dendl;
- entries_heap.update(entry->handle);
return true;
}
} else if (entry) {
is_dirty = entry->dirty;
}
- _erase(dpp, key, y);
ldpp_dout(dpp, 10) << "LFUDAPolicy::" << __func__ << "(): updated refcount is: " << refcount << dendl;
- LFUDAEntry* e = new LFUDAEntry(key, offset, len, version, is_dirty, refcount, localWeight);
- handle_type handle = entries_heap.push(e);
- e->set_handle(handle);
- entries_map.emplace(key, e);
+
+ if (entry) {
+ entry->key = key;
+ entry->offset = offset;
+ entry->len = len;
+ entry->version = version;
+ entry->dirty = is_dirty;
+ entry->refcount = refcount;
+ entry->localWeight = localWeight;
+ entries_heap.update(entry->handle, entry);
+ } else {
+ LFUDAEntry* e = new LFUDAEntry(key, offset, len, version, is_dirty, refcount, localWeight);
+ handle_type handle = entries_heap.push(e);
+ e->set_handle(handle);
+ entries_map.emplace(key, e);
+ }
if (updateLocalWeight) {
int ret = -1;
TEST_F(D4NFilterFixture, DeleteObjectWrite)
{
env->cct->_conf->d4n_writecache_enabled = true;
- env->cct->_conf->rgw_d4n_cache_cleaning_interval = 0;
+ env->cct->_conf->rgw_d4n_cache_cleaning_interval = 1;
const std::string testName = "DeleteObjectWrite";
std::string version;
std::unique_ptr<rgw::sal::Object::DeleteOp> del_op = obj->get_delete_op();
EXPECT_EQ(del_op->delete_obj(env->dpp, optional_yield{yield}, rgw::sal::FLAG_LOG_OP), 0);
+ std::string key = TEST_BUCKET + testName + "#" + version + "#" + TEST_OBJ + testName;
+ d4nFilter->get_policy_driver()->get_cache_policy()->update_refcount_if_key_exists(env->dpp, key, rgw::d4n::RefCount::DECR, optional_yield{yield});
dynamic_cast<rgw::d4n::LFUDAPolicy*>(d4nFilter->get_policy_driver()->get_cache_policy())->save_y(null_yield);
}, rethrow);
- io.run_for(std::chrono::seconds(2)); // Allow cleaning cycle to complete
+ io.run_for(std::chrono::seconds(3)); // Allow cleaning cycle to complete
net::spawn(io, [this, &testName, &version] (net::yield_context yield) {
dynamic_cast<rgw::d4n::LFUDAPolicy*>(d4nFilter->get_policy_driver()->get_cache_policy())->save_y(optional_yield{yield});
TEST_F(D4NFilterFixture, DeleteVersionedObjectWrite)
{
env->cct->_conf->d4n_writecache_enabled = true;
- env->cct->_conf->rgw_d4n_cache_cleaning_interval = 0;
- const std::string testName = "DeleteVersionedObjectRead";
+ env->cct->_conf->rgw_d4n_cache_cleaning_interval = 1;
+ const std::string testName = "DeleteVersionedObjectWrite";
const std::string bucketName = "/tmp/d4n_filter_tests/dbstore-default_ns.1";
std::string version, instance;
std::unique_ptr<rgw::sal::Object::DeleteOp> del_op_suspended = objSuspended->get_delete_op();
EXPECT_EQ(del_op_suspended->delete_obj(env->dpp, optional_yield{yield}, rgw::sal::FLAG_LOG_OP), 0);
+ d4nFilter->get_policy_driver()->get_cache_policy()->update_refcount_if_key_exists(env->dpp,
+ url_encode(bucketName, true) + "#" + instance + "#" + TEST_OBJ + testName, rgw::d4n::RefCount::DECR, optional_yield{yield});
+ d4nFilter->get_policy_driver()->get_cache_policy()->update_refcount_if_key_exists(env->dpp,
+ url_encode(bucketName, true) + "#" + version + "#" + TEST_OBJ + testName, rgw::d4n::RefCount::DECR, optional_yield{yield});
dynamic_cast<rgw::d4n::LFUDAPolicy*>(d4nFilter->get_policy_driver()->get_cache_policy())->save_y(null_yield);
}, rethrow);
- io.run_for(std::chrono::seconds(2)); // Allow cleaning cycle to complete
+ io.run_for(std::chrono::seconds(3)); // Allow cleaning cycle to complete
net::spawn(io, [this, &testName, &bucketName, &version, &instance] (net::yield_context yield) {
dynamic_cast<rgw::d4n::LFUDAPolicy*>(d4nFilter->get_policy_driver()->get_cache_policy())->save_y(optional_yield{yield});
TEST_F(D4NFilterFixture, VersionedDeleteBeforeCleaning)
{
env->cct->_conf->d4n_writecache_enabled = true;
- env->cct->_conf->rgw_d4n_cache_cleaning_interval = 0;
+ env->cct->_conf->rgw_d4n_cache_cleaning_interval = 1;
const std::string testName = "VersionedDeleteBeforeCleaning";
const std::string bucketName = "/tmp/d4n_filter_tests/dbstore-default_ns.1";
std::vector<std::string> instances;
EXPECT_EQ(objEnabled->get_instance(), instances[0]); // Next latest version
objEnabled->set_instance(instances[0]);
+ d4nFilter->get_policy_driver()->get_cache_policy()->update_refcount_if_key_exists(env->dpp,
+ url_encode(bucketName, true) + "#" + instances[1] + "#" + TEST_OBJ + testName, rgw::d4n::RefCount::DECR, optional_yield{yield});
dynamic_cast<rgw::d4n::LFUDAPolicy*>(d4nFilter->get_policy_driver()->get_cache_policy())->save_y(null_yield);
}, rethrow);
- io.run_for(std::chrono::seconds(2)); // Allow cleaning cycle to complete
+ io.run_for(std::chrono::seconds(3)); // Allow cleaning cycle to complete
net::spawn(io, [this, &testName, &bucketName, &instances] (net::yield_context yield) {
dynamic_cast<rgw::d4n::LFUDAPolicy*>(d4nFilter->get_policy_driver()->get_cache_policy())->save_y(optional_yield{yield});