Skip to content
  • Filipe Manana's avatar
    Btrfs: fix racy system chunk allocation when setting block group ro · a9629596
    Filipe Manana authored
    If while setting a block group read-only we end up allocating a system
    chunk, through check_system_chunk(), we were not doing it while holding
    the chunk mutex which is a problem if a concurrent chunk allocation is
    happening, through do_chunk_alloc(), as it means both block groups can
    end up using the same logical addresses and physical regions in the
    device(s). So make sure we hold the chunk mutex.
    
    Cc: stable@vger.kernel.org  # 4.0+
    Fixes: 2f081088
    
     ("btrfs: delete chunk allocation attemp when
                          setting block group ro")
    
    Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
    Signed-off-by: default avatarChris Mason <clm@fb.com>
    a9629596