]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: recalculate coll_t::_str during decode() to fix stale values 63938/head
authorKefu Chai <tchaikov@gmail.com>
Mon, 21 Jul 2025 01:28:20 +0000 (09:28 +0800)
committerKefu Chai <tchaikov@gmail.com>
Mon, 21 Jul 2025 02:55:29 +0000 (10:55 +0800)
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 <tchaikov@gmail.com>
src/osd/osd_types.cc

index 3e04c28f31fb6b6b9a4b9d6f0245e2d1e1805ae9..7ad3d815429b322b7564847ec590be695f73995c 100644 (file)
@@ -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;