]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
memory leaks, etc.
authorsage <sage@29311d96-e01e-0410-9327-a35deaab8ce9>
Tue, 14 Jun 2005 06:29:03 +0000 (06:29 +0000)
committersage <sage@29311d96-e01e-0410-9327-a35deaab8ce9>
Tue, 14 Jun 2005 06:29:03 +0000 (06:29 +0000)
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@309 29311d96-e01e-0410-9327-a35deaab8ce9

24 files changed:
ceph/client/Client.cc
ceph/common/DecayCounter.h
ceph/common/Logger.cc
ceph/common/Logger.h
ceph/config.cc
ceph/fakesyn.cc
ceph/include/buffer.h
ceph/mds/CDir.h
ceph/mds/CInode.h
ceph/mds/LogEvent.h
ceph/mds/LogStream.cc
ceph/mds/MDBalancer.cc
ceph/mds/MDCache.cc
ceph/mds/MDCache.h
ceph/mds/MDLog.cc
ceph/mds/MDS.cc
ceph/mds/MDStore.cc
ceph/mds/events/EAlloc.h
ceph/msg/CheesySerializer.cc
ceph/msg/HostMonitor.cc
ceph/osd/FakeStore.cc
ceph/osd/OSD.cc
ceph/osd/OSDMap.h
ceph/osdc/Filer.cc

index 0645fca921254d11dddb491ad954b4a91eaf0a19..c67d7b8f2a0c7dceba5cbb9912f39b80ac030c08 100644 (file)
@@ -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();
 }
 
index e5cb69ee6938cedc6966fb4eb0bd6482fdffcd64..183a1148c2825f83db158c0ef6f1131635d1233b 100644 (file)
@@ -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;
index 1e1749ca3d4a2887279a8bc1c28f5ab099721e2b..eb24fe9f5b36919e0444342adb7900fdc1120b37 100644 (file)
@@ -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<string>::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
index b2b9d81501810201bc8ef5d8358340bd6353f55b..9ed0a81e0eaaa5264c6343c8fc10f3af12a65f03 100644 (file)
@@ -21,6 +21,7 @@ class Logger {
   int last_logged;
   int interval;
   int wrote_header;
+  int wrote_header_last;
 
   string filename;
 
index ab98f9a891a4485406caccfc6a4c908c706e34c6..1ab8d99ea138d7cfd6091816f9c81979153e70e3 100644 (file)
@@ -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]);
 
index e7e05094ac8723a544d90b4d915f2161df4df1f0..1683192854c80b2b62157cd530ff444aee63a0c9 100644 (file)
@@ -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; i<NUMCLIENT; i++) {
        
-       cout << "waiting for synthetic client to finish" << endl;
+       cout << "waiting for synthetic client " << i << " to finish" << endl;
        syn[i]->join_thread();
        delete syn[i];
        
        client[i]->unmount();
-       cout << "unmounted" << endl;
+       //cout << "unmounted" << endl;
        client[i]->shutdown();
   }
   
index f2a3f9028551dca112429305a65a55101c8a26e5..fdbac01e0acb5712299f5f9fe989735a46118835 100644 (file)
@@ -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 
                         << ")";
 }
index 35c8d21eaef1e2740288a827998b43e89156efc6..d7c5c967332f674c9f42cd319a86584285442f44 100644 (file)
@@ -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;
index c440078f34f503e570b4179f77d15b9a5be99592..2ed1e3864c1ab6dc174d998a004afdb59e1f133f 100644 (file)
@@ -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<fileh_t, CFile*>::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();
index b2ad458e8ec584105d394bb0aa5aac212925e330..fe4173e8a021d7b4dda5db2f821c855b9f0883d0 100644 (file)
@@ -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);
index 306597b92f4c489638b1bd758278726243891fc2..55e1b6989189baf9bbda7de34686a0abd35376be 100644 (file)
@@ -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);
 
index 24df995b4c91b25d03780a13c88a4cc9cb418aa3..97fceda99d0e2b13b1ea4239d4c82043e5b394b2 100644 (file)
@@ -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);
+  }
 }
 
 
index eca7000c7cd710510adf00a8d47f8317ca7e3433..3cef53b90740739057b59f051447d08bbb130da5 100644 (file)
@@ -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<CDir*>::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<CDir*>::iterator it = nested_exports[ex].begin();
@@ -6214,12 +6222,17 @@ void MDCache::handle_export_dir(MExportDir *m)
   list<inodeno_t> 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<inodeno_t>& imported_subdirs)
+int MDCache::import_dir_block(crope& r,
+                                                         int& off,
+                                                         int oldauth,
+                                                         CDir *import_root,
+                                                         list<inodeno_t>& 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;
 }
 
 
index 5a62a08fd89cebfb2cce6cd063b7cdc52fe5c5d6..6ec7d1040c8070b30e4111cc248b68020e6fa2c1 100644 (file)
@@ -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<inodeno_t>& imported_subdirs);
+  int import_dir_block(crope& r,
+                                          int& off,
+                                          int oldauth,
+                                          CDir *import_root,
+                                          list<inodeno_t>& 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);
index 2cf8c67716d88b305ef57680f59b650d4eafd188..1fbcedd96188b618a770a4fa74110ff8056badf3 100644 (file)
@@ -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];
index faba9facc8102bcb4f4b492a19dc05e050892dc8..b20b2db1336e49febfc0707d4c07a0ba46da3a2f 100644 (file)
@@ -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
index c04925446c3b4840583792784b5f8c0134d25e58..c725cd27bb13fc2f8757a88cc66aaf1a84b40a02 100644 (file)
@@ -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));  
index f686204c0d4594e6b651459428e8f9d5112a983d..2215f8e6c231ff57fd81fab45d9e98cb291dd191 100644 (file)
 
 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
index e487e38b98b4ebc7acbbda08db475e28f87ece1f..aa9fbc3b98fad18167cf3449d7951e409081cf7f 100644 (file)
@@ -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;
   }
index 15c21bdbf4ee723768cf78879956ca8f4dd8220f..a6ab29921c6afd9e9d3fb8825e486b293d157c4f 100644 (file)
@@ -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;
 }
 
 
index fc3f94dbeab1fb46f2b0c6b5d36c999d24017f2b..c4f67f0c22c7323322cc20ea9fce2ee4848ec595 100644 (file)
@@ -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?
index 05a8ce5d0440d6e0d9f7665be837be354fd10316..5d920396b754ebfe3faf75acf82b15049e7b594e 100644 (file)
@@ -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<bufferptr>::iterator it = bl.buffers().begin();
           it != bl.buffers().end();
           it++) {
+
        int r = store->write(m->get_oid(),
                                                 (*it).length(), off,
                                                 (*it).c_str(),
index 6e50630185090fed12c645d25591b1d03307f568..f2c95fa88bf35e6031676b1652f322f4172c42a6 100644 (file)
@@ -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; }
 
index e6ea7a5bd515d3ac7d5b941314fa33e77540af10..2817327d6f9b689b3b9f65fc55215eb2484518e2 100644 (file)
@@ -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;