Skip to content

Commit 25eb142

Browse files
committed
msg/Message: make {encode,decode}_trace unconditional
These are protocol features and cannot vary based on our compilation. Encode and decode unconditionally. The callers have already guarded these field additions with a message version bump and are conditionally calling decode_trace. Signed-off-by: Sage Weil <sage@redhat.com>
1 parent 60baa90 commit 25eb142

1 file changed

Lines changed: 9 additions & 10 deletions

File tree

src/msg/Message.cc

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -846,26 +846,25 @@ WRITE_RAW_ENCODER(blkin_trace_info)
846846

847847
void Message::encode_trace(bufferlist &bl, uint64_t features) const
848848
{
849-
#ifdef WITH_BLKIN
850-
if (features & CEPH_FEATURE_BLKIN_TRACING)
851-
::encode(*trace.get_info(), bl);
852-
#endif
849+
auto p = trace.get_info();
850+
static const blkin_trace_info empty = { 0, 0, 0 };
851+
if (!p) {
852+
p = &empty;
853+
}
854+
::encode(*p, bl);
853855
}
854856

855857
void Message::decode_trace(bufferlist::iterator &p, bool create)
856858
{
859+
blkin_trace_info info = {};
860+
::decode(info, p);
861+
857862
#ifdef WITH_BLKIN
858863
if (!connection)
859864
return;
860865

861866
const auto msgr = connection->get_messenger();
862867
const auto endpoint = msgr->get_trace_endpoint();
863-
blkin_trace_info info = {};
864-
865-
// only decode a trace if both sides of the connection agree
866-
if (connection->has_feature(CEPH_FEATURE_BLKIN_TRACING))
867-
::decode(info, p);
868-
869868
if (info.trace_id) {
870869
trace.init(get_type_name(), endpoint, &info, true);
871870
trace.event("decoded trace");

0 commit comments

Comments
 (0)