Merge pull request #41573 from tchaikov/wip-allocat-ctor

os/bluestore: pass string_view to ctor of Allocator

Reviewed-by: Igor Fedotov <ifedotov@suse.com>
This commit is contained in:
Kefu Chai 2021-05-29 10:36:43 +08:00 committed by GitHub
commit 2ba0f48bd1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 25 additions and 25 deletions

View File

@ -25,8 +25,7 @@ class Allocator::SocketHook : public AdminSocketHook {
friend class Allocator;
std::string name;
public:
explicit SocketHook(Allocator *alloc,
const std::string& _name) :
SocketHook(Allocator *alloc, std::string_view _name) :
alloc(alloc), name(_name)
{
AdminSocket *admin_socket = g_ceph_context->get_admin_socket();
@ -106,7 +105,7 @@ public:
}
};
Allocator::Allocator(const std::string& name,
Allocator::Allocator(std::string_view name,
int64_t _capacity,
int64_t _block_size)
: device_size(_capacity), block_size(_block_size)
@ -124,8 +123,8 @@ const string& Allocator::get_name() const {
return asok_hook->name;
}
Allocator *Allocator::create(CephContext* cct, string type,
int64_t size, int64_t block_size, const std::string& name)
Allocator *Allocator::create(CephContext* cct, std::string_view type,
int64_t size, int64_t block_size, std::string_view name)
{
Allocator* alloc = nullptr;
if (type == "stupid") {

View File

@ -19,9 +19,9 @@
class Allocator {
public:
explicit Allocator(const std::string& name,
int64_t _capacity,
int64_t _block_size);
Allocator(std::string_view name,
int64_t _capacity,
int64_t _block_size);
virtual ~Allocator();
/*
@ -66,8 +66,8 @@ public:
virtual double get_fragmentation_score();
virtual void shutdown() = 0;
static Allocator *create(CephContext* cct, std::string type, int64_t size,
int64_t block_size, const std::string& name = "");
static Allocator *create(CephContext* cct, std::string_view type, int64_t size,
int64_t block_size, const std::string_view name = "");
const string& get_name() const;

View File

@ -301,7 +301,7 @@ AvlAllocator::AvlAllocator(CephContext* cct,
int64_t device_size,
int64_t block_size,
uint64_t max_mem,
const std::string& name) :
std::string_view name) :
Allocator(name, device_size, block_size),
range_size_alloc_threshold(
cct->_conf.get_val<uint64_t>("bluestore_avl_alloc_bf_threshold")),
@ -314,7 +314,7 @@ AvlAllocator::AvlAllocator(CephContext* cct,
AvlAllocator::AvlAllocator(CephContext* cct,
int64_t device_size,
int64_t block_size,
const std::string& name) :
std::string_view name) :
Allocator(name, device_size, block_size),
range_size_alloc_threshold(
cct->_conf.get_val<uint64_t>("bluestore_avl_alloc_bf_threshold")),

View File

@ -65,11 +65,11 @@ protected:
*/
AvlAllocator(CephContext* cct, int64_t device_size, int64_t block_size,
uint64_t max_mem,
const std::string& name);
std::string_view name);
public:
AvlAllocator(CephContext* cct, int64_t device_size, int64_t block_size,
const std::string& name);
std::string_view name);
~AvlAllocator();
const char* get_type() const override
{

View File

@ -11,7 +11,7 @@
BitmapAllocator::BitmapAllocator(CephContext* _cct,
int64_t capacity,
int64_t alloc_unit,
const std::string& name) :
std::string_view name) :
Allocator(name, capacity, alloc_unit),
cct(_cct)
{

View File

@ -16,7 +16,8 @@ class BitmapAllocator : public Allocator,
public AllocatorLevel02<AllocatorLevel01Loose> {
CephContext* cct;
public:
BitmapAllocator(CephContext* _cct, int64_t capacity, int64_t alloc_unit, const std::string& name);
BitmapAllocator(CephContext* _cct, int64_t capacity, int64_t alloc_unit,
std::string_view name);
~BitmapAllocator() override
{
}

View File

@ -13,7 +13,7 @@ class HybridAllocator : public AvlAllocator {
public:
HybridAllocator(CephContext* cct, int64_t device_size, int64_t _block_size,
uint64_t max_mem,
const std::string& name) :
std::string_view name) :
AvlAllocator(cct, device_size, _block_size, max_mem, name) {
}
const char* get_type() const override

View File

@ -13,7 +13,7 @@
StupidAllocator::StupidAllocator(CephContext* cct,
int64_t capacity,
int64_t _block_size,
const std::string& name)
std::string_view name)
: Allocator(name, capacity, _block_size),
cct(cct), num_free(0),
free(10)

View File

@ -39,7 +39,7 @@ public:
StupidAllocator(CephContext* cct,
int64_t size,
int64_t block_size,
const std::string& name);
std::string_view name);
~StupidAllocator() override;
const char* get_type() const override
{

View File

@ -21,7 +21,7 @@
ZonedAllocator::ZonedAllocator(CephContext* cct,
int64_t size,
int64_t blk_size,
const std::string& name)
std::string_view name)
: Allocator(name, size, blk_size),
cct(cct),
num_free(0),

View File

@ -70,7 +70,7 @@ class ZonedAllocator : public Allocator {
public:
ZonedAllocator(CephContext* cct, int64_t size, int64_t block_size,
const std::string& name);
std::string_view name);
~ZonedAllocator() override;
const char *get_type() const override {

View File

@ -28,7 +28,7 @@ public:
AllocTest(): alloc(0) { }
void init_alloc(int64_t size, uint64_t min_alloc_size) {
std::cout << "Creating alloc type " << string(GetParam()) << " \n";
alloc.reset(Allocator::create(g_ceph_context, string(GetParam()), size,
alloc.reset(Allocator::create(g_ceph_context, GetParam(), size,
min_alloc_size));
}
@ -333,7 +333,7 @@ TEST_P(AllocTest, mempoolAccounting)
uint64_t alloc_size = 4 * 1024;
uint64_t capacity = 512ll * 1024 * 1024 * 1024;
Allocator* alloc = Allocator::create(g_ceph_context, string(GetParam()),
Allocator* alloc = Allocator::create(g_ceph_context, GetParam(),
capacity, alloc_size);
ASSERT_NE(alloc, nullptr);
alloc->init_add_free(0, capacity);

View File

@ -23,7 +23,7 @@ public:
AllocTest(): alloc(0) { }
void init_alloc(int64_t size, uint64_t min_alloc_size) {
std::cout << "Creating alloc type " << string(GetParam()) << " \n";
alloc.reset(Allocator::create(g_ceph_context, string(GetParam()), size,
alloc.reset(Allocator::create(g_ceph_context, GetParam(), size,
min_alloc_size));
}

View File

@ -202,7 +202,7 @@ int replay_and_check_for_duplicate(char* fname)
std::cerr << "error: invalid init: " << s << std::endl;
return -1;
}
alloc.reset(Allocator::create(g_ceph_context, string("bitmap"), total,
alloc.reset(Allocator::create(g_ceph_context, "bitmap", total,
alloc_unit));
owned_by_app.insert(0, total);