]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
BlueStore/allocator: Give allocator names, so they can be distinguished.
authorAdam Kupczyk <akupczyk@redhat.com>
Fri, 2 Aug 2019 11:53:37 +0000 (13:53 +0200)
committerNeha Ojha <nojha@redhat.com>
Wed, 7 Aug 2019 19:53:19 +0000 (15:53 -0400)
Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
(cherry picked from commit 0d64893c3ebc8a56ceac61596efc6f75ed06fbaf)

src/os/bluestore/Allocator.cc
src/os/bluestore/Allocator.h
src/os/bluestore/BitmapAllocator.cc
src/os/bluestore/BitmapAllocator.h
src/os/bluestore/BlueFS.cc
src/os/bluestore/BlueStore.cc
src/os/bluestore/StupidAllocator.cc
src/os/bluestore/StupidAllocator.h

index 4c140cefd48278bf2d8e459e688796a8c0668eb8..56854a056b8a2be0f0a68c5b950f422589dd5f1e 100644 (file)
@@ -8,17 +8,31 @@
 
 #define dout_subsys ceph_subsys_bluestore
 
+Allocator::Allocator(const std::string& name)
+{
+  asok_hook = new SocketHook(this, name);
+}
+
+
+Allocator::~Allocator()
+{
+}
+
+
 Allocator *Allocator::create(CephContext* cct, string type,
-                             int64_t size, int64_t block_size)
+                             int64_t size, int64_t block_size, const std::string& name)
 {
+  Allocator* alloc = nullptr;
   if (type == "stupid") {
-    return new StupidAllocator(cct);
+    alloc = new StupidAllocator(cct, name);
   } else if (type == "bitmap") {
-    return new BitmapAllocator(cct, size, block_size);
+    alloc = new BitmapAllocator(cct, size, block_size, name);
   }
-  lderr(cct) << "Allocator::" << __func__ << " unknown alloc type "
+  if (alloc == nullptr) {
+    lderr(cct) << "Allocator::" << __func__ << " unknown alloc type "
             << type << dendl;
-  return nullptr;
+  }
+  return alloc;
 }
 
 void Allocator::release(const PExtentVector& release_vec)
index 7425e33629d0eda8dcd7c7a56c286b48a69056a6..1bb95e945df7f4245b7ad564e0d36e43e01870df 100644 (file)
@@ -21,7 +21,8 @@ class FreelistManager;
 
 class Allocator {
 public:
-  virtual ~Allocator() {}
+  explicit Allocator(const std::string& name);
+  virtual ~Allocator();
 
   /*
    * Allocate required number of blocks in n number of extents.
@@ -59,8 +60,9 @@ public:
   }
   virtual double get_fragmentation_score();
   virtual void shutdown() = 0;
+
   static Allocator *create(CephContext* cct, string type, int64_t size,
-                          int64_t block_size);
+                          int64_t block_size, const std::string& name = "");
 };
 
 #endif
index 3e80d0258436d3a25fec18f4911adad1e52da667..80f218489150d1ba150c426dfc3e69c03325a013 100755 (executable)
@@ -10,7 +10,9 @@
 
 BitmapAllocator::BitmapAllocator(CephContext* _cct,
                                         int64_t capacity,
-                                        int64_t alloc_unit) :
+                                        int64_t alloc_unit,
+                                        const std::string& name) :
+    Allocator(name),
     cct(_cct)
 {
   ldout(cct, 10) << __func__ << " 0x" << std::hex << capacity << "/"
index df41c1a958c51040788c0a1fed8abf60b90e4997..ed7f122775fbb486e1a9531aa86b5dff6adf9a95 100755 (executable)
@@ -17,7 +17,7 @@ class BitmapAllocator : public Allocator,
   CephContext* cct;
 
 public:
-  BitmapAllocator(CephContext* _cct, int64_t capacity, int64_t alloc_unit);
+  BitmapAllocator(CephContext* _cct, int64_t capacity, int64_t alloc_unit, const std::string& name);
   ~BitmapAllocator() override
   {
   }
index 9330e27d39646b7927964bdd5cbec0e32e58d2a7..07dcb1b45196775fce53bc77c3883387b1096d78 100644 (file)
@@ -391,9 +391,16 @@ void BlueFS::_init_alloc()
       continue;
     }
     assert(bdev[id]->get_size());
+    ceph_assert(bdev[id]->get_size());
+    std::string name = "bluefs-";
+    const char* devnames[] = {"wal","db","slow"};
+    if (id <= BDEV_SLOW)
+      name += devnames[id];
+    else
+      name += to_string(uintptr_t(this));
     alloc[id] = Allocator::create(cct, cct->_conf->bluefs_allocator,
                                  bdev[id]->get_size(),
-                                 cct->_conf->bluefs_alloc_size);
+                                 cct->_conf->bluefs_alloc_size, name);
     interval_set<uint64_t>& p = block_all[id];
     for (interval_set<uint64_t>::iterator q = p.begin(); q != p.end(); ++q) {
       alloc[id]->init_add_free(q.get_start(), q.get_len());
index ee840c53c65e01594e7cda0b66b3c9676b19c60f..70f4e3c85a67e7a6055e096cc34d09fda86ed067 100644 (file)
@@ -4613,7 +4613,7 @@ int BlueStore::_open_alloc()
   assert(bdev->get_size());
   alloc = Allocator::create(cct, cct->_conf->bluestore_allocator,
                             bdev->get_size(),
-                            min_alloc_size);
+                            min_alloc_size, "block");
   if (!alloc) {
     lderr(cct) << __func__ << " Allocator::unknown alloc type "
                << cct->_conf->bluestore_allocator
index 0f957e4c6d129e2979cc2bf5f72dfdb7f912c87d..3e573f349bc4ed68473f217264a7833c448426b6 100644 (file)
@@ -10,8 +10,8 @@
 #undef dout_prefix
 #define dout_prefix *_dout << "stupidalloc 0x" << this << " "
 
-StupidAllocator::StupidAllocator(CephContext* cct)
-  : cct(cct), num_free(0),
+StupidAllocator::StupidAllocator(CephContext* cct, const std::string& name)
+  : Allocator(name), cct(cct), num_free(0),
     free(10),
     last_alloc(0)
 {
index fb0e2761a0ae2153606cdfb022ed2ada295fb0c7..4cbb3ce75d76553e4ccead075cbf7a505344ee5f 100644 (file)
@@ -34,7 +34,7 @@ class StupidAllocator : public Allocator {
     uint64_t alloc_unit);
 
 public:
-  StupidAllocator(CephContext* cct);
+  StupidAllocator(CephContext* cct, const std::string& name = "");
   ~StupidAllocator() override;
 
   int64_t allocate(