]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Osd: revise agent_choose_mode() to track the flush mode
authorMingxin Liu <mingxinliu@ubuntukylin.com>
Thu, 28 May 2015 06:33:10 +0000 (14:33 +0800)
committerliumingxin <mingxinliu@ubuntukylin.com>
Tue, 2 Jun 2015 01:59:52 +0000 (09:59 +0800)
Signed-off-by: Mingxin Liu <mingxinliu@ubuntukylin.com>
Reviewed-by: Li Wang <liwang@ubuntukylin.com>
Suggested-by: Nick Fisk <nick@fisk.me.uk>
src/osd/OSD.cc
src/osd/OSD.h
src/osd/ReplicatedPG.cc

index 294272844c4439aecbd46884aefe25c6c09e2399..e6393855132bdde73f7a1be2432aa55692b44587 100644 (file)
@@ -212,6 +212,7 @@ OSDService::OSDService(OSD *osd) :
   agent_lock("OSD::agent_lock"),
   agent_valid_iterator(false),
   agent_ops(0),
+  flush_mode_high_count(0),
   agent_active(true),
   agent_thread(this),
   agent_stop_flag(false),
index 2cf6819f596b836519696e36ef3d919e7ee85739..454896b5530b24d620b31de8f993a62444a9b238 100644 (file)
@@ -581,6 +581,7 @@ public:
   set<PGRef>::iterator agent_queue_pos;
   bool agent_valid_iterator;
   int agent_ops;
+  int flush_mode_high_count; //once have one pg with FLUSH_MODE_HIGH then flush objects with high speed
   set<hobject_t> agent_oids;
   bool agent_active;
   struct AgentThread : public Thread {
@@ -672,6 +673,16 @@ public:
     return agent_ops;
   }
 
+  void agent_inc_high_count() {
+    Mutex::Locker l(agent_lock);
+    flush_mode_high_count ++;
+  }
+
+  void agent_dec_high_count() {
+    Mutex::Locker l(agent_lock);
+    flush_mode_high_count --;
+  }
+
 
   // -- Objecter, for teiring reads/writes from/to other OSDs --
   Objecter *objecter;
index 4c549a5fd3d39bbaca0b7adc821744054b473115..a59958425660cde70cf087df7757cbc8d96b1c7c 100644 (file)
@@ -11020,17 +11020,23 @@ bool ReplicatedPG::agent_choose_mode(bool restart, OpRequestRef op)
   // flush mode
   TierAgentState::flush_mode_t flush_mode = TierAgentState::FLUSH_MODE_IDLE;
   uint64_t flush_target = pool.info.cache_target_dirty_ratio_micro;
+  uint64_t flush_high_target = pool.info.cache_target_dirty_high_ratio_micro;
   uint64_t flush_slop = (float)flush_target * g_conf->osd_agent_slop;
-  if (restart || agent_state->flush_mode == TierAgentState::FLUSH_MODE_IDLE)
+  if (restart || agent_state->flush_mode == TierAgentState::FLUSH_MODE_IDLE) {
     flush_target += flush_slop;
-  else
+    flush_high_target += flush_slop;
+  } else {
     flush_target -= MIN(flush_target, flush_slop);
+    flush_high_target -= MIN(flush_high_target, flush_slop);
+  }
 
   if (info.stats.stats_invalid) {
     // idle; stats can't be trusted until we scrub.
     dout(20) << __func__ << " stats invalid (post-split), idle" << dendl;
+  } else if (dirty_micro > flush_high_target) {
+    flush_mode = TierAgentState::FLUSH_MODE_HIGH;
   } else if (dirty_micro > flush_target) {
-    flush_mode = TierAgentState::FLUSH_MODE_ACTIVE;
+    flush_mode = TierAgentState::FLUSH_MODE_LOW;
   }
 
   // evict mode
@@ -11075,6 +11081,10 @@ bool ReplicatedPG::agent_choose_mode(bool restart, OpRequestRef op)
            << " -> "
            << TierAgentState::get_flush_mode_name(flush_mode)
            << dendl;
+    if (flush_mode == TierAgentState::FLUSH_MODE_HIGH)
+      osd->agent_inc_high_count();
+    if (agent_state->flush_mode == TierAgentState::FLUSH_MODE_HIGH)
+      osd->agent_dec_high_count();
     agent_state->flush_mode = flush_mode;
   }
   if (evict_mode != agent_state->evict_mode) {