Skip to content

Commit

Permalink
btrfs: drop block from cache on error in relocation
Browse files Browse the repository at this point in the history
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: [email protected] # 4.9+
Reviewed-by: Qu Wenruo <[email protected]>
Signed-off-by: Josef Bacik <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

Signed-off-by: John Vincent <[email protected]>
Signed-off-by: John Vincent <[email protected]>
  • Loading branch information
josefbacik authored and ravindu644 committed Mar 29, 2024
1 parent 510dce8 commit ea09d07
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion fs/btrfs/relocation.c
Original file line number Diff line number Diff line change
Expand Up @@ -1194,7 +1194,7 @@ struct backref_node *build_backref_tree(struct reloc_control *rc,
free_backref_node(cache, lower);
}

free_backref_node(cache, node);
remove_backref_node(cache, node);
return ERR_PTR(err);
}
ASSERT(!node || !node->detached);
Expand Down

0 comments on commit ea09d07

Please sign in to comment.