]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
ReplicatedPG::fill_in_copy_get: fix omap loop conditions 1372/head
authorSamuel Just <sam.just@inktank.com>
Wed, 5 Mar 2014 01:05:36 +0000 (17:05 -0800)
committerSamuel Just <sam.just@inktank.com>
Wed, 5 Mar 2014 03:29:21 +0000 (19:29 -0800)
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>
src/osd/ReplicatedPG.cc

index 7ba87c484ada99b2b651e80b75bdad7f44cb5afa..cca32723a103d28d4a6c85827bb231ab27745eca 100644 (file)
@@ -5301,9 +5301,11 @@ int ReplicatedPG::fill_in_copy_get(
        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();