Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

btrfs-progs: docs: add an extra note to btrfs data checksum and directIO #954

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Documentation/ch-checksumming.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,24 @@
block has an inline checksum stored in the b-tree node header. Each data block
has a detached checksum stored in the checksum tree.

.. note::
Since a data checksum is calculated just before submitting to the block
device, btrfs has a strong requirement that the coresponding data block must

Check failure on line 8 in Documentation/ch-checksumming.rst

View workflow job for this annotation

GitHub Actions / Check for spelling errors

coresponding ==> corresponding
not be modified until the writeback is finished.

This requirement is met for a buffered write as btrfs has the full control on
its page caches, but a direct write (``O_DIRECT``) bypasses page caches, and
btrfs can not control the direct IO buffer (as it can be in user space memory),
thus it's possible that a user space program modifies its direct write buffer
before the buffer is fully written back, and this can lead to a data checksum mismatch.

To avoid such a checksum mismatch, since v6.14 btrfs will force a direct
write to fall back to a buffered one, if the inode requires a data checksum.
This will bring a small performance penalty, and if the end user requires true
zero-copy direct writes, they should set the ``NODATASUM`` flag for the inode
and make sure the direct IO buffer is fully aligned to btrfs block size.


There are several checksum algorithms supported. The default and backward
compatible algorithm is *crc32c*. Since kernel 5.5 there are three more with different
characteristics and trade-offs regarding speed and strength. The following list
Expand Down