]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: using the same bucket num_shards as master zg when create bucket in secondary zg
authorlu.shasha <lu.shasha@eisoo.com>
Fri, 7 Apr 2017 07:34:27 +0000 (15:34 +0800)
committerlu.shasha <lu.shasha@eisoo.com>
Mon, 24 Apr 2017 01:05:23 +0000 (09:05 +0800)
create bucket in secondary zonegroup will forward to master. The master may have different num_shards option.
So when create bucket in local, should use master's num_shards instead of local num_shards option.

Fixes: http://tracker.ceph.com/issues/19745
Signed-off-by: Shasha Lu <lu.shasha@eisoo.com>
src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index 393af6b44385f7cb26561e8b4148aae3120c5330..ccab7d12a016b38f61861cf03b0fa9be99cbb618 100644 (file)
@@ -2264,6 +2264,7 @@ void RGWCreateBucket::execute()
 
   RGWBucketInfo master_info;
   rgw_bucket *pmaster_bucket;
+  uint32_t *pmaster_num_shards;
   real_time creation_time;
 
   if (!store->is_meta_master()) {
@@ -2280,9 +2281,11 @@ void RGWCreateBucket::execute()
     ldout(s->cct, 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;
     pobjv = &objv;
   } else {
     pmaster_bucket = NULL;
+    pmaster_num_shards = NULL;
   }
 
   string zonegroup_id;
@@ -2355,7 +2358,7 @@ void RGWCreateBucket::execute()
                                 placement_rule, s->bucket_info.swift_ver_location,
                                 pquota_info, attrs,
                                 info, pobjv, &ep_objv, creation_time,
-                                pmaster_bucket, true);
+                                pmaster_bucket, pmaster_num_shards, true);
   /* continue if EEXIST and create_bucket will fail below.  this way we can
    * recover from a partial create by retrying it. */
   ldout(s->cct, 20) << "rgw_create_bucket returned ret=" << op_ret << " bucket=" << s->bucket << dendl;
@@ -5428,6 +5431,7 @@ int RGWBulkUploadOp::handle_dir(const boost::string_ref path)
 
   RGWBucketInfo master_info;
   rgw_bucket *pmaster_bucket = nullptr;
+  uint32_t *pmaster_num_shards = nullptr;
   real_time creation_time;
   obj_version objv, ep_objv, *pobjv = nullptr;
 
@@ -5450,9 +5454,11 @@ 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;
     pobjv = &objv;
   } else {
     pmaster_bucket = nullptr;
+    pmaster_num_shards = nullptr;
   }
 
 
@@ -5498,7 +5504,7 @@ int RGWBulkUploadOp::handle_dir(const boost::string_ref path)
                                 placement_rule, binfo.swift_ver_location,
                                 pquota_info, attrs,
                                 out_info, pobjv, &ep_objv, creation_time,
-                                pmaster_bucket, true);
+                                pmaster_bucket, pmaster_num_shards, true);
   /* continue if EEXIST and create_bucket will fail below.  this way we can
    * recover from a partial create by retrying it. */
   ldout(s->cct, 20) << "rgw_create_bucket returned ret=" << op_ret
index cdeca8ab4c98f26c677d3aae27a5c8bd70e791fc..17e5fe9bce49535f4056c990ef46e925ade59683 100644 (file)
@@ -5354,6 +5354,7 @@ int RGWRados::create_bucket(RGWUserInfo& owner, rgw_bucket& bucket,
                             obj_version *pep_objv,
                             real_time creation_time,
                             rgw_bucket *pmaster_bucket,
+                            uint32_t *pmaster_num_shards,
                            bool exclusive)
 {
 #define MAX_CREATE_RETRIES 20 /* need to bound retries */
@@ -5390,7 +5391,11 @@ int RGWRados::create_bucket(RGWUserInfo& owner, rgw_bucket& bucket,
     info.index_type = rule_info.index_type;
     info.swift_ver_location = swift_ver_location;
     info.swift_versioning = (!swift_ver_location.empty());
-    info.num_shards = bucket_index_max_shards;
+    if (pmaster_num_shards) {
+      info.num_shards = *pmaster_num_shards;
+    } else {
+      info.num_shards = bucket_index_max_shards;
+    }
     info.bucket_index_shard_hash_type = RGWBucketInfo::MOD;
     info.requester_pays = false;
     if (real_clock::is_zero(creation_time)) {
index 4a4f75c2bb537b3e8ad7449956e2947772b90bf2..16533d9f074870c12d600a4b9d5de56f9e5f4301 100644 (file)
@@ -2542,6 +2542,7 @@ public:
                             obj_version *pep_objv,
                             ceph::real_time creation_time,
                             rgw_bucket *master_bucket,
+                            uint32_t *master_num_shards,
                             bool exclusive = true);
   int add_bucket_placement(const rgw_pool& new_pool);
   int remove_bucket_placement(const rgw_pool& new_pool);