diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-11-16 19:44:48 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-01-01 11:46:52 -0500 |
commit | a58a6a58f5ad55aa1f5c54598c44f1d9938c1793 (patch) | |
tree | 01c129d85febc80b3057b91f07cc34826bd4225a | |
parent | 73ab9e03861c22ec6723b7b110d62ba60f37c164 (diff) | |
download | lwn-a58a6a58f5ad55aa1f5c54598c44f1d9938c1793.tar.gz lwn-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>
-rw-r--r-- | fs/bcachefs/darray.c | 4 | ||||
-rw-r--r-- | fs/bcachefs/darray.h | 2 |
2 files changed, 4 insertions, 2 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; } diff --git a/fs/bcachefs/darray.h b/fs/bcachefs/darray.h index 43ea21ad9ea3..6157c53d5bf0 100644 --- a/fs/bcachefs/darray.h +++ b/fs/bcachefs/darray.h @@ -92,7 +92,7 @@ do { \ #define darray_exit(_d) \ do { \ - kfree((_d)->data); \ + kvfree((_d)->data); \ darray_init(_d); \ } while (0) |