+inline bool operator==(const rgw_bucket_category_stats& lhs,
+ const rgw_bucket_category_stats& rhs) {
+ return lhs.total_size == rhs.total_size
+ && lhs.total_size_rounded == rhs.total_size_rounded
+ && lhs.num_entries == rhs.num_entries
+ && lhs.actual_size == rhs.actual_size;
+}
+inline bool operator!=(const rgw_bucket_category_stats& lhs,
+ const rgw_bucket_category_stats& rhs) {
+ return !(lhs == rhs);
+}
+
+enum class cls_rgw_reshard_status : uint8_t {
+ NOT_RESHARDING = 0,
+ IN_PROGRESS = 1,
+ DONE = 2
+};
+
+inline std::string to_string(const cls_rgw_reshard_status status)
+{
+ switch (status) {
+ case cls_rgw_reshard_status::NOT_RESHARDING:
+ return "not-resharding";
+ case cls_rgw_reshard_status::IN_PROGRESS:
+ return "in-progress";
+ case cls_rgw_reshard_status::DONE:
+ return "done";
+ };
+ return "Unknown reshard status";
+}
+
+struct cls_rgw_bucket_instance_entry {
+ using RESHARD_STATUS = cls_rgw_reshard_status;
+
+ cls_rgw_reshard_status reshard_status{RESHARD_STATUS::NOT_RESHARDING};
+ std::string new_bucket_instance_id;
+ int32_t num_shards{-1};
+
+ void encode(ceph::buffer::list& bl) const {
+ ENCODE_START(1, 1, bl);
+ encode((uint8_t)reshard_status, bl);
+ encode(new_bucket_instance_id, bl);
+ encode(num_shards, bl);
+ ENCODE_FINISH(bl);
+ }
+
+ void decode(ceph::buffer::list::const_iterator& bl) {
+ DECODE_START(1, bl);
+ uint8_t s;
+ decode(s, bl);
+ reshard_status = (cls_rgw_reshard_status)s;
+ decode(new_bucket_instance_id, bl);
+ decode(num_shards, bl);
+ DECODE_FINISH(bl);
+ }
+
+ void dump(ceph::Formatter *f) const;
+ static void generate_test_instances(std::list<cls_rgw_bucket_instance_entry*>& o);
+
+ void clear() {
+ reshard_status = RESHARD_STATUS::NOT_RESHARDING;
+ new_bucket_instance_id.clear();
+ }
+
+ void set_status(const std::string& new_instance_id,
+ int32_t new_num_shards,
+ cls_rgw_reshard_status s) {
+ reshard_status = s;
+ new_bucket_instance_id = new_instance_id;
+ num_shards = new_num_shards;
+ }
+
+ bool resharding() const {
+ return reshard_status != RESHARD_STATUS::NOT_RESHARDING;
+ }
+ bool resharding_in_progress() const {
+ return reshard_status == RESHARD_STATUS::IN_PROGRESS;
+ }
+};
+WRITE_CLASS_ENCODER(cls_rgw_bucket_instance_entry)
+
+using rgw_bucket_dir_stats = std::map<RGWObjCategory, rgw_bucket_category_stats>;
+