From: Igor Fedotov Date: Tue, 12 Jun 2018 11:50:30 +0000 (+0300) Subject: os/bluestore: rename new bitmap allocator class to BitmapAllocator. X-Git-Tag: v14.0.1~1129^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=a8e8c192acb48ce93553b04d1953ce8bee1b16e4;p=ceph.git os/bluestore: rename new bitmap allocator class to BitmapAllocator. Signed-off-by: Igor Fedotov --- diff --git a/src/os/CMakeLists.txt b/src/os/CMakeLists.txt index c5e1b0d138bc..17f78b71204f 100644 --- a/src/os/CMakeLists.txt +++ b/src/os/CMakeLists.txt @@ -31,7 +31,7 @@ if(WITH_BLUESTORE) bluestore/fastbmap_allocator_impl.cc bluestore/FreelistManager.cc bluestore/StupidAllocator.cc - bluestore/BitmapFastAllocator.cc + bluestore/BitmapAllocator.cc ) endif(WITH_BLUESTORE) diff --git a/src/os/bluestore/Allocator.cc b/src/os/bluestore/Allocator.cc index 9b12301bac8c..b6026353165c 100644 --- a/src/os/bluestore/Allocator.cc +++ b/src/os/bluestore/Allocator.cc @@ -3,7 +3,7 @@ #include "Allocator.h" #include "StupidAllocator.h" -#include "BitmapFastAllocator.h" +#include "BitmapAllocator.h" #include "common/debug.h" #define dout_subsys ceph_subsys_bluestore @@ -14,7 +14,7 @@ Allocator *Allocator::create(CephContext* cct, string type, if (type == "stupid") { return new StupidAllocator(cct); } else if (type == "bitmap") { - return new BitmapFastAllocator(cct, size, block_size); + return new BitmapAllocator(cct, size, block_size); } lderr(cct) << "Allocator::" << __func__ << " unknown alloc type " << type << dendl; diff --git a/src/os/bluestore/BitmapAllocator.cc b/src/os/bluestore/BitmapAllocator.cc new file mode 100755 index 000000000000..fc7d66c0f95e --- /dev/null +++ b/src/os/bluestore/BitmapAllocator.cc @@ -0,0 +1,85 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#include "BitmapAllocator.h" + +#define dout_context cct +#define dout_subsys ceph_subsys_bluestore +#undef dout_prefix +#define dout_prefix *_dout << "fbmap_alloc 0x" << this << " " + +BitmapAllocator::BitmapAllocator(CephContext* _cct, + int64_t capacity, + int64_t alloc_unit) : + cct(_cct) +{ + ldout(cct, 10) << __func__ << " 0x" << std::hex << capacity << "/" + << alloc_unit << std::dec << dendl; + _init(capacity, alloc_unit, false); +} + +int64_t BitmapAllocator::allocate( + uint64_t want_size, uint64_t alloc_unit, uint64_t max_alloc_size, + int64_t hint, PExtentVector *extents) +{ + uint64_t allocated = 0; + + ldout(cct, 10) << __func__ << std::hex << "0x" << want_size + << "/" << alloc_unit << "," << max_alloc_size << "," << hint + << std::dec << dendl; + + + _allocate_l2(want_size, alloc_unit, max_alloc_size, hint, + &allocated, extents); + if (!allocated) { + return -ENOSPC; + } + for (auto e : *extents) { + ldout(cct, 10) << __func__ + << " 0x" << std::hex << e.offset << "~" << e.length + << "/" << alloc_unit << "," << max_alloc_size << "," << hint + << std::dec << dendl; + } + return int64_t(allocated); +} + +void BitmapAllocator::release( + const interval_set& release_set) +{ + for (auto r : release_set) { + ldout(cct, 10) << __func__ << " 0x" << std::hex << r.first << "~" << r.second + << std::dec << dendl; + } + _free_l2(release_set); + ldout(cct, 10) << __func__ << " done" << dendl; +} + + +void BitmapAllocator::init_add_free(uint64_t offset, uint64_t length) +{ + ldout(cct, 10) << __func__ << " 0x" << std::hex << offset << "~" << length + << std::dec << dendl; + + auto mas = get_min_alloc_size(); + uint64_t offs = round_up_to(offset, mas); + uint64_t l = p2align(offset + length - offs, mas); + + _mark_free(offs, l); + ldout(cct, 10) << __func__ << " done" << dendl; +} +void BitmapAllocator::init_rm_free(uint64_t offset, uint64_t length) +{ + ldout(cct, 10) << __func__ << " 0x" << std::hex << offset << "~" << length + << std::dec << dendl; + auto mas = get_min_alloc_size(); + uint64_t offs = round_up_to(offset, mas); + uint64_t l = p2align(offset + length - offs, mas); + _mark_allocated(offs, l); + ldout(cct, 10) << __func__ << " done" << dendl; +} + +void BitmapAllocator::shutdown() +{ + ldout(cct, 1) << __func__ << dendl; + _shutdown(); +} diff --git a/src/os/bluestore/BitmapAllocator.h b/src/os/bluestore/BitmapAllocator.h new file mode 100755 index 000000000000..c4f7f7beb29a --- /dev/null +++ b/src/os/bluestore/BitmapAllocator.h @@ -0,0 +1,48 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab + +#ifndef CEPH_OS_BLUESTORE_BITMAPFASTALLOCATOR_H +#define CEPH_OS_BLUESTORE_BITMAPFASTALLOCATOR_H + +#include + +#include "Allocator.h" +#include "os/bluestore/bluestore_types.h" +#include "fastbmap_allocator_impl.h" +#include "include/mempool.h" +#include "common/debug.h" + +class BitmapAllocator : public Allocator, + public AllocatorLevel02 { + CephContext* cct; + +public: + BitmapAllocator(CephContext* _cct, int64_t capacity, int64_t alloc_unit); + ~BitmapAllocator() override + { + } + + + int64_t allocate( + uint64_t want_size, uint64_t alloc_unit, uint64_t max_alloc_size, + int64_t hint, PExtentVector *extents) override; + + void release( + const interval_set& release_set) override; + + uint64_t get_free() override + { + return get_available(); + } + + void dump() override + { + } + + void init_add_free(uint64_t offset, uint64_t length) override; + void init_rm_free(uint64_t offset, uint64_t length) override; + + void shutdown() override; +}; + +#endif diff --git a/src/os/bluestore/BitmapFastAllocator.cc b/src/os/bluestore/BitmapFastAllocator.cc deleted file mode 100755 index 3180ca00d35d..000000000000 --- a/src/os/bluestore/BitmapFastAllocator.cc +++ /dev/null @@ -1,85 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab - -#include "BitmapFastAllocator.h" - -#define dout_context cct -#define dout_subsys ceph_subsys_bluestore -#undef dout_prefix -#define dout_prefix *_dout << "fbmap_alloc 0x" << this << " " - -BitmapFastAllocator::BitmapFastAllocator(CephContext* _cct, - int64_t capacity, - int64_t alloc_unit) : - cct(_cct) -{ - ldout(cct, 10) << __func__ << " 0x" << std::hex << capacity << "/" - << alloc_unit << std::dec << dendl; - _init(capacity, alloc_unit, false); -} - -int64_t BitmapFastAllocator::allocate( - uint64_t want_size, uint64_t alloc_unit, uint64_t max_alloc_size, - int64_t hint, PExtentVector *extents) -{ - uint64_t allocated = 0; - - ldout(cct, 10) << __func__ << std::hex << "0x" << want_size - << "/" << alloc_unit << "," << max_alloc_size << "," << hint - << std::dec << dendl; - - - _allocate_l2(want_size, alloc_unit, max_alloc_size, hint, - &allocated, extents); - if (!allocated) { - return -ENOSPC; - } - for (auto e : *extents) { - ldout(cct, 10) << __func__ - << " 0x" << std::hex << e.offset << "~" << e.length - << "/" << alloc_unit << "," << max_alloc_size << "," << hint - << std::dec << dendl; - } - return int64_t(allocated); -} - -void BitmapFastAllocator::release( - const interval_set& release_set) -{ - for (auto r : release_set) { - ldout(cct, 10) << __func__ << " 0x" << std::hex << r.first << "~" << r.second - << std::dec << dendl; - } - _free_l2(release_set); - ldout(cct, 10) << __func__ << " done" << dendl; -} - - -void BitmapFastAllocator::init_add_free(uint64_t offset, uint64_t length) -{ - ldout(cct, 10) << __func__ << " 0x" << std::hex << offset << "~" << length - << std::dec << dendl; - - auto mas = get_min_alloc_size(); - uint64_t offs = round_up_to(offset, mas); - uint64_t l = p2align(offset + length - offs, mas); - - _mark_free(offs, l); - ldout(cct, 10) << __func__ << " done" << dendl; -} -void BitmapFastAllocator::init_rm_free(uint64_t offset, uint64_t length) -{ - ldout(cct, 10) << __func__ << " 0x" << std::hex << offset << "~" << length - << std::dec << dendl; - auto mas = get_min_alloc_size(); - uint64_t offs = round_up_to(offset, mas); - uint64_t l = p2align(offset + length - offs, mas); - _mark_allocated(offs, l); - ldout(cct, 10) << __func__ << " done" << dendl; -} - -void BitmapFastAllocator::shutdown() -{ - ldout(cct, 1) << __func__ << dendl; - _shutdown(); -} diff --git a/src/os/bluestore/BitmapFastAllocator.h b/src/os/bluestore/BitmapFastAllocator.h deleted file mode 100755 index 9807780b50c8..000000000000 --- a/src/os/bluestore/BitmapFastAllocator.h +++ /dev/null @@ -1,48 +0,0 @@ -// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- -// vim: ts=8 sw=2 smarttab - -#ifndef CEPH_OS_BLUESTORE_BITMAPFASTALLOCATOR_H -#define CEPH_OS_BLUESTORE_BITMAPFASTALLOCATOR_H - -#include - -#include "Allocator.h" -#include "os/bluestore/bluestore_types.h" -#include "fastbmap_allocator_impl.h" -#include "include/mempool.h" -#include "common/debug.h" - -class BitmapFastAllocator : public Allocator, - public AllocatorLevel02 { - CephContext* cct; - -public: - BitmapFastAllocator(CephContext* _cct, int64_t capacity, int64_t alloc_unit); - ~BitmapFastAllocator() override - { - } - - - int64_t allocate( - uint64_t want_size, uint64_t alloc_unit, uint64_t max_alloc_size, - int64_t hint, PExtentVector *extents) override; - - void release( - const interval_set& release_set) override; - - uint64_t get_free() override - { - return get_available(); - } - - void dump() override - { - } - - void init_add_free(uint64_t offset, uint64_t length) override; - void init_rm_free(uint64_t offset, uint64_t length) override; - - void shutdown() override; -}; - -#endif