From 04b5a7111666b793768321223937f9ec0adb8124 Mon Sep 17 00:00:00 2001 From: Yehuda Sadeh Date: Fri, 10 Jan 2014 16:28:24 -0800 Subject: [PATCH] rgw: some quota fixes Signed-off-by: Yehuda Sadeh --- src/rgw/rgw_quota.cc | 43 +++++++++++++++++++++---------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/src/rgw/rgw_quota.cc b/src/rgw/rgw_quota.cc index bf32a0f06becd..6f5f8ea0ba293 100644 --- a/src/rgw/rgw_quota.cc +++ b/src/rgw/rgw_quota.cc @@ -372,15 +372,15 @@ void UserAsyncRefreshHandler::handle_response(int r) class RGWUserStatsCache : public RGWQuotaCache { protected: bool map_find(const string& user, rgw_bucket& bucket, RGWQuotaCacheStats& qs) { - return stats_map.find(bucket, qs); + return stats_map.find(user, qs); } bool map_find_and_update(const string& user, rgw_bucket& bucket, lru_map::UpdateContext *ctx) { - return stats_map.find_and_update(bucket, NULL, ctx); + return stats_map.find_and_update(user, NULL, ctx); } void map_add(const string& user, rgw_bucket& bucket, RGWQuotaCacheStats& qs) { - stats_map.add(bucket, qs); + stats_map.add(user, qs); } int fetch_stats_from_storage(const string& user, rgw_bucket& bucket, RGWStorageStats& stats); @@ -438,31 +438,30 @@ public: RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t num_objs, uint64_t size) { uint64_t size_kb = rgw_rounded_kb(size); - if (!bucket_quota.enabled) { - return 0; - } - RGWStorageStats bucket_stats; + if (bucket_quota.enabled) { + RGWStorageStats bucket_stats; - int ret = bucket_stats_cache.get_stats(user, bucket, bucket_stats, bucket_quota); - if (ret < 0) - return ret; + int ret = bucket_stats_cache.get_stats(user, bucket, bucket_stats, bucket_quota); + if (ret < 0) + return ret; - ret = check_quota("bucket", bucket_quota, bucket_stats, num_objs, size_kb); - if (ret < 0) - return ret; - - RGWStorageStats user_stats; - - ret = user_stats_cache.get_stats(user, bucket, user_stats, user_quota); - if (ret < 0) - return ret; + ret = check_quota("bucket", bucket_quota, bucket_stats, num_objs, size_kb); + if (ret < 0) + return ret; + } - ret = check_quota("user", user_quota, user_stats, num_objs, size_kb); - if (ret < 0) - return ret; + if (user_quota.enabled) { + RGWStorageStats user_stats; + int ret = user_stats_cache.get_stats(user, bucket, user_stats, user_quota); + if (ret < 0) + return ret; + ret = check_quota("user", user_quota, user_stats, num_objs, size_kb); + if (ret < 0) + return ret; + } return 0; } -- 2.39.5