]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/bluestore/BlueFS: add some perfcounters
authorSage Weil <sage@redhat.com>
Mon, 4 Apr 2016 18:56:13 +0000 (14:56 -0400)
committerSage Weil <sage@redhat.com>
Tue, 5 Apr 2016 15:19:04 +0000 (11:19 -0400)
Most utilization-related.

Signed-off-by: Sage Weil <sage@redhat.com>
src/os/bluestore/BlueFS.cc
src/os/bluestore/BlueFS.h

index d2c8c175bc5db339d2af771ccce15a3da76de528..41ae52a4d2c71e81eaea154a7c951933cc04e2b1 100644 (file)
@@ -5,6 +5,7 @@
 
 #include "common/debug.h"
 #include "common/errno.h"
+#include "common/perf_counters.h"
 #include "BlockDevice.h"
 #include "Allocator.h"
 #include "StupidAllocator.h"
@@ -15,7 +16,8 @@
 #define dout_prefix *_dout << "bluefs "
 
 BlueFS::BlueFS()
-  : ino_last(0),
+  : logger(NULL),
+    ino_last(0),
     log_seq(0),
     log_writer(NULL),
     bdev(MAX_BDEV),
@@ -38,6 +40,52 @@ BlueFS::~BlueFS()
   }
 }
 
+void BlueFS::_init_logger()
+{
+  PerfCountersBuilder b(g_ceph_context, "BlueFS",
+                        l_bluefs_first, l_bluefs_last);
+  b.add_u64_counter(l_bluefs_gift_bytes, "gift_bytes", "Bytes gifted from BlueStore");
+  b.add_u64_counter(l_bluefs_reclaim_bytes, "reclaim_bytes", "Bytes reclaimed by BlueStore");
+  b.add_u64(l_bluefs_db_total_bytes, "db_total_bytes", "Total bytes (main db device)");
+  b.add_u64(l_bluefs_db_free_bytes, "db_free_bytes", "Free bytes (main db device)");
+  b.add_u64(l_bluefs_wal_total_bytes, "wal_total_bytes", "Total bytes (wal device)");
+  b.add_u64(l_bluefs_wal_free_bytes, "wal_free_bytes", "Free bytes (wal device)");
+  b.add_u64(l_bluefs_slow_total_bytes, "slow_total_bytes", "Total bytes (slow device)");
+  b.add_u64(l_bluefs_slow_free_bytes, "slow_free_bytes", "Free bytes (slow device)");
+  b.add_u64(l_bluefs_num_files, "num_files", "File count");
+  b.add_u64(l_bluefs_log_bytes, "log_bytes", "Size of the metadata log");
+  b.add_u64_counter(l_bluefs_log_compactions, "log_compactions", "Compactions of the metadata log");
+  b.add_u64_counter(l_bluefs_logged_bytes, "logged_bytes", "Bytes written to the metadata log");
+  logger = b.create_perf_counters();
+  g_ceph_context->get_perfcounters_collection()->add(logger);
+}
+
+void BlueFS::_shutdown_logger()
+{
+  g_ceph_context->get_perfcounters_collection()->remove(logger);
+  delete logger;
+}
+
+void BlueFS::_update_logger_stats()
+{
+  // we must be holding the lock
+  logger->set(l_bluefs_num_files, file_map.size());
+  logger->set(l_bluefs_log_bytes, log_writer->file->fnode.size);
+
+  if (alloc[BDEV_WAL]) {
+    logger->set(l_bluefs_wal_total_bytes, block_total[BDEV_WAL]);
+    logger->set(l_bluefs_wal_free_bytes, alloc[BDEV_WAL]->get_free());
+  }
+  if (alloc[BDEV_DB]) {
+    logger->set(l_bluefs_db_total_bytes, block_total[BDEV_DB]);
+    logger->set(l_bluefs_db_free_bytes, alloc[BDEV_DB]->get_free());
+  }
+  if (alloc[BDEV_SLOW]) {
+    logger->set(l_bluefs_slow_total_bytes, block_total[BDEV_SLOW]);
+    logger->set(l_bluefs_slow_free_bytes, alloc[BDEV_SLOW]->get_free());
+  }
+}
+
 /*static void aio_cb(void *priv, void *priv2)
 {
   BlueFS *fs = static_cast<BlueFS*>(priv);
@@ -87,6 +135,9 @@ void BlueFS::add_block_extent(unsigned id, uint64_t offset, uint64_t length)
     assert(r == 0);
     alloc[id]->init_add_free(offset, length);
   }
+
+  if (logger)
+    logger->inc(l_bluefs_gift_bytes, length);
   dout(10) << __func__ << " done" << dendl;
 }
 
@@ -112,6 +163,8 @@ int BlueFS::reclaim_blocks(unsigned id, uint64_t want,
   r = _flush_log();
   assert(r == 0);
 
+  if (logger)
+    logger->inc(l_bluefs_reclaim_bytes, *length);
   dout(1) << __func__ << " bdev " << id << " want " << want
          << " got " << *offset << "~" << *length << dendl;
   return 0;
@@ -171,6 +224,7 @@ int BlueFS::mkfs(uuid_d osd_uuid)
          << dendl;
 
   _init_alloc();
+  _init_logger();
 
   super.version = 1;
   super.block_size = bdev[BDEV_DB]->get_block_size();
@@ -215,6 +269,7 @@ int BlueFS::mkfs(uuid_d osd_uuid)
   block_all.clear();
   block_total.clear();
   _stop_alloc();
+  _shutdown_logger();
 
   dout(10) << __func__ << " success" << dendl;
   return 0;
@@ -280,6 +335,8 @@ int BlueFS::mount()
   assert(log_writer->file->fnode.ino == 1);
   log_writer->pos = log_writer->file->fnode.size;
   dout(10) << __func__ << " log write pos set to " << log_writer->pos << dendl;
+
+  _init_logger();
   return 0;
 
  out:
@@ -301,6 +358,7 @@ void BlueFS::umount()
   dir_map.clear();
   super = bluefs_super_t();
   log_t.clear();
+  _shutdown_logger();
 }
 
 int BlueFS::fsck()
@@ -898,6 +956,8 @@ void BlueFS::_compact_log()
   for (auto& r : old_extents) {
     alloc[r.bdev]->release(r.offset, r.length);
   }
+
+  logger->inc(l_bluefs_log_compactions);
 }
 
 void BlueFS::_pad_bl(bufferlist& bl)
@@ -936,6 +996,8 @@ int BlueFS::_flush_log()
   _pad_bl(bl);
   log_writer->append(bl);
 
+  logger->inc(l_bluefs_logged_bytes, bl.length());
+
   log_t.clear();
   log_t.seq = 0;  // just so debug output is less confusing
 
@@ -955,6 +1017,8 @@ int BlueFS::_flush_log()
     dirty_files.erase(p++);
   }
 
+  _update_logger_stats();
+
   return 0;
 }
 
index 1785e1a7bf147ba82048ba7acdd0013c4291aa58..0f9ce7e72ccccaffc762cc045b92186b1f49d105 100644 (file)
 #include "boost/intrusive/list.hpp"
 #include <boost/intrusive_ptr.hpp>
 
+class PerfCounters;
+
 class Allocator;
 
+enum {
+  l_bluefs_first = 732600,
+  l_bluefs_gift_bytes,
+  l_bluefs_reclaim_bytes,
+  l_bluefs_db_total_bytes,
+  l_bluefs_db_free_bytes,
+  l_bluefs_wal_total_bytes,
+  l_bluefs_wal_free_bytes,
+  l_bluefs_slow_total_bytes,
+  l_bluefs_slow_free_bytes,
+  l_bluefs_num_files,
+  l_bluefs_log_bytes,
+  l_bluefs_log_compactions,
+  l_bluefs_logged_bytes,
+  l_bluefs_last,
+};
+
 class BlueFS {
 public:
   static constexpr unsigned MAX_BDEV = 3;
@@ -161,6 +180,8 @@ public:
 private:
   std::mutex lock;
 
+  PerfCounters *logger;
+
   // cache
   map<string, DirRef> dir_map;                    ///< dirname -> Dir
   ceph::unordered_map<uint64_t,FileRef> file_map; ///< ino -> File
@@ -185,6 +206,10 @@ private:
   vector<uint64_t> block_total;               ///< sum of block_all
   vector<Allocator*> alloc;                   ///< allocators for bdevs
 
+  void _init_logger();
+  void _shutdown_logger();
+  void _update_logger_stats();
+
   void _init_alloc();
   void _stop_alloc();