]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: clean up MExportDir encoding
authorSage Weil <sage@newdream.net>
Fri, 9 May 2008 16:28:34 +0000 (09:28 -0700)
committerSage Weil <sage@newdream.net>
Fri, 9 May 2008 16:28:34 +0000 (09:28 -0700)
src/mds/LogEvent.cc
src/mds/Migrator.cc
src/mds/events/EImportStart.h
src/mds/journal.cc
src/messages/MExportDir.h

index 949d400d334fc509cf6e7373de9f38a5b02327f1..e9dafa34109a54291999fd56a0cd60cdcfd9f4ab 100644 (file)
@@ -80,6 +80,7 @@ LogEvent *LogEvent::decode(bufferlist& bl)
 
   // decode
   le->decode(p);
+  assert(p.end());
   
   return le;
 }
index 480c7594c4192724157b1374c7761356f0d1a030..6fcc93847651d6a31a87762bc3bdffd5ccdaf625 100644 (file)
@@ -815,21 +815,14 @@ void Migrator::export_go_synced(CDir *dir)
   mds->balancer->subtract_export(dir);
   
   // fill export message with cache data
+  MExportDir *req = new MExportDir(dir->dirfrag());
   utime_t now = g_clock.now();
   map<__u32,entity_inst_t> exported_client_map;
-  bufferlist export_data;
-  int num_exported_inodes = encode_export_dir( export_data,
-                                              dir,   // recur start point
-                                              exported_client_map,
-                                              now );
-  bufferlist bl;
-  ::encode(exported_client_map, bl);
-  bl.claim_append(export_data);
-  export_data.claim(bl);
-
-  // send the export data!
-  MExportDir *req = new MExportDir(dir->dirfrag());
-  req->take_dirstate(export_data);
+  int num_exported_inodes = encode_export_dir(req->export_data,
+                                             dir,   // recur start point
+                                             exported_client_map,
+                                             now);
+  ::encode(exported_client_map, req->client_map);
 
   // add bounds to message
   set<CDir*> bounds;
@@ -1636,7 +1629,7 @@ public:
 
 void Migrator::handle_export_dir(MExportDir *m)
 {
-  CDir *dir = cache->get_dirfrag(m->get_dirfrag());
+  CDir *dir = cache->get_dirfrag(m->dirfrag);
   assert(dir);
 
   int oldauth = m->get_source().num();
@@ -1648,19 +1641,19 @@ void Migrator::handle_export_dir(MExportDir *m)
   C_MDS_ImportDirLoggedStart *onlogged = new C_MDS_ImportDirLoggedStart(this, dir, m->get_source().num());
 
   // start the journal entry
-  EImportStart *le = new EImportStart(dir->dirfrag(), m->get_bounds());
+  EImportStart *le = new EImportStart(dir->dirfrag(), m->bounds);
   le->metablob.add_dir_context(dir);
   
   // adjust auth (list us _first_)
   cache->adjust_subtree_auth(dir, mds->get_nodeid(), oldauth);
 
-  // add this crap to my cache
-  bufferlist::iterator blp = m->get_dirstate().begin();
-
   // new client sessions, open these after we journal
-  ::decode(onlogged->imported_client_map, blp);
+  bufferlist::iterator cmp = m->client_map.begin();
+  ::decode(onlogged->imported_client_map, cmp);
+  assert(cmp.end());
   mds->server->prepare_force_open_sessions(onlogged->imported_client_map);
 
+  bufferlist::iterator blp = m->export_data.begin();
   int num_imported_inodes = 0;
   while (!blp.end()) {
     num_imported_inodes += 
@@ -1672,10 +1665,10 @@ void Migrator::handle_export_dir(MExportDir *m)
                        import_caps[dir],
                        import_updated_scatterlocks[dir]);
   }
-  dout(10) << " " << m->get_bounds().size() << " imported bounds" << dendl;
+  dout(10) << " " << m->bounds.size() << " imported bounds" << dendl;
   
   // include imported sessions in EImportStart
-  le->client_map.claim(m->get_dirstate());
+  le->client_map.claim(m->client_map);
 
   // include bounds in EImportStart
   set<CDir*> import_bounds;
index bb5be9b6fc3558b02a3899389ec255d34a82505f..aa3d24ce81ba2e8a50083442d929a84f2750c3f9 100644 (file)
@@ -30,7 +30,7 @@ protected:
 
  public:
   EMetaBlob metablob;
-  bufferlist client_map;  // encoded map<int,entity_inst_t>
+  bufferlist client_map;  // encoded map<__u32,entity_inst_t>
   version_t cmapv;
 
   EImportStart(dirfrag_t di,
index a11a4f556bbdcaab92d2e1fb218a4fd430daf8a9..da9e53ab227cb64e94fc100aed4a38285daa98a6 100644 (file)
@@ -770,6 +770,7 @@ void EExport::replay(MDS *mds)
 void EImportStart::replay(MDS *mds)
 {
   dout(10) << "EImportStart.replay " << base << dendl;
+  metablob.print(*_dout);
   metablob.replay(mds, _segment);
 
   // put in ambiguous import list
index ec1dc094dcbe6afa633ae0546be7743422881149..595267a024bb522f04b4b5493dfffb08dc97df80 100644 (file)
 
 
 class MExportDir : public Message {
+ public:  
   dirfrag_t dirfrag;
-  
-  bufferlist dirstate;
+  bufferlist export_data;
   list<dirfrag_t> bounds;
+  bufferlist client_map;
 
- public:  
   MExportDir() {}
   MExportDir(dirfrag_t df) : 
     Message(MSG_MDS_EXPORTDIR),
@@ -36,13 +36,6 @@ class MExportDir : public Message {
     o << "export(" << dirfrag << ")";
   }
 
-  dirfrag_t get_dirfrag() { return dirfrag; }
-  bufferlist& get_dirstate() { return dirstate; }
-  list<dirfrag_t>& get_bounds() { return bounds; }
-
-  void take_dirstate(bufferlist& bl) {
-    dirstate.claim(bl);
-  }
   void add_export(dirfrag_t df) { 
     bounds.push_back(df); 
   }
@@ -50,13 +43,15 @@ class MExportDir : public Message {
   void encode_payload() {
     ::encode(dirfrag, payload);
     ::encode(bounds, payload);
-    ::encode(dirstate, payload);
+    ::encode(export_data, payload);
+    ::encode(client_map, payload);
   }
   void decode_payload() {
     bufferlist::iterator p = payload.begin();
     ::decode(dirfrag, p);
     ::decode(bounds, p);
-    ::decode(dirstate, p);
+    ::decode(export_data, p);
+    ::decode(client_map, p);
   }
 
 };