]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
test/crimson/seastore/test_transaction_manager: add a UT case for 57709/head
authorXuehan Xu <xuxuehan@qianxin.com>
Thu, 13 Jun 2024 06:22:50 +0000 (14:22 +0800)
committerXuehan Xu <xuxuehan@qianxin.com>
Wed, 26 Jun 2024 02:59:20 +0000 (10:59 +0800)
detecting invalid lba mappings

Signed-off-by: Xuehan Xu <xuxuehan@qianxin.com>
src/test/crimson/seastore/test_transaction_manager.cc

index 36e08001971d51156a6e864a65156e322126a45b..a638896a86e7ddbfee0e60908dce77502022bc48 100644 (file)
@@ -14,6 +14,7 @@
 #include "crimson/os/seastore/segment_manager.h"
 
 #include "test/crimson/seastore/test_block.h"
+#include "crimson/os/seastore/lba_manager/btree/lba_btree_node.h"
 
 using namespace crimson;
 using namespace crimson::os;
@@ -2173,6 +2174,42 @@ TEST_P(tm_single_device_intergrity_check_test_t, remap_lazy_read)
    });
 }
 
+TEST_P(tm_single_device_test_t, invalid_lba_mapping_detect)
+{
+  run_async([this] {
+    using namespace crimson::os::seastore::lba_manager::btree;
+    {
+      auto t = create_transaction();
+      for (int i = 0; i < LEAF_NODE_CAPACITY; i++) {
+       auto extent = alloc_extent(
+         t,
+         i * 4096,
+         4096,
+         'a');
+      }
+      submit_transaction(std::move(t));
+    }
+
+    {
+      auto t = create_transaction();
+      auto pin = get_pin(t, (LEAF_NODE_CAPACITY - 1) * 4096);
+      assert(pin->is_parent_valid());
+      auto extent = alloc_extent(t, LEAF_NODE_CAPACITY * 4096, 4096, 'a');
+      assert(!pin->is_parent_valid());
+      pin = get_pin(t, LEAF_NODE_CAPACITY * 4096);
+      std::ignore = alloc_extent(t, (LEAF_NODE_CAPACITY + 1) * 4096, 4096, 'a');
+      assert(pin->is_parent_valid());
+      assert(pin->parent_modified());
+      pin->maybe_fix_pos();
+      auto v = pin->get_logical_extent(*t.t);
+      assert(v.has_child());
+      auto extent2 = v.get_child_fut().unsafe_get0();
+      assert(extent.get() == extent2.get());
+      submit_transaction(std::move(t));
+    }
+  });
+}
+
 TEST_P(tm_single_device_test_t, random_writes_concurrent)
 {
   test_random_writes_concurrent();