]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/.../avlallocator: fix base_addr handling in find_block()
authorChanyoung Park <chaney.p@kakaoenterprise.com>
Sat, 23 Aug 2025 15:37:46 +0000 (15:37 +0000)
committermyoungwon oh <ohmyoungwon@gmail.com>
Sun, 24 Aug 2025 11:54:18 +0000 (11:54 +0000)
Fixes: https://tracker.ceph.com/issues/72699
Signed-off-by: Chanyoung Park <chaney.p@kakaoenterprise.com>
src/crimson/os/seastore/random_block_manager/avlallocator.cc
src/test/crimson/seastore/test_extent_allocator.cc

index c439424e4fa406a76ca959f94f35ed334c3ddfe5..fb4f5b7692f8140413bd3268c4dc457a15a9c1ae 100644 (file)
@@ -84,7 +84,7 @@ rbm_abs_addr AvlAllocator::find_block(size_t size)
       return off;
     } 
   }
-  return total_size;
+  return base_addr + total_size;
 }
 
 extent_len_t AvlAllocator::find_block(
index ece78e5c1d6d52e0b19b5a035bc94dc480747ed5..979e3442f3bf4a78de0a65dcb66443e491a8b2d8 100644 (file)
@@ -46,9 +46,9 @@ struct allocator_test_t :
     }
     return seastar::now();
   }
-  void init_alloc(uint64_t block_size, uint64_t total_size) {
+  void init_alloc(uint64_t block_size, uint64_t total_size, uint64_t base_addr = 0) {
     assert(allocator);
-    allocator->init(0, total_size, block_size);
+    allocator->init(base_addr, total_size, block_size);
   }
   void close() {
     assert(allocator);
@@ -121,6 +121,35 @@ TEST_P(allocator_test_t, test_scattered_alloc)
   }
 }
 
+TEST_P(allocator_test_t, test_base_addr)
+{
+  uint64_t block_size = 8192;
+  uint64_t capacity = 1024 * block_size;
+
+  auto run_case = [&](uint64_t base_addr) {
+    init_alloc(block_size, capacity, base_addr);
+
+    allocator->mark_extent_used(base_addr, block_size * 256);
+    allocator->mark_extent_used(base_addr + (block_size * 512), block_size * 256);
+
+    auto result = allocate(block_size * 512);
+    ASSERT_EQ(false, result.has_value());
+
+    result = allocates(block_size * 512);
+    ASSERT_EQ(true, result.has_value());
+
+    free(base_addr, block_size * 512);
+
+    result = allocate(block_size * 512);
+    ASSERT_EQ(true, result.has_value());
+
+    close();
+  };
+
+  run_case(0 /* base_addr */);
+  run_case(capacity /* base_addr */);
+}
+
 TEST_P(allocator_test_t, test_random_alloc_verify)
 {
   uint64_t block_size = 4096;