]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Prevent overflow of stats cached values 16720/head
authorAleksei Gutikov <aleksey.gutikov@synesis.ru>
Mon, 21 Aug 2017 14:04:45 +0000 (17:04 +0300)
committerPavan Rallabhandi <PRallabhandi@walmartlabs.com>
Mon, 28 Aug 2017 07:13:10 +0000 (12:43 +0530)
Signed-off-by: Pavan Rallabhandi <PRallabhandi@walmartlabs.com>
Fixes: http://tracker.ceph.com/issues/20934
Signed-off-by: Aleksei Gutikov <aleksey.gutikov@synesis.ru>
(cherry picked from commit 634215eea1ddd4e4f5dc0066c4a2e745cfc20475)

Conflicts:
src/rgw/rgw_quota.cc
       Have the quota stats structures to reflect rounded values in KB and honor the signed integer values

src/rgw/rgw_quota.cc

index 1153639184e928cda2a1e57bfba18023062bfc72..dc880b4bd0d88494dc033d4a373d50cbf3f5fbbb 100644 (file)
@@ -221,19 +221,19 @@ public:
     uint64_t rounded_kb_added = rgw_rounded_objsize_kb(added_bytes);
     uint64_t rounded_kb_removed = rgw_rounded_objsize_kb(removed_bytes);
 
-    if ((entry->stats.num_kb_rounded + rounded_kb_added - rounded_kb_removed) >= 0) {
+    if (((int64_t)(entry->stats.num_kb_rounded + rounded_kb_added - rounded_kb_removed)) >= 0) {
       entry->stats.num_kb_rounded += (rounded_kb_added - rounded_kb_removed);
     } else {
       entry->stats.num_kb_rounded = 0;
     }
     
-    if ((entry->stats.num_kb + ((added_bytes - removed_bytes) / 1024)) >= 0) {
+    if (((int64_t)(entry->stats.num_kb + ((added_bytes - removed_bytes) / 1024))) >= 0) {
       entry->stats.num_kb += (added_bytes - removed_bytes) / 1024;
     } else {
       entry->stats.num_kb = 0;
     }
     
-    if ((entry->stats.num_objects + objs_delta) >= 0) {
+    if (((int64_t)(entry->stats.num_objects + objs_delta)) >= 0) {
       entry->stats.num_objects += objs_delta;
     } else {
       entry->stats.num_objects = 0;