]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/cls/rgw/cls_rgw_types.h
import quincy beta 17.1.0
[ceph.git] / ceph / src / cls / rgw / cls_rgw_types.h
index 6098f1be65938209c774f4993afa82274301aa20..cdaebe5ce21cda47669ffb6a9826ffca2e07954e 100644 (file)
@@ -1,12 +1,17 @@
 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
 // vim: ts=8 sw=2 smarttab
 
-#ifndef CEPH_CLS_RGW_TYPES_H
-#define CEPH_CLS_RGW_TYPES_H
+#pragma once
 
+#include <string>
+#include <boost/container/flat_map.hpp>
 #include "common/ceph_time.h"
 #include "common/Formatter.h"
 
+#undef FMT_HEADER_ONLY
+#define FMT_HEADER_ONLY 1
+#include <fmt/format.h>
+
 #include "rgw/rgw_basic_types.h"
 
 #define CEPH_RGW_REMOVE 'r'
 
 class JSONObj;
 
-namespace ceph {
-  class Formatter;
-}
 using ceph::operator <<;
 
-using rgw_zone_set = std::set<std::string>;
+struct rgw_zone_set_entry {
+  std::string zone;
+  std::optional<std::string> location_key;
+
+  bool operator<(const rgw_zone_set_entry& e) const {
+    if (zone < e.zone) {
+      return true;
+    }
+    if (zone > e.zone) {
+      return false;
+    }
+    return (location_key < e.location_key);
+  }
+
+  rgw_zone_set_entry() {}
+  rgw_zone_set_entry(const std::string& _zone,
+                     std::optional<std::string> _location_key) : zone(_zone),
+                                                                location_key(_location_key) {}
+  rgw_zone_set_entry(const std::string& s) {
+    from_str(s);
+  }
+
+  void from_str(const std::string& s);
+  std::string to_str() const;
+
+  void encode(ceph::buffer::list &bl) const;
+  void decode(ceph::buffer::list::const_iterator &bl);
+
+  void dump(ceph::Formatter *f) const;
+  void decode_json(JSONObj *obj);
+};
+WRITE_CLASS_ENCODER(rgw_zone_set_entry)
+
+struct rgw_zone_set {
+  std::set<rgw_zone_set_entry> entries;
+
+  void encode(ceph::buffer::list &bl) const {
+    /* no ENCODE_START, ENCODE_END for backward compatibility */
+    ceph::encode(entries, bl);
+  }
+  void decode(ceph::buffer::list::const_iterator &bl) {
+    /* no DECODE_START, DECODE_END for backward compatibility */
+    ceph::decode(entries, bl);
+  }
+
+  void insert(const std::string& zone, std::optional<std::string> location_key);
+  bool exists(const std::string& zone, std::optional<std::string> location_key) const;
+};
+WRITE_CLASS_ENCODER(rgw_zone_set)
+
+/* backward compatibility, rgw_zone_set needs to encode/decode the same as std::set */
+void encode_json(const char *name, const rgw_zone_set& zs, ceph::Formatter *f);
+void decode_json_obj(rgw_zone_set& zs, JSONObj *obj);
+
 
 enum RGWPendingState {
   CLS_RGW_STATE_PENDING_MODIFY = 0,
@@ -42,6 +97,13 @@ enum RGWModifyOp {
   CLS_RGW_OP_RESYNC          = 8,
 };
 
+std::string_view to_string(RGWModifyOp op);
+RGWModifyOp parse_modify_op(std::string_view name);
+
+inline std::ostream& operator<<(std::ostream& out, RGWModifyOp op) {
+  return out << to_string(op);
+}
+
 enum RGWBILogFlags {
   RGW_BILOG_FLAG_VERSIONED_OP = 0x1,
 };
@@ -56,11 +118,23 @@ enum RGWCheckMTimeType {
 
 #define ROUND_BLOCK_SIZE 4096
 
-static inline uint64_t cls_rgw_get_rounded_size(uint64_t size)
-{
+inline uint64_t cls_rgw_get_rounded_size(uint64_t size) {
   return (size + ROUND_BLOCK_SIZE - 1) & ~(ROUND_BLOCK_SIZE - 1);
 }
 
+/*
+ * This takes a std::string that either wholly contains a delimiter or is a
+ * path that ends with a delimiter and appends a new character to the
+ * end such that when a we request bucket-index entries *after* this,
+ * we'll get the next object after the "subdirectory". This works
+ * because we append a '\xFF' charater, and no valid UTF-8 character
+ * can contain that byte, so no valid entries can be skipped.
+ */
+inline std::string cls_rgw_after_delim(const std::string& path) {
+  // assert: ! path.empty()
+  return path + '\xFF';
+}
+
 struct rgw_bucket_pending_info {
   RGWPendingState state;
   ceph::real_time timestamp;
@@ -68,7 +142,7 @@ struct rgw_bucket_pending_info {
 
   rgw_bucket_pending_info() : state(CLS_RGW_STATE_PENDING_MODIFY), op(0) {}
 
-  void encode(bufferlist &bl) const {
+  void encode(ceph::buffer::list &bl) const {
     ENCODE_START(2, 2, bl);
     uint8_t s = (uint8_t)state;
     encode(s, bl);
@@ -76,7 +150,7 @@ struct rgw_bucket_pending_info {
     encode(op, bl);
     ENCODE_FINISH(bl);
   }
-  void decode(bufferlist::const_iterator &bl) {
+  void decode(ceph::buffer::list::const_iterator &bl) {
     DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl);
     uint8_t s;
     decode(s, bl);
@@ -85,9 +159,9 @@ struct rgw_bucket_pending_info {
     decode(op, bl);
     DECODE_FINISH(bl);
   }
-  void dump(Formatter *f) const;
+  void dump(ceph::Formatter *f) const;
   void decode_json(JSONObj *obj);
-  static void generate_test_instances(list<rgw_bucket_pending_info*>& o);
+  static void generate_test_instances(std::list<rgw_bucket_pending_info*>& o);
 };
 WRITE_CLASS_ENCODER(rgw_bucket_pending_info)
 
@@ -106,26 +180,33 @@ enum class RGWObjCategory : uint8_t {
                   // uploads; not currently used in the codebase
 
   MultiMeta = 3,  // b-i entries for multipart upload metadata objs
+
+  CloudTiered = 4, // b-i entries which are tiered to external cloud
 };
 
+std::string_view to_string(RGWObjCategory c);
+
+inline std::ostream& operator<<(std::ostream& out, RGWObjCategory c) {
+  return out << to_string(c);
+}
 
 struct rgw_bucket_dir_entry_meta {
   RGWObjCategory category;
   uint64_t size;
   ceph::real_time mtime;
-  string etag;
-  string owner;
-  string owner_display_name;
-  string content_type;
+  std::string etag;
+  std::string owner;
+  std::string owner_display_name;
+  std::string content_type;
   uint64_t accounted_size;
-  string user_data;
-  string storage_class;
+  std::string user_data;
+  std::string storage_class;
   bool appendable;
 
   rgw_bucket_dir_entry_meta() :
     category(RGWObjCategory::None), size(0), accounted_size(0), appendable(false) { }
 
-  void encode(bufferlist &bl) const {
+  void encode(ceph::buffer::list &bl) const {
     ENCODE_START(7, 3, bl);
     encode(category, bl);
     encode(size, bl);
@@ -141,7 +222,7 @@ struct rgw_bucket_dir_entry_meta {
     ENCODE_FINISH(bl);
   }
 
-  void decode(bufferlist::const_iterator &bl) {
+  void decode(ceph::buffer::list::const_iterator &bl) {
     DECODE_START_LEGACY_COMPAT_LEN(6, 3, 3, bl);
     decode(category, bl);
     decode(size, bl);
@@ -163,14 +244,14 @@ struct rgw_bucket_dir_entry_meta {
       decode(appendable, bl);
     DECODE_FINISH(bl);
   }
-  void dump(Formatter *f) const;
+  void dump(ceph::Formatter *f) const;
   void decode_json(JSONObj *obj);
-  static void generate_test_instances(list<rgw_bucket_dir_entry_meta*>& o);
+  static void generate_test_instances(std::list<rgw_bucket_dir_entry_meta*>& o);
 };
 WRITE_CLASS_ENCODER(rgw_bucket_dir_entry_meta)
 
 template<class T>
-void encode_packed_val(T val, bufferlist& bl)
+void encode_packed_val(T val, ceph::buffer::list& bl)
 {
   using ceph::encode;
   if ((uint64_t)val < 0x80) {
@@ -199,7 +280,7 @@ void encode_packed_val(T val, bufferlist& bl)
 }
 
 template<class T>
-void decode_packed_val(T& val, bufferlist::const_iterator& bl)
+void decode_packed_val(T& val, ceph::buffer::list::const_iterator& bl)
 {
   using ceph::decode;
   unsigned char c;
@@ -241,7 +322,7 @@ void decode_packed_val(T& val, bufferlist::const_iterator& bl)
       }
       break;
     default:
-      throw buffer::error();
+      throw ceph::buffer::malformed_input();
   }
 }
 
@@ -251,40 +332,56 @@ struct rgw_bucket_entry_ver {
 
   rgw_bucket_entry_ver() : pool(-1), epoch(0) {}
 
-  void encode(bufferlist &bl) const {
+  void encode(ceph::buffer::list &bl) const {
     ENCODE_START(1, 1, bl);
     encode_packed_val(pool, bl);
     encode_packed_val(epoch, bl);
     ENCODE_FINISH(bl);
   }
-  void decode(bufferlist::const_iterator &bl) {
+  void decode(ceph::buffer::list::const_iterator &bl) {
     DECODE_START(1, bl);
     decode_packed_val(pool, bl);
     decode_packed_val(epoch, bl);
     DECODE_FINISH(bl);
   }
-  void dump(Formatter *f) const;
+  void dump(ceph::Formatter *f) const;
   void decode_json(JSONObj *obj);
-  static void generate_test_instances(list<rgw_bucket_entry_ver*>& o);
+  static void generate_test_instances(std::list<rgw_bucket_entry_ver*>& o);
 };
 WRITE_CLASS_ENCODER(rgw_bucket_entry_ver)
 
+
 struct cls_rgw_obj_key {
-  string name;
-  string instance;
+  std::string name;
+  std::string instance;
 
   cls_rgw_obj_key() {}
-  cls_rgw_obj_key(const string &_name) : name(_name) {}
-  cls_rgw_obj_key(const string& n, const string& i) : name(n), instance(i) {}
+  cls_rgw_obj_key(const std::string &_name) : name(_name) {}
+  cls_rgw_obj_key(const std::string& n, const std::string& i) : name(n), instance(i) {}
+
+  std::string to_string() const {
+    return fmt::format("{}({})", name, instance);
+  }
+
+  bool empty() const {
+    return name.empty();
+  }
 
-  void set(const string& _name) {
+  void set(const std::string& _name) {
     name = _name;
+    instance.clear();
   }
 
   bool operator==(const cls_rgw_obj_key& k) const {
     return (name.compare(k.name) == 0) &&
            (instance.compare(k.instance) == 0);
   }
+
+  bool operator!=(const cls_rgw_obj_key& k) const {
+    return (name.compare(k.name) != 0) ||
+           (instance.compare(k.instance) != 0);
+  }
+
   bool operator<(const cls_rgw_obj_key& k) const {
     int r = name.compare(k.name);
     if (r == 0) {
@@ -292,30 +389,29 @@ struct cls_rgw_obj_key {
     }
     return (r < 0);
   }
+
   bool operator<=(const cls_rgw_obj_key& k) const {
     return !(k < *this);
   }
-  bool empty() const {
-    return name.empty();
-  }
-  void encode(bufferlist &bl) const {
+
+  void encode(ceph::buffer::list &bl) const {
     ENCODE_START(1, 1, bl);
     encode(name, bl);
     encode(instance, bl);
     ENCODE_FINISH(bl);
   }
-  void decode(bufferlist::const_iterator &bl) {
+  void decode(ceph::buffer::list::const_iterator &bl) {
     DECODE_START(1, bl);
     decode(name, bl);
     decode(instance, bl);
     DECODE_FINISH(bl);
   }
-  void dump(Formatter *f) const {
+  void dump(ceph::Formatter *f) const {
     f->dump_string("name", name);
     f->dump_string("instance", instance);
   }
   void decode_json(JSONObj *obj);
-  static void generate_test_instances(list<cls_rgw_obj_key*>& ls) {
+  static void generate_test_instances(std::list<cls_rgw_obj_key*>& ls) {
     ls.push_back(new cls_rgw_obj_key);
     ls.push_back(new cls_rgw_obj_key);
     ls.back()->name = "name";
@@ -324,28 +420,45 @@ struct cls_rgw_obj_key {
 };
 WRITE_CLASS_ENCODER(cls_rgw_obj_key)
 
-
-#define RGW_BUCKET_DIRENT_FLAG_VER           0x1    /* a versioned object instance */
-#define RGW_BUCKET_DIRENT_FLAG_CURRENT       0x2    /* the last object instance of a versioned object */
-#define RGW_BUCKET_DIRENT_FLAG_DELETE_MARKER 0x4    /* delete marker */
-#define RGW_BUCKET_DIRENT_FLAG_VER_MARKER    0x8    /* object is versioned, a placeholder for the plain entry */
+inline std::ostream& operator<<(std::ostream& out, const cls_rgw_obj_key& o) {
+  out << o.name;
+  if (!o.instance.empty()) {
+    out << '[' << o.instance << ']';
+  }
+  return out;
+}
 
 struct rgw_bucket_dir_entry {
+  /* a versioned object instance */
+  static constexpr uint16_t FLAG_VER =                0x1;
+  /* the last object instance of a versioned object */
+  static constexpr uint16_t FLAG_CURRENT =            0x2;
+  /* delete marker */
+  static constexpr uint16_t FLAG_DELETE_MARKER =      0x4;
+  /* object is versioned, a placeholder for the plain entry */
+  static constexpr uint16_t FLAG_VER_MARKER =         0x8;
+  /* object is a proxy; it is not listed in the bucket index but is a
+   * prefix ending with a delimiter, perhaps common to multiple
+   * entries; it is only useful when a delimiter is used and
+   * represents a "subdirectory" (again, ending in a delimiter) that
+   * may contain one or more actual entries/objects */
+  static constexpr uint16_t FLAG_COMMON_PREFIX =   0x8000;
+
   cls_rgw_obj_key key;
   rgw_bucket_entry_ver ver;
   std::string locator;
   bool exists;
   rgw_bucket_dir_entry_meta meta;
-  multimap<string, rgw_bucket_pending_info> pending_map;
+  std::multimap<std::string, rgw_bucket_pending_info> pending_map;
   uint64_t index_ver;
-  string tag;
+  std::string tag;
   uint16_t flags;
   uint64_t versioned_epoch;
 
   rgw_bucket_dir_entry() :
     exists(false), index_ver(0), flags(0), versioned_epoch(0) {}
 
-  void encode(bufferlist &bl) const {
+  void encode(ceph::buffer::list &bl) const {
     ENCODE_START(8, 3, bl);
     encode(key.name, bl);
     encode(ver.epoch, bl);
@@ -361,7 +474,7 @@ struct rgw_bucket_dir_entry {
     encode(versioned_epoch, bl);
     ENCODE_FINISH(bl);
   }
-  void decode(bufferlist::const_iterator &bl) {
+  void decode(ceph::buffer::list::const_iterator &bl) {
     DECODE_START_LEGACY_COMPAT_LEN(8, 3, 3, bl);
     decode(key.name, bl);
     decode(ver.epoch, bl);
@@ -392,20 +505,28 @@ struct rgw_bucket_dir_entry {
     DECODE_FINISH(bl);
   }
 
-  bool is_current() {
-    int test_flags = RGW_BUCKET_DIRENT_FLAG_VER | RGW_BUCKET_DIRENT_FLAG_CURRENT;
-    return (flags & RGW_BUCKET_DIRENT_FLAG_VER) == 0 ||
+  bool is_current() const {
+    int test_flags =
+      rgw_bucket_dir_entry::FLAG_VER | rgw_bucket_dir_entry::FLAG_CURRENT;
+    return (flags & rgw_bucket_dir_entry::FLAG_VER) == 0 ||
            (flags & test_flags) == test_flags;
   }
-  bool is_delete_marker() { return (flags & RGW_BUCKET_DIRENT_FLAG_DELETE_MARKER) != 0; }
-  bool is_visible() {
+  bool is_delete_marker() const {
+    return (flags & rgw_bucket_dir_entry::FLAG_DELETE_MARKER) != 0;
+  }
+  bool is_visible() const {
     return is_current() && !is_delete_marker();
   }
-  bool is_valid() { return (flags & RGW_BUCKET_DIRENT_FLAG_VER_MARKER) == 0; }
+  bool is_valid() const {
+    return (flags & rgw_bucket_dir_entry::FLAG_VER_MARKER) == 0;
+  }
+  bool is_common_prefix() const {
+    return flags & rgw_bucket_dir_entry::FLAG_COMMON_PREFIX;
+  }
 
-  void dump(Formatter *f) const;
+  void dump(ceph::Formatter *f) const;
   void decode_json(JSONObj *obj);
-  static void generate_test_instances(list<rgw_bucket_dir_entry*>& o);
+  static void generate_test_instances(std::list<rgw_bucket_dir_entry*>& o);
 };
 WRITE_CLASS_ENCODER(rgw_bucket_dir_entry)
 
@@ -420,12 +541,12 @@ struct rgw_bucket_category_stats;
 
 struct rgw_cls_bi_entry {
   BIIndexType type;
-  string idx;
-  bufferlist data;
+  std::string idx;
+  ceph::buffer::list data;
 
   rgw_cls_bi_entry() : type(BIIndexType::Invalid) {}
 
-  void encode(bufferlist& bl) const {
+  void encode(ceph::buffer::list& bl) const {
     ENCODE_START(1, 1, bl);
     encode(type, bl);
     encode(idx, bl);
@@ -433,7 +554,7 @@ struct rgw_cls_bi_entry {
     ENCODE_FINISH(bl);
   }
 
-  void decode(bufferlist::const_iterator& bl) {
+  void decode(ceph::buffer::list::const_iterator& bl) {
     DECODE_START(1, bl);
     uint8_t c;
     decode(c, bl);
@@ -443,7 +564,7 @@ struct rgw_cls_bi_entry {
     DECODE_FINISH(bl);
   }
 
-  void dump(Formatter *f) const;
+  void dump(ceph::Formatter *f) const;
   void decode_json(JSONObj *obj, cls_rgw_obj_key *effective_key = NULL);
 
   bool get_info(cls_rgw_obj_key *key, RGWObjCategory *category,
@@ -461,14 +582,14 @@ enum OLHLogOp {
 struct rgw_bucket_olh_log_entry {
   uint64_t epoch;
   OLHLogOp op;
-  string op_tag;
+  std::string op_tag;
   cls_rgw_obj_key key;
   bool delete_marker;
 
   rgw_bucket_olh_log_entry() : epoch(0), op(CLS_RGW_OLH_OP_UNKNOWN), delete_marker(false) {}
 
 
-  void encode(bufferlist &bl) const {
+  void encode(ceph::buffer::list &bl) const {
     ENCODE_START(1, 1, bl);
     encode(epoch, bl);
     encode((__u8)op, bl);
@@ -477,7 +598,7 @@ struct rgw_bucket_olh_log_entry {
     encode(delete_marker, bl);
     ENCODE_FINISH(bl);
   }
-  void decode(bufferlist::const_iterator &bl) {
+  void decode(ceph::buffer::list::const_iterator &bl) {
     DECODE_START(1, bl);
     decode(epoch, bl);
     uint8_t c;
@@ -488,8 +609,8 @@ struct rgw_bucket_olh_log_entry {
     decode(delete_marker, bl);
     DECODE_FINISH(bl);
   }
-  static void generate_test_instances(list<rgw_bucket_olh_log_entry*>& o);
-  void dump(Formatter *f) const;
+  static void generate_test_instances(std::list<rgw_bucket_olh_log_entry*>& o);
+  void dump(ceph::Formatter *f) const;
   void decode_json(JSONObj *obj);
 };
 WRITE_CLASS_ENCODER(rgw_bucket_olh_log_entry)
@@ -498,14 +619,14 @@ struct rgw_bucket_olh_entry {
   cls_rgw_obj_key key;
   bool delete_marker;
   uint64_t epoch;
-  map<uint64_t, vector<struct rgw_bucket_olh_log_entry> > pending_log;
-  string tag;
+  std::map<uint64_t, std::vector<struct rgw_bucket_olh_log_entry> > pending_log;
+  std::string tag;
   bool exists;
   bool pending_removal;
 
   rgw_bucket_olh_entry() : delete_marker(false), epoch(0), exists(false), pending_removal(false) {}
 
-  void encode(bufferlist &bl) const {
+  void encode(ceph::buffer::list &bl) const {
     ENCODE_START(1, 1, bl);
     encode(key, bl);
     encode(delete_marker, bl);
@@ -516,7 +637,7 @@ struct rgw_bucket_olh_entry {
     encode(pending_removal, bl);
     ENCODE_FINISH(bl);
   }
-  void decode(bufferlist::const_iterator &bl) {
+  void decode(ceph::buffer::list::const_iterator &bl) {
     DECODE_START(1, bl);
     decode(key, bl);
     decode(delete_marker, bl);
@@ -527,29 +648,29 @@ struct rgw_bucket_olh_entry {
     decode(pending_removal, bl);
     DECODE_FINISH(bl);
   }
-  void dump(Formatter *f) const;
+  void dump(ceph::Formatter *f) const;
   void decode_json(JSONObj *obj);
 };
 WRITE_CLASS_ENCODER(rgw_bucket_olh_entry)
 
 struct rgw_bi_log_entry {
-  string id;
-  string object;
-  string instance;
+  std::string id;
+  std::string object;
+  std::string instance;
   ceph::real_time timestamp;
   rgw_bucket_entry_ver ver;
   RGWModifyOp op;
   RGWPendingState state;
   uint64_t index_ver;
-  string tag;
+  std::string tag;
   uint16_t bilog_flags;
-  string owner; /* only being set if it's a delete marker */
-  string owner_display_name; /* only being set if it's a delete marker */
+  std::string owner; /* only being set if it's a delete marker */
+  std::string owner_display_name; /* only being set if it's a delete marker */
   rgw_zone_set zones_trace;
 
   rgw_bi_log_entry() : op(CLS_RGW_OP_UNKNOWN), state(CLS_RGW_STATE_PENDING_MODIFY), index_ver(0), bilog_flags(0) {}
 
-  void encode(bufferlist &bl) const {
+  void encode(ceph::buffer::list &bl) const {
     ENCODE_START(4, 1, bl);
     encode(id, bl);
     encode(object, bl);
@@ -568,7 +689,7 @@ struct rgw_bi_log_entry {
     encode(zones_trace, bl);
     ENCODE_FINISH(bl);
   }
-  void decode(bufferlist::const_iterator &bl) {
+  void decode(ceph::buffer::list::const_iterator &bl) {
     DECODE_START(4, bl);
     decode(id, bl);
     decode(object, bl);
@@ -594,9 +715,9 @@ struct rgw_bi_log_entry {
     }
     DECODE_FINISH(bl);
   }
-  void dump(Formatter *f) const;
+  void dump(ceph::Formatter *f) const;
   void decode_json(JSONObj *obj);
-  static void generate_test_instances(list<rgw_bi_log_entry*>& o);
+  static void generate_test_instances(std::list<rgw_bi_log_entry*>& o);
 
   bool is_versioned() {
     return ((bilog_flags & RGW_BILOG_FLAG_VERSIONED_OP) != 0);
@@ -612,7 +733,7 @@ struct rgw_bucket_category_stats {
 
   rgw_bucket_category_stats() : total_size(0), total_size_rounded(0), num_entries(0) {}
 
-  void encode(bufferlist &bl) const {
+  void encode(ceph::buffer::list &bl) const {
     ENCODE_START(3, 2, bl);
     encode(total_size, bl);
     encode(total_size_rounded, bl);
@@ -620,7 +741,7 @@ struct rgw_bucket_category_stats {
     encode(actual_size, bl);
     ENCODE_FINISH(bl);
   }
-  void decode(bufferlist::const_iterator &bl) {
+  void decode(ceph::buffer::list::const_iterator &bl) {
     DECODE_START_LEGACY_COMPAT_LEN(3, 2, 2, bl);
     decode(total_size, bl);
     decode(total_size_rounded, bl);
@@ -632,41 +753,50 @@ struct rgw_bucket_category_stats {
     }
     DECODE_FINISH(bl);
   }
-  void dump(Formatter *f) const;
-  static void generate_test_instances(list<rgw_bucket_category_stats*>& o);
+  void dump(ceph::Formatter *f) const;
+  static void generate_test_instances(std::list<rgw_bucket_category_stats*>& o);
 };
 WRITE_CLASS_ENCODER(rgw_bucket_category_stats)
 
-enum cls_rgw_reshard_status {
-  CLS_RGW_RESHARD_NOT_RESHARDING  = 0,
-  CLS_RGW_RESHARD_IN_PROGRESS     = 1,
-  CLS_RGW_RESHARD_DONE            = 2,
+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
 };
 
-static inline std::string to_string(const enum cls_rgw_reshard_status status)
+inline std::string to_string(const cls_rgw_reshard_status status)
 {
   switch (status) {
-  case CLS_RGW_RESHARD_NOT_RESHARDING:
+  case cls_rgw_reshard_status::NOT_RESHARDING:
     return "not-resharding";
-    break;
-  case CLS_RGW_RESHARD_IN_PROGRESS:
+  case cls_rgw_reshard_status::IN_PROGRESS:
     return "in-progress";
-    break;
-  case CLS_RGW_RESHARD_DONE:
+  case cls_rgw_reshard_status::DONE:
     return "done";
-    break;
-  default:
-    break;
   };
   return "Unknown reshard status";
 }
 
 struct cls_rgw_bucket_instance_entry {
-  cls_rgw_reshard_status reshard_status{CLS_RGW_RESHARD_NOT_RESHARDING};
-  string new_bucket_instance_id;
+  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(bufferlist& bl) const {
+  void encode(ceph::buffer::list& bl) const {
     ENCODE_START(1, 1, bl);
     encode((uint8_t)reshard_status, bl);
     encode(new_bucket_instance_id, bl);
@@ -674,7 +804,7 @@ struct cls_rgw_bucket_instance_entry {
     ENCODE_FINISH(bl);
   }
 
-  void decode(bufferlist::const_iterator& bl) {
+  void decode(ceph::buffer::list::const_iterator& bl) {
     DECODE_START(1, bl);
     uint8_t s;
     decode(s, bl);
@@ -684,41 +814,45 @@ struct cls_rgw_bucket_instance_entry {
     DECODE_FINISH(bl);
   }
 
-  void dump(Formatter *f) const;
-  static void generate_test_instances(list<cls_rgw_bucket_instance_entry*>& o);
+  void dump(ceph::Formatter *f) const;
+  static void generate_test_instances(std::list<cls_rgw_bucket_instance_entry*>& o);
 
   void clear() {
-    reshard_status = CLS_RGW_RESHARD_NOT_RESHARDING;
+    reshard_status = RESHARD_STATUS::NOT_RESHARDING;
     new_bucket_instance_id.clear();
   }
 
-  void set_status(const string& new_instance_id, int32_t new_num_shards, cls_rgw_reshard_status s) {
+  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 != CLS_RGW_RESHARD_NOT_RESHARDING;
+    return reshard_status != RESHARD_STATUS::NOT_RESHARDING;
   }
   bool resharding_in_progress() const {
-    return reshard_status == CLS_RGW_RESHARD_IN_PROGRESS;
+    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>;
+
 struct rgw_bucket_dir_header {
-  map<RGWObjCategory, rgw_bucket_category_stats> stats;
+  rgw_bucket_dir_stats stats;
   uint64_t tag_timeout;
   uint64_t ver;
   uint64_t master_ver;
-  string max_marker;
+  std::string max_marker;
   cls_rgw_bucket_instance_entry new_instance;
   bool syncstopped;
 
   rgw_bucket_dir_header() : tag_timeout(0), ver(0), master_ver(0), syncstopped(false) {}
 
-  void encode(bufferlist &bl) const {
+  void encode(ceph::buffer::list &bl) const {
     ENCODE_START(7, 2, bl);
     encode(stats, bl);
     encode(tag_timeout, bl);
@@ -729,7 +863,7 @@ struct rgw_bucket_dir_header {
     encode(syncstopped,bl);
     ENCODE_FINISH(bl);
   }
-  void decode(bufferlist::const_iterator &bl) {
+  void decode(ceph::buffer::list::const_iterator &bl) {
     DECODE_START_LEGACY_COMPAT_LEN(6, 2, 2, bl);
     decode(stats, bl);
     if (struct_v > 2) {
@@ -756,8 +890,8 @@ struct rgw_bucket_dir_header {
     }
     DECODE_FINISH(bl);
   }
-  void dump(Formatter *f) const;
-  static void generate_test_instances(list<rgw_bucket_dir_header*>& o);
+  void dump(ceph::Formatter *f) const;
+  static void generate_test_instances(std::list<rgw_bucket_dir_header*>& o);
 
   bool resharding() const {
     return new_instance.resharding();
@@ -770,22 +904,22 @@ WRITE_CLASS_ENCODER(rgw_bucket_dir_header)
 
 struct rgw_bucket_dir {
   rgw_bucket_dir_header header;
-  std::map<string, rgw_bucket_dir_entry> m;
+  boost::container::flat_map<std::string, rgw_bucket_dir_entry> m;
 
-  void encode(bufferlist &bl) const {
+  void encode(ceph::buffer::list &bl) const {
     ENCODE_START(2, 2, bl);
     encode(header, bl);
     encode(m, bl);
     ENCODE_FINISH(bl);
   }
-  void decode(bufferlist::const_iterator &bl) {
+  void decode(ceph::buffer::list::const_iterator &bl) {
     DECODE_START_LEGACY_COMPAT_LEN(2, 2, 2, bl);
     decode(header, bl);
     decode(m, bl);
     DECODE_FINISH(bl);
   }
-  void dump(Formatter *f) const;
-  static void generate_test_instances(list<rgw_bucket_dir*>& o);
+  void dump(ceph::Formatter *f) const;
+  static void generate_test_instances(std::list<rgw_bucket_dir*>& o);
 };
 WRITE_CLASS_ENCODER(rgw_bucket_dir)
 
@@ -798,7 +932,7 @@ struct rgw_usage_data {
   rgw_usage_data() : bytes_sent(0), bytes_received(0), ops(0), successful_ops(0) {}
   rgw_usage_data(uint64_t sent, uint64_t received) : bytes_sent(sent), bytes_received(received), ops(0), successful_ops(0) {}
 
-  void encode(bufferlist& bl) const {
+  void encode(ceph::buffer::list& bl) const {
     ENCODE_START(1, 1, bl);
     encode(bytes_sent, bl);
     encode(bytes_received, bl);
@@ -807,7 +941,7 @@ struct rgw_usage_data {
     ENCODE_FINISH(bl);
   }
 
-  void decode(bufferlist::const_iterator& bl) {
+  void decode(ceph::buffer::list::const_iterator& bl) {
     DECODE_START(1, bl);
     decode(bytes_sent, bl);
     decode(bytes_received, bl);
@@ -829,16 +963,16 @@ WRITE_CLASS_ENCODER(rgw_usage_data)
 struct rgw_usage_log_entry {
   rgw_user owner;
   rgw_user payer; /* if empty, same as owner */
-  string bucket;
+  std::string bucket;
   uint64_t epoch;
   rgw_usage_data total_usage; /* this one is kept for backwards compatibility */
-  map<string, rgw_usage_data> usage_map;
+  std::map<std::string, rgw_usage_data> usage_map;
 
   rgw_usage_log_entry() : epoch(0) {}
-  rgw_usage_log_entry(string& o, string& b) : owner(o), bucket(b), epoch(0) {}
-  rgw_usage_log_entry(string& o, string& p, string& b) : owner(o), payer(p), bucket(b), epoch(0) {}
+  rgw_usage_log_entry(std::string& o, std::string& b) : owner(o), bucket(b), epoch(0) {}
+  rgw_usage_log_entry(std::string& o, std::string& p, std::string& b) : owner(o), payer(p), bucket(b), epoch(0) {}
 
-  void encode(bufferlist& bl) const {
+  void encode(ceph::buffer::list& bl) const {
     ENCODE_START(3, 1, bl);
     encode(owner.to_str(), bl);
     encode(bucket, bl);
@@ -853,9 +987,9 @@ struct rgw_usage_log_entry {
   }
 
 
-   void decode(bufferlist::const_iterator& bl) {
+   void decode(ceph::buffer::list::const_iterator& bl) {
     DECODE_START(3, bl);
-    string s;
+    std::string s;
     decode(s, bl);
     owner.from_str(s);
     decode(bucket, bl);
@@ -870,14 +1004,15 @@ struct rgw_usage_log_entry {
       decode(usage_map, bl);
     }
     if (struct_v >= 3) {
-      string p;
+      std::string p;
       decode(p, bl);
       payer.from_str(p);
     }
     DECODE_FINISH(bl);
   }
 
-  void aggregate(const rgw_usage_log_entry& e, map<string, bool> *categories = NULL) {
+  void aggregate(const rgw_usage_log_entry& e,
+                std::map<std::string, bool> *categories = NULL) {
     if (owner.empty()) {
       owner = e.owner;
       bucket = e.bucket;
@@ -885,44 +1020,44 @@ struct rgw_usage_log_entry {
       payer = e.payer;
     }
 
-    map<string, rgw_usage_data>::const_iterator iter;
-    for (iter = e.usage_map.begin(); iter != e.usage_map.end(); ++iter) {
+    for (auto iter = e.usage_map.begin(); iter != e.usage_map.end(); ++iter) {
       if (!categories || !categories->size() || categories->count(iter->first)) {
         add(iter->first, iter->second);
       }
     }
   }
 
-  void sum(rgw_usage_data& usage, map<string, bool>& categories) const {
+  void sum(rgw_usage_data& usage,
+          std::map<std::string, bool>& categories) const {
     usage = rgw_usage_data();
-    for (map<string, rgw_usage_data>::const_iterator iter = usage_map.begin(); iter != usage_map.end(); ++iter) {
+    for (auto iter = usage_map.begin(); iter != usage_map.end(); ++iter) {
       if (!categories.size() || categories.count(iter->first)) {
         usage.aggregate(iter->second);
       }
     }
   }
 
-  void add(const string& category, const rgw_usage_data& data) {
+  void add(const std::string& category, const rgw_usage_data& data) {
     usage_map[category].aggregate(data);
     total_usage.aggregate(data);
   }
 
-  void dump(Formatter* f) const;
-  static void generate_test_instances(list<rgw_usage_log_entry*>& o);
+  void dump(ceph::Formatter* f) const;
+  static void generate_test_instances(std::list<rgw_usage_log_entry*>& o);
 
 };
 WRITE_CLASS_ENCODER(rgw_usage_log_entry)
 
 struct rgw_usage_log_info {
-  vector<rgw_usage_log_entry> entries;
+  std::vector<rgw_usage_log_entry> entries;
 
-  void encode(bufferlist& bl) const {
+  void encode(ceph::buffer::list& bl) const {
     ENCODE_START(1, 1, bl);
     encode(entries, bl);
     ENCODE_FINISH(bl);
   }
 
-  void decode(bufferlist::const_iterator& bl) {
+  void decode(ceph::buffer::list::const_iterator& bl) {
     DECODE_START(1, bl);
     decode(entries, bl);
     DECODE_FINISH(bl);
@@ -933,20 +1068,20 @@ struct rgw_usage_log_info {
 WRITE_CLASS_ENCODER(rgw_usage_log_info)
 
 struct rgw_user_bucket {
-  string user;
-  string bucket;
+  std::string user;
+  std::string bucket;
 
   rgw_user_bucket() {}
-  rgw_user_bucket(const string& u, const string& b) : user(u), bucket(b) {}
+  rgw_user_bucket(const std::string& u, const std::string& b) : user(u), bucket(b) {}
 
-  void encode(bufferlist& bl) const {
+  void encode(ceph::buffer::list& bl) const {
     ENCODE_START(1, 1, bl);
     encode(user, bl);
     encode(bucket, bl);
     ENCODE_FINISH(bl);
   }
 
-  void decode(bufferlist::const_iterator& bl) {
+  void decode(ceph::buffer::list::const_iterator& bl) {
     DECODE_START(1, bl);
     decode(user, bl);
     decode(bucket, bl);
@@ -971,14 +1106,14 @@ enum cls_rgw_gc_op {
 };
 
 struct cls_rgw_obj {
-  string pool;
+  std::string pool;
   cls_rgw_obj_key key;
-  string loc;
+  std::string loc;
 
   cls_rgw_obj() {}
-  cls_rgw_obj(string& _p, cls_rgw_obj_key& _k) : pool(_p), key(_k) {}
+  cls_rgw_obj(std::string& _p, cls_rgw_obj_key& _k) : pool(_p), key(_k) {}
 
-  void encode(bufferlist& bl) const {
+  void encode(ceph::buffer::list& bl) const {
     ENCODE_START(2, 1, bl);
     encode(pool, bl);
     encode(key.name, bl);
@@ -987,7 +1122,7 @@ struct cls_rgw_obj {
     ENCODE_FINISH(bl);
   }
 
-  void decode(bufferlist::const_iterator& bl) {
+  void decode(ceph::buffer::list::const_iterator& bl) {
     DECODE_START(2, bl);
     decode(pool, bl);
     decode(key.name, bl);
@@ -998,13 +1133,13 @@ struct cls_rgw_obj {
     DECODE_FINISH(bl);
   }
 
-  void dump(Formatter *f) const {
+  void dump(ceph::Formatter *f) const {
     f->dump_string("pool", pool);
     f->dump_string("oid", key.name);
     f->dump_string("key", loc);
     f->dump_string("instance", key.instance);
   }
-  static void generate_test_instances(list<cls_rgw_obj*>& ls) {
+  static void generate_test_instances(std::list<cls_rgw_obj*>& ls) {
     ls.push_back(new cls_rgw_obj);
     ls.push_back(new cls_rgw_obj);
     ls.back()->pool = "mypool";
@@ -1015,11 +1150,11 @@ struct cls_rgw_obj {
 WRITE_CLASS_ENCODER(cls_rgw_obj)
 
 struct cls_rgw_obj_chain {
-  list<cls_rgw_obj> objs;
+  std::list<cls_rgw_obj> objs;
 
   cls_rgw_obj_chain() {}
 
-  void push_obj(const string& pool, const cls_rgw_obj_key& key, const string& loc) {
+  void push_obj(const std::string& pool, const cls_rgw_obj_key& key, const std::string& loc) {
     cls_rgw_obj obj;
     obj.pool = pool;
     obj.key = key;
@@ -1027,28 +1162,28 @@ struct cls_rgw_obj_chain {
     objs.push_back(obj);
   }
 
-  void encode(bufferlist& bl) const {
+  void encode(ceph::buffer::list& bl) const {
     ENCODE_START(1, 1, bl);
     encode(objs, bl);
     ENCODE_FINISH(bl);
   }
 
-  void decode(bufferlist::const_iterator& bl) {
+  void decode(ceph::buffer::list::const_iterator& bl) {
     DECODE_START(1, bl);
     decode(objs, bl);
     DECODE_FINISH(bl);
   }
 
-  void dump(Formatter *f) const {
+  void dump(ceph::Formatter *f) const {
     f->open_array_section("objs");
-    for (list<cls_rgw_obj>::const_iterator p = objs.begin(); p != objs.end(); ++p) {
+    for (std::list<cls_rgw_obj>::const_iterator p = objs.begin(); p != objs.end(); ++p) {
       f->open_object_section("obj");
       p->dump(f);
       f->close_section();
     }
     f->close_section();
   }
-  static void generate_test_instances(list<cls_rgw_obj_chain*>& ls) {
+  static void generate_test_instances(std::list<cls_rgw_obj_chain*>& ls) {
     ls.push_back(new cls_rgw_obj_chain);
   }
 
@@ -1060,13 +1195,13 @@ WRITE_CLASS_ENCODER(cls_rgw_obj_chain)
 
 struct cls_rgw_gc_obj_info
 {
-  string tag;
+  std::string tag;
   cls_rgw_obj_chain chain;
   ceph::real_time time;
 
   cls_rgw_gc_obj_info() {}
 
-  void encode(bufferlist& bl) const {
+  void encode(ceph::buffer::list& bl) const {
     ENCODE_START(1, 1, bl);
     encode(tag, bl);
     encode(chain, bl);
@@ -1074,7 +1209,7 @@ struct cls_rgw_gc_obj_info
     ENCODE_FINISH(bl);
   }
 
-  void decode(bufferlist::const_iterator& bl) {
+  void decode(ceph::buffer::list::const_iterator& bl) {
     DECODE_START(1, bl);
     decode(tag, bl);
     decode(chain, bl);
@@ -1082,18 +1217,18 @@ struct cls_rgw_gc_obj_info
     DECODE_FINISH(bl);
   }
 
-  void dump(Formatter *f) const {
+  void dump(ceph::Formatter *f) const {
     f->dump_string("tag", tag);
     f->open_object_section("chain");
     chain.dump(f);
     f->close_section();
     f->dump_stream("time") << time;
   }
-  static void generate_test_instances(list<cls_rgw_gc_obj_info*>& ls) {
+  static void generate_test_instances(std::list<cls_rgw_gc_obj_info*>& ls) {
     ls.push_back(new cls_rgw_gc_obj_info);
     ls.push_back(new cls_rgw_gc_obj_info);
     ls.back()->tag = "footag";
-    ceph_timespec ts{init_le32(21), init_le32(32)};
+    ceph_timespec ts{ceph_le32(21), ceph_le32(32)};
     ls.back()->time = ceph::real_clock::from_ceph_timespec(ts);
   }
 };
@@ -1102,11 +1237,11 @@ WRITE_CLASS_ENCODER(cls_rgw_gc_obj_info)
 struct cls_rgw_lc_obj_head
 {
   time_t start_date = 0;
-  string marker;
+  std::string marker;
 
   cls_rgw_lc_obj_head() {}
 
-  void encode(bufferlist& bl) const {
+  void encode(ceph::buffer::list& bl) const {
     ENCODE_START(1, 1, bl);
     uint64_t t = start_date;
     encode(t, bl);
@@ -1114,7 +1249,7 @@ struct cls_rgw_lc_obj_head
     ENCODE_FINISH(bl);
   }
 
-  void decode(bufferlist::const_iterator& bl) {
+  void decode(ceph::buffer::list::const_iterator& bl) {
     DECODE_START(1, bl);
     uint64_t t;
     decode(t, bl);
@@ -1123,24 +1258,55 @@ struct cls_rgw_lc_obj_head
     DECODE_FINISH(bl);
   }
 
-  void dump(Formatter *f) const;
-  static void generate_test_instances(list<cls_rgw_lc_obj_head*>& ls);
+  void dump(ceph::Formatter *f) const;
+  static void generate_test_instances(std::list<cls_rgw_lc_obj_head*>& ls);
 };
 WRITE_CLASS_ENCODER(cls_rgw_lc_obj_head)
 
+struct cls_rgw_lc_entry {
+  std::string bucket;
+  uint64_t start_time; // if in_progress
+  uint32_t status;
+
+  cls_rgw_lc_entry()
+    : start_time(0), status(0) {}
+
+  cls_rgw_lc_entry(const cls_rgw_lc_entry& rhs) = default;
+
+  cls_rgw_lc_entry(const std::string& b, uint64_t t, uint32_t s)
+    : bucket(b), start_time(t), status(s) {};
+
+  void encode(bufferlist& bl) const {
+    ENCODE_START(1, 1, bl);
+    encode(bucket, bl);
+    encode(start_time, bl);
+    encode(status, bl);
+    ENCODE_FINISH(bl);
+  }
+
+  void decode(bufferlist::const_iterator& bl) {
+    DECODE_START(1, bl);
+    decode(bucket, bl);
+    decode(start_time, bl);
+    decode(status, bl);
+    DECODE_FINISH(bl);
+  }
+};
+WRITE_CLASS_ENCODER(cls_rgw_lc_entry);
+
 struct cls_rgw_reshard_entry
 {
   ceph::real_time time;
-  string tenant;
-  string bucket_name;
-  string bucket_id;
-  string new_instance_id;
+  std::string tenant;
+  std::string bucket_name;
+  std::string bucket_id;
+  std::string new_instance_id;
   uint32_t old_num_shards{0};
   uint32_t new_num_shards{0};
 
   cls_rgw_reshard_entry() {}
 
-  void encode(bufferlist& bl) const {
+  void encode(ceph::buffer::list& bl) const {
     ENCODE_START(1, 1, bl);
     encode(time, bl);
     encode(tenant, bl);
@@ -1152,7 +1318,7 @@ struct cls_rgw_reshard_entry
     ENCODE_FINISH(bl);
   }
 
-  void decode(bufferlist::const_iterator& bl) {
+  void decode(ceph::buffer::list::const_iterator& bl) {
     DECODE_START(1, bl);
     decode(time, bl);
     decode(tenant, bl);
@@ -1164,12 +1330,10 @@ struct cls_rgw_reshard_entry
     DECODE_FINISH(bl);
   }
 
-  void dump(Formatter *f) const;
-  static void generate_test_instances(list<cls_rgw_reshard_entry*>& o);
+  void dump(ceph::Formatter *f) const;
+  static void generate_test_instances(std::list<cls_rgw_reshard_entry*>& o);
 
-  static void generate_key(const string& tenant, const string& bucket_name, string *key);
-  void get_key(string *key) const;
+  static void generate_key(const std::string& tenant, const std::string& bucket_name, std::string *key);
+  void get_key(std::string *key) const;
 };
 WRITE_CLASS_ENCODER(cls_rgw_reshard_entry)
-
-#endif