cursor.omap_offet indicates the most recently recovered key, we continue
filling in at the smallest key k | k > cursor.omap_offset. If the loop
as written terminates due to !(left > 0), iter points at the next key to
copy, rather than the last key copied, resulting in the next copy
operation skipping that key.
Now, iter, if valid, must point to the last key copied once the loop has
completed since we check left <= 0 prior to advancing iter. We can
therefore use it to fill in cursor.omap_offset.
Signed-off-by: Samuel Just <sam.just@inktank.com>
osd->store->get_omap_iterator(coll, oi.soid);
assert(iter);
iter->upper_bound(cursor.omap_offset);
- for (; left > 0 && iter->valid(); iter->next()) {
+ for (; iter->valid(); iter->next()) {
out_omap.insert(make_pair(iter->key(), iter->value()));
left -= iter->key().length() + 4 + iter->value().length() + 4;
+ if (left <= 0)
+ break;
}
if (iter->valid()) {
cursor.omap_offset = iter->key();