]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: only encode stretch mode variables in the OSDMap when in use
authorGreg Farnum <gfarnum@redhat.com>
Tue, 21 Jul 2020 17:55:57 +0000 (17:55 +0000)
committerGreg Farnum <gfarnum@redhat.com>
Tue, 21 Jul 2020 17:59:15 +0000 (17:59 +0000)
We were previously encoding them unconditionally, but that led to
OSDMap crc mismatches between old and new daemons, which was bad.

Instead, we only set target_v to encode stretch mode when it's in use,
and we assert safety upon doing so.

Signed-off-by: Greg Farnum <gfarnum@redhat.com>
src/osd/OSDMap.cc

index 5aa14d2b0c80b3f261fa6dc0a81bedc2b1ea0bc6..73302d6fb1429589299be3e409c93172046cd82d 100644 (file)
@@ -646,13 +646,18 @@ void OSDMap::Incremental::encode(ceph::buffer::list& bl, uint64_t features) cons
   }
 
   {
-    uint8_t target_v = 10;
+    uint8_t target_v = 9; // if bumping this, be aware of stretch_mode target_v 10!
     uint8_t new_compat_v = 0;
     if (!HAVE_FEATURE(features, SERVER_LUMINOUS)) {
       target_v = 2;
     } else if (!HAVE_FEATURE(features, SERVER_NAUTILUS)) {
       target_v = 6;
     }
+    if (change_stretch_mode) {
+      ceph_assert(target_v >= 9);
+      target_v = std::max((uint8_t)10, target_v);
+      new_compat_v = std::max((uint8_t)10, std::max(new_compat_v, struct_compat));
+    }
     ENCODE_START(target_v, 1, bl); // extended, osd-only data
     if (target_v < 7) {
       encode_addrvec_map_as_addr(new_hb_back_up, bl, features);
@@ -702,10 +707,6 @@ void OSDMap::Incremental::encode(ceph::buffer::list& bl, uint64_t features) cons
       encode(new_stretch_mode_bucket, bl);
       encode(stretch_mode_enabled, bl);
     }
-    if (change_stretch_mode) {
-      ceph_assert(target_v >= 10);
-      new_compat_v = 10;
-    }
     ENCODE_FINISH_NEW_COMPAT(bl, new_compat_v); // osd-only data
   }
 
@@ -3030,7 +3031,7 @@ void OSDMap::encode(ceph::buffer::list& bl, uint64_t features) const
   {
     // NOTE: any new encoding dependencies must be reflected by
     // SIGNIFICANT_FEATURES
-    uint8_t target_v = 10;
+    uint8_t target_v = 9; // when bumping this, be aware of stretch_mode target_v 10!
     uint8_t new_compat_v = 0;
     if (!HAVE_FEATURE(features, SERVER_LUMINOUS)) {
       target_v = 1;
@@ -3039,6 +3040,11 @@ void OSDMap::encode(ceph::buffer::list& bl, uint64_t features) const
     } else if (!HAVE_FEATURE(features, SERVER_NAUTILUS)) {
       target_v = 6;
     }
+    if (stretch_mode_enabled) {
+      ceph_assert(target_v >= 9);
+      target_v = std::max((uint8_t)10, target_v);
+      new_compat_v = std::max((uint8_t)10, std::max(new_compat_v, struct_compat));
+    }
     ENCODE_START(target_v, 1, bl); // extended, osd-only data
     if (target_v < 7) {
       encode_addrvec_pvec_as_addr(osd_addrs->hb_back_addrs, bl, features);
@@ -3087,10 +3093,6 @@ void OSDMap::encode(ceph::buffer::list& bl, uint64_t features) const
     if (target_v >= 9) {
       encode(device_class_flags, bl);
     }
-    if (stretch_mode_enabled) {
-      ceph_assert(target_v >= 10);
-      new_compat_v = 10;
-    }
     if (target_v >= 10) {
       encode(stretch_mode_enabled, bl);
       encode(stretch_bucket_count, bl);