From: sage Date: Tue, 14 Jun 2005 20:52:15 +0000 (+0000) Subject: md cache bugs X-Git-Tag: v0.1~2067 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f69665c10a75eb0002d2d5a571a388abd54364f8;p=ceph.git md cache bugs git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@314 29311d96-e01e-0410-9327-a35deaab8ce9 --- diff --git a/ceph/include/lru.h b/ceph/include/lru.h index 48c706fb910..a6b9fce0b94 100644 --- a/ceph/include/lru.h +++ b/ceph/include/lru.h @@ -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; diff --git a/ceph/mds/CDir.cc b/ceph/mds/CDir.cc index ce4b3009a41..c8c80153802 100644 --- a/ceph/mds/CDir.cc +++ b/ceph/mds/CDir.cc @@ -14,6 +14,8 @@ #undef dout #define dout(x) if (x <= g_conf.debug) cout << "mds" << mds->get_nodeid() << " cdir: " +map 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); diff --git a/ceph/mds/CDir.h b/ceph/mds/CDir.h index d7c5c967332..29b848f593b 100644 --- a/ceph/mds/CDir.h +++ b/ceph/mds/CDir.h @@ -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 CDir_map_t; + +extern map cdir_pins; // counts + + class CDir { public: CInode *inode; diff --git a/ceph/mds/CInode.cc b/ceph/mds/CInode.cc index 701f9ae197f..6d4ac739fba 100644 --- a/ceph/mds/CInode.cc +++ b/ceph/mds/CInode.cc @@ -13,6 +13,8 @@ #define dout(x) if (x <= g_conf.debug) cout << "cinode: " +map cinode_pins; // counts + ostream& operator<<(ostream& out, CInode& in) { diff --git a/ceph/mds/CInode.h b/ceph/mds/CInode.h index 2ed1e3864c1..ff873723a8e 100644 --- a/ceph/mds/CInode.h +++ b/ceph/mds/CInode.h @@ -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 cinode_pins; // counts + + // cached inode wrapper class CInode : LRUObject { public: @@ -267,6 +270,7 @@ class CInode : LRUObject { void make_anchor_trace(vector& 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& 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; diff --git a/ceph/mds/MDCache.cc b/ceph/mds/MDCache.cc index 11dea05ebef..3fb20fa5271 100644 --- a/ceph/mds/MDCache.cc +++ b/ceph/mds/MDCache.cc @@ -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::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::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::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)); diff --git a/ceph/mds/MDCache.h b/ceph/mds/MDCache.h index 367e5e64d29..873c75ecf3d 100644 --- a/ceph/mds/MDCache.h +++ b/ceph/mds/MDCache.h @@ -59,6 +59,7 @@ class MUnhashDirAck; typedef hash_map 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); diff --git a/ceph/mds/MDS.cc b/ceph/mds/MDS.cc index 6fb7a094acc..5a06c6559e3 100644 --- a/ceph/mds/MDS.cc +++ b/ceph/mds/MDS.cc @@ -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); diff --git a/ceph/mds/MDS.h b/ceph/mds/MDS.h index 9a0e879fe12..d98776b643a 100644 --- a/ceph/mds/MDS.h +++ b/ceph/mds/MDS.h @@ -132,7 +132,7 @@ class MDS : public Dispatcher { MDLog *mdlog; MDBalancer *balancer; - Logger *logger; + Logger *logger, *logger2; protected: __uint64_t stat_ops;