]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: replace RGWBucketInfo's sharding-related fields with BucketLayout
authorShilpa Jagannath <smanjara@redhat.com>
Fri, 20 Mar 2020 18:16:24 +0000 (23:46 +0530)
committerShilpa Jagannath <smanjara@redhat.com>
Mon, 30 Mar 2020 11:01:24 +0000 (16:31 +0530)
Signed-off-by: Shilpa Jagannath <smanjara@redhat.com>
14 files changed:
src/rgw/rgw_admin.cc
src/rgw/rgw_bucket.cc
src/rgw/rgw_common.cc
src/rgw/rgw_common.h
src/rgw/rgw_data_sync.cc
src/rgw/rgw_json_enc.cc
src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h
src/rgw/rgw_reshard.cc
src/rgw/rgw_trim_bilog.cc
src/rgw/rgw_zone.h
src/rgw/services/svc_bi_rados.cc
src/rgw/services/svc_zone.cc

index 99285b4444346307a162e750eb406159ae1883ec..dfe4218149ae3a68c915ede59603a8457eaf3150 100644 (file)
@@ -2731,7 +2731,7 @@ int check_reshard_bucket_params(rgw::sal::RGWRadosStore *store,
     return -EBUSY;
   }
 
-  int num_source_shards = (bucket_info.num_shards > 0 ? bucket_info.num_shards : 1);
+  int num_source_shards = (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? bucket_info.layout.current_index.layout.normal.num_shards : 1);
 
   if (num_shards <= num_source_shards && !yes_i_really_mean_it) {
     cerr << "num shards is less or equal to current shards count" << std::endl
@@ -3179,7 +3179,7 @@ int main(int argc, const char **argv)
   boost::optional<string> index_pool;
   boost::optional<string> data_pool;
   boost::optional<string> data_extra_pool;
-  RGWBucketIndexType placement_index_type = RGWBIType_Normal;
+  rgw::BucketIndexType placement_index_type = rgw::BucketIndexType::Normal;
   bool index_type_specified = false;
 
   boost::optional<std::string> compression_type;
@@ -3549,11 +3549,11 @@ int main(int argc, const char **argv)
       data_extra_pool = val;
     } else if (ceph_argparse_witharg(args, i, &val, "--placement-index-type", (char*)NULL)) {
       if (val == "normal") {
-        placement_index_type = RGWBIType_Normal;
+        placement_index_type = rgw::BucketIndexType::Normal;
       } else if (val == "indexless") {
-        placement_index_type = RGWBIType_Indexless;
+        placement_index_type = rgw::BucketIndexType::Indexless;
       } else {
-        placement_index_type = (RGWBucketIndexType)strict_strtol(val.c_str(), 10, &err);
+        placement_index_type = (rgw::BucketIndexType)strict_strtol(val.c_str(), 10, &err);
         if (!err.empty()) {
           cerr << "ERROR: failed to parse index type index: " << err << std::endl;
           return EINVAL;
@@ -6513,14 +6513,14 @@ next:
       max_entries = 1000;
     }
 
-    int max_shards = (bucket_info.num_shards > 0 ? bucket_info.num_shards : 1);
+    int max_shards = (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? bucket_info.layout.current_index.layout.normal.num_shards : 1);
 
     formatter->open_array_section("entries");
 
     int i = (specified_shard_id ? shard_id : 0);
     for (; i < max_shards; i++) {
       RGWRados::BucketShard bs(store->getRados());
-      int shard_id = (bucket_info.num_shards > 0  ? i : -1);
+      int shard_id = (bucket_info.layout.current_index.layout.normal.num_shards > 0  ? i : -1);
       int ret = bs.init(bucket, shard_id, nullptr /* no RGWBucketInfo */);
       marker.clear();
 
@@ -6580,11 +6580,11 @@ next:
       return EINVAL;
     }
 
-    int max_shards = (bucket_info.num_shards > 0 ? bucket_info.num_shards : 1);
+    int max_shards = (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? bucket_info.layout.current_index.layout.normal.num_shards : 1);
 
     for (int i = 0; i < max_shards; i++) {
       RGWRados::BucketShard bs(store->getRados());
-      int shard_id = (bucket_info.num_shards > 0  ? i : -1);
+      int shard_id = (bucket_info.layout.current_index.layout.normal.num_shards > 0  ? i : -1);
       int ret = bs.init(bucket, shard_id, nullptr /* no RGWBucketInfo */);
       if (ret < 0) {
         cerr << "ERROR: bs.init(bucket=" << bucket << ", shard=" << shard_id << "): " << cpp_strerror(-ret) << std::endl;
@@ -6881,7 +6881,7 @@ next:
       return ret;
     }
 
-    int num_source_shards = (bucket_info.num_shards > 0 ? bucket_info.num_shards : 1);
+    int num_source_shards = (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? bucket_info.layout.current_index.layout.normal.num_shards : 1);
 
     RGWReshard reshard(store);
     cls_rgw_reshard_entry entry;
index 108b1c13e2d1c5278f7ae8fb5f4310e393a52aa7..825cc1ad16999c559affe33384fd2be0cfa4240c 100644 (file)
@@ -1097,8 +1097,8 @@ int RGWBucket::sync(RGWBucketAdminOpState& op_state, map<string, bufferlist> *at
     return r;
   }
 
-  int shards_num = bucket_info.num_shards? bucket_info.num_shards : 1;
-  int shard_id = bucket_info.num_shards? 0 : -1;
+  int shards_num = bucket_info.layout.current_index.layout.normal.num_shards? bucket_info.layout.current_index.layout.normal.num_shards : 1;
+  int shard_id = bucket_info.layout.current_index.layout.normal.num_shards? 0 : -1;
 
   if (!sync) {
     r = store->svc()->bilog_rados->log_stop(bucket_info, -1);
@@ -1387,14 +1387,14 @@ static int bucket_stats(rgw::sal::RGWRadosStore *store, const std::string& tenan
 
   formatter->open_object_section("stats");
   formatter->dump_string("bucket", bucket.name);
-  formatter->dump_int("num_shards", bucket_info.num_shards);
+  formatter->dump_int("num_shards", bucket_info.layout.current_index.layout.normal.num_shards);
   formatter->dump_string("tenant", bucket.tenant);
   formatter->dump_string("zonegroup", bucket_info.zonegroup);
   formatter->dump_string("placement_rule", bucket_info.placement_rule.to_str());
   ::encode_json("explicit_placement", bucket.explicit_placement, formatter);
   formatter->dump_string("id", bucket.bucket_id);
   formatter->dump_string("marker", bucket.marker);
-  formatter->dump_stream("index_type") << bucket_info.index_type;
+  formatter->dump_stream("index_type") << bucket_info.layout.current_index.layout.type;
   ::encode_json("owner", bucket_info.owner, formatter);
   formatter->dump_string("ver", bucket_ver);
   formatter->dump_string("master_ver", master_ver);
@@ -1496,7 +1496,7 @@ int RGWBucketAdminOp::limit_check(rgw::sal::RGWRadosStore *store,
            num_objects += s.second.num_objects;
        }
 
-       num_shards = info.num_shards;
+       num_shards = info.layout.current_index.layout.normal.num_shards;
        uint64_t objs_per_shard =
          (num_shards) ? num_objects/num_shards : num_objects;
        {
@@ -1637,10 +1637,10 @@ int RGWBucketAdminOp::set_quota(rgw::sal::RGWRadosStore *store, RGWBucketAdminOp
 
 static int purge_bucket_instance(rgw::sal::RGWRadosStore *store, const RGWBucketInfo& bucket_info)
 {
-  int max_shards = (bucket_info.num_shards > 0 ? bucket_info.num_shards : 1);
+  int max_shards = (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? bucket_info.layout.current_index.layout.normal.num_shards : 1);
   for (int i = 0; i < max_shards; i++) {
     RGWRados::BucketShard bs(store->getRados());
-    int shard_id = (bucket_info.num_shards > 0  ? i : -1);
+    int shard_id = (bucket_info.layout.current_index.layout.normal.num_shards > 0  ? i : -1);
     int ret = bs.init(bucket_info.bucket, shard_id, nullptr);
     if (ret < 0) {
       cerr << "ERROR: bs.init(bucket=" << bucket_info.bucket << ", shard=" << shard_id
@@ -3032,7 +3032,7 @@ int RGWMetadataHandlerPut_BucketInstance::put_check()
         return ret;
       }
     }
-    bci.info.index_type = rule_info.index_type;
+    bci.info.layout.current_index.layout.type = rule_info.index_type;
   } else {
     /* existing bucket, keep its placement */
     bci.info.bucket.explicit_placement = old_bci->info.bucket.explicit_placement;
index f3c08f8873c3fcba7d86984455e4852d153e5cc2..0545122d12393de282a89c140fd603ded14e82f0 100644 (file)
@@ -2000,15 +2000,15 @@ void RGWBucketInfo::encode(bufferlist& bl) const {
   encode(placement_rule, bl);
   encode(has_instance_obj, bl);
   encode(quota, bl);
-  encode(num_shards, bl);
-  encode(bucket_index_shard_hash_type, bl);
+  encode(layout.current_index.layout.normal.num_shards, bl);
+  encode(layout.current_index.layout.normal.hash_type, bl);
   encode(requester_pays, bl);
   encode(owner.tenant, bl);
   encode(has_website, bl);
   if (has_website) {
     encode(website_conf, bl);
   }
-  encode((uint32_t)index_type, bl);
+  encode((uint32_t)layout.current_index.layout.type, bl);
   encode(swift_versioning, bl);
   if (swift_versioning) {
     encode(swift_ver_location, bl);
@@ -2054,9 +2054,9 @@ void RGWBucketInfo::decode(bufferlist::const_iterator& bl) {
   if (struct_v >= 9)
     decode(quota, bl);
   if (struct_v >= 10)
-    decode(num_shards, bl);
+    decode(layout.current_index.layout.normal.num_shards, bl);
   if (struct_v >= 11)
-    decode(bucket_index_shard_hash_type, bl);
+    decode(layout.current_index.layout.normal.hash_type, bl);
   if (struct_v >= 12)
     decode(requester_pays, bl);
   if (struct_v >= 13)
@@ -2072,9 +2072,9 @@ void RGWBucketInfo::decode(bufferlist::const_iterator& bl) {
   if (struct_v >= 15) {
     uint32_t it;
     decode(it, bl);
-    index_type = (RGWBucketIndexType)it;
+    layout.current_index.layout.type = (rgw::BucketIndexType)it;
   } else {
-    index_type = RGWBIType_Normal;
+    layout.current_index.layout.type = rgw::BucketIndexType::Normal;
   }
   swift_versioning = false;
   swift_ver_location.clear();
index 34fb71b833b9f35796c899fc4e6eab535a6834ff..4d6d866d98b995d1a0ea6057d326d67ef470e1c3 100644 (file)
@@ -1091,17 +1091,12 @@ enum RGWBucketFlags {
   BUCKET_OBJ_LOCK_ENABLED = 0X20,
 };
 
-enum RGWBucketIndexType {
-  RGWBIType_Normal = 0,
-  RGWBIType_Indexless = 1,
-};
-
-inline ostream& operator<<(ostream& out, const RGWBucketIndexType &index_type) 
+inline ostream& operator<<(ostream& out, const rgw::BucketIndexType &index_type)
 {
   switch (index_type) {
-    case RGWBIType_Normal:
+    case rgw::BucketIndexType::Normal:
       return out << "Normal";
-    case RGWBIType_Indexless:
+    case rgw::BucketIndexType::Indexless:
       return out << "Indexless";
     default:
       return out << "Unknown";
@@ -1132,10 +1127,6 @@ struct RGWBucketInfo {
   //   - value of 0 indicates there is no sharding (this is by default
   //     before this feature is implemented).
   //   - value of UINT32_T::MAX indicates this is a blind bucket.
-  uint32_t num_shards{0};
-
-  // Represents the bucket index shard hash type.
-  uint8_t bucket_index_shard_hash_type{MOD};
 
   // Represents the shard number for blind bucket.
   const static uint32_t NUM_SHARDS_BLIND_BUCKET;
@@ -1145,8 +1136,6 @@ struct RGWBucketInfo {
   bool has_website{false};
   RGWBucketWebsiteConf website_conf;
 
-  RGWBucketIndexType index_type = RGWBIType_Normal;
-
   bool swift_versioning{false};
   string swift_ver_location;
 
index aeceb05099d138e9702d55c37ee8cf65e02c72cf..94ad515453612e6fe110b3e5b82117b37078fdf8 100644 (file)
@@ -853,7 +853,7 @@ public:
             call(new RGWReadRESTResourceCR<bucket_instance_meta_info>(sync_env->cct, sc->conn, sync_env->http_manager, path, pairs, &meta_info));
           }
 
-          num_shards = meta_info.data.get_bucket_info().num_shards;
+          num_shards = meta_info.data.get_bucket_info().layout.current_index.layout.normal.num_shards;
           if (num_shards > 0) {
             for (i = 0; i < num_shards; i++) {
               char buf[16];
@@ -2822,11 +2822,12 @@ RGWRemoteBucketManager::RGWRemoteBucketManager(const DoutPrefixProvider *_dpp,
   conn = _conn;
   source_zone = _source_zone;
 
-  int num_shards = (source_bucket_info.num_shards <= 0 ? 1 : source_bucket_info.num_shards);
+  int num_shards = (source_bucket_info.layout.current_index.layout.normal.num_shards <= 0 ? 
+                    1 : source_bucket_info.layout.current_index.layout.normal.num_shards);
 
   sync_pairs.resize(num_shards);
 
-  int cur_shard = std::min<int>(source_bucket_info.num_shards, 0);
+  int cur_shard = std::min<int>(source_bucket_info.layout.current_index.layout.normal.num_shards, 0);
 
   for (int i = 0; i < num_shards; ++i, ++cur_shard) {
     auto& sync_pair = sync_pairs[i];
@@ -2834,7 +2835,7 @@ RGWRemoteBucketManager::RGWRemoteBucketManager(const DoutPrefixProvider *_dpp,
     sync_pair.source_bs.bucket = source_bucket_info.bucket;
     sync_pair.dest_bs.bucket = dest_bucket;
 
-    sync_pair.source_bs.shard_id = (source_bucket_info.num_shards > 0 ? cur_shard : -1);
+    sync_pair.source_bs.shard_id = (source_bucket_info.layout.current_index.layout.normal.num_shards > 0 ? cur_shard : -1);
 
     if (dest_bucket == source_bucket_info.bucket) {
       sync_pair.dest_bs.shard_id = sync_pair.source_bs.shard_id;
@@ -4299,8 +4300,8 @@ int RGWRunBucketSourcesSyncCR::operate()
       {
         ldpp_dout(sync_env->dpp, 20) << __func__ << "(): sync pipe=" << *siter << dendl;
 
-        source_num_shards = siter->source.get_bucket_info().num_shards;
-        target_num_shards = siter->target.get_bucket_info().num_shards;
+        source_num_shards = siter->source.get_bucket_info().layout.current_index.layout.normal.num_shards;
+        target_num_shards = siter->target.get_bucket_info().layout.current_index.layout.normal.num_shards;
         if (source_bs) {
           sync_pair.source_bs = *source_bs;
         } else {
@@ -4951,13 +4952,13 @@ class RGWCollectBucketSyncStatusCR : public RGWShardCollectCR {
       dest_bucket_info(dest_bucket_info),
       i(status->begin()), end(status->end())
   {
-    shard_to_shard_sync = (source_bucket_info.num_shards == dest_bucket_info.num_shards);
+    shard_to_shard_sync = (source_bucket_info.layout.current_index.layout.normal.num_shards == dest_bucket_info.layout.current_index.layout.normal.num_shards);
 
-    source_bs = rgw_bucket_shard(source_bucket_info.bucket, source_bucket_info.num_shards > 0 ? 0 : -1);
-    dest_bs = rgw_bucket_shard(dest_bucket_info.bucket, dest_bucket_info.num_shards > 0 ? 0 : -1);
+    source_bs = rgw_bucket_shard(source_bucket_info.bucket, source_bucket_info.layout.current_index.layout.normal.num_shards > 0 ? 0 : -1);
+    dest_bs = rgw_bucket_shard(dest_bucket_info.bucket, dest_bucket_info.layout.current_index.layout.normal.num_shards > 0 ? 0 : -1);
 
     status->clear();
-    status->resize(std::max<size_t>(1, source_bucket_info.num_shards));
+    status->resize(std::max<size_t>(1, source_bucket_info.layout.current_index.layout.normal.num_shards));
 
     i = status->begin();
     end = status->end();
index dec0e32dfd99b6b2c278e2a0a8f993c121ea9f16..8083212e33b570f4f960c13df1751d1592d105da 100644 (file)
@@ -780,8 +780,8 @@ void RGWBucketInfo::dump(Formatter *f) const
   encode_json("placement_rule", placement_rule, f);
   encode_json("has_instance_obj", has_instance_obj, f);
   encode_json("quota", quota, f);
-  encode_json("num_shards", num_shards, f);
-  encode_json("bi_shard_hash_type", (uint32_t)bucket_index_shard_hash_type, f);
+  encode_json("num_shards", layout.current_index.layout.normal.num_shards, f);
+  encode_json("bi_shard_hash_type", (uint32_t)layout.current_index.layout.normal.hash_type, f);
   encode_json("requester_pays", requester_pays, f);
   encode_json("has_website", has_website, f);
   if (has_website) {
@@ -789,7 +789,7 @@ void RGWBucketInfo::dump(Formatter *f) const
   }
   encode_json("swift_versioning", swift_versioning, f);
   encode_json("swift_ver_location", swift_ver_location, f);
-  encode_json("index_type", (uint32_t)index_type, f);
+  encode_json("index_type", (uint32_t)layout.current_index.layout.type, f);
   encode_json("mdsearch_config", mdsearch_config, f);
   encode_json("reshard_status", (int)reshard_status, f);
   encode_json("new_bucket_instance_id", new_bucket_instance_id, f);
@@ -815,10 +815,10 @@ void RGWBucketInfo::decode_json(JSONObj *obj) {
   placement_rule.from_str(pr);
   JSONDecoder::decode_json("has_instance_obj", has_instance_obj, obj);
   JSONDecoder::decode_json("quota", quota, obj);
-  JSONDecoder::decode_json("num_shards", num_shards, obj);
+  JSONDecoder::decode_json("num_shards", layout.current_index.layout.normal.num_shards, obj);
   uint32_t hash_type;
   JSONDecoder::decode_json("bi_shard_hash_type", hash_type, obj);
-  bucket_index_shard_hash_type = (uint8_t)hash_type;
+  layout.current_index.layout.normal.num_shards = (uint8_t)hash_type;
   JSONDecoder::decode_json("requester_pays", requester_pays, obj);
   JSONDecoder::decode_json("has_website", has_website, obj);
   if (has_website) {
@@ -828,7 +828,7 @@ void RGWBucketInfo::decode_json(JSONObj *obj) {
   JSONDecoder::decode_json("swift_ver_location", swift_ver_location, obj);
   uint32_t it;
   JSONDecoder::decode_json("index_type", it, obj);
-  index_type = (RGWBucketIndexType)it;
+  layout.current_index.layout.type = (rgw::BucketIndexType)it;
   JSONDecoder::decode_json("mdsearch_config", mdsearch_config, obj);
   int rs;
   JSONDecoder::decode_json("reshard_status", rs, obj);
@@ -1317,7 +1317,7 @@ void RGWZonePlacementInfo::decode_json(JSONObj *obj)
   JSONDecoder::decode_json("data_extra_pool", data_extra_pool, obj);
   uint32_t it;
   JSONDecoder::decode_json("index_type", it, obj);
-  index_type = (RGWBucketIndexType)it;
+  index_type = (rgw::BucketIndexType)it;
 
   /* backward compatibility, these are now defined in storage_classes */
   string standard_compression_type;
index cb8e8a90d5333e71f6c476ebeb2085d04164f34d..9f64814e694ca79273aa35a22be4676d26bf2f45 100644 (file)
@@ -3286,7 +3286,7 @@ void RGWCreateBucket::execute()
     ldpp_dout(this, 20) << "got creation time: << " << master_info.creation_time << dendl;
     pmaster_bucket= &master_info.bucket;
     creation_time = master_info.creation_time;
-    pmaster_num_shards = &master_info.num_shards;
+    pmaster_num_shards = &master_info.layout.current_index.layout.normal.num_shards;
     pobjv = &objv;
     obj_lock_enabled = master_info.obj_lock_enabled();
   } else {
@@ -7022,7 +7022,7 @@ int RGWBulkUploadOp::handle_dir(const boost::string_ref path)
 
     pmaster_bucket= &master_info.bucket;
     creation_time = master_info.creation_time;
-    pmaster_num_shards = &master_info.num_shards;
+    pmaster_num_shards = &master_info.layout.current_index.layout.normal.num_shards;
     pobjv = &objv;
   } else {
     pmaster_bucket = nullptr;
index 3f6c32c8d48673f5075ae84fcde2f2b5f88532d6..56512156d2e7f576a2fe00e6eaccb84134700775 100644 (file)
@@ -2211,15 +2211,15 @@ int RGWRados::create_bucket(const RGWUserInfo& owner, rgw_bucket& bucket,
     info.owner = owner.user_id;
     info.zonegroup = zonegroup_id;
     info.placement_rule = selected_placement_rule;
-    info.index_type = rule_info.index_type;
+    info.layout.current_index.layout.type = rule_info.index_type;
     info.swift_ver_location = swift_ver_location;
     info.swift_versioning = (!swift_ver_location.empty());
     if (pmaster_num_shards) {
-      info.num_shards = *pmaster_num_shards;
+      info.layout.current_index.layout.normal.num_shards = *pmaster_num_shards;
     } else {
-      info.num_shards = bucket_index_max_shards;
+      info.layout.current_index.layout.normal.num_shards = bucket_index_max_shards;
     }
-    info.bucket_index_shard_hash_type = RGWBucketInfo::MOD;
+    info.layout.current_index.layout.normal.num_shards = RGWBucketInfo::MOD;
     info.requester_pays = false;
     if (real_clock::is_zero(creation_time)) {
       info.creation_time = ceph::real_clock::now();
@@ -7538,7 +7538,7 @@ public:
 int RGWRados::get_bucket_stats_async(RGWBucketInfo& bucket_info, int shard_id, RGWGetBucketStats_CB *ctx)
 {
   int num_aio = 0;
-  RGWGetBucketStatsContext *get_ctx = new RGWGetBucketStatsContext(ctx, bucket_info.num_shards ? : 1);
+  RGWGetBucketStatsContext *get_ctx = new RGWGetBucketStatsContext(ctx, bucket_info.layout.current_index.layout.normal.num_shards ? : 1);
   ceph_assert(get_ctx);
   int r = cls_bucket_head_async(bucket_info, shard_id, get_ctx, &num_aio);
   if (r < 0) {
@@ -8886,7 +8886,7 @@ int RGWRados::check_bucket_shards(const RGWBucketInfo& bucket_info,
 
   bool need_resharding = false;
   uint32_t num_source_shards =
-    (bucket_info.num_shards > 0 ? bucket_info.num_shards : 1);
+    (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? bucket_info.layout.current_index.layout.normal.num_shards : 1);
   const uint32_t max_dynamic_shards =
     uint32_t(cct->_conf.get_val<uint64_t>("rgw_max_dynamic_shards"));
 
@@ -8913,7 +8913,7 @@ int RGWRados::check_bucket_shards(const RGWBucketInfo& bucket_info,
   }
 
   ldout(cct, 20) << "RGWRados::" << __func__ << " bucket " << bucket.name <<
-    " needs resharding; current num shards " << bucket_info.num_shards <<
+    " needs resharding; current num shards " << bucket_info.layout.current_index.layout.normal.num_shards <<
     "; new num shards " << final_num_shards << " (suggested " <<
     suggested_num_shards << ")" << dendl;
 
@@ -8924,7 +8924,7 @@ int RGWRados::add_bucket_to_reshard(const RGWBucketInfo& bucket_info, uint32_t n
 {
   RGWReshard reshard(this->store);
 
-  uint32_t num_source_shards = (bucket_info.num_shards > 0 ? bucket_info.num_shards : 1);
+  uint32_t num_source_shards = (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? bucket_info.layout.current_index.layout.normal.num_shards : 1);
 
   new_num_shards = std::min(new_num_shards, get_max_bucket_shards());
   if (new_num_shards <= num_source_shards) {
@@ -8957,14 +8957,14 @@ int RGWRados::get_target_shard_id(const RGWBucketInfo& bucket_info, const string
                                   int *shard_id)
 {
   int r = 0;
-  switch (bucket_info.bucket_index_shard_hash_type) {
-    case RGWBucketInfo::MOD:
-      if (!bucket_info.num_shards) {
+  switch (bucket_info.layout.current_index.layout.normal.hash_type) {
+    case rgw::BucketHashType::Mod:
+      if (!bucket_info.layout.current_index.layout.normal.num_shards) {
         if (shard_id) {
           *shard_id = -1;
         }
       } else {
-        uint32_t sid = svc.bi_rados->bucket_shard_index(obj_key, bucket_info.num_shards);
+        uint32_t sid = svc.bi_rados->bucket_shard_index(obj_key, bucket_info.layout.current_index.layout.normal.num_shards);
         if (shard_id) {
           *shard_id = (int)sid;
         }
index e19b8d44811e63265c31c9ca79f7c85bbae9f57c..5d0e580c87b79060c60cba73e7720c85c545875f 100644 (file)
@@ -945,7 +945,7 @@ public:
 
       UpdateIndex(RGWRados::Bucket *_target, const rgw_obj& _obj) : target(_target), obj(_obj),
                                                               bs(target->get_store()) {
-                                                                blind = (target->get_bucket_info().index_type == RGWBIType_Indexless);
+                                                                blind = (target->get_bucket_info().layout.current_index.layout.type == rgw::BucketIndexType::Indexless);
                                                               }
 
       int get_bucket_shard(BucketShard **pbs) {
index e20d8a392388da2a8d48dc2e76499d891f422b53..d1a5af6ed3cf9f391424b4d3a3bf66574631399b 100644 (file)
@@ -107,7 +107,7 @@ public:
     store(_store), bucket_info(_bucket_info), bs(store->getRados()),
     aio_completions(_completions)
   {
-    num_shard = (bucket_info.num_shards > 0 ? _num_shard : -1);
+    num_shard = (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? _num_shard : -1);
     bs.init(bucket_info.bucket, num_shard, nullptr /* no RGWBucketInfo */);
 
     max_aio_completions =
@@ -304,7 +304,7 @@ int RGWBucketReshard::clear_resharding(rgw::sal::RGWRadosStore* store,
 int RGWBucketReshard::clear_index_shard_reshard_status(rgw::sal::RGWRadosStore* store,
                                                       const RGWBucketInfo& bucket_info)
 {
-  uint32_t num_shards = bucket_info.num_shards;
+  uint32_t num_shards = bucket_info.layout.current_index.layout.normal.num_shards;
 
   if (num_shards < std::numeric_limits<uint32_t>::max()) {
     int ret = set_resharding_status(store, bucket_info,
@@ -332,7 +332,7 @@ static int create_new_bucket_instance(rgw::sal::RGWRadosStore *store,
 
   store->getRados()->create_bucket_id(&new_bucket_info.bucket.bucket_id);
 
-  new_bucket_info.num_shards = new_num_shards;
+  new_bucket_info.layout.current_index.layout.normal.num_shards = new_num_shards;
   new_bucket_info.objv_tracker.clear();
 
   new_bucket_info.new_bucket_instance_id.clear();
@@ -556,7 +556,7 @@ int RGWBucketReshard::do_reshard(int num_shards,
     return ret;
   }
 
-  int num_target_shards = (new_bucket_info.num_shards > 0 ? new_bucket_info.num_shards : 1);
+  int num_target_shards = (new_bucket_info.layout.current_index.layout.normal.num_shards > 0 ? new_bucket_info.layout.current_index.layout.normal.num_shards : 1);
 
   BucketReshardManager target_shards_mgr(store, new_bucket_info, num_target_shards);
 
@@ -573,7 +573,7 @@ int RGWBucketReshard::do_reshard(int num_shards,
   }
 
   const int num_source_shards =
-    (bucket_info.num_shards > 0 ? bucket_info.num_shards : 1);
+    (bucket_info.layout.current_index.layout.normal.num_shards > 0 ? bucket_info.layout.current_index.layout.normal.num_shards : 1);
   string marker;
   for (int i = 0; i < num_source_shards; ++i) {
     bool is_truncated = true;
index 9e2ac89d218edce87478e7651af84386bb88deb6..1f5740e082acbac4c2c020c512398bc8f866aa6c 100644 (file)
@@ -529,7 +529,7 @@ int BucketTrimInstanceCR::operate()
 
     // initialize each shard with the maximum marker, which is only used when
     // there are no peers syncing from us
-    min_markers.assign(std::max(1u, pbucket_info->num_shards),
+    min_markers.assign(std::max(1u, pbucket_info->layout.current_index.layout.normal.num_shards),
                        RGWSyncLogTrimCR::max_marker);
 
     // determine the minimum marker for each shard
index 090c3e3c3061828b613fd56167b711d65a528ec2..b29575af7951c19432606d9571ba6ad68d0de323 100644 (file)
@@ -268,9 +268,9 @@ struct RGWZonePlacementInfo {
   rgw_pool index_pool;
   rgw_pool data_extra_pool; /* if not set we should use data_pool */
   RGWZoneStorageClasses storage_classes;
-  RGWBucketIndexType index_type;
+  rgw::BucketIndexType index_type;
 
-  RGWZonePlacementInfo() : index_type(RGWBIType_Normal) {}
+  RGWZonePlacementInfo() : index_type(rgw::BucketIndexType::Normal) {}
 
   void encode(bufferlist& bl) const {
     ENCODE_START(7, 1, bl);
@@ -301,7 +301,7 @@ struct RGWZonePlacementInfo {
     if (struct_v >= 5) {
       uint32_t it;
       decode(it, bl);
-      index_type = (RGWBucketIndexType)it;
+      index_type = (rgw::BucketIndexType)it;
     }
     string standard_compression_type;
     if (struct_v >= 6) {
index 3ef0b6f09c21b97d5610f2d7afde557f75db00ca..0aa71ea507ef33a7bc708119cf7b721aeb3cb27c 100644 (file)
@@ -142,17 +142,18 @@ static void get_bucket_instance_ids(const RGWBucketInfo& bucket_info,
 {
   const rgw_bucket& bucket = bucket_info.bucket;
   string plain_id = bucket.name + ":" + bucket.bucket_id;
-  if (!bucket_info.num_shards) {
+
+  if (!bucket_info.layout.current_index.layout.normal.num_shards) {
     (*result)[0] = plain_id;
   } else {
     char buf[16];
     if (shard_id < 0) {
-      for (uint32_t i = 0; i < bucket_info.num_shards; ++i) {
+      for (uint32_t i = 0; i < bucket_info.layout.current_index.layout.normal.num_shards; ++i) {
         snprintf(buf, sizeof(buf), ":%d", i);
         (*result)[i] = plain_id + buf;
       }
     } else {
-      if ((uint32_t)shard_id > bucket_info.num_shards) {
+      if ((uint32_t)shard_id > bucket_info.layout.current_index.layout.normal.num_shards) {
         return;
       }
       snprintf(buf, sizeof(buf), ":%d", shard_id);
@@ -176,7 +177,7 @@ int RGWSI_BucketIndex_RADOS::open_bucket_index(const RGWBucketInfo& bucket_info,
     return ret;
   }
 
-  get_bucket_index_objects(bucket_oid_base, bucket_info.num_shards, bucket_objs, shard_id);
+  get_bucket_index_objects(bucket_oid_base, bucket_info.layout.current_index.layout.normal.num_shards, bucket_objs, shard_id);
   if (bucket_instance_ids) {
     get_bucket_instance_ids(bucket_info, shard_id, bucket_instance_ids);
   }
@@ -245,8 +246,8 @@ int RGWSI_BucketIndex_RADOS::open_bucket_index_shard(const RGWBucketInfo& bucket
 
   string oid;
 
-  ret = get_bucket_index_object(bucket_oid_base, obj_key, bucket_info.num_shards,
-        (RGWBucketInfo::BIShardsHashType)bucket_info.bucket_index_shard_hash_type, &oid, shard_id);
+  ret = get_bucket_index_object(bucket_oid_base, obj_key, bucket_info.layout.current_index.layout.normal.num_shards,
+        (RGWBucketInfo::BIShardsHashType)bucket_info.layout.current_index.layout.normal.hash_type, &oid, shard_id);
   if (ret < 0) {
     ldout(cct, 10) << "get_bucket_index_object() returned ret=" << ret << dendl;
     return ret;
@@ -272,7 +273,7 @@ int RGWSI_BucketIndex_RADOS::open_bucket_index_shard(const RGWBucketInfo& bucket
 
   string oid;
 
-  get_bucket_index_object(bucket_oid_base, bucket_info.num_shards,
+  get_bucket_index_object(bucket_oid_base, bucket_info.layout.current_index.layout.normal.num_shards,
                           shard_id, &oid);
 
   *bucket_obj = svc.rados->obj(index_pool, oid);
@@ -322,7 +323,7 @@ int RGWSI_BucketIndex_RADOS::init_index(RGWBucketInfo& bucket_info)
   dir_oid.append(bucket_info.bucket.bucket_id);
 
   map<int, string> bucket_objs;
-  get_bucket_index_objects(dir_oid, bucket_info.num_shards, &bucket_objs);
+  get_bucket_index_objects(dir_oid, bucket_info.layout.current_index.layout.normal.num_shards, &bucket_objs);
 
   return CLSRGWIssueBucketIndexInit(index_pool.ioctx(),
                                    bucket_objs,
@@ -342,7 +343,7 @@ int RGWSI_BucketIndex_RADOS::clean_index(RGWBucketInfo& bucket_info)
   dir_oid.append(bucket_info.bucket.bucket_id);
 
   std::map<int, std::string> bucket_objs;
-  get_bucket_index_objects(dir_oid, bucket_info.num_shards, &bucket_objs);
+  get_bucket_index_objects(dir_oid, bucket_info.layout.current_index.layout.normal.num_shards, &bucket_objs);
 
   return CLSRGWIssueBucketIndexClean(index_pool.ioctx(),
                                     bucket_objs,
@@ -415,8 +416,8 @@ int RGWSI_BucketIndex_RADOS::handle_overwrite(const RGWBucketInfo& info,
   bool old_sync_enabled = orig_info.datasync_flag_enabled();
 
   if (old_sync_enabled != new_sync_enabled) {
-    int shards_num = info.num_shards? info.num_shards : 1;
-    int shard_id = info.num_shards? 0 : -1;
+    int shards_num = info.layout.current_index.layout.normal.num_shards? info.layout.current_index.layout.normal.num_shards : 1;
+    int shard_id = info.layout.current_index.layout.normal.num_shards? 0 : -1;
 
     int ret;
     if (!new_sync_enabled) {
index df5386930512b693a59dbbe522aeef45bcb6d730..e32aff9b3c9859e75665932cbac82dc30c442586 100644 (file)
@@ -1196,7 +1196,7 @@ read_omap:
   rule_info->storage_classes.set_storage_class(RGW_STORAGE_CLASS_STANDARD, &pool, nullptr);
   rule_info->data_extra_pool = pool_name;
   rule_info->index_pool = pool_name;
-  rule_info->index_type = RGWBIType_Normal;
+  rule_info->index_type = rgw::BucketIndexType::Normal;
 
   return 0;
 }