]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ReplicatedBackend: update the collection_list mechanisms to skip stashed objects
authorSamuel Just <sam.just@inktank.com>
Wed, 4 Dec 2013 20:09:22 +0000 (12:09 -0800)
committerSamuel Just <sam.just@inktank.com>
Wed, 22 Jan 2014 22:39:14 +0000 (14:39 -0800)
Signed-off-by: Samuel Just <sam.just@inktank.com>
src/common/hobject.h
src/osd/ReplicatedBackend.cc

index 7b28ff2884025758c53ddcaa4570b7107d6cfadb..171375457836ab089a4fe7edda68e6293ed0fb82 100644 (file)
@@ -268,6 +268,14 @@ public:
     return generation == NO_GEN && shard_id == NO_SHARD;
   }
 
+  bool is_no_gen() const {
+    return generation == NO_GEN;
+  }
+
+  bool is_no_shard() const {
+    return shard_id == NO_SHARD;
+  }
+
   // maximum sorted value.
   static ghobject_t get_max() {
     ghobject_t h(hobject_t::get_max());
index 8f3156db14a7d7fbbc1fee0d1a83d12a466a21d4..f66a58eee6de9eac412fa452c382957b7051bb3a 100644 (file)
@@ -227,25 +227,33 @@ int ReplicatedBackend::objects_list_partial(
   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(ls);
+  ghobject_t _next(begin);
+  ls->reserve(max);
+  int r = 0;
+  while (!_next.is_max() && ls->size() < (unsigned)min) {
+    vector<ghobject_t> objects;
+    int r = osd->store->collection_list_partial(
+      coll,
+      _next,
+      min - ls->size(),
+      max - ls->size(),
+      seq,
+      &objects,
+      &_next);
+    if (r != 0)
+      break;
+    for (vector<ghobject_t>::iterator i = objects.begin();
+        i != objects.end();
+        ++i) {
+      assert(i->is_no_shard());
+      if (i->is_no_gen()) {
+       ls->push_back(i->hobj);
+      }
+    }
   }
-  assert(_next.is_degenerate());
-  *next = _next.hobj;
+  if (r == 0)
+    *next = _next.hobj;
   return r;
 }
 
@@ -255,6 +263,7 @@ int ReplicatedBackend::objects_list_range(
   snapid_t seq,
   vector<hobject_t> *ls)
 {
+  assert(ls);
   vector<ghobject_t> objects;
   int r = osd->store->collection_list_range(
     coll,
@@ -266,8 +275,10 @@ int ReplicatedBackend::objects_list_range(
   for (vector<ghobject_t>::iterator i = objects.begin();
        i != objects.end();
        ++i) {
-    assert(i->is_degenerate());
-    ls->push_back(i->hobj);
+    assert(i->is_no_shard());
+    if (i->is_no_gen()) {
+      ls->push_back(i->hobj);
+    }
   }
   return r;
 }