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
This commit is contained in:
Bananymous 2026-01-11 04:00:04 +02:00
parent 5637b8602b
commit cae2b3bd14
1 changed files with 3 additions and 6 deletions

View File

@ -61,13 +61,13 @@ namespace Kernel
const uint32_t inode_blocks_per_fs_block = blksize() / 512; const uint32_t inode_blocks_per_fs_block = blksize() / 512;
const uint32_t indices_per_fs_block = blksize() / sizeof(uint32_t); const uint32_t indices_per_fs_block = blksize() / sizeof(uint32_t);
if (block == 0 && !allocate)
return BAN::Optional<uint32_t>();
if (depth == 0) if (depth == 0)
{ {
if (block == 0) if (block == 0)
{ {
if (!allocate)
return BAN::Optional<uint32_t>();
block = TRY(m_fs.reserve_free_block(block_group())); block = TRY(m_fs.reserve_free_block(block_group()));
m_inode.blocks += inode_blocks_per_fs_block; m_inode.blocks += inode_blocks_per_fs_block;
@ -87,9 +87,6 @@ namespace Kernel
TRY(m_fs.read_block(block, block_buffer)); TRY(m_fs.read_block(block, block_buffer));
else else
{ {
if (!allocate)
return BAN::Optional<uint32_t>();
block = TRY(m_fs.reserve_free_block(block_group())); block = TRY(m_fs.reserve_free_block(block_group()));
m_inode.blocks += inode_blocks_per_fs_block; m_inode.blocks += inode_blocks_per_fs_block;