From: Patrick Donnelly Date: Sat, 8 Jun 2024 19:00:27 +0000 (-0400) Subject: mds: add warning about encoding new fields X-Git-Tag: testing/wip-jcollin-testing-20240701.061036-squid~5^2~5 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=1a709427535bb2eab5d0083285fecedd64fcf21b;p=ceph-ci.git 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) --- 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);