encoding: allow users to specify a different compatv after encoding

This way we can set the compatv preferentially depending on whether
we've actually encoded new information or not.

Signed-off-by: Greg Farnum <greg@inktank.com>
This commit is contained in:
Greg Farnum 2013-11-20 17:04:26 -08:00 committed by Sage Weil
parent d2963c0a3d
commit 0d4ea9f746

View File

@ -708,6 +708,8 @@ inline void decode(std::deque<T>& ls, bufferlist::iterator& p)
__u8 struct_v = v, struct_compat = compat; \
::encode(struct_v, bl); \
::encode(struct_compat, bl); \
buffer::list::iterator struct_compat_it = bl.end(); \
struct_compat_it.advance(-1); \
ceph_le32 struct_len; \
struct_len = 0; \
::encode(struct_len, bl); \
@ -719,11 +721,18 @@ inline void decode(std::deque<T>& ls, bufferlist::iterator& p)
* finish encoding block
*
* @param bl bufferlist we were encoding to
* @param new_struct_compat struct-compat value to use
*/
#define ENCODE_FINISH(bl) \
#define ENCODE_FINISH_NEW_COMPAT(bl, new_struct_compat) \
} while (false); \
struct_len = bl.length() - struct_len_it.get_off() - sizeof(struct_len); \
struct_len_it.copy_in(4, (char *)&struct_len);
struct_len_it.copy_in(4, (char *)&struct_len); \
if (new_struct_compat) { \
struct_compat = new_struct_compat; \
struct_compat_it.copy_in(1, (char *)&struct_compat); \
}
#define ENCODE_FINISH(bl) ENCODE_FINISH_NEW_COMPAT(bl, 0)
#define DECODE_ERR_VERSION(func, v) \
"" #func " unknown encoding version > " #v