From: Kefu Chai Date: Mon, 21 Jul 2025 01:28:20 +0000 (+0800) Subject: osd: recalculate coll_t::_str during decode() to fix stale values X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d01003ec50412f828de64767dec84ead8ad5bb96;p=ceph.git osd: recalculate coll_t::_str during decode() to fix stale values Fix compatibility issue where coll_t::_str retained stale values after decoding v1/v2 format blobs, causing confusing debug output and tool messages. The _str field was not recalculated when decoding older formats: - v1 format (pre-Ceph v0.21, before commit a108774e) - v2 format (meta/regular PGs) - v3 format always includes _str (temp PGs) This primarily affected debugging scenarios since _str is only used for log messages and BlueStore low-level tool output. The issue went undetected because existing tests reused struct instances, preserving field values across encode/decode cycles. An upcoming test change will allocate fresh instances for each decode, which would expose these stale values. Since _str can be derived from always-encoded fields, recalculate it during decode() when missing from the encoded data. Signed-off-by: Kefu Chai --- diff --git a/src/osd/osd_types.cc b/src/osd/osd_types.cc index 3e04c28f31fb..7ad3d815429b 100644 --- a/src/osd/osd_types.cc +++ b/src/osd/osd_types.cc @@ -1051,6 +1051,8 @@ void coll_t::decode(ceph::buffer::list::const_iterator& bl) type = TYPE_PG; } removal_seq = 0; + // recalculate _str, which is not encoded by v1 + calc_str(); } break; @@ -1063,6 +1065,8 @@ void coll_t::decode(ceph::buffer::list::const_iterator& bl) decode(snap, bl); type = (type_t)_type; removal_seq = 0; + // recalculate _str, which is not encoded by v2 + calc_str(); } break;