]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: Do not decrement stats cache when the cache values are zero 16389/head
authorPavan Rallabhandi <PRallabhandi@walmartlabs.com>
Tue, 18 Jul 2017 09:10:04 +0000 (14:40 +0530)
committerPavan Rallabhandi <PRallabhandi@walmartlabs.com>
Tue, 25 Jul 2017 09:01:49 +0000 (14:31 +0530)
With RGWs configured in a load balancer, there is a possibility of
having the cached values going unbound, when PUT/DELETE operations
do not land up on the same RGW. To avoid such cases, make sure the
decrement of stats happen only when the cached values are sane.

Fixes: http://tracker.ceph.com/issues/20661
Signed-off-by: Pavan Rallabhandi <PRallabhandi@walmartlabs.com>
src/rgw/rgw_quota.cc

index 370cf3f1a6063a2a31ae7cff0da8c813c37ca47d..bf74e7fdc3243f8b54239337f010bb595af5d35e 100644 (file)
@@ -232,9 +232,23 @@ public:
     const uint64_t rounded_added = rgw_rounded_objsize(added_bytes);
     const uint64_t rounded_removed = rgw_rounded_objsize(removed_bytes);
 
-    entry->stats.size += added_bytes - removed_bytes;
-    entry->stats.size_rounded += rounded_added - rounded_removed;
-    entry->stats.num_objects += objs_delta;
+    if ((entry->stats.size + added_bytes - removed_bytes) >= 0) {
+      entry->stats.size += added_bytes - removed_bytes;
+    } else {
+      entry->stats.size = 0;
+    }
+
+    if ((entry->stats.size_rounded + rounded_added - rounded_removed) >= 0) {
+      entry->stats.size_rounded += rounded_added - rounded_removed;
+    } else {
+      entry->stats.size_rounded = 0;
+    }
+
+    if ((entry->stats.num_objects + objs_delta) >= 0) {
+      entry->stats.num_objects += objs_delta;
+    } else {
+      entry->stats.num_objects = 0;
+    }
 
     return true;
   }