diff options
| author | Qu Wenruo <wqu@suse.com> | 2026-11-05 14:51:16 +1030 |
|---|---|---|
| committer | David Sterba <dsterba@suse.com> | 2026-11-23 18:30:15 +0100 |
| commit | aec8248642ce734dcc2991c069e8edfcf90770c8 (patch) | |
| tree | abbd5dcdef5b106989bb10ad383cac8cf4cef58f /tools/perf/scripts/python/flamegraph.py | |
| parent | 356217202a30e58b02c49c1027874a13e011c822 (diff) | |
btrfs: skip fast sync for inodes with encoded writes
[BUG REPORT]
Sashiko reported a bug that encoded writes can have its file extents
recorded before their data reach disks.
[CAUSE]
An encoded write returns to the caller as soon as its bio is submitted,
and its folios are not in the inode's page cache:
btrfs_ioctl_encoded_write()
\- btrfs_do_encoded_write()
|- btrfs_alloc_ordered_extent()
\- btrfs_submit_compressed_write() <- returns before the bio ends
A fast fsync only waits for writeback of the folios in the page cache,
so it has nothing to wait for on such an ordered extent:
btrfs_sync_file()
|- btrfs_get_ordered_extents_for_logging()
|- filemap_fdatawait_range() <- no folio under writeback
\- btrfs_log_dentry_safe()
\- ...
\- log_extent_csums()
\- log_csums() <- csum_list may be in flight
This has two problems:
- fsync can return before the data of the encoded write is on disk, while
the log tree describing it is already persisted.
- With async data checksum generation, the sums are attached to
ordered->csum_list by btrfs_csum_one_bio() before the checksums are
calculated. log_extent_csums() can then log zeroed or partially
calculated checksums.
For buffered writes this is not a problem, as writeback of a folio ends
after the bio endio, which in turn runs after the checksums are
generated.
[FIX]
Fix it by requiring full sync for the inode which went through encoded
writes.
Encoded writes are mostly utilized by btrfs-receive, so it's never on
the hot path.
And received subvolumes are set read-only, so normally no one should
even call fsync() on those inodes. Thus the cost of full fsync on encoded
writes should be very acceptable.
Link: https://sashiko.dev/#/patchset/8eb322321cac98013cc46dfe8d89fa58c1ad3dee.1793766229.git.wqu%40suse.com
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'tools/perf/scripts/python/flamegraph.py')
0 files changed, 0 insertions, 0 deletions
