]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
*** empty log message ***
authorsage <sage@29311d96-e01e-0410-9327-a35deaab8ce9>
Tue, 14 Jun 2005 17:51:13 +0000 (17:51 +0000)
committersage <sage@29311d96-e01e-0410-9327-a35deaab8ce9>
Tue, 14 Jun 2005 17:51:13 +0000 (17:51 +0000)
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@313 29311d96-e01e-0410-9327-a35deaab8ce9

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

index cc009429e0047ab102f45bc1828152bae96947e7..48c706fb91094bc514e5fd902c473daa54ffa9e1 100644 (file)
@@ -10,27 +10,25 @@ using namespace std;
 
 
 class LRUObject {
- protected:
+ private:
   LRUObject *lru_next, *lru_prev;
   bool lru_in_top;
-  bool lru_in_lru;
+  //bool lru_in_lru;
   bool lru_expireable;
+  class LRU *lru;
 
  public:
   LRUObject() {
        lru_next = lru_prev = NULL;
        lru_in_top = false;
-       lru_in_lru = false;
+       //lru_in_lru = false;
+       lru = 0;
        lru_expireable = true;
   }
 
   // pin/unpin item in cache
-  void lru_pin() {
-       lru_expireable = false;
-  }
-  void lru_unpin() {
-       lru_expireable = true;
-  }
+  void lru_pin(); 
+  void lru_unpin();
 
   friend class LRU;
 };
@@ -40,13 +38,16 @@ class LRUObject {
 class LRU {
  protected:
   LRUObject *lru_tophead, *lru_toptail, *lru_bothead, *lru_bottail;
-  __uint32_t lru_ntop, lru_nbot, lru_num;
+  __uint32_t lru_ntop, lru_nbot, lru_num, lru_num_pinned;
   double lru_midpoint;
   __uint32_t lru_max;   // max items
 
+  friend class LRUObject;
+
  public:
   LRU() {
        lru_ntop = lru_nbot = lru_num = 0;
+       lru_num_pinned = 0;
        lru_tophead = lru_toptail = NULL;
        lru_bothead = lru_bottail = NULL;
        lru_midpoint = .9;
@@ -60,18 +61,22 @@ class LRU {
   __uint32_t lru_get_size() {
        return lru_num;
   }
-
   __uint32_t lru_get_max() {
        return lru_max;
   }
+  __uint32_t lru_get_num_pinned() {
+       return lru_num_pinned;
+  }
   void lru_set_max(__uint32_t m) { lru_max = m; }
   void lru_set_midpoint(float f) { lru_midpoint = f; }
   
 
   // insert at top of lru
   void lru_insert_top(LRUObject *o) {
-       assert(!o->lru_in_lru);
-       o->lru_in_lru = true;
+       //assert(!o->lru_in_lru);
+       //o->lru_in_lru = true;
+       assert(!o->lru);
+       o->lru = this;
 
        o->lru_in_top = true;
        o->lru_next = lru_tophead;
@@ -84,14 +89,16 @@ class LRU {
        lru_tophead = o;
        lru_ntop++;
        lru_num++;
-
+       lru_num_pinned += !o->lru_expireable;
        lru_adjust();
   }
 
   // insert at mid point in lru
   void lru_insert_mid(LRUObject *o) {
-       assert(!o->lru_in_lru);
-       o->lru_in_lru = true;
+       //assert(!o->lru_in_lru);
+       //o->lru_in_lru = true;
+       assert(!o->lru);
+       o->lru = this;
 
        o->lru_in_top = false;
        o->lru_next = lru_bothead;
@@ -104,6 +111,7 @@ class LRU {
        lru_bothead = o;
        lru_nbot++;
        lru_num++;
+       lru_num_pinned += !o->lru_expireable;
   }
 
 
@@ -126,7 +134,9 @@ class LRU {
   LRUObject *lru_remove(LRUObject *o) {
        // not in list
        //assert(o->lru_in_lru);
-       if (!o->lru_in_lru) return o;  // might have expired and been removed that way.
+       //if (!o->lru_in_lru) return o;  // might have expired and been removed that way.
+       if (!o->lru) return o;
+
 
        if (o->lru_in_top) {
          //cout << "removing " << o << " from top" << endl;
@@ -154,8 +164,10 @@ class LRU {
          lru_nbot--;
        }
        lru_num--;
+       lru_num_pinned -= !o->lru_expireable;
        o->lru_next = o->lru_prev = NULL;
-       o->lru_in_lru = false;
+       //o->lru_in_lru = false;
+       o->lru = 0;
        return o;
   }
 
@@ -210,4 +222,14 @@ class LRU {
 };
 
 
+inline void LRUObject::lru_pin() 
+{
+  lru_expireable = false;
+  if (lru) lru->lru_num_pinned++;
+}
+inline void LRUObject::lru_unpin() {
+  lru_expireable = true;
+  if (lru) lru->lru_num_pinned--;
+}
+
 #endif
index 3a840277336e1f29d40eae4a198a48e6adcdcbce..701f9ae197f288c0200b0abc954c7cd9fb22852d 100644 (file)
@@ -64,7 +64,6 @@ CInode::CInode(bool auth) : LRUObject(),
   ref = 0;
   
   parent = NULL;
-  lru_next = lru_prev = NULL;
   
   dir = NULL;     // CDir opened separately
 
index 29e87d7795e626eb610fa80069022e8edab4a2d1..11dea05ebeff1be583bc918c0c45c9f962ee08d8 100644 (file)
@@ -1467,6 +1467,7 @@ void MDCache::request_cleanup(Message *req)
 
   // log some stats *****
   mds->logger->set("c", lru.lru_get_size());
+  mds->logger->set("cpin", lru.lru_get_num_pinned());
   mds->logger->set("cmax", lru.lru_get_max());
 
 
index 9b3b8bb2f467f5c9a7fa7fa9d71a2a983df815c1..6fb7a094acceca7719c52e863f7df8477b38ba55 100644 (file)
@@ -131,6 +131,7 @@ MDS::MDS(MDCluster *mdc, int whoami, Messenger *m) {
   mds_logtype.add_inc("cfw");
 
   mds_logtype.add_set("c");
+  mds_logtype.add_set("cpin");
   mds_logtype.add_set("cmax");
   mds_logtype.add_inc("dis");
   mds_logtype.add_inc("cmiss");