diff --git a/src/common/hobject.h b/src/common/hobject.h index 7b28ff28840..17137545783 100644 --- a/src/common/hobject.h +++ b/src/common/hobject.h @@ -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()); diff --git a/src/osd/ReplicatedBackend.cc b/src/osd/ReplicatedBackend.cc index 8f3156db14a..f66a58eee6d 100644 --- a/src/osd/ReplicatedBackend.cc +++ b/src/osd/ReplicatedBackend.cc @@ -227,25 +227,33 @@ int ReplicatedBackend::objects_list_partial( vector *ls, hobject_t *next) { - vector objects; - ghobject_t _next; - int r = osd->store->collection_list_partial( - coll, - begin, - min, - max, - seq, - &objects, - &_next); - ls->reserve(objects.size()); - for (vector::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 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::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 *ls) { + assert(ls); vector objects; int r = osd->store->collection_list_range( coll, @@ -266,8 +275,10 @@ int ReplicatedBackend::objects_list_range( for (vector::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; }