On Thu, Jul 25, 2019 at 11:27:29AM +0300, Nikolay Borisov wrote:
> Commit 06297d8cefca ("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: 06297d8cefca ("btrfs: switch extent_buffer blocking_writers from atomic to int")
> Signed-off-by: Nikolay Borisov <nborisov@xxxxxxxx>
> Tested-by: Johannes Thumshirn <jthumshirn@xxxxxxxx>
Reviewed-by: David Sterba <dsterba@xxxxxxxx>