aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosef Bacik <josef@toxicpanda.com>2020-02-28 14:59:22 -0500
committerJosef Bacik <josef@toxicpanda.com>2020-02-28 14:59:22 -0500
commit1e2d2400f3b5322e23ef819913ba79fef9dde7da (patch)
tree6d32e4e0d20a50f1c7ae51bd381e8632061814b7
parentbfacd1b8bf312264bd511d58f7dd980734bcf9b0 (diff)
downloadbtrfs-next-1e2d2400f3b5322e23ef819913ba79fef9dde7da.tar.gz
btrfs: splice rc->reloc_roots onto reloc roots in recover
If we have an error while processing the reloc roots we could leak roots that were added to rc->reloc_roots before we hit the error. Handle this by splicing rc->reloc_roots onto our local reloc_roots list so they are properly cleaned up. Signed-off-by: Josef Bacik <josef@toxicpanda.com>
-rw-r--r--fs/btrfs/relocation.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index 173fc7628235a9..f42589cb351c2a 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -4710,6 +4710,9 @@ int btrfs_recover_relocation(struct btrfs_root *root)
if (ret < 0 && !err)
err = ret;
out_free:
+ mutex_lock(&fs_info->reloc_mutex);
+ list_splice_init(&rc->reloc_roots, &reloc_roots);
+ mutex_unlock(&fs_info->reloc_mutex);
kfree(rc);
out:
if (!list_empty(&reloc_roots))