mirror of
https://github.com/rustfs/rustfs.git
synced 2026-07-27 16:48:58 +00:00
f96314a1d5
bitrot_shard_file_size only counts per-block checksum bytes for the two streaming Highway variants, while BitrotWriter::write interleaves a hash for any hash_algo.size() > 0 and bitrot_verify's read loop assumes an interleaved hash per block. The three disagree for non-streaming algorithms (SHA256/HighwayHash256/BLAKE2b512/Md5), but the divergence is unreachable in production: every write path hardcodes HighwayHash256S and ErasureInfo::get_checksum_info defaults to HighwayHash256S. Per the audit decision (backlog#959), do NOT change the size formula: it is a byte-for-byte port of MinIO's bitrotShardFileSize and its bare return for non-streaming algorithms is correct for MinIO whole-file bitrot; changing it would break legacy interop. Instead, document the per-algorithm layout contract at bitrot_shard_file_size, BitrotWriter, and bitrot_verify, and add regression tests that pin the invariants: get_checksum_info defaults to HighwayHash256S, and the size formula counts per-block hash bytes for streaming variants only while returning the bare size for non-streaming ones. No disk layout or formula change. Co-authored-by: heihutu <heihutu@gmail.com>