]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
modified get_target_shard_id() to take bucket_index_normal_layout directly
authorShilpa Jagannath <smanjara@redhat.com>
Tue, 31 Mar 2020 11:20:58 +0000 (16:50 +0530)
committerShilpa Jagannath <smanjara@redhat.com>
Wed, 1 Apr 2020 05:48:09 +0000 (11:18 +0530)
Signed-off-by: Shilpa Jagannath <smanjara@redhat.com>
src/rgw/rgw_bucket_layout.h
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h
src/rgw/rgw_reshard.cc

index 69030d03016099080dd88b5557a35514b1e041fe..cb84bd184425c55bb185c053620612307a2f11fa 100644 (file)
@@ -30,12 +30,12 @@ enum class BucketHashType : uint8_t {
   Mod, // rjenkins hash of object name, modulo num_shards
 };
 
-inline std::ostream& operator<<(std::ostream& out, const rgw::BucketIndexType &index_type)
+inline std::ostream& operator<<(std::ostream& out, const BucketIndexType &index_type)
 {
   switch (index_type) {
-    case rgw::BucketIndexType::Normal:
+    case BucketIndexType::Normal:
       return out << "Normal";
-    case rgw::BucketIndexType::Indexless:
+    case BucketIndexType::Indexless:
       return out << "Indexless";
     default:
       return out << "Unknown";
index 56512156d2e7f576a2fe00e6eaccb84134700775..4f3e2f0c2e17f5a1f9750b1149918c7dec2d79d3 100644 (file)
@@ -8953,18 +8953,18 @@ int RGWRados::check_quota(const rgw_user& bucket_owner, rgw_bucket& bucket,
   return quota_handler->check_quota(bucket_owner, bucket, user_quota, bucket_quota, 1, obj_size);
 }
 
-int RGWRados::get_target_shard_id(const RGWBucketInfo& bucket_info, const string& obj_key,
+int RGWRados::get_target_shard_id(const rgw::bucket_index_normal_layout& layout, const string& obj_key,
                                   int *shard_id)
 {
   int r = 0;
-  switch (bucket_info.layout.current_index.layout.normal.hash_type) {
+  switch (layout.hash_type) {
     case rgw::BucketHashType::Mod:
-      if (!bucket_info.layout.current_index.layout.normal.num_shards) {
+      if (!layout.num_shards) {
         if (shard_id) {
           *shard_id = -1;
         }
       } else {
-        uint32_t sid = svc.bi_rados->bucket_shard_index(obj_key, bucket_info.layout.current_index.layout.normal.num_shards);
+        uint32_t sid = svc.bi_rados->bucket_shard_index(obj_key, layout.num_shards);
         if (shard_id) {
           *shard_id = (int)sid;
         }
index 5d0e580c87b79060c60cba73e7720c85c545875f..db3c2bd6ebbf7c3e74a54b1c3d6b1af4ad146977 100644 (file)
@@ -1425,7 +1425,7 @@ public:
                              uint64_t end_epoch);
   int cls_obj_usage_log_clear(string& oid);
 
-  int get_target_shard_id(const RGWBucketInfo& bucket_info, const string& obj_key, int *shard_id);
+  int get_target_shard_id(const rgw::bucket_index_normal_layout& layout, const string& obj_key, int *shard_id);
 
   int lock_exclusive(const rgw_pool& pool, const string& oid, ceph::timespan& duration, rgw_zone_id& zone_id, string& owner_id);
   int unlock(const rgw_pool& pool, const string& oid, rgw_zone_id& zone_id, string& owner_id);
index d1a5af6ed3cf9f391424b4d3a3bf66574631399b..d1d42fde1c66f50bf14fb8ed320c17f2e5f254eb 100644 (file)
@@ -525,6 +525,7 @@ int RGWBucketReshard::do_reshard(int num_shards,
                                 Formatter *formatter)
 {
   rgw_bucket& bucket = bucket_info.bucket;
+  rgw::bucket_index_normal_layout layout;
 
   int ret = 0;
 
@@ -611,7 +612,7 @@ int RGWBucketReshard::do_reshard(int num_shards,
          // place the multipart .meta object on the same shard as its head object
          obj.index_hash_source = mp.get_key();
        }
-       int ret = store->getRados()->get_target_shard_id(new_bucket_info, obj.get_hash_object(), &target_shard_id);
+       int ret = store->getRados()->get_target_shard_id(layout, obj.get_hash_object(), &target_shard_id);
        if (ret < 0) {
          lderr(store->ctx()) << "ERROR: get_target_shard_id() returned ret=" << ret << dendl;
          return ret;