1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-24 01:05:08 +00:00

Kernel: Remove the now defunct LOCKER(..) macro.

This commit is contained in:
Brian Gianforcaro 2021-04-24 15:27:32 -07:00 committed by Andreas Kling
parent 0d5827f865
commit 8d6e9fad40
31 changed files with 196 additions and 198 deletions

View file

@ -69,7 +69,7 @@ Ext2FS::~Ext2FS()
bool Ext2FS::flush_super_block()
{
LOCKER(m_lock);
Locker locker(m_lock);
VERIFY((sizeof(ext2_super_block) % logical_block_size()) == 0);
auto super_block_buffer = UserOrKernelBuffer::for_kernel_buffer((u8*)&m_super_block);
bool success = raw_write_blocks(2, (sizeof(ext2_super_block) / logical_block_size()), super_block_buffer);
@ -87,7 +87,7 @@ const ext2_group_desc& Ext2FS::group_descriptor(GroupIndex group_index) const
bool Ext2FS::initialize()
{
LOCKER(m_lock);
Locker locker(m_lock);
VERIFY((sizeof(ext2_super_block) % logical_block_size()) == 0);
auto super_block_buffer = UserOrKernelBuffer::for_kernel_buffer((u8*)&m_super_block);
bool success = raw_read_blocks(2, (sizeof(ext2_super_block) / logical_block_size()), super_block_buffer);
@ -387,7 +387,7 @@ KResult Ext2FSInode::shrink_triply_indirect_block(BlockBasedFS::BlockIndex block
KResult Ext2FSInode::flush_block_list()
{
LOCKER(m_lock);
Locker locker(m_lock);
if (m_block_list.is_empty()) {
m_raw_inode.i_blocks = 0;
@ -628,7 +628,7 @@ Vector<Ext2FS::BlockIndex> Ext2FSInode::compute_block_list_impl_internal(const e
void Ext2FS::free_inode(Ext2FSInode& inode)
{
LOCKER(m_lock);
Locker locker(m_lock);
VERIFY(inode.m_raw_inode.i_links_count == 0);
dbgln_if(EXT2_DEBUG, "Ext2FS[{}]::free_inode(): Inode {} has no more links, time to delete!", fsid(), inode.index());
@ -662,7 +662,7 @@ void Ext2FS::free_inode(Ext2FSInode& inode)
void Ext2FS::flush_block_group_descriptor_table()
{
LOCKER(m_lock);
Locker locker(m_lock);
unsigned blocks_to_write = ceil_div(m_block_group_count * sizeof(ext2_group_desc), block_size());
unsigned first_block_of_bgdt = block_size() == 1024 ? 2 : 1;
auto buffer = UserOrKernelBuffer::for_kernel_buffer((u8*)block_group_descriptors());
@ -672,7 +672,7 @@ void Ext2FS::flush_block_group_descriptor_table()
void Ext2FS::flush_writes()
{
LOCKER(m_lock);
Locker locker(m_lock);
if (m_super_block_dirty) {
flush_super_block();
m_super_block_dirty = false;
@ -732,7 +732,7 @@ u64 Ext2FSInode::size() const
InodeMetadata Ext2FSInode::metadata() const
{
LOCKER(m_lock);
Locker locker(m_lock);
InodeMetadata metadata;
metadata.inode = identifier();
metadata.size = size();
@ -759,7 +759,7 @@ InodeMetadata Ext2FSInode::metadata() const
void Ext2FSInode::flush_metadata()
{
LOCKER(m_lock);
Locker locker(m_lock);
dbgln_if(EXT2_DEBUG, "Ext2FSInode[{}]::flush_metadata(): Flushing inode", identifier());
fs().write_ext2_inode(index(), m_raw_inode);
if (is_directory()) {
@ -774,7 +774,7 @@ void Ext2FSInode::flush_metadata()
RefPtr<Inode> Ext2FS::get_inode(InodeIdentifier inode) const
{
LOCKER(m_lock);
Locker locker(m_lock);
VERIFY(inode.fsid() == fsid());
{
@ -1049,7 +1049,7 @@ Ext2FS::FeaturesReadOnly Ext2FS::get_features_readonly() const
KResult Ext2FSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntryView&)> callback) const
{
LOCKER(m_lock);
Locker locker(m_lock);
VERIFY(is_directory());
auto buffer_or = read_entire();
@ -1073,7 +1073,7 @@ KResult Ext2FSInode::traverse_as_directory(Function<bool(const FS::DirectoryEntr
KResult Ext2FSInode::write_directory(const Vector<Ext2FSDirectoryEntry>& entries)
{
LOCKER(m_lock);
Locker locker(m_lock);
int directory_size = 0;
for (auto& entry : entries)
@ -1130,7 +1130,7 @@ KResultOr<NonnullRefPtr<Inode>> Ext2FSInode::create_child(const String& name, mo
KResult Ext2FSInode::add_child(Inode& child, const StringView& name, mode_t mode)
{
LOCKER(m_lock);
Locker locker(m_lock);
VERIFY(is_directory());
if (name.length() > EXT2_NAME_LEN)
@ -1173,7 +1173,7 @@ KResult Ext2FSInode::add_child(Inode& child, const StringView& name, mode_t mode
KResult Ext2FSInode::remove_child(const StringView& name)
{
LOCKER(m_lock);
Locker locker(m_lock);
dbgln_if(EXT2_DEBUG, "Ext2FSInode[{}]::remove_child(): Removing '{}'", identifier(), name);
VERIFY(is_directory());
@ -1239,7 +1239,7 @@ bool Ext2FS::write_ext2_inode(InodeIndex inode, const ext2_inode& e2inode)
auto Ext2FS::allocate_blocks(GroupIndex preferred_group_index, size_t count) -> KResultOr<Vector<BlockIndex>>
{
LOCKER(m_lock);
Locker locker(m_lock);
dbgln_if(EXT2_DEBUG, "Ext2FS: allocate_blocks(preferred group: {}, count {})", preferred_group_index, count);
if (count == 0)
return Vector<BlockIndex> {};
@ -1304,7 +1304,7 @@ auto Ext2FS::allocate_blocks(GroupIndex preferred_group_index, size_t count) ->
KResultOr<InodeIndex> Ext2FS::allocate_inode(GroupIndex preferred_group)
{
dbgln_if(EXT2_DEBUG, "Ext2FS: allocate_inode(preferred_group: {})", preferred_group);
LOCKER(m_lock);
Locker locker(m_lock);
// FIXME: We shouldn't refuse to allocate an inode if there is no group that can house the whole thing.
// In those cases we should just spread it across multiple groups.
@ -1380,7 +1380,7 @@ auto Ext2FS::group_index_from_inode(InodeIndex inode) const -> GroupIndex
KResultOr<bool> Ext2FS::get_inode_allocation_state(InodeIndex index) const
{
LOCKER(m_lock);
Locker locker(m_lock);
if (index == 0)
return EINVAL;
auto group_index = group_index_from_inode(index);
@ -1423,7 +1423,7 @@ KResult Ext2FS::update_bitmap_block(BlockIndex bitmap_block, size_t bit_index, b
KResult Ext2FS::set_inode_allocation_state(InodeIndex inode_index, bool new_state)
{
LOCKER(m_lock);
Locker locker(m_lock);
auto group_index = group_index_from_inode(inode_index);
unsigned index_in_group = inode_index.value() - ((group_index.value() - 1) * inodes_per_group());
unsigned bit_index = (index_in_group - 1) % inodes_per_group();
@ -1458,7 +1458,7 @@ KResultOr<Ext2FS::CachedBitmap*> Ext2FS::get_bitmap_block(BlockIndex bitmap_bloc
KResult Ext2FS::set_block_allocation_state(BlockIndex block_index, bool new_state)
{
VERIFY(block_index != 0);
LOCKER(m_lock);
Locker locker(m_lock);
auto group_index = group_index_from_block_index(block_index);
unsigned index_in_group = (block_index.value() - first_block_index().value()) - ((group_index.value() - 1) * blocks_per_group());
@ -1471,7 +1471,7 @@ KResult Ext2FS::set_block_allocation_state(BlockIndex block_index, bool new_stat
KResult Ext2FS::create_directory(Ext2FSInode& parent_inode, const String& name, mode_t mode, uid_t uid, gid_t gid)
{
LOCKER(m_lock);
Locker locker(m_lock);
VERIFY(is_directory(mode));
auto inode_or_error = create_inode(parent_inode, name, mode, 0, uid, gid);
@ -1546,7 +1546,7 @@ KResultOr<NonnullRefPtr<Inode>> Ext2FS::create_inode(Ext2FSInode& parent_inode,
bool Ext2FSInode::populate_lookup_cache() const
{
LOCKER(m_lock);
Locker locker(m_lock);
if (!m_lookup_cache.is_empty())
return true;
HashMap<String, InodeIndex> children;
@ -1571,7 +1571,7 @@ RefPtr<Inode> Ext2FSInode::lookup(StringView name)
dbgln_if(EXT2_DEBUG, "Ext2FSInode[{}]:lookup(): Looking up '{}'", identifier(), name);
if (!populate_lookup_cache())
return {};
LOCKER(m_lock);
Locker locker(m_lock);
auto it = m_lookup_cache.find(name.hash(), [&](auto& entry) { return entry.key == name; });
if (it != m_lookup_cache.end())
return fs().get_inode({ fsid(), (*it).value });
@ -1586,7 +1586,7 @@ void Ext2FSInode::one_ref_left()
int Ext2FSInode::set_atime(time_t t)
{
LOCKER(m_lock);
Locker locker(m_lock);
if (fs().is_readonly())
return -EROFS;
m_raw_inode.i_atime = t;
@ -1596,7 +1596,7 @@ int Ext2FSInode::set_atime(time_t t)
int Ext2FSInode::set_ctime(time_t t)
{
LOCKER(m_lock);
Locker locker(m_lock);
if (fs().is_readonly())
return -EROFS;
m_raw_inode.i_ctime = t;
@ -1606,7 +1606,7 @@ int Ext2FSInode::set_ctime(time_t t)
int Ext2FSInode::set_mtime(time_t t)
{
LOCKER(m_lock);
Locker locker(m_lock);
if (fs().is_readonly())
return -EROFS;
m_raw_inode.i_mtime = t;
@ -1616,7 +1616,7 @@ int Ext2FSInode::set_mtime(time_t t)
KResult Ext2FSInode::increment_link_count()
{
LOCKER(m_lock);
Locker locker(m_lock);
if (fs().is_readonly())
return EROFS;
if (m_raw_inode.i_links_count == max_link_count)
@ -1628,7 +1628,7 @@ KResult Ext2FSInode::increment_link_count()
KResult Ext2FSInode::decrement_link_count()
{
LOCKER(m_lock);
Locker locker(m_lock);
if (fs().is_readonly())
return EROFS;
VERIFY(m_raw_inode.i_links_count);
@ -1641,21 +1641,21 @@ KResult Ext2FSInode::decrement_link_count()
void Ext2FS::uncache_inode(InodeIndex index)
{
LOCKER(m_lock);
Locker locker(m_lock);
m_inode_cache.remove(index);
}
KResultOr<size_t> Ext2FSInode::directory_entry_count() const
{
VERIFY(is_directory());
LOCKER(m_lock);
Locker locker(m_lock);
populate_lookup_cache();
return m_lookup_cache.size();
}
KResult Ext2FSInode::chmod(mode_t mode)
{
LOCKER(m_lock);
Locker locker(m_lock);
if (m_raw_inode.i_mode == mode)
return KSuccess;
m_raw_inode.i_mode = mode;
@ -1665,7 +1665,7 @@ KResult Ext2FSInode::chmod(mode_t mode)
KResult Ext2FSInode::chown(uid_t uid, gid_t gid)
{
LOCKER(m_lock);
Locker locker(m_lock);
if (m_raw_inode.i_uid == uid && m_raw_inode.i_gid == gid)
return KSuccess;
m_raw_inode.i_uid = uid;
@ -1676,7 +1676,7 @@ KResult Ext2FSInode::chown(uid_t uid, gid_t gid)
KResult Ext2FSInode::truncate(u64 size)
{
LOCKER(m_lock);
Locker locker(m_lock);
if (static_cast<u64>(m_raw_inode.i_size) == size)
return KSuccess;
if (auto result = resize(size); result.is_error())
@ -1687,7 +1687,7 @@ KResult Ext2FSInode::truncate(u64 size)
KResultOr<int> Ext2FSInode::get_block_address(int index)
{
LOCKER(m_lock);
Locker locker(m_lock);
if (m_block_list.is_empty())
m_block_list = compute_block_list();
@ -1700,31 +1700,31 @@ KResultOr<int> Ext2FSInode::get_block_address(int index)
unsigned Ext2FS::total_block_count() const
{
LOCKER(m_lock);
Locker locker(m_lock);
return super_block().s_blocks_count;
}
unsigned Ext2FS::free_block_count() const
{
LOCKER(m_lock);
Locker locker(m_lock);
return super_block().s_free_blocks_count;
}
unsigned Ext2FS::total_inode_count() const
{
LOCKER(m_lock);
Locker locker(m_lock);
return super_block().s_inodes_count;
}
unsigned Ext2FS::free_inode_count() const
{
LOCKER(m_lock);
Locker locker(m_lock);
return super_block().s_free_inodes_count;
}
KResult Ext2FS::prepare_to_unmount() const
{
LOCKER(m_lock);
Locker locker(m_lock);
for (auto& it : m_inode_cache) {
if (it.value->ref_count() > 1)