]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
PGBackend,ReplicatedBackend: add interfaces for scanning the pg
authorSamuel Just <sam.just@inktank.com>
Tue, 17 Sep 2013 17:11:54 +0000 (10:11 -0700)
committerSamuel Just <sam.just@inktank.com>
Fri, 4 Oct 2013 20:50:06 +0000 (13:50 -0700)
This will be important since the erasure coded pg will have a different
on-disk format than the replicated backend.

Signed-off-by: Samuel Just <sam.just@inktank.com>
src/osd/PGBackend.h
src/osd/ReplicatedBackend.cc
src/osd/ReplicatedBackend.h

index e3cc05bf345630b57ab18dafc935423447bfe0a8..408c589a08a06d7d04e2b9e8e8322fc2a92af0fc 100644 (file)
    virtual void clear_temp_obj(const hobject_t &oid) = 0;
 
    virtual ~PGBackend() {}
+
+   /// List objects in collection
+   virtual int objects_list_partial(
+     const hobject_t &begin,
+     int min,
+     int max,
+     snapid_t seq,
+     vector<hobject_t> *ls,
+     hobject_t *next) = 0;
+
+   virtual int objects_list_range(
+     const hobject_t &start,
+     const hobject_t &end,
+     snapid_t seq,
+     vector<hobject_t> *ls) = 0;
+
+   virtual int objects_get_attr(
+     const hobject_t &hoid,
+     const string &attr,
+     bufferlist *out) = 0;
  };
 
 #endif
index 9868e7af2c8771af7d9b090351f0495f8e770216..ddc39d703727cd7cdd42e477b0ee859a7a927787 100644 (file)
@@ -194,3 +194,75 @@ void ReplicatedBackend::on_flushed()
     assert(0 == "found garbage in the temp collection");
   }
 }
+
+
+int ReplicatedBackend::objects_list_partial(
+  const hobject_t &begin,
+  int min,
+  int max,
+  snapid_t seq,
+  vector<hobject_t> *ls,
+  hobject_t *next)
+{
+  vector<ghobject_t> objects;
+  ghobject_t _next;
+  int r = osd->store->collection_list_partial(
+    coll,
+    begin,
+    min,
+    max,
+    seq,
+    &objects,
+    &_next);
+  ls->reserve(objects.size());
+  for (vector<ghobject_t>::iterator i = objects.begin();
+       i != objects.end();
+       ++i) {
+    assert(i->is_degenerate());
+    ls->push_back(i->hobj);
+  }
+  assert(_next.is_degenerate());
+  *next = _next.hobj;
+  return r;
+}
+
+int ReplicatedBackend::objects_list_range(
+  const hobject_t &start,
+  const hobject_t &end,
+  snapid_t seq,
+  vector<hobject_t> *ls)
+{
+  vector<ghobject_t> objects;
+  int r = osd->store->collection_list_range(
+    coll,
+    start,
+    end,
+    seq,
+    &objects);
+  ls->reserve(objects.size());
+  for (vector<ghobject_t>::iterator i = objects.begin();
+       i != objects.end();
+       ++i) {
+    assert(i->is_degenerate());
+    ls->push_back(i->hobj);
+  }
+  return r;
+}
+
+int ReplicatedBackend::objects_get_attr(
+  const hobject_t &hoid,
+  const string &attr,
+  bufferlist *out)
+{
+  bufferptr bp;
+  int r = osd->store->getattr(
+    coll,
+    hoid,
+    attr.c_str(),
+    bp);
+  if (r >= 0 && out) {
+    out->clear();
+    out->push_back(bp);
+  }
+  return r;
+}
index e34e55a618e17abc9d68c4d45527b128badc653a..cc5f060e136b25de2795d7fa1042706cde3872cb 100644 (file)
@@ -148,6 +148,26 @@ public:
       f->close_section();
     }
   }
+
+  /// List objects in collection
+  int objects_list_partial(
+    const hobject_t &begin,
+    int min,
+    int max,
+    snapid_t seq,
+    vector<hobject_t> *ls,
+    hobject_t *next);
+
+  int objects_list_range(
+    const hobject_t &start,
+    const hobject_t &end,
+    snapid_t seq,
+    vector<hobject_t> *ls);
+
+  int objects_get_attr(
+    const hobject_t &hoid,
+    const string &attr,
+    bufferlist *out);
 private:
   // push
   struct PushInfo {