From: Yehuda Sadeh Date: Tue, 14 Jan 2014 08:18:52 +0000 (-0800) Subject: rgw: round bytes to the next 4k for quota use X-Git-Tag: v0.78~270^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2f9a93d385878b15dde9822cd98796b0866a969f;p=ceph.git rgw: round bytes to the next 4k for quota use Be more consistent as we round it like this in the objclass, so we need the accounting to match. Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_common.h b/src/rgw/rgw_common.h index 3e4f0f4823f3..cd10ceb05c5b 100644 --- a/src/rgw/rgw_common.h +++ b/src/rgw/rgw_common.h @@ -1279,6 +1279,11 @@ static inline uint64_t rgw_rounded_kb(uint64_t bytes) return (bytes + 1023) / 1024; } +static inline uint64_t rgw_rounded_objsize_kb(uint64_t bytes) +{ + return ((bytes + 4095) & ~4095) / 1024; +} + extern string rgw_string_unquote(const string& s); extern void parse_csv_string(const string& ival, vector& ovals); extern int parse_key_value(string& in_str, string& key, string& val); diff --git a/src/rgw/rgw_quota.cc b/src/rgw/rgw_quota.cc index 2854c312c7e4..3e677b30f848 100644 --- a/src/rgw/rgw_quota.cc +++ b/src/rgw/rgw_quota.cc @@ -217,8 +217,8 @@ public: RGWQuotaStatsUpdate(int _objs_delta, uint64_t _added_bytes, uint64_t _removed_bytes) : objs_delta(_objs_delta), added_bytes(_added_bytes), removed_bytes(_removed_bytes) {} bool update(RGWQuotaCacheStats *entry) { - uint64_t rounded_kb_added = rgw_rounded_kb(added_bytes); - uint64_t rounded_kb_removed = rgw_rounded_kb(removed_bytes); + uint64_t rounded_kb_added = rgw_rounded_objsize_kb(added_bytes); + uint64_t rounded_kb_removed = rgw_rounded_objsize_kb(removed_bytes); entry->stats.num_kb_rounded += (rounded_kb_added - rounded_kb_removed); entry->stats.num_kb += (added_bytes - removed_bytes) / 1024; @@ -561,7 +561,7 @@ public: virtual int check_quota(const string& user, rgw_bucket& bucket, RGWQuotaInfo& user_quota, RGWQuotaInfo& bucket_quota, uint64_t num_objs, uint64_t size) { - uint64_t size_kb = rgw_rounded_kb(size); + uint64_t size_kb = rgw_rounded_objsize_kb(size); if (bucket_quota.enabled) { RGWStorageStats bucket_stats;