From patchwork Thu Oct 24 16:24:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13849377 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 793F31F81A7 for ; Thu, 24 Oct 2024 16:24:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729787076; cv=none; b=HITTgC/1P3nR+3Jf59yVpFI9jvjbqQTaRX8yDjW/ahfeV4W2LjGBZ82hWRO4wJCYjPijQXN3LLl0+e6R2xYGDrVQIr88qPMsG0n7SkL5B7u+0f8QEr9o2Rn4VoUSE5roxXW+XAAM3EYUSINVeHtdi4kfhkv25S4hVuZZARPReF0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729787076; c=relaxed/simple; bh=yd0jgbeMZD0ObYBXMD/TjqkrwO/GNR4bI1bELLEoihA=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OEt9o5CQQsUwejjDofdgwU5HCrlE7hunvUHs3qCF2nPZLhEWG7q2M0a2vHUy4aHyjhd5uYgCbAnb3k0hCV4OR+TdGX7vt0PMK8O7ntXaTs+Mmq+foeX9j9YXcl6Z4VZx5u+hWa8jrVxoRZVUaEKHi0YVNsO1eygNJb/e3KGiciw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=VW4q5u+n; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="VW4q5u+n" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8ABC5C4CEE3 for ; Thu, 24 Oct 2024 16:24:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729787076; bh=yd0jgbeMZD0ObYBXMD/TjqkrwO/GNR4bI1bELLEoihA=; h=From:To:Subject:Date:In-Reply-To:References:From; b=VW4q5u+nacsfIU3MQ8pZaMDmHV+N/WsWJ5CUY+VLX8GTQhXxNqQ5Cz4ZrAF2HfP0t G0bJMfReYXMmjmc+CjcHoe+/x+lsBp7uiGgzP0NUg7CbbiZT7paUu4nI/c5kpr3VUa Gj7b5P2cdMCnny9pHjYXNvQ5EWEggQRLkwkwML9e0uym+p1DzVGwfEQYGVzyhClakK 9e+0pS1Ka2A+eqW0GzwSjlL1tgAQnSboKHXg7FX5ZWsP/TLvMTyppgXoaEgYYZ9z4t eoMRyYkKHhJOAwAHFHLZLOs1L8kAQ51TsthGNVOI93BOlXZR1Xm4+O9jm6MJvttiW7 qAc4hvbnkMU7Q== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH 06/18] btrfs: use helper to find first ref head at btrfs_destroy_delayed_refs() Date: Thu, 24 Oct 2024 17:24:14 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana 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. Signed-off-by: Filipe Manana --- fs/btrfs/delayed-ref.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c index db834268faef..2b2273296246 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;