]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
include/denc: Add protection against bumping up compat
authorAdam Kupczyk <akupczyk@ibm.com>
Thu, 6 Jun 2024 18:10:45 +0000 (18:10 +0000)
committerAdam Kupczyk <akupczyk@ibm.com>
Tue, 25 Jun 2024 06:47:27 +0000 (06:47 +0000)
Added protection against bumping up compat until U_____ release (SQUID+2)

Signed-off-by: Adam Kupczyk <akupczyk@ibm.com>
src/include/denc.h
src/osd/osd_types.h
src/test/test_denc.cc

index 623e4639cb57f6a4637ee1b4807fada31d8519f3..1ebc395e70ee46946bdebdd7409a1a0a90cb4a2b 100644 (file)
@@ -51,6 +51,7 @@
 
 #include "common/convenience.h"
 #include "common/error_code.h"
+#include "ceph_ver.h"
 
 template<typename T, typename=void>
 struct denc_traits {
@@ -1845,11 +1846,26 @@ inline std::enable_if_t<traits::supported && !traits::featured> decode_nohead(
 // Helpers for versioning the encoding.  These correspond to the
 // {ENCODE,DECODE}_{START,FINISH} macros.
 
+// DENC_START interface suggests it is checking compatibility,
+// but the feature was unimplemented until SQUID.
+// Due to -2 compatibility rule we cannot bump up compat until U____ release.
+
 #define DENC_START(v, compat, p)                                       \
   __u8 struct_v = v;                                                   \
   __u8 struct_compat = compat;                                         \
   char *_denc_pchar;                                                   \
   uint32_t _denc_u32;                                                  \
+  static_assert(CEPH_RELEASE >= 21 || compat == 1);                    \
+  _denc_start(p, &struct_v, &struct_compat, &_denc_pchar, &_denc_u32); \
+  do {
+
+// For the only type that is with compat 2, osd_reqid_t, and unittest.
+#define DENC_START_COMPAT_2(v, compat, p)                              \
+  __u8 struct_v = v;                                                   \
+  __u8 struct_compat = compat;                                         \
+  char *_denc_pchar;                                                   \
+  uint32_t _denc_u32;                                                  \
+  static_assert(CEPH_RELEASE >= 21 || compat == 2);                    \
   _denc_start(p, &struct_v, &struct_compat, &_denc_pchar, &_denc_u32); \
   do {
 
index a82b167b571ca0588b92084ea7c7bd749fda54e1..ee814f29678a406306909f5ccaf58b6068dc384e 100644 (file)
@@ -164,7 +164,7 @@ struct osd_reqid_t {
   {}
 
   DENC(osd_reqid_t, v, p) {
-    DENC_START(2, 2, p);
+    DENC_START_COMPAT_2(2, 2, p);
     denc(v.name, p);
     denc(v.tid, p);
     denc(v.inc, p);
index 46dfe67e9eeef968441d96080e6480127e56e2f2..02dd1454ef8cc6782fc226117867705c5cbfe562 100644 (file)
@@ -375,7 +375,7 @@ struct foo2_only2_t {
   uint32_t c = 55;
 
   DENC(foo2_only2_t, v, p) {
-    DENC_START(2, 2, p);
+    DENC_START_COMPAT_2(2, 2, p);
     ::denc(v.a, p);
     ::denc(v.b, p);
     ::denc(v.c, p);