]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
osd: change pg_missing_item encode and decode
authorletterwuyu <lishuhao@unitedstack.com>
Mon, 6 May 2019 07:23:12 +0000 (15:23 +0800)
committerletterwuyu <lishuhao@unitedstack.com>
Mon, 6 May 2019 13:30:06 +0000 (21:30 +0800)
since luminous, recovery_deletes is always true, and octopus won't
maintain compatibility with jewel OSDs

Signed-off-by: lishuhao <lishuhao@unitedstack.com>
src/osd/osd_types.h

index d48afd76f089d234905cf54e7edd2025effee998..2fbb375eb0e22307752b00469eba3f7c1d286cf1 100644 (file)
@@ -4220,59 +4220,43 @@ struct pg_missing_item {
 
   void encode(ceph::buffer::list& bl, uint64_t features) const {
     using ceph::encode;
-    // encoding a zeroed eversion_t to differentiate between OSD_RECOVERY_DELETES、
-    // SERVER_OCTOPUS and legacy unversioned encoding - a need value of 0'0 is not
-    // possible. This can be replaced with the legacy encoding
-
-    bool have_recovery_deletes = HAVE_FEATURE(features, OSD_RECOVERY_DELETES);
-    bool have_server_octopus = HAVE_FEATURE(features, SERVER_OCTOPUS);
-
-    if (have_recovery_deletes)
+    if (HAVE_FEATURE(features, SERVER_OCTOPUS)) {
+      // encoding a zeroed eversion_t to differentiate between OSD_RECOVERY_DELETES、
+      // SERVER_OCTOPUS and legacy unversioned encoding - a need value of 0'0 is not
+      // possible. This can be replaced with the legacy encoding
       encode(eversion_t(), bl);
-    if (have_server_octopus)
       encode(eversion_t(-1, -1), bl);
-
-    encode(need, bl);
-    encode(have, bl);
-      
-    if (have_recovery_deletes)
+      encode(need, bl);
+      encode(have, bl);   
       encode(static_cast<uint8_t>(flags), bl);
-    if (have_server_octopus)
       encode(clean_regions, bl);
+    } else {
+      encode(eversion_t(), bl);
+      encode(need, bl);
+      encode(have, bl);
+      encode(static_cast<uint8_t>(flags), bl);
+    }
   }
   void decode(ceph::buffer::list::const_iterator& bl) {
     using ceph::decode;
-    eversion_t e;
+    eversion_t e, l;
     decode(e, bl);
-
-    if(e == eversion_t()) {
-        eversion_t l;
-        decode(l, bl);
-        if(l == eversion_t(-1, -1)) {
-            // support all
-          decode(need, bl);
-          decode(have, bl);
-          uint8_t f;
-          decode(f, bl);
-          flags = static_cast<missing_flags_t>(f);
-          decode(clean_regions, bl);
-         } else {
-          // support OSD_RECOVERY_DELETES
-          need = l;
-          decode(have, bl);
-          uint8_t f;
-          decode(f, bl);
-          flags = static_cast<missing_flags_t>(f); 
-        }
-    } else if (e == eversion_t(-1, -1)) {
-      // support NAUTILUS
+    decode(l, bl);
+    if(l == eversion_t(-1, -1)) {
+      // support all
       decode(need, bl);
       decode(have, bl);
+      uint8_t f;
+      decode(f, bl);
+      flags = static_cast<missing_flags_t>(f);
       decode(clean_regions, bl);
-    } else {
-      // legacy encoding
-      need = e;
+     } else {
+      // support OSD_RECOVERY_DELETES
+      need = l;
       decode(have, bl);
+      uint8_t f;
+      decode(f, bl);
+      flags = static_cast<missing_flags_t>(f); 
     }
   }
 
@@ -4627,10 +4611,12 @@ public:
   }
   static void generate_test_instances(std::list<pg_missing_set*>& o) {
     o.push_back(new pg_missing_set);
+    o.back()->may_include_deletes = true;
     o.push_back(new pg_missing_set);
     o.back()->add(
       hobject_t(object_t("foo"), "foo", 123, 456, 0, ""),
       eversion_t(5, 6), eversion_t(5, 1), false);
+    o.back()->may_include_deletes = true;
     o.push_back(new pg_missing_set);
     o.back()->add(
       hobject_t(object_t("foo"), "foo", 123, 456, 0, ""),