Skip to content

Commit

Permalink
Revert "btrfs: call __btrfs_remove_free_space_cache_locked on cache l…
Browse files Browse the repository at this point in the history
…oad failure"

This reverts commit 3ea7c50 which is
commit 8a1ae27 upstream.

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>
  • Loading branch information
gregkh committed Oct 26, 2022
1 parent c86103f commit 217fd75
Showing 1 changed file with 20 additions and 33 deletions.
53 changes: 20 additions & 33 deletions fs/btrfs/free-space-cache.c
Expand Up @@ -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)
Expand Down Expand Up @@ -900,14 +881,7 @@ static int __load_free_space_cache(struct btrfs_root *root, struct inode *inode,
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;
}

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 217fd75

Please sign in to comment.