]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: fix up PG::Missing methods a bit
authorSage Weil <sage@newdream.net>
Thu, 13 Oct 2011 19:56:28 +0000 (12:56 -0700)
committerSage Weil <sage@newdream.net>
Sat, 15 Oct 2011 04:02:32 +0000 (21:02 -0700)
Pass in iterators when possible.  Stack methods instead of duplicating
functionality.

Signed-off-by: Sage Weil <sage@newdream.net>
src/osd/PG.cc
src/osd/PG.h

index fc20e21e45c75d8f492be794da5ddde2029e3979..1908c4adb924ac7fbd588adcfd8fedbcee3c8875 100644 (file)
@@ -3705,7 +3705,7 @@ eversion_t PG::Missing::have_old(const hobject_t& oid) const
  * this needs to be called in log order as we extend the log.  it
  * assumes missing is accurate up through the previous log entry.
  */
-void PG::Missing::add_next_event(Log::Entry& e, const Info &info)
+void PG::Missing::add_next_event(const Log::Entry& e, const Info &info)
 {
   if (e.is_update()) {
     if (e.prior_version == eversion_t()) {
@@ -3752,18 +3752,23 @@ void PG::Missing::add(const hobject_t& oid, eversion_t need, eversion_t have)
 
 void PG::Missing::rm(const hobject_t& oid, eversion_t v)
 {
-  if (missing.count(oid) && missing[oid].need <= v) {
-    rmissing.erase(missing[oid].need.version);
-    missing.erase(oid);
-  }
+  std::map<hobject_t, Missing::item>::iterator p = missing.find(oid);
+  if (p != missing.end() && p->second.need <= v)
+    rm(p);
+}
+
+void PG::Missing::rm(const std::map<hobject_t, Missing::item>::iterator &m)
+{
+  rmissing.erase(m->second.need.version);
+  missing.erase(m);
 }
 
 void PG::Missing::got(const hobject_t& oid, eversion_t v)
 {
-  assert(missing.count(oid));
-  assert(missing[oid].need <= v);
-  rmissing.erase(missing[oid].need.version);
-  missing.erase(oid);
+  std::map<hobject_t, Missing::item>::iterator p = missing.find(oid);
+  assert(p != missing.end());
+  assert(p->second.need <= v);
+  got(p);
 }
 
 void PG::Missing::got(const std::map<hobject_t, Missing::item>::iterator &m)
index 709d94063376c20d6310250efb0936ca7de50fbf..59792eb0756acafaa78ea8fc50ceb14c4e271b3c 100644 (file)
@@ -713,10 +713,11 @@ public:
     bool is_missing(const hobject_t& oid) const;
     bool is_missing(const hobject_t& oid, eversion_t v) const;
     eversion_t have_old(const hobject_t& oid) const;
-    void add_next_event(Log::Entry& e, const Info &info);
+    void add_next_event(const Log::Entry& e, const Info &info);
     void revise_need(hobject_t oid, eversion_t need);
     void add(const hobject_t& oid, eversion_t need, eversion_t have);
     void rm(const hobject_t& oid, eversion_t v);
+    void rm(const std::map<hobject_t, Missing::item>::iterator &m);
     void got(const hobject_t& oid, eversion_t v);
     void got(const std::map<hobject_t, Missing::item>::iterator &m);