]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
MDSMap: mds_info_t now uses modern encoding
authorGreg Farnum <greg@inktank.com>
Thu, 31 Jan 2013 21:14:27 +0000 (13:14 -0800)
committerGreg Farnum <greg@inktank.com>
Tue, 5 Feb 2013 21:29:06 +0000 (13:29 -0800)
We have to update the older-style MDSMap encodings to generate
the previous versions for clients as well.

Signed-off-by: Greg Farnum <greg@inktank.com>
src/mds/MDSMap.cc
src/mds/MDSMap.h
src/test/encoding/types.h

index 08e1a554d2553be07b3e7b5ef9ebb43983b25321..ae09aeddbe5e93722a14396ed2f0bd9631634369 100644 (file)
@@ -64,6 +64,17 @@ void MDSMap::mds_info_t::dump(Formatter *f) const
   f->close_section();
 }
 
+void MDSMap::mds_info_t::generate_test_instances(list<mds_info_t*>& ls)
+{
+  mds_info_t *sample = new mds_info_t();
+  ls.push_back(sample);
+  sample = new mds_info_t();
+  sample->global_id = 1;
+  sample->name = "test_instance";
+  sample->rank = 0;
+  ls.push_back(sample);
+}
+
 void MDSMap::dump(Formatter *f) const
 {
   f->dump_int("epoch", epoch);
@@ -268,10 +279,27 @@ void MDSMap::get_health(list<pair<health_status_t,string> >& summary,
   }
 }
 
-void MDSMap::mds_info_t::encode(bufferlist& bl) const
+void MDSMap::mds_info_t::encode_versioned(bufferlist& bl, uint64_t features) const
+{
+  ENCODE_START(4, 4, bl);
+  ::encode(global_id, bl);
+  ::encode(name, bl);
+  ::encode(rank, bl);
+  ::encode(inc, bl);
+  ::encode(state, bl);
+  ::encode(state_seq, bl);
+  ::encode(addr, bl);
+  ::encode(laggy_since, bl);
+  ::encode(standby_for_rank, bl);
+  ::encode(standby_for_name, bl);
+  ::encode(export_targets, bl);
+  ENCODE_FINISH(bl);
+}
+
+void MDSMap::mds_info_t::encode_unversioned(bufferlist& bl) const
 {
-  __u8 v = 3;
-  ::encode(v, bl);
+  __u8 struct_v = 3;
+  ::encode(struct_v, bl);
   ::encode(global_id, bl);
   ::encode(name, bl);
   ::encode(rank, bl);
@@ -287,8 +315,7 @@ void MDSMap::mds_info_t::encode(bufferlist& bl) const
 
 void MDSMap::mds_info_t::decode(bufferlist::iterator& bl)
 {
-  __u8 v;
-  ::decode(v, bl);
+  DECODE_START_LEGACY_COMPAT_LEN(4, 4, 4, bl);
   ::decode(global_id, bl);
   ::decode(name, bl);
   ::decode(rank, bl);
@@ -299,8 +326,9 @@ void MDSMap::mds_info_t::decode(bufferlist::iterator& bl)
   ::decode(laggy_since, bl);
   ::decode(standby_for_rank, bl);
   ::decode(standby_for_name, bl);
-  if (v >= 2)
+  if (struct_v >= 2)
     ::decode(export_targets, bl);
+  DECODE_FINISH(bl);
 }
 
 
@@ -318,8 +346,14 @@ void MDSMap::encode(bufferlist& bl, uint64_t features) const
     ::encode(session_autoclose, bl);
     ::encode(max_file_size, bl);
     ::encode(max_mds, bl);
-    ::encode(mds_info, bl);
-    __u32 n = data_pools.size();
+    __u32 n = mds_info.size();
+    ::encode(n, bl);
+    for (map<uint64_t, mds_info_t>::const_iterator i = mds_info.begin();
+       i != mds_info.end(); ++i) {
+      ::encode(i->first, bl);
+      ::encode(i->second, bl, features);
+    }
+    n = data_pools.size();
     ::encode(n, bl);
     for (set<int64_t>::const_iterator p = data_pools.begin(); p != data_pools.end(); ++p) {
       n = *p;
@@ -340,7 +374,13 @@ void MDSMap::encode(bufferlist& bl, uint64_t features) const
     ::encode(session_autoclose, bl);
     ::encode(max_file_size, bl);
     ::encode(max_mds, bl);
-    ::encode(mds_info, bl);
+    __u32 n = mds_info.size();
+    ::encode(n, bl);
+    for (map<uint64_t, mds_info_t>::const_iterator i = mds_info.begin();
+       i != mds_info.end(); ++i) {
+      ::encode(i->first, bl);
+      ::encode(i->second, bl, features);
+    }
     ::encode(data_pools, bl);
     ::encode(cas_pool, bl);
 
@@ -368,7 +408,7 @@ void MDSMap::encode(bufferlist& bl, uint64_t features) const
     ::encode(session_autoclose, bl);
     ::encode(max_file_size, bl);
     ::encode(max_mds, bl);
-    ::encode(mds_info, bl);
+    ::encode(mds_info, bl, features);
     ::encode(data_pools, bl);
     ::encode(cas_pool, bl);
 
index 2a5ee888169c53f5dd45776e7a8a54ab1284b3cc..23c8482f25a4183700b5478e6351d0b6c51bcafc 100644 (file)
@@ -124,9 +124,16 @@ public:
 
     entity_inst_t get_inst() const { return entity_inst_t(entity_name_t::MDS(rank), addr); }
 
-    void encode(bufferlist& bl) const;
+    void encode(bufferlist& bl, uint64_t features) const {
+      if ((features & CEPH_FEATURE_MDSENC) == 0 ) encode_unversioned(bl);
+      else encode_versioned(bl, features);
+    }
     void decode(bufferlist::iterator& p);
     void dump(Formatter *f) const;
+    static void generate_test_instances(list<mds_info_t*>& ls);
+  private:
+    void encode_versioned(bufferlist& bl, uint64_t features) const;
+    void encode_unversioned(bufferlist& bl) const;
   };
 
 
@@ -490,7 +497,7 @@ public:
   void dump(Formatter *f) const;
   static void generate_test_instances(list<MDSMap*>& ls);
 };
-WRITE_CLASS_ENCODER(MDSMap::mds_info_t)
+WRITE_CLASS_ENCODER_FEATURES(MDSMap::mds_info_t)
 WRITE_CLASS_ENCODER_FEATURES(MDSMap)
 
 inline ostream& operator<<(ostream& out, MDSMap& m) {
index c36da829a34cdb796749c9c4ca0a5dead95bba09..423d8472eea98e8d0fda6cbd4362b9e176155277 100644 (file)
@@ -111,6 +111,7 @@ TYPE(mds_table_pending_t)
 
 #include "mds/MDSMap.h"
 TYPE_FEATUREFUL(MDSMap)
+TYPE_FEATUREFUL(MDSMap::mds_info_t)
 
 #ifdef WITH_RADOSGW