Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 01eacb2

Browse files
fdmananamasoncl
authored andcommitted
Btrfs: always clear a block group node when removing it from the tree
Always clear a block group's rbnode after removing it from the rbtree to ensure that any tasks that might be holding a reference on the block group don't end up accessing stale rbnode left and right child pointers through next_block_group(). This is a leftover from the change titled: "Btrfs: fix invalid block group rbtree access after bg is removed" Signed-off-by: Filipe Manana <[email protected]> Signed-off-by: Chris Mason <[email protected]>
1 parent a1e7e16 commit 01eacb2

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

fs/btrfs/extent-tree.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8872,6 +8872,7 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info)
88728872
cache_node);
88738873
rb_erase(&block_group->cache_node,
88748874
&info->block_group_cache_tree);
8875+
RB_CLEAR_NODE(&block_group->cache_node);
88758876
spin_unlock(&info->block_group_cache_lock);
88768877

88778878
down_write(&block_group->space_info->groups_sem);
@@ -9130,6 +9131,7 @@ int btrfs_read_block_groups(struct btrfs_root *root)
91309131
spin_lock(&info->block_group_cache_lock);
91319132
rb_erase(&cache->cache_node,
91329133
&info->block_group_cache_tree);
9134+
RB_CLEAR_NODE(&cache->cache_node);
91339135
spin_unlock(&info->block_group_cache_lock);
91349136
btrfs_put_block_group(cache);
91359137
goto error;
@@ -9271,6 +9273,7 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans,
92719273
spin_lock(&root->fs_info->block_group_cache_lock);
92729274
rb_erase(&cache->cache_node,
92739275
&root->fs_info->block_group_cache_tree);
9276+
RB_CLEAR_NODE(&cache->cache_node);
92749277
spin_unlock(&root->fs_info->block_group_cache_lock);
92759278
btrfs_put_block_group(cache);
92769279
return ret;

0 commit comments

Comments
 (0)