Revert "btrfs: call __btrfs_remove_free_space_cache_locked on cache load failure"
This reverts commit3ea7c50339which is commit8a1ae2781dupstream. It causes many reported btrfs issues, so revert it for now. Cc: Josef Bacik <josef@toxicpanda.com> Cc: David Sterba <dsterba@suse.com> Cc: Sasha Levin <sashal@kernel.org> Reported-by: Tobias Powalowski <tobias.powalowski@googlemail.com> Link: https://lore.kernel.org/r/CAHfPjO8G1Tq2iJDhPry-dPj1vQZRh4NYuRmhHByHgu7_2rQkrQ@mail.gmail.com Reported-by: Ernst Herzberg <earny@net4u.de> Link: https://lore.kernel.org/r/8196dd88-4e11-78a7-8f96-20cf3e886e68@net4u.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
+20
-33
@@ -48,25 +48,6 @@ static void bitmap_clear_bits(struct btrfs_free_space_ctl *ctl,
|
||||
struct btrfs_free_space *info, u64 offset,
|
||||
u64 bytes, bool update_stats);
|
||||
|
||||
static void __btrfs_remove_free_space_cache_locked(
|
||||
struct btrfs_free_space_ctl *ctl)
|
||||
{
|
||||
struct btrfs_free_space *info;
|
||||
struct rb_node *node;
|
||||
|
||||
while ((node = rb_last(&ctl->free_space_offset)) != NULL) {
|
||||
info = rb_entry(node, struct btrfs_free_space, offset_index);
|
||||
if (!info->bitmap) {
|
||||
unlink_free_space(ctl, info, true);
|
||||
kmem_cache_free(btrfs_free_space_cachep, info);
|
||||
} else {
|
||||
free_bitmap(ctl, info);
|
||||
}
|
||||
|
||||
cond_resched_lock(&ctl->tree_lock);
|
||||
}
|
||||
}
|
||||
|
||||
static struct inode *__lookup_free_space_inode(struct btrfs_root *root,
|
||||
struct btrfs_path *path,
|
||||
u64 offset)
|
||||
@@ -900,14 +881,7 @@ out:
|
||||
return ret;
|
||||
free_cache:
|
||||
io_ctl_drop_pages(&io_ctl);
|
||||
|
||||
/*
|
||||
* We need to call the _locked variant so we don't try to update the
|
||||
* discard counters.
|
||||
*/
|
||||
spin_lock(&ctl->tree_lock);
|
||||
__btrfs_remove_free_space_cache_locked(ctl);
|
||||
spin_unlock(&ctl->tree_lock);
|
||||
__btrfs_remove_free_space_cache(ctl);
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -1033,13 +1007,7 @@ int load_free_space_cache(struct btrfs_block_group *block_group)
|
||||
if (ret == 0)
|
||||
ret = 1;
|
||||
} else {
|
||||
/*
|
||||
* We need to call the _locked variant so we don't try to update
|
||||
* the discard counters.
|
||||
*/
|
||||
spin_lock(&tmp_ctl.tree_lock);
|
||||
__btrfs_remove_free_space_cache(&tmp_ctl);
|
||||
spin_unlock(&tmp_ctl.tree_lock);
|
||||
btrfs_warn(fs_info,
|
||||
"block group %llu has wrong amount of free space",
|
||||
block_group->start);
|
||||
@@ -3002,6 +2970,25 @@ static void __btrfs_return_cluster_to_free_space(
|
||||
btrfs_put_block_group(block_group);
|
||||
}
|
||||
|
||||
static void __btrfs_remove_free_space_cache_locked(
|
||||
struct btrfs_free_space_ctl *ctl)
|
||||
{
|
||||
struct btrfs_free_space *info;
|
||||
struct rb_node *node;
|
||||
|
||||
while ((node = rb_last(&ctl->free_space_offset)) != NULL) {
|
||||
info = rb_entry(node, struct btrfs_free_space, offset_index);
|
||||
if (!info->bitmap) {
|
||||
unlink_free_space(ctl, info, true);
|
||||
kmem_cache_free(btrfs_free_space_cachep, info);
|
||||
} else {
|
||||
free_bitmap(ctl, info);
|
||||
}
|
||||
|
||||
cond_resched_lock(&ctl->tree_lock);
|
||||
}
|
||||
}
|
||||
|
||||
void __btrfs_remove_free_space_cache(struct btrfs_free_space_ctl *ctl)
|
||||
{
|
||||
spin_lock(&ctl->tree_lock);
|
||||
|
||||
Reference in New Issue
Block a user