1 #ifndef CEPH_CLS_RGW_TYPES_H
2 #define CEPH_CLS_RGW_TYPES_H
4 #include "common/ceph_time.h"
5 #include "common/Formatter.h"
7 #include "rgw/rgw_basic_types.h"
9 #define CEPH_RGW_REMOVE 'r'
10 #define CEPH_RGW_UPDATE 'u'
11 #define CEPH_RGW_TAG_TIMEOUT 120
12 #define CEPH_RGW_DIR_SUGGEST_LOG_OP 0x80
13 #define CEPH_RGW_DIR_SUGGEST_OP_MASK 0x7f
21 using rgw_zone_set
= std::set
<std::string
>;
23 enum RGWPendingState
{
24 CLS_RGW_STATE_PENDING_MODIFY
= 0,
25 CLS_RGW_STATE_COMPLETE
= 1,
26 CLS_RGW_STATE_UNKNOWN
= 2,
32 CLS_RGW_OP_CANCEL
= 2,
33 CLS_RGW_OP_UNKNOWN
= 3,
34 CLS_RGW_OP_LINK_OLH
= 4,
35 CLS_RGW_OP_LINK_OLH_DM
= 5, /* creation of delete marker */
36 CLS_RGW_OP_UNLINK_INSTANCE
= 6,
37 CLS_RGW_OP_SYNCSTOP
= 7,
38 CLS_RGW_OP_RESYNC
= 8,
42 RGW_BILOG_FLAG_VERSIONED_OP
= 0x1,
45 enum RGWCheckMTimeType
{
46 CLS_RGW_CHECK_TIME_MTIME_EQ
= 0,
47 CLS_RGW_CHECK_TIME_MTIME_LT
= 1,
48 CLS_RGW_CHECK_TIME_MTIME_LE
= 2,
49 CLS_RGW_CHECK_TIME_MTIME_GT
= 3,
50 CLS_RGW_CHECK_TIME_MTIME_GE
= 4,
53 #define ROUND_BLOCK_SIZE 4096
55 static inline uint64_t cls_rgw_get_rounded_size(uint64_t size
)
57 return (size
+ ROUND_BLOCK_SIZE
- 1) & ~(ROUND_BLOCK_SIZE
- 1);
60 struct rgw_bucket_pending_info
{
61 RGWPendingState state
;
62 ceph::real_time timestamp
;
65 rgw_bucket_pending_info() : state(CLS_RGW_STATE_PENDING_MODIFY
), op(0) {}
67 void encode(bufferlist
&bl
) const {
68 ENCODE_START(2, 2, bl
);
69 uint8_t s
= (uint8_t)state
;
71 ::encode(timestamp
, bl
);
75 void decode(bufferlist::iterator
&bl
) {
76 DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl
);
79 state
= (RGWPendingState
)s
;
80 ::decode(timestamp
, bl
);
84 void dump(Formatter
*f
) const;
85 void decode_json(JSONObj
*obj
);
86 static void generate_test_instances(list
<rgw_bucket_pending_info
*>& o
);
88 WRITE_CLASS_ENCODER(rgw_bucket_pending_info
)
90 struct rgw_bucket_dir_entry_meta
{
93 ceph::real_time mtime
;
96 string owner_display_name
;
98 uint64_t accounted_size
;
101 rgw_bucket_dir_entry_meta() :
102 category(0), size(0), accounted_size(0) { }
104 void encode(bufferlist
&bl
) const {
105 ENCODE_START(5, 3, bl
);
106 ::encode(category
, bl
);
111 ::encode(owner_display_name
, bl
);
112 ::encode(content_type
, bl
);
113 ::encode(accounted_size
, bl
);
114 ::encode(user_data
, bl
);
117 void decode(bufferlist::iterator
&bl
) {
118 DECODE_START_LEGACY_COMPAT_LEN(5, 3, 3, bl
);
119 ::decode(category
, bl
);
124 ::decode(owner_display_name
, bl
);
126 ::decode(content_type
, bl
);
128 ::decode(accounted_size
, bl
);
130 accounted_size
= size
;
132 ::decode(user_data
, bl
);
135 void dump(Formatter
*f
) const;
136 void decode_json(JSONObj
*obj
);
137 static void generate_test_instances(list
<rgw_bucket_dir_entry_meta
*>& o
);
139 WRITE_CLASS_ENCODER(rgw_bucket_dir_entry_meta
)
142 void encode_packed_val(T val
, bufferlist
& bl
)
144 if ((uint64_t)val
< 0x80) {
145 ::encode((uint8_t)val
, bl
);
147 unsigned char c
= 0x80;
149 if ((uint64_t)val
< 0x100) {
152 ::encode((uint8_t)val
, bl
);
153 } else if ((uint64_t)val
<= 0x10000) {
156 ::encode((uint16_t)val
, bl
);
157 } else if ((uint64_t)val
<= 0x1000000) {
160 ::encode((uint32_t)val
, bl
);
164 ::encode((uint64_t)val
, bl
);
170 void decode_packed_val(T
& val
, bufferlist::iterator
& bl
)
211 throw buffer::error();
215 struct rgw_bucket_entry_ver
{
219 rgw_bucket_entry_ver() : pool(-1), epoch(0) {}
221 void encode(bufferlist
&bl
) const {
222 ENCODE_START(1, 1, bl
);
223 ::encode_packed_val(pool
, bl
);
224 ::encode_packed_val(epoch
, bl
);
227 void decode(bufferlist::iterator
&bl
) {
229 ::decode_packed_val(pool
, bl
);
230 ::decode_packed_val(epoch
, bl
);
233 void dump(Formatter
*f
) const;
234 void decode_json(JSONObj
*obj
);
235 static void generate_test_instances(list
<rgw_bucket_entry_ver
*>& o
);
237 WRITE_CLASS_ENCODER(rgw_bucket_entry_ver
)
239 struct cls_rgw_obj_key
{
244 cls_rgw_obj_key(const string
&_name
) : name(_name
) {}
245 cls_rgw_obj_key(const string
& n
, const string
& i
) : name(n
), instance(i
) {}
247 void set(const string
& _name
) {
251 bool operator==(const cls_rgw_obj_key
& k
) const {
252 return (name
.compare(k
.name
) == 0) &&
253 (instance
.compare(k
.instance
) == 0);
255 bool operator<(const cls_rgw_obj_key
& k
) const {
256 int r
= name
.compare(k
.name
);
258 r
= instance
.compare(k
.instance
);
262 bool operator<=(const cls_rgw_obj_key
& k
) const {
268 void encode(bufferlist
&bl
) const {
269 ENCODE_START(1, 1, bl
);
271 ::encode(instance
, bl
);
274 void decode(bufferlist::iterator
&bl
) {
277 ::decode(instance
, bl
);
280 void dump(Formatter
*f
) const {
281 f
->dump_string("name", name
);
282 f
->dump_string("instance", instance
);
284 void decode_json(JSONObj
*obj
);
285 static void generate_test_instances(list
<cls_rgw_obj_key
*>& ls
) {
286 ls
.push_back(new cls_rgw_obj_key
);
287 ls
.push_back(new cls_rgw_obj_key
);
288 ls
.back()->name
= "name";
289 ls
.back()->instance
= "instance";
292 WRITE_CLASS_ENCODER(cls_rgw_obj_key
)
295 #define RGW_BUCKET_DIRENT_FLAG_VER 0x1 /* a versioned object instance */
296 #define RGW_BUCKET_DIRENT_FLAG_CURRENT 0x2 /* the last object instance of a versioned object */
297 #define RGW_BUCKET_DIRENT_FLAG_DELETE_MARKER 0x4 /* delete marker */
298 #define RGW_BUCKET_DIRENT_FLAG_VER_MARKER 0x8 /* object is versioned, a placeholder for the plain entry */
300 struct rgw_bucket_dir_entry
{
302 rgw_bucket_entry_ver ver
;
305 struct rgw_bucket_dir_entry_meta meta
;
306 multimap
<string
, struct rgw_bucket_pending_info
> pending_map
;
310 uint64_t versioned_epoch
;
312 rgw_bucket_dir_entry() :
313 exists(false), index_ver(0), flags(0), versioned_epoch(0) {}
315 void encode(bufferlist
&bl
) const {
316 ENCODE_START(8, 3, bl
);
317 ::encode(key
.name
, bl
);
318 ::encode(ver
.epoch
, bl
);
319 ::encode(exists
, bl
);
321 ::encode(pending_map
, bl
);
322 ::encode(locator
, bl
);
324 ::encode_packed_val(index_ver
, bl
);
326 ::encode(key
.instance
, bl
);
328 ::encode(versioned_epoch
, bl
);
331 void decode(bufferlist::iterator
&bl
) {
332 DECODE_START_LEGACY_COMPAT_LEN(8, 3, 3, bl
);
333 ::decode(key
.name
, bl
);
334 ::decode(ver
.epoch
, bl
);
335 ::decode(exists
, bl
);
337 ::decode(pending_map
, bl
);
339 ::decode(locator
, bl
);
347 ::decode_packed_val(index_ver
, bl
);
351 ::decode(key
.instance
, bl
);
357 ::decode(versioned_epoch
, bl
);
363 int test_flags
= RGW_BUCKET_DIRENT_FLAG_VER
| RGW_BUCKET_DIRENT_FLAG_CURRENT
;
364 return (flags
& RGW_BUCKET_DIRENT_FLAG_VER
) == 0 ||
365 (flags
& test_flags
) == test_flags
;
367 bool is_delete_marker() { return (flags
& RGW_BUCKET_DIRENT_FLAG_DELETE_MARKER
) != 0; }
369 return is_current() && !is_delete_marker();
371 bool is_valid() { return (flags
& RGW_BUCKET_DIRENT_FLAG_VER_MARKER
) == 0; }
373 void dump(Formatter
*f
) const;
374 void decode_json(JSONObj
*obj
);
375 static void generate_test_instances(list
<rgw_bucket_dir_entry
*>& o
);
377 WRITE_CLASS_ENCODER(rgw_bucket_dir_entry
)
386 struct rgw_bucket_category_stats
;
388 struct rgw_cls_bi_entry
{
393 rgw_cls_bi_entry() : type(InvalidIdx
) {}
395 void encode(bufferlist
& bl
) const {
396 ENCODE_START(1, 1, bl
);
397 ::encode((uint8_t)type
, bl
);
403 void decode(bufferlist::iterator
& bl
) {
407 type
= (BIIndexType
)c
;
413 void dump(Formatter
*f
) const;
414 void decode_json(JSONObj
*obj
, cls_rgw_obj_key
*effective_key
= NULL
);
416 bool get_info(cls_rgw_obj_key
*key
, uint8_t *category
, rgw_bucket_category_stats
*accounted_stats
);
418 WRITE_CLASS_ENCODER(rgw_cls_bi_entry
)
421 CLS_RGW_OLH_OP_UNKNOWN
= 0,
422 CLS_RGW_OLH_OP_LINK_OLH
= 1,
423 CLS_RGW_OLH_OP_UNLINK_OLH
= 2, /* object does not exist */
424 CLS_RGW_OLH_OP_REMOVE_INSTANCE
= 3,
427 struct rgw_bucket_olh_log_entry
{
434 rgw_bucket_olh_log_entry() : epoch(0), op(CLS_RGW_OLH_OP_UNKNOWN
), delete_marker(false) {}
437 void encode(bufferlist
&bl
) const {
438 ENCODE_START(1, 1, bl
);
440 ::encode((__u8
)op
, bl
);
441 ::encode(op_tag
, bl
);
443 ::encode(delete_marker
, bl
);
446 void decode(bufferlist::iterator
&bl
) {
452 ::decode(op_tag
, bl
);
454 ::decode(delete_marker
, bl
);
457 static void generate_test_instances(list
<rgw_bucket_olh_log_entry
*>& o
);
458 void dump(Formatter
*f
) const;
459 void decode_json(JSONObj
*obj
);
461 WRITE_CLASS_ENCODER(rgw_bucket_olh_log_entry
)
463 struct rgw_bucket_olh_entry
{
467 map
<uint64_t, vector
<struct rgw_bucket_olh_log_entry
> > pending_log
;
470 bool pending_removal
;
472 rgw_bucket_olh_entry() : delete_marker(false), epoch(0), exists(false), pending_removal(false) {}
474 void encode(bufferlist
&bl
) const {
475 ENCODE_START(1, 1, bl
);
477 ::encode(delete_marker
, bl
);
479 ::encode(pending_log
, bl
);
481 ::encode(exists
, bl
);
482 ::encode(pending_removal
, bl
);
485 void decode(bufferlist::iterator
&bl
) {
488 ::decode(delete_marker
, bl
);
490 ::decode(pending_log
, bl
);
492 ::decode(exists
, bl
);
493 ::decode(pending_removal
, bl
);
496 void dump(Formatter
*f
) const;
497 void decode_json(JSONObj
*obj
);
499 WRITE_CLASS_ENCODER(rgw_bucket_olh_entry
)
501 struct rgw_bi_log_entry
{
505 ceph::real_time timestamp
;
506 rgw_bucket_entry_ver ver
;
508 RGWPendingState state
;
511 uint16_t bilog_flags
;
512 string owner
; /* only being set if it's a delete marker */
513 string owner_display_name
; /* only being set if it's a delete marker */
514 rgw_zone_set zones_trace
;
516 rgw_bi_log_entry() : op(CLS_RGW_OP_UNKNOWN
), state(CLS_RGW_STATE_PENDING_MODIFY
), index_ver(0), bilog_flags(0) {}
518 void encode(bufferlist
&bl
) const {
519 ENCODE_START(4, 1, bl
);
521 ::encode(object
, bl
);
522 ::encode(timestamp
, bl
);
525 uint8_t c
= (uint8_t)op
;
529 encode_packed_val(index_ver
, bl
);
530 ::encode(instance
, bl
);
531 ::encode(bilog_flags
, bl
);
533 ::encode(owner_display_name
, bl
);
534 ::encode(zones_trace
, bl
);
537 void decode(bufferlist::iterator
&bl
) {
540 ::decode(object
, bl
);
541 ::decode(timestamp
, bl
);
548 state
= (RGWPendingState
)c
;
549 decode_packed_val(index_ver
, bl
);
551 ::decode(instance
, bl
);
552 ::decode(bilog_flags
, bl
);
556 ::decode(owner_display_name
, bl
);
559 ::decode(zones_trace
, bl
);
563 void dump(Formatter
*f
) const;
564 void decode_json(JSONObj
*obj
);
565 static void generate_test_instances(list
<rgw_bi_log_entry
*>& o
);
567 bool is_versioned() {
568 return ((bilog_flags
& RGW_BILOG_FLAG_VERSIONED_OP
) != 0);
571 WRITE_CLASS_ENCODER(rgw_bi_log_entry
)
573 struct rgw_bucket_category_stats
{
575 uint64_t total_size_rounded
;
576 uint64_t num_entries
;
577 uint64_t actual_size
{0}; //< account for compression, encryption
579 rgw_bucket_category_stats() : total_size(0), total_size_rounded(0), num_entries(0) {}
581 void encode(bufferlist
&bl
) const {
582 ENCODE_START(3, 2, bl
);
583 ::encode(total_size
, bl
);
584 ::encode(total_size_rounded
, bl
);
585 ::encode(num_entries
, bl
);
586 ::encode(actual_size
, bl
);
589 void decode(bufferlist::iterator
&bl
) {
590 DECODE_START_LEGACY_COMPAT_LEN(3, 2, 2, bl
);
591 ::decode(total_size
, bl
);
592 ::decode(total_size_rounded
, bl
);
593 ::decode(num_entries
, bl
);
595 ::decode(actual_size
, bl
);
597 actual_size
= total_size
;
601 void dump(Formatter
*f
) const;
602 static void generate_test_instances(list
<rgw_bucket_category_stats
*>& o
);
604 WRITE_CLASS_ENCODER(rgw_bucket_category_stats
)
606 enum cls_rgw_reshard_status
{
607 CLS_RGW_RESHARD_NONE
= 0,
608 CLS_RGW_RESHARD_IN_PROGRESS
= 1,
609 CLS_RGW_RESHARD_DONE
= 2,
612 struct cls_rgw_bucket_instance_entry
{
613 cls_rgw_reshard_status reshard_status
{CLS_RGW_RESHARD_NONE
};
614 string new_bucket_instance_id
;
615 int32_t num_shards
{-1};
617 void encode(bufferlist
& bl
) const {
618 ENCODE_START(1, 1, bl
);
619 ::encode((uint8_t)reshard_status
, bl
);
620 ::encode(new_bucket_instance_id
, bl
);
621 ::encode(num_shards
, bl
);
625 void decode(bufferlist::iterator
& bl
) {
629 reshard_status
= (cls_rgw_reshard_status
)s
;
630 ::decode(new_bucket_instance_id
, bl
);
631 ::decode(num_shards
, bl
);
635 void dump(Formatter
*f
) const;
636 static void generate_test_instances(list
<cls_rgw_bucket_instance_entry
*>& o
);
639 reshard_status
= CLS_RGW_RESHARD_NONE
;
640 new_bucket_instance_id
.clear();
643 void set_status(const string
& new_instance_id
, int32_t new_num_shards
, cls_rgw_reshard_status s
) {
645 new_bucket_instance_id
= new_instance_id
;
646 num_shards
= new_num_shards
;
649 bool resharding() const {
650 return reshard_status
!= CLS_RGW_RESHARD_NONE
;
652 bool resharding_in_progress() const {
653 return reshard_status
== CLS_RGW_RESHARD_IN_PROGRESS
;
656 WRITE_CLASS_ENCODER(cls_rgw_bucket_instance_entry
)
658 struct rgw_bucket_dir_header
{
659 map
<uint8_t, rgw_bucket_category_stats
> stats
;
660 uint64_t tag_timeout
;
664 cls_rgw_bucket_instance_entry new_instance
;
667 rgw_bucket_dir_header() : tag_timeout(0), ver(0), master_ver(0), syncstopped(false) {}
669 void encode(bufferlist
&bl
) const {
670 ENCODE_START(7, 2, bl
);
672 ::encode(tag_timeout
, bl
);
674 ::encode(master_ver
, bl
);
675 ::encode(max_marker
, bl
);
676 ::encode(new_instance
, bl
);
677 ::encode(syncstopped
,bl
);
680 void decode(bufferlist::iterator
&bl
) {
681 DECODE_START_LEGACY_COMPAT_LEN(6, 2, 2, bl
);
684 ::decode(tag_timeout
, bl
);
690 ::decode(master_ver
, bl
);
695 ::decode(max_marker
, bl
);
698 ::decode(new_instance
, bl
);
700 new_instance
= cls_rgw_bucket_instance_entry();
703 ::decode(syncstopped
,bl
);
707 void dump(Formatter
*f
) const;
708 static void generate_test_instances(list
<rgw_bucket_dir_header
*>& o
);
710 bool resharding() const {
711 return new_instance
.resharding();
713 bool resharding_in_progress() const {
714 return new_instance
.resharding_in_progress();
717 WRITE_CLASS_ENCODER(rgw_bucket_dir_header
)
719 struct rgw_bucket_dir
{
720 struct rgw_bucket_dir_header header
;
721 std::map
<string
, struct rgw_bucket_dir_entry
> m
;
723 void encode(bufferlist
&bl
) const {
724 ENCODE_START(2, 2, bl
);
725 ::encode(header
, bl
);
729 void decode(bufferlist::iterator
&bl
) {
730 DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl
);
731 ::decode(header
, bl
);
735 void dump(Formatter
*f
) const;
736 static void generate_test_instances(list
<rgw_bucket_dir
*>& o
);
738 WRITE_CLASS_ENCODER(rgw_bucket_dir
)
740 struct rgw_usage_data
{
742 uint64_t bytes_received
;
744 uint64_t successful_ops
;
746 rgw_usage_data() : bytes_sent(0), bytes_received(0), ops(0), successful_ops(0) {}
747 rgw_usage_data(uint64_t sent
, uint64_t received
) : bytes_sent(sent
), bytes_received(received
), ops(0), successful_ops(0) {}
749 void encode(bufferlist
& bl
) const {
750 ENCODE_START(1, 1, bl
);
751 ::encode(bytes_sent
, bl
);
752 ::encode(bytes_received
, bl
);
754 ::encode(successful_ops
, bl
);
758 void decode(bufferlist::iterator
& bl
) {
760 ::decode(bytes_sent
, bl
);
761 ::decode(bytes_received
, bl
);
763 ::decode(successful_ops
, bl
);
767 void aggregate(const rgw_usage_data
& usage
) {
768 bytes_sent
+= usage
.bytes_sent
;
769 bytes_received
+= usage
.bytes_received
;
771 successful_ops
+= usage
.successful_ops
;
774 WRITE_CLASS_ENCODER(rgw_usage_data
)
777 struct rgw_usage_log_entry
{
779 rgw_user payer
; /* if empty, same as owner */
782 rgw_usage_data total_usage
; /* this one is kept for backwards compatibility */
783 map
<string
, rgw_usage_data
> usage_map
;
785 rgw_usage_log_entry() : epoch(0) {}
786 rgw_usage_log_entry(string
& o
, string
& b
) : owner(o
), bucket(b
), epoch(0) {}
787 rgw_usage_log_entry(string
& o
, string
& p
, string
& b
) : owner(o
), payer(p
), bucket(b
), epoch(0) {}
789 void encode(bufferlist
& bl
) const {
790 ENCODE_START(3, 1, bl
);
791 ::encode(owner
.to_str(), bl
);
792 ::encode(bucket
, bl
);
794 ::encode(total_usage
.bytes_sent
, bl
);
795 ::encode(total_usage
.bytes_received
, bl
);
796 ::encode(total_usage
.ops
, bl
);
797 ::encode(total_usage
.successful_ops
, bl
);
798 ::encode(usage_map
, bl
);
799 ::encode(payer
.to_str(), bl
);
804 void decode(bufferlist::iterator
& bl
) {
809 ::decode(bucket
, bl
);
811 ::decode(total_usage
.bytes_sent
, bl
);
812 ::decode(total_usage
.bytes_received
, bl
);
813 ::decode(total_usage
.ops
, bl
);
814 ::decode(total_usage
.successful_ops
, bl
);
816 usage_map
[""] = total_usage
;
818 ::decode(usage_map
, bl
);
828 void aggregate(const rgw_usage_log_entry
& e
, map
<string
, bool> *categories
= NULL
) {
836 map
<string
, rgw_usage_data
>::const_iterator iter
;
837 for (iter
= e
.usage_map
.begin(); iter
!= e
.usage_map
.end(); ++iter
) {
838 if (!categories
|| !categories
->size() || categories
->count(iter
->first
)) {
839 add(iter
->first
, iter
->second
);
844 void sum(rgw_usage_data
& usage
, map
<string
, bool>& categories
) const {
845 usage
= rgw_usage_data();
846 for (map
<string
, rgw_usage_data
>::const_iterator iter
= usage_map
.begin(); iter
!= usage_map
.end(); ++iter
) {
847 if (!categories
.size() || categories
.count(iter
->first
)) {
848 usage
.aggregate(iter
->second
);
853 void add(const string
& category
, const rgw_usage_data
& data
) {
854 usage_map
[category
].aggregate(data
);
855 total_usage
.aggregate(data
);
858 WRITE_CLASS_ENCODER(rgw_usage_log_entry
)
860 struct rgw_usage_log_info
{
861 vector
<rgw_usage_log_entry
> entries
;
863 void encode(bufferlist
& bl
) const {
864 ENCODE_START(1, 1, bl
);
865 ::encode(entries
, bl
);
869 void decode(bufferlist::iterator
& bl
) {
871 ::decode(entries
, bl
);
875 rgw_usage_log_info() {}
877 WRITE_CLASS_ENCODER(rgw_usage_log_info
)
879 struct rgw_user_bucket
{
884 rgw_user_bucket(const string
& u
, const string
& b
) : user(u
), bucket(b
) {}
886 void encode(bufferlist
& bl
) const {
887 ENCODE_START(1, 1, bl
);
889 ::encode(bucket
, bl
);
893 void decode(bufferlist::iterator
& bl
) {
896 ::decode(bucket
, bl
);
900 bool operator<(const rgw_user_bucket
& ub2
) const {
901 int comp
= user
.compare(ub2
.user
);
905 return bucket
.compare(ub2
.bucket
) < 0;
910 WRITE_CLASS_ENCODER(rgw_user_bucket
)
914 CLS_RGW_GC_DEL_BUCKET
,
923 cls_rgw_obj(string
& _p
, cls_rgw_obj_key
& _k
) : pool(_p
), key(_k
) {}
925 void encode(bufferlist
& bl
) const {
926 ENCODE_START(2, 1, bl
);
928 ::encode(key
.name
, bl
);
934 void decode(bufferlist::iterator
& bl
) {
937 ::decode(key
.name
, bl
);
945 void dump(Formatter
*f
) const {
946 f
->dump_string("pool", pool
);
947 f
->dump_string("oid", key
.name
);
948 f
->dump_string("key", loc
);
949 f
->dump_string("instance", key
.instance
);
951 static void generate_test_instances(list
<cls_rgw_obj
*>& ls
) {
952 ls
.push_back(new cls_rgw_obj
);
953 ls
.push_back(new cls_rgw_obj
);
954 ls
.back()->pool
= "mypool";
955 ls
.back()->key
.name
= "myoid";
956 ls
.back()->loc
= "mykey";
959 WRITE_CLASS_ENCODER(cls_rgw_obj
)
961 struct cls_rgw_obj_chain
{
962 list
<cls_rgw_obj
> objs
;
964 cls_rgw_obj_chain() {}
966 void push_obj(const string
& pool
, const cls_rgw_obj_key
& key
, const string
& loc
) {
974 void encode(bufferlist
& bl
) const {
975 ENCODE_START(1, 1, bl
);
980 void decode(bufferlist::iterator
& bl
) {
986 void dump(Formatter
*f
) const {
987 f
->open_array_section("objs");
988 for (list
<cls_rgw_obj
>::const_iterator p
= objs
.begin(); p
!= objs
.end(); ++p
) {
989 f
->open_object_section("obj");
995 static void generate_test_instances(list
<cls_rgw_obj_chain
*>& ls
) {
996 ls
.push_back(new cls_rgw_obj_chain
);
1000 return objs
.empty();
1003 WRITE_CLASS_ENCODER(cls_rgw_obj_chain
)
1005 struct cls_rgw_gc_obj_info
1008 cls_rgw_obj_chain chain
;
1009 ceph::real_time time
;
1011 cls_rgw_gc_obj_info() {}
1013 void encode(bufferlist
& bl
) const {
1014 ENCODE_START(1, 1, bl
);
1016 ::encode(chain
, bl
);
1021 void decode(bufferlist::iterator
& bl
) {
1022 DECODE_START(1, bl
);
1024 ::decode(chain
, bl
);
1029 void dump(Formatter
*f
) const {
1030 f
->dump_string("tag", tag
);
1031 f
->open_object_section("chain");
1034 f
->dump_stream("time") << time
;
1036 static void generate_test_instances(list
<cls_rgw_gc_obj_info
*>& ls
) {
1037 ls
.push_back(new cls_rgw_gc_obj_info
);
1038 ls
.push_back(new cls_rgw_gc_obj_info
);
1039 ls
.back()->tag
= "footag";
1040 ceph_timespec ts
{21, 32};
1041 ls
.back()->time
= ceph::real_clock::from_ceph_timespec(ts
);
1044 WRITE_CLASS_ENCODER(cls_rgw_gc_obj_info
)
1046 struct cls_rgw_lc_obj_head
1051 cls_rgw_lc_obj_head() {}
1053 void encode(bufferlist
& bl
) const {
1054 ENCODE_START(1, 1, bl
);
1055 uint64_t t
= start_date
;
1057 ::encode(marker
, bl
);
1061 void decode(bufferlist::iterator
& bl
) {
1062 DECODE_START(1, bl
);
1065 start_date
= static_cast<time_t>(t
);
1066 ::decode(marker
, bl
);
1071 WRITE_CLASS_ENCODER(cls_rgw_lc_obj_head
)
1073 struct cls_rgw_reshard_entry
1075 ceph::real_time time
;
1079 string new_instance_id
;
1080 uint32_t old_num_shards
{0};
1081 uint32_t new_num_shards
{0};
1083 cls_rgw_reshard_entry() {}
1085 void encode(bufferlist
& bl
) const {
1086 ENCODE_START(1, 1, bl
);
1088 ::encode(tenant
, bl
);
1089 ::encode(bucket_name
, bl
);
1090 ::encode(bucket_id
, bl
);
1091 ::encode(new_instance_id
, bl
);
1092 ::encode(old_num_shards
, bl
);
1093 ::encode(new_num_shards
, bl
);
1097 void decode(bufferlist::iterator
& bl
) {
1098 DECODE_START(1, bl
);
1100 ::decode(tenant
, bl
);
1101 ::decode(bucket_name
, bl
);
1102 ::decode(bucket_id
, bl
);
1103 ::decode(new_instance_id
, bl
);
1104 ::decode(old_num_shards
, bl
);
1105 ::decode(new_num_shards
, bl
);
1109 void dump(Formatter
*f
) const;
1110 static void generate_test_instances(list
<cls_rgw_reshard_entry
*>& o
);
1112 static void generate_key(const string
& tenant
, const string
& bucket_name
, string
*key
);
1113 void get_key(string
*key
) const;
1115 WRITE_CLASS_ENCODER(cls_rgw_reshard_entry
)