void lookup_object_cache_store(std::string pool_name, std::string vol_name, std::string obj_name, int& ret) {
std::string cache_path;
- ret = m_object_cache_store->lookup_object(pool_name, 1, 2, obj_name, cache_path);
+ ret = m_object_cache_store->lookup_object(pool_name, 1, 2, obj_name, true,
+ cache_path);
}
void TearDown() override {
#include "CacheClient.h"
#include "common/Cond.h"
+#include "common/version.h"
#define dout_context g_ceph_context
#define dout_subsys ceph_subsys_immutable_obj_cache
// TODO : re-implement this method
int CacheClient::register_client(Context* on_finish) {
ObjectCacheRequest* reg_req = new ObjectCacheRegData(RBDSC_REGISTER,
- m_sequence_id++);
+ m_sequence_id++,
+ ceph_version_to_str());
reg_req->encode();
bufferlist bl;
case RBDSC_REGISTER: {
// TODO(dehao): skip register and allow clients to lookup directly
+ auto req_reg_data = reinterpret_cast <ObjectCacheRegData*> (req);
+ session->set_client_version(req_reg_data->version);
+
ObjectCacheRequest* reply = new ObjectCacheRegReplyData(
RBDSC_REGISTER_REPLY, req->seq);
session->send(reply);
std::string cache_path;
ObjectCacheReadData* req_read_data =
reinterpret_cast <ObjectCacheReadData*> (req);
+ bool return_dne_path = session->client_version().empty();
int ret = m_object_cache_store->lookup_object(
req_read_data->pool_namespace, req_read_data->pool_id,
- req_read_data->snap_id, req_read_data->oid, cache_path);
+ req_read_data->snap_id, req_read_data->oid, return_dne_path,
+ cache_path);
ObjectCacheRequest* reply = nullptr;
if (ret != OBJ_CACHE_PROMOTED && ret != OBJ_CACHE_DNE) {
reply = new ObjectCacheReadRadosData(RBDSC_READ_RADOS, req->seq);
return m_dm_socket;
}
+void CacheSession::set_client_version(const std::string &version) {
+ m_client_version = version;
+}
+
+const std::string &CacheSession::client_version() const {
+ return m_client_version;
+}
+
void CacheSession::close() {
if (m_dm_socket.is_open()) {
boost::system::error_code close_ec;
void fault(const boost::system::error_code& ec);
void send(ObjectCacheRequest* msg);
+ void set_client_version(const std::string &version);
+ const std::string &client_version() const;
+
private:
stream_protocol::socket m_dm_socket;
ProcessMsg m_server_process_msg;
CephContext* m_cct;
+ std::string m_client_version;
+
bufferptr m_bp_header;
};
int ObjectCacheStore::lookup_object(std::string pool_nspace,
uint64_t pool_id, uint64_t snap_id,
std::string object_name,
+ bool return_dne_path,
std::string& target_cache_file_path) {
ldout(m_cct, 20) << "object name = " << object_name
<< " in pool ID : " << pool_id << dendl;
target_cache_file_path = get_cache_file_path(cache_file_name);
return ret;
case OBJ_CACHE_DNE:
+ if (return_dne_path) {
+ target_cache_file_path = get_cache_file_path(cache_file_name);
+ }
+ return ret;
case OBJ_CACHE_SKIP:
return ret;
default:
int lookup_object(std::string pool_nspace,
uint64_t pool_id, uint64_t snap_id,
std::string object_name,
+ bool return_dne_path,
std::string& target_cache_file_path);
private:
ObjectCacheRegData::ObjectCacheRegData() {}
ObjectCacheRegData::ObjectCacheRegData(uint16_t t, uint64_t s)
: ObjectCacheRequest(t, s) {}
+ObjectCacheRegData::ObjectCacheRegData(uint16_t t, uint64_t s,
+ const std::string &version)
+ : ObjectCacheRequest(t, s),
+ version(version) {
+}
ObjectCacheRegData::~ObjectCacheRegData() {}
-void ObjectCacheRegData::encode_payload() {}
+void ObjectCacheRegData::encode_payload() {
+ ceph::encode(version, payload);
+}
-void ObjectCacheRegData::decode_payload(bufferlist::const_iterator i) {}
+void ObjectCacheRegData::decode_payload(bufferlist::const_iterator i) {
+ if (i.end()) {
+ return;
+ }
+ ceph::decode(version, i);
+}
ObjectCacheRegReplyData::ObjectCacheRegReplyData() {}
ObjectCacheRegReplyData::ObjectCacheRegReplyData(uint16_t t, uint64_t s)
class ObjectCacheRegData : public ObjectCacheRequest {
public:
+ std::string version;
ObjectCacheRegData();
+ ObjectCacheRegData(uint16_t t, uint64_t s, const std::string &version);
ObjectCacheRegData(uint16_t t, uint64_t s);
~ObjectCacheRegData() override;
void encode_payload() override;
void decode_payload(bufferlist::const_iterator bl) override;
uint16_t get_request_type() override { return RBDSC_REGISTER; }
- bool payload_empty() override { return true; }
+ bool payload_empty() override { return false; }
};
class ObjectCacheRegReplyData : public ObjectCacheRequest {