From 7e1717c93e259bd64133d1ac80e240747bc6386b Mon Sep 17 00:00:00 2001 From: sage Date: Tue, 14 Jun 2005 06:29:03 +0000 Subject: [PATCH] memory leaks, etc. git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@309 29311d96-e01e-0410-9327-a35deaab8ce9 --- ceph/client/Client.cc | 4 ++ ceph/common/DecayCounter.h | 4 ++ ceph/common/Logger.cc | 6 ++- ceph/common/Logger.h | 1 + ceph/config.cc | 3 +- ceph/fakesyn.cc | 10 ++--- ceph/include/buffer.h | 2 +- ceph/mds/CDir.h | 5 ++- ceph/mds/CInode.h | 6 ++- ceph/mds/LogEvent.h | 15 ++++--- ceph/mds/LogStream.cc | 10 ++--- ceph/mds/MDBalancer.cc | 37 +++++++++++------ ceph/mds/MDCache.cc | 80 ++++++++++++++++++++++++------------ ceph/mds/MDCache.h | 23 ++++++----- ceph/mds/MDLog.cc | 2 + ceph/mds/MDS.cc | 14 +++++-- ceph/mds/MDStore.cc | 2 +- ceph/mds/events/EAlloc.h | 16 ++++---- ceph/msg/CheesySerializer.cc | 6 +-- ceph/msg/HostMonitor.cc | 5 ++- ceph/osd/FakeStore.cc | 12 +++--- ceph/osd/OSD.cc | 9 +++- ceph/osd/OSDMap.h | 3 ++ ceph/osdc/Filer.cc | 4 +- 24 files changed, 178 insertions(+), 101 deletions(-) diff --git a/ceph/client/Client.cc b/ceph/client/Client.cc index 0645fca921254..c67d7b8f2a0c7 100644 --- a/ceph/client/Client.cc +++ b/ceph/client/Client.cc @@ -396,6 +396,8 @@ int Client::mount(int mkfs) dout(1) << "mounted" << endl; mounted = true; + delete reply; + client_lock.Unlock(); } @@ -414,6 +416,8 @@ int Client::unmount() mounted = false; dout(1) << "unmounted" << endl; + delete reply; + client_lock.Unlock(); } diff --git a/ceph/common/DecayCounter.h b/ceph/common/DecayCounter.h index e5cb69ee6938c..183a1148c2825 100644 --- a/ceph/common/DecayCounter.h +++ b/ceph/common/DecayCounter.h @@ -29,6 +29,10 @@ class DecayCounter { decay(now); val += a; } + void adjust_down(const DecayCounter& other) { + // assume other has same time stamp as us... + val -= other.val; + } void set_halflife(double hl) { half_life = hl; diff --git a/ceph/common/Logger.cc b/ceph/common/Logger.cc index 1e1749ca3d4a2..eb24fe9f5b369 100644 --- a/ceph/common/Logger.cc +++ b/ceph/common/Logger.cc @@ -25,6 +25,7 @@ Logger::Logger(string fn, LogType *type) wrote_header = -1; open = false; this->type = type; + wrote_header_last = 0; } Logger::~Logger() @@ -91,13 +92,16 @@ void Logger::flush(bool force) } // header? - if (wrote_header != type->version) { + wrote_header_last++; + if (wrote_header != type->version || + wrote_header_last > 10) { out << "#"; for (vector::iterator it = type->keys.begin(); it != type->keys.end(); it++) { out << "\t" << *it; } out << endl; wrote_header = type->version; + wrote_header_last = 0; } // write line to log diff --git a/ceph/common/Logger.h b/ceph/common/Logger.h index b2b9d81501810..9ed0a81e0eaaa 100644 --- a/ceph/common/Logger.h +++ b/ceph/common/Logger.h @@ -21,6 +21,7 @@ class Logger { int last_logged; int interval; int wrote_header; + int wrote_header_last; string filename; diff --git a/ceph/config.cc b/ceph/config.cc index ab98f9a891a44..1ab8d99ea138d 100644 --- a/ceph/config.cc +++ b/ceph/config.cc @@ -136,15 +136,16 @@ void parse_config_options(int argc, char **argv, g_conf.mds_log_read_inc = atoi(argv[++i]); else if (strcmp(argv[i], "--mds_log_max_trimming") == 0) g_conf.mds_log_max_trimming = atoi(argv[++i]); + else if (strcmp(argv[i], "--mds_commit_on_shutdown") == 0) g_conf.mds_commit_on_shutdown = atoi(argv[++i]); else if (strcmp(argv[i], "--mds_log_flush_on_shutdown") == 0) g_conf.mds_log_flush_on_shutdown = atoi(argv[++i]); + else if (strcmp(argv[i], "--mds_bal_interval") == 0) g_conf.mds_bal_interval = atoi(argv[++i]); - else if (strcmp(argv[i], "--osd_fsync") == 0) g_conf.osd_fsync = atoi(argv[++i]); diff --git a/ceph/fakesyn.cc b/ceph/fakesyn.cc index e7e05094ac872..1683192854c80 100644 --- a/ceph/fakesyn.cc +++ b/ceph/fakesyn.cc @@ -88,8 +88,6 @@ int main(int oargc, char **oargv) { } } - fakemessenger_startthread(); - MDCluster *mdc = new MDCluster(NUMMDS, NUMOSD); @@ -141,10 +139,10 @@ int main(int oargc, char **oargv) { client[i]->init(); // use my argc, argv (make sure you pass a mount point!) - cout << "mounting" << endl; + //cout << "mounting" << endl; client[i]->mount(mkfs); - cout << "starting synthetic client " << endl; + //cout << "starting synthetic client " << endl; syn[i] = new SyntheticClient(client[i]); char s[20]; @@ -160,12 +158,12 @@ int main(int oargc, char **oargv) { } for (int i=0; ijoin_thread(); delete syn[i]; client[i]->unmount(); - cout << "unmounted" << endl; + //cout << "unmounted" << endl; client[i]->shutdown(); } diff --git a/ceph/include/buffer.h b/ceph/include/buffer.h index f2a3f9028551d..fdbac01e0acb5 100644 --- a/ceph/include/buffer.h +++ b/ceph/include/buffer.h @@ -221,7 +221,7 @@ class bufferptr { inline ostream& operator<<(ostream& out, bufferptr& bp) { return out << "bufferptr(len=" << bp._len << ", off=" << bp._off - //<< ", " << bp.c_str() + << ", int=" << *(int*)(bp.c_str()) << ", " << *bp._buffer << ")"; } diff --git a/ceph/mds/CDir.h b/ceph/mds/CDir.h index 35c8d21eaef1e..d7c5c967332f6 100644 --- a/ceph/mds/CDir.h +++ b/ceph/mds/CDir.h @@ -610,6 +610,7 @@ class CDirExport { st.popularity_justme.take( dir->popularity[MDS_POP_JUSTME] ); st.popularity_curdom.take( dir->popularity[MDS_POP_CURDOM] ); + dir->popularity[MDS_POP_ANYDOM].adjust_down(st.popularity_curdom); rep_by = dir->dir_rep_by; open_by = dir->open_by; @@ -619,7 +620,7 @@ class CDirExport { inodeno_t get_ino() { return st.ino; } __uint64_t get_nden() { return st.nden; } - void update_dir(CDir *dir) { + void update_dir(CDir *dir, timepair_t& now) { assert(dir->ino() == st.ino); //dir->nitems = st.nitems; @@ -629,8 +630,10 @@ class CDirExport { dir->dir_auth = st.dir_auth; dir->dir_rep = st.dir_rep; + double newcurdom = st.popularity_curdom.get(now) - dir->popularity[MDS_POP_CURDOM].get(now); dir->popularity[MDS_POP_JUSTME].take( st.popularity_justme ); dir->popularity[MDS_POP_CURDOM].take( st.popularity_curdom ); + dir->popularity[MDS_POP_ANYDOM].adjust(now, newcurdom); dir->dir_rep_by = rep_by; dir->open_by = open_by; diff --git a/ceph/mds/CInode.h b/ceph/mds/CInode.h index c440078f34f50..2ed1e3864c1ab 100644 --- a/ceph/mds/CInode.h +++ b/ceph/mds/CInode.h @@ -618,6 +618,7 @@ public: st.popularity_justme.take( in->popularity[MDS_POP_JUSTME] ); st.popularity_curdom.take( in->popularity[MDS_POP_CURDOM] ); + in->popularity[MDS_POP_ANYDOM].adjust_down(st.popularity_curdom); // suck up fh's from inode for (map::iterator it = in->fh_map.begin(); @@ -638,12 +639,15 @@ public: inodeno_t get_ino() { return st.inode.ino; } - int update_inode(CInode *in) { + int update_inode(CInode *in, timepair_t& now) { in->inode = st.inode; in->version = st.version; + + double newcurdom = st.popularity_curdom.get(now) - in->popularity[MDS_POP_CURDOM].get(now); in->popularity[MDS_POP_JUSTME].take( st.popularity_justme ); in->popularity[MDS_POP_CURDOM].take( st.popularity_curdom ); + in->popularity[MDS_POP_ANYDOM].adjust(now, newcurdom); if (st.is_dirty) in->mark_dirty(); diff --git a/ceph/mds/LogEvent.h b/ceph/mds/LogEvent.h index b2ad458e8ec58..fe4173e8a021d 100644 --- a/ceph/mds/LogEvent.h +++ b/ceph/mds/LogEvent.h @@ -14,27 +14,26 @@ using namespace std; // generic log event class LogEvent { - protected: - int type; + private: + int _type; public: - LogEvent(int t) { - type = t; - } + LogEvent(int t) : _type(t) { } - int get_type() { return type; } + int get_type() { return _type; } virtual void encode_payload(bufferlist& bl) = 0; virtual void decode_payload(bufferlist& bl, int& off) = 0; void encode(bufferlist& bl) { // type - bl.append((char*)&type, sizeof(type)); + assert(_type > 0); + bl.append((char*)&_type, sizeof(_type)); // len placeholder int len = 0; // we don't know just yet... int off = bl.length(); - bl.append((char*)&type, sizeof(len)); + bl.append((char*)&len, sizeof(len)); // payload encode_payload(bl); diff --git a/ceph/mds/LogStream.cc b/ceph/mds/LogStream.cc index 306597b92f4c4..55e1b6989189b 100644 --- a/ceph/mds/LogStream.cc +++ b/ceph/mds/LogStream.cc @@ -43,20 +43,20 @@ off_t LogStream::append(LogEvent *e) size_t elen = bl.length(); // append - dout(10) << "append event type " << e->get_type() << " size " << elen << " at log offset " << append_pos << endl; + dout(15) << "append event type " << e->get_type() << " size " << elen << " at log offset " << append_pos << endl; off_t off = append_pos; append_pos += elen; - dout(15) << "write buf was " << write_buf.length() << endl; + //dout(15) << "write buf was " << write_buf.length() << " bl " << write_buf << endl; write_buf.claim_append(bl); - dout(15) << "write buf now " << write_buf.length() << endl; + //dout(15) << "write buf now " << write_buf.length() << " bl " << write_buf << endl; return off; } void LogStream::_append_2(off_t off) { - dout(10) << "sync_pos now " << off << endl; + dout(15) << "sync_pos now " << off << endl; sync_pos = off; // wake up waiters @@ -133,7 +133,7 @@ LogEvent *LogStream::get_next_event() read_buf.copy(off, sizeof(__uint32_t), (char*)&length); off += sizeof(__uint32_t); - dout(10) << "getting next event from " << read_pos << ", type " << type << ", size " << length << endl; + dout(15) << "getting next event from " << read_pos << ", type " << type << ", size " << length << endl; assert(type > 0); diff --git a/ceph/mds/MDBalancer.cc b/ceph/mds/MDBalancer.cc index 24df995b4c91b..97fceda99d0e2 100644 --- a/ceph/mds/MDBalancer.cc +++ b/ceph/mds/MDBalancer.cc @@ -474,39 +474,50 @@ void MDBalancer::hit_recursive(CDir *dir, timepair_t& now) */ void MDBalancer::subtract_export(CDir *dir) { - - // FIXME this is totally wrong - timepair_t now = g_clock.gettimepair(); double curdom = -dir->popularity[MDS_POP_CURDOM].get(now); - double anydom = -dir->popularity[MDS_POP_ANYDOM].get(now); bool in_domain = !dir->is_import(); while (true) { CInode *in = dir->inode; - if (in_domain) - in->popularity[MDS_POP_CURDOM].adjust(now, curdom); - if (in->is_auth()) - in->popularity[MDS_POP_ANYDOM].adjust(now, anydom); + in->popularity[MDS_POP_ANYDOM].adjust(now, curdom); + if (in_domain) in->popularity[MDS_POP_CURDOM].adjust(now, curdom); dir = in->get_parent_dir(); if (!dir) break; - + if (dir->is_import()) in_domain = false; - if (in_domain) - dir->popularity[MDS_POP_CURDOM].adjust(now, curdom); - if (dir->is_auth()) - dir->popularity[MDS_POP_ANYDOM].adjust(now, anydom); + dir->popularity[MDS_POP_ANYDOM].adjust(now, curdom); + if (in_domain) dir->popularity[MDS_POP_CURDOM].adjust(now, curdom); } } void MDBalancer::add_import(CDir *dir) { + timepair_t now = g_clock.gettimepair(); + double curdom = dir->popularity[MDS_POP_CURDOM].get(now); + + bool in_domain = !dir->is_import(); + while (true) { + CInode *in = dir->inode; + + in->popularity[MDS_POP_ANYDOM].adjust(now, curdom); + if (in_domain) in->popularity[MDS_POP_CURDOM].adjust(now, curdom); + + dir = in->get_parent_dir(); + if (!dir) break; + + if (dir->is_import()) in_domain = false; + + dir->popularity[MDS_POP_ANYDOM].adjust(now, curdom); + if (in_domain) dir->popularity[MDS_POP_CURDOM].adjust(now, curdom); + } + } diff --git a/ceph/mds/MDCache.cc b/ceph/mds/MDCache.cc index eca7000c7cd71..3cef53b907407 100644 --- a/ceph/mds/MDCache.cc +++ b/ceph/mds/MDCache.cc @@ -556,8 +556,6 @@ void MDCache::shutdown_start() bool MDCache::shutdown_pass() { - static bool did_inode_updates = false; - dout(7) << "shutdown_pass" << endl; //assert(mds->is_shutting_down()); if (mds->is_shut_down()) { @@ -2976,7 +2974,8 @@ void MDCache::handle_rename(MRename *m) // decode + import inode (into new location start) int off = 0; - decode_import_inode(destdn, m->get_inode_state(), off, m->get_source()); + timepair_t now = g_clock.gettimepair(); + decode_import_inode(destdn, m->get_inode_state(), off, m->get_source(), now); CInode *in = destdn->inode; assert(in); @@ -5334,7 +5333,6 @@ void MDCache::export_dir(CDir *dir, mds->messenger->send_message(new MExportDirDiscover(dir->inode), dest, MDS_PORT_CACHE, MDS_PORT_CACHE); dir->auth_pin(); // pin dir, to hang up our freeze - mds->logger->inc("ex"); // take away popularity (and pass it on to the context, MExportDir request later) mds->balancer->subtract_export(dir); @@ -5561,11 +5559,11 @@ void MDCache::export_dir_go(CDir *dir, // fill export message with cache data C_MDS_ExportFinish *fin = new C_MDS_ExportFinish(mds, dir, dest); - export_dir_walk( req, - fin, - dir, // base - dir, // recur start point - dest ); + int num_exported_inodes = export_dir_walk( req, + fin, + dir, // base + dir, // recur start point + dest ); // send the export data! mds->messenger->send_message(req, @@ -5575,6 +5573,11 @@ void MDCache::export_dir_go(CDir *dir, // queue up the finisher dir->add_waiter( CDIR_WAIT_UNFREEZE, fin ); + + // stats + mds->logger->inc("ex"); + mds->logger->inc("iex", num_exported_inodes); + show_imports(); } @@ -5627,12 +5630,14 @@ void MDCache::encode_export_inode(CInode *in, crope& state_rope, int new_auth) } -void MDCache::export_dir_walk(MExportDir *req, +int MDCache::export_dir_walk(MExportDir *req, C_MDS_ExportFinish *fin, CDir *basedir, CDir *dir, int newauth) { + int num_exported = 0; + dout(7) << "export_dir_walk " << *dir << " " << dir->nitems << " items" << endl; // dir @@ -5676,6 +5681,8 @@ void MDCache::export_dir_walk(MExportDir *req, CDentry *dn = it->second; CInode *in = dn->inode; + num_exported++; + // -- dentry dout(7) << "export_dir_walk exporting " << *dn << endl; dir_rope.append( it->first.c_str(), it->first.length()+1 ); @@ -5745,7 +5752,9 @@ void MDCache::export_dir_walk(MExportDir *req, // subdirs for (list::iterator it = subdirs.begin(); it != subdirs.end(); it++) - export_dir_walk(req, fin, basedir, *it, newauth); + num_exported += export_dir_walk(req, fin, basedir, *it, newauth); + + return num_exported; } @@ -6124,7 +6133,6 @@ void MDCache::handle_export_dir(MExportDir *m) show_imports(); - mds->logger->inc("im"); // note new authority (locally) in inode if (dir->inode->is_auth()) @@ -6182,7 +6190,7 @@ void MDCache::handle_export_dir(MExportDir *m) imports.erase(ex); ex->state_clear(CDIR_STATE_IMPORT); - mds->logger->inc("immyex"); + mds->logger->inc("imex"); // move nested exports under containing_import for (set::iterator it = nested_exports[ex].begin(); @@ -6214,12 +6222,17 @@ void MDCache::handle_export_dir(MExportDir *m) list imported_subdirs; crope dir_state = m->get_state(); int off = 0; + int num_imported_inodes = 0; + timepair_t now = g_clock.gettimepair(); // for popularity adjustments + for (int i = 0; i < m->get_ndirs(); i++) { - import_dir_block(dir_state, - off, - oldauth, - dir, // import root - imported_subdirs); + num_imported_inodes += + import_dir_block(dir_state, + off, + oldauth, + dir, // import root + imported_subdirs, + now); } dout(10) << " " << imported_subdirs.size() << " imported subdirs" << endl; dout(10) << " " << m->get_exports().size() << " imported nested exports" << endl; @@ -6266,6 +6279,13 @@ void MDCache::handle_export_dir(MExportDir *m) } + // some stats + mds->logger->inc("im"); + mds->logger->inc("iim", num_imported_inodes); + mds->logger->set("nex", exports.size()); + mds->logger->set("nim", imports.size()); + + // FIXME LOG IT /* @@ -6309,7 +6329,7 @@ void MDCache::handle_export_dir_finish(MExportDirFinish *m) } -void MDCache::decode_import_inode(CDentry *dn, crope& r, int& off, int oldauth) +void MDCache::decode_import_inode(CDentry *dn, crope& r, int& off, int oldauth, timepair_t& now) { CInodeExport istate; @@ -6326,7 +6346,7 @@ void MDCache::decode_import_inode(CDentry *dn, crope& r, int& off, int oldauth) } // state - istate.update_inode(in); + istate.update_inode(in, now); // add inode? if (added) { @@ -6372,11 +6392,12 @@ void MDCache::decode_import_inode(CDentry *dn, crope& r, int& off, int oldauth) } -void MDCache::import_dir_block(crope& r, - int& off, - int oldauth, - CDir *import_root, - list& imported_subdirs) +int MDCache::import_dir_block(crope& r, + int& off, + int oldauth, + CDir *import_root, + list& imported_subdirs, + timepair_t& now) { // set up dir CDirExport dstate; @@ -6394,7 +6415,7 @@ void MDCache::import_dir_block(crope& r, imported_subdirs.push_back(dir->ino()); // assimilate state - dstate.update_dir( dir ); + dstate.update_dir( dir, now ); if (diri->is_auth()) dir->dir_auth = CDIR_AUTH_PARENT; // update_dir may hose dir_auth // mark (may already be marked from get_or_open_dir() above) @@ -6420,7 +6441,11 @@ void MDCache::import_dir_block(crope& r, dout(15) << "doing contents" << endl; // contents + int num_imported = 0; for (long nden = dstate.get_nden(); nden>0; nden--) { + + num_imported++; + // dentry string dname = r.c_str() + off; off += dname.length()+1; @@ -6453,7 +6478,7 @@ void MDCache::import_dir_block(crope& r, } else if (icode == 'I') { // inode - decode_import_inode(dn, r, off, oldauth); + decode_import_inode(dn, r, off, oldauth, now); } // mark dentry dirty? (only _after_ we link the inode!) @@ -6461,6 +6486,7 @@ void MDCache::import_dir_block(crope& r, } + return num_imported; } diff --git a/ceph/mds/MDCache.h b/ceph/mds/MDCache.h index 5a62a08fd89ce..6ec7d1040c807 100644 --- a/ceph/mds/MDCache.h +++ b/ceph/mds/MDCache.h @@ -291,11 +291,11 @@ class MDCache { void handle_export_dir_prep_ack(MExportDirPrepAck *m); void export_dir_go(CDir *dir, int dest); - void export_dir_walk(MExportDir *req, - class C_MDS_ExportFinish *fin, - CDir *basedir, - CDir *dir, - int newauth); + int export_dir_walk(MExportDir *req, + class C_MDS_ExportFinish *fin, + CDir *basedir, + CDir *dir, + int newauth); void export_dir_finish(CDir *dir); void handle_export_dir_notify_ack(MExportDirNotifyAck *m); @@ -309,16 +309,17 @@ class MDCache { void handle_export_dir(MExportDir *m); void import_dir_finish(CDir *dir); void handle_export_dir_finish(MExportDirFinish *m); - void import_dir_block(crope& r, - int& off, - int oldauth, - CDir *import_root, - list& imported_subdirs); + int import_dir_block(crope& r, + int& off, + int oldauth, + CDir *import_root, + list& imported_subdirs, + timepair_t& now); void got_hashed_replica(CDir *import, inodeno_t dir_ino, inodeno_t replica_ino); - void decode_import_inode(CDentry *dn, crope& r, int &off, int oldauth); + void decode_import_inode(CDentry *dn, crope& r, int &off, int oldauth, timepair_t& now); // bystander void handle_export_dir_warning(MExportDirWarning *m); diff --git a/ceph/mds/MDLog.cc b/ceph/mds/MDLog.cc index 2cf8c67716d88..1fbcedd96188b 100644 --- a/ceph/mds/MDLog.cc +++ b/ceph/mds/MDLog.cc @@ -24,6 +24,8 @@ MDLog::MDLog(MDS *m) num_events = 0; max_events = 0; + waiting_for_read = false; + logstream = new LogStream(mds, mds->filer, MDS_INO_LOG_OFFSET + mds->get_nodeid()); char name[80]; diff --git a/ceph/mds/MDS.cc b/ceph/mds/MDS.cc index faba9facc8102..b20b2db1336e4 100644 --- a/ceph/mds/MDS.cc +++ b/ceph/mds/MDS.cc @@ -109,6 +109,7 @@ MDS::MDS(MDCluster *mdc, int whoami, Messenger *m) { shutting_down = false; shut_down = false; + mds_paused = false; stat_ops = 0; last_heartbeat = 0; @@ -134,12 +135,16 @@ MDS::~MDS() { if (mdstore) { delete mdstore; mdstore = NULL; } if (mdlog) { delete mdlog; mdlog = NULL; } if (balancer) { delete balancer; balancer = NULL; } + if (osdmonitor) { delete osdmonitor; osdmonitor = 0; } + if (idalloc) { delete idalloc; idalloc = NULL; } + if (anchormgr) { delete anchormgr; anchormgr = NULL; } + if (osdcluster) { delete osdcluster; osdcluster = 0; } - if (logger) { delete logger; logger = 0; } - + if (filer) { delete filer; filer = 0; } if (messenger) { delete messenger; messenger = NULL; } - if (idalloc) { delete idalloc; idalloc = NULL; } + if (logger) { delete logger; logger = 0; } + } @@ -392,6 +397,9 @@ void MDS::my_dispatch(Message *m) // flush log mdlog->flush(); + + // trim cache + mdcache->trim(); // finish any triggered contexts diff --git a/ceph/mds/MDStore.cc b/ceph/mds/MDStore.cc index c04925446c3b4..c725cd27bb13f 100644 --- a/ceph/mds/MDStore.cc +++ b/ceph/mds/MDStore.cc @@ -605,7 +605,7 @@ void MDStore::do_fetch_dir_2( bufferlist& bl, dout(7) << *mds << "do_fetch_dir_2 hashcode " << hashcode << " dir " << *dir << endl; // parse buffer contents into cache - cout << "bl is " << bl << endl; + dout(15) << "bl is " << bl << endl; size_t size; bl.copy(0, sizeof(size), (char*)&size); assert(bl.length() >= size + sizeof(size)); diff --git a/ceph/mds/events/EAlloc.h b/ceph/mds/events/EAlloc.h index f686204c0d459..2215f8e6c231f 100644 --- a/ceph/mds/events/EAlloc.h +++ b/ceph/mds/events/EAlloc.h @@ -13,14 +13,14 @@ class EAlloc : public LogEvent { protected: - int type; + int idtype; idno_t id; int what; public: - EAlloc(int type, idno_t id, int what) : + EAlloc(int idtype, idno_t id, int what) : LogEvent(EVENT_ALLOC) { - this->type = type; + this->idtype = idtype; this->id = id; this->what = what; } @@ -28,14 +28,14 @@ class EAlloc : public LogEvent { LogEvent(EVENT_ALLOC) { } - virtual void encode_payload(bufferlist& bl) { - bl.append((char*)&type, sizeof(type)); + void encode_payload(bufferlist& bl) { + bl.append((char*)&idtype, sizeof(idtype)); bl.append((char*)&id, sizeof(id)); bl.append((char*)&what, sizeof(what)); } void decode_payload(bufferlist& bl, int& off) { - bl.copy(off, sizeof(type), (char*)&type); - off += sizeof(type); + bl.copy(off, sizeof(idtype), (char*)&idtype); + off += sizeof(idtype); bl.copy(off, sizeof(id), (char*)&id); off += sizeof(id); bl.copy(off, sizeof(what), (char*)&what); @@ -44,7 +44,7 @@ class EAlloc : public LogEvent { virtual bool obsolete(MDS *mds) { - if (mds->idalloc->is_dirty(type,id)) + if (mds->idalloc->is_dirty(idtype, id)) return false; // still dirty else return true; // already flushed diff --git a/ceph/msg/CheesySerializer.cc b/ceph/msg/CheesySerializer.cc index e487e38b98b4e..aa9fbc3b98fad 100644 --- a/ceph/msg/CheesySerializer.cc +++ b/ceph/msg/CheesySerializer.cc @@ -54,7 +54,7 @@ Message *CheesySerializer::sendrecv(Message *m, msg_addr_t dest, int port) { int fromport = 0; - Cond *cond = new Cond(); + Cond cond; // make up a pcid that is unique (to me!) /* NOTE: since request+replies are matched up on pcid's alone, it means that @@ -72,7 +72,7 @@ Message *CheesySerializer::sendrecv(Message *m, msg_addr_t dest, int port) // add call records assert(call_cond.count(pcid) == 0); // pcid should be UNIQUE - call_cond[pcid] = cond; + call_cond[pcid] = &cond; call_reply[pcid] = 0; // no reply yet // send. drop locks in case send_message is bad and blocks @@ -85,7 +85,7 @@ Message *CheesySerializer::sendrecv(Message *m, msg_addr_t dest, int port) dout(DEBUGLVL) << "sendrecv waiting for reply on pcid " << pcid << endl; //cout << "wait start, value = " << sem->Value() << endl; - cond->Wait(lock); + cond.Wait(lock); } else { dout(DEBUGLVL) << "sendrecv reply is already here on pcid " << pcid << endl; } diff --git a/ceph/msg/HostMonitor.cc b/ceph/msg/HostMonitor.cc index 15c21bdbf4ee7..a6ab29921c6af 100644 --- a/ceph/msg/HostMonitor.cc +++ b/ceph/msg/HostMonitor.cc @@ -201,13 +201,16 @@ void HostMonitor::handle_ping_ack(MPingAck *m) void HostMonitor::handle_failure_ack(MFailureAck *m) { + + // FIXME: this doesn't handle failed -> alive transitions gracefully at all.. + // the higher-up's acknowledged our failure notification, we can stop resending it. msg_addr_t failed = m->get_failed(); dout(DBL) << "handle_failure_ack " << failed << endl; unacked_failures.erase(failed); acked_failures.insert(failed); - // FIXME: this doesn't handle failed -> alive transitions gracefully at all.. + delete m; } diff --git a/ceph/osd/FakeStore.cc b/ceph/osd/FakeStore.cc index fc3f94dbeab1f..c4f67f0c22c73 100644 --- a/ceph/osd/FakeStore.cc +++ b/ceph/osd/FakeStore.cc @@ -33,7 +33,8 @@ FakeStore::FakeStore(char *base, int whoami, char *shadow) if (shadow) { is_shadow = true; shadowdir = shadow; - } + } else + is_shadow = false; } @@ -71,12 +72,12 @@ int FakeStore::finalize() //// void FakeStore::get_dir(string& dir) { - static char s[30]; + char s[30]; sprintf(s, "%d", whoami); dir = basedir + "/" + s; } void FakeStore::get_oname(object_t oid, string& fn, bool shadow) { - static char s[100]; + char s[100]; sprintf(s, "%d/%02lld/%lld", whoami, HASH_FUNC(oid), oid); if (shadow) fn = shadowdir + "/" + s; @@ -297,9 +298,8 @@ int FakeStore::write(object_t oid, off_t actual = lseek(fd, offset, SEEK_SET); size_t did = 0; - if (actual == offset) { - did = ::write(fd, buffer, len); - } + assert(actual == offset); + did = ::write(fd, buffer, len); // sync to to disk? if (do_fsync) fsync(fd); // should this be fsync? diff --git a/ceph/osd/OSD.cc b/ceph/osd/OSD.cc index 05a8ce5d0440d..5d920396b754e 100644 --- a/ceph/osd/OSD.cc +++ b/ceph/osd/OSD.cc @@ -47,6 +47,8 @@ OSD::OSD(int id, Messenger *m) messenger = m; messenger->set_dispatcher(this); + osdcluster = 0; + // use fake store store = new FakeStore(osd_base_path, whoami); @@ -79,8 +81,10 @@ OSD::OSD(int id, Messenger *m) OSD::~OSD() { + if (osdcluster) { delete osdcluster; osdcluster = 0; } if (messenger) { delete messenger; messenger = 0; } if (logger) { delete logger; logger = 0; } + if (store) { delete store; store = 0; } } int OSD::init() @@ -122,6 +126,7 @@ void OSD::dispatch(Message *m) // osd case MSG_SHUTDOWN: shutdown(); + delete m; break; case MSG_OSD_GETCLUSTERACK: @@ -310,8 +315,7 @@ void OSD::op_read(MOSDOp *r) bptr.set_length(got); // properly size the buffer // give it to the reply in a bufferlist - bufferlist bl; - bl.push_back( bptr ); + reply->get_data().push_back( bptr ); reply->set_result(0); reply->set_data(bl); @@ -346,6 +350,7 @@ void OSD::op_write(MOSDOp *m) for (list::iterator it = bl.buffers().begin(); it != bl.buffers().end(); it++) { + int r = store->write(m->get_oid(), (*it).length(), off, (*it).c_str(), diff --git a/ceph/osd/OSDMap.h b/ceph/osd/OSDMap.h index 6e50630185090..f2c95fa88bf35 100644 --- a/ceph/osd/OSDMap.h +++ b/ceph/osd/OSDMap.h @@ -84,6 +84,9 @@ class OSDCluster { public: OSDCluster() : version(0), rush(0) { } + ~OSDCluster() { + if (rush) { delete rush; rush = 0; } + } __uint64_t get_version() { return version; } diff --git a/ceph/osdc/Filer.cc b/ceph/osdc/Filer.cc index e6ea7a5bd515d..2817327d6f9b6 100644 --- a/ceph/osdc/Filer.cc +++ b/ceph/osdc/Filer.cc @@ -167,12 +167,12 @@ Filer::handle_osd_read_reply(MOSDOpReply *m) // finish, clean up Context *onfinish = p->onfinish; - delete p; // del pendingOsdRead_t - int result = p->read_result->length(); // assume success + dout(7) << "read " << result << " bytes " << p->read_result->length() << endl; // done + delete p; // del pendingOsdRead_t if (onfinish) { onfinish->finish(result); delete onfinish; -- 2.39.5