From 75a6b27f7381d49563bfa034bea9d2918d14a995 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 6 Mar 2020 11:15:03 +0100 Subject: [PATCH] Ext2FS: Remove unused allocate_block() We only use allocate_blocks() now. If you want a single block, you can just call allocate_blocks() with a count of 1. --- Kernel/FileSystem/Ext2FileSystem.cpp | 34 ---------------------------- Kernel/FileSystem/Ext2FileSystem.h | 1 - 2 files changed, 35 deletions(-) diff --git a/Kernel/FileSystem/Ext2FileSystem.cpp b/Kernel/FileSystem/Ext2FileSystem.cpp index d2a45f36e1..179b041c4b 100644 --- a/Kernel/FileSystem/Ext2FileSystem.cpp +++ b/Kernel/FileSystem/Ext2FileSystem.cpp @@ -1049,40 +1049,6 @@ bool Ext2FS::write_ext2_inode(unsigned inode, const ext2_inode& e2inode) return success; } -Ext2FS::BlockIndex Ext2FS::allocate_block(GroupIndex preferred_group_index) -{ - LOCKER(m_lock); -#ifdef EXT2_DEBUG - dbg() << "Ext2FS: allocate_block() preferred_group_index: " << preferred_group_index; -#endif - bool found_a_group = false; - GroupIndex group_index = preferred_group_index; - - if (group_descriptor(preferred_group_index).bg_free_blocks_count) { - found_a_group = true; - } else { - for (group_index = 1; group_index < m_block_group_count; ++group_index) { - if (group_descriptor(group_index).bg_free_blocks_count) { - found_a_group = true; - break; - } - } - } - ASSERT(found_a_group); - auto& bgd = group_descriptor(group_index); - auto& cached_bitmap = get_bitmap_block(bgd.bg_block_bitmap); - - int blocks_in_group = min(blocks_per_group(), super_block().s_blocks_count); - auto block_bitmap = Bitmap::wrap(cached_bitmap.buffer.data(), blocks_in_group); - - BlockIndex first_block_in_group = (group_index - 1) * blocks_per_group() + first_block_index(); - auto first_unset_bit_index = block_bitmap.find_first_unset(); - ASSERT(first_unset_bit_index.has_value()); - BlockIndex block_index = first_unset_bit_index.value() + first_block_in_group; - set_block_allocation_state(block_index, true); - return block_index; -} - Vector Ext2FS::allocate_blocks(GroupIndex preferred_group_index, size_t count) { LOCKER(m_lock); diff --git a/Kernel/FileSystem/Ext2FileSystem.h b/Kernel/FileSystem/Ext2FileSystem.h index 3185a5a567..526d40db87 100644 --- a/Kernel/FileSystem/Ext2FileSystem.h +++ b/Kernel/FileSystem/Ext2FileSystem.h @@ -136,7 +136,6 @@ private: BlockIndex first_block_index() const; InodeIndex find_a_free_inode(GroupIndex preferred_group, off_t expected_size); Vector allocate_blocks(GroupIndex preferred_group_index, size_t count); - BlockIndex allocate_block(GroupIndex preferred_group_index); GroupIndex group_index_from_inode(InodeIndex) const; GroupIndex group_index_from_block_index(BlockIndex) const;