From: fdmanana@kernel.org
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 04/11] btrfs: make add_extent_changeset() only return errors or success
Date: Mon, 16 Mar 2026 16:14:07 +0000 [thread overview]
Message-ID: <02445b0a42cdedd284e1c87cfe2f4e4d8ae9aff8.1773676775.git.fdmanana@suse.com> (raw)
In-Reply-To: <cover.1773676775.git.fdmanana@suse.com>
From: Filipe Manana <fdmanana@suse.com>
Currently add_extent_changeset() always returns the return value from its
call to ulist_add(), which can return an error, 0 or 1. There are no
callers that care about the difference between 0 and 1 and all except one
of them, check for negative values and ignore other values, but there is
another caller (btrfs_clear_extent_bit_changeset()) that must set its
'ret' variable to 0 after calling add_extent_changeset(), so that it
does not return an unexpected value of 1 to its caller.
So change add_extent_changeset() to only return errors or 0, avoiding
that caller (and any future callers) from having to deal with a return
value of 1.
Signed-off-by: Filipe Manana <fdmanana@suse.com>
---
fs/btrfs/extent-io-tree.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/fs/btrfs/extent-io-tree.c b/fs/btrfs/extent-io-tree.c
index 93dca9199249..5972fe28716e 100644
--- a/fs/btrfs/extent-io-tree.c
+++ b/fs/btrfs/extent-io-tree.c
@@ -187,6 +187,8 @@ static int add_extent_changeset(struct extent_state *state, u32 bits,
struct extent_changeset *changeset,
int set)
{
+ int ret;
+
if (!changeset)
return 0;
if (set && (state->state & bits) == bits)
@@ -195,7 +197,10 @@ static int add_extent_changeset(struct extent_state *state, u32 bits,
return 0;
changeset->bytes_changed += state->end - state->start + 1;
- return ulist_add(&changeset->range_changed, state->start, state->end, GFP_ATOMIC);
+ ret = ulist_add(&changeset->range_changed, state->start, state->end, GFP_ATOMIC);
+ if (ret < 0)
+ return ret;
+ return 0;
}
static inline struct extent_state *next_state(struct extent_state *state)
@@ -745,7 +750,6 @@ int btrfs_clear_extent_bit_changeset(struct extent_io_tree *tree, u64 start, u64
"add_extent_changeset", ret);
goto out;
}
- ret = 0;
if (tree->owner == IO_TREE_INODE_IO)
btrfs_clear_delalloc_extent(tree->inode, state, bits);
--
2.47.2
next prev 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 ` fdmanana [this message]
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 ` [PATCH 07/11] btrfs: remove wake parameter from clear_state_bit() fdmanana
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=02445b0a42cdedd284e1c87cfe2f4e4d8ae9aff8.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