diff options
| author | Rosen Penev <rosenp@gmail.com> | 2026-07-03 15:45:57 -0700 |
|---|---|---|
| committer | David Sterba <dsterba@suse.com> | 2026-08-07 19:17:17 +0200 |
| commit | f6c02cd048bd7db865a2e2d65cae78aea64444fa (patch) | |
| tree | d11478cef2c90d234f8eb9c87a796d0ad46188dd | |
| parent | 01c2f41fc441f75b3f9326443372faceb1cb6638 (diff) | |
btrfs: compression: allocate heuristic buckets with workspace
Avoid allocating the heuristic buckets separately from the workspace,
the lifetime is the same.
The new size of struct heuristic_ws is 2112. SLUB merges same/similar
sized structures for the named caches, so there's a chance such size
already exists on the system, like below:
$ grep 2112 /proc/slabinfo
sighand_cache 593 1335 2112 15 8
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
| -rw-r--r-- | fs/btrfs/compression.c | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index ffb6b52863a7..c62b5148d5ac 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -651,9 +651,9 @@ struct heuristic_ws { u8 *sample; u32 sample_size; /* Buckets store counters for each byte value */ - struct bucket_item *bucket; + struct bucket_item bucket[BUCKET_SIZE]; /* Sorting buffer */ - struct bucket_item *bucket_b; + struct bucket_item bucket_b[BUCKET_SIZE]; struct list_head list; }; @@ -664,8 +664,6 @@ static void free_heuristic_ws(struct list_head *ws) workspace = list_entry(ws, struct heuristic_ws, list); kvfree(workspace->sample); - kfree(workspace->bucket); - kfree(workspace->bucket_b); kfree(workspace); } @@ -681,14 +679,6 @@ static struct list_head *alloc_heuristic_ws(struct btrfs_fs_info *fs_info) if (!ws->sample) goto fail; - ws->bucket = kzalloc_objs(*ws->bucket, BUCKET_SIZE); - if (!ws->bucket) - goto fail; - - ws->bucket_b = kzalloc_objs(*ws->bucket_b, BUCKET_SIZE); - if (!ws->bucket_b) - goto fail; - INIT_LIST_HEAD(&ws->list); return &ws->list; fail: |
