]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
PG: handle MOSDPGLog messages in Active state.
authorGreg Farnum <gregory.farnum@dreamhost.com>
Thu, 5 May 2011 21:36:26 +0000 (14:36 -0700)
committerGreg Farnum <gregory.farnum@dreamhost.com>
Thu, 5 May 2011 21:36:26 +0000 (14:36 -0700)
We previously didn't, but we definitely need to as we can go
active while waiting on strays to send in logs to recover missing
objects.

Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
src/osd/PG.cc
src/osd/PG.h

index 37f330f62d1471802f253d20f3170f92c0d3b3be..60bb1b89d3f731185a9de0a0bd0b879cdce5322e 100644 (file)
@@ -569,10 +569,11 @@ void PG::merge_log(ObjectStore::Transaction& t,
  * TODO: if the missing set becomes very large, this could get expensive.
  * Instead, we probably want to just iterate over our unfound set.
  */
-void PG::search_for_missing(const Info &oinfo, const Missing *omissing,
+bool PG::search_for_missing(const Info &oinfo, const Missing *omissing,
                            int fromosd)
 {
   bool stats_updated = false;
+  bool found_missing = false;
 
   // found items?
   for (map<sobject_t,Missing::item>::iterator p = missing.missing.begin();
@@ -620,12 +621,14 @@ void PG::search_for_missing(const Info &oinfo, const Missing *omissing,
     else {
       ml->second.insert(fromosd);
     }
+    found_missing = true;
   }
   if (stats_updated) {
     update_stats();
   }
 
   dout(20) << "search_for_missing missing " << missing.missing << dendl;
+  return found_missing;
 }
 
 void PG::discover_all_missing(map< int, map<pg_t,PG::Query> > &query_map)
@@ -4025,6 +4028,18 @@ PG::RecoveryState::Active::react(const MInfoRec& infoevt) {
   return discard_event();
 }
 
+boost::statechart::result
+PG::RecoveryState::Active::react(const MLogRec& logevt) {
+  dout(10) << "searching osd" << logevt.from
+           << " log for unfound items" << dendl;
+  PG *pg = context< RecoveryMachine >().pg;
+  bool got_missing = pg->search_for_missing(logevt.msg->info,
+                                            &pg->missing, logevt.from);
+  if (got_missing)
+    pg->osd->queue_for_recovery(pg);
+  return discard_event();
+}
+
 void PG::RecoveryState::Active::exit() {
   context< RecoveryMachine >().log_exit(state_name, enter_time);
 }
index d1b1637390514e309f4ff162f0cb613ea744f835..9f9ac9f363e0ff2c64bb7b5a703be09e5934a149 100644 (file)
@@ -1088,12 +1088,14 @@ public:
        boost::statechart::custom_reaction< ActMap >,
        boost::statechart::custom_reaction< AdvMap >,
        boost::statechart::custom_reaction< MInfoRec >,
-       boost::statechart::custom_reaction< MNotifyRec >
+       boost::statechart::custom_reaction< MNotifyRec >,
+       boost::statechart::custom_reaction< MLogRec >
        > reactions;
       boost::statechart::result react(const ActMap&);
       boost::statechart::result react(const AdvMap&);
       boost::statechart::result react(const MInfoRec& infoevt);
       boost::statechart::result react(const MNotifyRec& notevt);
+      boost::statechart::result react(const MLogRec& logevt);
     };
 
     struct ReplicaActive : boost::statechart::state< ReplicaActive, Started >, NamedState {
@@ -1303,7 +1305,7 @@ public:
   bool proc_replica_info(int from, Info &info);
   bool merge_old_entry(ObjectStore::Transaction& t, Log::Entry& oe);
   void merge_log(ObjectStore::Transaction& t, Info &oinfo, Log &olog, int from);
-  void search_for_missing(const Info &oinfo, const Missing *omissing,
+  bool search_for_missing(const Info &oinfo, const Missing *omissing,
                          int fromosd);
 
   void check_for_lost_objects();