Skip to content

Commit d01003e

Browse files
committed
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 a108774) - 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 <[email protected]>
1 parent bffa446 commit d01003e

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/osd/osd_types.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,8 @@ void coll_t::decode(ceph::buffer::list::const_iterator& bl)
10511051
type = TYPE_PG;
10521052
}
10531053
removal_seq = 0;
1054+
// recalculate _str, which is not encoded by v1
1055+
calc_str();
10541056
}
10551057
break;
10561058

@@ -1063,6 +1065,8 @@ void coll_t::decode(ceph::buffer::list::const_iterator& bl)
10631065
decode(snap, bl);
10641066
type = (type_t)_type;
10651067
removal_seq = 0;
1068+
// recalculate _str, which is not encoded by v2
1069+
calc_str();
10661070
}
10671071
break;
10681072

0 commit comments

Comments
 (0)