]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: add bucket index log layout structure 37586/head
authorShilpa Jagannath <smanjara@redhat.com>
Tue, 4 Aug 2020 12:00:41 +0000 (17:30 +0530)
committerCasey Bodley <cbodley@redhat.com>
Thu, 12 Nov 2020 21:48:07 +0000 (16:48 -0500)
Signed-off-by: Shilpa Jagannath <smanjara@redhat.com>
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_bucket_layout.cc
src/rgw/rgw_bucket_layout.h
src/rgw/rgw_rados.cc

index 942d113c35be9a3bf0e69a6385b26fa4d8ca40a0..85002ba9cb7da909751998f39eed1a29a34f4ca6 100644 (file)
@@ -74,20 +74,85 @@ void decode(bucket_index_layout_generation& l, bufferlist::const_iterator& bl)
   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);
 }
 
index cb84bd184425c55bb185c053620612307a2f11fa..a09215abc88edba2581682eb4d3fcfcfe6e96c41 100644 (file)
@@ -72,6 +72,54 @@ void encode(const bucket_index_layout_generation& l, bufferlist& bl, uint64_t f=
 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,
@@ -86,6 +134,10 @@ struct BucketLayout {
 
   // 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);
index dcef286757c90b40fc07e215b4de5cdce30d982a..0d68608ecb632ba302b2b2aa50ed24ecb412ea13 100644 (file)
@@ -2242,7 +2242,15 @@ int RGWRados::create_bucket(const RGWUserInfo& owner, rgw_bucket& bucket,
       // 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();