From: jhonxue Date: Mon, 2 Nov 2020 10:42:35 +0000 (+0800) Subject: osd: fix bluestore stupid allocator choose wrong bin when running for that bdev_bloc... X-Git-Tag: v16.1.0~513^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=350ccfc200242c6af967c6bc0b4b00515dec4dfe;p=ceph.git osd: fix bluestore stupid allocator choose wrong bin when running for that bdev_block_size can be changed 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 --- diff --git a/src/os/bluestore/StupidAllocator.cc b/src/os/bluestore/StupidAllocator.cc index 2660657d9e9..0f4726d7677 100644 --- a/src/os/bluestore/StupidAllocator.cc +++ b/src/os/bluestore/StupidAllocator.cc @@ -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; diff --git a/src/os/bluestore/StupidAllocator.h b/src/os/bluestore/StupidAllocator.h index 4139de81b60..0bf189779c8 100644 --- a/src/os/bluestore/StupidAllocator.h +++ b/src/os/bluestore/StupidAllocator.h @@ -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 using allocator_t = mempool::bluestore_alloc::pool_allocator>;