]> git.baikalelectronics.ru Git - kernel.git/commit
Btrfs: fix race deleting block group from space_info->ro_bgs list
authorFilipe Manana <fdmanana@suse.com>
Fri, 16 Jan 2015 13:24:40 +0000 (13:24 +0000)
committerChris Mason <clm@fb.com>
Mon, 19 Jan 2015 21:05:45 +0000 (13:05 -0800)
commit3c746e24cf715a47701fd6284eb1a1190d6351d9
tree90744350470ba845aa065952de640cbaf52bddd3
parentb8e89d9070920099dd44725ec6aee5b2877f65d6
Btrfs: fix race deleting block group from space_info->ro_bgs list

When removing a block group we were deleting it from its space_info's
ro_bgs list without the correct protection - the space info's spinlock.
Fix this by doing the list delete while holding the spinlock of the
corresponding space info, which is the correct lock for any operation
on that list.

This issue was introduced in the 3.19 kernel by the following change:

    Btrfs: move read only block groups onto their own list V2
    commit 90857de7e96d0e49aab55f3d50f8c55da450b6ae

I ran into a kernel crash while a task was running statfs, which iterates
the space_info->ro_bgs list while holding the space info's spinlock,
and another task was deleting it from the same list, without holding that
spinlock, as part of the block group remove operation (while running the
function btrfs_remove_block_group). This happened often when running the
stress test xfstests/generic/038 I recently made.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
fs/btrfs/ctree.h
fs/btrfs/extent-tree.c