]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: more multisite dynamic resharding pieces.
authorShilpa Jagannath <smanjara@redhat.com>
Wed, 1 Apr 2020 17:28:46 +0000 (22:58 +0530)
committerShilpa Jagannath <smanjara@redhat.com>
Mon, 27 Apr 2020 07:46:08 +0000 (13:16 +0530)
rados object names of bi shard to take a unique id called
generation number.

Signed-off-by: Shilpa Jagannath <smanjara@redhat.com>
src/rgw/rgw_rados.cc
src/rgw/services/svc_bi_rados.cc
src/rgw/services/svc_bi_rados.h

index a6dbb57d97120e98a830d232f28941bdc5fba944..8c32c76c3723ae9d46f3fd5ee7aa0c20f2b28103 100644 (file)
@@ -2634,6 +2634,9 @@ int RGWRados::BucketShard::init(const rgw_bucket& _bucket,
 
   auto obj_ctx = store->svc.sysobj->init_obj_ctx();
 
+  rgw::bucket_index_layout_generation generator;
+  uint64_t gen_number = generator.gen;
+
   RGWBucketInfo bucket_info;
   RGWBucketInfo* bucket_info_p =
     bucket_info_out ? bucket_info_out : &bucket_info;
@@ -2644,7 +2647,7 @@ int RGWRados::BucketShard::init(const rgw_bucket& _bucket,
 
   string oid;
 
-  ret = store->svc.bi_rados->open_bucket_index_shard(*bucket_info_p, shard_id, &bucket_obj);
+  ret = store->svc.bi_rados->open_bucket_index_shard(*bucket_info_p, shard_id, gen_number, &bucket_obj);
   if (ret < 0) {
     ldout(store->ctx(), 0) << "ERROR: open_bucket_index_shard() returned ret=" << ret << dendl;
     return ret;
@@ -2676,8 +2679,10 @@ int RGWRados::BucketShard::init(const RGWBucketInfo& bucket_info, int sid)
 {
   bucket = bucket_info.bucket;
   shard_id = sid;
+  rgw::bucket_index_layout_generation generator;
+  uint64_t gen_number = generator.gen;
 
-  int ret = store->svc.bi_rados->open_bucket_index_shard(bucket_info, shard_id, &bucket_obj);
+  int ret = store->svc.bi_rados->open_bucket_index_shard(bucket_info, shard_id, gen_number, &bucket_obj);
   if (ret < 0) {
     ldout(store->ctx(), 0) << "ERROR: open_bucket_index_shard() returned ret=" << ret << dendl;
     return ret;
index 494d7094d271d7cd4db3f7989576e8e05e246c02..33ce61d77fb13e31935d0cc92d73eb8f84675f73 100644 (file)
@@ -187,15 +187,21 @@ int RGWSI_BucketIndex_RADOS::open_bucket_index(const RGWBucketInfo& bucket_info,
 void RGWSI_BucketIndex_RADOS::get_bucket_index_object(const string& bucket_oid_base,
                                                       uint32_t num_shards,
                                                       int shard_id,
+                                                      uint64_t gen_id,
                                                       string *bucket_obj)
 {
   if (!num_shards) {
     // By default with no sharding, we use the bucket oid as itself
     (*bucket_obj) = bucket_oid_base;
   } else {
-    char buf[bucket_oid_base.size() + 32];
-    snprintf(buf, sizeof(buf), "%s.%d", bucket_oid_base.c_str(), shard_id);
-    (*bucket_obj) = buf;
+    char buf[bucket_oid_base.size() + 64];
+    if (gen_id != 0) {
+      snprintf(buf, sizeof(buf), "%s.%" PRIu64 ".%d", bucket_oid_base.c_str(), gen_id, shard_id);
+      (*bucket_obj) = buf;
+    } else {
+      snprintf(buf, sizeof(buf), "%s.%d", bucket_oid_base.c_str(), shard_id);
+      (*bucket_obj) = buf;
+    }
   }
 }
 
@@ -260,6 +266,7 @@ int RGWSI_BucketIndex_RADOS::open_bucket_index_shard(const RGWBucketInfo& bucket
 
 int RGWSI_BucketIndex_RADOS::open_bucket_index_shard(const RGWBucketInfo& bucket_info,
                                                      int shard_id,
+                                                     uint64_t gen_id,
                                                      RGWSI_RADOS::Obj *bucket_obj)
 {
   RGWSI_RADOS::Pool index_pool;
@@ -274,7 +281,7 @@ int RGWSI_BucketIndex_RADOS::open_bucket_index_shard(const RGWBucketInfo& bucket
   string oid;
 
   get_bucket_index_object(bucket_oid_base, bucket_info.layout.current_index.layout.normal.num_shards,
-                          shard_id, &oid);
+                          shard_id, gen_id, &oid);
 
   *bucket_obj = svc.rados->obj(index_pool, oid);
 
index 87387d7ca0803ea6b969fac6be7fd24d147ce2e3..753e5e7e12cdd85b0359d6d656bc84bbdf9976a6 100644 (file)
@@ -50,6 +50,7 @@ class RGWSI_BucketIndex_RADOS : public RGWSI_BucketIndex
   void get_bucket_index_object(const string& bucket_oid_base,
                                uint32_t num_shards,
                                int shard_id,
+                               uint64_t gen_id,
                                string *bucket_obj);
   int get_bucket_index_object(const string& bucket_oid_base, const string& obj_key,
                               uint32_t num_shards, rgw::BucketHashType hash_type,
@@ -114,7 +115,7 @@ public:
                               int *shard_id);
 
   int open_bucket_index_shard(const RGWBucketInfo& bucket_info,
-                              int shard_id,
+                              int shard_id, uint64_t gen_id,
                               RGWSI_RADOS::Obj *bucket_obj);
 
   int open_bucket_index(const RGWBucketInfo& bucket_info,