From 0bc604bf569d2ee83fa8770646d111c5a2436d9f Mon Sep 17 00:00:00 2001 From: liuchang0812 Date: Mon, 13 Feb 2017 14:38:29 +0800 Subject: [PATCH 1/3] cleanup: do not include boost/scoped_ptr.hpp in Allocator.h Signed-off-by: liuchang0812 --- src/os/bluestore/Allocator.h | 1 - src/test/objectstore/Allocator_test.cc | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/os/bluestore/Allocator.h b/src/os/bluestore/Allocator.h index bdbdca40608..aefb867dc3f 100644 --- a/src/os/bluestore/Allocator.h +++ b/src/os/bluestore/Allocator.h @@ -13,7 +13,6 @@ #define CEPH_OS_BLUESTORE_ALLOCATOR_H #include -#include #include "include/assert.h" #include "os/bluestore/bluestore_types.h" diff --git a/src/test/objectstore/Allocator_test.cc b/src/test/objectstore/Allocator_test.cc index f2fea3a175b..3a408265962 100644 --- a/src/test/objectstore/Allocator_test.cc +++ b/src/test/objectstore/Allocator_test.cc @@ -5,6 +5,7 @@ * Author: Ramesh Chander, Ramesh.Chander@sandisk.com */ #include +#include #include #include "common/Mutex.h" From 95c80ed1d5bffe3cd8ee6a6deb8044171167acd6 Mon Sep 17 00:00:00 2001 From: liuchang0812 Date: Mon, 13 Feb 2017 17:59:28 +0800 Subject: [PATCH 2/3] cleanup: use boost::algorithm::ends_with in bluestore Signed-off-by: liuchang0812 --- src/os/bluestore/BlueFS.cc | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/os/bluestore/BlueFS.cc b/src/os/bluestore/BlueFS.cc index 4f80ec464e6..f1928ac0757 100644 --- a/src/os/bluestore/BlueFS.cc +++ b/src/os/bluestore/BlueFS.cc @@ -1,6 +1,7 @@ // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- // vim: ts=8 sw=2 smarttab +#include "boost/algorithm/string.hpp" #include "BlueFS.h" #include "common/debug.h" @@ -8,6 +9,7 @@ #include "common/perf_counters.h" #include "BlockDevice.h" #include "Allocator.h" +#include "include/assert.h" #define dout_context cct #define dout_subsys ceph_subsys_bluefs @@ -1917,9 +1919,9 @@ int BlueFS::open_for_write( // match up with bluestore. the slow device is always the second // one (when a dedicated block.db device is present and used at // bdev 0). the wal device is always last. - if (strcmp(dirname.c_str() + dirname.length() - 5, ".slow") == 0) { + if (boost::algorithm::ends_with(filename, ".slow")) { file->fnode.prefer_bdev = BlueFS::BDEV_SLOW; - } else if (strcmp(dirname.c_str() + dirname.length() - 4, ".wal") == 0) { + } else if (boost::algorithm::ends_with(dirname, ".wal")) { file->fnode.prefer_bdev = BlueFS::BDEV_WAL; } } @@ -1932,12 +1934,12 @@ int BlueFS::open_for_write( *h = _create_writer(file); - if (0 == filename.compare(filename.length() - 4, 4, ".log")) { + if (boost::algorithm::ends_with(filename, ".log")) { (*h)->writer_type = BlueFS::WRITER_WAL; if (logger && !overwrite) { logger->inc(l_bluefs_files_written_wal); } - } else if (0 == filename.compare(filename.length() - 4, 4, ".sst")) { + } else if (boost::algorithm::ends_with(filename, ".sst")) { (*h)->writer_type = BlueFS::WRITER_SST; if (logger) { logger->inc(l_bluefs_files_written_sst); @@ -2177,7 +2179,7 @@ int BlueFS::readdir(const string& dirname, vector *ls) { std::lock_guard l(lock); dout(10) << __func__ << " " << dirname << dendl; - if (dirname.size() == 0) { + if (dirname.empty()) { // list dirs ls->reserve(dir_map.size() + 2); for (auto& q : dir_map) { From b893123e071340e6e877905bb6a462edb0bc355d Mon Sep 17 00:00:00 2001 From: liuchang0812 Date: Mon, 13 Feb 2017 21:05:41 +0800 Subject: [PATCH 3/3] cleanup: add override for bluestore Signed-off-by: liuchang0812 --- src/os/bluestore/BitMapAllocator.h | 16 ++++++++-------- src/os/bluestore/StupidAllocator.h | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/os/bluestore/BitMapAllocator.h b/src/os/bluestore/BitMapAllocator.h index e5b9ca6d6f0..b2134d06b33 100644 --- a/src/os/bluestore/BitMapAllocator.h +++ b/src/os/bluestore/BitMapAllocator.h @@ -29,24 +29,24 @@ public: BitMapAllocator(CephContext* cct, int64_t device_size, int64_t block_size); ~BitMapAllocator(); - int reserve(uint64_t need); - void unreserve(uint64_t unused); + int reserve(uint64_t need) override; + void unreserve(uint64_t unused) override; int64_t allocate( uint64_t want_size, uint64_t alloc_unit, uint64_t max_alloc_size, - int64_t hint, mempool::bluestore_alloc::vector *extents); + int64_t hint, mempool::bluestore_alloc::vector *extents) override; int release( - uint64_t offset, uint64_t length); + uint64_t offset, uint64_t length) override; - uint64_t get_free(); + uint64_t get_free() override; void dump() override; - void init_add_free(uint64_t offset, uint64_t length); - void init_rm_free(uint64_t offset, uint64_t length); + void init_add_free(uint64_t offset, uint64_t length) override; + void init_rm_free(uint64_t offset, uint64_t length) override; - void shutdown(); + void shutdown() override; }; #endif diff --git a/src/os/bluestore/StupidAllocator.h b/src/os/bluestore/StupidAllocator.h index ce8101a552d..a051bd0efff 100644 --- a/src/os/bluestore/StupidAllocator.h +++ b/src/os/bluestore/StupidAllocator.h @@ -28,28 +28,28 @@ public: StupidAllocator(CephContext* cct); ~StupidAllocator(); - int reserve(uint64_t need); - void unreserve(uint64_t unused); + int reserve(uint64_t need) override; + void unreserve(uint64_t unused) override; int64_t allocate( uint64_t want_size, uint64_t alloc_unit, uint64_t max_alloc_size, - int64_t hint, mempool::bluestore_alloc::vector *extents); + int64_t hint, mempool::bluestore_alloc::vector *extents) override; int64_t allocate_int( uint64_t want_size, uint64_t alloc_unit, int64_t hint, uint64_t *offset, uint32_t *length); int release( - uint64_t offset, uint64_t length); + uint64_t offset, uint64_t length) override; - uint64_t get_free(); + uint64_t get_free() override; void dump() override; - void init_add_free(uint64_t offset, uint64_t length); - void init_rm_free(uint64_t offset, uint64_t length); + void init_add_free(uint64_t offset, uint64_t length) override; + void init_rm_free(uint64_t offset, uint64_t length) override; - void shutdown(); + void shutdown() override; }; #endif