]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: handle event notify/info/log from Initial
authorSage Weil <sage.weil@dreamhost.com>
Thu, 5 May 2011 15:11:41 +0000 (08:11 -0700)
committerSage Weil <sage.weil@dreamhost.com>
Thu, 5 May 2011 15:11:41 +0000 (08:11 -0700)
We shouldn't post a creation event and jump into peering/stray based on
pg creation when we are about to process more information or else we will
send out unnecessary queries.  Instead, handle those from Initial and jump
to the appropriate state.

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

index 9ed3336961fcea54452888859792f2123488b622..eda7abafb56c0f0f0f96b9442cd55b51c2ad2d46 100644 (file)
@@ -1174,15 +1174,6 @@ PG *OSD::get_or_create_pg(const PG::Info& info, epoch_t epoch, int from, int& cr
     // kick any waiters
     wake_pg_waiters(pg->info.pgid);
 
-    map<int, map<pg_t, PG::Query> > query_map;
-    map<int, MOSDPGInfo*> info_map;
-    map<int, vector<PG::Info> > notify_list;
-    PG::RecoveryCtx rctx(&query_map, &info_map, &notify_list,
-                         &((*pfin)->contexts), *pt);
-    pg->handle_create(&rctx);
-    do_queries(query_map);
-    do_infos(info_map);
-    do_notifies(notify_list);
   } else {
     // already had it.  did the mapping change?
     pg = _lookup_lock_pg(info.pgid);
index 7a231e02481719ff3d26eafa105ee22209fb2647..4037b1db6f51e2589547de3fecab45c2ef71d0a9 100644 (file)
@@ -293,6 +293,7 @@ void PG::proc_replica_log(ObjectStore::Transaction& t, Info &oinfo, Log &olog, M
 
 void PG::proc_replica_info(int from, Info &oinfo)
 {
+  dout(10) << "proc_replica_info osd" << from << " " << oinfo << dendl;
   assert(is_primary());
   peer_info[from] = oinfo;
   might_have_unfound.insert(from);
@@ -3725,6 +3726,29 @@ PG::RecoveryState::Initial::Initial(my_context ctx) : my_base(ctx) {
   context< RecoveryMachine >().log_enter(state_name);
 }
 
+boost::statechart::result 
+PG::RecoveryState::Initial::react(const MNotifyRec& notify) {
+  PG *pg = context< RecoveryMachine >().pg;
+  pg->proc_replica_info(notify.from, notify.info);
+  return transit< Primary >();
+}
+
+boost::statechart::result 
+PG::RecoveryState::Initial::react(const MInfoRec& i) {
+  PG *pg = context< RecoveryMachine >().pg;
+  assert(!pg->is_primary());
+  post_event(i);
+  return transit< Stray >();
+}
+
+boost::statechart::result 
+PG::RecoveryState::Initial::react(const MLogRec& i) {
+  PG *pg = context< RecoveryMachine >().pg;
+  assert(!pg->is_primary());
+  post_event(i);
+  return transit< Stray >();
+}
+
 void PG::RecoveryState::Initial::exit() {
   context< RecoveryMachine >().log_exit(state_name, enter_time);
 }
index 439d3650bc006989f9998b51dae0d7d0b949af96..82ef708de56290104b76bfbe36dcd0d12c35a114 100644 (file)
@@ -991,11 +991,18 @@ public:
       typedef boost::mpl::list <
        boost::statechart::transition< Initialize, Started >,
        boost::statechart::transition< Load, Reset >,
+       boost::statechart::custom_reaction< MNotifyRec >,
+       boost::statechart::custom_reaction< MInfoRec >,
+       boost::statechart::custom_reaction< MLogRec >,
        boost::statechart::transition< boost::statechart::event_base, Crashed >
        > reactions;
 
       Initial(my_context ctx);
       void exit();
+
+      boost::statechart::result react(const MNotifyRec&);
+      boost::statechart::result react(const MInfoRec&);
+      boost::statechart::result react(const MLogRec&);
     };
 
     struct Reset :
@@ -1117,6 +1124,7 @@ public:
     struct Stray : boost::statechart::state< Stray, Started >, NamedState {
       bool backlog_requested;
       map<int, Query> pending_queries;
+
       typedef boost::mpl::list <
        boost::statechart::custom_reaction< MQuery >,
        boost::statechart::custom_reaction< MLogRec >,
@@ -1141,6 +1149,7 @@ public:
     struct GetInfo :
       boost::statechart::state< GetInfo, Peering >, NamedState {
       set<int> peer_info_requested;
+
       typedef boost::mpl::list <
        boost::statechart::transition< GotInfo, GetLog >,
        boost::statechart::custom_reaction< MNotifyRec >