]>
Commit | Line | Data |
---|---|---|
f64942e4 AA |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | ||
7c673cae FG |
4 | #ifndef CEPH_CLS_RGW_TYPES_H |
5 | #define CEPH_CLS_RGW_TYPES_H | |
6 | ||
7c673cae FG |
7 | #include "common/ceph_time.h" |
8 | #include "common/Formatter.h" | |
9 | ||
10 | #include "rgw/rgw_basic_types.h" | |
11 | ||
12 | #define CEPH_RGW_REMOVE 'r' | |
13 | #define CEPH_RGW_UPDATE 'u' | |
14 | #define CEPH_RGW_TAG_TIMEOUT 120 | |
15 | #define CEPH_RGW_DIR_SUGGEST_LOG_OP 0x80 | |
16 | #define CEPH_RGW_DIR_SUGGEST_OP_MASK 0x7f | |
17 | ||
18 | class JSONObj; | |
19 | ||
20 | namespace ceph { | |
21 | class Formatter; | |
22 | } | |
11fdf7f2 | 23 | using ceph::operator <<; |
7c673cae | 24 | |
31f18b77 FG |
25 | using rgw_zone_set = std::set<std::string>; |
26 | ||
7c673cae FG |
27 | enum RGWPendingState { |
28 | CLS_RGW_STATE_PENDING_MODIFY = 0, | |
29 | CLS_RGW_STATE_COMPLETE = 1, | |
30 | CLS_RGW_STATE_UNKNOWN = 2, | |
31 | }; | |
32 | ||
33 | enum RGWModifyOp { | |
34 | CLS_RGW_OP_ADD = 0, | |
35 | CLS_RGW_OP_DEL = 1, | |
36 | CLS_RGW_OP_CANCEL = 2, | |
37 | CLS_RGW_OP_UNKNOWN = 3, | |
38 | CLS_RGW_OP_LINK_OLH = 4, | |
39 | CLS_RGW_OP_LINK_OLH_DM = 5, /* creation of delete marker */ | |
40 | CLS_RGW_OP_UNLINK_INSTANCE = 6, | |
c07f9fc5 FG |
41 | CLS_RGW_OP_SYNCSTOP = 7, |
42 | CLS_RGW_OP_RESYNC = 8, | |
7c673cae FG |
43 | }; |
44 | ||
45 | enum RGWBILogFlags { | |
46 | RGW_BILOG_FLAG_VERSIONED_OP = 0x1, | |
47 | }; | |
48 | ||
49 | enum RGWCheckMTimeType { | |
50 | CLS_RGW_CHECK_TIME_MTIME_EQ = 0, | |
51 | CLS_RGW_CHECK_TIME_MTIME_LT = 1, | |
52 | CLS_RGW_CHECK_TIME_MTIME_LE = 2, | |
53 | CLS_RGW_CHECK_TIME_MTIME_GT = 3, | |
54 | CLS_RGW_CHECK_TIME_MTIME_GE = 4, | |
55 | }; | |
56 | ||
57 | #define ROUND_BLOCK_SIZE 4096 | |
58 | ||
59 | static inline uint64_t cls_rgw_get_rounded_size(uint64_t size) | |
60 | { | |
61 | return (size + ROUND_BLOCK_SIZE - 1) & ~(ROUND_BLOCK_SIZE - 1); | |
62 | } | |
63 | ||
64 | struct rgw_bucket_pending_info { | |
65 | RGWPendingState state; | |
66 | ceph::real_time timestamp; | |
67 | uint8_t op; | |
68 | ||
69 | rgw_bucket_pending_info() : state(CLS_RGW_STATE_PENDING_MODIFY), op(0) {} | |
70 | ||
71 | void encode(bufferlist &bl) const { | |
72 | ENCODE_START(2, 2, bl); | |
73 | uint8_t s = (uint8_t)state; | |
11fdf7f2 TL |
74 | encode(s, bl); |
75 | encode(timestamp, bl); | |
76 | encode(op, bl); | |
7c673cae FG |
77 | ENCODE_FINISH(bl); |
78 | } | |
11fdf7f2 | 79 | void decode(bufferlist::const_iterator &bl) { |
7c673cae FG |
80 | DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl); |
81 | uint8_t s; | |
11fdf7f2 | 82 | decode(s, bl); |
7c673cae | 83 | state = (RGWPendingState)s; |
11fdf7f2 TL |
84 | decode(timestamp, bl); |
85 | decode(op, bl); | |
7c673cae FG |
86 | DECODE_FINISH(bl); |
87 | } | |
88 | void dump(Formatter *f) const; | |
89 | void decode_json(JSONObj *obj); | |
90 | static void generate_test_instances(list<rgw_bucket_pending_info*>& o); | |
91 | }; | |
92 | WRITE_CLASS_ENCODER(rgw_bucket_pending_info) | |
93 | ||
11fdf7f2 TL |
94 | |
95 | // categories of objects stored in a bucket index (b-i) and used to | |
96 | // differentiate their associated statistics (bucket stats, and in | |
97 | // some cases user stats) | |
98 | enum class RGWObjCategory : uint8_t { | |
99 | None = 0, // b-i entries for delete markers; also used in | |
100 | // testing and for default values in default | |
101 | // constructors | |
102 | ||
103 | Main = 1, // b-i entries for standard objs | |
104 | ||
105 | Shadow = 2, // presumfably intended for multipart shadow | |
106 | // uploads; not currently used in the codebase | |
107 | ||
108 | MultiMeta = 3, // b-i entries for multipart upload metadata objs | |
109 | }; | |
110 | ||
111 | ||
7c673cae | 112 | struct rgw_bucket_dir_entry_meta { |
11fdf7f2 | 113 | RGWObjCategory category; |
7c673cae FG |
114 | uint64_t size; |
115 | ceph::real_time mtime; | |
116 | string etag; | |
117 | string owner; | |
118 | string owner_display_name; | |
119 | string content_type; | |
120 | uint64_t accounted_size; | |
121 | string user_data; | |
11fdf7f2 TL |
122 | string storage_class; |
123 | bool appendable; | |
7c673cae FG |
124 | |
125 | rgw_bucket_dir_entry_meta() : | |
11fdf7f2 | 126 | category(RGWObjCategory::None), size(0), accounted_size(0), appendable(false) { } |
7c673cae FG |
127 | |
128 | void encode(bufferlist &bl) const { | |
11fdf7f2 TL |
129 | ENCODE_START(7, 3, bl); |
130 | encode(category, bl); | |
131 | encode(size, bl); | |
132 | encode(mtime, bl); | |
133 | encode(etag, bl); | |
134 | encode(owner, bl); | |
135 | encode(owner_display_name, bl); | |
136 | encode(content_type, bl); | |
137 | encode(accounted_size, bl); | |
138 | encode(user_data, bl); | |
139 | encode(storage_class, bl); | |
140 | encode(appendable, bl); | |
7c673cae FG |
141 | ENCODE_FINISH(bl); |
142 | } | |
11fdf7f2 TL |
143 | |
144 | void decode(bufferlist::const_iterator &bl) { | |
145 | DECODE_START_LEGACY_COMPAT_LEN(6, 3, 3, bl); | |
146 | decode(category, bl); | |
147 | decode(size, bl); | |
148 | decode(mtime, bl); | |
149 | decode(etag, bl); | |
150 | decode(owner, bl); | |
151 | decode(owner_display_name, bl); | |
7c673cae | 152 | if (struct_v >= 2) |
11fdf7f2 | 153 | decode(content_type, bl); |
7c673cae | 154 | if (struct_v >= 4) |
11fdf7f2 | 155 | decode(accounted_size, bl); |
7c673cae FG |
156 | else |
157 | accounted_size = size; | |
158 | if (struct_v >= 5) | |
11fdf7f2 TL |
159 | decode(user_data, bl); |
160 | if (struct_v >= 6) | |
161 | decode(storage_class, bl); | |
162 | if (struct_v >= 7) | |
163 | decode(appendable, bl); | |
7c673cae FG |
164 | DECODE_FINISH(bl); |
165 | } | |
166 | void dump(Formatter *f) const; | |
167 | void decode_json(JSONObj *obj); | |
168 | static void generate_test_instances(list<rgw_bucket_dir_entry_meta*>& o); | |
169 | }; | |
170 | WRITE_CLASS_ENCODER(rgw_bucket_dir_entry_meta) | |
171 | ||
172 | template<class T> | |
173 | void encode_packed_val(T val, bufferlist& bl) | |
174 | { | |
11fdf7f2 | 175 | using ceph::encode; |
7c673cae | 176 | if ((uint64_t)val < 0x80) { |
11fdf7f2 | 177 | encode((uint8_t)val, bl); |
7c673cae FG |
178 | } else { |
179 | unsigned char c = 0x80; | |
180 | ||
181 | if ((uint64_t)val < 0x100) { | |
182 | c |= 1; | |
11fdf7f2 TL |
183 | encode(c, bl); |
184 | encode((uint8_t)val, bl); | |
7c673cae FG |
185 | } else if ((uint64_t)val <= 0x10000) { |
186 | c |= 2; | |
11fdf7f2 TL |
187 | encode(c, bl); |
188 | encode((uint16_t)val, bl); | |
7c673cae FG |
189 | } else if ((uint64_t)val <= 0x1000000) { |
190 | c |= 4; | |
11fdf7f2 TL |
191 | encode(c, bl); |
192 | encode((uint32_t)val, bl); | |
7c673cae FG |
193 | } else { |
194 | c |= 8; | |
11fdf7f2 TL |
195 | encode(c, bl); |
196 | encode((uint64_t)val, bl); | |
7c673cae FG |
197 | } |
198 | } | |
199 | } | |
200 | ||
201 | template<class T> | |
11fdf7f2 | 202 | void decode_packed_val(T& val, bufferlist::const_iterator& bl) |
7c673cae | 203 | { |
11fdf7f2 | 204 | using ceph::decode; |
7c673cae | 205 | unsigned char c; |
11fdf7f2 | 206 | decode(c, bl); |
7c673cae FG |
207 | if (c < 0x80) { |
208 | val = c; | |
209 | return; | |
210 | } | |
211 | ||
212 | c &= ~0x80; | |
213 | ||
214 | switch (c) { | |
215 | case 1: | |
216 | { | |
217 | uint8_t v; | |
11fdf7f2 | 218 | decode(v, bl); |
7c673cae FG |
219 | val = v; |
220 | } | |
221 | break; | |
222 | case 2: | |
223 | { | |
224 | uint16_t v; | |
11fdf7f2 | 225 | decode(v, bl); |
7c673cae FG |
226 | val = v; |
227 | } | |
228 | break; | |
229 | case 4: | |
230 | { | |
231 | uint32_t v; | |
11fdf7f2 | 232 | decode(v, bl); |
7c673cae FG |
233 | val = v; |
234 | } | |
235 | break; | |
236 | case 8: | |
237 | { | |
238 | uint64_t v; | |
11fdf7f2 | 239 | decode(v, bl); |
7c673cae FG |
240 | val = v; |
241 | } | |
242 | break; | |
243 | default: | |
244 | throw buffer::error(); | |
245 | } | |
246 | } | |
247 | ||
248 | struct rgw_bucket_entry_ver { | |
249 | int64_t pool; | |
250 | uint64_t epoch; | |
251 | ||
252 | rgw_bucket_entry_ver() : pool(-1), epoch(0) {} | |
253 | ||
254 | void encode(bufferlist &bl) const { | |
255 | ENCODE_START(1, 1, bl); | |
11fdf7f2 TL |
256 | encode_packed_val(pool, bl); |
257 | encode_packed_val(epoch, bl); | |
7c673cae FG |
258 | ENCODE_FINISH(bl); |
259 | } | |
11fdf7f2 | 260 | void decode(bufferlist::const_iterator &bl) { |
7c673cae | 261 | DECODE_START(1, bl); |
11fdf7f2 TL |
262 | decode_packed_val(pool, bl); |
263 | decode_packed_val(epoch, bl); | |
7c673cae FG |
264 | DECODE_FINISH(bl); |
265 | } | |
266 | void dump(Formatter *f) const; | |
267 | void decode_json(JSONObj *obj); | |
268 | static void generate_test_instances(list<rgw_bucket_entry_ver*>& o); | |
269 | }; | |
270 | WRITE_CLASS_ENCODER(rgw_bucket_entry_ver) | |
271 | ||
272 | struct cls_rgw_obj_key { | |
273 | string name; | |
274 | string instance; | |
275 | ||
276 | cls_rgw_obj_key() {} | |
277 | cls_rgw_obj_key(const string &_name) : name(_name) {} | |
278 | cls_rgw_obj_key(const string& n, const string& i) : name(n), instance(i) {} | |
279 | ||
280 | void set(const string& _name) { | |
281 | name = _name; | |
282 | } | |
283 | ||
284 | bool operator==(const cls_rgw_obj_key& k) const { | |
285 | return (name.compare(k.name) == 0) && | |
286 | (instance.compare(k.instance) == 0); | |
287 | } | |
288 | bool operator<(const cls_rgw_obj_key& k) const { | |
289 | int r = name.compare(k.name); | |
290 | if (r == 0) { | |
291 | r = instance.compare(k.instance); | |
292 | } | |
293 | return (r < 0); | |
294 | } | |
295 | bool operator<=(const cls_rgw_obj_key& k) const { | |
296 | return !(k < *this); | |
297 | } | |
11fdf7f2 | 298 | bool empty() const { |
7c673cae FG |
299 | return name.empty(); |
300 | } | |
301 | void encode(bufferlist &bl) const { | |
302 | ENCODE_START(1, 1, bl); | |
11fdf7f2 TL |
303 | encode(name, bl); |
304 | encode(instance, bl); | |
7c673cae FG |
305 | ENCODE_FINISH(bl); |
306 | } | |
11fdf7f2 | 307 | void decode(bufferlist::const_iterator &bl) { |
7c673cae | 308 | DECODE_START(1, bl); |
11fdf7f2 TL |
309 | decode(name, bl); |
310 | decode(instance, bl); | |
7c673cae FG |
311 | DECODE_FINISH(bl); |
312 | } | |
313 | void dump(Formatter *f) const { | |
314 | f->dump_string("name", name); | |
315 | f->dump_string("instance", instance); | |
316 | } | |
317 | void decode_json(JSONObj *obj); | |
318 | static void generate_test_instances(list<cls_rgw_obj_key*>& ls) { | |
319 | ls.push_back(new cls_rgw_obj_key); | |
320 | ls.push_back(new cls_rgw_obj_key); | |
321 | ls.back()->name = "name"; | |
322 | ls.back()->instance = "instance"; | |
323 | } | |
324 | }; | |
325 | WRITE_CLASS_ENCODER(cls_rgw_obj_key) | |
326 | ||
327 | ||
328 | #define RGW_BUCKET_DIRENT_FLAG_VER 0x1 /* a versioned object instance */ | |
329 | #define RGW_BUCKET_DIRENT_FLAG_CURRENT 0x2 /* the last object instance of a versioned object */ | |
330 | #define RGW_BUCKET_DIRENT_FLAG_DELETE_MARKER 0x4 /* delete marker */ | |
331 | #define RGW_BUCKET_DIRENT_FLAG_VER_MARKER 0x8 /* object is versioned, a placeholder for the plain entry */ | |
332 | ||
333 | struct rgw_bucket_dir_entry { | |
334 | cls_rgw_obj_key key; | |
335 | rgw_bucket_entry_ver ver; | |
336 | std::string locator; | |
337 | bool exists; | |
11fdf7f2 TL |
338 | rgw_bucket_dir_entry_meta meta; |
339 | multimap<string, rgw_bucket_pending_info> pending_map; | |
7c673cae FG |
340 | uint64_t index_ver; |
341 | string tag; | |
342 | uint16_t flags; | |
343 | uint64_t versioned_epoch; | |
344 | ||
345 | rgw_bucket_dir_entry() : | |
346 | exists(false), index_ver(0), flags(0), versioned_epoch(0) {} | |
347 | ||
348 | void encode(bufferlist &bl) const { | |
349 | ENCODE_START(8, 3, bl); | |
11fdf7f2 TL |
350 | encode(key.name, bl); |
351 | encode(ver.epoch, bl); | |
352 | encode(exists, bl); | |
353 | encode(meta, bl); | |
354 | encode(pending_map, bl); | |
355 | encode(locator, bl); | |
356 | encode(ver, bl); | |
357 | encode_packed_val(index_ver, bl); | |
358 | encode(tag, bl); | |
359 | encode(key.instance, bl); | |
360 | encode(flags, bl); | |
361 | encode(versioned_epoch, bl); | |
7c673cae FG |
362 | ENCODE_FINISH(bl); |
363 | } | |
11fdf7f2 | 364 | void decode(bufferlist::const_iterator &bl) { |
7c673cae | 365 | DECODE_START_LEGACY_COMPAT_LEN(8, 3, 3, bl); |
11fdf7f2 TL |
366 | decode(key.name, bl); |
367 | decode(ver.epoch, bl); | |
368 | decode(exists, bl); | |
369 | decode(meta, bl); | |
370 | decode(pending_map, bl); | |
7c673cae | 371 | if (struct_v >= 2) { |
11fdf7f2 | 372 | decode(locator, bl); |
7c673cae FG |
373 | } |
374 | if (struct_v >= 4) { | |
11fdf7f2 | 375 | decode(ver, bl); |
7c673cae FG |
376 | } else { |
377 | ver.pool = -1; | |
378 | } | |
379 | if (struct_v >= 5) { | |
11fdf7f2 TL |
380 | decode_packed_val(index_ver, bl); |
381 | decode(tag, bl); | |
7c673cae FG |
382 | } |
383 | if (struct_v >= 6) { | |
11fdf7f2 | 384 | decode(key.instance, bl); |
7c673cae FG |
385 | } |
386 | if (struct_v >= 7) { | |
11fdf7f2 | 387 | decode(flags, bl); |
7c673cae FG |
388 | } |
389 | if (struct_v >= 8) { | |
11fdf7f2 | 390 | decode(versioned_epoch, bl); |
7c673cae FG |
391 | } |
392 | DECODE_FINISH(bl); | |
393 | } | |
394 | ||
395 | bool is_current() { | |
396 | int test_flags = RGW_BUCKET_DIRENT_FLAG_VER | RGW_BUCKET_DIRENT_FLAG_CURRENT; | |
397 | return (flags & RGW_BUCKET_DIRENT_FLAG_VER) == 0 || | |
398 | (flags & test_flags) == test_flags; | |
399 | } | |
400 | bool is_delete_marker() { return (flags & RGW_BUCKET_DIRENT_FLAG_DELETE_MARKER) != 0; } | |
401 | bool is_visible() { | |
402 | return is_current() && !is_delete_marker(); | |
403 | } | |
404 | bool is_valid() { return (flags & RGW_BUCKET_DIRENT_FLAG_VER_MARKER) == 0; } | |
405 | ||
406 | void dump(Formatter *f) const; | |
407 | void decode_json(JSONObj *obj); | |
408 | static void generate_test_instances(list<rgw_bucket_dir_entry*>& o); | |
409 | }; | |
410 | WRITE_CLASS_ENCODER(rgw_bucket_dir_entry) | |
411 | ||
11fdf7f2 TL |
412 | enum class BIIndexType : uint8_t { |
413 | Invalid = 0, | |
414 | Plain = 1, | |
415 | Instance = 2, | |
416 | OLH = 3, | |
7c673cae FG |
417 | }; |
418 | ||
419 | struct rgw_bucket_category_stats; | |
420 | ||
421 | struct rgw_cls_bi_entry { | |
422 | BIIndexType type; | |
423 | string idx; | |
424 | bufferlist data; | |
425 | ||
11fdf7f2 | 426 | rgw_cls_bi_entry() : type(BIIndexType::Invalid) {} |
7c673cae FG |
427 | |
428 | void encode(bufferlist& bl) const { | |
429 | ENCODE_START(1, 1, bl); | |
11fdf7f2 TL |
430 | encode(type, bl); |
431 | encode(idx, bl); | |
432 | encode(data, bl); | |
7c673cae FG |
433 | ENCODE_FINISH(bl); |
434 | } | |
435 | ||
11fdf7f2 | 436 | void decode(bufferlist::const_iterator& bl) { |
7c673cae FG |
437 | DECODE_START(1, bl); |
438 | uint8_t c; | |
11fdf7f2 | 439 | decode(c, bl); |
7c673cae | 440 | type = (BIIndexType)c; |
11fdf7f2 TL |
441 | decode(idx, bl); |
442 | decode(data, bl); | |
7c673cae FG |
443 | DECODE_FINISH(bl); |
444 | } | |
445 | ||
446 | void dump(Formatter *f) const; | |
447 | void decode_json(JSONObj *obj, cls_rgw_obj_key *effective_key = NULL); | |
448 | ||
11fdf7f2 TL |
449 | bool get_info(cls_rgw_obj_key *key, RGWObjCategory *category, |
450 | rgw_bucket_category_stats *accounted_stats); | |
7c673cae FG |
451 | }; |
452 | WRITE_CLASS_ENCODER(rgw_cls_bi_entry) | |
453 | ||
454 | enum OLHLogOp { | |
455 | CLS_RGW_OLH_OP_UNKNOWN = 0, | |
456 | CLS_RGW_OLH_OP_LINK_OLH = 1, | |
457 | CLS_RGW_OLH_OP_UNLINK_OLH = 2, /* object does not exist */ | |
458 | CLS_RGW_OLH_OP_REMOVE_INSTANCE = 3, | |
459 | }; | |
460 | ||
461 | struct rgw_bucket_olh_log_entry { | |
462 | uint64_t epoch; | |
463 | OLHLogOp op; | |
464 | string op_tag; | |
465 | cls_rgw_obj_key key; | |
466 | bool delete_marker; | |
467 | ||
468 | rgw_bucket_olh_log_entry() : epoch(0), op(CLS_RGW_OLH_OP_UNKNOWN), delete_marker(false) {} | |
469 | ||
470 | ||
471 | void encode(bufferlist &bl) const { | |
472 | ENCODE_START(1, 1, bl); | |
11fdf7f2 TL |
473 | encode(epoch, bl); |
474 | encode((__u8)op, bl); | |
475 | encode(op_tag, bl); | |
476 | encode(key, bl); | |
477 | encode(delete_marker, bl); | |
7c673cae FG |
478 | ENCODE_FINISH(bl); |
479 | } | |
11fdf7f2 | 480 | void decode(bufferlist::const_iterator &bl) { |
7c673cae | 481 | DECODE_START(1, bl); |
11fdf7f2 | 482 | decode(epoch, bl); |
7c673cae | 483 | uint8_t c; |
11fdf7f2 | 484 | decode(c, bl); |
7c673cae | 485 | op = (OLHLogOp)c; |
11fdf7f2 TL |
486 | decode(op_tag, bl); |
487 | decode(key, bl); | |
488 | decode(delete_marker, bl); | |
7c673cae FG |
489 | DECODE_FINISH(bl); |
490 | } | |
491 | static void generate_test_instances(list<rgw_bucket_olh_log_entry*>& o); | |
492 | void dump(Formatter *f) const; | |
493 | void decode_json(JSONObj *obj); | |
494 | }; | |
495 | WRITE_CLASS_ENCODER(rgw_bucket_olh_log_entry) | |
496 | ||
497 | struct rgw_bucket_olh_entry { | |
498 | cls_rgw_obj_key key; | |
499 | bool delete_marker; | |
500 | uint64_t epoch; | |
501 | map<uint64_t, vector<struct rgw_bucket_olh_log_entry> > pending_log; | |
502 | string tag; | |
503 | bool exists; | |
504 | bool pending_removal; | |
505 | ||
506 | rgw_bucket_olh_entry() : delete_marker(false), epoch(0), exists(false), pending_removal(false) {} | |
507 | ||
508 | void encode(bufferlist &bl) const { | |
509 | ENCODE_START(1, 1, bl); | |
11fdf7f2 TL |
510 | encode(key, bl); |
511 | encode(delete_marker, bl); | |
512 | encode(epoch, bl); | |
513 | encode(pending_log, bl); | |
514 | encode(tag, bl); | |
515 | encode(exists, bl); | |
516 | encode(pending_removal, bl); | |
7c673cae FG |
517 | ENCODE_FINISH(bl); |
518 | } | |
11fdf7f2 | 519 | void decode(bufferlist::const_iterator &bl) { |
7c673cae | 520 | DECODE_START(1, bl); |
11fdf7f2 TL |
521 | decode(key, bl); |
522 | decode(delete_marker, bl); | |
523 | decode(epoch, bl); | |
524 | decode(pending_log, bl); | |
525 | decode(tag, bl); | |
526 | decode(exists, bl); | |
527 | decode(pending_removal, bl); | |
7c673cae FG |
528 | DECODE_FINISH(bl); |
529 | } | |
530 | void dump(Formatter *f) const; | |
531 | void decode_json(JSONObj *obj); | |
532 | }; | |
533 | WRITE_CLASS_ENCODER(rgw_bucket_olh_entry) | |
534 | ||
535 | struct rgw_bi_log_entry { | |
536 | string id; | |
537 | string object; | |
538 | string instance; | |
539 | ceph::real_time timestamp; | |
540 | rgw_bucket_entry_ver ver; | |
541 | RGWModifyOp op; | |
542 | RGWPendingState state; | |
543 | uint64_t index_ver; | |
544 | string tag; | |
545 | uint16_t bilog_flags; | |
546 | string owner; /* only being set if it's a delete marker */ | |
547 | string owner_display_name; /* only being set if it's a delete marker */ | |
31f18b77 | 548 | rgw_zone_set zones_trace; |
7c673cae FG |
549 | |
550 | rgw_bi_log_entry() : op(CLS_RGW_OP_UNKNOWN), state(CLS_RGW_STATE_PENDING_MODIFY), index_ver(0), bilog_flags(0) {} | |
551 | ||
552 | void encode(bufferlist &bl) const { | |
31f18b77 | 553 | ENCODE_START(4, 1, bl); |
11fdf7f2 TL |
554 | encode(id, bl); |
555 | encode(object, bl); | |
556 | encode(timestamp, bl); | |
557 | encode(ver, bl); | |
558 | encode(tag, bl); | |
7c673cae | 559 | uint8_t c = (uint8_t)op; |
11fdf7f2 | 560 | encode(c, bl); |
7c673cae | 561 | c = (uint8_t)state; |
11fdf7f2 | 562 | encode(c, bl); |
7c673cae | 563 | encode_packed_val(index_ver, bl); |
11fdf7f2 TL |
564 | encode(instance, bl); |
565 | encode(bilog_flags, bl); | |
566 | encode(owner, bl); | |
567 | encode(owner_display_name, bl); | |
568 | encode(zones_trace, bl); | |
7c673cae FG |
569 | ENCODE_FINISH(bl); |
570 | } | |
11fdf7f2 | 571 | void decode(bufferlist::const_iterator &bl) { |
31f18b77 | 572 | DECODE_START(4, bl); |
11fdf7f2 TL |
573 | decode(id, bl); |
574 | decode(object, bl); | |
575 | decode(timestamp, bl); | |
576 | decode(ver, bl); | |
577 | decode(tag, bl); | |
7c673cae | 578 | uint8_t c; |
11fdf7f2 | 579 | decode(c, bl); |
7c673cae | 580 | op = (RGWModifyOp)c; |
11fdf7f2 | 581 | decode(c, bl); |
7c673cae FG |
582 | state = (RGWPendingState)c; |
583 | decode_packed_val(index_ver, bl); | |
584 | if (struct_v >= 2) { | |
11fdf7f2 TL |
585 | decode(instance, bl); |
586 | decode(bilog_flags, bl); | |
7c673cae FG |
587 | } |
588 | if (struct_v >= 3) { | |
11fdf7f2 TL |
589 | decode(owner, bl); |
590 | decode(owner_display_name, bl); | |
7c673cae | 591 | } |
31f18b77 | 592 | if (struct_v >= 4) { |
11fdf7f2 | 593 | decode(zones_trace, bl); |
31f18b77 | 594 | } |
7c673cae FG |
595 | DECODE_FINISH(bl); |
596 | } | |
597 | void dump(Formatter *f) const; | |
598 | void decode_json(JSONObj *obj); | |
599 | static void generate_test_instances(list<rgw_bi_log_entry*>& o); | |
600 | ||
601 | bool is_versioned() { | |
602 | return ((bilog_flags & RGW_BILOG_FLAG_VERSIONED_OP) != 0); | |
603 | } | |
604 | }; | |
605 | WRITE_CLASS_ENCODER(rgw_bi_log_entry) | |
606 | ||
607 | struct rgw_bucket_category_stats { | |
608 | uint64_t total_size; | |
609 | uint64_t total_size_rounded; | |
610 | uint64_t num_entries; | |
611 | uint64_t actual_size{0}; //< account for compression, encryption | |
612 | ||
613 | rgw_bucket_category_stats() : total_size(0), total_size_rounded(0), num_entries(0) {} | |
614 | ||
615 | void encode(bufferlist &bl) const { | |
616 | ENCODE_START(3, 2, bl); | |
11fdf7f2 TL |
617 | encode(total_size, bl); |
618 | encode(total_size_rounded, bl); | |
619 | encode(num_entries, bl); | |
620 | encode(actual_size, bl); | |
7c673cae FG |
621 | ENCODE_FINISH(bl); |
622 | } | |
11fdf7f2 | 623 | void decode(bufferlist::const_iterator &bl) { |
7c673cae | 624 | DECODE_START_LEGACY_COMPAT_LEN(3, 2, 2, bl); |
11fdf7f2 TL |
625 | decode(total_size, bl); |
626 | decode(total_size_rounded, bl); | |
627 | decode(num_entries, bl); | |
7c673cae | 628 | if (struct_v >= 3) { |
11fdf7f2 | 629 | decode(actual_size, bl); |
7c673cae FG |
630 | } else { |
631 | actual_size = total_size; | |
632 | } | |
633 | DECODE_FINISH(bl); | |
634 | } | |
635 | void dump(Formatter *f) const; | |
636 | static void generate_test_instances(list<rgw_bucket_category_stats*>& o); | |
637 | }; | |
638 | WRITE_CLASS_ENCODER(rgw_bucket_category_stats) | |
639 | ||
31f18b77 | 640 | enum cls_rgw_reshard_status { |
494da23a TL |
641 | CLS_RGW_RESHARD_NOT_RESHARDING = 0, |
642 | CLS_RGW_RESHARD_IN_PROGRESS = 1, | |
643 | CLS_RGW_RESHARD_DONE = 2, | |
31f18b77 FG |
644 | }; |
645 | ||
f64942e4 AA |
646 | static inline std::string to_string(const enum cls_rgw_reshard_status status) |
647 | { | |
648 | switch (status) { | |
494da23a TL |
649 | case CLS_RGW_RESHARD_NOT_RESHARDING: |
650 | return "not-resharding"; | |
f64942e4 AA |
651 | break; |
652 | case CLS_RGW_RESHARD_IN_PROGRESS: | |
494da23a | 653 | return "in-progress"; |
f64942e4 AA |
654 | break; |
655 | case CLS_RGW_RESHARD_DONE: | |
494da23a | 656 | return "done"; |
f64942e4 AA |
657 | break; |
658 | default: | |
659 | break; | |
660 | }; | |
661 | return "Unknown reshard status"; | |
662 | } | |
663 | ||
31f18b77 | 664 | struct cls_rgw_bucket_instance_entry { |
494da23a | 665 | cls_rgw_reshard_status reshard_status{CLS_RGW_RESHARD_NOT_RESHARDING}; |
31f18b77 FG |
666 | string new_bucket_instance_id; |
667 | int32_t num_shards{-1}; | |
668 | ||
669 | void encode(bufferlist& bl) const { | |
670 | ENCODE_START(1, 1, bl); | |
11fdf7f2 TL |
671 | encode((uint8_t)reshard_status, bl); |
672 | encode(new_bucket_instance_id, bl); | |
673 | encode(num_shards, bl); | |
31f18b77 FG |
674 | ENCODE_FINISH(bl); |
675 | } | |
676 | ||
11fdf7f2 | 677 | void decode(bufferlist::const_iterator& bl) { |
31f18b77 FG |
678 | DECODE_START(1, bl); |
679 | uint8_t s; | |
11fdf7f2 | 680 | decode(s, bl); |
31f18b77 | 681 | reshard_status = (cls_rgw_reshard_status)s; |
11fdf7f2 TL |
682 | decode(new_bucket_instance_id, bl); |
683 | decode(num_shards, bl); | |
31f18b77 FG |
684 | DECODE_FINISH(bl); |
685 | } | |
686 | ||
687 | void dump(Formatter *f) const; | |
688 | static void generate_test_instances(list<cls_rgw_bucket_instance_entry*>& o); | |
689 | ||
690 | void clear() { | |
494da23a | 691 | reshard_status = CLS_RGW_RESHARD_NOT_RESHARDING; |
31f18b77 FG |
692 | new_bucket_instance_id.clear(); |
693 | } | |
694 | ||
695 | void set_status(const string& new_instance_id, int32_t new_num_shards, cls_rgw_reshard_status s) { | |
696 | reshard_status = s; | |
697 | new_bucket_instance_id = new_instance_id; | |
698 | num_shards = new_num_shards; | |
699 | } | |
700 | ||
701 | bool resharding() const { | |
494da23a | 702 | return reshard_status != CLS_RGW_RESHARD_NOT_RESHARDING; |
31f18b77 FG |
703 | } |
704 | bool resharding_in_progress() const { | |
705 | return reshard_status == CLS_RGW_RESHARD_IN_PROGRESS; | |
706 | } | |
707 | }; | |
708 | WRITE_CLASS_ENCODER(cls_rgw_bucket_instance_entry) | |
709 | ||
7c673cae | 710 | struct rgw_bucket_dir_header { |
11fdf7f2 | 711 | map<RGWObjCategory, rgw_bucket_category_stats> stats; |
7c673cae FG |
712 | uint64_t tag_timeout; |
713 | uint64_t ver; | |
714 | uint64_t master_ver; | |
715 | string max_marker; | |
31f18b77 | 716 | cls_rgw_bucket_instance_entry new_instance; |
c07f9fc5 | 717 | bool syncstopped; |
7c673cae | 718 | |
c07f9fc5 | 719 | rgw_bucket_dir_header() : tag_timeout(0), ver(0), master_ver(0), syncstopped(false) {} |
7c673cae FG |
720 | |
721 | void encode(bufferlist &bl) const { | |
c07f9fc5 | 722 | ENCODE_START(7, 2, bl); |
11fdf7f2 TL |
723 | encode(stats, bl); |
724 | encode(tag_timeout, bl); | |
725 | encode(ver, bl); | |
726 | encode(master_ver, bl); | |
727 | encode(max_marker, bl); | |
728 | encode(new_instance, bl); | |
729 | encode(syncstopped,bl); | |
7c673cae FG |
730 | ENCODE_FINISH(bl); |
731 | } | |
11fdf7f2 | 732 | void decode(bufferlist::const_iterator &bl) { |
31f18b77 | 733 | DECODE_START_LEGACY_COMPAT_LEN(6, 2, 2, bl); |
11fdf7f2 | 734 | decode(stats, bl); |
7c673cae | 735 | if (struct_v > 2) { |
11fdf7f2 | 736 | decode(tag_timeout, bl); |
7c673cae FG |
737 | } else { |
738 | tag_timeout = 0; | |
739 | } | |
740 | if (struct_v >= 4) { | |
11fdf7f2 TL |
741 | decode(ver, bl); |
742 | decode(master_ver, bl); | |
7c673cae FG |
743 | } else { |
744 | ver = 0; | |
745 | } | |
746 | if (struct_v >= 5) { | |
11fdf7f2 | 747 | decode(max_marker, bl); |
7c673cae | 748 | } |
31f18b77 | 749 | if (struct_v >= 6) { |
11fdf7f2 | 750 | decode(new_instance, bl); |
31f18b77 FG |
751 | } else { |
752 | new_instance = cls_rgw_bucket_instance_entry(); | |
753 | } | |
c07f9fc5 | 754 | if (struct_v >= 7) { |
11fdf7f2 | 755 | decode(syncstopped,bl); |
c07f9fc5 | 756 | } |
7c673cae FG |
757 | DECODE_FINISH(bl); |
758 | } | |
759 | void dump(Formatter *f) const; | |
760 | static void generate_test_instances(list<rgw_bucket_dir_header*>& o); | |
31f18b77 FG |
761 | |
762 | bool resharding() const { | |
763 | return new_instance.resharding(); | |
764 | } | |
765 | bool resharding_in_progress() const { | |
766 | return new_instance.resharding_in_progress(); | |
767 | } | |
7c673cae FG |
768 | }; |
769 | WRITE_CLASS_ENCODER(rgw_bucket_dir_header) | |
770 | ||
771 | struct rgw_bucket_dir { | |
11fdf7f2 TL |
772 | rgw_bucket_dir_header header; |
773 | std::map<string, rgw_bucket_dir_entry> m; | |
7c673cae FG |
774 | |
775 | void encode(bufferlist &bl) const { | |
776 | ENCODE_START(2, 2, bl); | |
11fdf7f2 TL |
777 | encode(header, bl); |
778 | encode(m, bl); | |
7c673cae FG |
779 | ENCODE_FINISH(bl); |
780 | } | |
11fdf7f2 | 781 | void decode(bufferlist::const_iterator &bl) { |
7c673cae | 782 | DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl); |
11fdf7f2 TL |
783 | decode(header, bl); |
784 | decode(m, bl); | |
7c673cae FG |
785 | DECODE_FINISH(bl); |
786 | } | |
787 | void dump(Formatter *f) const; | |
788 | static void generate_test_instances(list<rgw_bucket_dir*>& o); | |
789 | }; | |
790 | WRITE_CLASS_ENCODER(rgw_bucket_dir) | |
791 | ||
792 | struct rgw_usage_data { | |
793 | uint64_t bytes_sent; | |
794 | uint64_t bytes_received; | |
795 | uint64_t ops; | |
796 | uint64_t successful_ops; | |
797 | ||
798 | rgw_usage_data() : bytes_sent(0), bytes_received(0), ops(0), successful_ops(0) {} | |
799 | rgw_usage_data(uint64_t sent, uint64_t received) : bytes_sent(sent), bytes_received(received), ops(0), successful_ops(0) {} | |
800 | ||
801 | void encode(bufferlist& bl) const { | |
802 | ENCODE_START(1, 1, bl); | |
11fdf7f2 TL |
803 | encode(bytes_sent, bl); |
804 | encode(bytes_received, bl); | |
805 | encode(ops, bl); | |
806 | encode(successful_ops, bl); | |
7c673cae FG |
807 | ENCODE_FINISH(bl); |
808 | } | |
809 | ||
11fdf7f2 | 810 | void decode(bufferlist::const_iterator& bl) { |
7c673cae | 811 | DECODE_START(1, bl); |
11fdf7f2 TL |
812 | decode(bytes_sent, bl); |
813 | decode(bytes_received, bl); | |
814 | decode(ops, bl); | |
815 | decode(successful_ops, bl); | |
7c673cae FG |
816 | DECODE_FINISH(bl); |
817 | } | |
818 | ||
819 | void aggregate(const rgw_usage_data& usage) { | |
820 | bytes_sent += usage.bytes_sent; | |
821 | bytes_received += usage.bytes_received; | |
822 | ops += usage.ops; | |
823 | successful_ops += usage.successful_ops; | |
824 | } | |
825 | }; | |
826 | WRITE_CLASS_ENCODER(rgw_usage_data) | |
827 | ||
828 | ||
829 | struct rgw_usage_log_entry { | |
830 | rgw_user owner; | |
831 | rgw_user payer; /* if empty, same as owner */ | |
832 | string bucket; | |
833 | uint64_t epoch; | |
834 | rgw_usage_data total_usage; /* this one is kept for backwards compatibility */ | |
835 | map<string, rgw_usage_data> usage_map; | |
836 | ||
837 | rgw_usage_log_entry() : epoch(0) {} | |
838 | rgw_usage_log_entry(string& o, string& b) : owner(o), bucket(b), epoch(0) {} | |
839 | rgw_usage_log_entry(string& o, string& p, string& b) : owner(o), payer(p), bucket(b), epoch(0) {} | |
840 | ||
841 | void encode(bufferlist& bl) const { | |
842 | ENCODE_START(3, 1, bl); | |
11fdf7f2 TL |
843 | encode(owner.to_str(), bl); |
844 | encode(bucket, bl); | |
845 | encode(epoch, bl); | |
846 | encode(total_usage.bytes_sent, bl); | |
847 | encode(total_usage.bytes_received, bl); | |
848 | encode(total_usage.ops, bl); | |
849 | encode(total_usage.successful_ops, bl); | |
850 | encode(usage_map, bl); | |
851 | encode(payer.to_str(), bl); | |
7c673cae FG |
852 | ENCODE_FINISH(bl); |
853 | } | |
854 | ||
855 | ||
11fdf7f2 | 856 | void decode(bufferlist::const_iterator& bl) { |
7c673cae FG |
857 | DECODE_START(3, bl); |
858 | string s; | |
11fdf7f2 | 859 | decode(s, bl); |
7c673cae | 860 | owner.from_str(s); |
11fdf7f2 TL |
861 | decode(bucket, bl); |
862 | decode(epoch, bl); | |
863 | decode(total_usage.bytes_sent, bl); | |
864 | decode(total_usage.bytes_received, bl); | |
865 | decode(total_usage.ops, bl); | |
866 | decode(total_usage.successful_ops, bl); | |
7c673cae FG |
867 | if (struct_v < 2) { |
868 | usage_map[""] = total_usage; | |
869 | } else { | |
11fdf7f2 | 870 | decode(usage_map, bl); |
7c673cae FG |
871 | } |
872 | if (struct_v >= 3) { | |
873 | string p; | |
11fdf7f2 | 874 | decode(p, bl); |
7c673cae FG |
875 | payer.from_str(p); |
876 | } | |
877 | DECODE_FINISH(bl); | |
878 | } | |
879 | ||
880 | void aggregate(const rgw_usage_log_entry& e, map<string, bool> *categories = NULL) { | |
881 | if (owner.empty()) { | |
882 | owner = e.owner; | |
883 | bucket = e.bucket; | |
884 | epoch = e.epoch; | |
885 | payer = e.payer; | |
886 | } | |
887 | ||
888 | map<string, rgw_usage_data>::const_iterator iter; | |
889 | for (iter = e.usage_map.begin(); iter != e.usage_map.end(); ++iter) { | |
890 | if (!categories || !categories->size() || categories->count(iter->first)) { | |
891 | add(iter->first, iter->second); | |
892 | } | |
893 | } | |
894 | } | |
895 | ||
896 | void sum(rgw_usage_data& usage, map<string, bool>& categories) const { | |
897 | usage = rgw_usage_data(); | |
898 | for (map<string, rgw_usage_data>::const_iterator iter = usage_map.begin(); iter != usage_map.end(); ++iter) { | |
899 | if (!categories.size() || categories.count(iter->first)) { | |
900 | usage.aggregate(iter->second); | |
901 | } | |
902 | } | |
903 | } | |
904 | ||
905 | void add(const string& category, const rgw_usage_data& data) { | |
906 | usage_map[category].aggregate(data); | |
907 | total_usage.aggregate(data); | |
908 | } | |
91327a77 AA |
909 | |
910 | void dump(Formatter* f) const; | |
911 | static void generate_test_instances(list<rgw_usage_log_entry*>& o); | |
912 | ||
7c673cae FG |
913 | }; |
914 | WRITE_CLASS_ENCODER(rgw_usage_log_entry) | |
915 | ||
916 | struct rgw_usage_log_info { | |
917 | vector<rgw_usage_log_entry> entries; | |
918 | ||
919 | void encode(bufferlist& bl) const { | |
920 | ENCODE_START(1, 1, bl); | |
11fdf7f2 | 921 | encode(entries, bl); |
7c673cae FG |
922 | ENCODE_FINISH(bl); |
923 | } | |
924 | ||
11fdf7f2 | 925 | void decode(bufferlist::const_iterator& bl) { |
7c673cae | 926 | DECODE_START(1, bl); |
11fdf7f2 | 927 | decode(entries, bl); |
7c673cae FG |
928 | DECODE_FINISH(bl); |
929 | } | |
930 | ||
931 | rgw_usage_log_info() {} | |
932 | }; | |
933 | WRITE_CLASS_ENCODER(rgw_usage_log_info) | |
934 | ||
935 | struct rgw_user_bucket { | |
936 | string user; | |
937 | string bucket; | |
938 | ||
939 | rgw_user_bucket() {} | |
940 | rgw_user_bucket(const string& u, const string& b) : user(u), bucket(b) {} | |
941 | ||
942 | void encode(bufferlist& bl) const { | |
943 | ENCODE_START(1, 1, bl); | |
11fdf7f2 TL |
944 | encode(user, bl); |
945 | encode(bucket, bl); | |
7c673cae FG |
946 | ENCODE_FINISH(bl); |
947 | } | |
948 | ||
11fdf7f2 | 949 | void decode(bufferlist::const_iterator& bl) { |
7c673cae | 950 | DECODE_START(1, bl); |
11fdf7f2 TL |
951 | decode(user, bl); |
952 | decode(bucket, bl); | |
7c673cae FG |
953 | DECODE_FINISH(bl); |
954 | } | |
955 | ||
956 | bool operator<(const rgw_user_bucket& ub2) const { | |
957 | int comp = user.compare(ub2.user); | |
958 | if (comp < 0) | |
959 | return true; | |
960 | else if (!comp) | |
961 | return bucket.compare(ub2.bucket) < 0; | |
962 | ||
963 | return false; | |
964 | } | |
965 | }; | |
966 | WRITE_CLASS_ENCODER(rgw_user_bucket) | |
967 | ||
968 | enum cls_rgw_gc_op { | |
969 | CLS_RGW_GC_DEL_OBJ, | |
970 | CLS_RGW_GC_DEL_BUCKET, | |
971 | }; | |
972 | ||
973 | struct cls_rgw_obj { | |
974 | string pool; | |
975 | cls_rgw_obj_key key; | |
976 | string loc; | |
977 | ||
978 | cls_rgw_obj() {} | |
979 | cls_rgw_obj(string& _p, cls_rgw_obj_key& _k) : pool(_p), key(_k) {} | |
980 | ||
981 | void encode(bufferlist& bl) const { | |
982 | ENCODE_START(2, 1, bl); | |
11fdf7f2 TL |
983 | encode(pool, bl); |
984 | encode(key.name, bl); | |
985 | encode(loc, bl); | |
986 | encode(key, bl); | |
7c673cae FG |
987 | ENCODE_FINISH(bl); |
988 | } | |
989 | ||
11fdf7f2 | 990 | void decode(bufferlist::const_iterator& bl) { |
7c673cae | 991 | DECODE_START(2, bl); |
11fdf7f2 TL |
992 | decode(pool, bl); |
993 | decode(key.name, bl); | |
994 | decode(loc, bl); | |
7c673cae | 995 | if (struct_v >= 2) { |
11fdf7f2 | 996 | decode(key, bl); |
7c673cae FG |
997 | } |
998 | DECODE_FINISH(bl); | |
999 | } | |
1000 | ||
1001 | void dump(Formatter *f) const { | |
1002 | f->dump_string("pool", pool); | |
1003 | f->dump_string("oid", key.name); | |
1004 | f->dump_string("key", loc); | |
1005 | f->dump_string("instance", key.instance); | |
1006 | } | |
1007 | static void generate_test_instances(list<cls_rgw_obj*>& ls) { | |
1008 | ls.push_back(new cls_rgw_obj); | |
1009 | ls.push_back(new cls_rgw_obj); | |
1010 | ls.back()->pool = "mypool"; | |
1011 | ls.back()->key.name = "myoid"; | |
1012 | ls.back()->loc = "mykey"; | |
1013 | } | |
1014 | }; | |
1015 | WRITE_CLASS_ENCODER(cls_rgw_obj) | |
1016 | ||
1017 | struct cls_rgw_obj_chain { | |
1018 | list<cls_rgw_obj> objs; | |
1019 | ||
1020 | cls_rgw_obj_chain() {} | |
1021 | ||
1022 | void push_obj(const string& pool, const cls_rgw_obj_key& key, const string& loc) { | |
1023 | cls_rgw_obj obj; | |
1024 | obj.pool = pool; | |
1025 | obj.key = key; | |
1026 | obj.loc = loc; | |
1027 | objs.push_back(obj); | |
1028 | } | |
1029 | ||
1030 | void encode(bufferlist& bl) const { | |
1031 | ENCODE_START(1, 1, bl); | |
11fdf7f2 | 1032 | encode(objs, bl); |
7c673cae FG |
1033 | ENCODE_FINISH(bl); |
1034 | } | |
1035 | ||
11fdf7f2 | 1036 | void decode(bufferlist::const_iterator& bl) { |
7c673cae | 1037 | DECODE_START(1, bl); |
11fdf7f2 | 1038 | decode(objs, bl); |
7c673cae FG |
1039 | DECODE_FINISH(bl); |
1040 | } | |
1041 | ||
1042 | void dump(Formatter *f) const { | |
1043 | f->open_array_section("objs"); | |
1044 | for (list<cls_rgw_obj>::const_iterator p = objs.begin(); p != objs.end(); ++p) { | |
1045 | f->open_object_section("obj"); | |
1046 | p->dump(f); | |
1047 | f->close_section(); | |
1048 | } | |
1049 | f->close_section(); | |
1050 | } | |
1051 | static void generate_test_instances(list<cls_rgw_obj_chain*>& ls) { | |
1052 | ls.push_back(new cls_rgw_obj_chain); | |
1053 | } | |
1054 | ||
1055 | bool empty() { | |
1056 | return objs.empty(); | |
1057 | } | |
1058 | }; | |
1059 | WRITE_CLASS_ENCODER(cls_rgw_obj_chain) | |
1060 | ||
1061 | struct cls_rgw_gc_obj_info | |
1062 | { | |
1063 | string tag; | |
1064 | cls_rgw_obj_chain chain; | |
1065 | ceph::real_time time; | |
1066 | ||
1067 | cls_rgw_gc_obj_info() {} | |
1068 | ||
1069 | void encode(bufferlist& bl) const { | |
1070 | ENCODE_START(1, 1, bl); | |
11fdf7f2 TL |
1071 | encode(tag, bl); |
1072 | encode(chain, bl); | |
1073 | encode(time, bl); | |
7c673cae FG |
1074 | ENCODE_FINISH(bl); |
1075 | } | |
1076 | ||
11fdf7f2 | 1077 | void decode(bufferlist::const_iterator& bl) { |
7c673cae | 1078 | DECODE_START(1, bl); |
11fdf7f2 TL |
1079 | decode(tag, bl); |
1080 | decode(chain, bl); | |
1081 | decode(time, bl); | |
7c673cae FG |
1082 | DECODE_FINISH(bl); |
1083 | } | |
1084 | ||
1085 | void dump(Formatter *f) const { | |
1086 | f->dump_string("tag", tag); | |
1087 | f->open_object_section("chain"); | |
1088 | chain.dump(f); | |
1089 | f->close_section(); | |
1090 | f->dump_stream("time") << time; | |
1091 | } | |
1092 | static void generate_test_instances(list<cls_rgw_gc_obj_info*>& ls) { | |
1093 | ls.push_back(new cls_rgw_gc_obj_info); | |
1094 | ls.push_back(new cls_rgw_gc_obj_info); | |
1095 | ls.back()->tag = "footag"; | |
1096 | ceph_timespec ts{21, 32}; | |
1097 | ls.back()->time = ceph::real_clock::from_ceph_timespec(ts); | |
1098 | } | |
1099 | }; | |
1100 | WRITE_CLASS_ENCODER(cls_rgw_gc_obj_info) | |
1101 | ||
1102 | struct cls_rgw_lc_obj_head | |
1103 | { | |
11fdf7f2 | 1104 | time_t start_date = 0; |
7c673cae FG |
1105 | string marker; |
1106 | ||
1107 | cls_rgw_lc_obj_head() {} | |
1108 | ||
1109 | void encode(bufferlist& bl) const { | |
1110 | ENCODE_START(1, 1, bl); | |
1111 | uint64_t t = start_date; | |
11fdf7f2 TL |
1112 | encode(t, bl); |
1113 | encode(marker, bl); | |
7c673cae FG |
1114 | ENCODE_FINISH(bl); |
1115 | } | |
1116 | ||
11fdf7f2 | 1117 | void decode(bufferlist::const_iterator& bl) { |
7c673cae FG |
1118 | DECODE_START(1, bl); |
1119 | uint64_t t; | |
11fdf7f2 | 1120 | decode(t, bl); |
7c673cae | 1121 | start_date = static_cast<time_t>(t); |
11fdf7f2 | 1122 | decode(marker, bl); |
7c673cae FG |
1123 | DECODE_FINISH(bl); |
1124 | } | |
1125 | ||
11fdf7f2 TL |
1126 | void dump(Formatter *f) const; |
1127 | static void generate_test_instances(list<cls_rgw_lc_obj_head*>& ls); | |
7c673cae FG |
1128 | }; |
1129 | WRITE_CLASS_ENCODER(cls_rgw_lc_obj_head) | |
1130 | ||
31f18b77 FG |
1131 | struct cls_rgw_reshard_entry |
1132 | { | |
1133 | ceph::real_time time; | |
1134 | string tenant; | |
1135 | string bucket_name; | |
1136 | string bucket_id; | |
1137 | string new_instance_id; | |
1138 | uint32_t old_num_shards{0}; | |
1139 | uint32_t new_num_shards{0}; | |
1140 | ||
1141 | cls_rgw_reshard_entry() {} | |
1142 | ||
1143 | void encode(bufferlist& bl) const { | |
1144 | ENCODE_START(1, 1, bl); | |
11fdf7f2 TL |
1145 | encode(time, bl); |
1146 | encode(tenant, bl); | |
1147 | encode(bucket_name, bl); | |
1148 | encode(bucket_id, bl); | |
1149 | encode(new_instance_id, bl); | |
1150 | encode(old_num_shards, bl); | |
1151 | encode(new_num_shards, bl); | |
31f18b77 FG |
1152 | ENCODE_FINISH(bl); |
1153 | } | |
1154 | ||
11fdf7f2 | 1155 | void decode(bufferlist::const_iterator& bl) { |
31f18b77 | 1156 | DECODE_START(1, bl); |
11fdf7f2 TL |
1157 | decode(time, bl); |
1158 | decode(tenant, bl); | |
1159 | decode(bucket_name, bl); | |
1160 | decode(bucket_id, bl); | |
1161 | decode(new_instance_id, bl); | |
1162 | decode(old_num_shards, bl); | |
1163 | decode(new_num_shards, bl); | |
31f18b77 FG |
1164 | DECODE_FINISH(bl); |
1165 | } | |
1166 | ||
1167 | void dump(Formatter *f) const; | |
1168 | static void generate_test_instances(list<cls_rgw_reshard_entry*>& o); | |
1169 | ||
1170 | static void generate_key(const string& tenant, const string& bucket_name, string *key); | |
1171 | void get_key(string *key) const; | |
1172 | }; | |
1173 | WRITE_CLASS_ENCODER(cls_rgw_reshard_entry) | |
1174 | ||
7c673cae | 1175 | #endif |