From: Zulai Wang Date: Sat, 22 May 2021 13:21:10 +0000 (+0800) Subject: rgw: remove quota soft threshold X-Git-Tag: v17.1.0~1814^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=32a39705765af0f87bec9101e5d337b797e05fea;p=ceph-ci.git rgw: remove quota soft threshold Remove quota soft threshold, which causes expensive checks for sharded buckets Fixes: 14eabd4aa7b8a2e2c0c43fe7f877ed2171277526 Signed-off-by: Zulai Wang --- diff --git a/src/common/options/rgw.yaml.in b/src/common/options/rgw.yaml.in index 5c3ab21335c..57e31d9bdbb 100644 --- a/src/common/options/rgw.yaml.in +++ b/src/common/options/rgw.yaml.in @@ -1774,18 +1774,6 @@ options: services: - rgw with_legacy: true -- name: rgw_bucket_quota_soft_threshold - type: float - level: basic - desc: RGW quota soft threshold - long_desc: Threshold from which RGW doesn't rely on cached info for quota decisions. - This is done for higher accuracy of the quota mechanism at cost of performance, - when getting close to the quota limit. The value configured here is the ratio - between the data usage to the max usage as specified by the quota. - default: 0.95 - services: - - rgw - with_legacy: true - name: rgw_bucket_quota_cache_size type: int level: advanced diff --git a/src/rgw/rgw_quota.cc b/src/rgw/rgw_quota.cc index 4759f43c6ff..02d1652bd5f 100644 --- a/src/rgw/rgw_quota.cc +++ b/src/rgw/rgw_quota.cc @@ -81,11 +81,10 @@ public: async_refcount->put_wait(); /* wait for all pending async requests to complete */ } - int get_stats(const rgw_user& user, const rgw_bucket& bucket, RGWStorageStats& stats, RGWQuotaInfo& quota, optional_yield y, const DoutPrefixProvider *dpp); + int get_stats(const rgw_user& user, const rgw_bucket& bucket, RGWStorageStats& stats, optional_yield y, + const DoutPrefixProvider* dpp); void adjust_stats(const rgw_user& user, rgw_bucket& bucket, int objs_delta, uint64_t added_bytes, uint64_t removed_bytes); - virtual bool can_use_cached_stats(RGWQuotaInfo& quota, RGWStorageStats& stats); - void set_stats(const rgw_user& user, const rgw_bucket& bucket, RGWQuotaCacheStats& qs, RGWStorageStats& stats); int async_refresh(const rgw_user& user, const rgw_bucket& bucket, RGWQuotaCacheStats& qs); void async_refresh_response(const rgw_user& user, rgw_bucket& bucket, RGWStorageStats& stats); @@ -106,36 +105,6 @@ public: virtual AsyncRefreshHandler *allocate_refresh_handler(const rgw_user& user, const rgw_bucket& bucket) = 0; }; -template -bool RGWQuotaCache::can_use_cached_stats(RGWQuotaInfo& quota, RGWStorageStats& cached_stats) -{ - if (quota.max_size >= 0) { - if (quota.max_size_soft_threshold < 0) { - quota.max_size_soft_threshold = quota.max_size * store->ctx()->_conf->rgw_bucket_quota_soft_threshold; - } - - if (cached_stats.size_rounded >= (uint64_t)quota.max_size_soft_threshold) { - ldout(store->ctx(), 20) << "quota: can't use cached stats, exceeded soft threshold (size): " - << cached_stats.size_rounded << " >= " << quota.max_size_soft_threshold << dendl; - return false; - } - } - - if (quota.max_objects >= 0) { - if (quota.max_objs_soft_threshold < 0) { - quota.max_objs_soft_threshold = quota.max_objects * store->ctx()->_conf->rgw_bucket_quota_soft_threshold; - } - - if (cached_stats.num_objects >= (uint64_t)quota.max_objs_soft_threshold) { - ldout(store->ctx(), 20) << "quota: can't use cached stats, exceeded soft threshold (num objs): " - << cached_stats.num_objects << " >= " << quota.max_objs_soft_threshold << dendl; - return false; - } - } - - return true; -} - template int RGWQuotaCache::async_refresh(const rgw_user& user, const rgw_bucket& bucket, RGWQuotaCacheStats& qs) { @@ -196,7 +165,7 @@ void RGWQuotaCache::set_stats(const rgw_user& user, const rgw_bucket& bucket, } template -int RGWQuotaCache::get_stats(const rgw_user& user, const rgw_bucket& bucket, RGWStorageStats& stats, RGWQuotaInfo& quota, optional_yield y, const DoutPrefixProvider *dpp) { +int RGWQuotaCache::get_stats(const rgw_user& user, const rgw_bucket& bucket, RGWStorageStats& stats, optional_yield y, const DoutPrefixProvider* dpp) { RGWQuotaCacheStats qs; utime_t now = ceph_clock_now(); if (map_find(user, bucket, qs)) { @@ -209,8 +178,7 @@ int RGWQuotaCache::get_stats(const rgw_user& user, const rgw_bucket& bucket, } } - if (can_use_cached_stats(quota, qs.stats) && qs.expiration > - ceph_clock_now()) { + if (qs.expiration > ceph_clock_now()) { stats = qs.stats; return 0; } @@ -598,13 +566,6 @@ public: return new UserAsyncRefreshHandler(dpp, store, this, user, bucket); } - bool can_use_cached_stats(RGWQuotaInfo& quota, RGWStorageStats& stats) override { - /* in the user case, the cached stats may contain a better estimation of the totals, as - * the backend is only periodically getting updated. - */ - return true; - } - bool going_down() { return down_flag; } @@ -953,8 +914,7 @@ public: const DoutPrefix dp(store->ctx(), dout_subsys, "rgw quota handler: "); if (bucket_quota.enabled) { RGWStorageStats bucket_stats; - int ret = bucket_stats_cache.get_stats(user, bucket, bucket_stats, - bucket_quota, y, &dp); + int ret = bucket_stats_cache.get_stats(user, bucket, bucket_stats, y, &dp); if (ret < 0) { return ret; } @@ -966,8 +926,7 @@ public: if (user_quota.enabled) { RGWStorageStats user_stats; - int ret = user_stats_cache.get_stats(user, bucket, user_stats, - user_quota, y, &dp); + int ret = user_stats_cache.get_stats(user, bucket, user_stats, y, &dp); if (ret < 0) { return ret; } diff --git a/src/rgw/rgw_quota.h b/src/rgw/rgw_quota.h index b8b386bbdce..df50d6cdad1 100644 --- a/src/rgw/rgw_quota.h +++ b/src/rgw/rgw_quota.h @@ -37,14 +37,6 @@ namespace rgw { namespace sal { struct RGWQuotaInfo { template friend class RGWQuotaCache; -protected: - /* The quota thresholds after which comparing against cached storage stats - * is disallowed. Those fields may be accessed only by the RGWQuotaCache. - * They are not intended as tunables but rather as a mean to store results - * of repeating calculations in the quota cache subsystem. */ - int64_t max_size_soft_threshold; - int64_t max_objs_soft_threshold; - public: int64_t max_size; int64_t max_objects; @@ -54,9 +46,7 @@ public: bool check_on_raw; RGWQuotaInfo() - : max_size_soft_threshold(-1), - max_objs_soft_threshold(-1), - max_size(-1), + : max_size(-1), max_objects(-1), enabled(false), check_on_raw(false) {