]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: StupidAllocator stucks on 4GB allocations
authorIgor Fedotov <ifedotov@suse.com>
Tue, 9 Jul 2019 18:19:37 +0000 (21:19 +0300)
committerIgor Fedotov <ifedotov@suse.com>
Sat, 25 Jul 2020 10:55:22 +0000 (13:55 +0300)
Signed-off-by: Igor Fedotov <ifedotov@suse.com>
(cherry picked from commit 1a91a67bf2fab64d27a000b3c62d3d7beac1aa75)

 Conflicts:
src/test/objectstore/Allocator_test.cc
 Previous gtest version

src/os/bluestore/StupidAllocator.cc
src/test/objectstore/Allocator_test.cc

index c17ebb3b13aa116278479731d0390e4cf8ab7529..c80c855ad40e43b504590eab79e18baebb3bcaf5 100644 (file)
@@ -193,6 +193,8 @@ int64_t StupidAllocator::allocate(
   if (max_alloc_size == 0) {
     max_alloc_size = want_size;
   }
+  // cap with 32-bit val
+  max_alloc_size = std::min(max_alloc_size, 0x10000000 - alloc_unit);
 
   while (allocated_size < want_size) {
     res = allocate_int(std::min(max_alloc_size, (want_size - allocated_size)),
index 60ccd95174a862c55e45c025bf120a3e746c8cfc..73f95f5b56aacb912adb5b24595b76b004612fb3 100644 (file)
@@ -411,7 +411,7 @@ TEST_P(AllocTest, test_alloc_big2)
   int64_t mas = 1024*1024;
   init_alloc(blocks*block_size, block_size);
   alloc->init_add_free(0, blocks * block_size);
-  
+
   PExtentVector extents;
   uint64_t need = block_size * blocks / 4; // 2GB
   EXPECT_EQ(need,
@@ -422,6 +422,24 @@ TEST_P(AllocTest, test_alloc_big2)
   EXPECT_TRUE(extents[0].length > 0);
 }
 
+//Verifies stuck 4GB chunk allocation
+//in StupidAllocator
+//
+TEST_P(AllocTest, test_alloc_big3)
+{
+  int64_t block_size = 4096;
+  int64_t blocks = 1048576 * 2;
+  int64_t mas = 1024*1024;
+  init_alloc(blocks*block_size, block_size);
+  alloc->init_add_free(0, blocks * block_size);
+
+  PExtentVector extents;
+  uint64_t need = block_size * blocks / 2; // 4GB
+  EXPECT_EQ(need,
+      alloc->allocate(need, mas, 0, &extents));
+  EXPECT_TRUE(extents[0].length > 0);
+}
+
 INSTANTIATE_TEST_CASE_P(
   Allocator,
   AllocTest,