summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorCen Zhang <zzzccc427@gmail.com>2026-05-06 22:20:46 +0800
committerDavid Sterba <dsterba@suse.com>2026-08-07 19:18:02 +0200
commitb63609b56ae6250d1be33f2d09e721101af2426a (patch)
tree37dbd250438b68c08646aba0db717ae28e23b385 /scripts
parent80ffd9dcd263f547e3b9774246250b457cdb42f6 (diff)
downloadlinux-next-b63609b56ae6250d1be33f2d09e721101af2426a.tar.gz
linux-next-b63609b56ae6250d1be33f2d09e721101af2426a.zip
btrfs: fix root-in-trans fast-path ordering
btrfs_record_root_in_trans() has a lockless fast path for shareable roots. It skips reloc_mutex when root->last_trans matches the current transaction and BTRFS_ROOT_IN_TRANS_SETUP is clear. The writer side publishes that state in two phases: it sets IN_TRANS_SETUP before updating root->last_trans, then clears the bit after btrfs_init_reloc_root() finishes. However, the reader-side smp_rmb() is before both loads, so it does not order the last_trans load against the later bit test. A reader can observe the new last_trans value while missing the setup bit and return before the relocation-root setup is complete. Read root->last_trans first, then issue the read barrier before testing IN_TRANS_SETUP. Also use clear_bit_unlock() for the writer's final clear and test_bit_acquire() for the successful fast path, so the lockless return observes the setup done before the bit was cleared. Fixes: 7585717f304f ("Btrfs: fix relocation races") Signed-off-by: Cen Zhang <zzzccc427@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'scripts')
0 files changed, 0 insertions, 0 deletions