Join GitHub today
Checksums and Their Use in ZFS
End-to-end checksums are a key feature of ZFS and an important differentiator for ZFS over other RAID implementations and filesystems. Advantages of end-to-end checksums include:
- detects data corruption upon reading from media
- blocks that are detected as corrupt are automatically repaired if possible, by
using the RAID protection in suitably configured pools, or redundant copies (see
- periodic scrubs can check data to detect and repair latent media degradation (bit rot) and corruption from other sources
- checksums on ZFS replication streams,
zfs receive, ensure the data received is not corrupted by intervening storage or transport mechanisms
The checksum algorithms in ZFS can be changed for datasets (filesystems or volumes). The checksum algorithm used for each block is stored in the block pointer (metadata). The block checksum is calculated when the block is written, so changing the algorithm only affects writes occurring after the change.
The checksum algorithm for a dataset can be changed by setting the
zfs set checksum=sha256 pool_name/dataset_name
|Checksum||Ok for dedup and nopwrite?||Compatible with other ZFS implementations?||Notes|
|off||no||yes||Do not do use
|fletcher2||no||yes||Deprecated implementation of Fletcher checksum, use
|fletcher4||no||yes||Fletcher algorithm, also used for
|sha256||yes||yes||Default for deduped datasets|
|noparity||no||yes||Do not use
|sha512||yes||requires pool feature
|skein||yes||requires pool feature
|edonr||yes||requires pool feature
ZFS has the ability to offload checksum operations to the Intel QuickAssist Technology (QAT) adapters.
Some ZFS features use microbenchmarks when the
zfs.ko kernel module is loaded
to determine the optimal algorithm for checksums. The results of the microbenchmarks
are observable in the
/proc/spl/kstat/zfs directory. The winning algorithm is
reported as the "fastest" and becomes the default. The default can be overridden
by setting zfs module parameters.
While it may be tempting to disable checksums to improve CPU performance, it is widely considered by the ZFS community to be an extrodinarily bad idea. Don't disable checksums.