]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
OSD,PG: clean up _get_or_create_pg and set interval based on msg
authorSamuel Just <sam.just@inktank.com>
Sun, 17 Jun 2012 23:16:42 +0000 (16:16 -0700)
committerSamuel Just <sam.just@inktank.com>
Thu, 5 Jul 2012 17:15:00 +0000 (10:15 -0700)
Previously, we set last_peering_reset based on the epoch in which the pg
is created.  We now pass the map from the query_epoch to the creation
methods to set based on that.

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
src/osd/osd_types.cc

index 9d3077f3a38e6ffb06f6272c0c98b3621ae26c65..5bfdf7d002860990eb1a7d9044bc189e37b114fc 100644 (file)
@@ -1213,7 +1213,9 @@ void OSD::_put_pool(PGPool *p)
   }
 }
 
-PG *OSD::_open_lock_pg(pg_t pgid, bool no_lockdep_check, bool hold_map_lock)
+PG *OSD::_open_lock_pg(
+  OSDMapRef createmap,
+  pg_t pgid, bool no_lockdep_check, bool hold_map_lock)
 {
   assert(osd_lock.is_locked());
 
@@ -1226,7 +1228,7 @@ PG *OSD::_open_lock_pg(pg_t pgid, bool no_lockdep_check, bool hold_map_lock)
   hobject_t logoid = make_pg_log_oid(pgid);
   hobject_t infooid = make_pg_biginfo_oid(pgid);
   if (osdmap->get_pg_type(pgid) == pg_pool_t::TYPE_REP)
-    pg = new ReplicatedPG(&service, osdmap, pool, pgid, logoid, infooid);
+    pg = new ReplicatedPG(&service, createmap, pool, pgid, logoid, infooid);
   else 
     assert(0);
 
@@ -1241,15 +1243,17 @@ PG *OSD::_open_lock_pg(pg_t pgid, bool no_lockdep_check, bool hold_map_lock)
   return pg;
 }
 
-PG *OSD::_create_lock_pg(pg_t pgid, bool newly_created, bool hold_map_lock,
-                        int role, vector<int>& up, vector<int>& acting, pg_history_t history,
-                        pg_interval_map_t& pi,
-                        ObjectStore::Transaction& t)
+PG *OSD::_create_lock_pg(
+  OSDMapRef createmap,
+  pg_t pgid, bool newly_created, bool hold_map_lock,
+  int role, vector<int>& up, vector<int>& acting, pg_history_t history,
+  pg_interval_map_t& pi,
+  ObjectStore::Transaction& t)
 {
   assert(osd_lock.is_locked());
   dout(20) << "_create_lock_pg pgid " << pgid << dendl;
 
-  PG *pg = _open_lock_pg(pgid, true, hold_map_lock);
+  PG *pg = _open_lock_pg(createmap, pgid, true, hold_map_lock);
 
   t.create_collection(coll_t(pgid));
 
@@ -1337,6 +1341,8 @@ void OSD::load_pgs()
       if (it->is_removal(&seq, &pgid)) {
        if (seq >= next_removal_seq)
          next_removal_seq = seq + 1;
+       dout(10) << "queueing coll " << *it << " for removal, seq is "
+                << seq << "pgid is " << pgid << dendl;
        boost::tuple<coll_t, SequencerRef, DeletingStateRef> *to_queue =
          new boost::tuple<coll_t, SequencerRef, DeletingStateRef>;
        to_queue->get<0>() = *it;
@@ -1366,7 +1372,7 @@ void OSD::load_pgs()
       continue;
     }
 
-    PG *pg = _open_lock_pg(pgid);
+    PG *pg = _open_lock_pg(osdmap, pgid);
 
     // read pg state, log
     pg->read_state(store);
@@ -1439,8 +1445,10 @@ 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
     PG::RecoveryCtx rctx = create_context();
-    pg = _create_lock_pg(info.pgid, create, false, role, up, acting, history, pi,
-                        *rctx.transaction);
+    pg = _create_lock_pg(
+      get_map(epoch),
+      info.pgid, create, false, role, up, acting, history, pi,
+      *rctx.transaction);
     pg->handle_create(&rctx);
     dispatch_context(rctx, pg);
       
@@ -3965,7 +3973,7 @@ void OSD::do_split(PG *parent, set<pg_t>& childpgids, ObjectStore::Transaction&
       history.same_interval_since = history.same_primary_since =
       osdmap->get_epoch();
     pg_interval_map_t pi;
-    PG *pg = _create_lock_pg(*q, true, true,
+    PG *pg = _create_lock_pg(service.get_osdmap(), *q, true, true,
                             parent->get_role(), parent->up, parent->acting, history, pi, t);
     children[*q] = pg;
     dout(10) << "  child " << *pg << dendl;
@@ -4207,10 +4215,11 @@ void OSD::handle_pg_create(OpRequestRef op)
     if (can_create_pg(pgid)) {
       pg_interval_map_t pi;
       PG::RecoveryCtx rctx = create_context();
-      PG *pg = _create_lock_pg(pgid, true, false,
-                              0, creating_pgs[pgid].acting, creating_pgs[pgid].acting,
-                              history, pi,
-                              *rctx.transaction);
+      PG *pg = _create_lock_pg(
+       osdmap, pgid, true, false,
+       0, creating_pgs[pgid].acting, creating_pgs[pgid].acting,
+       history, pi,
+       *rctx.transaction);
       creating_pgs.erase(pgid);
       wake_pg_waiters(pg->info.pgid);
       pg->handle_create(&rctx);
index ff45cdd69fe3ccb0b34952303edcafcd45f24d00..f332f4ed944b673c2cefa20d990ca885d6abc078 100644 (file)
@@ -259,6 +259,10 @@ public:
   Mutex pg_temp_lock;
   map<pg_t, vector<int> > pg_temp_wanted;
   void queue_want_pg_temp(pg_t pgid, vector<int>& want);
+  void remove_want_pg_temp(pg_t pgid) {
+    Mutex::Locker l(pg_temp_lock);
+    pg_temp_wanted.erase(pgid);
+  }
   void send_pg_temp();
 
   void queue_for_peering(PG *pg);
@@ -693,11 +697,16 @@ protected:
   bool  _have_pg(pg_t pgid);
   PG   *_lookup_lock_pg(pg_t pgid);
   PG   *_lookup_lock_pg_with_map_lock_held(pg_t pgid);
-  PG   *_open_lock_pg(pg_t pg, bool no_lockdep_check=false, bool hold_map_lock=false);
-  PG   *_create_lock_pg(pg_t pgid, bool newly_created, bool hold_map_lock,
-                       int role, vector<int>& up, vector<int>& acting,
+  PG   *_open_lock_pg(OSDMapRef createmap,
+                     pg_t pg, bool no_lockdep_check=false,
+                     bool hold_map_lock=false);
+  PG   *_create_lock_pg(OSDMapRef createmap,
+                       pg_t pgid, bool newly_created,
+                       bool hold_map_lock, int role,
+                       vector<int>& up, vector<int>& acting,
                        pg_history_t history,
-                       pg_interval_map_t& pi, ObjectStore::Transaction& t);
+                       pg_interval_map_t& pi,
+                       ObjectStore::Transaction& t);
 
   PG *lookup_lock_raw_pg(pg_t pgid);
 
index cccebf6a960fee7e89424e8e1b384d1064cdfac9..12008f49af953461566f0db57e6d1ddcf63710fa 100644 (file)
@@ -1243,7 +1243,8 @@ void PG::activate(ObjectStore::Transaction& t, list<Context*>& tfin,
   assert(!is_active());
 
   // -- crash recovery?
-  if (pool->info.crash_replay_interval > 0 &&
+  if (is_primary() &&
+      pool->info.crash_replay_interval > 0 &&
       may_need_replay(get_osdmap())) {
     replay_until = ceph_clock_now(g_ceph_context);
     replay_until += pool->info.crash_replay_interval;
@@ -3852,7 +3853,7 @@ void PG::start_peering_interval(const OSDMapRef lastmap,
     }
   }
   // make sure we clear out any pg_temp change requests
-  osd->pg_temp_wanted.erase(info.pgid);
+  osd->remove_want_pg_temp(info.pgid);
   cancel_recovery();
 
   if (acting.empty() && up.size() && up[0] == osd->whoami) {
@@ -4267,6 +4268,7 @@ boost::statechart::result PG::RecoveryState::Initial::react(const MNotifyRec& no
   PG *pg = context< RecoveryMachine >().pg;
   pg->proc_replica_info(notify.from, notify.notify.info);
   pg->update_heartbeat_peers();
+  pg->set_last_peering_reset();
   return transit< Primary >();
 }
 
@@ -4288,8 +4290,6 @@ boost::statechart::result PG::RecoveryState::Initial::react(const MLogRec& i)
 
 void PG::RecoveryState::Initial::exit()
 {
-  PG *pg = context< RecoveryMachine >().pg;
-  pg->set_last_peering_reset();
   context< RecoveryMachine >().log_exit(state_name, enter_time);
 }
 
index be1d58d2ab365f2d514e7a6b0273c0c20bfcf377..a004b35b08a5a0853811a6378b030fc27b19a60f 100644 (file)
@@ -1048,9 +1048,6 @@ public:
       typedef boost::mpl::list <
        boost::statechart::transition< Initialize, Reset >,
        boost::statechart::transition< Load, Reset >,
-       boost::statechart::custom_reaction< MNotifyRec >,
-       boost::statechart::custom_reaction< MInfoRec >,
-       boost::statechart::custom_reaction< MLogRec >,
        boost::statechart::custom_reaction< NullEvt >,
        boost::statechart::transition< boost::statechart::event_base, Crashed >
        > reactions;
index 846e40fa92ee5c731b8254340f7b62b2f4ddb723..6bc433662361bb30552b30371cb58da4fd6c380d 100644 (file)
@@ -282,10 +282,10 @@ bool coll_t::is_pg(pg_t& pgid, snapid_t& snap) const
 
 bool coll_t::is_removal(uint64_t *seq, pg_t *pgid) const
 {
-  if (str.substr(0, 12) != string("FORREMOVAL_"))
+  if (str.substr(0, 11) != string("FORREMOVAL_"))
     return false;
 
-  stringstream ss(str.substr(12));
+  stringstream ss(str.substr(11));
   ss >> *seq;
   char sep;
   ss >> sep;