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>
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;
}
#define darray_exit(_d) \
do { \
- kfree((_d)->data); \
+ kvfree((_d)->data); \
darray_init(_d); \
} while (0)