]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/onode-staged-tree: fix container_t::update_size() to accept negative value
authorYingxin Cheng <yingxin.cheng@intel.com>
Wed, 7 Apr 2021 08:09:41 +0000 (16:09 +0800)
committerYingxin Cheng <yingxin.cheng@intel.com>
Thu, 29 Apr 2021 08:03:37 +0000 (16:03 +0800)
Signed-off-by: Yingxin Cheng <yingxin.cheng@intel.com>
src/crimson/os/seastore/onode_manager/staged-fltree/stages/node_stage_layout.cc
src/crimson/os/seastore/onode_manager/staged-fltree/stages/stage.h

index ef16143f9944faab54fea81e9047c29d0bf8727f..8fb3ff1425d87fff9f0440d8d8b7365de81e66ba 100644 (file)
@@ -36,6 +36,13 @@ void F013_T::update_size_at(
     NodeExtentMutable& mut, const me_t& node, index_t index, int change)
 {
   assert(index <= node.num_keys);
+#ifndef NDEBUG
+  // check underflow
+  if (change < 0 && index != node.num_keys) {
+    assert(node.get_item_start_offset(index) <
+           node.get_item_end_offset(index));
+  }
+#endif
   for (const auto* p_slot = &node.slots[index];
        p_slot < &node.slots[node.num_keys];
        ++p_slot) {
@@ -44,6 +51,14 @@ void F013_T::update_size_at(
         (void*)&(p_slot->right_offset),
         node_offset_t(offset - change));
   }
+#ifndef NDEBUG
+  // check overflow
+  if (change > 0 && index != node.num_keys) {
+    assert(node.num_keys > 0);
+    assert(node.get_key_start_offset(node.num_keys) <=
+           node.slots[node.num_keys - 1].right_offset);
+  }
+#endif
 }
 
 template <typename SlotType>
index d9be080201b20e4e9df71815b30dc937fa2b5957..3475784ce9b2223b4f7292330da4d6ba964b2dec 100644 (file)
@@ -335,7 +335,7 @@ struct staged {
 
     template <typename T = void>
     std::enable_if_t<!IS_BOTTOM, T>
-    update_size(NodeExtentMutable& mut, node_offset_t insert_size) {
+    update_size(NodeExtentMutable& mut, int insert_size) {
       assert(!is_end());
       container_t::update_size_at(mut, container, _index, insert_size);
     }
@@ -627,7 +627,7 @@ struct staged {
           mut, container, key, is_end(), size, p_left_bound);
     }
 
-    void update_size(NodeExtentMutable& mut, node_offset_t insert_size) {
+    void update_size(NodeExtentMutable& mut, int insert_size) {
       assert(!is_end());
       container_t::update_size(mut, container, insert_size);
     }