1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
5 #include "SocketCommon.h"
7 #define dout_subsys ceph_subsys_immutable_obj_cache
9 #define dout_prefix *_dout << "ceph::cache::Types: " << __func__ << ": "
12 namespace immutable_obj_cache
{
14 ObjectCacheRequest::ObjectCacheRequest() {}
15 ObjectCacheRequest::ObjectCacheRequest(uint16_t t
, uint64_t s
)
17 ObjectCacheRequest::~ObjectCacheRequest() {}
19 void ObjectCacheRequest::encode() {
20 ENCODE_START(1, 1, payload
);
21 ceph::encode(type
, payload
);
22 ceph::encode(seq
, payload
);
23 if (!payload_empty()) {
26 ENCODE_FINISH(payload
);
29 void ObjectCacheRequest::decode(bufferlist
& bl
) {
32 ceph::decode(type
, i
);
34 if (!payload_empty()) {
40 ObjectCacheRegData::ObjectCacheRegData() {}
41 ObjectCacheRegData::ObjectCacheRegData(uint16_t t
, uint64_t s
)
42 : ObjectCacheRequest(t
, s
) {}
44 ObjectCacheRegData::~ObjectCacheRegData() {}
46 void ObjectCacheRegData::encode_payload() {}
48 void ObjectCacheRegData::decode_payload(bufferlist::const_iterator i
) {}
50 ObjectCacheRegReplyData::ObjectCacheRegReplyData() {}
51 ObjectCacheRegReplyData::ObjectCacheRegReplyData(uint16_t t
, uint64_t s
)
52 : ObjectCacheRequest(t
, s
) {}
54 ObjectCacheRegReplyData::~ObjectCacheRegReplyData() {}
56 void ObjectCacheRegReplyData::encode_payload() {}
58 void ObjectCacheRegReplyData::decode_payload(bufferlist::const_iterator bl
) {}
60 ObjectCacheReadData::ObjectCacheReadData(uint16_t t
, uint64_t s
,
63 uint64_t pool_id
, uint64_t snap_id
,
65 std::string pool_namespace
)
66 : ObjectCacheRequest(t
, s
), read_offset(read_offset
),
67 read_len(read_len
), pool_id(pool_id
), snap_id(snap_id
),
68 oid(oid
), pool_namespace(pool_namespace
)
71 ObjectCacheReadData::ObjectCacheReadData(uint16_t t
, uint64_t s
)
72 : ObjectCacheRequest(t
, s
) {}
74 ObjectCacheReadData::~ObjectCacheReadData() {}
76 void ObjectCacheReadData::encode_payload() {
77 ceph::encode(read_offset
, payload
);
78 ceph::encode(read_len
, payload
);
79 ceph::encode(pool_id
, payload
);
80 ceph::encode(snap_id
, payload
);
81 ceph::encode(oid
, payload
);
82 ceph::encode(pool_namespace
, payload
);
85 void ObjectCacheReadData::decode_payload(bufferlist::const_iterator i
) {
86 ceph::decode(read_offset
, i
);
87 ceph::decode(read_len
, i
);
88 ceph::decode(pool_id
, i
);
89 ceph::decode(snap_id
, i
);
91 ceph::decode(pool_namespace
, i
);
94 ObjectCacheReadReplyData::ObjectCacheReadReplyData(uint16_t t
, uint64_t s
,
96 : ObjectCacheRequest(t
, s
), cache_path(cache_path
) {}
97 ObjectCacheReadReplyData::ObjectCacheReadReplyData(uint16_t t
, uint64_t s
)
98 : ObjectCacheRequest(t
, s
) {}
100 ObjectCacheReadReplyData::~ObjectCacheReadReplyData() {}
102 void ObjectCacheReadReplyData::encode_payload() {
103 ceph::encode(cache_path
, payload
);
106 void ObjectCacheReadReplyData::decode_payload(bufferlist::const_iterator i
) {
107 ceph::decode(cache_path
, i
);
110 ObjectCacheReadRadosData::ObjectCacheReadRadosData() {}
111 ObjectCacheReadRadosData::ObjectCacheReadRadosData(uint16_t t
, uint64_t s
)
112 : ObjectCacheRequest(t
, s
) {}
114 ObjectCacheReadRadosData::~ObjectCacheReadRadosData() {}
116 void ObjectCacheReadRadosData::encode_payload() {}
118 void ObjectCacheReadRadosData::decode_payload(bufferlist::const_iterator i
) {}
120 ObjectCacheRequest
* decode_object_cache_request(bufferlist payload_buffer
) {
121 ObjectCacheRequest
* req
= nullptr;
125 auto i
= payload_buffer
.cbegin();
127 ceph::decode(type
, i
);
128 ceph::decode(seq
, i
);
132 case RBDSC_REGISTER
: {
133 req
= new ObjectCacheRegData(type
, seq
);
137 req
= new ObjectCacheReadData(type
, seq
);
140 case RBDSC_REGISTER_REPLY
: {
141 req
= new ObjectCacheRegReplyData(type
, seq
);
144 case RBDSC_READ_REPLY
: {
145 req
= new ObjectCacheReadReplyData(type
, seq
);
148 case RBDSC_READ_RADOS
: {
149 req
= new ObjectCacheReadRadosData(type
, seq
);
156 req
->decode(payload_buffer
);
161 } // namespace immutable_obj_cache