]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: implement ReplicatedPG::scan_range
authorSage Weil <sage.weil@dreamhost.com>
Fri, 2 Dec 2011 05:03:28 +0000 (21:03 -0800)
committerSamuel Just <samuel.just@dreamhost.com>
Wed, 14 Dec 2011 19:31:32 +0000 (11:31 -0800)
Scan a range of the local collection.

Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/osd/ReplicatedPG.cc
src/osd/ReplicatedPG.h

index 54d7a92c23b11f8a996ac61a5cbf7b1029d91670..ecfd4e2bd0da9a954418fc2a8e8612ab207f05fb 100644 (file)
@@ -5151,6 +5151,35 @@ int ReplicatedPG::recover_replicas(int max)
   return started;
 }
 
+void ReplicatedPG::scan_range(hobject_t begin, int min, int max, BackfillInterval *bi)
+{
+  assert(is_locked());
+  dout(10) << "scan_range from " << begin << dendl;
+  bi->begin = begin;
+
+  vector<hobject_t> ls(max);
+  int r = osd->store->collection_list_partial(coll, begin, min, max, &ls, &bi->end);
+  assert(r >= 0);
+
+  for (vector<hobject_t>::iterator p = ls.begin(); p != ls.end(); ++p) {
+    ObjectContext *obc = NULL;
+    if (is_primary())
+      obc = _lookup_object_context(*p);
+    if (obc) {
+      bi->objects[*p] = obc->obs.oi.version;
+      dout(20) << "  " << *p << " " << obc->obs.oi.version << dendl;
+    } else {
+      bufferlist bl;
+      int r = osd->store->getattr(coll, *p, OI_ATTR, bl);
+      assert(r >= 0);
+      object_info_t oi(bl);
+      bi->objects[*p] = oi.version;
+      dout(20) << "  " << *p << " " << oi.version << dendl;
+    }
+  }
+}
+
+
 void ReplicatedPG::remove_object_with_snap_hardlinks(ObjectStore::Transaction& t, const hobject_t& soid)
 {
   t.remove(coll, soid);
index e5e456fbf7a5fff745a7706daa4fa62867d76fa1..a979d20c849009d5342113c771946d6f28d01d4e 100644 (file)
@@ -612,6 +612,16 @@ protected:
   int recover_primary(int max);
   int recover_replicas(int max);
 
+  /**
+   * scan a (hash) range of objects in the current pg
+   *
+   * @begin first item should be >= this value
+   * @min return at least this many items, unless we are done
+   * @max return no more than this many items
+   * @bi [out] resulting map of objects to eversion_t's
+   */
+  void scan_range(hobject_t begin, int min, int max, BackfillInterval *bi);
+
   void dump_watchers(ObjectContext *obc);
   void remove_watcher(ObjectContext *obc, entity_name_t entity);
   void remove_notify(ObjectContext *obc, Watch::Notification *notif);