Btrfs NODATASUM
Btrfs NODATASUM marks file data as excluded from the filesystem's data checksumming.
NODATACOW implies NODATASUM, but disabling data checksums is not synonymous with disabling copy-on-write; the mount option applies to newly created files. Metadata remains checksummed.
Data checksums live in a separate checksum tree and are verified after reads, while with NODATASUM the read path returns success without looking them up. [1] [5] Regular files get the flag from the nodatasum mount option, from nodatacow, or from a directory with NODATACOW, and chattr +C sets it only while the file is empty. [5] Compression is disabled, and deduplication requires both files to be in the same checksum and COW state. [1] [3]
In a write-amplification study a 4 KB overwrite followed by fsync wrote 32 times the user data by default, 28 times without data checksums and about 18.6 times with COW also disabled, so checksums were the smaller share of the saving. [6] A field study of 1.53 million drives over 41 months found more than 400,000 checksum mismatches, 8% of them during RAID reconstruction. [7]
Relations
Advantages
- Checksum metadata need not be updated on writes, which the manual lists as a slight performance gain. [1]
- True zero-copy direct writes remain possible, while checksummed files fall back to buffered writes in newer kernels. [1]
Limitations
- Scrub cannot checksum-validate the affected file data or use those missing checksums to select a correct mirror after silent damage. [2]
- Failing disks are not marked unreliable, so reads keep being balanced across possibly damaged replicas. [2]
Citations
- Btrfs documentation: btrfs(5), datacow/nodatacow and datasum/nodatasum
- Btrfs documentation: btrfs-scrub(8), checksum exclusions and read-only limitations
- Btrfs documentation: Deduplication, compatibility of COW files with NODATASUM
- Linux v6.12 fs/btrfs: inode.c, file-item.c and ioctl.c, NODATASUM flag handling.
- Mohan, Kadekodi, Chidambaram. Analyzing IO Amplification in Linux File Systems. 2017 (arXiv 1707.08514).
- Bairavasundaram et al. An Analysis of Data Corruption in the Storage Stack. USENIX FAST 2008.
Further reading
Sources & caveats
- The Btrfs documentation pages are rolling latest versions that mention kernel changes later than the v6.12 code, so documentation and code come from different versions.
- The documentation and kernel code are project material.
- The write-amplification figures come from one 2017 kernel and one workload (a 4 KB overwrite followed by fsync in a 100 MB file); most of the saving came from disabling copy-on-write rather than checksums.
- Arithmetic: 28 / 32 is 12.5% less written without data checksums, 18.6 / 32 is 41.9% less with COW also off, or 128, 112 and 74.4 KB per 4 KB overwrite.
- The field study of 1.53 million drives is university-led with storage-vendor co-authors, covers a different file system and says nothing about NODATASUM.
- The direct I/O and scrub statements are taken from the manual and were not tested.