From: Filipe Manana Date: Fri, 18 Oct 2024 10:29:37 +0000 (+0100) Subject: btrfs: use helper to find first ref head at btrfs_destroy_delayed_refs() X-Git-Tag: v6.13-rc1~213^2~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=055903c4e7fa2945b1b4014726e7268056047242;p=thirdparty%2Flinux.git btrfs: use helper to find first ref head at btrfs_destroy_delayed_refs() 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 Reviewed-by: Qu Wenruo Signed-off-by: Filipe Manana Reviewed-by: David Sterba Signed-off-by: David Sterba --- diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c index e8291316c6835..dc3a29f3c3577 100644 --- a/fs/btrfs/delayed-ref.c +++ b/fs/btrfs/delayed-ref.c @@ -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;