]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: Fix deadlock caused by missing memory barrier
authorNikolay Borisov <nborisov@suse.com>
Thu, 25 Jul 2019 08:27:29 +0000 (11:27 +0300)
committerDavid Sterba <dsterba@suse.com>
Thu, 25 Jul 2019 15:34:08 +0000 (17:34 +0200)
commitef9e20e040488a8dbd0bb02fa5336dfab480fe82
treea08365bc6b1370f162158b1518061f689dc924a8
parent0697dab66a253b6ae594ccf6af73faf7c0d7695d
btrfs: Fix deadlock caused by missing memory barrier

Commit 0b8a4ab78557 ("btrfs: switch extent_buffer blocking_writers from
atomic to int") changed the type of blocking_writers but forgot to
adjust relevant code in btrfs_tree_unlock by converting the
smp_mb__after_atomic to smp_mb.  This opened up the possibility of a
deadlock due to re-ordering of setting blocking_writers and
checking/waking up the waiter. This particular lockup is explained in a
comment above waitqueue_active() function.

Fix it by converting the memory barrier to a full smp_mb, accounting
for the fact that blocking_writers is a simple integer.

Fixes: 0b8a4ab78557 ("btrfs: switch extent_buffer blocking_writers from atomic to int")
Tested-by: Johannes Thumshirn <jthumshirn@suse.com>
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/locking.c