From: Sage Weil Date: Thu, 5 May 2011 15:11:41 +0000 (-0700) Subject: osd: handle event notify/info/log from Initial X-Git-Tag: v0.28~74^2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1fbefb32f9f57bb6e99acb3cda07be4f8fc4354f;p=ceph.git osd: handle event notify/info/log from Initial 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 --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 9ed3336961fc..eda7abafb56c 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -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 > query_map; - map info_map; - map > notify_list; - PG::RecoveryCtx rctx(&query_map, &info_map, ¬ify_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); diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 7a231e024817..4037b1db6f51 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -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); } diff --git a/src/osd/PG.h b/src/osd/PG.h index 439d3650bc00..82ef708de562 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -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 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 peer_info_requested; + typedef boost::mpl::list < boost::statechart::transition< GotInfo, GetLog >, boost::statechart::custom_reaction< MNotifyRec >