From d157553d05ac13e2bfd79a0e9b27551e07dab026 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 6722f0f2a367..5f155f999bc7 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 a8aaf11c0512..30dcd9c53938 100644 --- a/src/mds/CDir.cc +++ b/src/mds/CDir.cc @@ -2495,6 +2495,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.47.3