]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: add_event() helper to assimilate Log::Entry into Missing
authorSage Weil <sage@newdream.net>
Thu, 31 Jul 2008 19:50:31 +0000 (12:50 -0700)
committerSage Weil <sage@newdream.net>
Thu, 31 Jul 2008 19:50:31 +0000 (12:50 -0700)
src/TODO
src/osd/PG.cc
src/osd/PG.h

index d76db56e3ed38c6c2c8eec07dfe0b05619199c68..19a95b4792eecf59b049fb13b98744270bd1cffe 100644 (file)
--- a/src/TODO
+++ b/src/TODO
@@ -72,6 +72,8 @@ crush
 - "knob" bucket
 
 pgmon
+- include osd vector with pg state
+  - check for orphan pgs
 - monitor pg states, notify on out?
 - watch osd utilization; adjust overload in cluster map
 
index a1f8bb348dff1c43e632922510693297ab50e488..b107177153b26ab0e36ed3164b3c50f57a7173b3 100644 (file)
@@ -203,7 +203,7 @@ void PG::proc_replica_log(Log &olog, Missing& omissing, int from)
                  << ", ignoring" << dendl;
       } else {
         dout(10) << " divergent " << *pp << ", adding to missing" << dendl;
-        peer_missing[from].add(pp->oid, pp->version);
+        peer_missing[from].add_event(*pp);
       }
 
       ++pp;
@@ -265,7 +265,7 @@ void PG::merge_log(Log &olog, Missing &omissing, int fromosd)
                 dout(10) << "merge_log  divergent entry " << oe
                          << " not superceded by " << *log.objects[oe.oid]
                          << ", adding to missing" << dendl;
-                missing.add(oe.oid, oe.version);
+                missing.add_event(oe);
               } else {
                 dout(10) << "merge_log  divergent entry " << oe
                          << " superceded by " << *log.objects[oe.oid] 
@@ -273,7 +273,7 @@ void PG::merge_log(Log &olog, Missing &omissing, int fromosd)
               }
             } else {
               dout(10) << "merge_log  divergent entry " << oe << ", adding to missing" << dendl;
-              missing.add(oe.oid, oe.version);
+              missing.add_event(oe);
             }
             olog.log.pop_back();  // discard divergent entry
           }
@@ -281,13 +281,8 @@ void PG::merge_log(Log &olog, Missing &omissing, int fromosd)
         break;
       }
 
-      if (p->is_delete()) {
-        dout(10) << "merge_log merging " << *p << ", not missing" << dendl;
-        missing.rm(p->oid, p->version);
-      } else {
-        dout(10) << "merge_log merging " << *p << ", now missing" << dendl;
-        missing.add(p->oid, p->version);
-      }
+      dout(10) << "merge_log merging " << *p << ", not missing" << dendl;
+      missing.add_event(*p);
     }
 
     info.last_update = log.top = olog.top;
@@ -319,12 +314,8 @@ void PG::merge_log(Log &olog, Missing &omissing, int fromosd)
         dout(15) << *to << dendl;
         
         // new missing object?
-        if (to->version > info.last_complete) {
-          if (to->is_update()) 
-            missing.add(to->oid, to->version);
-          else 
-          missing.rm(to->oid, to->version);
-        }
+        if (to->version > info.last_complete)
+         missing.add_event(*to);
       }
       assert(to != olog.log.end());
       
@@ -356,10 +347,7 @@ void PG::merge_log(Log &olog, Missing &omissing, int fromosd)
         dout(10) << "merge_log " << *from << dendl;
         
         // add to missing
-        if (from->is_update()) {
-          missing.add(from->oid, from->version);
-        } else
-          missing.rm(from->oid, from->version);
+       missing.add_event(*from);
       }
       
       // remove divergent items
@@ -1010,7 +998,7 @@ void PG::activate(ObjectStore::Transaction& t,
              p != m->log.log.end();
              p++) 
           if (p->version > plu)
-            pm.add(p->oid, p->version);
+            pm.add_event(*p);
       }
       
       if (m) {
@@ -1307,7 +1295,7 @@ void PG::read_log(ObjectStore *store)
     pobject_t poid(info.pgid.pool(), 0, i->oid);
     int r = osd->store->getattr(info.pgid, poid, "version", &v, sizeof(v));
     if (r < 0 || v < i->version) 
-      missing.add(i->oid, i->version);
+      missing.add_event(*i);
   }
 }
 
index a6343d0ebf5b5ddf654c749d38c75a6dbeea6fa7..898c1d489010f3a570dbdedfbb4d4ca316387ccd 100644 (file)
@@ -167,77 +167,6 @@ public:
   WRITE_CLASS_ENCODER(Query)
 
   
-  /*
-   * Missing - summary of missing objects.
-   *  kept in memory, as a supplement to Log.
-   *  also used to pass missing info in messages.
-   */
-  class Missing {
-  public:
-    map<object_t, eversion_t> missing;   // oid -> v
-    map<eversion_t, object_t> rmissing;  // v -> oid
-
-    map<object_t, int>       loc;       // where i think i can get them.
-
-    int num_lost() const { return missing.size() - loc.size(); }
-    int num_missing() const { return missing.size(); }
-
-    bool is_missing(object_t oid) {
-      return missing.count(oid);
-    }
-    bool is_missing(object_t oid, eversion_t v) {
-      return missing.count(oid) && missing[oid] <= v;
-    }
-    void add(object_t oid) {
-      eversion_t z;
-      add(oid,z);
-    }
-    void add(object_t oid, eversion_t v) {
-      if (missing.count(oid)) {
-        if (missing[oid] > v) return;   // already missing newer.
-        rmissing.erase(missing[oid]);
-      }
-      missing[oid] = v;
-      rmissing[v] = oid;
-    }
-    void rm(object_t oid, eversion_t when) {
-      if (missing.count(oid) && missing[oid] < when) {
-        rmissing.erase(missing[oid]);
-        missing.erase(oid);
-        loc.erase(oid);
-      }        
-    }
-    void got(object_t oid, eversion_t v) {
-      assert(missing.count(oid));
-      assert(missing[oid] <= v);
-      loc.erase(oid);
-      rmissing.erase(missing[oid]);
-      missing.erase(oid);
-    }
-    void got(object_t oid) {
-      assert(missing.count(oid));
-      loc.erase(oid);
-      rmissing.erase(missing[oid]);
-      missing.erase(oid);
-    }
-
-    void encode(bufferlist &bl) const {
-      ::encode(missing, bl);
-      ::encode(loc, bl);
-    }
-    void decode(bufferlist::iterator &bl) {
-      ::decode(missing, bl);
-      ::decode(loc, bl);
-
-      for (map<object_t,eversion_t>::iterator it = missing.begin();
-           it != missing.end();
-           it++) 
-        rmissing[it->second] = it->first;
-    }
-  };
-  WRITE_CLASS_ENCODER(Missing)
-
-
   /*
    * Log - incremental log of recent pg changes.
    *  also, serves as a recovery queue.
@@ -444,6 +373,85 @@ public:
   };
 
 
+  /*
+   * Missing - summary of missing objects.
+   *  kept in memory, as a supplement to Log.
+   *  also used to pass missing info in messages.
+   */
+  class Missing {
+  public:
+    map<object_t, eversion_t> missing;   // oid -> v
+    map<eversion_t, object_t> rmissing;  // v -> oid
+
+    map<object_t, int>       loc;       // where i think i can get them.
+
+    int num_lost() const { return missing.size() - loc.size(); }
+    int num_missing() const { return missing.size(); }
+
+    bool is_missing(object_t oid) {
+      return missing.count(oid);
+    }
+    bool is_missing(object_t oid, eversion_t v) {
+      return missing.count(oid) && missing[oid] <= v;
+    }
+    void add(object_t oid) {
+      eversion_t z;
+      add(oid,z);
+    }
+    
+    void add_event(Log::Entry& e) {
+      if (e.is_update())
+       add(e.oid, e.version);
+      else
+       rm(e.oid, e.version);
+    }
+
+    void add(object_t oid, eversion_t v) {
+      if (missing.count(oid)) {
+        if (missing[oid] > v) return;   // already missing newer.
+        rmissing.erase(missing[oid]);
+      }
+      missing[oid] = v;
+      rmissing[v] = oid;
+    }
+    void rm(object_t oid, eversion_t when) {
+      if (missing.count(oid) && missing[oid] < when) {
+        rmissing.erase(missing[oid]);
+        missing.erase(oid);
+        loc.erase(oid);
+      }        
+    }
+    void got(object_t oid, eversion_t v) {
+      assert(missing.count(oid));
+      assert(missing[oid] <= v);
+      loc.erase(oid);
+      rmissing.erase(missing[oid]);
+      missing.erase(oid);
+    }
+    void got(object_t oid) {
+      assert(missing.count(oid));
+      loc.erase(oid);
+      rmissing.erase(missing[oid]);
+      missing.erase(oid);
+    }
+
+    void encode(bufferlist &bl) const {
+      ::encode(missing, bl);
+      ::encode(loc, bl);
+    }
+    void decode(bufferlist::iterator &bl) {
+      ::decode(missing, bl);
+      ::decode(loc, bl);
+
+      for (map<object_t,eversion_t>::iterator it = missing.begin();
+           it != missing.end();
+           it++) 
+        rmissing[it->second] = it->first;
+    }
+  };
+  WRITE_CLASS_ENCODER(Missing)
+
+
   /*** PG ****/
 protected:
   OSD *osd;