]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: add flush/evict mode in pg stats
authorZhiqiang Wang <zhiqiang.wang@intel.com>
Tue, 11 Aug 2015 03:31:01 +0000 (11:31 +0800)
committerZhiqiang Wang <zhiqiang.wang@intel.com>
Thu, 13 Aug 2015 02:34:05 +0000 (10:34 +0800)
These statistic data are used to show the PGs in high/low flush mode and
some/full evict mode in the command line.

Signed-off-by: Zhiqiang Wang <zhiqiang.wang@intel.com>
src/osd/ReplicatedPG.cc
src/osd/osd_types.cc
src/osd/osd_types.h

index 4f5382cffce8be5f2747d020ffab7086b8752fc6..8a20f9ed0d8282896e6fc229163a62ae6f698fba 100644 (file)
@@ -11156,10 +11156,18 @@ bool ReplicatedPG::agent_choose_mode(bool restart, OpRequestRef op)
            << " -> "
            << TierAgentState::get_flush_mode_name(flush_mode)
            << dendl;
-    if (flush_mode == TierAgentState::FLUSH_MODE_HIGH)
+    if (flush_mode == TierAgentState::FLUSH_MODE_HIGH) {
       osd->agent_inc_high_count();
-    if (agent_state->flush_mode == TierAgentState::FLUSH_MODE_HIGH)
+      info.stats.stats.sum.num_flush_mode_high = 1;
+    } else if (flush_mode == TierAgentState::FLUSH_MODE_LOW) {
+      info.stats.stats.sum.num_flush_mode_low = 1;
+    }
+    if (agent_state->flush_mode == TierAgentState::FLUSH_MODE_HIGH) {
       osd->agent_dec_high_count();
+      info.stats.stats.sum.num_flush_mode_high = 0;
+    } else if (agent_state->flush_mode == TierAgentState::FLUSH_MODE_LOW) {
+      info.stats.stats.sum.num_flush_mode_low = 0;
+    }
     agent_state->flush_mode = flush_mode;
   }
   if (evict_mode != agent_state->evict_mode) {
@@ -11176,6 +11184,16 @@ bool ReplicatedPG::agent_choose_mode(bool restart, OpRequestRef op)
       requeue_ops(waiting_for_cache_not_full);
       requeued = true;
     }
+    if (evict_mode == TierAgentState::EVICT_MODE_SOME) {
+      info.stats.stats.sum.num_evict_mode_some = 1;
+    } else if (evict_mode == TierAgentState::EVICT_MODE_FULL) {
+      info.stats.stats.sum.num_evict_mode_full = 1;
+    }
+    if (agent_state->evict_mode == TierAgentState::EVICT_MODE_SOME) {
+      info.stats.stats.sum.num_evict_mode_some = 0;
+    } else if (agent_state->evict_mode == TierAgentState::EVICT_MODE_FULL) {
+      info.stats.stats.sum.num_evict_mode_full = 0;
+    }
     agent_state->evict_mode = evict_mode;
   }
   uint64_t old_effort = agent_state->evict_effort;
index df9f5974e777046b25d25dbd8e8fa2583985af4d..49727de05226125e1f4b051545801bb2bb94b2d9 100644 (file)
@@ -1560,11 +1560,15 @@ void object_stat_sum_t::dump(Formatter *f) const
   f->dump_int("num_evict", num_evict);
   f->dump_int("num_evict_kb", num_evict_kb);
   f->dump_int("num_promote", num_promote);
+  f->dump_int("num_flush_mode_high", num_flush_mode_high);
+  f->dump_int("num_flush_mode_low", num_flush_mode_low);
+  f->dump_int("num_evict_mode_some", num_evict_mode_some);
+  f->dump_int("num_evict_mode_full", num_evict_mode_full);
 }
 
 void object_stat_sum_t::encode(bufferlist& bl) const
 {
-  ENCODE_START(12, 3, bl);
+  ENCODE_START(13, 3, bl);
   ::encode(num_bytes, bl);
   ::encode(num_objects, bl);
   ::encode(num_object_clones, bl);
@@ -1593,12 +1597,16 @@ void object_stat_sum_t::encode(bufferlist& bl) const
   ::encode(num_evict, bl);
   ::encode(num_evict_kb, bl);
   ::encode(num_promote, bl);
+  ::encode(num_flush_mode_high, bl);
+  ::encode(num_flush_mode_low, bl);
+  ::encode(num_evict_mode_some, bl);
+  ::encode(num_evict_mode_full, bl);
   ENCODE_FINISH(bl);
 }
 
 void object_stat_sum_t::decode(bufferlist::iterator& bl)
 {
-  DECODE_START_LEGACY_COMPAT_LEN(12, 3, 3, bl);
+  DECODE_START_LEGACY_COMPAT_LEN(13, 3, 3, bl);
   ::decode(num_bytes, bl);
   if (struct_v < 3) {
     uint64_t num_kb;
@@ -1675,6 +1683,17 @@ void object_stat_sum_t::decode(bufferlist::iterator& bl)
     num_evict_kb = 0;
     num_promote = 0;
   }
+  if (struct_v >= 13) {
+    ::decode(num_flush_mode_high, bl);
+    ::decode(num_flush_mode_low, bl);
+    ::decode(num_evict_mode_some, bl);
+    ::decode(num_evict_mode_full, bl);
+  } else {
+    num_flush_mode_high = 0;
+    num_flush_mode_low = 0;
+    num_evict_mode_some = 0;
+    num_evict_mode_full = 0;
+  }
   DECODE_FINISH(bl);
 }
 
@@ -1707,6 +1726,10 @@ void object_stat_sum_t::generate_test_instances(list<object_stat_sum_t*>& o)
   a.num_evict = 7;
   a.num_evict_kb = 8;
   a.num_promote = 9;
+  a.num_flush_mode_high = 0;
+  a.num_flush_mode_low = 1;
+  a.num_evict_mode_some = 1;
+  a.num_evict_mode_full = 0;
   o.push_back(new object_stat_sum_t(a));
 }
 
@@ -1740,6 +1763,10 @@ void object_stat_sum_t::add(const object_stat_sum_t& o)
   num_evict += o.num_evict;
   num_evict_kb += o.num_evict_kb;
   num_promote += o.num_promote;
+  num_flush_mode_high += o.num_flush_mode_high;
+  num_flush_mode_low += o.num_flush_mode_low;
+  num_evict_mode_some += o.num_evict_mode_some;
+  num_evict_mode_full += o.num_evict_mode_full;
 }
 
 void object_stat_sum_t::sub(const object_stat_sum_t& o)
@@ -1772,6 +1799,10 @@ void object_stat_sum_t::sub(const object_stat_sum_t& o)
   num_evict -= o.num_evict;
   num_evict_kb -= o.num_evict_kb;
   num_promote -= o.num_promote;
+  num_flush_mode_high -= o.num_flush_mode_high;
+  num_flush_mode_low -= o.num_flush_mode_low;
+  num_evict_mode_some -= o.num_evict_mode_some;
+  num_evict_mode_full -= o.num_evict_mode_full;
 }
 
 bool operator==(const object_stat_sum_t& l, const object_stat_sum_t& r)
@@ -1804,7 +1835,11 @@ bool operator==(const object_stat_sum_t& l, const object_stat_sum_t& r)
     l.num_flush_kb == r.num_flush_kb &&
     l.num_evict == r.num_evict &&
     l.num_evict_kb == r.num_evict_kb &&
-    l.num_promote == r.num_promote;
+    l.num_promote == r.num_promote &&
+    l.num_flush_mode_high == r.num_flush_mode_high &&
+    l.num_flush_mode_low == r.num_flush_mode_low &&
+    l.num_evict_mode_some == r.num_evict_mode_some &&
+    l.num_evict_mode_full == r.num_evict_mode_full;
 }
 
 // -- object_stat_collection_t --
index 0a304587939cbebc916229403d84d755558705b9..b043f83711ec3c2ec85b72807b7de488f0fdf8ef 100644 (file)
@@ -1330,6 +1330,10 @@ struct object_stat_sum_t {
   int64_t num_evict;
   int64_t num_evict_kb;
   int64_t num_promote;
+  int32_t num_flush_mode_high;  // 1 when in high flush mode, otherwise 0
+  int32_t num_flush_mode_low;   // 1 when in low flush mode, otherwise 0
+  int32_t num_evict_mode_some;  // 1 when in evict some mode, otherwise 0
+  int32_t num_evict_mode_full;  // 1 when in evict full mode, otherwise 0
 
   object_stat_sum_t()
     : num_bytes(0),
@@ -1352,7 +1356,9 @@ struct object_stat_sum_t {
       num_flush_kb(0),
       num_evict(0),
       num_evict_kb(0),
-      num_promote(0)
+      num_promote(0),
+      num_flush_mode_high(0), num_flush_mode_low(0),
+      num_evict_mode_some(0), num_evict_mode_full(0)
   {}
 
   void floor(int64_t f) {
@@ -1385,6 +1391,10 @@ struct object_stat_sum_t {
     FLOOR(num_evict);
     FLOOR(num_evict_kb);
     FLOOR(num_promote);
+    FLOOR(num_flush_mode_high);
+    FLOOR(num_flush_mode_low);
+    FLOOR(num_evict_mode_some);
+    FLOOR(num_evict_mode_full);
 #undef FLOOR
   }
 
@@ -1425,6 +1435,10 @@ struct object_stat_sum_t {
     SPLIT(num_evict);
     SPLIT(num_evict_kb);
     SPLIT(num_promote);
+    SPLIT(num_flush_mode_high);
+    SPLIT(num_flush_mode_low);
+    SPLIT(num_evict_mode_some);
+    SPLIT(num_evict_mode_full);
 #undef SPLIT
   }