]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: On every incoming MPGStats, check for a full/near-full OSD and mark map if needed.
authorGreg Farnum <gregf@hq.newdream.net>
Thu, 22 Oct 2009 05:48:12 +0000 (22:48 -0700)
committerGreg Farnum <gregf@hq.newdream.net>
Fri, 23 Oct 2009 21:14:46 +0000 (14:14 -0700)
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h
src/mon/PGMonitor.cc
src/osd/osd_types.h

index 971049a4b4c6d38e563e2e974bbc15ef8b31ada5..2ba4307c590b4019c17197f577dc049e406be950 100644 (file)
@@ -271,6 +271,11 @@ bool OSDMonitor::should_propose(double& delay)
   if (pending_inc.fullmap.length())
     return true;
 
+  if (pending_inc.new_flags & CEPH_OSDMAP_FULL) { //get that info out there!
+    delay = 0.0;
+    return true;
+  }
+
   // adjust osd weights?
   if (osd_weight.size() == (unsigned)osdmap.get_max_osd()) {
     dout(0) << " adjusting osd weights based on " << osd_weight << dendl;
@@ -802,6 +807,9 @@ void OSDMonitor::tick()
     }
   }
 
+  //if map is set to full, get that info out there!
+  if (pending_inc.new_flags & CEPH_OSDMAP_FULL)
+    do_propose = true;
 
   // ---------------
 #define SWAP_PRIMARIES_AT_START 0
index 1caa0fac0de76eca249f9c1a0754542ca2213efe..35dc36c60d58f21dfc5747ea166d46a618229fe9 100644 (file)
@@ -163,6 +163,11 @@ private:
   void check_subs();
   void check_sub(Subscription *sub);
 
+  void add_flag(int flag) {
+    if (pending_inc.new_flags < 0)
+      pending_inc.new_flags = osdmap.flags;
+    pending_inc.new_flags |= flag;
+  }
 };
 
 #endif
index 1e6d5309e8270dee17a4dfc313de02a8263d44e0..f6ad0f69a031ca46a64704f5f1483fa9ec90d49e 100644 (file)
@@ -75,6 +75,7 @@ void PGMonitor::tick()
     // safely use mon->osdmon->osdmap
   }
   */
+
 }
 
 void PGMonitor::create_initial(bufferlist& bl)
@@ -324,6 +325,20 @@ bool PGMonitor::prepare_pg_stats(MPGStats *stats)
   else
     dout(10) << " got osd " << from << " " << stats->osd_stat << " (first report)" << dendl;
 
+  //Check how full the OSD is; set OSDMap to full/near-full if needed
+  float ratio = ((float)stats->osd_stat.kb_used) / (float) stats->osd_stat.kb;
+  if ( ratio > CEPH_OSD_FULL_RATIO ) {
+    dout(5) << "osd" << from << " has ratio " << ratio 
+           << "which is beyond CEPH_OSD_FULL_RATIO "
+           << CEPH_OSD_FULL_RATIO << dendl;
+    mon->osdmon()->add_flag(CEPH_OSDMAP_FULL);
+  } else if ( ratio > CEPH_OSD_NEARFULL_RATIO ) {
+    dout(10) << "osd" << from << " has ratio " << ratio 
+           << "which is beyond CEPH_OSD_NEARFULL_RATIO "
+           << CEPH_OSD_NEARFULL_RATIO << dendl;
+    mon->osdmon()->add_flag(CEPH_OSDMAP_NEARFULL);
+  }
+
   // apply to live map too (screw consistency)
   /*
     actually, no, don't.  that screws up our "latest" stash.  and can
index 1473f34b395681847869e75cc23f03fa74d1b459..d4bce24ffe70ee3e18332f7dc3716b6e9acaa946 100644 (file)
@@ -26,7 +26,8 @@
 
 #define CEPH_OSD_ONDISK_MAGIC "ceph osd volume v024"
 
-
+#define CEPH_OSD_NEARFULL_RATIO .8
+#define CEPH_OSD_FULL_RATIO .95