]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore: fix overlappedd allocation returned by bitmap allocator
authorIgor Fedotov <ifedotov@suse.com>
Mon, 25 Jun 2018 14:42:41 +0000 (17:42 +0300)
committerIgor Fedotov <ifedotov@suse.com>
Mon, 25 Jun 2018 15:06:24 +0000 (18:06 +0300)
Fixes: https://tracker.ceph.com/issues/24598
Signed-off-by: Igor Fedotov <ifedotov@suse.som>
src/os/bluestore/fastbmap_allocator_impl.cc
src/test/objectstore/Allocator_test.cc

index 9fdaab2fb3ba9950e338d94d389f6f68279088c9..424f8051871d6b31315f44924a573ee635e4eb85 100755 (executable)
@@ -85,8 +85,8 @@ interval_t AllocatorLevel01Loose::_get_longest_from_l0(uint64_t pos0,
              res_candidate.length, min_granules);
            if (res.length < res_candidate.length) {
              res = res_candidate;
-             res_candidate = interval_t();
            }
+           res_candidate = interval_t();
            pos += d;
            end_loop = pos >= pos1;
            continue;
index 3b6bc358856f70b9627955fecabc2005fe408b61..959932af9e5980f3dc36bd1bf032da5f90401e78 100644 (file)
@@ -285,6 +285,37 @@ TEST_P(AllocTest, test_alloc_fragmentation)
   // digits after decimal point due to this.
   EXPECT_EQ(0, uint64_t(alloc->get_fragmentation(alloc_unit) * 100));
 }
+
+TEST_P(AllocTest, test_alloc_bug_24598)
+{
+  if (string(GetParam()) != "bitmap")
+    return;
+  
+  uint64_t capacity = 0x2625a0000ull;
+  uint64_t alloc_unit = 0x4000;
+  uint64_t want_size = 0x200000;
+  PExtentVector allocated, tmp;
+
+  init_alloc(capacity, alloc_unit);
+
+  alloc->init_add_free(0x4800000, 0x100000);
+  alloc->init_add_free(0x4a00000, 0x100000);
+
+  alloc->init_rm_free(0x4800000, 0x100000);
+  alloc->init_rm_free(0x4a00000, 0x100000);
+
+  alloc->init_add_free(0x3f00000, 0x500000);
+  alloc->init_add_free(0x4500000, 0x100000);
+  alloc->init_add_free(0x4700000, 0x100000);
+  alloc->init_add_free(0x4900000, 0x100000);
+  alloc->init_add_free(0x4b00000, 0x200000);
+
+  EXPECT_EQ(want_size, alloc->allocate(want_size, 0x100000, 0, 0, &tmp));
+  EXPECT_EQ(tmp[0].offset, 0x4b00000);
+  EXPECT_EQ(tmp[0].length, 0x200000);
+  EXPECT_EQ(tmp.size(), 1);
+}
+
 INSTANTIATE_TEST_CASE_P(
   Allocator,
   AllocTest,