]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/os/seastore/.../lba_btree_node_impl: fix mutate_mapping for missing element
authorSamuel Just <sjust@redhat.com>
Fri, 30 Oct 2020 23:53:50 +0000 (16:53 -0700)
committerSamuel Just <sjust@redhat.com>
Mon, 7 Dec 2020 19:58:32 +0000 (11:58 -0800)
Also adds assert to LBAInternalNode -- any laddr in the range of an internal
node must necessarily be in the range of a child.

Signed-off-by: Samuel Just <sjust@redhat.com>
src/crimson/os/seastore/lba_manager/btree/lba_btree_node_impl.cc

index ba04440b91e90682efc4995c42a172f7e9193316..2559da4df5d17a80a9d6e024ae892835b569b1f5 100644 (file)
@@ -109,17 +109,22 @@ LBAInternalNode::mutate_mapping_ret LBAInternalNode::mutate_mapping(
   laddr_t laddr,
   mutate_func_t &&f)
 {
+  auto mutation_pt = get_containing_child(laddr);
+  if (mutation_pt == end()) {
+    assert(0 == "impossible");
+    return crimson::ct_error::enoent::make();
+  }
   return get_lba_btree_extent(
     c,
     get_meta().depth - 1,
-    get_containing_child(laddr)->get_val(),
+    mutation_pt->get_val(),
     get_paddr()
-  ).safe_then([this, c, laddr](LBANodeRef extent) {
+  ).safe_then([this, c, laddr, mutation_pt](LBANodeRef extent) {
     if (extent->at_min_capacity()) {
       return merge_entry(
        c,
        laddr,
-       get_containing_child(laddr),
+       mutation_pt,
        extent);
     } else {
       return merge_ertr::make_ready_future<LBANodeRef>(
@@ -470,6 +475,11 @@ LBALeafNode::mutate_mapping_ret LBALeafNode::mutate_mapping(
   laddr_t laddr,
   mutate_func_t &&f)
 {
+  auto mutation_pt = find(laddr);
+  if (mutation_pt == end()) {
+    return crimson::ct_error::enoent::make();
+  }
+
   if (!is_pending()) {
     return c.cache.duplicate_for_write(c.trans, this)->cast<LBALeafNode>(
     )->mutate_mapping(
@@ -478,11 +488,6 @@ LBALeafNode::mutate_mapping_ret LBALeafNode::mutate_mapping(
       std::move(f));
   }
 
-  auto mutation_pt = find(laddr);
-  if (mutation_pt == end()) {
-    return crimson::ct_error::enoent::make();
-  }
-
   auto cur = mutation_pt.get_val();
   auto mutated = f(cur);