Commit a4cb90dc authored by Josef Bacik's avatar Josef Bacik Committed by David Sterba

btrfs: make btrfs_release_delayed_iref handle the !iref case

Right now we only cleanup the delayed iref if we have
BTRFS_DELAYED_NODE_DEL_IREF set on the node.  However we have some error
conditions that need to cleanup the iref if it still exists, so to make
this code cleaner move the test_bit into btrfs_release_delayed_iref
itself and unconditionally call it in each of the cases instead.
Signed-off-by: default avatarJosef Bacik <josef@toxicpanda.com>
Reviewed-by: default avatarDavid Sterba <dsterba@suse.com>
Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
parent eb3b5053
......@@ -974,14 +974,16 @@ static void btrfs_release_delayed_inode(struct btrfs_delayed_node *delayed_node)
static void btrfs_release_delayed_iref(struct btrfs_delayed_node *delayed_node)
{
struct btrfs_delayed_root *delayed_root;
ASSERT(delayed_node->root);
clear_bit(BTRFS_DELAYED_NODE_DEL_IREF, &delayed_node->flags);
delayed_node->count--;
if (test_and_clear_bit(BTRFS_DELAYED_NODE_DEL_IREF, &delayed_node->flags)) {
struct btrfs_delayed_root *delayed_root;
delayed_root = delayed_node->root->fs_info->delayed_root;
finish_one_item(delayed_root);
ASSERT(delayed_node->root);
delayed_node->count--;
delayed_root = delayed_node->root->fs_info->delayed_root;
finish_one_item(delayed_root);
}
}
static int __btrfs_update_delayed_inode(struct btrfs_trans_handle *trans,
......@@ -1024,7 +1026,7 @@ static int __btrfs_update_delayed_inode(struct btrfs_trans_handle *trans,
btrfs_mark_buffer_dirty(leaf);
if (!test_bit(BTRFS_DELAYED_NODE_DEL_IREF, &node->flags))
goto no_iref;
goto out;
path->slots[0]++;
if (path->slots[0] >= btrfs_header_nritems(leaf))
......@@ -1046,7 +1048,6 @@ static int __btrfs_update_delayed_inode(struct btrfs_trans_handle *trans,
btrfs_del_item(trans, root, path);
out:
btrfs_release_delayed_iref(node);
no_iref:
btrfs_release_path(path);
err_out:
btrfs_delayed_inode_release_metadata(fs_info, node, (ret < 0));
......@@ -1898,8 +1899,7 @@ static void __btrfs_kill_delayed_node(struct btrfs_delayed_node *delayed_node)
btrfs_release_delayed_item(prev_item);
}
if (test_bit(BTRFS_DELAYED_NODE_DEL_IREF, &delayed_node->flags))
btrfs_release_delayed_iref(delayed_node);
btrfs_release_delayed_iref(delayed_node);
if (test_bit(BTRFS_DELAYED_NODE_INODE_DIRTY, &delayed_node->flags)) {
btrfs_delayed_inode_release_metadata(fs_info, delayed_node, false);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment