]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ObjectCacher: use uint64_t for target and max values
authorJosh Durgin <josh.durgin@inktank.com>
Tue, 11 Feb 2014 19:53:00 +0000 (11:53 -0800)
committerJosh Durgin <josh.durgin@inktank.com>
Wed, 12 Feb 2014 18:10:28 +0000 (10:10 -0800)
All the options are uint64_t, but the ObjectCacher was converting them
to int64_t. There's never any reason for these to be negative, so
change the type.

Adjust a few conditionals so that they only convert known-positive
signed values to uint64_t before comparing with the target and max
values. Leave the actual stats accounting as loff_t for now, since
bugs in accounting will have bad effects if negative values wrap
around.

Backport: emperor, dumpling
Signed-off-by: Josh Durgin <josh.durgin@inktank.com>
(cherry picked from commit db034acf546a72739ff6543241543f3bd651f3ae)

src/osdc/ObjectCacher.cc
src/osdc/ObjectCacher.h

index 8dc57cff22248853cf073140a2e6cb17779cc475..5ce50c76431e34d183f03acdd3998915a05acfc7 100644 (file)
@@ -951,7 +951,7 @@ void ObjectCacher::trim()
                 << ", objects: max " << max_objects << " current " << ob_lru.lru_get_size()
                 << dendl;
 
-  while (get_stat_clean() > max_size) {
+  while (get_stat_clean() > 0 && (uint64_t) get_stat_clean() > max_size) {
     BufferHead *bh = static_cast<BufferHead*>(bh_lru_rest.lru_expire());
     if (!bh)
       break;
@@ -1351,7 +1351,9 @@ void ObjectCacher::maybe_wait_for_writeback(uint64_t len)
   //  - do not wait for bytes other waiters are waiting on.  this means that
   //    threads do not wait for each other.  this effectively allows the cache
   //    size to balloon proportional to the data that is in flight.
-  while (get_stat_dirty() + get_stat_tx() >= max_dirty + get_stat_dirty_waiting()) {
+  while (get_stat_dirty() + get_stat_tx() > 0 &&
+        (uint64_t) (get_stat_dirty() + get_stat_tx()) >=
+        max_dirty + get_stat_dirty_waiting()) {
     ldout(cct, 10) << __func__ << " waiting for dirty|tx "
                   << (get_stat_dirty() + get_stat_tx()) << " >= max "
                   << max_dirty << " + dirty_waiting "
@@ -1406,7 +1408,7 @@ int ObjectCacher::_wait_for_write(OSDWrite *wr, uint64_t len, ObjectSet *oset, M
   }
 
   // start writeback anyway?
-  if (get_stat_dirty() > target_dirty) {
+  if (get_stat_dirty() > 0 && (uint64_t) get_stat_dirty() > target_dirty) {
     ldout(cct, 10) << "wait_for_write " << get_stat_dirty() << " > target "
                   << target_dirty << ", nudging flusher" << dendl;
     flusher_cond.Signal();
@@ -1430,7 +1432,7 @@ void ObjectCacher::flusher_entry()
                   << max_dirty << " max)"
                   << dendl;
     loff_t actual = get_stat_dirty() + get_stat_dirty_waiting();
-    if (actual > target_dirty) {
+    if (actual > 0 && (uint64_t) actual > target_dirty) {
       // flush some dirty pages
       ldout(cct, 10) << "flusher " 
                     << get_stat_dirty() << " dirty + " << get_stat_dirty_waiting()
index 6930fe96216193c4bcbee63317af809b424a203c..cc9983aa6011a1529deb470515e17f66a7dd87aa 100644 (file)
@@ -332,7 +332,7 @@ class ObjectCacher {
   string name;
   Mutex& lock;
   
-  int64_t max_dirty, target_dirty, max_size, max_objects;
+  uint64_t max_dirty, target_dirty, max_size, max_objects;
   utime_t max_dirty_age;
   bool block_writes_upfront;
 
@@ -615,7 +615,7 @@ public:
 
 
   // cache sizes
-  void set_max_dirty(int64_t v) {
+  void set_max_dirty(uint64_t v) {
     max_dirty = v;
   }
   void set_target_dirty(int64_t v) {