From 444b9c918c39a82953c173d64d511aa58945c1cd Mon Sep 17 00:00:00 2001 From: Orit Wasserman Date: Fri, 19 May 2017 14:02:17 +0300 Subject: [PATCH] rgw: add bucket to resharding queue if needs resharding Signed-off-by: Orit Wasserman --- src/rgw/rgw_op.cc | 7 +------ src/rgw/rgw_rados.cc | 21 +++++++++++++++++---- src/rgw/rgw_rados.h | 5 ++--- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/rgw/rgw_op.cc b/src/rgw/rgw_op.cc index cc9f290ecad9b..4114cf0caa0a8 100644 --- a/src/rgw/rgw_op.cc +++ b/src/rgw/rgw_op.cc @@ -3118,15 +3118,10 @@ void RGWPutObj::execute() ldout(s->cct, 20) << "check_quota() returned ret=" << op_ret << dendl; goto done; } - bool need_resharding = false; - op_ret = store->check_bucket_shards(s->bucket_owner.get_id(), s->bucket, - bucket_quota, s->bucket_info.num_shards, need_resharding); + op_ret = store->check_bucket_shards(s->bucket_info, s->bucket, bucket_quota); if (op_ret < 0) { ldout(s->cct, 20) << "check_bucket_shards() returned ret=" << op_ret << dendl; goto done; - } else if (need_resharding) { - /* Add to resharding queue */ - ldout(s->cct, 20) << s->bucket << " needs resharding " << dendl; } } diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 10e2cc49d3ee8..51a21a89350c0 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -13080,15 +13080,28 @@ int RGWRados::cls_user_remove_bucket(rgw_raw_obj& obj, const cls_user_bucket& bu return 0; } -int RGWRados::check_bucket_shards(const rgw_user& bucket_owner, rgw_bucket& bucket, - RGWQuotaInfo& bucket_quota, uint64_t num_shards, bool& need_resharding) +int RGWRados::check_bucket_shards(const RGWBucketInfo& bucket_info, rgw_bucket& bucket, + RGWQuotaInfo& bucket_quota) { if (!cct->_conf->rgw_dynamic_resharding) { return 0; } - return quota_handler->check_bucket_shards((uint64_t)cct->_conf->rgw_max_objs_per_shard, num_shards, - bucket_owner, bucket, bucket_quota, 1, need_resharding); + bool need_resharding = false; + int num_source_shards = (bucket_info.num_shards > 0 ? bucket_info.num_shards : 1); + + int ret = quota_handler->check_bucket_shards((uint64_t)cct->_conf->rgw_max_objs_per_shard, + num_source_shards, bucket_info.owner, bucket, bucket_quota, + 1, need_resharding); + if (ret < 0) { + return ret; + } + + if (need_resharding) { + return add_bucket_to_reshard(bucket_info); + } + + return ret; } int RGWRados::add_bucket_to_reshard(const RGWBucketInfo& bucket_info) diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 7a856b42f5a46..88594eba0266e 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -3479,9 +3479,8 @@ public: int check_quota(const rgw_user& bucket_owner, rgw_bucket& bucket, RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size); - int check_bucket_shards(const rgw_user& bucket_owner, rgw_bucket& bucket, - RGWQuotaInfo& bucket_quota, uint64_t num_shards, - bool& need_resharding); + int check_bucket_shards(const RGWBucketInfo& bucket_info, rgw_bucket& bucket, + RGWQuotaInfo& bucket_quota); int add_bucket_to_reshard(const RGWBucketInfo& bucket_info); -- 2.39.5