From 4cb1cbfbf336654e9884d5f5a3f110243ea893de Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Tue, 4 Mar 2014 17:05:36 -0800 Subject: [PATCH] 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 --- src/osd/ReplicatedPG.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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(); -- 2.47.3