]> git.baikalelectronics.ru Git - kernel.git/commitdiff
btrfs: make btrfs_release_delayed_iref handle the !iref case
authorJosef Bacik <josef@toxicpanda.com>
Fri, 21 May 2021 20:44:07 +0000 (16:44 -0400)
committerDavid Sterba <dsterba@suse.com>
Mon, 21 Jun 2021 13:19:05 +0000 (15:19 +0200)
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: Josef Bacik <josef@toxicpanda.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/delayed-inode.c

index 1a88f6214ebc013e6d84e01c33f6648b457c7df3..bbef8c8305377e24e6b4bbc9c227d3a6888f994a 100644 (file)
@@ -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 @@ again:
        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);