]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: avoid needless calls to peer(), build_prior()
authorSage Weil <sage@newdream.net>
Tue, 9 Dec 2008 19:00:04 +0000 (11:00 -0800)
committerSage Weil <sage@newdream.net>
Wed, 10 Dec 2008 00:00:51 +0000 (16:00 -0800)
Introduces PEERING pg state.  Also is smarter about when build_prior and
peer are actually called.

src/osd/OSD.cc
src/osd/PG.cc
src/osd/PG.h
src/osd/osd_types.h

index eb11c4a98ba1a97b7b2234fcbec7390453b85a94..1d0821f4096508a4c5b935b0be2be858d8956ee9 100644 (file)
@@ -1991,6 +1991,8 @@ void OSD::advance_map(ObjectStore::Transaction& t, interval_set<snapid_t>& remov
     int oldacker = pg->get_acker();
     vector<int> oldacting = pg->acting;
     
+    pg->clear_prior();
+
     // update PG
     pg->acting.swap(tacting);
     pg->set_role(role);
@@ -2026,6 +2028,7 @@ void OSD::advance_map(ObjectStore::Transaction& t, interval_set<snapid_t>& remov
     // deactivate.
     pg->state_clear(PG_STATE_ACTIVE);
     pg->state_clear(PG_STATE_DOWN);
+    pg->state_clear(PG_STATE_PEERING);  // we'll need to restart peering
 
     if (pg->is_primary() && 
        pg->info.pgid.size() != pg->acting.size())
@@ -2128,10 +2131,11 @@ void OSD::activate_map(ObjectStore::Transaction& t)
       if (!pg->info.dead_snaps.empty())
        pg->queue_snap_trim();
     }
-    else if (pg->is_primary() && !pg->is_active()) {
+    else if (pg->is_primary() &&
+            !pg->is_active()) {
       // i am (inactive) primary
-      pg->build_prior();
-      pg->peer(t, query_map, &info_map);
+      if (!pg->is_peering())
+       pg->peer(t, query_map, &info_map);
     }
     else if (pg->is_stray() &&
             pg->get_primary() >= 0) {
@@ -2682,7 +2686,6 @@ void OSD::handle_pg_notify(MOSDPGNotify *m)
        pg->set_role(role);
        pg->info.history = history;
        pg->clear_primary_state();  // yep, notably, set hml=false
-       pg->build_prior();      
        pg->write_info(t);
        pg->write_log(t);
       }
@@ -2734,7 +2737,6 @@ void OSD::handle_pg_notify(MOSDPGNotify *m)
       if (pg->is_all_uptodate()) 
        pg->finish_recovery();
     } else {
-      pg->build_prior();
       pg->peer(t, query_map, &info_map);
     }
     pg->update_stats();
index 2a13286bf5a7390fef9df1c60c6cc16e109eea3e..cdd8aa7af66fb4c1b1b98f7e6882a543b4448d55 100644 (file)
@@ -734,6 +734,16 @@ bool PG::prior_set_affected(OSDMap *osdmap)
   return false;
 }
 
+void PG::clear_prior()
+{
+  dout(10) << "clear_prior" << dendl;
+  prior_set.clear();
+  prior_set_down.clear();
+  prior_set_up_thru.clear();
+  must_notify_mon = false;
+}
+
+
 void PG::build_prior()
 {
   if (1) {
@@ -786,10 +796,7 @@ void PG::build_prior()
    * intervene in some as-yet-undetermined way.  :)
    */
 
-  // build prior set.
-  prior_set.clear();
-  prior_set_down.clear();
-  prior_set_up_thru.clear();
+  clear_prior();
 
   // current nodes, of course.
   for (unsigned i=1; i<acting.size(); i++)
@@ -801,8 +808,6 @@ void PG::build_prior()
   bool any_up_now = false;
   bool some_down = false;
 
-  must_notify_mon = false;
-
   // generate past intervals, if we don't have them.
   if (info.history.same_since > info.history.last_epoch_started &&
       (past_intervals.empty() ||
@@ -933,9 +938,16 @@ void PG::peer(ObjectStore::Transaction& t,
               map< int, map<pg_t,Query> >& query_map,
              map<int, MOSDPGInfo*> *activator_map)
 {
-  dout(10) << "peer.  acting is " << acting 
-           << ", prior_set is " << prior_set << dendl;
+  dout(10) << "peer acting is " << acting << dendl;
+
+  if (!is_active())
+    state_set(PG_STATE_PEERING);
+  
+  if (prior_set.empty())
+    build_prior();
 
+  dout(10) << "peer prior_set is " << prior_set << dendl;
+  
 
   /** GET ALL PG::Info *********/
 
@@ -1171,6 +1183,7 @@ void PG::activate(ObjectStore::Transaction& t,
   state_set(PG_STATE_ACTIVE);
   state_clear(PG_STATE_STRAY);
   state_clear(PG_STATE_DOWN);
+  state_clear(PG_STATE_PEERING);
   if (is_crashed()) {
     //assert(is_replay());      // HELP.. not on replica?
     state_clear(PG_STATE_CRASHED);
@@ -1181,7 +1194,7 @@ void PG::activate(ObjectStore::Transaction& t,
     state_set(PG_STATE_DEGRADED);
   else
     state_clear(PG_STATE_DEGRADED);
-  
+
   info.history.last_epoch_started = osd->osdmap->get_epoch();
   trim_past_intervals();
   
@@ -1422,6 +1435,12 @@ void PG::purge_strays()
   }
 
   stray_set.clear();
+
+  // clear _requested maps; we may have to peer() again if we discover
+  // (more) stray content
+  peer_info_requested.clear();
+  peer_log_requested.clear();
+  peer_summary_requested.clear();
 }
 
 
index 7022751e1cab842b725fa00abc2a79e2f27c81b4..58f9424f7c8863c5ce00d07b4d99ab9d2790fb66 100644 (file)
@@ -669,6 +669,7 @@ public:
   void generate_past_intervals();
   void trim_past_intervals();
   void build_prior();
+  void clear_prior();
   bool prior_set_affected(OSDMap *map);
 
   bool adjust_peers_complete_thru() {
@@ -786,6 +787,7 @@ public:
 
   int get_state() const { return state; }
   bool       is_active() const { return state_test(PG_STATE_ACTIVE); }
+  bool       is_peering() const { return state_test(PG_STATE_PEERING); }
   bool       is_crashed() const { return state_test(PG_STATE_CRASHED); }
   bool       is_down() const { return state_test(PG_STATE_DOWN); }
   bool       is_replay() const { return state_test(PG_STATE_REPLAY); }
index ae606ee7f133eb66d1d52b2bd89d88fec7a67f01..6addc1129cabb623948ae56d7a95062fd541be70 100644 (file)
@@ -355,6 +355,9 @@ inline ostream& operator<<(ostream& out, const osd_stat_t& s) {
 #define PG_STATE_SCRUBBING 256  // scrubbing
 #define PG_STATE_SCRUBQ    512  // queued for scrub
 #define PG_STATE_DEGRADED      1024  // pg membership not complete
+#define PG_STATE_INCONSISTENT  2048  // pg replicas are inconsistent (but shouldn't be)
+#define PG_STATE_REPAIR  2048   // pg should repair on next scrub
+#define PG_STATE_PEERING 4096
 
 static inline std::string pg_state_string(int state) {
   std::string st;
@@ -369,6 +372,9 @@ static inline std::string pg_state_string(int state) {
   if (state & PG_STATE_DEGRADED) st += "degraded+";
   if (state & PG_STATE_SCRUBBING) st += "scrubbing+";
   if (state & PG_STATE_SCRUBQ) st += "scrubq+";
+  if (state & PG_STATE_INCONSISTENT) st += "inconsistent+";
+  if (state & PG_STATE_REPAIR) st += "repair+";
+  if (state & PG_STATE_PEERING) st += "peering+";
   if (!st.length()) 
     st = "inactive";
   else