]> 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:08:48 +0000 (10:08 -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 c3994d530b062c040808fb910659579199d64cd8..29cfea585ef0e8cb1e878fc5cbc8b29005a44238 100644 (file)
@@ -953,7 +953,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;
@@ -1353,7 +1353,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 "
@@ -1408,7 +1410,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();
@@ -1432,7 +1434,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 f8b1ad8bf0289b7a8e1bb8daadfe7b076e2b8ca4..4bea58219eceec121aa2488e52d9343074d3eb0c 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) {