]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: expire old blacklist items (osdmap change)
authorSage Weil <sage@newdream.net>
Tue, 16 Dec 2008 18:41:55 +0000 (10:41 -0800)
committerSage Weil <sage@newdream.net>
Wed, 17 Dec 2008 18:32:09 +0000 (10:32 -0800)
src/mon/OSDMonitor.cc
src/mon/OSDMonitor.h
src/osd/OSDMap.cc
src/osd/OSDMap.h

index 00251d361cdd2fd0454fc449563126d626242043..0675bbf3e0d68024b359bc07c9b49d0c8b579fac 100644 (file)
@@ -761,6 +761,15 @@ void OSDMonitor::bcast_full_osd()
 }
 
 
+
+void OSDMonitor::blacklist(entity_addr_t a, utime_t until)
+{
+  dout(10) << "blacklist " << a << " until " << until << dendl;
+  pending_inc.new_blacklist[a] = until;
+}
+
+
+
 // TICK
 
 
@@ -774,6 +783,9 @@ void OSDMonitor::tick()
   if (!mon->is_leader()) return;
 
 
+
+  bool do_propose = false;
+
   // mark down osds out?
   utime_t now = g_clock.now();
   list<int> mark_out;
@@ -794,37 +806,50 @@ void OSDMonitor::tick()
     down_pending_out.erase(*i);
     pending_inc.new_weight[*i] = CEPH_OSD_OUT;
   }
-  if (!mark_out.empty()) {
-    propose_pending();
+  if (!mark_out.empty())
+    do_propose = true;
+
+
+  // expire blacklisted items?
+  for (hash_map<entity_addr_t,utime_t>::iterator p = osdmap.blacklist.begin();
+       p != osdmap.blacklist.end();
+       p++) {
+    if (p->second < now) {
+      dout(10) << "expiring blacklist item " << p->first << " expired " << p->second << " < now " << now << dendl;
+      pending_inc.old_blacklist.push_back(p->first);
+      do_propose = true;
+    }
   }
 
 
+  // ---------------
 #define SWAP_PRIMARIES_AT_START 0
 #define SWAP_TIME 1
-
-  if (!SWAP_PRIMARIES_AT_START) return;
-
-  // For all PGs that have OSD 0 as the primary,
-  // switch them to use the first replca
-
-
-  ps_t numps = osdmap.get_pg_num();
-  int minrep = 1; 
-  int maxrep = MIN(g_conf.num_osd, g_conf.osd_max_rep);
-  for (int pool=0; pool<1; pool++)
-    for (int nrep = minrep; nrep <= maxrep; nrep++) { 
-      for (ps_t ps = 0; ps < numps; ++ps) {
-       pg_t pgid = pg_t(pg_t::TYPE_REP, nrep, ps, pool, -1);
-       vector<int> osds;
-       osdmap.pg_to_osds(pgid, osds); 
-       if (osds[0] == 0) {
-         pending_inc.new_pg_swap_primary[pgid] = osds[1];
-         dout(3) << "Changing primary for PG " << pgid << " from " << osds[0] << " to "
-                 << osds[1] << dendl;
+  if (SWAP_PRIMARIES_AT_START) {
+    // For all PGs that have OSD 0 as the primary,
+    // switch them to use the first replca
+    ps_t numps = osdmap.get_pg_num();
+    int minrep = 1; 
+    int maxrep = MIN(g_conf.num_osd, g_conf.osd_max_rep);
+    for (int pool=0; pool<1; pool++)
+      for (int nrep = minrep; nrep <= maxrep; nrep++) { 
+       for (ps_t ps = 0; ps < numps; ++ps) {
+         pg_t pgid = pg_t(pg_t::TYPE_REP, nrep, ps, pool, -1);
+         vector<int> osds;
+         osdmap.pg_to_osds(pgid, osds); 
+         if (osds[0] == 0) {
+           pending_inc.new_pg_swap_primary[pgid] = osds[1];
+           dout(3) << "Changing primary for PG " << pgid << " from " << osds[0] << " to "
+                   << osds[1] << dendl;
+           do_propose = true;
+         }
        }
       }
-    }
-  propose_pending();
+  }
+  // ---------------
+
+  if (do_propose)
+    propose_pending();
 }
 
 
index 261c363ea0a4dfef6b744f50c7f3b9fed7813a7f..c602ca5915eac6d374c25a8ce1f4fc7e2d83a583 100644 (file)
@@ -135,6 +135,8 @@ private:
 
   void send_latest(entity_inst_t i, epoch_t start=0);
 
+  void blacklist(entity_addr_t a, utime_t until);
+
   void fake_osd_failure(int osd, bool down);
   void fake_osdmap_update();
   void fake_reorg();
index 77904b12dad00813772a29f57e16a4d23248bbdc..4c02acb3ca9a67499cc5e156fcd1dfab6b296953 100644 (file)
@@ -51,6 +51,11 @@ void OSDMap::print(ostream& out)
   }
   out << std::endl;
   
+  for (hash_map<entity_addr_t,utime_t>::iterator p = blacklist.begin();
+       p != blacklist.end();
+       p++)
+    out << "blacklist " << p->first << " expires " << p->second << "\n";
+  
   // ignore pg_swap_primary
   
   out << "max_snap " << get_max_snap() << "\n"
@@ -64,6 +69,8 @@ void OSDMap::print_summary(ostream& out)
       << get_num_osds() << " osds: "
       << get_num_up_osds() << " up, " 
       << get_num_in_osds() << " in";
+  if (blacklist.size())
+    out << ", " << blacklist.size() << " blacklisted";
 }
 
 
index bd3bfadc85f723afa2082f7dabb64d7c44f4e77c..eb579f3f3894052d0b4c8684b42a313bb4d15352 100644 (file)
@@ -160,7 +160,7 @@ public:
     map<pg_t,uint32_t> new_pg_swap_primary;
     list<pg_t> old_pg_swap_primary;
 
-    vector<entity_addr_t> new_blacklist;
+    map<entity_addr_t,utime_t> new_blacklist;
     vector<entity_addr_t> old_blacklist;
 
     snapid_t new_max_snap;
@@ -280,7 +280,7 @@ private:
   snapid_t max_snap;
   interval_set<snapid_t> removed_snaps;
 
-  hash_set<entity_addr_t> blacklist;
+  hash_map<entity_addr_t,utime_t> blacklist;
 
  public:
   CrushWrapper     crush;       // hierarchical map
@@ -576,10 +576,10 @@ private:
     removed_snaps.union_of(inc.removed_snaps);
 
     // blacklist
-    for (vector<entity_addr_t>::iterator p = inc.new_blacklist.begin();
+    for (map<entity_addr_t,utime_t>::iterator p = inc.new_blacklist.begin();
         p != inc.new_blacklist.end();
         p++)
-      blacklist.insert(*p);
+      blacklist[p->first] = p->second;
     for (vector<entity_addr_t>::iterator p = inc.old_blacklist.begin();
         p != inc.old_blacklist.end();
         p++)