mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-25 19:42:19 +00:00
Btrfs: re-add root to dead root list if we stop dropping it
commit d29a9f629e upstream.
If we stop dropping a root for whatever reason we need to add it back to the
dead root list so that we will re-start the dropping next transaction commit.
The other case this happens is if we recover a drop because we will add a root
without adding it to the fs radix tree, so we can leak it's root and commit root
extent buffer, adding this to the dead root list makes this cleanup happen.
Thanks,
Reported-by: Alex Lyakas <alex.btrfs@zadarastorage.com>
Signed-off-by: Josef Bacik <jbacik@fusionio.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
14e8656589
commit
0183a8ee8c
@@ -7298,6 +7298,7 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
|
||||
int err = 0;
|
||||
int ret;
|
||||
int level;
|
||||
bool root_dropped = false;
|
||||
|
||||
path = btrfs_alloc_path();
|
||||
if (!path) {
|
||||
@@ -7473,12 +7474,22 @@ int btrfs_drop_snapshot(struct btrfs_root *root,
|
||||
free_extent_buffer(root->commit_root);
|
||||
kfree(root);
|
||||
}
|
||||
root_dropped = true;
|
||||
out_end_trans:
|
||||
btrfs_end_transaction_throttle(trans, tree_root);
|
||||
out_free:
|
||||
kfree(wc);
|
||||
btrfs_free_path(path);
|
||||
out:
|
||||
/*
|
||||
* So if we need to stop dropping the snapshot for whatever reason we
|
||||
* need to make sure to add it back to the dead root list so that we
|
||||
* keep trying to do the work later. This also cleans up roots if we
|
||||
* don't have it in the radix (like when we recover after a power fail
|
||||
* or unmount) so we don't leak memory.
|
||||
*/
|
||||
if (root_dropped == false)
|
||||
btrfs_add_dead_root(root);
|
||||
if (err)
|
||||
btrfs_std_error(root->fs_info, err);
|
||||
return err;
|
||||
|
||||
Reference in New Issue
Block a user