mirror of
https://github.com/RGBCube/serenity
synced 2025-05-15 07:34:59 +00:00
Kernel: Remove VLA usage in Ext2FS block traversal code
This was using up to 12KB of kernel stack in the triply indirect case and looks generally spooky. Let's just allocate a ByteBuffer for now and take the performance hit (of heap allocation). Longer term we can reorganize the code to reduce the majority of the heap churn.
This commit is contained in:
parent
3dbb9c8448
commit
e58a600d52
1 changed files with 4 additions and 2 deletions
|
@ -506,9 +506,11 @@ Vector<Ext2FS::BlockIndex> Ext2FSInode::compute_block_list_impl_internal(const e
|
|||
auto count = min(blocks_remaining, entries_per_block);
|
||||
if (!count)
|
||||
return;
|
||||
u32 array[count];
|
||||
size_t read_size = count * sizeof(u32);
|
||||
auto array_storage = ByteBuffer::create_uninitialized(read_size);
|
||||
auto* array = (u32*)array_storage.data();
|
||||
auto buffer = UserOrKernelBuffer::for_kernel_buffer((u8*)array);
|
||||
auto result = fs().read_block(array_block_index, &buffer, sizeof(array), 0);
|
||||
auto result = fs().read_block(array_block_index, &buffer, read_size, 0);
|
||||
if (result.is_error()) {
|
||||
// FIXME: Stop here and propagate this error.
|
||||
dbgln("Ext2FS: compute_block_list_impl_internal had error: {}", result.error());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue