req_read_data->pool_namespace, req_read_data->pool_id,
req_read_data->snap_id, req_read_data->oid, cache_path);
ObjectCacheRequest* reply = nullptr;
- if (ret != OBJ_CACHE_PROMOTED) {
+ if (ret != OBJ_CACHE_PROMOTED && ret != OBJ_CACHE_DNE) {
reply = new ObjectCacheReadRadosData(RBDSC_READ_RADOS, req->seq);
} else {
reply = new ObjectCacheReadReplyData(RBDSC_READ_REPLY,
return ret;
}
+ auto state = OBJ_CACHE_PROMOTED;
if (ret == -ENOENT) {
// object is empty
+ state = OBJ_CACHE_DNE;
ret = 0;
- }
+ } else {
+ std::string cache_file_path = get_cache_file_path(cache_file_name, true);
+ if (cache_file_path == "") {
+ lderr(m_cct) << "fail to write cache file" << dendl;
+ m_policy->update_status(cache_file_name, OBJ_CACHE_NONE);
+ delete read_buf;
+ return -ENOSPC;
+ }
- std::string cache_file_path = get_cache_file_path(cache_file_name, true);
+ ret = read_buf->write_file(cache_file_path.c_str());
+ if (ret < 0) {
+ lderr(m_cct) << "fail to write cache file" << dendl;
- if (cache_file_path == "") {
- lderr(m_cct) << "fail to write cache file" << dendl;
- m_policy->update_status(cache_file_name, OBJ_CACHE_NONE);
- delete read_buf;
- return -ENOSPC;
- }
-
- ret = read_buf->write_file(cache_file_path.c_str());
- if (ret < 0) {
- lderr(m_cct) << "fail to write cache file" << dendl;
-
- m_policy->update_status(cache_file_name, OBJ_CACHE_NONE);
- delete read_buf;
- return ret;
+ m_policy->update_status(cache_file_name, OBJ_CACHE_NONE);
+ delete read_buf;
+ return ret;
+ }
}
// update metadata
ceph_assert(OBJ_CACHE_SKIP == m_policy->get_status(cache_file_name));
- m_policy->update_status(cache_file_name, OBJ_CACHE_PROMOTED, read_buf->length());
- ceph_assert(OBJ_CACHE_PROMOTED == m_policy->get_status(cache_file_name));
+ m_policy->update_status(cache_file_name, state, read_buf->length());
+ ceph_assert(state == m_policy->get_status(cache_file_name));
delete read_buf;
case OBJ_CACHE_PROMOTED:
target_cache_file_path = get_cache_file_path(cache_file_name);
return ret;
+ case OBJ_CACHE_DNE:
case OBJ_CACHE_SKIP:
return ret;
default:
OBJ_CACHE_NONE = 0,
OBJ_CACHE_PROMOTED,
OBJ_CACHE_SKIP,
+ OBJ_CACHE_DNE,
} cache_status_t;
class Policy {
Entry* entry = entry_it->second;
- if (entry->status == OBJ_CACHE_PROMOTED) {
+ if (entry->status == OBJ_CACHE_PROMOTED || entry->status == OBJ_CACHE_DNE) {
// bump pos in lru on hit
m_promoted_lru.lru_touch(entry);
}
}
// promoting done
- if (entry->status == OBJ_CACHE_SKIP && new_status== OBJ_CACHE_PROMOTED) {
+ if (entry->status == OBJ_CACHE_SKIP && (new_status== OBJ_CACHE_PROMOTED ||
+ new_status== OBJ_CACHE_DNE)) {
m_promoted_lru.lru_insert_top(entry);
entry->status = new_status;
entry->size = size;
}
// to evict
- if (entry->status == OBJ_CACHE_PROMOTED && new_status== OBJ_CACHE_NONE) {
+ if ((entry->status == OBJ_CACHE_PROMOTED || entry->status == OBJ_CACHE_DNE) &&
+ new_status== OBJ_CACHE_NONE) {
// mark this entry as free
uint64_t size = entry->size;
entry->file_name = "";
ceph::immutable_obj_cache::CacheController *cachectl = nullptr;
void usage() {
- std::cout << "usage: cache controller [options...]" << std::endl;
+ std::cout << "usage: ceph-immutable-object-cache [options...]" << std::endl;
std::cout << "options:\n";
std::cout << " -m monaddress[:port] connect to specified monitor\n";
std::cout << " --keyring=<path> path to keyring for local "