]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
btrfs: use helper to find first ref head at btrfs_destroy_delayed_refs()
authorFilipe Manana <fdmanana@suse.com>
Fri, 18 Oct 2024 10:29:37 +0000 (11:29 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 11 Nov 2024 13:34:20 +0000 (14:34 +0100)
Instead of open coding it, use the find_first_ref_head() helper at
btrfs_destroy_delayed_refs(). This avoids duplicating the logic,
specially with the upcoming changes in subsequent patches.

Reviewed-by: Boris Burkov <boris@bur.io>
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
fs/btrfs/delayed-ref.c

index e8291316c68353544fd7055f370e0619368f65b2..dc3a29f3c3577a739106ccb8fb64d6920e3f59be 100644 (file)
@@ -1241,18 +1241,19 @@ bool btrfs_find_delayed_tree_ref(struct btrfs_delayed_ref_head *head,
 
 void btrfs_destroy_delayed_refs(struct btrfs_transaction *trans)
 {
-       struct rb_node *node;
        struct btrfs_delayed_ref_root *delayed_refs = &trans->delayed_refs;
        struct btrfs_fs_info *fs_info = trans->fs_info;
 
        spin_lock(&delayed_refs->lock);
-       while ((node = rb_first_cached(&delayed_refs->href_root)) != NULL) {
+       while (true) {
                struct btrfs_delayed_ref_head *head;
                struct rb_node *n;
                bool pin_bytes = false;
 
-               head = rb_entry(node, struct btrfs_delayed_ref_head,
-                               href_node);
+               head = find_first_ref_head(delayed_refs);
+               if (!head)
+                       break;
+
                if (btrfs_delayed_ref_lock(delayed_refs, head))
                        continue;