diff options
| author | Filipe Manana <[email protected]> | 2025-03-25 17:26:37 +0000 |
|---|---|---|
| committer | David Sterba <[email protected]> | 2025-05-15 12:30:40 +0000 |
| commit | c4669e4a8b660143ad1fc9743dcb2a3d81a74b42 (patch) | |
| tree | 4881c2c3dfe646b92b7b2fa2b110fda733612c36 /fs/btrfs/extent-io-tree.c | |
| parent | btrfs: allow folios to be released while ordered extent is finishing (diff) | |
| download | kernel-c4669e4a8b660143ad1fc9743dcb2a3d81a74b42.tar.gz kernel-c4669e4a8b660143ad1fc9743dcb2a3d81a74b42.zip | |
btrfs: pass a pointer to get_range_bits() to cache first search result
Allow get_range_bits() to take an extent state pointer to pointer argument
so that we can cache the first extent state record in the target range, so
that a caller can use it for subsequent operations without doing a full
tree search. Currently the only user is try_release_extent_state(), which
then does a call to __clear_extent_bit() which can use such a cached state
record.
Signed-off-by: Filipe Manana <[email protected]>
Reviewed-by: David Sterba <[email protected]>
Signed-off-by: David Sterba <[email protected]>
Diffstat (limited to 'fs/btrfs/extent-io-tree.c')
| -rw-r--r-- | fs/btrfs/extent-io-tree.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/fs/btrfs/extent-io-tree.c b/fs/btrfs/extent-io-tree.c index 14510a71a8fd..7ae24a533404 100644 --- a/fs/btrfs/extent-io-tree.c +++ b/fs/btrfs/extent-io-tree.c @@ -1752,14 +1752,26 @@ bool test_range_bit_exists(struct extent_io_tree *tree, u64 start, u64 end, u32 return bitset; } -void get_range_bits(struct extent_io_tree *tree, u64 start, u64 end, u32 *bits) +void get_range_bits(struct extent_io_tree *tree, u64 start, u64 end, u32 *bits, + struct extent_state **cached_state) { struct extent_state *state; + /* + * The cached state is currently mandatory and not used to start the + * search, only to cache the first state record found in the range. + */ + ASSERT(cached_state != NULL); + ASSERT(*cached_state == NULL); + *bits = 0; spin_lock(&tree->lock); state = tree_search(tree, start); + if (state && state->start < end) { + *cached_state = state; + refcount_inc(&state->refs); + } while (state) { if (state->start > end) break; |
