]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: pg_pool_t: normalize encoding
authorSage Weil <sage@newdream.net>
Thu, 20 Oct 2011 04:47:50 +0000 (21:47 -0700)
committerSage Weil <sage@newdream.net>
Sun, 23 Oct 2011 23:24:36 +0000 (16:24 -0700)
Normalize encoding to be less awkward.  Use a FEATURE bit to indicate
whether the new encoding is supported, and encode appropriately.

Signed-off-by: Sage Weil <sage@newdream.net>
src/include/ceph_fs.h
src/messages/MOSDMap.h
src/msg/SimpleMessenger.h
src/osd/OSDMap.cc
src/osd/osd_types.cc
src/osd/osd_types.h

index 294231d19779b3fa411d8235d337bdeb44f598cf..d07f99f1802f22cadbe72e08914a9b8ccddb5fb6 100644 (file)
@@ -50,6 +50,7 @@
 #define CEPH_FEATURE_OBJECTLOCATOR  (1<<8)
 #define CEPH_FEATURE_PGID64         (1<<9)
 #define CEPH_FEATURE_INCSUBOSDMAP   (1<<10)
+#define CEPH_FEATURE_PGPOOL3        (1<<11)
 
 /*
  * ceph_file_layout - describe data layout for a file/inode
index 6c158a8a60eafbf41a91c29c2945fa9cc12f3cc9..1a956a44b6e299f67da38ee1e4ce54af5dd629ad 100644 (file)
@@ -79,7 +79,8 @@ public:
   void encode_payload(CephContext *cct) {
     ::encode(fsid, payload);
     header.version = 2;
-    if (connection && !connection->has_feature(CEPH_FEATURE_PGID64)) {
+    if (connection && (!connection->has_feature(CEPH_FEATURE_PGID64) ||
+                      !connection->has_feature(CEPH_FEATURE_PGPOOL3))) {
       // reencode maps using old format
       //
       // FIXME: this can probably be done more efficiently higher up
index 3c81c92dc282f8b46788afde972c8f9c379fdcec..10583501e89a1bc7277fd9f1289c763f039d7915 100644 (file)
@@ -61,7 +61,8 @@ using namespace __gnu_cxx;
   CEPH_FEATURE_DIRLAYOUTHASH |   \
   CEPH_FEATURE_OBJECTLOCATOR |  \
   CEPH_FEATURE_PGID64 |                 \
-  CEPH_FEATURE_INCSUBOSDMAP
+  CEPH_FEATURE_INCSUBOSDMAP |   \
+  CEPH_FEATURE_PGPOOL3
 
 class SimpleMessenger : public Messenger {
 public:
index 87f83234e70bc465e6eb5ea31cc2d1724a72258b..80f3e023ff3113deede660d88a2f831936c1784f 100644 (file)
@@ -92,7 +92,7 @@ void OSDMap::Incremental::encode_client_old(bufferlist& bl) const
        ++p) {
     n = p->first;
     ::encode(n, bl);
-    ::encode(p->second, bl);
+    ::encode(p->second, bl, 0);
   }
   // for ::encode(new_pool_names, bl);
   n = new_pool_names.size();
@@ -143,7 +143,7 @@ void OSDMap::Incremental::encode(bufferlist& bl, uint64_t features) const
   ::encode(crush, bl);
 
   ::encode(new_max_osd, bl);
-  ::encode(new_pools, bl);
+  ::encode(new_pools, bl, features);
   ::encode(new_pool_names, bl);
   ::encode(old_pools, bl);
   ::encode(new_up_client, bl);
@@ -460,7 +460,7 @@ void OSDMap::encode_client_old(bufferlist& bl) const
        ++p) {
     n = p->first;
     ::encode(n, bl);
-    ::encode(p->second, bl);
+    ::encode(p->second, bl, 0);
   }
   // for ::encode(pool_name, bl);
   n = pool_name.size();
@@ -516,7 +516,7 @@ void OSDMap::encode(bufferlist& bl, uint64_t features) const
   ::encode(created, bl);
   ::encode(modified, bl);
 
-  ::encode(pools, bl);
+  ::encode(pools, bl, features);
   ::encode(pool_name, bl);
   ::encode(pool_max, bl);
 
index 4710a5bc670f917edc9c533bfc6dcc0e092ee6fb..79265c3c04f9475a6e4d7a79af4aa500b69220ca 100644 (file)
@@ -396,9 +396,37 @@ ps_t pg_pool_t::raw_pg_to_pps(pg_t pg) const
     return ceph_stable_mod(pg.ps(), pgp_num, pgp_num_mask) + pg.pool();
 }
 
-void pg_pool_t::encode(bufferlist& bl) const
-{
-  __u8 struct_v = 2;
+void pg_pool_t::encode(bufferlist& bl, uint64_t features) const
+{
+  if ((features & CEPH_FEATURE_PGPOOL3) == 0) {
+    // this encoding matches the old struct ceph_pg_pool
+    __u8 struct_v = 2;
+    ::encode(struct_v, bl);
+    ::encode(type, bl);
+    ::encode(size, bl);
+    ::encode(crush_ruleset, bl);
+    ::encode(object_hash, bl);
+    ::encode(pg_num, bl);
+    ::encode(pgp_num, bl);
+    ::encode(lpg_num, bl);
+    ::encode(lpgp_num, bl);
+    ::encode(last_change, bl);
+    ::encode(snap_seq, bl);
+    ::encode(snap_epoch, bl);
+
+    __u32 n = snaps.size();
+    ::encode(n, bl);
+    n = removed_snaps.num_intervals();
+    ::encode(n, bl);
+
+    ::encode(auid, bl);
+
+    ::encode_nohead(snaps, bl);
+    removed_snaps.encode_nohead(bl);
+    return;
+  }
+
+  __u8 struct_v = 3;
   ::encode(struct_v, bl);
   ::encode(type, bl);
   ::encode(size, bl);
@@ -411,23 +439,16 @@ void pg_pool_t::encode(bufferlist& bl) const
   ::encode(last_change, bl);
   ::encode(snap_seq, bl);
   ::encode(snap_epoch, bl);
-
-  __u32 n = snaps.size();
-  ::encode(n, bl);
-  n = removed_snaps.num_intervals();
-  ::encode(n, bl);
-
+  ::encode(snaps, bl);
+  ::encode(removed_snaps, bl);
   ::encode(auid, bl);
-
-  ::encode_nohead(snaps, bl);
-  removed_snaps.encode_nohead(bl);
 }
 
 void pg_pool_t::decode(bufferlist::iterator& bl)
 {
   __u8 struct_v;
   ::decode(struct_v, bl);
-  if (struct_v > 2)
+  if (struct_v > 3)
     throw buffer::error();
 
   ::decode(type, bl);
@@ -441,15 +462,19 @@ void pg_pool_t::decode(bufferlist::iterator& bl)
   ::decode(last_change, bl);
   ::decode(snap_seq, bl);
   ::decode(snap_epoch, bl);
-  
-  __u32 n, m;
-  ::decode(n, bl);
-  ::decode(m, bl);
-  
-  ::decode(auid, bl);
 
-  ::decode_nohead(n, snaps, bl);
-  removed_snaps.decode_nohead(m, bl);
+  if (struct_v >= 3) {
+    ::decode(snaps, bl);
+    ::decode(removed_snaps, bl);
+    ::decode(auid, bl);
+  } else {
+    __u32 n, m;
+    ::decode(n, bl);
+    ::decode(m, bl);
+    ::decode(auid, bl);
+    ::decode_nohead(n, snaps, bl);
+    removed_snaps.decode_nohead(m, bl);
+  }
 
   calc_pg_masks();
 }
index 7c2483c56507f8f7f3258b0ba1ab6aef0b324bd6..cd8740d95f72e24898a07f9304bff63477a0c397 100644 (file)
@@ -654,10 +654,10 @@ struct pg_pool_t {
    */
   ps_t raw_pg_to_pps(pg_t pg) const;
 
-  void encode(bufferlist& bl) const;
+  void encode(bufferlist& bl, uint64_t features) const;
   void decode(bufferlist::iterator& bl);
 };
-WRITE_CLASS_ENCODER(pg_pool_t)
+WRITE_CLASS_ENCODER_FEATURES(pg_pool_t)
 
 ostream& operator<<(ostream& out, const pg_pool_t& p);