]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
DBObjectMap: fix next_parent()
authorSamuel Just <sjust@redhat.com>
Fri, 10 Feb 2017 23:48:57 +0000 (15:48 -0800)
committerDavid Zafman <dzafman@redhat.com>
Tue, 28 Mar 2017 16:32:46 +0000 (09:32 -0700)
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 <sjust@redhat.com>
(cherry picked from commit 74a7631d0938d7b44894f022224eab10a90d5cec)

src/os/filestore/DBObjectMap.cc

index 0fd9ed7bff7a11c64dd5c34991b0e6ef7a93697c..97833925d4994e0a3f2a696822c4424c8c8e061c 100644 (file)
@@ -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,