]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
bcachefs: Switch darray to kvmalloc()
authorKent Overstreet <kent.overstreet@linux.dev>
Fri, 17 Nov 2023 00:44:48 +0000 (19:44 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 1 Jan 2024 16:46:52 +0000 (11:46 -0500)
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>
fs/bcachefs/darray.c
fs/bcachefs/darray.h

index aae07be1d911dee203ae440d77d415875a3d5256..4c900c8532688fd7be902585ce531a822577804f 100644 (file)
@@ -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;
        }
index 43ea21ad9ea338931e0cb7a54d13bf9f50874b77..6157c53d5bf044516f2373c972275b5df215d26b 100644 (file)
@@ -92,7 +92,7 @@ do {                                                                  \
 
 #define darray_exit(_d)                                                        \
 do {                                                                   \
-       kfree((_d)->data);                                              \
+       kvfree((_d)->data);                                             \
        darray_init(_d);                                                \
 } while (0)