lkml.org 
[lkml]   [2020]   [Apr]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH 5.4 067/232] btrfs: restart relocate_tree_blocks properly
    Date
    From: Josef Bacik <josef@toxicpanda.com>

    [ Upstream commit 50dbbb71c79df89532ec41d118d59386e5a877e3 ]

    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>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    fs/btrfs/relocation.c | 11 ++---------
    1 file changed, 2 insertions(+), 9 deletions(-)

    diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
    index 7ce48f1364f76..c4ed7015cc7d9 100644
    --- a/fs/btrfs/relocation.c
    +++ b/fs/btrfs/relocation.c
    @@ -3176,9 +3176,8 @@ int relocate_tree_blocks(struct btrfs_trans_handle *trans,
    ret = relocate_tree_block(trans, rc, node, &block->key,
    path);
    if (ret < 0) {
    - if (ret != -EAGAIN || &block->rb_node == rb_first(blocks))
    - err = ret;
    - goto out;
    + err = ret;
    + break;
    }
    }
    out:
    @@ -4154,12 +4153,6 @@ restart:
    if (!RB_EMPTY_ROOT(&blocks)) {
    ret = relocate_tree_blocks(trans, rc, &blocks);
    if (ret < 0) {
    - /*
    - * if we fail to relocate tree blocks, force to update
    - * backref cache when committing transaction.
    - */
    - rc->backref_cache.last_trans = trans->transid - 1;
    -
    if (ret != -EAGAIN) {
    err = ret;
    break;
    --
    2.20.1


    \
     
     \ /
      Last update: 2020-04-16 16:08    [W:4.200 / U:0.196 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site