]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
md cache bugs
authorsage <sage@29311d96-e01e-0410-9327-a35deaab8ce9>
Tue, 14 Jun 2005 20:52:15 +0000 (20:52 +0000)
committersage <sage@29311d96-e01e-0410-9327-a35deaab8ce9>
Tue, 14 Jun 2005 20:52:15 +0000 (20:52 +0000)
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@314 29311d96-e01e-0410-9327-a35deaab8ce9

ceph/include/lru.h
ceph/mds/CDir.cc
ceph/mds/CDir.h
ceph/mds/CInode.cc
ceph/mds/CInode.h
ceph/mds/MDCache.cc
ceph/mds/MDCache.h
ceph/mds/MDS.cc
ceph/mds/MDS.h

index 48c706fb91094bc514e5fd902c473daa54ffa9e1..a6b9fce0b94a9196ca7a9abfccbcd7f4b2a35f7c 100644 (file)
@@ -29,8 +29,10 @@ class LRUObject {
   // pin/unpin item in cache
   void lru_pin(); 
   void lru_unpin();
+  bool lru_is_expireable() { return lru_expireable; }
 
   friend class LRU;
+  //friend class MDCache;
 };
 
 
@@ -43,7 +45,7 @@ class LRU {
   __uint32_t lru_max;   // max items
 
   friend class LRUObject;
-
+  //friend class MDCache; // hack
  public:
   LRU() {
        lru_ntop = lru_nbot = lru_num = 0;
index ce4b3009a41b28b7bafac101fe07f47ddf0dab68..c8c8015380269f2023a2d3652e7fe6f389153509 100644 (file)
@@ -14,6 +14,8 @@
 #undef dout
 #define dout(x)  if (x <= g_conf.debug) cout << "mds" << mds->get_nodeid() << "        cdir: "
 
+map<int,int> cdir_pins;
+
 
 ostream& operator<<(ostream& out, CDir& dir)
 {
@@ -569,6 +571,8 @@ void CDir::mark_clean()
 // ref counts
 
 void CDir::put(int by) {
+  cdir_pins[by]--;
+
   // bad?
   if (ref == 0 || ref_set.count(by) != 1) {
        dout(7) << *this << " bad put by " << by << " " << cdir_pin_names[by] << " was " << ref << " (" << ref_set << ")" << endl;
@@ -587,6 +591,8 @@ void CDir::put(int by) {
 }
 
 void CDir::get(int by) {
+  cdir_pins[by]++;
+
   // inode
   if (ref == 0)
        inode->get(CINODE_PIN_DIR);
index d7c5c967332f674c9f42cd319a86584285442f44..29b848f593b284b704fc76c6223f536808841720 100644 (file)
@@ -122,9 +122,9 @@ static char* cdir_pin_names[CDIR_NUM_PINS] = {
   "freeze",
   "proxy",
   "authpin",
-  "importing",
-  "importingexport",
-  "requestpins",
+  "imping",
+  "impgex",
+  "reqpins",
   "dirty"
 };
 
@@ -181,6 +181,10 @@ ostream& operator<<(ostream& out, class CDir& dir);
 // CDir
 typedef map<string, CDentry*> CDir_map_t;
 
+
+extern map<int, int> cdir_pins;  // counts
+
+
 class CDir {
  public:
   CInode          *inode;
index 701f9ae197f288c0200b0abc954c7cd9fb22852d..6d4ac739fbaed20ff20a807b5cc4786c2b95ed46 100644 (file)
@@ -13,6 +13,8 @@
 #define dout(x)  if (x <= g_conf.debug) cout << "cinode: "
 
 
+map<int, int> cinode_pins;  // counts
+
 
 ostream& operator<<(ostream& out, CInode& in)
 {
index 2ed1e3864c1ab6dc174d998a004afdb59e1f133f..ff873723a8e82c30ea6a5709baa187fea871b1f3 100644 (file)
@@ -68,12 +68,12 @@ static char *cinode_pin_names[CINODE_NUM_PINS] = {
   "opentok",
   "dndirty",
   "authpin",
-  "importing",
+  "imping",
   "request",
-  "renamesrc",
-  "archoring",
+  "rensrc",
+  "anching",
   "--",
-  "dentrylock"
+  "dnlock"
 };
 
 
@@ -157,6 +157,9 @@ class CInode;
 ostream& operator<<(ostream& out, CInode& in);
 
 
+extern map<int, int> cinode_pins;  // counts
+
+
 // cached inode wrapper
 class CInode : LRUObject {
  public:
@@ -267,6 +270,7 @@ class CInode : LRUObject {
   void make_anchor_trace(vector<class Anchor*>& trace);
 
 
+
   // -- state --
   unsigned get_state() { return state; }
   void state_clear(unsigned mask) {    state &= ~mask; }
@@ -467,6 +471,7 @@ class CInode : LRUObject {
   bool is_pinned() { return ref > 0; }
   set<int>& get_ref_set() { return ref_set; }
   void put(int by) {
+       cinode_pins[by]--;
        if (ref == 0 || ref_set.count(by) != 1) {
          dout(7) << " bad put " << *this << " by " << by << " " << cinode_pin_names[by] << " was " << ref << " (" << ref_set << ")" << endl;
          assert(ref_set.count(by) == 1);
@@ -479,6 +484,7 @@ class CInode : LRUObject {
        dout(7) << " put " << *this << " by " << by << " " << cinode_pin_names[by] << " now " << ref << " (" << ref_set << ")" << endl;
   }
   void get(int by) {
+       cinode_pins[by]++;
        if (ref == 0)
          lru_pin();
        if (ref_set.count(by)) {
@@ -649,8 +655,9 @@ public:
        in->popularity[MDS_POP_CURDOM].take( st.popularity_curdom );
        in->popularity[MDS_POP_ANYDOM].adjust(now, newcurdom);
 
-       if (st.is_dirty)
+       if (st.is_dirty) {
          in->mark_dirty();
+       }
 
        in->cached_by.clear();
        in->cached_by = cached_by;
index 11dea05ebeff1be583bc918c0c45c9f962ee08d8..3fb20fa5271ab49938e48f7b4a162b44bec87518 100644 (file)
@@ -507,6 +507,28 @@ bool MDCache::trim(__int32_t max) {
        } 
   }
 
+  /* hack
+  if (lru.lru_get_size() == max) {
+       int i;
+       dout(1) << "lru_top " << lru.lru_ntop << "/" << lru.lru_num << endl;
+       CInode *cur = (CInode*)lru.lru_tophead;
+       i = 1;
+       while (cur) {
+         dout(1) << " top " << i++ << "/" << lru.lru_ntop << " " << cur->lru_is_expireable() << "  " << *cur << endl;
+         cur = (CInode*)cur->lru_next;
+       }
+
+       dout(1) << "lru_bot " << lru.lru_nbot << "/" << lru.lru_num << endl;
+       cur = (CInode*)lru.lru_bothead;
+       i = 1;
+       while (cur) {
+         dout(1) << " bot " << i++ << "/" << lru.lru_nbot << " " << cur->lru_is_expireable() << "  " << *cur << endl;
+         cur = (CInode*)cur->lru_next;
+       }
+
+  }
+  */
+
   // send expires
   for (map<int, MCacheExpire*>::iterator it = expiremap.begin();
           it != expiremap.end();
@@ -1083,6 +1105,7 @@ int MDCache::path_traverse(filepath& origpath,
                // keep going.
                trace.push_back(dn);
                cur = dn->inode;
+               touch_inode(cur);
                depth++;
                continue;
          }
@@ -1112,7 +1135,7 @@ int MDCache::path_traverse(filepath& origpath,
                
                // directory isn't complete; reload
                dout(7) << "traverse: incomplete dir contents for " << *cur << ", fetching" << endl;
-               lru.lru_touch(cur);  // touch readdiree
+               touch_inode(cur);
                mds->mdstore->fetch_dir(cur->dir, ondelay);
                
                mds->logger->inc("cmiss");
@@ -1134,7 +1157,7 @@ int MDCache::path_traverse(filepath& origpath,
                } else {
                  dout(7) << "traverse: discover on " << *cur << " for " << want.get_path() << " to mds" << dauth << endl;
                  
-                 lru.lru_touch(cur);  // touch discoveree
+                 touch_inode(cur);
                
                  mds->messenger->send_message(new MDiscover(mds->get_nodeid(),
                                                                                                         cur->ino(),
@@ -1470,6 +1493,28 @@ void MDCache::request_cleanup(Message *req)
   mds->logger->set("cpin", lru.lru_get_num_pinned());
   mds->logger->set("cmax", lru.lru_get_max());
 
+  // pin
+  for (map<int,int>::iterator it = cinode_pins.begin();
+          it != cinode_pins.end();
+          it++) {
+       //string s = "I";
+       //s += cinode_pin_names[it->first];
+       mds->logger2->set(//s, 
+                                         cinode_pin_names[it->first],
+                                         it->second);
+  }
+  /*
+  for (map<int,int>::iterator it = cdir_pins.begin();
+          it != cdir_pins.end();
+          it++) {
+       //string s = "D";
+       //s += cdir_pin_names[it->first];
+       mds->logger2->set(//s, 
+                                         cdir_pin_names[it->first],
+                                         it->second);
+  }
+  */
+
 
 }
 
@@ -6346,10 +6391,17 @@ void MDCache::decode_import_inode(CDentry *dn, crope& r, int& off, int oldauth,
   } else {
        in->set_auth(true);
   }
-  
-  // state
+
+  // link before state
+  if (dn->inode != in) {
+       assert(!dn->inode);
+       dn->dir->link_inode(dn, in);
+  }
+
+  // state after link
   istate.update_inode(in, now);
-  
   // add inode?
   if (added) {
        add_inode(in);
@@ -6358,11 +6410,6 @@ void MDCache::decode_import_inode(CDentry *dn, crope& r, int& off, int oldauth,
        dout(10) << "  had " << *in << endl;
   }
   
-  // link to dentry
-  if (dn->inode != in) {
-       assert(!dn->inode);
-       dn->dir->link_inode(dn, in);
-  }
   
   // cached_by
   assert(!in->is_cached_by(oldauth));
index 367e5e64d29fb071b36fefb2459ac6b1d0960548..873c75ecf3d83c10c9c2675134d55731fb9fa0a2 100644 (file)
@@ -59,6 +59,7 @@ class MUnhashDirAck;
 
 typedef hash_map<inodeno_t, CInode*> inode_map_t;
 
+
 typedef const char* pchar;
 
 /** active_request_t
@@ -171,6 +172,13 @@ class MDCache {
   void remove_inode(CInode *in);
   void destroy_inode(CInode *in);
 
+  void touch_inode(CInode *in) {
+       if (in->is_auth())
+         lru.lru_touch(in);
+       else
+         lru.lru_midtouch(in);
+  }
+
  public:
   void export_empty_import(CDir *dir);
 
index 6fb7a094acceca7719c52e863f7df8477b38ba55..5a06c6559e327ab8a9b038059bc12db17341a293 100644 (file)
@@ -48,7 +48,7 @@
 using namespace std;
 
 
-LogType mds_logtype;
+LogType mds_logtype, mds_cache_logtype;
 
 #include "include/config.h"
 #undef dout
@@ -144,6 +144,10 @@ MDS::MDS(MDCluster *mdc, int whoami, Messenger *m) {
   mds_logtype.add_set("nex");
   mds_logtype.add_set("nim");
 
+  char n[80];
+  sprintf(n, "mds%d.cache", whoami);
+  logger2 = new Logger(n, (LogType*)&mds_cache_logtype);
+  
 
   // alloc
   idalloc = new IdAllocator(this);
index 9a0e879fe12a8b474961bc83be2606e12fb1869c..d98776b643a1a0d980df1e80e82bcf3f8be60c1d 100644 (file)
@@ -132,7 +132,7 @@ class MDS : public Dispatcher {
   MDLog        *mdlog;
   MDBalancer   *balancer;
 
-  Logger       *logger;
+  Logger       *logger, *logger2;
 
  protected:
   __uint64_t   stat_ops;