]> git.apps.os.sepia.ceph.com Git - ceph-ci.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)
committerAdam Kupczyk <akupczyk@redhat.com>
Fri, 2 Aug 2019 11:56:22 +0000 (13:56 +0200)
Signed-off-by: Adam Kupczyk <akupczyk@redhat.com>
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 00fdf0394b98e86423541226132409a0805eb791..6877a3bbce7d95cee734c0d58a23b7fa43e2cc15 100644 (file)
@@ -19,7 +19,8 @@
 
 class Allocator {
 public:
-  virtual ~Allocator() {}
+  explicit Allocator(const std::string& name);
+  virtual ~Allocator();
 
   /*
    * Allocate required number of blocks in n number of extents.
@@ -57,8 +58,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 367108c588084fef425615cd43f1adab976a2b9a..c24a333aae3168ef20200bf17b154851f2fb54a9 100644 (file)
@@ -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 100644 (file)
@@ -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 b9c529641bdd3e35d5148638ef44ac8e39c02a6c..e5d9174730c3bdcb4b256915842692c1a9444082 100644 (file)
@@ -441,9 +441,15 @@ void BlueFS::_init_alloc()
       continue;
     }
     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 52ebc5004f6ef6b9bbc906840979cd222cdd0fe1..305ea68818789011d3f30d58111327c569748e71 100644 (file)
@@ -4841,7 +4841,7 @@ int BlueStore::_open_alloc()
 
   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 289e17362806cab4ef2e23f159804510a306769e..c80c855ad40e43b504590eab79e18baebb3bcaf5 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 d603b47173ebed41cb07346ba3b198c57184aafd..23264757c3fd5f7e0d035d44f8b0604628cb6289 100644 (file)
@@ -35,7 +35,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(