summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/darray.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2023-11-17 01:44:48 +0100
committerKent Overstreet <kent.overstreet@linux.dev>2024-01-01 17:46:52 +0100
commita58a6a58f5ad55aa1f5c54598c44f1d9938c1793 (patch)
tree01c129d85febc80b3057b91f07cc34826bd4225a /fs/bcachefs/darray.c
parentbcachefs: Factor out darray resize slowpath (diff)
downloadlinux-a58a6a58f5ad55aa1f5c54598c44f1d9938c1793.tar.xz
linux-a58a6a58f5ad55aa1f5c54598c44f1d9938c1793.zip
bcachefs: Switch darray to kvmalloc()
We sometimes use darrays for quite large buffers - the btree write buffer in particular needs large buffers, since it must be sized to hold all the write buffer keys outstanding in the journal. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/darray.c')
-rw-r--r--fs/bcachefs/darray.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/fs/bcachefs/darray.c b/fs/bcachefs/darray.c
index aae07be1d911..4c900c853268 100644
--- a/fs/bcachefs/darray.c
+++ b/fs/bcachefs/darray.c
@@ -9,10 +9,12 @@ int __bch2_darray_resize(darray_void *d, size_t element_size, size_t new_size, g
if (new_size > d->size) {
new_size = roundup_pow_of_two(new_size);
- void *data = krealloc_array(d->data, new_size, element_size, gfp);
+ void *data = kvmalloc_array(new_size, element_size, gfp);
if (!data)
return -ENOMEM;
+ memcpy(data, d->data, d->size * element_size);
+ kvfree(d->data);
d->data = data;
d->size = new_size;
}