]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: move directly to Reset state on pg load
authorSage Weil <sage.weil@dreamhost.com>
Wed, 4 May 2011 20:05:09 +0000 (13:05 -0700)
committerSage Weil <sage.weil@dreamhost.com>
Wed, 4 May 2011 20:05:09 +0000 (13:05 -0700)
Add Initial -> Reset transition on pg load.  This avoids doing any
activation-type stuff (like sending messages) before we are ready.  In
particularly, we want to advance through any new OSDMaps and only
send out queries/notifies/whatever when we get to the activate_map
stage.

Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/osd/OSD.cc
src/osd/OSD.h
src/osd/PG.cc
src/osd/PG.h

index 23feecfff8f96506dc20c7a0ef17e191943ee6b8..6ca4e72f90f6fe3d4dbaaa586d89820f39d99563 100644 (file)
@@ -568,9 +568,7 @@ int OSD::init()
   }
 
   // load up pgs (as they previously existed)
-  // defer querying until after the messenger is initialized
-  map<int, map<pg_t, PG::Query> > query_map;
-  load_pgs(query_map);
+  load_pgs();
 
   dout(2) << "superblock: i am osd" << superblock.whoami << dendl;
   assert_warn(whoami == superblock.whoami);
@@ -622,8 +620,6 @@ int OSD::init()
   dout(0) << "started rotating keys" << dendl;
 #endif
 
-  do_queries(query_map);
-
   return 0;
 }
 
@@ -1053,7 +1049,7 @@ PG *OSD::lookup_lock_raw_pg(pg_t pgid)
 }
 
 
-void OSD::load_pgs(map<int, map<pg_t, PG::Query> > &query_map)
+void OSD::load_pgs()
 {
   assert(osd_lock.is_locked());
   dout(10) << "load_pgs" << dendl;
@@ -1093,8 +1089,8 @@ void OSD::load_pgs(map<int, map<pg_t, PG::Query> > &query_map)
     int role = osdmap->calc_pg_role(whoami, pg->acting, nrep);
     pg->set_role(role);
 
-    PG::RecoveryCtx rctx(&query_map, 0, 0, 0, 0);
-    pg->handle_create(&rctx);
+    PG::RecoveryCtx rctx(0, 0, 0, 0, 0);
+    pg->handle_loaded(&rctx);
 
     dout(10) << "load_pgs loaded " << *pg << " " << pg->log << dendl;
     pg->unlock();
index b1b1ae8f4a939e25550ebff636c1d336badb4c67..40ff50644ba19f355e0be013e886d63854f430c6 100644 (file)
@@ -514,7 +514,7 @@ protected:
                       ObjectStore::Transaction **pt,
                       C_Contexts **pfin);
   
-  void load_pgs(map<int, map<pg_t, PG::Query> > &query_map);
+  void load_pgs();
   void calc_priors_during(pg_t pgid, epoch_t start, epoch_t end, set<int>& pset);
   void project_pg_history(pg_t pgid, PG::Info::History& h, epoch_t from,
                          vector<int>& lastup, vector<int>& lastacting);
index b364b41c72340ff75e767c9567c82ab97b80a445..7ee0a103f615bf45ee5bb885701c05098cdd8cd3 100644 (file)
@@ -4343,12 +4343,20 @@ void PG::RecoveryState::handle_backlog_generated(RecoveryCtx *rctx)
   end_handle();
 }
 
+void PG::RecoveryState::handle_loaded(RecoveryCtx *rctx)
+{
+  start_handle(rctx);
+  machine.process_event(Load());
+  end_handle();
+}
+
 void PG::RecoveryState::handle_create(RecoveryCtx *rctx)
 {
   start_handle(rctx);
   machine.process_event(Initialize());
   end_handle();
 }
+
 /*---------------------------------------------------*/
 #undef dout_prefix
 #define dout_prefix (*_dout << pg->gen_prefix() << "PgPriorSet: ")
index d578bef9ea68d0515cb31d75e16552f574f169d0..d794e75c7f7169f45049c8b8b2c00364e6349882 100644 (file)
@@ -848,6 +848,7 @@ public:
     struct ActMap : boost::statechart::event< ActMap > {};
     struct Activate : boost::statechart::event< Activate > {};
     struct Initialize : boost::statechart::event< Initialize > {};
+    struct Load : boost::statechart::event< Load > {};
 
 
     /* States */
@@ -905,10 +906,12 @@ public:
     };
 
     struct Started;
+    struct Reset;
     struct Initial :
       boost::statechart::state< Initial, RecoveryMachine >, NamedState {
       typedef boost::mpl::list <
        boost::statechart::transition< Initialize, Started >,
+       boost::statechart::transition< Load, Reset >,
        boost::statechart::transition< boost::statechart::event_base, Crashed >
        > reactions;
       Initial(my_context ctx);
@@ -1103,6 +1106,7 @@ public:
     void handle_activate_map(RecoveryCtx *ctx);
     void handle_backlog_generated(RecoveryCtx *ctx);
     void handle_create(RecoveryCtx *ctx);
+    void handle_loaded(RecoveryCtx *ctx);
   } recovery_state;
 
 protected:
@@ -1434,6 +1438,10 @@ public:
   void handle_create(RecoveryCtx *rctx) {
     recovery_state.handle_create(rctx);
   }
+  void handle_loaded(RecoveryCtx *rctx) {
+    recovery_state.handle_loaded(rctx);
+  }
+
 
   // abstract bits
   virtual void do_op(MOSDOp *op) = 0;