From: lu.shasha Date: Fri, 7 Apr 2017 07:34:27 +0000 (+0800) Subject: rgw: using the same bucket num_shards as master zg when create bucket in secondary zg X-Git-Tag: v11.2.1~9^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9182c279cf2f2228471d506113c61566cbfea4bb;p=ceph.git rgw: using the same bucket num_shards as master zg when create bucket in secondary zg 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 (cherry picked from commit a34c4b8fb13dd5590eb3c6ecb5e55207ed8e3ee8) Conflicts: src/rgw/rgw_op.cc - no RGWBulkUploadOp:: methods in kraken; modifications to RGWBulkUploadOp::handle_dir() omitted --- diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index 6f29be48ecb..094079f34c4 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -2263,6 +2263,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()) { @@ -2279,9 +2280,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; @@ -2353,7 +2356,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; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 48a2344bf8d..0c409d0da2e 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -5374,6 +5374,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 */ @@ -5415,7 +5416,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)) { diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index c3475a28d6b..09e1bc84ec6 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -2265,6 +2265,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);