From cae2b3bd1432bd445f95f3dd63a9ae2f83e911a0 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sun, 11 Jan 2026 04:00:04 +0200 Subject: [PATCH] Kernel: Cleanup ext2 indirect block lookup If we are not allocating and the block is null, add a fast path to delete it. This also prevents possibly blocking filesystem block wrapper allocation --- kernel/kernel/FS/Ext2/Inode.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/kernel/kernel/FS/Ext2/Inode.cpp b/kernel/kernel/FS/Ext2/Inode.cpp index 45b545b5..72e6ed14 100644 --- a/kernel/kernel/FS/Ext2/Inode.cpp +++ b/kernel/kernel/FS/Ext2/Inode.cpp @@ -61,13 +61,13 @@ namespace Kernel const uint32_t inode_blocks_per_fs_block = blksize() / 512; const uint32_t indices_per_fs_block = blksize() / sizeof(uint32_t); + if (block == 0 && !allocate) + return BAN::Optional(); + if (depth == 0) { if (block == 0) { - if (!allocate) - return BAN::Optional(); - block = TRY(m_fs.reserve_free_block(block_group())); m_inode.blocks += inode_blocks_per_fs_block; @@ -87,9 +87,6 @@ namespace Kernel TRY(m_fs.read_block(block, block_buffer)); else { - if (!allocate) - return BAN::Optional(); - block = TRY(m_fs.reserve_free_block(block_group())); m_inode.blocks += inode_blocks_per_fs_block;