summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Burkov <boris@bur.io>2026-07-21 15:42:12 -0700
committerDavid Sterba <dsterba@suse.com>2026-08-07 19:17:18 +0200
commite8e7aff88e5bd35da940e249dde14393acdee98e (patch)
treed5f175dc5c440c46ba07c4b8108104eaaff3204a
parent9102b179512e11644fb0489ae62010a09afa199c (diff)
btrfs: factor init_extent_buffer from __alloc_extent_buffer
In preparation for preallocating extent_buffer data, factor eb initialization away from specifically allocating it. This allows us to allocate the eb, bfs, folios, etc. together in the main search_slot code paths, but still share initialization code with the dummy/test/clone allocation paths. Reviewed-by: Filipe Manana <fdmanana@suse.com> Signed-off-by: Boris Burkov <boris@bur.io> Reviewed-by: David Sterba <dsterba@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
-rw-r--r--fs/btrfs/extent_io.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/fs/btrfs/extent_io.c b/fs/btrfs/extent_io.c
index c7c3f138fb69..780939756f24 100644
--- a/fs/btrfs/extent_io.c
+++ b/fs/btrfs/extent_io.c
@@ -3309,12 +3309,9 @@ void btrfs_uninhibit_all_eb_writeback(struct btrfs_trans_handle *trans)
trans->inhibited_ebs_hand = 0;
}
-static struct extent_buffer *__alloc_extent_buffer(struct btrfs_fs_info *fs_info,
- u64 start)
+static void init_extent_buffer(struct btrfs_fs_info *fs_info,
+ struct extent_buffer *eb, u64 start)
{
- struct extent_buffer *eb = NULL;
-
- eb = kmem_cache_zalloc(extent_buffer_cache, GFP_NOFS|__GFP_NOFAIL);
eb->start = start;
eb->len = fs_info->nodesize;
eb->fs_info = fs_info;
@@ -3327,7 +3324,15 @@ static struct extent_buffer *__alloc_extent_buffer(struct btrfs_fs_info *fs_info
refcount_set(&eb->refs, 1);
ASSERT(eb->len <= BTRFS_MAX_METADATA_BLOCKSIZE);
+}
+
+static struct extent_buffer *__alloc_extent_buffer(struct btrfs_fs_info *fs_info,
+ u64 start)
+{
+ struct extent_buffer *eb;
+ eb = kmem_cache_zalloc(extent_buffer_cache, GFP_NOFS | __GFP_NOFAIL);
+ init_extent_buffer(fs_info, eb, start);
return eb;
}
@@ -3731,9 +3736,8 @@ struct extent_buffer *alloc_extent_buffer(struct btrfs_fs_info *fs_info,
if (eb)
return eb;
- eb = __alloc_extent_buffer(fs_info, start);
- if (!eb)
- return ERR_PTR(-ENOMEM);
+ eb = kmem_cache_zalloc(extent_buffer_cache, GFP_NOFS | __GFP_NOFAIL);
+ init_extent_buffer(fs_info, eb, start);
/*
* The reloc trees are just snapshots, so we need them to appear to be