From 7358742c6ea40ae4b199df2199b00903bd0fd0e4 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 9 May 2008 09:28:34 -0700 Subject: [PATCH] mds: clean up MExportDir encoding --- src/mds/LogEvent.cc | 1 + src/mds/Migrator.cc | 35 ++++++++++++++--------------------- src/mds/events/EImportStart.h | 2 +- src/mds/journal.cc | 1 + src/messages/MExportDir.h | 19 +++++++------------ 5 files changed, 24 insertions(+), 34 deletions(-) diff --git a/src/mds/LogEvent.cc b/src/mds/LogEvent.cc index 949d400d334fc..e9dafa34109a5 100644 --- a/src/mds/LogEvent.cc +++ b/src/mds/LogEvent.cc @@ -80,6 +80,7 @@ LogEvent *LogEvent::decode(bufferlist& bl) // decode le->decode(p); + assert(p.end()); return le; } diff --git a/src/mds/Migrator.cc b/src/mds/Migrator.cc index 480c7594c4192..6fcc93847651d 100644 --- a/src/mds/Migrator.cc +++ b/src/mds/Migrator.cc @@ -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 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 import_bounds; diff --git a/src/mds/events/EImportStart.h b/src/mds/events/EImportStart.h index bb5be9b6fc355..aa3d24ce81ba2 100644 --- a/src/mds/events/EImportStart.h +++ b/src/mds/events/EImportStart.h @@ -30,7 +30,7 @@ protected: public: EMetaBlob metablob; - bufferlist client_map; // encoded map + bufferlist client_map; // encoded map<__u32,entity_inst_t> version_t cmapv; EImportStart(dirfrag_t di, diff --git a/src/mds/journal.cc b/src/mds/journal.cc index a11a4f556bbdc..da9e53ab227cb 100644 --- a/src/mds/journal.cc +++ b/src/mds/journal.cc @@ -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 diff --git a/src/messages/MExportDir.h b/src/messages/MExportDir.h index ec1dc094dcbe6..595267a024bb5 100644 --- a/src/messages/MExportDir.h +++ b/src/messages/MExportDir.h @@ -20,12 +20,12 @@ class MExportDir : public Message { + public: dirfrag_t dirfrag; - - bufferlist dirstate; + bufferlist export_data; list 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& 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); } }; -- 2.39.5