Files
rustfs/crates
Zhengchao An 073bc96756 fix(filemeta): compute header signature instead of hardcoding zero (#4343)
The xl.meta version header `signature` was hardcoded to `[0,0,0,0]` on the
write path (`From<FileMetaVersion> for FileMetaVersionHeader`), and the
existing `get_signature` implementations only hashed `version_id` + `mod_time`
(+ `size`), so two versions that share a version_id and mod_time but differ in
body (e.g. a PutObjectTagging that reached only some disks) produced identical
headers. Such divergence was undetectable and unhealable in the strict merge
path (backlog#861, B12).

Compute a real signature over the full version body, mirroring MinIO's
`xlMetaV2Version.getSignature` semantics:

- Fill the signature on the write path via the `From` impl (covers
  add_version / set_idx / update_object_version).
- `MetaObject::get_signature` / `MetaDeleteMarker::get_signature` now clone the
  body, zero the per-disk `erasure_index`, fold `meta_user` / `meta_sys` in
  with order-independent hashes (msgpack map order is not stable across disks),
  marshal the rest and xxh64 it, then fold 64->32 bits. Empty vs all-empty
  PartETags are normalized alike.
- Invalid/bodyless versions return an `err` sentinel rather than all-zero, so
  they never collide with a real all-zero legacy signature.

Backward compatibility: the decode path preserves stored signature bytes, and
the normal (non-strict) merge path already zeroes signatures before grouping,
so existing all-zero xl.meta stays consistent across disks. Only strict
merge/heal compares signatures, where legacy data is uniformly zero (no split)
and genuine partial-write divergence is now correctly detected.

Adds unit tests covering: non-zero signature on write, erasure_index
independence, tag/metadata/size divergence detection, map-order independence,
PartETags normalization, delete-marker divergence, and the err sentinel.
2026-07-07 09:40:28 +08:00
..