]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.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)
committerNathan Cutler <ncutler@suse.com>
Wed, 12 Jul 2017 13:24:36 +0000 (15:24 +0200)
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>
(cherry picked from commit a34c4b8fb13dd5590eb3c6ecb5e55207ed8e3ee8)

Conflicts:
    src/rgw/rgw_op.cc
    - different argument list of store->create_bucket() in jewel, compared to
      master
    - no RGWBulkUploadOp:: in jewel; modifications to
      RGWBulkUploadOp::handle_dir() omitted

src/rgw/rgw_op.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index 3af17ddcdecaca558e613b9ee4dec6be9982e18f..175349869dda868c7fde107fc4ae97a053d5ee66 100644 (file)
@@ -1980,6 +1980,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()) {
@@ -1995,9 +1996,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;
@@ -2055,7 +2058,7 @@ void RGWCreateBucket::execute()
   op_ret = store->create_bucket(*(s->user), s->bucket, zonegroup_id,
                                 placement_rule, s->bucket_info.swift_ver_location,
                                 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;
index 1030bb52cf307f1aa049774bf28343ce7ab54d07..4bde28b4826bdcef8ac84df176fff9976ca10890 100644 (file)
@@ -5172,6 +5172,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 */
@@ -5224,7 +5225,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 6a63a03a63663e43c76d2fc4cb65a11b862169f2..5bf125d88b0902d1ea0dbbd43091ccc2c0a4475f 100644 (file)
@@ -2117,6 +2117,7 @@ public:
                             obj_version *pep_objv,
                             ceph::real_time creation_time,
                             rgw_bucket *master_bucket,
+                            uint32_t *master_num_shards,
                             bool exclusive = true);
   virtual int add_bucket_placement(std::string& new_pool);
   virtual int remove_bucket_placement(std::string& new_pool);