1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 #ifndef CEPH_CLS_RGW_TYPES_H
5 #define CEPH_CLS_RGW_TYPES_H
7 #include "common/ceph_time.h"
8 #include "common/Formatter.h"
10 #include "rgw/rgw_basic_types.h"
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
23 using ceph::operator <<;
25 using rgw_zone_set
= std::set
<std::string
>;
27 enum RGWPendingState
{
28 CLS_RGW_STATE_PENDING_MODIFY
= 0,
29 CLS_RGW_STATE_COMPLETE
= 1,
30 CLS_RGW_STATE_UNKNOWN
= 2,
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,
41 CLS_RGW_OP_SYNCSTOP
= 7,
42 CLS_RGW_OP_RESYNC
= 8,
46 RGW_BILOG_FLAG_VERSIONED_OP
= 0x1,
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,
57 #define ROUND_BLOCK_SIZE 4096
59 static inline uint64_t cls_rgw_get_rounded_size(uint64_t size
)
61 return (size
+ ROUND_BLOCK_SIZE
- 1) & ~(ROUND_BLOCK_SIZE
- 1);
64 struct rgw_bucket_pending_info
{
65 RGWPendingState state
;
66 ceph::real_time timestamp
;
69 rgw_bucket_pending_info() : state(CLS_RGW_STATE_PENDING_MODIFY
), op(0) {}
71 void encode(bufferlist
&bl
) const {
72 ENCODE_START(2, 2, bl
);
73 uint8_t s
= (uint8_t)state
;
75 encode(timestamp
, bl
);
79 void decode(bufferlist::const_iterator
&bl
) {
80 DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl
);
83 state
= (RGWPendingState
)s
;
84 decode(timestamp
, bl
);
88 void dump(Formatter
*f
) const;
89 void decode_json(JSONObj
*obj
);
90 static void generate_test_instances(list
<rgw_bucket_pending_info
*>& o
);
92 WRITE_CLASS_ENCODER(rgw_bucket_pending_info
)
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
103 Main
= 1, // b-i entries for standard objs
105 Shadow
= 2, // presumfably intended for multipart shadow
106 // uploads; not currently used in the codebase
108 MultiMeta
= 3, // b-i entries for multipart upload metadata objs
112 struct rgw_bucket_dir_entry_meta
{
113 RGWObjCategory category
;
115 ceph::real_time mtime
;
118 string owner_display_name
;
120 uint64_t accounted_size
;
122 string storage_class
;
125 rgw_bucket_dir_entry_meta() :
126 category(RGWObjCategory::None
), size(0), accounted_size(0), appendable(false) { }
128 void encode(bufferlist
&bl
) const {
129 ENCODE_START(7, 3, bl
);
130 encode(category
, 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
);
144 void decode(bufferlist::const_iterator
&bl
) {
145 DECODE_START_LEGACY_COMPAT_LEN(6, 3, 3, bl
);
146 decode(category
, bl
);
151 decode(owner_display_name
, bl
);
153 decode(content_type
, bl
);
155 decode(accounted_size
, bl
);
157 accounted_size
= size
;
159 decode(user_data
, bl
);
161 decode(storage_class
, bl
);
163 decode(appendable
, bl
);
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
);
170 WRITE_CLASS_ENCODER(rgw_bucket_dir_entry_meta
)
173 void encode_packed_val(T val
, bufferlist
& bl
)
176 if ((uint64_t)val
< 0x80) {
177 encode((uint8_t)val
, bl
);
179 unsigned char c
= 0x80;
181 if ((uint64_t)val
< 0x100) {
184 encode((uint8_t)val
, bl
);
185 } else if ((uint64_t)val
<= 0x10000) {
188 encode((uint16_t)val
, bl
);
189 } else if ((uint64_t)val
<= 0x1000000) {
192 encode((uint32_t)val
, bl
);
196 encode((uint64_t)val
, bl
);
202 void decode_packed_val(T
& val
, bufferlist::const_iterator
& bl
)
244 throw buffer::error();
248 struct rgw_bucket_entry_ver
{
252 rgw_bucket_entry_ver() : pool(-1), epoch(0) {}
254 void encode(bufferlist
&bl
) const {
255 ENCODE_START(1, 1, bl
);
256 encode_packed_val(pool
, bl
);
257 encode_packed_val(epoch
, bl
);
260 void decode(bufferlist::const_iterator
&bl
) {
262 decode_packed_val(pool
, bl
);
263 decode_packed_val(epoch
, bl
);
266 void dump(Formatter
*f
) const;
267 void decode_json(JSONObj
*obj
);
268 static void generate_test_instances(list
<rgw_bucket_entry_ver
*>& o
);
270 WRITE_CLASS_ENCODER(rgw_bucket_entry_ver
)
272 struct 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
) {}
280 void set(const string
& _name
) {
284 bool operator==(const cls_rgw_obj_key
& k
) const {
285 return (name
.compare(k
.name
) == 0) &&
286 (instance
.compare(k
.instance
) == 0);
288 bool operator<(const cls_rgw_obj_key
& k
) const {
289 int r
= name
.compare(k
.name
);
291 r
= instance
.compare(k
.instance
);
295 bool operator<=(const cls_rgw_obj_key
& k
) const {
301 void encode(bufferlist
&bl
) const {
302 ENCODE_START(1, 1, bl
);
304 encode(instance
, bl
);
307 void decode(bufferlist::const_iterator
&bl
) {
310 decode(instance
, bl
);
313 void dump(Formatter
*f
) const {
314 f
->dump_string("name", name
);
315 f
->dump_string("instance", instance
);
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";
325 WRITE_CLASS_ENCODER(cls_rgw_obj_key
)
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 */
333 struct rgw_bucket_dir_entry
{
335 rgw_bucket_entry_ver ver
;
338 rgw_bucket_dir_entry_meta meta
;
339 multimap
<string
, rgw_bucket_pending_info
> pending_map
;
343 uint64_t versioned_epoch
;
345 rgw_bucket_dir_entry() :
346 exists(false), index_ver(0), flags(0), versioned_epoch(0) {}
348 void encode(bufferlist
&bl
) const {
349 ENCODE_START(8, 3, bl
);
350 encode(key
.name
, bl
);
351 encode(ver
.epoch
, bl
);
354 encode(pending_map
, bl
);
357 encode_packed_val(index_ver
, bl
);
359 encode(key
.instance
, bl
);
361 encode(versioned_epoch
, bl
);
364 void decode(bufferlist::const_iterator
&bl
) {
365 DECODE_START_LEGACY_COMPAT_LEN(8, 3, 3, bl
);
366 decode(key
.name
, bl
);
367 decode(ver
.epoch
, bl
);
370 decode(pending_map
, bl
);
380 decode_packed_val(index_ver
, bl
);
384 decode(key
.instance
, bl
);
390 decode(versioned_epoch
, bl
);
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
;
400 bool is_delete_marker() { return (flags
& RGW_BUCKET_DIRENT_FLAG_DELETE_MARKER
) != 0; }
402 return is_current() && !is_delete_marker();
404 bool is_valid() { return (flags
& RGW_BUCKET_DIRENT_FLAG_VER_MARKER
) == 0; }
406 void dump(Formatter
*f
) const;
407 void decode_json(JSONObj
*obj
);
408 static void generate_test_instances(list
<rgw_bucket_dir_entry
*>& o
);
410 WRITE_CLASS_ENCODER(rgw_bucket_dir_entry
)
412 enum class BIIndexType
: uint8_t {
419 struct rgw_bucket_category_stats
;
421 struct rgw_cls_bi_entry
{
426 rgw_cls_bi_entry() : type(BIIndexType::Invalid
) {}
428 void encode(bufferlist
& bl
) const {
429 ENCODE_START(1, 1, bl
);
436 void decode(bufferlist::const_iterator
& bl
) {
440 type
= (BIIndexType
)c
;
446 void dump(Formatter
*f
) const;
447 void decode_json(JSONObj
*obj
, cls_rgw_obj_key
*effective_key
= NULL
);
449 bool get_info(cls_rgw_obj_key
*key
, RGWObjCategory
*category
,
450 rgw_bucket_category_stats
*accounted_stats
);
452 WRITE_CLASS_ENCODER(rgw_cls_bi_entry
)
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,
461 struct rgw_bucket_olh_log_entry
{
468 rgw_bucket_olh_log_entry() : epoch(0), op(CLS_RGW_OLH_OP_UNKNOWN
), delete_marker(false) {}
471 void encode(bufferlist
&bl
) const {
472 ENCODE_START(1, 1, bl
);
474 encode((__u8
)op
, bl
);
477 encode(delete_marker
, bl
);
480 void decode(bufferlist::const_iterator
&bl
) {
488 decode(delete_marker
, bl
);
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
);
495 WRITE_CLASS_ENCODER(rgw_bucket_olh_log_entry
)
497 struct rgw_bucket_olh_entry
{
501 map
<uint64_t, vector
<struct rgw_bucket_olh_log_entry
> > pending_log
;
504 bool pending_removal
;
506 rgw_bucket_olh_entry() : delete_marker(false), epoch(0), exists(false), pending_removal(false) {}
508 void encode(bufferlist
&bl
) const {
509 ENCODE_START(1, 1, bl
);
511 encode(delete_marker
, bl
);
513 encode(pending_log
, bl
);
516 encode(pending_removal
, bl
);
519 void decode(bufferlist::const_iterator
&bl
) {
522 decode(delete_marker
, bl
);
524 decode(pending_log
, bl
);
527 decode(pending_removal
, bl
);
530 void dump(Formatter
*f
) const;
531 void decode_json(JSONObj
*obj
);
533 WRITE_CLASS_ENCODER(rgw_bucket_olh_entry
)
535 struct rgw_bi_log_entry
{
539 ceph::real_time timestamp
;
540 rgw_bucket_entry_ver ver
;
542 RGWPendingState state
;
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 */
548 rgw_zone_set zones_trace
;
550 rgw_bi_log_entry() : op(CLS_RGW_OP_UNKNOWN
), state(CLS_RGW_STATE_PENDING_MODIFY
), index_ver(0), bilog_flags(0) {}
552 void encode(bufferlist
&bl
) const {
553 ENCODE_START(4, 1, bl
);
556 encode(timestamp
, bl
);
559 uint8_t c
= (uint8_t)op
;
563 encode_packed_val(index_ver
, bl
);
564 encode(instance
, bl
);
565 encode(bilog_flags
, bl
);
567 encode(owner_display_name
, bl
);
568 encode(zones_trace
, bl
);
571 void decode(bufferlist::const_iterator
&bl
) {
575 decode(timestamp
, bl
);
582 state
= (RGWPendingState
)c
;
583 decode_packed_val(index_ver
, bl
);
585 decode(instance
, bl
);
586 decode(bilog_flags
, bl
);
590 decode(owner_display_name
, bl
);
593 decode(zones_trace
, bl
);
597 void dump(Formatter
*f
) const;
598 void decode_json(JSONObj
*obj
);
599 static void generate_test_instances(list
<rgw_bi_log_entry
*>& o
);
601 bool is_versioned() {
602 return ((bilog_flags
& RGW_BILOG_FLAG_VERSIONED_OP
) != 0);
605 WRITE_CLASS_ENCODER(rgw_bi_log_entry
)
607 struct rgw_bucket_category_stats
{
609 uint64_t total_size_rounded
;
610 uint64_t num_entries
;
611 uint64_t actual_size
{0}; //< account for compression, encryption
613 rgw_bucket_category_stats() : total_size(0), total_size_rounded(0), num_entries(0) {}
615 void encode(bufferlist
&bl
) const {
616 ENCODE_START(3, 2, bl
);
617 encode(total_size
, bl
);
618 encode(total_size_rounded
, bl
);
619 encode(num_entries
, bl
);
620 encode(actual_size
, bl
);
623 void decode(bufferlist::const_iterator
&bl
) {
624 DECODE_START_LEGACY_COMPAT_LEN(3, 2, 2, bl
);
625 decode(total_size
, bl
);
626 decode(total_size_rounded
, bl
);
627 decode(num_entries
, bl
);
629 decode(actual_size
, bl
);
631 actual_size
= total_size
;
635 void dump(Formatter
*f
) const;
636 static void generate_test_instances(list
<rgw_bucket_category_stats
*>& o
);
638 WRITE_CLASS_ENCODER(rgw_bucket_category_stats
)
640 enum cls_rgw_reshard_status
{
641 CLS_RGW_RESHARD_NOT_RESHARDING
= 0,
642 CLS_RGW_RESHARD_IN_PROGRESS
= 1,
643 CLS_RGW_RESHARD_DONE
= 2,
646 static inline std::string
to_string(const enum cls_rgw_reshard_status status
)
649 case CLS_RGW_RESHARD_NOT_RESHARDING
:
650 return "not-resharding";
652 case CLS_RGW_RESHARD_IN_PROGRESS
:
653 return "in-progress";
655 case CLS_RGW_RESHARD_DONE
:
661 return "Unknown reshard status";
664 struct cls_rgw_bucket_instance_entry
{
665 cls_rgw_reshard_status reshard_status
{CLS_RGW_RESHARD_NOT_RESHARDING
};
666 string new_bucket_instance_id
;
667 int32_t num_shards
{-1};
669 void encode(bufferlist
& bl
) const {
670 ENCODE_START(1, 1, bl
);
671 encode((uint8_t)reshard_status
, bl
);
672 encode(new_bucket_instance_id
, bl
);
673 encode(num_shards
, bl
);
677 void decode(bufferlist::const_iterator
& bl
) {
681 reshard_status
= (cls_rgw_reshard_status
)s
;
682 decode(new_bucket_instance_id
, bl
);
683 decode(num_shards
, bl
);
687 void dump(Formatter
*f
) const;
688 static void generate_test_instances(list
<cls_rgw_bucket_instance_entry
*>& o
);
691 reshard_status
= CLS_RGW_RESHARD_NOT_RESHARDING
;
692 new_bucket_instance_id
.clear();
695 void set_status(const string
& new_instance_id
, int32_t new_num_shards
, cls_rgw_reshard_status s
) {
697 new_bucket_instance_id
= new_instance_id
;
698 num_shards
= new_num_shards
;
701 bool resharding() const {
702 return reshard_status
!= CLS_RGW_RESHARD_NOT_RESHARDING
;
704 bool resharding_in_progress() const {
705 return reshard_status
== CLS_RGW_RESHARD_IN_PROGRESS
;
708 WRITE_CLASS_ENCODER(cls_rgw_bucket_instance_entry
)
710 struct rgw_bucket_dir_header
{
711 map
<RGWObjCategory
, rgw_bucket_category_stats
> stats
;
712 uint64_t tag_timeout
;
716 cls_rgw_bucket_instance_entry new_instance
;
719 rgw_bucket_dir_header() : tag_timeout(0), ver(0), master_ver(0), syncstopped(false) {}
721 void encode(bufferlist
&bl
) const {
722 ENCODE_START(7, 2, bl
);
724 encode(tag_timeout
, bl
);
726 encode(master_ver
, bl
);
727 encode(max_marker
, bl
);
728 encode(new_instance
, bl
);
729 encode(syncstopped
,bl
);
732 void decode(bufferlist::const_iterator
&bl
) {
733 DECODE_START_LEGACY_COMPAT_LEN(6, 2, 2, bl
);
736 decode(tag_timeout
, bl
);
742 decode(master_ver
, bl
);
747 decode(max_marker
, bl
);
750 decode(new_instance
, bl
);
752 new_instance
= cls_rgw_bucket_instance_entry();
755 decode(syncstopped
,bl
);
759 void dump(Formatter
*f
) const;
760 static void generate_test_instances(list
<rgw_bucket_dir_header
*>& o
);
762 bool resharding() const {
763 return new_instance
.resharding();
765 bool resharding_in_progress() const {
766 return new_instance
.resharding_in_progress();
769 WRITE_CLASS_ENCODER(rgw_bucket_dir_header
)
771 struct rgw_bucket_dir
{
772 rgw_bucket_dir_header header
;
773 std::map
<string
, rgw_bucket_dir_entry
> m
;
775 void encode(bufferlist
&bl
) const {
776 ENCODE_START(2, 2, bl
);
781 void decode(bufferlist::const_iterator
&bl
) {
782 DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl
);
787 void dump(Formatter
*f
) const;
788 static void generate_test_instances(list
<rgw_bucket_dir
*>& o
);
790 WRITE_CLASS_ENCODER(rgw_bucket_dir
)
792 struct rgw_usage_data
{
794 uint64_t bytes_received
;
796 uint64_t successful_ops
;
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) {}
801 void encode(bufferlist
& bl
) const {
802 ENCODE_START(1, 1, bl
);
803 encode(bytes_sent
, bl
);
804 encode(bytes_received
, bl
);
806 encode(successful_ops
, bl
);
810 void decode(bufferlist::const_iterator
& bl
) {
812 decode(bytes_sent
, bl
);
813 decode(bytes_received
, bl
);
815 decode(successful_ops
, bl
);
819 void aggregate(const rgw_usage_data
& usage
) {
820 bytes_sent
+= usage
.bytes_sent
;
821 bytes_received
+= usage
.bytes_received
;
823 successful_ops
+= usage
.successful_ops
;
826 WRITE_CLASS_ENCODER(rgw_usage_data
)
829 struct rgw_usage_log_entry
{
831 rgw_user payer
; /* if empty, same as owner */
834 rgw_usage_data total_usage
; /* this one is kept for backwards compatibility */
835 map
<string
, rgw_usage_data
> usage_map
;
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) {}
841 void encode(bufferlist
& bl
) const {
842 ENCODE_START(3, 1, bl
);
843 encode(owner
.to_str(), 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
);
856 void decode(bufferlist::const_iterator
& 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
);
868 usage_map
[""] = total_usage
;
870 decode(usage_map
, bl
);
880 void aggregate(const rgw_usage_log_entry
& e
, map
<string
, bool> *categories
= NULL
) {
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
);
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
);
905 void add(const string
& category
, const rgw_usage_data
& data
) {
906 usage_map
[category
].aggregate(data
);
907 total_usage
.aggregate(data
);
910 void dump(Formatter
* f
) const;
911 static void generate_test_instances(list
<rgw_usage_log_entry
*>& o
);
914 WRITE_CLASS_ENCODER(rgw_usage_log_entry
)
916 struct rgw_usage_log_info
{
917 vector
<rgw_usage_log_entry
> entries
;
919 void encode(bufferlist
& bl
) const {
920 ENCODE_START(1, 1, bl
);
925 void decode(bufferlist::const_iterator
& bl
) {
931 rgw_usage_log_info() {}
933 WRITE_CLASS_ENCODER(rgw_usage_log_info
)
935 struct rgw_user_bucket
{
940 rgw_user_bucket(const string
& u
, const string
& b
) : user(u
), bucket(b
) {}
942 void encode(bufferlist
& bl
) const {
943 ENCODE_START(1, 1, bl
);
949 void decode(bufferlist::const_iterator
& bl
) {
956 bool operator<(const rgw_user_bucket
& ub2
) const {
957 int comp
= user
.compare(ub2
.user
);
961 return bucket
.compare(ub2
.bucket
) < 0;
966 WRITE_CLASS_ENCODER(rgw_user_bucket
)
970 CLS_RGW_GC_DEL_BUCKET
,
979 cls_rgw_obj(string
& _p
, cls_rgw_obj_key
& _k
) : pool(_p
), key(_k
) {}
981 void encode(bufferlist
& bl
) const {
982 ENCODE_START(2, 1, bl
);
984 encode(key
.name
, bl
);
990 void decode(bufferlist::const_iterator
& bl
) {
993 decode(key
.name
, bl
);
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
);
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";
1015 WRITE_CLASS_ENCODER(cls_rgw_obj
)
1017 struct cls_rgw_obj_chain
{
1018 list
<cls_rgw_obj
> objs
;
1020 cls_rgw_obj_chain() {}
1022 void push_obj(const string
& pool
, const cls_rgw_obj_key
& key
, const string
& loc
) {
1027 objs
.push_back(obj
);
1030 void encode(bufferlist
& bl
) const {
1031 ENCODE_START(1, 1, bl
);
1036 void decode(bufferlist::const_iterator
& bl
) {
1037 DECODE_START(1, bl
);
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");
1051 static void generate_test_instances(list
<cls_rgw_obj_chain
*>& ls
) {
1052 ls
.push_back(new cls_rgw_obj_chain
);
1056 return objs
.empty();
1059 WRITE_CLASS_ENCODER(cls_rgw_obj_chain
)
1061 struct cls_rgw_gc_obj_info
1064 cls_rgw_obj_chain chain
;
1065 ceph::real_time time
;
1067 cls_rgw_gc_obj_info() {}
1069 void encode(bufferlist
& bl
) const {
1070 ENCODE_START(1, 1, bl
);
1077 void decode(bufferlist::const_iterator
& bl
) {
1078 DECODE_START(1, bl
);
1085 void dump(Formatter
*f
) const {
1086 f
->dump_string("tag", tag
);
1087 f
->open_object_section("chain");
1090 f
->dump_stream("time") << time
;
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
{init_le32(21), init_le32(32)};
1097 ls
.back()->time
= ceph::real_clock::from_ceph_timespec(ts
);
1100 WRITE_CLASS_ENCODER(cls_rgw_gc_obj_info
)
1102 struct cls_rgw_lc_obj_head
1104 time_t start_date
= 0;
1107 cls_rgw_lc_obj_head() {}
1109 void encode(bufferlist
& bl
) const {
1110 ENCODE_START(1, 1, bl
);
1111 uint64_t t
= start_date
;
1117 void decode(bufferlist::const_iterator
& bl
) {
1118 DECODE_START(1, bl
);
1121 start_date
= static_cast<time_t>(t
);
1126 void dump(Formatter
*f
) const;
1127 static void generate_test_instances(list
<cls_rgw_lc_obj_head
*>& ls
);
1129 WRITE_CLASS_ENCODER(cls_rgw_lc_obj_head
)
1131 struct cls_rgw_reshard_entry
1133 ceph::real_time time
;
1137 string new_instance_id
;
1138 uint32_t old_num_shards
{0};
1139 uint32_t new_num_shards
{0};
1141 cls_rgw_reshard_entry() {}
1143 void encode(bufferlist
& bl
) const {
1144 ENCODE_START(1, 1, 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
);
1155 void decode(bufferlist::const_iterator
& bl
) {
1156 DECODE_START(1, 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
);
1167 void dump(Formatter
*f
) const;
1168 static void generate_test_instances(list
<cls_rgw_reshard_entry
*>& o
);
1170 static void generate_key(const string
& tenant
, const string
& bucket_name
, string
*key
);
1171 void get_key(string
*key
) const;
1173 WRITE_CLASS_ENCODER(cls_rgw_reshard_entry
)