From: Orit Wasserman Date: Thu, 18 May 2017 04:01:35 +0000 (+0300) Subject: rgw: add a check_bucket_shards to the quota X-Git-Tag: v12.1.0~276^2~39 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=553bf4b99685e29893093add82d0d37622f68de6;p=ceph-ci.git rgw: add a check_bucket_shards to the quota Signed-off-by: Orit Wasserman --- diff --git a/src/common/config_opts.h b/src/common/config_opts.h index ac95b1540d4..0502a8b1f56 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -1735,3 +1735,5 @@ OPTION(rgw_swift_custom_header, OPT_STR, "") // option to enable swift custom he /* resharding tunables */ OPTION(rgw_reshard_max_jobs, OPT_INT, 1024) OPTION(rgw_reshard_bucket_lock_duration, OPT_INT, 120) // duration of lock on bucket obj during resharding +OPTION(rgw_dynamic_resharding, OPT_BOOL, true) +OPTION(rgw_max_objs_per_shard, OPT_INT, 100000) diff --git a/src/rgw/rgw_quota.cc b/src/rgw/rgw_quota.cc index 6a61400a110..55dc64a0a72 100644 --- a/src/rgw/rgw_quota.cc +++ b/src/rgw/rgw_quota.cc @@ -939,6 +939,29 @@ public: bucket_stats_cache.adjust_stats(user, bucket, obj_delta, added_bytes, removed_bytes); user_stats_cache.adjust_stats(user, bucket, obj_delta, added_bytes, removed_bytes); } + + int check_bucket_shards(uint64_t max_objs_per_shard, uint64_t num_shards, + const rgw_user& user, rgw_bucket& bucket, RGWQuotaInfo& bucket_quota, + uint64_t num_objs, bool& need_resharding) + { + RGWStorageStats bucket_stats; + int ret = bucket_stats_cache.get_stats(user, bucket, bucket_stats, + bucket_quota); + if (ret < 0) { + return ret; + } + + if (bucket_stats.num_objects + num_objs > num_shards * max_objs_per_shard) { + dout(10) << "resharding needed: stats.num_objects=" << bucket_stats.num_objects + << " shard max_objects=" << max_objs_per_shard * num_shards << dendl; + need_resharding = true; + } else { + need_resharding = false; + } + + return 0; + } + }; @@ -951,3 +974,5 @@ void RGWQuotaHandler::free_handler(RGWQuotaHandler *handler) { delete handler; } + + diff --git a/src/rgw/rgw_quota.h b/src/rgw/rgw_quota.h index 9291434634c..b542c603eea 100644 --- a/src/rgw/rgw_quota.h +++ b/src/rgw/rgw_quota.h @@ -103,6 +103,10 @@ public: RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t num_objs, uint64_t size) = 0; + virtual int check_bucket_shards(uint64_t max_objs_per_shard, uint64_t num_shards, + const rgw_user& bucket_owner, rgw_bucket& bucket, + RGWQuotaInfo& bucket_quota, uint64_t num_objs, bool& need_resharding) = 0; + virtual void update_stats(const rgw_user& bucket_owner, rgw_bucket& bucket, int obj_delta, uint64_t added_bytes, uint64_t removed_bytes) = 0; static RGWQuotaHandler *generate_handler(RGWRados *store, bool quota_threads); diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index f6d11f239e9..bb3e34a26ea 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -13080,6 +13080,18 @@ 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) +{ + 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); +} + + int RGWRados::check_quota(const rgw_user& bucket_owner, rgw_bucket& bucket, RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t obj_size) { diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 3b7f5a362e8..d9d67065755 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -3479,6 +3479,10 @@ 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); + uint64_t instance_id(); const string& zone_id() { return get_zone_params().get_id();