From 1a709427535bb2eab5d0083285fecedd64fcf21b Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Sat, 8 Jun 2024 15:00:27 -0400 Subject: [PATCH] mds: add warning about encoding new fields It's never a good idea to put new fields in the middle of other encoded values unless you're willing to break all backwards-compatibility. Signed-off-by: Patrick Donnelly (cherry picked from commit d27b1156ae7d38902c76ffa48b6999a779ec5da9) --- src/mds/CDentry.cc | 1 + src/mds/CDir.cc | 1 + 2 files changed, 2 insertions(+) diff --git a/src/mds/CDentry.cc b/src/mds/CDentry.cc index 8694dfc72a2..9caa7ca92eb 100644 --- a/src/mds/CDentry.cc +++ b/src/mds/CDentry.cc @@ -568,6 +568,7 @@ void CDentry::encode_remote(inodeno_t& ino, unsigned char d_type, // marker, name, ino ENCODE_START(2, 1, bl); + // WARNING: always put new fields at the end of bl encode(ino, bl); encode(d_type, bl); encode(alternate_name, bl); diff --git a/src/mds/CDir.cc b/src/mds/CDir.cc index 3828fe04d7b..ce805ea7ff5 100644 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -2500,6 +2500,7 @@ void CDir::_omap_commit_ops(int r, int op_prio, int64_t metapool, version_t vers bl.append('i'); // inode ENCODE_START(2, 1, bl); + // WARNING: always put new fields at the end of bl encode(item.alternate_name, bl); _encode_primary_inode_base(item, dfts, bl); ENCODE_FINISH(bl); -- 2.39.5