]> git.baikalelectronics.ru Git - kernel.git/commit
btrfs: restart relocate_tree_blocks properly
authorJosef Bacik <josef@toxicpanda.com>
Fri, 13 Mar 2020 21:17:07 +0000 (17:17 -0400)
committerDavid Sterba <dsterba@suse.com>
Mon, 23 Mar 2020 16:03:51 +0000 (17:03 +0100)
commitf1c608534a3dffccb8b549fc198da15f67e6b364
tree661da4508b6cda5d8655b7ef4639bda9f0a05b1f
parent8f542fbe19ff9368092acd79240103850d4f437d
btrfs: restart relocate_tree_blocks properly

There are two bugs here, but fixing them independently would just result
in pain if you happened to bisect between the two patches.

First is how we handle the -EAGAIN from relocate_tree_block().  We don't
set error, unless we happen to be the first node, which makes no sense,
I have no idea what the code was trying to accomplish here.

We in fact _do_ want err set here so that we know we need to restart in
relocate_block_group().  Also we need finish_pending_nodes() to not
actually call link_to_upper(), because we didn't actually relocate the
block.

And then if we do get -EAGAIN we do not want to set our backref cache
last_trans to the one before ours.  This would force us to update our
backref cache if we didn't cross transaction ids, which would mean we'd
have some nodes updated to their new_bytenr, but still able to find
their old bytenr because we're searching the same commit root as the
last time we went through relocate_tree_blocks.

Fixing these two things keeps us from panicing when we start breaking
out of relocate_tree_blocks() either for delayed ref flushing or enospc.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/relocation.c