mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 14:35:07 +00:00
Kernel: Make InodeVMOBject construction OOM-aware
This commit moves the allocation of the resources required for InodeVMObject from its constructors to the constructors of its child classes. We're making this change to give the child classes the chance to expose the fallibility of the allocation.
This commit is contained in:
parent
3879e70447
commit
ad480ff18b
4 changed files with 10 additions and 10 deletions
|
@ -9,15 +9,15 @@
|
||||||
|
|
||||||
namespace Kernel::Memory {
|
namespace Kernel::Memory {
|
||||||
|
|
||||||
InodeVMObject::InodeVMObject(Inode& inode, size_t size)
|
InodeVMObject::InodeVMObject(Inode& inode, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages)
|
||||||
: VMObject(VMObject::must_create_physical_pages_but_fixme_should_propagate_errors(size))
|
: VMObject(move(new_physical_pages))
|
||||||
, m_inode(inode)
|
, m_inode(inode)
|
||||||
, m_dirty_pages(page_count(), false)
|
, m_dirty_pages(page_count(), false)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
InodeVMObject::InodeVMObject(InodeVMObject const& other)
|
InodeVMObject::InodeVMObject(InodeVMObject const& other, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages)
|
||||||
: VMObject(other.must_clone_physical_pages_but_fixme_should_propagate_errors())
|
: VMObject(move(new_physical_pages))
|
||||||
, m_inode(other.m_inode)
|
, m_inode(other.m_inode)
|
||||||
, m_dirty_pages(page_count(), false)
|
, m_dirty_pages(page_count(), false)
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,8 +28,8 @@ public:
|
||||||
u32 executable_mappings() const;
|
u32 executable_mappings() const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit InodeVMObject(Inode&, size_t);
|
explicit InodeVMObject(Inode&, FixedArray<RefPtr<PhysicalPage>>&&);
|
||||||
explicit InodeVMObject(InodeVMObject const&);
|
explicit InodeVMObject(InodeVMObject const&, FixedArray<RefPtr<PhysicalPage>>&&);
|
||||||
|
|
||||||
InodeVMObject& operator=(InodeVMObject const&) = delete;
|
InodeVMObject& operator=(InodeVMObject const&) = delete;
|
||||||
InodeVMObject& operator=(InodeVMObject&&) = delete;
|
InodeVMObject& operator=(InodeVMObject&&) = delete;
|
||||||
|
|
|
@ -20,12 +20,12 @@ ErrorOr<NonnullRefPtr<VMObject>> PrivateInodeVMObject::try_clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
PrivateInodeVMObject::PrivateInodeVMObject(Inode& inode, size_t size)
|
PrivateInodeVMObject::PrivateInodeVMObject(Inode& inode, size_t size)
|
||||||
: InodeVMObject(inode, size)
|
: InodeVMObject(inode, VMObject::must_create_physical_pages_but_fixme_should_propagate_errors(size))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
PrivateInodeVMObject::PrivateInodeVMObject(PrivateInodeVMObject const& other)
|
PrivateInodeVMObject::PrivateInodeVMObject(PrivateInodeVMObject const& other)
|
||||||
: InodeVMObject(other)
|
: InodeVMObject(other, other.must_clone_physical_pages_but_fixme_should_propagate_errors())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,12 +26,12 @@ ErrorOr<NonnullRefPtr<VMObject>> SharedInodeVMObject::try_clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedInodeVMObject::SharedInodeVMObject(Inode& inode, size_t size)
|
SharedInodeVMObject::SharedInodeVMObject(Inode& inode, size_t size)
|
||||||
: InodeVMObject(inode, size)
|
: InodeVMObject(inode, VMObject::must_create_physical_pages_but_fixme_should_propagate_errors(size))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedInodeVMObject::SharedInodeVMObject(SharedInodeVMObject const& other)
|
SharedInodeVMObject::SharedInodeVMObject(SharedInodeVMObject const& other)
|
||||||
: InodeVMObject(other)
|
: InodeVMObject(other, other.must_clone_physical_pages_but_fixme_should_propagate_errors())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue