Linux Btrfs filesystem development
 help / color / mirror / Atom feed
From: fdmanana@kernel.org
To: linux-btrfs@vger.kernel.org
Subject: [PATCH v2 08/15] btrfs: remove unused logic when looking up delayed items
Date: Mon, 22 Aug 2022 11:51:37 +0100	[thread overview]
Message-ID: <870a360c38df7f4331bb583545efae4c9f756b3a.1661165149.git.fdmanana@suse.com> (raw)
In-Reply-To: <cover.1661165149.git.fdmanana@suse.com>

From: Filipe Manana <fdmanana@suse.com>

All callers pass NULL to the 'prev' and 'next' arguments of the function
__btrfs_lookup_delayed_item(), so remove these arguments. Also, remove
the unnecessary wrapper __btrfs_lookup_delayed_insertion_item(), making
btrfs_delete_delayed_insertion_item() directly call
__btrfs_lookup_delayed_item().

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/delayed-inode.c | 45 +++-------------------------------------
 1 file changed, 3 insertions(+), 42 deletions(-)

diff --git a/fs/btrfs/delayed-inode.c b/fs/btrfs/delayed-inode.c
index cd2f3a8c4dfd..a8947ac00681 100644
--- a/fs/btrfs/delayed-inode.c
+++ b/fs/btrfs/delayed-inode.c
@@ -322,28 +322,20 @@ static struct btrfs_delayed_item *btrfs_alloc_delayed_item(u32 data_len,
  * __btrfs_lookup_delayed_item - look up the delayed item by key
  * @delayed_node: pointer to the delayed node
  * @index:	  the dir index value to lookup (offset of a dir index key)
- * @prev:	  used to store the prev item if the right item isn't found
- * @next:	  used to store the next item if the right item isn't found
  *
  * Note: if we don't find the right item, we will return the prev item and
  * the next item.
  */
 static struct btrfs_delayed_item *__btrfs_lookup_delayed_item(
 				struct rb_root *root,
-				u64 index,
-				struct btrfs_delayed_item **prev,
-				struct btrfs_delayed_item **next)
+				u64 index)
 {
-	struct rb_node *node, *prev_node = NULL;
+	struct rb_node *node = root->rb_node;
 	struct btrfs_delayed_item *delayed_item = NULL;
-	int ret = 0;
-
-	node = root->rb_node;
 
 	while (node) {
 		delayed_item = rb_entry(node, struct btrfs_delayed_item,
 					rb_node);
-		prev_node = node;
 		if (delayed_item->index < index)
 			node = node->rb_right;
 		else if (delayed_item->index > index)
@@ -352,40 +344,9 @@ static struct btrfs_delayed_item *__btrfs_lookup_delayed_item(
 			return delayed_item;
 	}
 
-	if (prev) {
-		if (!prev_node)
-			*prev = NULL;
-		else if (ret < 0)
-			*prev = delayed_item;
-		else if ((node = rb_prev(prev_node)) != NULL) {
-			*prev = rb_entry(node, struct btrfs_delayed_item,
-					 rb_node);
-		} else
-			*prev = NULL;
-	}
-
-	if (next) {
-		if (!prev_node)
-			*next = NULL;
-		else if (ret > 0)
-			*next = delayed_item;
-		else if ((node = rb_next(prev_node)) != NULL) {
-			*next = rb_entry(node, struct btrfs_delayed_item,
-					 rb_node);
-		} else
-			*next = NULL;
-	}
 	return NULL;
 }
 
-static struct btrfs_delayed_item *__btrfs_lookup_delayed_insertion_item(
-					struct btrfs_delayed_node *delayed_node,
-					u64 index)
-{
-	return __btrfs_lookup_delayed_item(&delayed_node->ins_root.rb_root, index,
-					   NULL, NULL);
-}
-
 static int __btrfs_add_delayed_item(struct btrfs_delayed_node *delayed_node,
 				    struct btrfs_delayed_item *ins)
 {
@@ -1549,7 +1510,7 @@ static int btrfs_delete_delayed_insertion_item(struct btrfs_fs_info *fs_info,
 	struct btrfs_delayed_item *item;
 
 	mutex_lock(&node->mutex);
-	item = __btrfs_lookup_delayed_insertion_item(node, index);
+	item = __btrfs_lookup_delayed_item(&node->ins_root.rb_root, index);
 	if (!item) {
 		mutex_unlock(&node->mutex);
 		return 1;
-- 
2.35.1


  parent reply	other threads:[~2022-08-22 10:52 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-17 11:22 [PATCH 00/15] btrfs: some updates to delayed items and inode logging fdmanana
2022-08-17 11:22 ` [PATCH 01/15] btrfs: don't drop dir index range items when logging a directory fdmanana
2022-08-17 11:22 ` [PATCH 02/15] btrfs: remove the root argument from log_new_dir_dentries() fdmanana
2022-08-17 11:22 ` [PATCH 03/15] btrfs: update stale comment for log_new_dir_dentries() fdmanana
2022-08-17 11:22 ` [PATCH 04/15] btrfs: free list element sooner at log_new_dir_dentries() fdmanana
2022-08-17 11:22 ` [PATCH 05/15] btrfs: avoid memory allocation at log_new_dir_dentries() for common case fdmanana
2022-08-17 11:22 ` [PATCH 06/15] btrfs: remove root argument from btrfs_delayed_item_reserve_metadata() fdmanana
2022-08-17 11:22 ` [PATCH 07/15] btrfs: store index number instead of key in struct btrfs_delayed_item fdmanana
2022-08-17 11:22 ` [PATCH 08/15] btrfs: remove unused logic when looking up delayed items fdmanana
2022-08-17 11:22 ` [PATCH 09/15] btrfs: shrink the size of struct btrfs_delayed_item fdmanana
2022-08-22 13:43   ` David Sterba
2022-08-22 14:15     ` Filipe Manana
2022-08-22 15:29       ` David Sterba
2022-08-22 16:00         ` Filipe Manana
2022-08-17 11:22 ` [PATCH 10/15] btrfs: search for last logged dir index if it's not cached in the inode fdmanana
2022-08-17 11:22 ` [PATCH 11/15] btrfs: move need_log_inode() to above log_conflicting_inodes() fdmanana
2022-08-17 11:22 ` [PATCH 12/15] btrfs: move log_new_dir_dentries() above btrfs_log_inode() fdmanana
2022-08-17 11:22 ` [PATCH 13/15] btrfs: log conflicting inodes without holding log mutex of the initial inode fdmanana
2022-08-17 11:22 ` [PATCH 14/15] btrfs: skip logging parent dir when conflicting inode is not a dir fdmanana
2022-08-17 11:22 ` [PATCH 15/15] btrfs: use delayed items when logging a directory fdmanana
2022-08-22 10:51 ` [PATCH v2 00/15] btrfs: some updates to delayed items and inode logging fdmanana
2022-08-22 10:51   ` [PATCH v2 01/15] btrfs: don't drop dir index range items when logging a directory fdmanana
2022-08-22 10:51   ` [PATCH v2 02/15] btrfs: remove the root argument from log_new_dir_dentries() fdmanana
2022-08-22 10:51   ` [PATCH v2 03/15] btrfs: update stale comment for log_new_dir_dentries() fdmanana
2022-08-22 10:51   ` [PATCH v2 04/15] btrfs: free list element sooner at log_new_dir_dentries() fdmanana
2022-08-22 10:51   ` [PATCH v2 05/15] btrfs: avoid memory allocation at log_new_dir_dentries() for common case fdmanana
2022-08-22 10:51   ` [PATCH v2 06/15] btrfs: remove root argument from btrfs_delayed_item_reserve_metadata() fdmanana
2022-08-22 10:51   ` [PATCH v2 07/15] btrfs: store index number instead of key in struct btrfs_delayed_item fdmanana
2022-08-22 10:51   ` fdmanana [this message]
2022-08-22 10:51   ` [PATCH v2 09/15] btrfs: shrink the size of " fdmanana
2022-08-22 10:51   ` [PATCH v2 10/15] btrfs: search for last logged dir index if it's not cached in the inode fdmanana
2022-08-22 10:51   ` [PATCH v2 11/15] btrfs: move need_log_inode() to above log_conflicting_inodes() fdmanana
2022-08-22 10:51   ` [PATCH v2 12/15] btrfs: move log_new_dir_dentries() above btrfs_log_inode() fdmanana
2022-08-22 10:51   ` [PATCH v2 13/15] btrfs: log conflicting inodes without holding log mutex of the initial inode fdmanana
2022-08-22 10:51   ` [PATCH v2 14/15] btrfs: skip logging parent dir when conflicting inode is not a dir fdmanana
2022-08-22 10:51   ` [PATCH v2 15/15] btrfs: use delayed items when logging a directory fdmanana
2022-08-22 15:45   ` [PATCH v2 00/15] btrfs: some updates to delayed items and inode logging 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=870a360c38df7f4331bb583545efae4c9f756b3a.1661165149.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox