DECODE_FINISH(bl);
}
-void encode(const BucketLayout& l, bufferlist& bl, uint64_t f)
+void encode(const bucket_index_log_layout& l, bufferlist& bl, uint64_t f)
+{
+ ENCODE_START(1, 1, bl);
+ encode(l.gen, bl);
+ encode(l.layout, bl);
+ ENCODE_FINISH(bl);
+}
+void decode(bucket_index_log_layout& l, bufferlist::const_iterator& bl)
+{
+ DECODE_START(1, bl);
+ decode(l.gen, bl);
+ decode(l.layout, bl);
+ DECODE_FINISH(bl);
+}
+
+void encode(const bucket_log_layout& l, bufferlist& bl, uint64_t f)
+{
+ ENCODE_START(1, 1, bl);
+ encode(l.type, bl);
+ switch (l.type) {
+ case BucketLogType::InIndex:
+ encode(l.in_index, bl);
+ break;
+ }
+ ENCODE_FINISH(bl);
+}
+void decode(bucket_log_layout& l, bufferlist::const_iterator& bl)
+{
+ DECODE_START(1, bl);
+ decode(l.type, bl);
+ switch (l.type) {
+ case BucketLogType::InIndex:
+ decode(l.in_index, bl);
+ break;
+ }
+ DECODE_FINISH(bl);
+}
+
+void encode(const bucket_log_layout_generation& l, bufferlist& bl, uint64_t f)
{
ENCODE_START(1, 1, bl);
+ encode(l.gen, bl);
+ encode(l.layout, bl);
+ ENCODE_FINISH(bl);
+}
+void decode(bucket_log_layout_generation& l, bufferlist::const_iterator& bl)
+{
+ DECODE_START(1, bl);
+ decode(l.gen, bl);
+ decode(l.layout, bl);
+ DECODE_FINISH(bl);
+}
+
+void encode(const BucketLayout& l, bufferlist& bl, uint64_t f)
+{
+ ENCODE_START(2, 1, bl);
encode(l.resharding, bl);
encode(l.current_index, bl);
encode(l.target_index, bl);
+ encode(l.logs, bl);
ENCODE_FINISH(bl);
}
void decode(BucketLayout& l, bufferlist::const_iterator& bl)
{
- DECODE_START(1, bl);
+ DECODE_START(2, bl);
decode(l.resharding, bl);
decode(l.current_index, bl);
decode(l.target_index, bl);
+ if (struct_v < 2) {
+ l.logs.clear();
+ // initialize the log layout to match the current index layout
+ if (l.current_index.layout.type == BucketIndexType::Normal) {
+ const auto gen = l.current_index.gen;
+ const auto& index = l.current_index.layout.normal;
+ l.logs.push_back(log_layout_from_index(gen, index));
+ }
+ } else {
+ decode(l.logs, bl);
+ }
DECODE_FINISH(bl);
}
void decode(bucket_index_layout_generation& l, bufferlist::const_iterator& bl);
+enum class BucketLogType : uint8_t {
+ // colocated with bucket index, so the log layout matches the index layout
+ InIndex,
+};
+
+inline std::ostream& operator<<(std::ostream& out, const BucketLogType &log_type)
+{
+ switch (log_type) {
+ case BucketLogType::InIndex:
+ return out << "InIndex";
+ default:
+ return out << "Unknown";
+ }
+}
+
+struct bucket_index_log_layout {
+ uint64_t gen = 0;
+ bucket_index_normal_layout layout;
+};
+
+void encode(const bucket_index_log_layout& l, bufferlist& bl, uint64_t f=0);
+void decode(bucket_index_log_layout& l, bufferlist::const_iterator& bl);
+
+struct bucket_log_layout {
+ BucketLogType type = BucketLogType::InIndex;
+
+ bucket_index_log_layout in_index;
+};
+
+void encode(const bucket_log_layout& l, bufferlist& bl, uint64_t f=0);
+void decode(bucket_log_layout& l, bufferlist::const_iterator& bl);
+
+
+struct bucket_log_layout_generation {
+ uint64_t gen = 0;
+ bucket_log_layout layout;
+};
+
+void encode(const bucket_log_layout_generation& l, bufferlist& bl, uint64_t f=0);
+void decode(bucket_log_layout_generation& l, bufferlist::const_iterator& bl);
+
+// return a log layout that shares its layout with the index
+inline bucket_log_layout_generation log_layout_from_index(
+ uint64_t gen, const bucket_index_normal_layout& index)
+{
+ return {gen, {BucketLogType::InIndex, {gen, index}}};
+}
+
enum class BucketReshardState : uint8_t {
None,
InProgress,
// target index layout of a resharding operation
std::optional<bucket_index_layout_generation> target_index;
+
+ // history of untrimmed bucket log layout generations, with the current
+ // generation at the back()
+ std::vector<bucket_log_layout_generation> logs;
};
void encode(const BucketLayout& l, bufferlist& bl, uint64_t f=0);
// TODO: remove this once sync doesn't require the same shard count
info.layout.current_index.layout.normal.num_shards = *pmaster_num_shards;
}
+ info.layout.current_index.layout.normal.hash_type = rgw::BucketHashType::Mod;
info.layout.current_index.layout.type = rule_info.index_type;
+ if (info.layout.current_index.layout.type == rgw::BucketIndexType::Normal) {
+ // use the same index layout for the bilog
+ const auto gen = info.layout.current_index.gen;
+ const auto& index = info.layout.current_index.layout.normal;
+ info.layout.logs.push_back(rgw::log_layout_from_index(gen, index));
+ }
+
info.requester_pays = false;
if (real_clock::is_zero(creation_time)) {
info.creation_time = ceph::real_clock::now();