All of lore.kernel.org
 help / color / mirror / Atom feed
From: fdmanana@kernel.org
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 03/11] btrfs: remove pointless in_tree field from struct btrfs_delayed_ref_node
Date: Mon, 29 May 2023 16:16:59 +0100	[thread overview]
Message-ID: <18656b6d56a9813f52f3594637ab3acb31e129ba.1685363099.git.fdmanana@suse.com> (raw)
In-Reply-To: <cover.1685363099.git.fdmanana@suse.com>

From: Filipe Manana <fdmanana@suse.com>

The 'in_tree' field is really not needed in struct btrfs_delayed_ref_node,
as we can check whether a reference is in the tree or not simply by
checking its red black tree node member with RB_EMPTY_NODE(), as when we
remove it from the tree we always call RB_CLEAR_NODE(). So remove that
field and use RB_EMPTY_NODE().

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/delayed-ref.c | 2 --
 fs/btrfs/delayed-ref.h | 3 +--
 fs/btrfs/disk-io.c     | 1 -
 fs/btrfs/extent-tree.c | 1 -
 4 files changed, 1 insertion(+), 6 deletions(-)

diff --git a/fs/btrfs/delayed-ref.c b/fs/btrfs/delayed-ref.c
index be1d18ec5cef..d6dce5792c0f 100644
--- a/fs/btrfs/delayed-ref.c
+++ b/fs/btrfs/delayed-ref.c
@@ -407,7 +407,6 @@ static inline void drop_delayed_ref(struct btrfs_delayed_ref_root *delayed_refs,
 	RB_CLEAR_NODE(&ref->ref_node);
 	if (!list_empty(&ref->add_list))
 		list_del(&ref->add_list);
-	ref->in_tree = 0;
 	btrfs_put_delayed_ref(ref);
 	atomic_dec(&delayed_refs->num_entries);
 }
@@ -853,7 +852,6 @@ static void init_delayed_ref_common(struct btrfs_fs_info *fs_info,
 	ref->num_bytes = num_bytes;
 	ref->ref_mod = 1;
 	ref->action = action;
-	ref->in_tree = 1;
 	ref->seq = seq;
 	ref->type = ref_type;
 	RB_CLEAR_NODE(&ref->ref_node);
diff --git a/fs/btrfs/delayed-ref.h b/fs/btrfs/delayed-ref.h
index 77b3e735772d..9b103bf27185 100644
--- a/fs/btrfs/delayed-ref.h
+++ b/fs/btrfs/delayed-ref.h
@@ -48,7 +48,6 @@ struct btrfs_delayed_ref_node {
 
 	unsigned int action:8;
 	unsigned int type:8;
-	unsigned int in_tree:1;
 };
 
 struct btrfs_delayed_extent_op {
@@ -341,7 +340,7 @@ static inline void btrfs_put_delayed_ref(struct btrfs_delayed_ref_node *ref)
 {
 	WARN_ON(refcount_read(&ref->refs) == 0);
 	if (refcount_dec_and_test(&ref->refs)) {
-		WARN_ON(ref->in_tree);
+		WARN_ON(!RB_EMPTY_NODE(&ref->ref_node));
 		switch (ref->type) {
 		case BTRFS_TREE_BLOCK_REF_KEY:
 		case BTRFS_SHARED_BLOCK_REF_KEY:
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 96f144094af6..793f7e48d62e 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -4849,7 +4849,6 @@ static int btrfs_destroy_delayed_refs(struct btrfs_transaction *trans,
 		while ((n = rb_first_cached(&head->ref_tree)) != NULL) {
 			ref = rb_entry(n, struct btrfs_delayed_ref_node,
 				       ref_node);
-			ref->in_tree = 0;
 			rb_erase_cached(&ref->ref_node, &head->ref_tree);
 			RB_CLEAR_NODE(&ref->ref_node);
 			if (!list_empty(&ref->add_list))
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 4f7ac5a5d29e..0aa775ac31e4 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -1913,7 +1913,6 @@ static int btrfs_run_delayed_refs_for_head(struct btrfs_trans_handle *trans,
 			return -EAGAIN;
 		}
 
-		ref->in_tree = 0;
 		rb_erase_cached(&ref->ref_node, &locked_ref->ref_tree);
 		RB_CLEAR_NODE(&ref->ref_node);
 		if (!list_empty(&ref->add_list))
-- 
2.34.1


  parent reply	other threads:[~2023-05-29 15:17 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-29 15:16 [PATCH 00/11] btrfs: some delayed refs optimizations and cleanups fdmanana
2023-05-29 15:16 ` [PATCH 01/11] btrfs: reorder some members of struct btrfs_delayed_ref_head fdmanana
2023-05-29 15:16 ` [PATCH 02/11] btrfs: remove unused is_head field from struct btrfs_delayed_ref_node fdmanana
2023-05-29 15:16 ` fdmanana [this message]
2023-05-29 15:17 ` [PATCH 04/11] btrfs: use a bool to track qgroup record insertion when adding ref head fdmanana
2023-05-29 15:17 ` [PATCH 05/11] btrfs: make insert_delayed_ref() return a bool instead of an int fdmanana
2023-05-29 15:17 ` [PATCH 06/11] btrfs: get rid of label and goto at insert_delayed_ref() fdmanana
2023-05-29 15:17 ` [PATCH 07/11] btrfs: assert correct lock is held at btrfs_select_ref_head() fdmanana
2023-05-29 15:17 ` [PATCH 08/11] btrfs: use bool type for delayed ref head fields that are used as booleans fdmanana
2023-05-29 15:17 ` [PATCH 09/11] btrfs: use a single switch statement when initializing delayed ref head fdmanana
2023-05-29 15:17 ` [PATCH 10/11] btrfs: remove unnecessary prototype declarations at disk-io.c fdmanana
2023-05-29 15:17 ` [PATCH 11/11] btrfs: make btrfs_destroy_delayed_refs() return void fdmanana
2023-05-30 15:03   ` David Sterba
2023-05-30 16:01     ` Filipe Manana
2023-05-30 15:04 ` [PATCH 00/11] btrfs: some delayed refs optimizations and cleanups David Sterba

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18656b6d56a9813f52f3594637ab3acb31e129ba.1685363099.git.fdmanana@suse.com \
    --to=fdmanana@kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.