From: Samuel Just Date: Wed, 5 Mar 2014 01:05:36 +0000 (-0800) Subject: ReplicatedPG::fill_in_copy_get: fix omap loop conditions X-Git-Tag: v0.78~84^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F1372%2Fhead;p=ceph.git ReplicatedPG::fill_in_copy_get: fix omap loop conditions 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 --- diff --git a/src/osd/ReplicatedPG.cc b/src/osd/ReplicatedPG.cc index 7ba87c484ada..cca32723a103 100644 --- a/src/osd/ReplicatedPG.cc +++ b/src/osd/ReplicatedPG.cc @@ -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();