]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
btrfs: drop block from cache on error in relocation
authorJosef Bacik <josef@toxicpanda.com>
Wed, 4 Mar 2020 16:18:23 +0000 (11:18 -0500)
committerStefan Bader <stefan.bader@canonical.com>
Tue, 5 May 2020 10:32:22 +0000 (12:32 +0200)
BugLink: https://bugs.launchpad.net/bugs/1873481
commit 8e19c9732ad1d127b5575a10f4fbcacf740500ff upstream.

If we have an error while building the backref tree in relocation we'll
process all the pending edges and then free the node.  However if we
integrated some edges into the cache we'll lose our link to those edges
by simply freeing this node, which means we'll leak memory and
references to any roots that we've found.

Instead we need to use remove_backref_node(), which walks through all of
the edges that are still linked to this node and free's them up and
drops any root references we may be holding.

CC: stable@vger.kernel.org # 4.9+
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Josef Bacik <josef@toxicpanda.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>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kelsey Skunberg <kelsey.skunberg@canonical.com>
fs/btrfs/relocation.c

index 84c15311c676ba5c26d0f81de106641c0d869d25..72ef93fea1fbeceab94933a857942c3983de7528 100644 (file)
@@ -1186,7 +1186,7 @@ out:
                        free_backref_node(cache, lower);
                }
 
-               free_backref_node(cache, node);
+               remove_backref_node(cache, node);
                return ERR_PTR(err);
        }
        ASSERT(!node || !node->detached);