summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python/task-analyzer.py
diff options
context:
space:
mode:
authorFilipe Manana <fdmanana@suse.com>2026-11-10 19:14:34 +0000
committerDavid Sterba <dsterba@suse.com>2026-11-23 19:47:02 +0100
commitad4bb983915d8588dc9dd3aeb60cf58aff574e3b (patch)
tree33b5bc1eb9f88d6a2dc4ef63055f8d39b2dee802 /tools/perf/scripts/python/task-analyzer.py
parent016bbc403305b3d5d61e5a1b543bd69dc7c813c3 (diff)
btrfs: fix race between concurrent sync direct IO writes
If we have a direct IO write within i_size, we lock the inode's VFS lock in shared mode, which allows for concurrent direct IO writes within different ranges of the file, which is an important optimization for many applications such as databases. However if we have a sync direct IO write within i_size, it locks the inode in shared mode and then enters fsync through the call to the iomap_dio_complete() function from iomap using the shared lock. This means that if we have another concurrent direct IO write that locks the inode in shared mode and the fsync is in fast mode (the inode flag BTRFS_INODE_NEEDS_FULL_SYNC is not set), the fsync does not wait for the ordered extent created by the concurrent direct IO write to complete before logging its extent map. The fsync code relies on direct IO writes to create ordered extents and wait for their IO to finish while holding the inode's lock, while the fsync should hold the inode lock in exclusive mode. This means that this race can end up persisting a log tree with file extent items that point to extents that were not yet written when the log is synced. Fix this by always taking the inode lock in exclusive mode if we have a sync write. This issue was identified by Sashiko in the link below, which identifies two different races between direct IO writes and fsync. The race fixed here is the second case identified by Sashiko in the link below. The first race is already being fixed in a separate patch from Josef. Link: https://sashiko.dev/#/bug/linux-ee047626-2fa7-46d5-b543-861136993fc7 Fixes: 939b656bc8ab ("btrfs: fix corruption after buffer fault in during direct IO append write") Reviewed-by: Qu Wenruo <wqu@suse.com> Signed-off-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'tools/perf/scripts/python/task-analyzer.py')
0 files changed, 0 insertions, 0 deletions