Skip to content

core: Reduce amount of calls to getattr/Stat, improve vfs.read #157

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

kohlschuetter
Copy link
Contributor

For many operations, we currently call VirtualFileSystem#getattr(Inode), which gets a full set of "stat" metadata for a given Inode.

In many cases however, we're only interested in the type of the Inode (e.g., directory, regular file, symlink, etc.). Certain VirtualFileSystem implementations may be able to retrieve that specific information significantly faster than the full metadata set.

Replace calls to vfs.getattr(Inode).type() with vfs.getStatType() where applicable, and provide default implementations for backwards compatibility.

Also don't retrieve Stat information at all where not required:

  1. In PseudoFS.checkAccess with ACE4_READ_ATTRIBUTES, and

  2. For OperationREAD, allow VirtualFileSystem to skip the Stat check (currently checking StatType but also file size), which is currently done per every call to "read":

Clarify the requirement of signaling "eof reached" as per NFSv4 spec, provide a new read() method to VirtualFileSystem with a corresponding callback function, and provide a default implementation for backwards compatibility.

For many operations, we currently call VirtualFileSystem#getattr(Inode),
which gets a full set of "stat" metadata for a given Inode.

In many cases however, we're only interested in the type of the Inode
(e.g., directory, regular file, symlink, etc.). Certain
VirtualFileSystem implementations may be able to retrieve that specific
information significantly faster than the full metadata set.

Replace calls to vfs.getattr(Inode).type() with vfs.getStatType() where
applicable, and provide default implementations for backwards
compatibility.

Also don't retrieve Stat information at all where not required:

1. In PseudoFS.checkAccess with ACE4_READ_ATTRIBUTES, and

2. For OperationREAD, allow VirtualFileSystem to skip the Stat check
(currently checking StatType but also file size), which is currently
done per every call to "read":

Clarify the requirement of signaling "eof reached" as per NFSv4 spec,
provide a new read() method to VirtualFileSystem with a corresponding
callback function, and provide a default implementation for backwards
compatibility.

Signed-off-by: Christian Kohlschütter <[email protected]>
Signed-off-by: Christian Kohlschütter <[email protected]>
@kofemann
Copy link
Member

Are there any benchmarks that justify this change? Almost all operations are subject to permission checks, thus, file attributes are almost always required. To reduce the number of filesystem calls, we use VfsCache which aggressively caches getattrs.

@kohlschuetter
Copy link
Contributor Author

The file type can (in many cases) be encoded directly in the Inode file handle, which means that the lookup is free.
Currently, we ask for "Stat" for every read and write, which is extremely suboptimal.

Caching can only go so far, especially when the file can be modified outside of nfs4j.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants