From: Samuel Just Date: Fri, 10 Feb 2017 23:48:57 +0000 (-0800) Subject: DBObjectMap: fix next_parent() X-Git-Tag: v11.2.1~210^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a3c3e3ef4e3d20baf28000f11b4ea5bb45e161f9;p=ceph.git 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) --- diff --git a/src/os/filestore/DBObjectMap.cc b/src/os/filestore/DBObjectMap.cc index 0fd9ed7bff7a..97833925d499 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,