diff options
author | Josef Bacik <josef@toxicpanda.com> | 2020-02-28 14:59:22 -0500 |
---|---|---|
committer | Josef Bacik <josef@toxicpanda.com> | 2020-02-28 14:59:22 -0500 |
commit | 1e2d2400f3b5322e23ef819913ba79fef9dde7da (patch) | |
tree | 6d32e4e0d20a50f1c7ae51bd381e8632061814b7 | |
parent | bfacd1b8bf312264bd511d58f7dd980734bcf9b0 (diff) | |
download | btrfs-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.c | 3 |
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)) |