]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
OSD: initialize pgs in get_or_create_pg via handle_create
authorSamuel Just <sam.just@inktank.com>
Thu, 31 May 2012 05:19:58 +0000 (21:19 -0800)
committerSamuel Just <sam.just@inktank.com>
Thu, 5 Jul 2012 17:14:58 +0000 (10:14 -0700)
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 <sam.just@inktank.com>
src/osd/OSD.cc
src/osd/OSD.h
src/osd/PG.cc
src/osd/PG.h

index d00d2a7305291d9d0aa26ec1d408f3258cffe666..2c5d337f4eb6266b4ddb181e6cf3ebbc26be102d 100644 (file)
@@ -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<pair<pg_info_t, pg_interval_map_t> > >  notify_list;  // primary -> list
+    map< int, map<pg_t,pg_query_t> > query_map;    // peer -> PG -> get_summary_since
+    map<int,MOSDPGInfo*> info_map;  // peer -> message
+    PG::RecoveryCtx rctx(&query_map, &info_map, &notify_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<pg_t,pg_query_t> > query_map;
-  map<int, MOSDPGInfo*> info_map;
-  int created = 0;
-
-  for (vector<pair<pg_info_t,pg_interval_map_t> >::iterator it = m->get_pg_list().begin();
+  for (vector<pair<pg_notify_t, pg_interval_map_t> >::iterator it = m->get_pg_list().begin();
        it != m->get_pg_list().end();
        it++) {
     PG *pg = 0;
index 65aa71231c82a01628dfa3f913cd2065c08523b6..25802f5bf59a89c26d85eea45bc65ef394037f8e 100644 (file)
@@ -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<int>& pset);
index 427a29846667dd81650a974a26fc63c0567afbbc..2c6e009b951e445da2d797004fbe1767a6174f8e 100644 (file)
@@ -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)
index ad4e2efaf486cd736009044aa03287e912e4df73..107d219a2016e4521fffb2cda94e73d8aa6d2236 100644 (file)
@@ -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 >,