]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: unconditionally cap chunks returned by allocator to 2^31 27298/head
authorIgor Fedotov <ifedotov@suse.com>
Wed, 20 Mar 2019 18:10:04 +0000 (21:10 +0300)
committerIgor Fedotov <ifedotov@suse.com>
Mon, 1 Apr 2019 16:43:52 +0000 (19:43 +0300)
Signed-off-by: Igor Fedotov <ifedotov@suse.com>
(cherry picked from commit 1337443e37ffbfcaf494bdb2bb80db4cf41b97f9)

src/os/bluestore/fastbmap_allocator_impl.h
src/test/objectstore/fastbmap_allocator_test.cc

index 7cb92a1fa2705db0dc2465c1c28f53c0f4635adb..88f9676ec259603c7684494514ddc21fe4c61332 100755 (executable)
@@ -155,7 +155,6 @@ class AllocatorLevel01Loose : public AllocatorLevel01
     interval_vector_t* res)
   {
     auto it = res->rbegin();
-
     if (max_length) {
       if (it != res->rend() && it->offset + it->length == offset) {
        auto l = max_length - it->length;
@@ -636,6 +635,11 @@ protected:
     assert(length >= min_length);
     assert((length % min_length) == 0);
 
+    uint64_t cap = 1ull << 31;
+    if (max_length == 0 || max_length >= cap) {
+      max_length = cap;
+    }
+
     uint64_t l1_w = slotset_width * l1._children_per_slot();
 
     std::lock_guard<std::mutex> l(lock);
index 222fde3ca374d8d452f19c6be64ee04863d83331..1bf847e4376ce5c1f092a6c423e4c47cebb83046 100755 (executable)
@@ -895,8 +895,6 @@ TEST(TestAllocatorLevel01, test_4G_alloc_bug2)
     std::map<size_t, size_t> bins_overall;
     al2.collect_stats(bins_overall);
 
-    std::cout << "!!!!!!!!!!!!!!" << std::endl;
-
     uint64_t allocated4 = 0;
     interval_vector_t a4;
     al2.allocate_l2(0x3e000000, _1m, &allocated4, &a4);
@@ -908,3 +906,23 @@ TEST(TestAllocatorLevel01, test_4G_alloc_bug2)
     ASSERT_EQ(a4[1].length, 0x3cd00000u);
   }
 }
+
+TEST(TestAllocatorLevel01, test_4G_alloc_bug3)
+{
+  {
+    TestAllocatorLevel02 al2;
+    uint64_t capacity = 0x8000 * _1m; // = 32GB
+    al2.init(capacity, 0x10000);
+    std::cout << "Init L2 cont aligned" << std::endl;
+
+      uint64_t allocated4 = 0;
+      interval_vector_t a4;
+      al2.allocate_l2(4096ull * _1m, _1m, &allocated4, &a4);
+      ASSERT_EQ(a4.size(), 2u); // allocator has to split into 2 allocations
+      ASSERT_EQ(allocated4, 4096ull * _1m);
+      ASSERT_EQ(a4[0].offset, 0u);
+      ASSERT_EQ(a4[0].length, 2048ull * _1m);
+      ASSERT_EQ(a4[1].offset, 2048ull * _1m);
+      ASSERT_EQ(a4[1].length, 2048ull * _1m);
+  }
+}