Skip to content

Commit bab24ce

Browse files
committed
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.
1 parent 508063e commit bab24ce

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

Kernel/FileSystem/Ext2FileSystem.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ bool Ext2FS::find_block_containing_inode(unsigned inode, unsigned& block_index,
184184
return true;
185185
}
186186

187-
Ext2FS::BlockListShape Ext2FS::compute_block_list_shape(unsigned blocks)
187+
Ext2FS::BlockListShape Ext2FS::compute_block_list_shape(unsigned blocks) const
188188
{
189189
BlockListShape shape;
190190
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
440440
#endif
441441

442442
unsigned blocks_remaining = block_count;
443+
444+
if (include_block_list_blocks) {
445+
auto shape = compute_block_list_shape(block_count);
446+
blocks_remaining += shape.meta_blocks;
447+
}
448+
443449
Vector<BlockIndex> list;
444450

445451
auto add_block = [&](BlockIndex bi) {

Kernel/FileSystem/Ext2FileSystem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ class Ext2FS final : public BlockBasedFS {
165165
unsigned meta_blocks { 0 };
166166
};
167167

168-
BlockListShape compute_block_list_shape(unsigned blocks);
168+
BlockListShape compute_block_list_shape(unsigned blocks) const;
169169

170170
unsigned m_block_group_count { 0 };
171171

0 commit comments

Comments
 (0)