]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: fix full ratio updates
authorSage Weil <sage@newdream.net>
Fri, 30 Dec 2011 16:06:55 +0000 (08:06 -0800)
committerSage Weil <sage@newdream.net>
Fri, 30 Dec 2011 16:06:55 +0000 (08:06 -0800)
- update them independently
- only if we are leader
- fix type for nearfull_ratio

Signed-off-by: Sage Weil <sage@newdream.net>
src/mon/PGMonitor.cc
src/mon/PGMonitor.h

index 1ad13b88a403c9069f8fd5aa08baaf84f699f2e4..1deb37336ba1cad28380545398f40d0d43dcd71b 100644 (file)
@@ -57,7 +57,8 @@ public:
   virtual ~RatioMonitor() {}
   virtual const char **get_tracked_conf_keys() const {
     static const char *KEYS[] = { "mon_osd_full_ratio",
-                                 "mon_osd_nearfull_ratio", NULL };
+                                 "mon_osd_nearfull_ratio",
+                                 NULL };
     return KEYS;
   }
   virtual void handle_conf_change(const md_config_t *conf,
@@ -69,7 +70,9 @@ public:
 
 PGMonitor::PGMonitor(Monitor *mn, Paxos *p)
   : PaxosService(mn, p),
-    ratio_lock("PGMonitor::ratio_lock"), need_ratio_update(false),
+    ratio_lock("PGMonitor::ratio_lock"),
+    need_full_ratio_update(false),
+    need_nearfull_ratio_update(false)
 {
   ratio_monitor = new RatioMonitor(this);
   g_conf->add_observer(ratio_monitor);
@@ -134,6 +137,20 @@ void PGMonitor::update_logger()
   mon->cluster_logger->set(l_cluster_num_kb, pg_map.pg_sum.stats.sum.num_kb);
 }
 
+void PGMonitor::update_full_ratios(float full_ratio, float nearfull_ratio)
+{
+  Mutex::Locker l(ratio_lock);
+  dout(10) << "update_full_ratios full " << full_ratio << " nearfull " << nearfull_ratio << dendl;
+  if (full_ratio != 0) {
+    new_full_ratio = full_ratio;
+    need_full_ratio_update = true;
+  }
+  if (nearfull_ratio != 0) {
+    new_nearfull_ratio = nearfull_ratio;
+    need_nearfull_ratio_update = true;
+  }
+}
+
 void PGMonitor::tick() 
 {
   if (!paxos->is_active()) return;
@@ -143,13 +160,27 @@ void PGMonitor::tick()
 
   if (mon->is_leader()) {
     ratio_lock.Lock();
-    if (need_ratio_update) {
-      need_ratio_update = false;
-      pending_inc.full_ratio = new_full_ratio;
-      pending_inc.nearfull_ratio = new_nearfull_ratio;
-      propose_pending();
+    bool propose = false;
+    if (need_full_ratio_update) {
+      dout(10) << "tick need full ratio update " << new_full_ratio << dendl;
+      need_full_ratio_update = false;
+      if (pg_map.full_ratio != new_full_ratio) {
+       pending_inc.full_ratio = new_full_ratio;
+       propose = true;
+      }
+    }
+    if (need_nearfull_ratio_update) {
+      dout(10) << "tick need nearfull ratio update " << new_nearfull_ratio << dendl;
+      need_nearfull_ratio_update = false;
+      if (pg_map.nearfull_ratio != new_nearfull_ratio) {
+       pending_inc.nearfull_ratio = new_nearfull_ratio;
+       propose = true;
+      }
     }
     ratio_lock.Unlock();
+    if (propose) {
+      propose_pending();
+    }
   }
 
   dout(10) << pg_map << dendl;
index eb839def1d33759798a8e4a3abb473c3d26baba2..56722914561b972fbfba221a95e70125ab7918b2 100644 (file)
@@ -44,7 +44,7 @@ public:
   PGMap pg_map;
 
   Mutex ratio_lock;
-  bool need_ratio_update;
+  bool need_full_ratio_update, need_nearfull_ratio_update;
   float new_full_ratio, new_nearfull_ratio;
 
 private:
@@ -66,14 +66,7 @@ private:
   bool prepare_pg_stats(MPGStats *stats);
   void _updated_stats(MPGStats *req, MPGStatsAck *ack);
 
-  void update_full_ratios(float full_ratio, int nearfull_ratio) {
-    Mutex::Locker l(ratio_lock);
-    if (full_ratio != 0)
-      new_full_ratio = full_ratio;
-    if (nearfull_ratio != 0)
-      new_nearfull_ratio = nearfull_ratio;
-    need_ratio_update = true;
-  }
+  void update_full_ratios(float full_ratio, float nearfull_ratio);
 
   struct C_Stats : public Context {
     PGMonitor *pgmon;