From 85f2151fec991e5db13d8e6f44b27e092605fb35 Mon Sep 17 00:00:00 2001 From: Samuel Just Date: Fri, 10 Feb 2017 15:48:57 -0800 Subject: [PATCH] DBObjectMap: fix next_parent() The previous implementation assumed that lower_bound(parent_iter->key()) always leaves the iterator on_parent(). There isn't any guarantee, however, that that key isn't present on the child as well. Signed-off-by: Samuel Just (cherry picked from commit 74a7631d0938d7b44894f022224eab10a90d5cec) --- src/os/filestore/DBObjectMap.cc | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/os/filestore/DBObjectMap.cc b/src/os/filestore/DBObjectMap.cc index 7a4ea28681b1..079019c57d61 100644 --- a/src/os/filestore/DBObjectMap.cc +++ b/src/os/filestore/DBObjectMap.cc @@ -375,17 +375,20 @@ int DBObjectMap::DBObjectMapIteratorImpl::next(bool validate) int DBObjectMap::DBObjectMapIteratorImpl::next_parent() { - if (!parent_iter || !parent_iter->valid()) { - invalid = true; - return 0; - } r = next(); if (r < 0) return r; - if (!valid() || on_parent() || !parent_iter->valid()) - return 0; + while (parent_iter && parent_iter->valid() && !on_parent()) { + assert(valid()); + r = lower_bound(parent_iter->key()); + if (r < 0) + return r; + } - return lower_bound(parent_iter->key()); + if (!parent_iter || !parent_iter->valid()) { + invalid = true; + } + return 0; } int DBObjectMap::DBObjectMapIteratorImpl::in_complete_region(const string &to_test, -- 2.47.3