mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 15:38:10 +00:00
Kernel/Ext2FS: Surface Vector allocation failures in block allocation
This commit is contained in:
parent
1f18558ee2
commit
bd37840cf5
1 changed files with 3 additions and 4 deletions
|
@ -1294,15 +1294,15 @@ bool Ext2FS::write_ext2_inode(InodeIndex inode, const ext2_inode& e2inode)
|
||||||
|
|
||||||
auto Ext2FS::allocate_blocks(GroupIndex preferred_group_index, size_t count) -> KResultOr<Vector<BlockIndex>>
|
auto Ext2FS::allocate_blocks(GroupIndex preferred_group_index, size_t count) -> KResultOr<Vector<BlockIndex>>
|
||||||
{
|
{
|
||||||
MutexLocker locker(m_lock);
|
|
||||||
dbgln_if(EXT2_DEBUG, "Ext2FS: allocate_blocks(preferred group: {}, count {})", preferred_group_index, count);
|
dbgln_if(EXT2_DEBUG, "Ext2FS: allocate_blocks(preferred group: {}, count {})", preferred_group_index, count);
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return Vector<BlockIndex> {};
|
return Vector<BlockIndex> {};
|
||||||
|
|
||||||
Vector<BlockIndex> blocks;
|
Vector<BlockIndex> blocks;
|
||||||
dbgln_if(EXT2_DEBUG, "Ext2FS: allocate_blocks:");
|
if (!blocks.try_ensure_capacity(count))
|
||||||
blocks.ensure_capacity(count);
|
return ENOMEM;
|
||||||
|
|
||||||
|
MutexLocker locker(m_lock);
|
||||||
auto group_index = preferred_group_index;
|
auto group_index = preferred_group_index;
|
||||||
|
|
||||||
if (!group_descriptor(preferred_group_index).bg_free_blocks_count) {
|
if (!group_descriptor(preferred_group_index).bg_free_blocks_count) {
|
||||||
|
@ -1310,7 +1310,6 @@ auto Ext2FS::allocate_blocks(GroupIndex preferred_group_index, size_t count) ->
|
||||||
}
|
}
|
||||||
|
|
||||||
while (blocks.size() < count) {
|
while (blocks.size() < count) {
|
||||||
|
|
||||||
bool found_a_group = false;
|
bool found_a_group = false;
|
||||||
if (group_descriptor(group_index).bg_free_blocks_count) {
|
if (group_descriptor(group_index).bg_free_blocks_count) {
|
||||||
found_a_group = true;
|
found_a_group = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue