diff options
author | Andreas Kling <kling@serenityos.org> | 2020-11-07 16:45:03 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-11-07 16:45:03 +0100 |
commit | bab24ce34c6d48b478026ade3ee759ba4830744f (patch) | |
tree | af9b14d6a79915d89dddb1dbe7409a4d88ef97cb /Kernel | |
parent | 508063ef85d627b848b46665c98eeef5bd793808 (diff) | |
download | serenity-bab24ce34c6d48b478026ade3ee759ba4830744f.zip |
Ext2FS: Deallocate block list meta blocks when freeing an inode
When computing the list of blocks to deallocate when freeing an inode,
we would stop collecting blocks after reaching the inode's block count.
Since we're getting rid of the inode, we need to also include the meta
blocks used by the on-disk block list itself.
Diffstat (limited to 'Kernel')
-rw-r--r-- | Kernel/FileSystem/Ext2FileSystem.cpp | 8 | ||||
-rw-r--r-- | Kernel/FileSystem/Ext2FileSystem.h | 2 |
2 files changed, 8 insertions, 2 deletions
diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index e85b302e02..d991924b95 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -184,7 +184,7 @@ bool Ext2FS::find_block_containing_inode(unsigned inode, unsigned& block_index, return true; } -Ext2FS::BlockListShape Ext2FS::compute_block_list_shape(unsigned blocks) +Ext2FS::BlockListShape Ext2FS::compute_block_list_shape(unsigned blocks) const { BlockListShape shape; const unsigned entries_per_block = EXT2_ADDR_PER_BLOCK(&super_block()); @@ -440,6 +440,12 @@ Vector<Ext2FS::BlockIndex> Ext2FS::block_list_for_inode_impl(const ext2_inode& e #endif unsigned blocks_remaining = block_count; + + if (include_block_list_blocks) { + auto shape = compute_block_list_shape(block_count); + blocks_remaining += shape.meta_blocks; + } + Vector<BlockIndex> list; auto add_block = [&](BlockIndex bi) { diff --git a/Kernel/FileSystem/Ext2FileSystem.h b/Kernel/FileSystem/Ext2FileSystem.h index 7d28b84ff2..d274fb082e 100644 --- a/Kernel/FileSystem/Ext2FileSystem.h +++ b/Kernel/FileSystem/Ext2FileSystem.h @@ -165,7 +165,7 @@ private: unsigned meta_blocks { 0 }; }; - BlockListShape compute_block_list_shape(unsigned blocks); + BlockListShape compute_block_list_shape(unsigned blocks) const; unsigned m_block_group_count { 0 }; |