]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: round bytes to the next 4k for quota use
authorYehuda Sadeh <yehuda@inktank.com>
Tue, 14 Jan 2014 08:18:52 +0000 (00:18 -0800)
committerYehuda Sadeh <yehuda@inktank.com>
Fri, 24 Jan 2014 18:28:53 +0000 (10:28 -0800)
Be more consistent as we round it like this in the objclass, so we need
the accounting to match.

Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/rgw/rgw_common.h
src/rgw/rgw_quota.cc

index 3e4f0f4823f356ee2ded6687b24cda5b6739cf45..cd10ceb05c5b0b18c5ecc370a85c1c48cf6b8131 100644 (file)
@@ -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<string>& ovals);
 extern int parse_key_value(string& in_str, string& key, string& val);
index 2854c312c7e46df0d6b0e3471ed1b8bf9751e5da..3e677b30f8487ae5364656bf0feec3f114220618 100644 (file)
@@ -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;