]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fix not journaling client metadata
authorJohn Spray <john.spray@redhat.com>
Thu, 18 Sep 2014 09:29:06 +0000 (10:29 +0100)
committerSage Weil <sage@redhat.com>
Thu, 18 Sep 2014 17:52:20 +0000 (10:52 -0700)
Previously the code was there for storing in
the SessionMap table, but not for the ESession
logevent.

Fixes: #9518
Signed-off-by: John Spray <john.spray@redhat.com>
(cherry picked from commit 1395275e0f4d12631b1e4074598a7682810f00f9)

src/mds/Server.cc
src/mds/events/ESession.h
src/mds/journal.cc
src/mds/mdstypes.cc

index 5a50ccc9713ea4823f690f2aefdbdb989b5a1b4b..22b00d7447569da84b91b3b6928aec4b1a2e50ce 100644 (file)
@@ -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;
index 1ac859a458997debbd41cc3197c649f0bed436de..3d55c83e74792e8d99affa1287f635443f1c696f 100644 (file)
@@ -29,14 +29,19 @@ class ESession : public LogEvent {
   interval_set<inodeno_t> inos;
   version_t inotablev;
 
+  // Client metadata stored during open
+  std::map<std::string, std::string> 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<std::string, std::string> &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<inodeno_t>& i, version_t iv) :
index c67421d5dafbed69a7ceecd9eddee19f523e163c..41e36ad6b3c27a9856812e1187db30984e70da00 100644 (file)
@@ -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<string, string>::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<ESession*>& ls)
index 22f4efd621f36a6dee843379fcc8191ec2f735b7..eb1ae77d655c1064c3f2a0fb667a48541543cdae 100644 (file)
@@ -620,6 +620,11 @@ void session_info_t::dump(Formatter *f) const
     f->close_section();
   }
   f->close_section();
+
+  for (map<string, string>::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<session_info_t*>& ls)