mirror of
https://kernel.googlesource.com/pub/scm/linux/kernel/git/stable/linux-stable.git
synced 2025-10-03 21:39:54 +10:00
btrfs: error on missing block group when unaccounting log tree extent buffers
commit fc5799986f
upstream.
Currently we only log an error message if we can't find the block group
for a log tree extent buffer when unaccounting it (while freeing a log
tree). A missing block group means something is seriously wrong and we
end up leaking space from the metadata space info. So return -ENOENT in
case we don't find the block group.
CC: stable@vger.kernel.org # 6.12+
Reviewed-by: Boris Burkov <boris@bur.io>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
807c422740
commit
58e66d83e1
@ -2587,14 +2587,14 @@ static int replay_one_buffer(struct btrfs_root *log, struct extent_buffer *eb,
|
||||
/*
|
||||
* Correctly adjust the reserved bytes occupied by a log tree extent buffer
|
||||
*/
|
||||
static void unaccount_log_buffer(struct btrfs_fs_info *fs_info, u64 start)
|
||||
static int unaccount_log_buffer(struct btrfs_fs_info *fs_info, u64 start)
|
||||
{
|
||||
struct btrfs_block_group *cache;
|
||||
|
||||
cache = btrfs_lookup_block_group(fs_info, start);
|
||||
if (!cache) {
|
||||
btrfs_err(fs_info, "unable to find block group for %llu", start);
|
||||
return;
|
||||
return -ENOENT;
|
||||
}
|
||||
|
||||
spin_lock(&cache->space_info->lock);
|
||||
@ -2605,27 +2605,22 @@ static void unaccount_log_buffer(struct btrfs_fs_info *fs_info, u64 start)
|
||||
spin_unlock(&cache->space_info->lock);
|
||||
|
||||
btrfs_put_block_group(cache);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int clean_log_buffer(struct btrfs_trans_handle *trans,
|
||||
struct extent_buffer *eb)
|
||||
{
|
||||
int ret;
|
||||
|
||||
btrfs_tree_lock(eb);
|
||||
btrfs_clear_buffer_dirty(trans, eb);
|
||||
wait_on_extent_buffer_writeback(eb);
|
||||
btrfs_tree_unlock(eb);
|
||||
|
||||
if (trans) {
|
||||
ret = btrfs_pin_reserved_extent(trans, eb);
|
||||
if (ret)
|
||||
return ret;
|
||||
} else {
|
||||
unaccount_log_buffer(eb->fs_info, eb->start);
|
||||
}
|
||||
if (trans)
|
||||
return btrfs_pin_reserved_extent(trans, eb);
|
||||
|
||||
return 0;
|
||||
return unaccount_log_buffer(eb->fs_info, eb->start);
|
||||
}
|
||||
|
||||
static noinline int walk_down_log_tree(struct btrfs_trans_handle *trans,
|
||||
|
Loading…
Reference in New Issue
Block a user