Ext2FS: Use cached inode block list in resize() if available

If we have already cached the block list of an Ext2FSInode, we can save
a lot of time by not regenerating it.
This commit is contained in:
Andreas Kling 2020-11-24 11:49:46 +01:00
parent 541579bc04
commit 20205708b9
Notes: sideshowbarker 2024-07-19 01:17:18 +09:00

View file

@ -772,7 +772,12 @@ KResult Ext2FSInode::resize(u64 new_size)
return KResult(-ENOSPC);
}
auto block_list = fs().block_list_for_inode(m_raw_inode);
Vector<Ext2FS::BlockIndex> block_list;
if (!m_block_list.is_empty())
block_list = m_block_list;
else
fs().block_list_for_inode(m_raw_inode);
if (blocks_needed_after > blocks_needed_before) {
auto new_blocks = fs().allocate_blocks(fs().group_index_from_inode(index()), blocks_needed_after - blocks_needed_before);
block_list.append(move(new_blocks));