summaryrefslogtreecommitdiff
path: root/Kernel/Memory
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@gmail.com>2022-02-10 19:39:17 +0200
committerIdan Horowitz <idan.horowitz@gmail.com>2022-02-11 17:49:46 +0200
commitd9d33627223f4b713b0ca17ccd99b6a15c89745e (patch)
tree5f5063dc5673a74741294303967d20c8bedcf974 /Kernel/Memory
parent8030e2a88f8b6c9a78ac9734fb2c08071f8d3d70 (diff)
downloadserenity-d9d33627223f4b713b0ca17ccd99b6a15c89745e.zip
Kernel: Make SharedInodeVMObject pages Bitmap allocation OOM-fallible
Diffstat (limited to 'Kernel/Memory')
-rw-r--r--Kernel/Memory/InodeVMObject.cpp8
-rw-r--r--Kernel/Memory/InodeVMObject.h4
-rw-r--r--Kernel/Memory/PrivateInodeVMObject.cpp14
-rw-r--r--Kernel/Memory/PrivateInodeVMObject.h4
-rw-r--r--Kernel/Memory/SharedInodeVMObject.cpp14
-rw-r--r--Kernel/Memory/SharedInodeVMObject.h4
6 files changed, 26 insertions, 22 deletions
diff --git a/Kernel/Memory/InodeVMObject.cpp b/Kernel/Memory/InodeVMObject.cpp
index 9642454416..a072968d85 100644
--- a/Kernel/Memory/InodeVMObject.cpp
+++ b/Kernel/Memory/InodeVMObject.cpp
@@ -9,17 +9,17 @@
namespace Kernel::Memory {
-InodeVMObject::InodeVMObject(Inode& inode, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages)
+InodeVMObject::InodeVMObject(Inode& inode, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages, Bitmap dirty_pages)
: VMObject(move(new_physical_pages))
, m_inode(inode)
- , m_dirty_pages(Bitmap::try_create(page_count(), false).release_value_but_fixme_should_propagate_errors())
+ , m_dirty_pages(move(dirty_pages))
{
}
-InodeVMObject::InodeVMObject(InodeVMObject const& other, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages)
+InodeVMObject::InodeVMObject(InodeVMObject const& other, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages, Bitmap dirty_pages)
: VMObject(move(new_physical_pages))
, m_inode(other.m_inode)
- , m_dirty_pages(Bitmap::try_create(page_count(), false).release_value_but_fixme_should_propagate_errors())
+ , m_dirty_pages(move(dirty_pages))
{
for (size_t i = 0; i < page_count(); ++i)
m_dirty_pages.set(i, other.m_dirty_pages.get(i));
diff --git a/Kernel/Memory/InodeVMObject.h b/Kernel/Memory/InodeVMObject.h
index 33898faf10..6f9500c933 100644
--- a/Kernel/Memory/InodeVMObject.h
+++ b/Kernel/Memory/InodeVMObject.h
@@ -28,8 +28,8 @@ public:
u32 executable_mappings() const;
protected:
- explicit InodeVMObject(Inode&, FixedArray<RefPtr<PhysicalPage>>&&);
- explicit InodeVMObject(InodeVMObject const&, FixedArray<RefPtr<PhysicalPage>>&&);
+ explicit InodeVMObject(Inode&, FixedArray<RefPtr<PhysicalPage>>&&, Bitmap dirty_pages);
+ explicit InodeVMObject(InodeVMObject const&, FixedArray<RefPtr<PhysicalPage>>&&, Bitmap dirty_pages);
InodeVMObject& operator=(InodeVMObject const&) = delete;
InodeVMObject& operator=(InodeVMObject&&) = delete;
diff --git a/Kernel/Memory/PrivateInodeVMObject.cpp b/Kernel/Memory/PrivateInodeVMObject.cpp
index adc965b791..623e02776f 100644
--- a/Kernel/Memory/PrivateInodeVMObject.cpp
+++ b/Kernel/Memory/PrivateInodeVMObject.cpp
@@ -12,22 +12,24 @@ namespace Kernel::Memory {
ErrorOr<NonnullRefPtr<PrivateInodeVMObject>> PrivateInodeVMObject::try_create_with_inode(Inode& inode)
{
auto new_physical_pages = TRY(VMObject::try_create_physical_pages(inode.size()));
- return adopt_nonnull_ref_or_enomem(new (nothrow) PrivateInodeVMObject(inode, move(new_physical_pages)));
+ auto dirty_pages = TRY(Bitmap::try_create(new_physical_pages.size(), false));
+ return adopt_nonnull_ref_or_enomem(new (nothrow) PrivateInodeVMObject(inode, move(new_physical_pages), move(dirty_pages)));
}
ErrorOr<NonnullRefPtr<VMObject>> PrivateInodeVMObject::try_clone()
{
auto new_physical_pages = TRY(this->try_clone_physical_pages());
- return adopt_nonnull_ref_or_enomem<VMObject>(new (nothrow) PrivateInodeVMObject(*this, move(new_physical_pages)));
+ auto dirty_pages = TRY(Bitmap::try_create(new_physical_pages.size(), false));
+ return adopt_nonnull_ref_or_enomem<VMObject>(new (nothrow) PrivateInodeVMObject(*this, move(new_physical_pages), move(dirty_pages)));
}
-PrivateInodeVMObject::PrivateInodeVMObject(Inode& inode, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages)
- : InodeVMObject(inode, move(new_physical_pages))
+PrivateInodeVMObject::PrivateInodeVMObject(Inode& inode, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages, Bitmap dirty_pages)
+ : InodeVMObject(inode, move(new_physical_pages), move(dirty_pages))
{
}
-PrivateInodeVMObject::PrivateInodeVMObject(PrivateInodeVMObject const& other, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages)
- : InodeVMObject(other, move(new_physical_pages))
+PrivateInodeVMObject::PrivateInodeVMObject(PrivateInodeVMObject const& other, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages, Bitmap dirty_pages)
+ : InodeVMObject(other, move(new_physical_pages), move(dirty_pages))
{
}
diff --git a/Kernel/Memory/PrivateInodeVMObject.h b/Kernel/Memory/PrivateInodeVMObject.h
index b3efadcc7e..6b480832e3 100644
--- a/Kernel/Memory/PrivateInodeVMObject.h
+++ b/Kernel/Memory/PrivateInodeVMObject.h
@@ -23,8 +23,8 @@ public:
private:
virtual bool is_private_inode() const override { return true; }
- explicit PrivateInodeVMObject(Inode&, FixedArray<RefPtr<PhysicalPage>>&&);
- explicit PrivateInodeVMObject(PrivateInodeVMObject const&, FixedArray<RefPtr<PhysicalPage>>&&);
+ explicit PrivateInodeVMObject(Inode&, FixedArray<RefPtr<PhysicalPage>>&&, Bitmap dirty_pages);
+ explicit PrivateInodeVMObject(PrivateInodeVMObject const&, FixedArray<RefPtr<PhysicalPage>>&&, Bitmap dirty_pages);
virtual StringView class_name() const override { return "PrivateInodeVMObject"sv; }
diff --git a/Kernel/Memory/SharedInodeVMObject.cpp b/Kernel/Memory/SharedInodeVMObject.cpp
index 650455ef06..fdda7d7860 100644
--- a/Kernel/Memory/SharedInodeVMObject.cpp
+++ b/Kernel/Memory/SharedInodeVMObject.cpp
@@ -16,7 +16,8 @@ ErrorOr<NonnullRefPtr<SharedInodeVMObject>> SharedInodeVMObject::try_create_with
if (auto shared_vmobject = inode.shared_vmobject())
return shared_vmobject.release_nonnull();
auto new_physical_pages = TRY(VMObject::try_create_physical_pages(size));
- auto vmobject = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) SharedInodeVMObject(inode, move(new_physical_pages))));
+ auto dirty_pages = TRY(Bitmap::try_create(new_physical_pages.size(), false));
+ auto vmobject = TRY(adopt_nonnull_ref_or_enomem(new (nothrow) SharedInodeVMObject(inode, move(new_physical_pages), move(dirty_pages))));
vmobject->inode().set_shared_vmobject(*vmobject);
return vmobject;
}
@@ -24,16 +25,17 @@ ErrorOr<NonnullRefPtr<SharedInodeVMObject>> SharedInodeVMObject::try_create_with
ErrorOr<NonnullRefPtr<VMObject>> SharedInodeVMObject::try_clone()
{
auto new_physical_pages = TRY(this->try_clone_physical_pages());
- return adopt_nonnull_ref_or_enomem<VMObject>(new (nothrow) SharedInodeVMObject(*this, move(new_physical_pages)));
+ auto dirty_pages = TRY(Bitmap::try_create(new_physical_pages.size(), false));
+ return adopt_nonnull_ref_or_enomem<VMObject>(new (nothrow) SharedInodeVMObject(*this, move(new_physical_pages), move(dirty_pages)));
}
-SharedInodeVMObject::SharedInodeVMObject(Inode& inode, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages)
- : InodeVMObject(inode, move(new_physical_pages))
+SharedInodeVMObject::SharedInodeVMObject(Inode& inode, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages, Bitmap dirty_pages)
+ : InodeVMObject(inode, move(new_physical_pages), move(dirty_pages))
{
}
-SharedInodeVMObject::SharedInodeVMObject(SharedInodeVMObject const& other, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages)
- : InodeVMObject(other, move(new_physical_pages))
+SharedInodeVMObject::SharedInodeVMObject(SharedInodeVMObject const& other, FixedArray<RefPtr<PhysicalPage>>&& new_physical_pages, Bitmap dirty_pages)
+ : InodeVMObject(other, move(new_physical_pages), move(dirty_pages))
{
}
diff --git a/Kernel/Memory/SharedInodeVMObject.h b/Kernel/Memory/SharedInodeVMObject.h
index 2c38eead01..75d3637808 100644
--- a/Kernel/Memory/SharedInodeVMObject.h
+++ b/Kernel/Memory/SharedInodeVMObject.h
@@ -23,8 +23,8 @@ public:
private:
virtual bool is_shared_inode() const override { return true; }
- explicit SharedInodeVMObject(Inode&, FixedArray<RefPtr<PhysicalPage>>&&);
- explicit SharedInodeVMObject(SharedInodeVMObject const&, FixedArray<RefPtr<PhysicalPage>>&&);
+ explicit SharedInodeVMObject(Inode&, FixedArray<RefPtr<PhysicalPage>>&&, Bitmap dirty_pages);
+ explicit SharedInodeVMObject(SharedInodeVMObject const&, FixedArray<RefPtr<PhysicalPage>>&&, Bitmap dirty_pages);
virtual StringView class_name() const override { return "SharedInodeVMObject"sv; }