Message ID | 20200304161830.2360-2-josef@toxicpanda.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | relocation error handling fixes | expand |
On 2020/3/5 上午12:18, Josef Bacik wrote: > 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. > > Signed-off-by: Josef Bacik <josef@toxicpanda.com> Reviewed-by: Qu Wenruo <wqu@suse.com> Thanks, Qu > --- > fs/btrfs/relocation.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c > index 4fb7e3cc2aca..507361e99316 100644 > --- a/fs/btrfs/relocation.c > +++ b/fs/btrfs/relocation.c > @@ -1244,7 +1244,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); >
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 4fb7e3cc2aca..507361e99316 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -1244,7 +1244,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);
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. Signed-off-by: Josef Bacik <josef@toxicpanda.com> --- fs/btrfs/relocation.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)