]> git.proxmox.com Git - ceph.git/blob - ceph/src/tools/immutable_object_cache/Types.cc
a0a4c6352aa5382cf729f34d46948cbd7aad0419
[ceph.git] / ceph / src / tools / immutable_object_cache / Types.cc
1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
3
4 #include "Types.h"
5 #include "SocketCommon.h"
6
7 #define dout_subsys ceph_subsys_immutable_obj_cache
8 #undef dout_prefix
9 #define dout_prefix *_dout << "ceph::cache::Types: " << __func__ << ": "
10
11 namespace ceph {
12 namespace immutable_obj_cache {
13
14 ObjectCacheRequest::ObjectCacheRequest() {}
15 ObjectCacheRequest::ObjectCacheRequest(uint16_t t, uint64_t s)
16 : type(t), seq(s) {}
17 ObjectCacheRequest::~ObjectCacheRequest() {}
18
19 void ObjectCacheRequest::encode() {
20 ENCODE_START(1, 1, payload);
21 ceph::encode(type, payload);
22 ceph::encode(seq, payload);
23 if (!payload_empty()) {
24 encode_payload();
25 }
26 ENCODE_FINISH(payload);
27 }
28
29 void ObjectCacheRequest::decode(bufferlist& bl) {
30 auto i = bl.cbegin();
31 DECODE_START(1, i);
32 ceph::decode(type, i);
33 ceph::decode(seq, i);
34 if (!payload_empty()) {
35 decode_payload(i);
36 }
37 DECODE_FINISH(i);
38 }
39
40 ObjectCacheRegData::ObjectCacheRegData() {}
41 ObjectCacheRegData::ObjectCacheRegData(uint16_t t, uint64_t s)
42 : ObjectCacheRequest(t, s) {}
43
44 ObjectCacheRegData::~ObjectCacheRegData() {}
45
46 void ObjectCacheRegData::encode_payload() {}
47
48 void ObjectCacheRegData::decode_payload(bufferlist::const_iterator i) {}
49
50 ObjectCacheRegReplyData::ObjectCacheRegReplyData() {}
51 ObjectCacheRegReplyData::ObjectCacheRegReplyData(uint16_t t, uint64_t s)
52 : ObjectCacheRequest(t, s) {}
53
54 ObjectCacheRegReplyData::~ObjectCacheRegReplyData() {}
55
56 void ObjectCacheRegReplyData::encode_payload() {}
57
58 void ObjectCacheRegReplyData::decode_payload(bufferlist::const_iterator bl) {}
59
60 ObjectCacheReadData::ObjectCacheReadData(uint16_t t, uint64_t s,
61 uint64_t read_offset,
62 uint64_t read_len,
63 uint64_t pool_id, uint64_t snap_id,
64 std::string oid,
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)
69 {}
70
71 ObjectCacheReadData::ObjectCacheReadData(uint16_t t, uint64_t s)
72 : ObjectCacheRequest(t, s) {}
73
74 ObjectCacheReadData::~ObjectCacheReadData() {}
75
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);
83 }
84
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);
90 ceph::decode(oid, i);
91 ceph::decode(pool_namespace, i);
92 }
93
94 ObjectCacheReadReplyData::ObjectCacheReadReplyData(uint16_t t, uint64_t s,
95 string cache_path)
96 : ObjectCacheRequest(t, s), cache_path(cache_path) {}
97 ObjectCacheReadReplyData::ObjectCacheReadReplyData(uint16_t t, uint64_t s)
98 : ObjectCacheRequest(t, s) {}
99
100 ObjectCacheReadReplyData::~ObjectCacheReadReplyData() {}
101
102 void ObjectCacheReadReplyData::encode_payload() {
103 ceph::encode(cache_path, payload);
104 }
105
106 void ObjectCacheReadReplyData::decode_payload(bufferlist::const_iterator i) {
107 ceph::decode(cache_path, i);
108 }
109
110 ObjectCacheReadRadosData::ObjectCacheReadRadosData() {}
111 ObjectCacheReadRadosData::ObjectCacheReadRadosData(uint16_t t, uint64_t s)
112 : ObjectCacheRequest(t, s) {}
113
114 ObjectCacheReadRadosData::~ObjectCacheReadRadosData() {}
115
116 void ObjectCacheReadRadosData::encode_payload() {}
117
118 void ObjectCacheReadRadosData::decode_payload(bufferlist::const_iterator i) {}
119
120 ObjectCacheRequest* decode_object_cache_request(bufferlist payload_buffer) {
121 ObjectCacheRequest* req = nullptr;
122
123 uint16_t type;
124 uint64_t seq;
125 auto i = payload_buffer.cbegin();
126 DECODE_START(1, i);
127 ceph::decode(type, i);
128 ceph::decode(seq, i);
129 DECODE_FINISH(i);
130
131 switch (type) {
132 case RBDSC_REGISTER: {
133 req = new ObjectCacheRegData(type, seq);
134 break;
135 }
136 case RBDSC_READ: {
137 req = new ObjectCacheReadData(type, seq);
138 break;
139 }
140 case RBDSC_REGISTER_REPLY: {
141 req = new ObjectCacheRegReplyData(type, seq);
142 break;
143 }
144 case RBDSC_READ_REPLY: {
145 req = new ObjectCacheReadReplyData(type, seq);
146 break;
147 }
148 case RBDSC_READ_RADOS: {
149 req = new ObjectCacheReadRadosData(type, seq);
150 break;
151 }
152 default:
153 ceph_assert(0);
154 }
155
156 req->decode(payload_buffer);
157
158 return req;
159 }
160
161 } // namespace immutable_obj_cache
162 } // namespace ceph