From 65abfc07df0031b3a7b317c24c848661e352037e Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Wed, 30 May 2012 21:19:58 -0800 Subject: [PATCH] OSD: initialize pgs in get_or_create_pg via handle_create Previously, pgs were initialized via Info/Log/etc. Since the event which triggered the pg creation may now be queued, map update events may occur before the event is processed. Thus, get_or_create_pg now handles the initialization prior to queuing the event. Signed-off-by: Samuel Just --- src/osd/OSD.cc | 29 +++++++++++++---------------- src/osd/OSD.h | 4 +--- src/osd/PG.cc | 2 ++ src/osd/PG.h | 2 +- 4 files changed, 17 insertions(+), 20 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index d00d2a7305291..2c5d337f4eb62 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -1343,9 +1343,7 @@ void OSD::load_pgs() * hasn't changed since the given epoch and we are the primary. */ PG *OSD::get_or_create_pg(const pg_info_t& info, pg_interval_map_t& pi, - epoch_t epoch, int from, int& created, bool primary, - ObjectStore::Transaction **pt, - C_Contexts **pfin) + epoch_t epoch, int from, int& created, bool primary) { PG *pg; ObjectStore::Transaction *t = 0; @@ -1394,7 +1392,15 @@ PG *OSD::get_or_create_pg(const pg_info_t& info, pg_interval_map_t& pi, // ok, create PG locally using provided Info and History t = new ObjectStore::Transaction; fin = new C_Contexts(g_ceph_context); - pg = _create_lock_pg(info.pgid, create, false, role, up, acting, history, pi, **pt); + map< int, vector > > notify_list; // primary -> list + map< int, map > query_map; // peer -> PG -> get_summary_since + map info_map; // peer -> message + PG::RecoveryCtx rctx(&query_map, &info_map, ¬ify_list, &fin->contexts, t); + pg = _create_lock_pg(info.pgid, create, false, role, up, acting, history, pi, *t); + pg->handle_create(&rctx); + do_notifies(notify_list, osdmap->get_epoch()); + do_queries(query_map); + do_infos(info_map); created++; dout(10) << *pg << " is new" << dendl; @@ -1415,14 +1421,10 @@ PG *OSD::get_or_create_pg(const pg_info_t& info, pg_interval_map_t& pi, t = new ObjectStore::Transaction; fin = new C_Contexts(g_ceph_context); } - if (pt) { - assert(pfin); - *pt = t; - *pfin = fin; - } else if (t && t->empty()) { + if (t && t->empty()) { delete t; delete fin; - } else { + } else if (t) { int tr = store->queue_transaction( &pg->osr, t, new ObjectStore::C_DeleteTransaction(t), fin); @@ -4333,12 +4335,7 @@ void OSD::handle_pg_notify(OpRequestRef op) op->mark_started(); - // look for unknown PGs i'm primary for - map< int, map > query_map; - map info_map; - int created = 0; - - for (vector >::iterator it = m->get_pg_list().begin(); + for (vector >::iterator it = m->get_pg_list().begin(); it != m->get_pg_list().end(); it++) { PG *pg = 0; diff --git a/src/osd/OSD.h b/src/osd/OSD.h index 65aa71231c82a..25802f5bf59a8 100644 --- a/src/osd/OSD.h +++ b/src/osd/OSD.h @@ -518,9 +518,7 @@ protected: PG *get_or_create_pg(const pg_info_t& info, pg_interval_map_t& pi, epoch_t epoch, int from, int& pcreated, - bool primary, - ObjectStore::Transaction **pt = 0, - C_Contexts **pfin = 0); + bool primary); void load_pgs(); void calc_priors_during(pg_t pgid, epoch_t start, epoch_t end, set& pset); diff --git a/src/osd/PG.cc b/src/osd/PG.cc index 427a29846667d..2c6e009b951e4 100644 --- a/src/osd/PG.cc +++ b/src/osd/PG.cc @@ -4105,6 +4105,8 @@ void PG::handle_create(RecoveryCtx *rctx) dout(10) << "handle_create" << dendl; Initialize evt; recovery_state.handle_event(evt, rctx); + ActMap evt2; + recovery_state.handle_event(evt2, rctx); } void PG::handle_query_state(Formatter *f) diff --git a/src/osd/PG.h b/src/osd/PG.h index ad4e2efaf486c..107d219a2016e 100644 --- a/src/osd/PG.h +++ b/src/osd/PG.h @@ -964,7 +964,7 @@ public: void exit(); typedef boost::mpl::list < - boost::statechart::transition< Initialize, Started >, + boost::statechart::transition< Initialize, Reset >, boost::statechart::transition< Load, Reset >, boost::statechart::custom_reaction< MNotifyRec >, boost::statechart::custom_reaction< MInfoRec >, -- 2.39.5