]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: fix bluestore stupid allocator choose wrong bin when running for that bdev_bloc... 37900/head
authorjhonxue <jhonxue@tencent.com>
Mon, 2 Nov 2020 10:42:35 +0000 (18:42 +0800)
committerjhonxue <jhonxue@tencent.com>
Mon, 2 Nov 2020 10:42:35 +0000 (18:42 +0800)
by asok command that ceph daemon osd.* config set bdev_block_size other_size

Fixes: https://tracker.ceph.com/issues/48048
Signed-off-by: Xue Yantao <jhonxue@tencent.com>
src/os/bluestore/StupidAllocator.cc
src/os/bluestore/StupidAllocator.h

index 2660657d9e93480baa07dfb1d48118e47d72648f..0f4726d767746f0f1f12e663f72c18ebdee60b0b 100644 (file)
@@ -17,6 +17,8 @@ StupidAllocator::StupidAllocator(CephContext* cct,
     block_size(_block_size),
     free(10)
 {
+  ceph_assert(cct != nullptr);
+  bdev_block_size = cct->_conf->bdev_block_size;
 }
 
 StupidAllocator::~StupidAllocator()
@@ -25,7 +27,8 @@ StupidAllocator::~StupidAllocator()
 
 unsigned StupidAllocator::_choose_bin(uint64_t orig_len)
 {
-  uint64_t len = orig_len / cct->_conf->bdev_block_size;
+  ceph_assert(bdev_block_size > 0);
+  uint64_t len = orig_len / bdev_block_size;
   int bin = std::min((int)cbits(len), (int)free.size() - 1);
   ldout(cct, 30) << __func__ << " len 0x" << std::hex << orig_len
                 << std::dec << " -> " << bin << dendl;
index 4139de81b60344ba17ea10a5495158e68c04f304..0bf189779c8cc0950148f932d22e420c1b5622c0 100644 (file)
@@ -19,6 +19,7 @@ class StupidAllocator : public Allocator {
 
   int64_t num_free;     ///< total bytes in freelist
   int64_t block_size;
+  uint64_t bdev_block_size;
 
   template <typename K, typename V> using allocator_t =
     mempool::bluestore_alloc::pool_allocator<std::pair<const K, V>>;