From: Adam Kupczyk Date: Thu, 6 Jun 2024 18:10:45 +0000 (+0000) Subject: include/denc: Add protection against bumping up compat X-Git-Tag: v19.1.1~100^2~5 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=ea0ef1cbce0bee226c166333e901f29160a95e14;p=ceph.git include/denc: Add protection against bumping up compat Added protection against bumping up compat until U_____ release (SQUID+2) Signed-off-by: Adam Kupczyk (cherry picked from commit c94c8baf012b66ba2fe13abbeb2f27c16c717df4) --- diff --git a/src/include/denc.h b/src/include/denc.h index 623e4639cb57f..1ebc395e70ee4 100644 --- a/src/include/denc.h +++ b/src/include/denc.h @@ -51,6 +51,7 @@ #include "common/convenience.h" #include "common/error_code.h" +#include "ceph_ver.h" template struct denc_traits { @@ -1845,11 +1846,26 @@ inline std::enable_if_t 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 { diff --git a/src/osd/osd_types.h b/src/osd/osd_types.h index 4a80101c26977..2427fc9ab10f0 100644 --- a/src/osd/osd_types.h +++ b/src/osd/osd_types.h @@ -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); diff --git a/src/test/test_denc.cc b/src/test/test_denc.cc index 46dfe67e9eeef..02dd1454ef8cc 100644 --- a/src/test/test_denc.cc +++ b/src/test/test_denc.cc @@ -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);