]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds/MDCache: stray/purge perfcounters
authorJohn Spray <john.spray@redhat.com>
Mon, 19 Jan 2015 12:16:59 +0000 (12:16 +0000)
committerJohn Spray <john.spray@redhat.com>
Mon, 19 Jan 2015 13:06:45 +0000 (13:06 +0000)
Fixes: #10388
Signed-off-by: John Spray <john.spray@redhat.com>
src/mds/MDCache.cc
src/mds/MDCache.h
src/mds/MDS.cc
src/mds/MDS.h

index 4ec067240e3d9f08d823452eae748962d05c2835..3f7bf665d502872c89769db626909e81e5318dba 100644 (file)
@@ -167,6 +167,9 @@ public:
 
 
 MDCache::MDCache(MDS *m) :
+  num_strays(0),
+  num_strays_purging(0),
+  num_strays_delayed(0),
   recovery_queue(m),
   delayed_eval_stray(member_offset(CDentry, item_stray))
 {
@@ -710,8 +713,13 @@ CDentry *MDCache::get_or_create_stray_dentry(CInode *in)
   if (!straydn) {
     straydn = straydir->add_null_dentry(straydname);
     straydn->mark_new();
-  } else 
+
+    num_strays++;
+    logger->set(l_mdc_num_strays, num_strays);
+    logger->inc(l_mdc_strays_created);
+  } else {
     assert(straydn->get_projected_linkage()->is_null());
+  }
 
   straydn->state_set(CDentry::STATE_STRAY);
   return straydn;
@@ -6060,8 +6068,10 @@ bool MDCache::trim(int max, int count)
     CDentry *dn = *p;
     ++p;
     dn->item_stray.remove_myself();
+    num_strays_delayed--;
     eval_stray(dn);
   }
+  logger->set(l_mdc_num_strays_delayed, num_strays_delayed);
 
   map<mds_rank_t, MCacheExpire*> expiremap;
   bool is_standby_replay = mds->is_standby_replay();
@@ -8877,6 +8887,7 @@ void MDCache::scan_stray_dir(dirfrag_t next)
     for (CDir::map_t::iterator q = dir->items.begin(); q != dir->items.end(); ++q) {
       CDentry *dn = q->second;
       CDentry::linkage_t *dnl = dn->get_projected_linkage();
+      num_strays++;
       if (dnl->is_primary())
        maybe_eval_stray(dnl->get_inode());
     }
@@ -8952,8 +8963,11 @@ void MDCache::eval_stray(CDentry *dn, bool delay)
       return;
     }
     if (delay) {
-      if (!dn->item_stray.is_on_list())
+      if (!dn->item_stray.is_on_list()) {
        delayed_eval_stray.push_back(&dn->item_stray);
+       num_strays_delayed++;
+       logger->set(l_mdc_num_strays_delayed, num_strays_delayed);
+      }
     } else {
       if (in->is_dir())
        in->close_dirfrags();
@@ -9036,8 +9050,14 @@ void MDCache::purge_stray(CDentry *dn)
   dn->get(CDentry::PIN_PURGING);
   in->state_set(CInode::STATE_PURGING);
 
-  if (dn->item_stray.is_on_list())
+  num_strays_purging++;
+  logger->set(l_mdc_num_strays_purging, num_strays_purging);
+
+  if (dn->item_stray.is_on_list()) {
     dn->item_stray.remove_myself();
+    num_strays_delayed--;
+    logger->set(l_mdc_num_strays_delayed, num_strays_delayed);
+  }
 
   if (in->is_dirty_parent())
     in->clear_dirty_parent();
@@ -9177,6 +9197,12 @@ void MDCache::_purge_stray_purged(CDentry *dn, int r)
     le->metablob.add_destroyed_inode(in->ino());
 
     mds->mdlog->submit_entry(le, new C_MDC_PurgeStrayLogged(this, dn, pdv, mds->mdlog->get_current_segment()));
+
+    num_strays_purging--;
+    num_strays--;
+    logger->set(l_mdc_num_strays, num_strays);
+    logger->set(l_mdc_num_strays_purging, num_strays_purging);
+    logger->inc(l_mdc_strays_purged);
   } else {
     // new refs.. just truncate to 0
     EUpdate *le = new EUpdate(mds->mdlog, "purge_stray truncate");
@@ -11709,3 +11735,25 @@ void MDCache::flush_dentry_work(MDRequestRef& mdr)
     return;
   in->flush(new C_FinishIOMDR(mds, mdr));
 }
+
+
+/**
+ * Initialize performance counters with global perfcounter
+ * collection.
+ */
+void MDCache::register_perfcounters()
+{
+    PerfCountersBuilder pcb(g_ceph_context,
+            "mds_cache", l_mdc_first, l_mdc_last);
+
+    /* Stray/purge statistics */
+    pcb.add_u64(l_mdc_num_strays, "num_strays");
+    pcb.add_u64(l_mdc_num_strays_purging, "num_strays_purging");
+    pcb.add_u64(l_mdc_num_strays_delayed, "num_strays_delayed");
+    pcb.add_u64_counter(l_mdc_strays_created, "strays_created");
+    pcb.add_u64_counter(l_mdc_strays_purged, "strays_purged");
+
+    logger = pcb.create_perf_counters();
+    g_ceph_context->get_perfcounters_collection()->add(logger);
+}
+
index 8cf8c7a49de09dc17785d5d40d9b67887c3e2210..3dba221f61513d34c5a805a2ea52aaf70edf04ea 100644 (file)
@@ -72,6 +72,21 @@ struct MDRequestImpl;
 typedef ceph::shared_ptr<MDRequestImpl> MDRequestRef;
 struct MDSlaveUpdate;
 
+enum {
+  l_mdc_first = 3000,
+  // How many dentries are currently in stray dirs
+  l_mdc_num_strays,
+  // How many stray dentries are currently being purged
+  l_mdc_num_strays_purging,
+  // How many stray dentries are currently delayed for purge due to refs
+  l_mdc_num_strays_delayed,
+  // How many dentries have ever been added to stray dir
+  l_mdc_strays_created,
+  // How many dentries have ever finished purging from stray dir
+  l_mdc_strays_purged,
+  l_mdc_last,
+};
+
 
 // flags for predirty_journal_parents()
 static const int PREDIRTY_PRIMARY = 1; // primary dn, adjust nested accounting
@@ -102,6 +117,8 @@ class MDCache {
 
   set<CInode*> base_inodes;
 
+  PerfCounters *logger;
+
 public:
   void advance_stray() {
     stray_index = (stray_index+1)%NUM_STRAY;
@@ -114,11 +131,17 @@ public:
   int num_inodes_with_caps;
   int num_caps;
 
+  uint64_t num_strays;
+  uint64_t num_strays_purging;
+  uint64_t num_strays_delayed;
+
   unsigned max_dir_commit_size;
 
   ceph_file_layout default_file_layout;
   ceph_file_layout default_log_layout;
 
+  void register_perfcounters();
+
   // -- client leases --
 public:
   static const int client_lease_pools = 3;
index 387eda18ffa34bfb7b72bdcc2f7ba315d31adbd5..a22c585f8f58bfc4dbf8dd6c0c7d55b945b71dff 100644 (file)
@@ -704,6 +704,7 @@ void MDS::create_logger()
 
   mdlog->create_logger();
   server->create_logger();
+  mdcache->register_perfcounters();
 }
 
 
index 73654f4fc2f948539a946b951da641539613e37f..0b3e62333fa8f16fc22e2dee179446c98a796592 100644 (file)
@@ -76,11 +76,6 @@ enum {
   l_mds_last,
 };
 
-enum {
-  l_mdc_first = 3000,
-  l_mdc_last,
-};
-
 // memory utilization
 enum {
   l_mdm_first = 2500,