@@ -1835,8 +1835,6 @@ struct StructVChecker
18351835 p += 2 + 4 ; \
18361836 } \
18371837 static void _denc_finish (size_t & p, \
1838- __u8 *struct_v, \
1839- __u8 *struct_compat, \
18401838 char **, uint32_t *) { } \
18411839 /* encode */ \
18421840 static void _denc_start (::ceph::buffer::list::contiguous_appender& p, \
@@ -1850,8 +1848,6 @@ struct StructVChecker
18501848 *start_oob_off = p.get_out_of_band_offset (); \
18511849 } \
18521850 static void _denc_finish (::ceph::buffer::list::contiguous_appender& p, \
1853- __u8 *struct_v, \
1854- __u8 *struct_compat, \
18551851 char **len_pos, \
18561852 uint32_t *start_oob_off) { \
18571853 *(ceph_le32*)*len_pos = p.get_pos () - *len_pos - sizeof (uint32_t ) + \
@@ -1872,7 +1868,6 @@ struct StructVChecker
18721868 *start_pos = const_cast <char *>(p.get_pos ()); \
18731869 } \
18741870 static void _denc_finish (::ceph::buffer::ptr::const_iterator& p, \
1875- __u8 *struct_v, __u8 *struct_compat, \
18761871 char **start_pos, \
18771872 uint32_t *struct_len) { \
18781873 const char *pos = p.get_pos (); \
@@ -1902,6 +1897,16 @@ struct StructVChecker
19021897 _denc_start (p, &struct_v.v , &struct_compat, &_denc_pchar, &_denc_u32); \
19031898 do {
19041899
1900+ // the variant for seldom-used cases when we manually select encoding version
1901+ #define DENC_START_UNCHECKED (_v, compat, p ) \
1902+ __u8 struct_v = _v; \
1903+ __u8 struct_compat = compat; \
1904+ char *_denc_pchar; \
1905+ uint32_t _denc_u32; \
1906+ static_assert (CEPH_RELEASE >= (CEPH_RELEASE_SQUID /* 19*/ + 2 ) || compat == 1 ); \
1907+ _denc_start (p, &struct_v, &struct_compat, &_denc_pchar, &_denc_u32); \
1908+ do {
1909+
19051910// For the only type that is with compat 2: unittest.
19061911#define DENC_START_COMPAT_2 (_v, compat, p ) \
19071912 StructVChecker<_v> struct_v{_v}; \
@@ -1912,6 +1917,16 @@ struct StructVChecker
19121917 _denc_start (p, &struct_v.v , &struct_compat, &_denc_pchar, &_denc_u32); \
19131918 do {
19141919
1920+ // This variant is unsafe, because older versions will not even catch incompatibility.
1921+ // The ability to decode must be verified by other means,
1922+ #define DENC_START_UNSAFE (v, compat, p ) \
1923+ __u8 struct_v = v; \
1924+ __u8 struct_compat = compat; \
1925+ char *_denc_pchar; \
1926+ uint32_t _denc_u32; \
1927+ _denc_start (p, &struct_v, &struct_compat, &_denc_pchar, &_denc_u32); \
1928+ do {
1929+
19151930// For osd_reqid_t which cannot be upgraded at all.
19161931// We used it to communicate with clients and now we cannot safely upgrade.
19171932#define DENC_START_OSD_REQID (_v, compat, p ) \
@@ -1925,8 +1940,7 @@ struct StructVChecker
19251940
19261941#define DENC_FINISH (p ) \
19271942 } while (false ); \
1928- _denc_finish (p, &struct_v.v , &struct_compat, &_denc_pchar, &_denc_u32);
1929-
1943+ _denc_finish (p, &_denc_pchar, &_denc_u32);
19301944
19311945// ----------------------------------------------------------------------
19321946
0 commit comments