public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: fdmanana@kernel.org
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 07/11] btrfs: remove wake parameter from clear_state_bit()
Date: Mon, 16 Mar 2026 16:14:10 +0000	[thread overview]
Message-ID: <96fe9129f85ed910d38bd02b0e046e23db4a4cd6.1773676775.git.fdmanana@suse.com> (raw)
In-Reply-To: <cover.1773676775.git.fdmanana@suse.com>

From: Filipe Manana <fdmanana@suse.com>

There's no need to pass the 'wake' parameter, we can determine if we have
to wake up waiters by checking if EXTENT_LOCK_BITS is set in the bits to
clear. So simplify things and remove the parameter.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
 fs/btrfs/extent-io-tree.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/fs/btrfs/extent-io-tree.c b/fs/btrfs/extent-io-tree.c
index a99e67585d64..5ffb99c258e9 100644
--- a/fs/btrfs/extent-io-tree.c
+++ b/fs/btrfs/extent-io-tree.c
@@ -550,14 +550,14 @@ static inline struct extent_state *next_search_state(struct extent_state *state,
 
 /*
  * Utility function to clear some bits in an extent state struct.  It will
- * optionally wake up anyone waiting on this state (wake == 1).
+ * optionally wake up anyone waiting on this state.
  *
  * If no bits are set on the state struct after clearing things, the
  * struct is freed and removed from the tree
  */
 static struct extent_state *clear_state_bit(struct extent_io_tree *tree,
 					    struct extent_state *state,
-					    u32 bits, int wake, u64 end,
+					    u32 bits, u64 end,
 					    struct extent_changeset *changeset)
 {
 	struct extent_state *next;
@@ -571,7 +571,7 @@ static struct extent_state *clear_state_bit(struct extent_io_tree *tree,
 	if (unlikely(ret))
 		extent_io_tree_panic(tree, state, "add_extent_changeset", ret);
 	state->state &= ~bits_to_clear;
-	if (wake)
+	if (bits & EXTENT_LOCK_BITS)
 		wake_up(&state->wq);
 	if (state->state == 0) {
 		next = next_search_state(state, end);
@@ -708,8 +708,7 @@ int btrfs_clear_extent_bit_changeset(struct extent_io_tree *tree, u64 start, u64
 			goto out;
 		}
 		if (state->end <= end) {
-			state = clear_state_bit(tree, state, bits, wake, end,
-						changeset);
+			state = clear_state_bit(tree, state, bits, end, changeset);
 			goto next;
 		}
 		if (need_resched())
@@ -777,13 +776,13 @@ int btrfs_clear_extent_bit_changeset(struct extent_io_tree *tree, u64 start, u64
 		if (wake)
 			wake_up(&state->wq);
 
-		clear_state_bit(tree, prealloc, bits, wake, end, changeset);
+		clear_state_bit(tree, prealloc, bits, end, changeset);
 
 		prealloc = NULL;
 		goto out;
 	}
 
-	state = clear_state_bit(tree, state, bits, wake, end, changeset);
+	state = clear_state_bit(tree, state, bits, end, changeset);
 next:
 	if (last_end >= end)
 		goto out;
@@ -1422,7 +1421,7 @@ int btrfs_convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
 	if (state->start == start && state->end <= end) {
 		set_state_bits(tree, state, bits, NULL);
 		cache_state(state, cached_state);
-		state = clear_state_bit(tree, state, clear_bits, 0, end, NULL);
+		state = clear_state_bit(tree, state, clear_bits, end, NULL);
 		if (last_end >= end)
 			goto out;
 		start = last_end + 1;
@@ -1461,7 +1460,7 @@ int btrfs_convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
 		if (state->end <= end) {
 			set_state_bits(tree, state, bits, NULL);
 			cache_state(state, cached_state);
-			state = clear_state_bit(tree, state, clear_bits, 0, end, NULL);
+			state = clear_state_bit(tree, state, clear_bits, end, NULL);
 			if (last_end >= end)
 				goto out;
 			start = last_end + 1;
@@ -1546,7 +1545,7 @@ int btrfs_convert_extent_bit(struct extent_io_tree *tree, u64 start, u64 end,
 
 		set_state_bits(tree, prealloc, bits, NULL);
 		cache_state(prealloc, cached_state);
-		clear_state_bit(tree, prealloc, clear_bits, 0, end, NULL);
+		clear_state_bit(tree, prealloc, clear_bits, end, NULL);
 		prealloc = NULL;
 		goto out;
 	}
-- 
2.47.2


  parent reply	other threads:[~2026-03-16 16:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-16 16:14 [PATCH 00/11] btrfs: some optimizations and cleanups for io trees fdmanana
2026-03-16 16:14 ` [PATCH 01/11] btrfs: optimize clearing all bits from the last extent record in an io tree fdmanana
2026-03-16 16:14 ` [PATCH 02/11] btrfs: turn extent_io_tree_panic() into a macro for better error reporting fdmanana
2026-03-16 16:14 ` [PATCH 03/11] btrfs: tag as unlikely branches that call extent_io_tree_panic() fdmanana
2026-03-16 16:14 ` [PATCH 04/11] btrfs: make add_extent_changeset() only return errors or success fdmanana
2026-03-16 16:14 ` [PATCH 05/11] btrfs: use extent_io_tree_panic() instead of BUG_ON() fdmanana
2026-03-16 16:14 ` [PATCH 06/11] btrfs: change last argument of add_extent_changeset() to boolean fdmanana
2026-03-16 16:14 ` fdmanana [this message]
2026-03-16 16:14 ` [PATCH 08/11] btrfs: avoid unnecessary wake ups on io trees when there are no waiters fdmanana
2026-03-16 16:14 ` [PATCH 09/11] btrfs: free cached state outside critical section in wait_extent_bit() fdmanana
2026-03-16 16:14 ` [PATCH 10/11] btrfs: panic instead of warn when splitting extent state not in the tree fdmanana
2026-03-16 16:14 ` [PATCH 11/11] btrfs: optimize clearing all bits from first extent record in an io tree fdmanana
2026-03-18 11:02 ` [PATCH 00/11] btrfs: some optimizations and cleanups for io trees 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=96fe9129f85ed910d38bd02b0e046e23db4a4cd6.1773676775.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