1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 05:48:12 +00:00

Kernel: Deemphasize inode identifiers

These APIs were clearly modeled after Ext2FS internals, and make perfect sense
in Ext2FS context. The new APIs are more generic, and map better to the
semantics exported to the userspace, where inode identifiers only appear in
stat() and readdir() output, but never in any input.

This will also hopefully reduce the potential for races (see commit c44b4d61f3).

Lastly, this makes it way more viable to implement a filesystem that only
synthesizes its inodes lazily when queried, and destroys them when they are no
longer in use. With inode identifiers being used to reference inodes, the only
choice for such a filesystem is to persist any inode it has given out the
identifier for, because it might be queried at any later time. With direct
references to inodes, the filesystem will know when the last reference is
dropped and the inode can be safely destroyed.
This commit is contained in:
Sergey Bugaev 2020-06-24 23:35:56 +03:00 committed by Andreas Kling
parent c689be0dbc
commit df66c28479
12 changed files with 133 additions and 160 deletions

View file

@ -63,7 +63,8 @@ private:
virtual RefPtr<Inode> lookup(StringView name) override;
virtual void flush_metadata() override;
virtual ssize_t write_bytes(off_t, ssize_t, const u8* data, FileDescription*) override;
virtual KResult add_child(InodeIdentifier child_id, const StringView& name, mode_t) override;
virtual KResultOr<NonnullRefPtr<Inode>> create_child(const String& name, mode_t, dev_t, uid_t, gid_t) override;
virtual KResult add_child(Inode& child, const StringView& name, mode_t) override;
virtual KResult remove_child(const StringView& name) override;
virtual int set_atime(time_t) override;
virtual int set_ctime(time_t) override;
@ -128,9 +129,9 @@ private:
bool flush_super_block();
virtual const char* class_name() const override;
virtual InodeIdentifier root_inode() const override;
virtual KResultOr<NonnullRefPtr<Inode>> create_inode(InodeIdentifier parent_id, const String& name, mode_t, off_t size, dev_t, uid_t, gid_t) override;
virtual KResult create_directory(InodeIdentifier parent_inode, const String& name, mode_t, uid_t, gid_t) override;
virtual NonnullRefPtr<Inode> root_inode() const override;
KResultOr<NonnullRefPtr<Inode>> create_inode(InodeIdentifier parent_id, const String& name, mode_t, off_t size, dev_t, uid_t, gid_t);
KResult create_directory(InodeIdentifier parent_inode, const String& name, mode_t, uid_t, gid_t);
virtual RefPtr<Inode> get_inode(InodeIdentifier) const override;
virtual void flush_writes() override;