From 1395275e0f4d12631b1e4074598a7682810f00f9 Mon Sep 17 00:00:00 2001 From: John Spray Date: Thu, 18 Sep 2014 10:29:06 +0100 Subject: [PATCH] mds: fix not journaling client metadata Previously the code was there for storing in the SessionMap table, but not for the ESession logevent. Fixes: #9518 Signed-off-by: John Spray --- src/mds/Server.cc | 2 +- src/mds/events/ESession.h | 9 +++++++-- src/mds/journal.cc | 15 +++++++++++++-- src/mds/mdstypes.cc | 5 +++++ 4 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/mds/Server.cc b/src/mds/Server.cc index 5a50ccc9713..22b00d74475 100644 --- a/src/mds/Server.cc +++ b/src/mds/Server.cc @@ -236,7 +236,7 @@ void Server::handle_client_session(MClientSession *m) sseq = mds->sessionmap.set_state(session, Session::STATE_OPENING); mds->sessionmap.touch_session(session); pv = ++mds->sessionmap.projected; - mdlog->start_submit_entry(new ESession(m->get_source_inst(), true, pv), + mdlog->start_submit_entry(new ESession(m->get_source_inst(), true, pv, m->client_meta), new C_MDS_session_finish(mds, session, sseq, true, pv)); mdlog->flush(); break; diff --git a/src/mds/events/ESession.h b/src/mds/events/ESession.h index 1ac859a4589..3d55c83e747 100644 --- a/src/mds/events/ESession.h +++ b/src/mds/events/ESession.h @@ -29,14 +29,19 @@ class ESession : public LogEvent { interval_set inos; version_t inotablev; + // Client metadata stored during open + std::map client_metadata; + public: ESession() : LogEvent(EVENT_SESSION), open(false) { } - ESession(const entity_inst_t& inst, bool o, version_t v) : + ESession(const entity_inst_t& inst, bool o, version_t v, + const std::map &cm) : LogEvent(EVENT_SESSION), client_inst(inst), open(o), cmapv(v), - inotablev(0) { + inotablev(0), + client_metadata(cm) { } ESession(const entity_inst_t& inst, bool o, version_t v, const interval_set& i, version_t iv) : diff --git a/src/mds/journal.cc b/src/mds/journal.cc index c67421d5daf..41e36ad6b3c 100644 --- a/src/mds/journal.cc +++ b/src/mds/journal.cc @@ -1615,6 +1615,7 @@ void ESession::replay(MDS *mds) if (open) { session = mds->sessionmap.get_or_add_session(client_inst); mds->sessionmap.set_state(session, Session::STATE_OPEN); + session->set_client_metadata(client_metadata); dout(10) << " opened session " << session->info.inst << dendl; } else { session = mds->sessionmap.get_session(client_inst.name); @@ -1651,19 +1652,20 @@ void ESession::replay(MDS *mds) void ESession::encode(bufferlist &bl) const { - ENCODE_START(3, 3, bl); + ENCODE_START(4, 3, bl); ::encode(stamp, bl); ::encode(client_inst, bl); ::encode(open, bl); ::encode(cmapv, bl); ::encode(inos, bl); ::encode(inotablev, bl); + ::encode(client_metadata, bl); ENCODE_FINISH(bl); } void ESession::decode(bufferlist::iterator &bl) { - DECODE_START_LEGACY_COMPAT_LEN(3, 3, 3, bl); + DECODE_START_LEGACY_COMPAT_LEN(4, 3, 3, bl); if (struct_v >= 2) ::decode(stamp, bl); ::decode(client_inst, bl); @@ -1671,6 +1673,9 @@ void ESession::decode(bufferlist::iterator &bl) ::decode(cmapv, bl); ::decode(inos, bl); ::decode(inotablev, bl); + if (struct_v >= 4) { + ::decode(client_metadata, bl); + } DECODE_FINISH(bl); } @@ -1681,6 +1686,12 @@ void ESession::dump(Formatter *f) const f->dump_int("client map version", cmapv); f->dump_stream("inos") << inos; f->dump_int("inotable version", inotablev); + f->open_object_section("client_metadata"); + for (map::const_iterator i = client_metadata.begin(); + i != client_metadata.end(); ++i) { + f->dump_string(i->first.c_str(), i->second); + } + f->close_section(); // client_metadata } void ESession::generate_test_instances(list& ls) diff --git a/src/mds/mdstypes.cc b/src/mds/mdstypes.cc index 22f4efd621f..eb1ae77d655 100644 --- a/src/mds/mdstypes.cc +++ b/src/mds/mdstypes.cc @@ -620,6 +620,11 @@ void session_info_t::dump(Formatter *f) const f->close_section(); } f->close_section(); + + for (map::const_iterator i = client_metadata.begin(); + i != client_metadata.end(); ++i) { + f->dump_string(i->first.c_str(), i->second); + } } void session_info_t::generate_test_instances(list& ls) -- 2.47.3