diff options
| author | Filipe Manana <fdmanana@suse.com> | 2026-09-18 12:24:37 +0100 |
|---|---|---|
| committer | David Sterba <dsterba@suse.com> | 2026-10-12 19:16:22 +0200 |
| commit | 1b934cad5c0e025e85f76aafec6edf55795b5252 (patch) | |
| tree | a8abb1bf44ca120900f779fd868ecda3aef6a1c1 /tools/perf/scripts/python/stackcollapse.py | |
| parent | 7884a8f3279c28ff990e2eacd5c2479bb1c930d0 (diff) | |
| download | linux-1b934cad5c0e025e85f76aafec6edf55795b5252.tar.gz linux-1b934cad5c0e025e85f76aafec6edf55795b5252.zip | |
btrfs: fix barrier usage in btrfs_record_root_in_trans()
The barrier usage in btrfs_record_root_in_trans() is wrong, as the writer
side, in record_root_in_trans(), sets BTRFS_ROOT_IN_TRANS_SETUP, does a
write barrier and then sets the root's last transaction. This means the
reader side must check the root's last transaction, issue a read barrier
and then check for BTRFS_ROOT_IN_TRANS_SETUP. However, currently we issue
a read barrier and then check the root's last transaction and the bit
BTRFS_ROOT_IN_TRANS_SETUP, which can be problematic because the CPU is
free to reorder the checks and the following can happen:
1) Before reading the root's last_trans, it checks that
BTRFS_ROOT_IN_TRANS_SETUP is not set.
2) A writer sets BTRFS_ROOT_IN_TRANS_SETUP, does smp_wmb() and updates
the root's last_trans.
3) The reader then sees the root's last_trans matches the current
transaction and falsely concludes the root setup is completes and
returns without waiting for the writer task to complete the setup
(calling btrfs_init_reloc_root()).
So fix the reading ordered as previously described: check the root's
last_trans, issue read barrier and then check BTRFS_ROOT_IN_TRANS_SETUP
(the reverse of what the writer side does).
Assisted-by: LLM
Reviewed-by: Boris Burkov <boris@bur.io>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'tools/perf/scripts/python/stackcollapse.py')
0 files changed, 0 insertions, 0 deletions
